InstroFlowController#
- class InstroFlowController(
- name: str,
- driver: FlowControllerDriverBase,
- publishers: list[Publisher] | None = None,
- **kwargs,
Bases:
InstrumentFlow-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
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.Poll the device and publish all live measurements at once.
Read the current mass flow.
Read the current pressure.
Read the current process value (primary feedback measurement for control).
Read the current setpoint.
Return the most recent sample for
channel_namefrom the in-memory buffer.Read the current volumetric flow.
Open the underlying driver.
Fan
dataout to every configured publisher;kwargspass through.Select the active working fluid by name.
Command a new flow setpoint in the device's configured engineering units.
Start the background daemon thread.
Signal the background daemon to stop and join it.
Zero the flow reading.
- get_flow_data(
- **kwargs,
Poll the device and publish all live measurements at once.
- set_setpoint(
- value: float,
- **kwargs,
Command a new flow setpoint in the device’s configured engineering units.
- select_working_fluid(
- fluid_name: str,
- **kwargs,
Select the active working fluid by name.
- get_setpoint(
- **kwargs,
Read the current setpoint. A subset of get_flow_data(); driver implementations may fetch a full frame internally.
- get_mass_flow(
- **kwargs,
Read the current mass flow. A subset of get_flow_data(); driver implementations may fetch a full frame internally.
- get_volumetric_flow(
- **kwargs,
Read the current volumetric flow. A subset of get_flow_data(); driver implementations may fetch a full frame internally.
- get_pressure(
- **kwargs,
Read the current pressure. A subset of get_flow_data(); driver implementations may fetch a full frame internally.
- get_process_value(
- **kwargs,
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
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 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( ) 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.
- 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.