InstroFlowController#

class InstroFlowController(
name: str,
driver: FlowControllerDriverBase,
publishers: list[Publisher] | None = None,
**kwargs,
)[source]#

Bases: Instrument

Flow-controller instrument. Methods return Measurement/Command for publishing.

Initialize an InstroFlowController.

Parameters:
  • name

    Channel-name prefix for published data.

  • driver

    Concrete flow-controller driver; owns its own transport:

    fc = InstroFlowController(
        "main",
        driver=AlicatMC("ASRL7::INSTR", "M"),
    )
    

  • publishers

    Publishers that receive emitted Measurement/Command data.

  • **kwargs

    Default tags applied to every emitted Measurement/Command. Pass dataset_rid="<rid>" to auto-create a NominalCorePublisher.

Note

Direct access to driver-specific methods not in FlowControllerDriverBase (e.g., AlicatMC.set_loop_control_variable, gas-mixture methods) bypasses _resource_lock and is the caller’s responsibility to synchronize if mixed with concurrent InstroFlowController method calls.

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

Close the underlying driver and stop the daemon.

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_flow_data

Poll the device and publish all live measurements at once.

get_mass_flow

Read the current mass flow.

get_pressure

Read the current pressure.

get_process_value

Read the current process value (primary feedback measurement for control).

get_setpoint

Read the current setpoint.

get_single_channel_value

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

get_volumetric_flow

Read the current volumetric flow.

open

Open the underlying driver.

publish

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

select_working_fluid

Select the active working fluid by name.

set_setpoint

Command a new flow setpoint in the device's configured engineering units.

start

Start the background daemon thread.

stop

Signal the background daemon to stop and join it.

tare_flow

Zero the flow reading.

open() → None[source]#

Open the underlying driver.

close() → None[source]#

Close the underlying driver and stop the daemon.

get_flow_data(
**kwargs,
) → Measurement | None[source]#

Poll the device and publish all live measurements at once.

set_setpoint(
value: float,
**kwargs,
) → Command[source]#

Command a new flow setpoint in the device’s configured engineering units.

select_working_fluid(
fluid_name: str,
**kwargs,
) → Command[source]#

Select the active working fluid by name.

tare_flow(**kwargs) → Command[source]#

Zero the flow reading. Device must have zero flow when called.

get_setpoint(
**kwargs,
) → Measurement | None[source]#

Read the current setpoint. A subset of get_flow_data(); driver implementations may fetch a full frame internally.

get_mass_flow(
**kwargs,
) → Measurement | None[source]#

Read the current mass flow. A subset of get_flow_data(); driver implementations may fetch a full frame internally.

get_volumetric_flow(
**kwargs,
) → Measurement | None[source]#

Read the current volumetric flow. A subset of get_flow_data(); driver implementations may fetch a full frame internally.

get_pressure(
**kwargs,
) → Measurement | None[source]#

Read the current pressure. A subset of get_flow_data(); driver implementations may fetch a full frame internally.

get_process_value(
**kwargs,
) → Measurement | None[source]#

Read the current process value (primary feedback measurement for control).

The key used in the channel name is determined by the driver’s process_value_source property. For mass-flow controllers this is mass_flow; for liquid-flow controllers, volumetric_flow; etc.

add_background_daemon_function(
method: Callable,
*args,
**kwargs,
)#

Append method to the daemon’s call list. Use define_background_daemon to replace instead.

add_publisher(
publisher: Publisher,
)#

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

property background_interval#

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

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(
channel_name: str,
length: int = 1,
wait_for_new_samples: bool = False,
timeout: float = 10.0,
) → Measurement#

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

If the channel does not exist yet, or no sample is available, the code will always block until timeout expires.

Parameters:
  • channel_name

    Name of the channel to retrieve.

  • length

    Number of trailing samples to return.

  • wait_for_new_samples

    Block until at least length new 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=True and channel did not appear within timeout.

  • ChannelValueTimeoutError – wait_for_new_samples=True and values did not arrive within timeout.

get_single_channel_value(
channel_name: str,
) → float | str | None#

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

This will not wait, if data is not available then None is 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 data out to every configured publisher; kwargs pass through.

start()#

Start the background daemon thread. No-op if already running.

stop()#

Signal the background daemon to stop and join it. No-op if not running.