InstroFlowController
InstroFlowController is a hardware abstraction layer (HAL) that provides a unified interface for InstroFlowMeter. The category class defines the vendor-independent API (set_voltage, get_voltage, output_enable, …). A vendor-specific driver (e.g. BK9115, KeysightE36100, TDKLambdaGenesys, RigolDP800) owns its connection details and translates those calls into vendor commands.
Supported Vendors
- AlicatMC: Alicat MC-series serial-controlled flow meters
Key Concepts
Driver Composition
AnInstroFlowController is built from a concrete driver:
- The vendor driver (e.g.
AlicatMC) owns the connection setup and vendor-specific command mapping. InstroFlowControllerowns the category-level workflow: measurements, commands, publishers, the background daemon.
Lifecycle
The typical InstroFlowController workflow:- Construct: instantiate the vendor driver and pass it to
InstroFlowController. open(): establishes the VISA connection.- Configure and measure: select gas, set flow setpoint, tare flow (optional), and read flow data.
start(): begins a periodic background daemon. (Optional) By default this callsget_flow_dataperiodically.stop(): ends the background daemon (if started).close(): disconnects from hardware.
Creating an InstroFlowController Instance
Parameters
name: A name for this flow controller instance. Used as a prefix for channel names when publishing.driver: A concreteFlowControllerDriverBaseinstance (e.g.AlicatMC) configured with the connection details for that model.publishers: Optional list of publishers to attach.**kwargs: Additional keyword arguments become default tags when using a publisher that supports tags (likeNominalCorePublisher).
Choosing a Driver
Choose the concrete driver that matches the flow controller model, then pass the instrument connection settings to that driver. For example, useAlicatMC for the Alicat MC-series.
Examples
All measurement methods returnMeasurement objects. This is common amongst all Instrument objects.
Basic Usage
Background Daemon for Continuous Monitoring
start()begins a background daemon, executing a function or list of functions periodically.stop()ends the background daemon.
Default Flow Controller Background DaemonFor each meter, using
get_flow_data():- temperature
- pressure
- mass flow (
mass_flow) - volumetric flow (
vol_flow) - setpoint (as read back from the meter)
setpoint.cmdrepresents the last command to the controller from this client)
Instrument class, but is configurable via the background_interval property.- To define your own background daemon, call
define_background_daemon(method, *args, **kwargs), which replaces the registered daemon functions. - To add a method to the background daemon stack, call
add_background_daemon_function().
Important Note about PublishersData is published as a direct result of an instrument method being called.For example, when you call
get_flow_data(), this not only queries the instrument for the voltage but also causes all attached Publishers to publish the measurement response automatically.Therefore the background daemon, when calling these instrument methods, is publishing data in the background as well!Published channels
Every measurement/command call produces a channel keyed under{name}.{descriptor}, where {name} is the name argument passed to the constructor.
Method Reference
Custom Driver Development
This section is for developers implementingInstroFlowController support for flow controllers that aren’t shipped in the library.
Overview
Driver developers subclassFlowControllerDriverBase and own whatever transport their instrument needs. The caller chooses a concrete driver and passes it to InstroFlowController:
InstroFlowController’s vendor-independent API (get_flow_data, set_setpoint, select_gas, tare_flow) into vendor-specific commands.
Driver Responsibilities
A flow controller driver must:- Expose a protocol-native constructor: accept inputs like
visa_resource,host,port, ordevice_id, depending on the instrument. - Own transport setup: create and store the transport internally. Do not require users to pass a
VisaDriveror other transport object. - Own lifecycle: implement
open()andclose()by opening and closing the underlying transport. - Map commands: translate each abstract method into vendor-specific commands.
- Parse responses: convert instrument responses into
FlowDataor the expected return type.
FlowControllerDriverBase Interface
All flow controller drivers subclassFlowControllerDriverBase and implement these abstract methods:
@abc.abstractmethod. FlowData (from instro.flowcontroller.types) carries pressure, temperature, vol_flow, mass_flow, setpoint, gas, and status_flags.
Talking to the Instrument
Concrete drivers should hide transport details behind private attributes. For VISA-backed drivers (including RS-232/serial), create aVisaDriver internally and use it for all I/O:
self._visa.write(command): Send a command (no response expected).self._visa.query(command): Send a command and receive the response string.self._visa.read(): Read one line from the device buffer.
VisaDriver owns the resource lock. Use with self._visa.lock(): when a sequence of writes and reads must execute atomically.
See the VisaDriver guide for the full transport reference, covering configuration, terminators, timeouts, and serial settings.
Implementation Example: Alicat MC-Series
AlicatMC is the reference driver. It communicates over RS-232 using Alicat’s proprietary ASCII polling protocol — not SCPI — so commands are terse single-character identifiers rather than IEEE 488.2-style mnemonics.
Alicat ASCII protocol, not SCPIAlicat MC-series devices use a proprietary ASCII polling protocol. Commands are single-character identifiers (e.g.
{id} to poll, {id}s{setpt} to set a setpoint, {id}v to tare, {id}g{n} to select a gas) rather than SCPI mnemonics. An unrecognized command returns ?. Consult the Alicat Gas Flow Controller Manual for the full command reference.Using a Custom Driver
ConstructInstroFlowController with your own driver instance:
Summary
Driver development requires careful mapping of vendor-specific behavior to the unifiedInstroFlowController interface. Focus on:
- Subclassing
FlowControllerDriverBase - Designing a constructor around natural connection parameters for the instrument
- Hiding transport construction inside the driver
- Implementing all six abstract methods on
FlowControllerDriverBase - Returning correctly typed
FlowDatafrom measurement methods - Parsing and raising instrument errors appropriately
- Testing with actual hardware to ensure commands work as expected