Simulated thermometer

The project Qenex_SimulTempMeasure.qproj is in the Examples folder next to QInsight.exe. It uses the pair of example plugins whose source code is explained in Example TempSensor: the Temperature Sensor (example) driver and the Temperature Sensor Protocol (example) protocol. The device is simulated inside the driver, so the project runs without hardware.

What the example shows

  • A custom driver with a write path: the driver hands the protocol text lines chN=value and receives commands from it to re-base a channel.
  • Three data types on the same kind of signal: double in °C, float converted to °F by a linear conversion, and int rounded by the protocol.
  • Operator writes from signal controls: the variables Temp1Set and Temp2Set send a new base value of channels 1 and 2 back to the device.
  • File logging through the File data logger driver and its replay.

What you need

Just QInsight. The plugins are part of the installation (the Drivers and Protocols folders next to QInsight.exe).

The project

Drivers and protocols

Temperature Sensor (example) driverMeaning
periodMs=200period in which the simulator transmits all channels
channels=3number of simulated channels (1 to 16)

The protocol has no settings. An unknown key in the driver or protocol settings ends up as a warning in the log, the same as with the built-in plugins.

The project also has a File data logger driver (file=DataLogs;append=true) and a File data replay driver (file=DataLogs\values.qilog;mode=realtime) for recording and replaying the measurement.

Variables

VariableTypeComm paramsPresentation
Temp1doubledirection="read";channel="ch1"°C
Temp2floatdirection="read";channel="ch2"°F, conversion eng = raw × 1.8 + 32
Temp3intdirection="read";channel="ch3"°C, rounded by the protocol
Temp1Setdoubledirection="write";channel="ch1"°C, a write re-bases channel 1
Temp2Setdoubledirection="write";channel="ch2"°C, a write re-bases channel 2

Workspace

A graph of the three channels, a gauge and five signal controls; Temp1Set and Temp2Set are in write mode.

What you will see and what to try

  • After Start the three channels slowly wander around their base values, Temp2 in degrees Fahrenheit.
  • Write e.g. 40 into Temp1Set: channel 1 jumps to the new base value and keeps wandering around it. The same with Temp2Set for channel 2, shown in °F on the graph.
  • Change channels=1 and Temp3 stops receiving data; periodMs=1000 slows all channels down.
  • Enable logging on the variables and replay the record with the File data replay driver after Stop.