Library
Instrument
Instrument is the base class for all instrument types. Its responsibilities include:
- Handling background daemons for synchronous instrument communication.
- Holds the
publishers an instrument will use. - Creates and holds the communication interface for the instrument.
Instrument.
Measurements and Commands
Within anInstrument, data is packaged into Measurement and Command objects when data is read from or sent to an instrument, respectively.
The rationale for this is:
- Consistency regardless of instrument type or vendor.
- Interoperability of publishers across instrument types.
- Better integration with the Nominal ecosystem by enforcing that certain data, like timestamps, is always present.
Measurement and Command are defined in instro.lib.types and re-exported from instro.lib, so either import path works: from instro.lib import Measurement, Command or from instro.lib.types import Measurement, Command.
Measurement
AMeasurement object should be created when reading data from an instrument.
Command
ACommand object should be created when telling an instrument to do something.
Measurement, a Command carries a single datapoint per channel (float | str, not list[float]) and a single timestamp. The str option covers categorical commands whose value is not numeric: mode names and relay states such as OPEN / CLOSED.
Parameters
-
channel_data: dict[str, list[float]]This dictionary maps names (or numbers, as strings) to lists of numeric measurements. For example, if your instrument has channels"my_thermocouple1"and"my_thermocouple2", and you collected 10 samples from each,channel_datamight look like: -
timestamps: list[int]A list of timestamps in integer nanoseconds since the Unix epoch, one per measurement sample, aligned with the values inchannel_data. The length oftimestampsshould match the length of each list inchannel_data. -
tags: dict[str, str] | NoneOptional metadata associated with this measurement acquisition. Common tags include test IDs, operator name, or environmental qualifiers. Useful for search, provenance, and analysis.
Backwards-compatible channel naming (legacy_naming)
Every category instrument accepts a legacy_naming: bool = False keyword at construction. When set to True, the instrument publishes channels under their pre-v1.0 names.
- Backwards compatibility. If your dashboards or recorded datasets were keyed on the pre-v1.0 channel names, flip the flag on each instrument as a single-line stopgap while you update downstream consumers.
- Categories with a v1.0 rename (PSU, ELoad, I2C, DAQ digital channels, and the experimental
InstroScopeininstro-unstable) honor the flag. - Categories with no v1.0 rename (DMM, Modbus, DAQ analog/relay) ignore the flag (the published names are unchanged either way).
- All-or-nothing per instrument. There is no way to use new names for some channels and legacy for others on the same instance.
legacy_namingis scheduled for removal in v2.0. Plan to migrate downstream consumers within that window.