Custom driver

A driver is a .NET library (DLL). QInsight discovers it automatically — the class just has to implement the IDriverBase interface and the DLL must sit in the Drivers folder next to QInsight.exe. No other registration is needed.

Driver skeleton

In practice you inherit from the ready-made DriverBase base class, which handles the common parts (protocols, states, settings):

public class MyDeviceDriver : DriverBase
{
    public MyDeviceDriver()   // a parameterless constructor is mandatory
    {
        Specification = new SpecificationBase
        {
            Name = "MyDeviceDriver",
            Label = "My Device",
            Version = "1.0.0",
        };
    }

    public override void SetConfiguration()
    {
        // parse RawSettings ("key=value;...") into your own fields
    }

    public override async Task StartAsync(CancellationToken ct)
    {
        // open the connection, start the read loop,
        // pass the received data to the protocols
    }

    public override async Task StopAsync(CancellationToken ct)
    {
        // stop the communication and release the connection
    }

    public override void Send<T>(T data) { /* send data to the device */ }
    public override Task SendAsync<T>(T data, CancellationToken ct)
        => Task.Run(() => Send(data), ct);

    public override void Dispose() { /* cleanup */ }
}

The driver reports its status by calling SetState(...) — the state shows up in the Logs window and in the UI.

Optional capabilities

Depending on its purpose, a driver implements additional interfaces:

  • IReplayDriver — the driver can replay a record (pause, seek, speed…),
  • IProtocolVariableSinkDriver — the driver consumes values (e.g. a logger),
  • IProtocolVariableCommandDriver — the driver accepts variable commands.

Deployment

Copy the compiled DLL into the Drivers folder. After restarting QInsight, the driver appears in the Home → Project Configuration → Drivers list. Only a reference (name + version) is stored in the project, so the project can be moved to another computer with the same driver set.

Next

Custom protocol.