Custom Control
Controls are the third plugin type — a DLL in the Controls folder next
to QInsight.exe. After restarting the application the control appears in the
Controls panel and can be dragged onto workspaces like any shipped element.
Basics
A control implements the IControlBase interface; in practice it inherits
from the ControlBase base class, which handles the common properties
(position, size, colors, locking, serialization of variable bindings).
The class needs a public parameterless constructor; put one control per
DLL. Key points:
ControlName,Label,Icon,Description— abstract properties;Labelis the text in the Controls panel,IconandDescription(tooltip) go with it.ControlBasebuilds the plugin specification from them and the assembly version.CanBindVariable(variable)— which variables the control accepts (e.g. scalars only); QInsight refuses a drop of any other.BindVariable(variable)— called when a variable is dropped onto the control. A single-value control (like Gauge) replaces the previous variable; a multi-value one (like Graph) adds it.UpdateVariableValueAsync(variable)— live values arrive here, on the UI thread, as a snapshot of the variable; the control manages its own redraw rate (Refresh time). By default the control gets only the latest value per UI tick; a control that needs every sample (graph) implements the marker interfaceISampleHistoryControl. Only values read from the device arrive — an operator write is not echoed.IsRun,OnEditToRun/OnRunToEdit— switching between the edit and runtime mode (protected virtual methods). The shipped controls empty their display on Edit → Run and show only values that then come from the device; the graph clears its data.Logger— the application log (ILogger); QInsight sets it after creating the control, never through the constructor.null= silent.- Writes and reads from the control — optional interfaces
IVariableWriteControl(Write Mode) andIVariableReadControl(the Read button for On Request variables). QInsight injects the delegates (CanWriteVariableProvider,WriteVariableEngValueAsync, resp.CanReadVariableProvider,ReadVariableAsync) and callsRefreshWriteCapability()/RefreshReadCapability(); the control itself knows nothing about drivers or protocols. - Saving into the project — the class is marked
[DataContract]and the properties that should survive saving[DataMember](the rest[IgnoreDataMember]). The workspace serializer only knows control types from assemblies whose name starts withQenex.QSuite.Controls(e.g.Qenex.QSuite.Controls.MyControl) — name the DLL that way.
The project is a WPF library (net10.0-windows, UseWPF) referencing
the Control project of QSuite (Controls/Control, which also brings in
the Telerik UI for WPF packages it builds on).
MVVM
The control UI is written strictly MVVM: composition in XAML,
interaction via bindings and commands, logic in the ViewModel — no logic in
code-behind. The class derived from ControlBase is the ViewModel;
QInsight finds the view (a UserControl in the same DLL) by the
ViewModel's type name without "Model" — e.g.
….ViewModels.MyControlViewModel → ….Views.MyControlView — and sets
the ViewModel as its DataContext. The shipped Single-Signal control
is the reference pattern.
Deployment
Copy the compiled DLL into the Controls folder next to QInsight.exe and
restart QInsight. The
control appears in the Controls panel; its bindings and settings are saved
into the project automatically.
Next
An overview of everything QInsight ships — Reference.

