InstroDMM#
- class InstroDMM(
- name: str | None = None,
- driver: DMMDriverBase | None = None,
- publishers: list[Publisher] | None = None,
- config: DMMConfig | dict | Path | str | None = None,
- autostart: bool = False,
- **kwargs,
Bases:
InstrumentDigital multimeter instrument. Call
set_measurement_functionthenread, or a singleread_<function>.Initialize an InstroDMM.
Provide either
configordriver, not both.- Parameters:
name
Channel-name prefix for published data. Falls back to
config.device.namewhenconfigis given.driver
Concrete DMM driver; owns its own transport:
dmm = InstroDMM( "main", driver=Agilent34401A("ASRL3::INSTR"), )
publishers
Publishers that receive emitted Measurement/Command data. Combined with any publishers declared in
config.config
A
DMMConfig, a dict, or a path to a JSON config file. Itsmeasurementblock is applied through the public setters onopen().autostart
When True, open the connection and start background polling. Requires
configwith ameasurementblock, since polling cannot start without a measurement function.**kwargs
Default tags applied to every emitted Measurement/Command. Pass
dataset_rid="<rid>"to auto-create a NominalCorePublisher (uses the on-disk ‘default’ Nominal credential).
Attributes
Seconds between background daemon iterations (0 = no wait).
Return an insertion-ordered snapshot of all published channel names.
Methods
Append
methodto the daemon's call list.Register a publisher to receive this instrument's Measurement/Command data.
Close the underlying driver and stop the daemon.
Replace all daemon functions with a single
method(called with the given args).Return the most recent
lengthsamples forchannel_namefrom the in-memory buffer.Return the most recent sample for
channel_namefrom the in-memory buffer.Open the underlying driver and apply any configured measurement state.
Fan
dataout to every configured publisher;kwargspass through.Trigger a measurement under the configured function and return it.
Read AC current (amperes), selecting the function first if needed.
Read AC voltage (volts), selecting the function first if needed.
Read DC current (amperes), selecting the function first if needed.
Read DC voltage (volts), selecting the function first if needed.
Read 4-wire resistance (ohms), selecting the function first if needed.
Read 2-wire resistance (ohms), selecting the function first if needed.
Set integration time as a number of power-line cycles.
Set integration time (aperture) in seconds.
Set resolution in digits.
Configure the DMM for
function(DC voltage, resistance, etc.).Set manual range;
Noneselects auto-range.Start the background daemon thread.
Signal the background daemon to stop and join it.
- property background_interval#
Seconds between background daemon iterations (0 = no wait).
- start() None[source]#
Start the background daemon thread.
- Raises:
ValueError –
set_measurement_functionhas not been called.
- set_measurement_function(
- function: MeasurementFunction,
- **kwargs,
Configure the DMM for
function(DC voltage, resistance, etc.).
- set_digits(n: int, **kwargs) Command[source]#
Set resolution in digits. Requires set_measurement_function() to have been called.
- set_aperture_seconds(
- seconds: float,
- **kwargs,
Set integration time (aperture) in seconds. Requires set_measurement_function() first.
- set_aperture_nplc(
- nplc: float,
- **kwargs,
Set integration time as a number of power-line cycles.
Higher NPLC integrates over more AC noise (better DC/DCI/resistance accuracy) at the cost of measurement rate. NPLC=100 is the typical highest-accuracy setting. Requires
set_measurement_functionfirst.
- set_range( ) Command[source]#
Set manual range;
Noneselects auto-range. Requiresset_measurement_functionfirst.Publishes
range_mode.cmd("AUTO"/"MANUAL") on every call andrange.cmd(float) only when a manual range is supplied — splitting them keeps each channel single-typed, which the Nominal streaming backend requires.
- read(**kwargs) Measurement[source]#
Trigger a measurement under the configured function and return it. Requires
set_measurement_functionfirst.
- read_dc_voltage(**kwargs) Measurement[source]#
Read DC voltage (volts), selecting the function first if needed.
- read_ac_voltage(**kwargs) Measurement[source]#
Read AC voltage (volts), selecting the function first if needed.
- read_dc_current(**kwargs) Measurement[source]#
Read DC current (amperes), selecting the function first if needed.
- read_ac_current(**kwargs) Measurement[source]#
Read AC current (amperes), selecting the function first if needed.
- read_resistance(**kwargs) Measurement[source]#
Read 2-wire resistance (ohms), selecting the function first if needed.
- read_four_wire_resistance(
- **kwargs,
Read 4-wire resistance (ohms), selecting the function first if needed.
- add_background_daemon_function(
- method: Callable,
- *args,
- **kwargs,
Append
methodto the daemon’s call list. Usedefine_background_daemonto replace instead.
- add_publisher(
- publisher: Publisher,
Register a publisher to receive this instrument’s Measurement/Command data.
- property channel_names: tuple[str, ...]#
Return an insertion-ordered snapshot of all published channel names.
Names are complete after one full daemon iteration: {name}.loop_time publishes every iteration, so call get_channel(“loop_time”, wait_for_new_samples=True) then read channel_names to ensure the complete set has arrived.
- Raises:
RuntimeError – No background buffer;
start()was not called.
- define_background_daemon(
- method: Callable,
- *args,
- **kwargs,
Replace all daemon functions with a single
method(called with the given args).
- get_channel( ) Measurement#
Return the most recent
lengthsamples forchannel_namefrom the in-memory buffer.If the channel does not exist yet, or no sample is available, the code will always block until
timeoutexpires.- Parameters:
channel_name
Name of the channel to retrieve.
length
Number of trailing samples to return.
wait_for_new_samples
Block until at least
lengthnew values arrive.timeout
Seconds to wait when insufficient data exists or
wait_for_new_samples=True.
- Raises:
RuntimeError – No background buffer;
start()was not called.ChannelNotFoundError – channel had no values and no data appeared before
timeout.wait_for_new_samples=Trueand channel did not appear withintimeout.ChannelValueTimeoutError –
wait_for_new_samples=Trueand values did not arrive withintimeout.
- get_single_channel_value(
- channel_name: str,
Return the most recent sample for
channel_namefrom the in-memory buffer.This will not wait, if data is not available then
Noneis returned.- Parameters:
channel_name
Name of the channel to retrieve.
- Raises:
RuntimeError – No background buffer;
start()was not called.
- publish(
- data: Measurement | Command,
- **kwargs,
Fan
dataout to every configured publisher;kwargspass through.
- stop()#
Signal the background daemon to stop and join it. No-op if not running.