# InstroFlowController

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

Bases: [`Instrument`](https://dev.nominal.io/instro/ref/library/instro.lib.instrument.Instrument.md#instro.lib.instrument.Instrument "instro.lib.instrument.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`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.background_interval "instro.unstable.flowcontroller.InstroFlowController.background_interval") | Seconds between background daemon iterations (0 = no wait). |
| --- | --- |
| [`channel_names`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.channel_names "instro.unstable.flowcontroller.InstroFlowController.channel_names") | Return an insertion-ordered snapshot of all published channel names. |

Methods

| [`add_background_daemon_function`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.add_background_daemon_function "instro.unstable.flowcontroller.InstroFlowController.add_background_daemon_function") | Append `method` to the daemon's call list. |
| --- | --- |
| [`add_publisher`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.add_publisher "instro.unstable.flowcontroller.InstroFlowController.add_publisher") | Register a publisher to receive this instrument's Measurement/Command data. |
| [`close`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.close "instro.unstable.flowcontroller.InstroFlowController.close") | Close the underlying driver and stop the daemon. |
| [`define_background_daemon`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.define_background_daemon "instro.unstable.flowcontroller.InstroFlowController.define_background_daemon") | Replace all daemon functions with a single `method` (called with the given args). |
| [`get_channel`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.get_channel "instro.unstable.flowcontroller.InstroFlowController.get_channel") | Return the most recent `length` samples for `channel_name` from the in-memory buffer. |
| [`get_flow_data`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.get_flow_data "instro.unstable.flowcontroller.InstroFlowController.get_flow_data") | Poll the device and publish all live measurements at once. |
| [`get_mass_flow`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.get_mass_flow "instro.unstable.flowcontroller.InstroFlowController.get_mass_flow") | Read the current mass flow. |
| [`get_pressure`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.get_pressure "instro.unstable.flowcontroller.InstroFlowController.get_pressure") | Read the current pressure. |
| [`get_process_value`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.get_process_value "instro.unstable.flowcontroller.InstroFlowController.get_process_value") | Read the current process value (primary feedback measurement for control). |
| [`get_setpoint`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.get_setpoint "instro.unstable.flowcontroller.InstroFlowController.get_setpoint") | Read the current setpoint. |
| [`get_single_channel_value`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.get_single_channel_value "instro.unstable.flowcontroller.InstroFlowController.get_single_channel_value") | Return the most recent sample for `channel_name` from the in-memory buffer. |
| [`get_volumetric_flow`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.get_volumetric_flow "instro.unstable.flowcontroller.InstroFlowController.get_volumetric_flow") | Read the current volumetric flow. |
| [`open`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.open "instro.unstable.flowcontroller.InstroFlowController.open") | Open the underlying driver. |
| [`publish`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.publish "instro.unstable.flowcontroller.InstroFlowController.publish") | Fan `data` out to every configured publisher; `kwargs` pass through. |
| [`select_working_fluid`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.select_working_fluid "instro.unstable.flowcontroller.InstroFlowController.select_working_fluid") | Select the active working fluid by name. |
| [`set_setpoint`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.set_setpoint "instro.unstable.flowcontroller.InstroFlowController.set_setpoint") | Command a new flow setpoint in the device's configured engineering units. |
| [`start`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.start "instro.unstable.flowcontroller.InstroFlowController.start") | Start the background daemon thread. |
| [`stop`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.stop "instro.unstable.flowcontroller.InstroFlowController.stop") | Signal the background daemon to stop and join it. |
| [`tare_flow`](https://dev.nominal.io/instro/ref/instruments/instro.unstable.flowcontroller.InstroFlowController.md#instro.unstable.flowcontroller.InstroFlowController.tare_flow "instro.unstable.flowcontroller.InstroFlowController.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**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – 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**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – No background buffer; `start()` was not called.
    - [**ChannelNotFoundError**](https://dev.nominal.io/instro/ref/library/instro.lib.publishers.channel_buffer.ChannelNotFoundError.md#instro.lib.publishers.channel_buffer.ChannelNotFoundError "instro.lib.publishers.channel_buffer.ChannelNotFoundError") – channel had no values and no data appeared before `timeout`.
      `wait_for_new_samples=True` and channel did not appear within `timeout`.
    - [**ChannelValueTimeoutError**](https://dev.nominal.io/instro/ref/library/instro.lib.publishers.channel_buffer.ChannelValueTimeoutError.md#instro.lib.publishers.channel_buffer.ChannelValueTimeoutError "instro.lib.publishers.channel_buffer.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**](https://docs.python.org/3/builtins/exceptions.html#RuntimeError "(in Python v3.15)") – 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.
