Instrument#

class Instrument(
name: str,
publishers: list[Publisher] | None = None,
background_config: BackgroundDaemonConfig | None = None,
legacy_naming: bool = False,
**kwargs,
)[source]#

Bases: object

Base class for Nominal instrument interfaces. Owns publishing and the background daemon.

Initialize an Instrument.

Parameters:
  • name – Channel-name prefix for published data.

  • publishers – Publishers that receive emitted Measurement/Command data.

  • background_config – Background-daemon settings; default if omitted.

  • legacy_naming – When True, publish channels under their pre-v1.0 names (e.g. main.ch1_v instead of main.ch1.voltage for PSU) for dashboards or recorded datasets keyed on those names. The setting is all-or-nothing per instrument. PSU, ELoad, I2C, InstroScope, and DAQ digital channels honor the flag; the categories with no v1.0 rename (DMM, Modbus, DAQ analog and relay channels) ignore it. Scheduled for removal in v2.0.

  • **kwargs – Default tags applied to every emitted Measurement or Command. Pass dataset_rid="<rid>" to auto-create a NominalCorePublisher (uses the on-disk ‘default’ Nominal credential).

Attributes

background_interval

Seconds between background daemon iterations (0 = no wait).

channel_names

Return an insertion-ordered snapshot of all published channel names.

Methods

add_background_daemon_function

Append method to the daemon's call list.

add_publisher

Register a publisher to receive this instrument's Measurement/Command data.

close

Stop the background daemon and close every publisher.

define_background_daemon

Replace all daemon functions with a single method (called with the given args).

get_channel

Return the most recent length samples for channel_name from the in-memory buffer.

get_single_channel_value

Return the most recent sample for channel_name from the in-memory buffer.

open

No-op base hook.

publish

Fan data out to every configured publisher; kwargs pass through.

start

Start the background daemon thread.

stop

Signal the background daemon to stop and join it.

_package_command

Build a single-channel Command namespaced under this instrument.

_package_measurement

Build a single-channel Measurement namespaced under this instrument.