InstroPSU#
- class InstroPSU(
- name: str | None = None,
- driver: PSUDriverBase | None = None,
- num_channels: int | None = None,
- publishers: list[Publisher] | None = None,
- config: PSUConfig | dict | Path | str | None = None,
- autostart: bool = False,
- **kwargs,
Bases:
InstrumentPower-supply instrument. Methods return Measurement/Command for publishing.
Initialize an InstroPSU.
Provide either
configordriver/num_channelstogether, not both.- Parameters:
name
Channel-name prefix for published data. Falls back to
config.device.namewhenconfigis given.driver
Concrete PSU driver; owns its own transport:
psu = InstroPSU( name="main", driver=BK9115("USB0::0xFFFF::0x9115::SN::INSTR"), num_channels=1, )
num_channels
Number of output channels on this PSU.
publishers
Publishers that receive emitted Measurement/Command data. Combined with any publishers declared in
config.config
A
PSUConfig, a dict, or a path to a JSON config file.autostart
When True, open the connection and start background polling.
**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.
Set the current limit, then the voltage, then the output state on
channel.Clear every latched protection trip on
channel.Disconnect from the device.
Replace all daemon functions with a single
method(called with the given args).Return the most recent
lengthsamples forchannel_namefrom the in-memory buffer.Measure the current (amperes) flowing through
channel.Query the configured current-limit setpoint (amperes) on
channel.Query whether
channelis regulating in constant voltage, constant current, unregulated, or off (published as a string).Query whether the output on
channelis enabled.Query whether overcurrent protection is enabled on
channel.Query the overcurrent protection threshold (amperes) on
channel.Query whether overcurrent protection has tripped on
channeland not been cleared.Query the overvoltage protection trip delay (seconds) on
channel.Query whether overvoltage protection is enabled on
channel.Query the overvoltage protection threshold (volts) on
channel.Query whether overvoltage protection has tripped on
channeland not been cleared.Query whether remote sense is enabled on
channel.Return the most recent sample for
channel_namefrom the in-memory buffer.Measure the voltage (volts) sensed at
channelterminals.Query the configured voltage setpoint (volts) on
channel.Establish connection to the device.
Enable or disable the output on
channel.Fan
dataout to every configured publisher;kwargspass through.Set the current limit (amperes) on
channel.Enable or disable overcurrent protection on
channel.Set the overcurrent protection threshold (amperes) on
channel.Set the overvoltage protection trip delay (seconds) on
channel.Enable or disable overvoltage protection on
channel.Set the overvoltage protection threshold (volts) on
channel.Enable or disable remote sense on
channel.Set the output voltage (volts) on
channel.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).
- apply( ) list[Command][source]#
Set the current limit, then the voltage, then the output state on
channel.The output stays off unless
enable=Trueis passed, and on the default path it is disabled before the new setpoints are written, so setpoints are never applied to a live output. Every argument is keyword-only, so a value can’t land on the wrong setpoint and the output can’t be energized withoutenable=Truespelled out at the call site.Holds the resource lock across all steps so nothing observes a half-applied channel, and publishes only after releasing it so publisher I/O never blocks the background daemon or other threads waiting on the instrument.
Not atomic on the instrument: if a step raises, earlier steps have already been committed and the channel is left in an unknown state. Commands for the steps that did land are still published before the exception propagates.
- get_voltage(
- channel: int,
- **kwargs,
Measure the voltage (volts) sensed at
channelterminals. Output may vary from voltage setpoint outside of constant voltage mode. ReturnsNoneif unavailable.
- get_current(
- channel: int,
- **kwargs,
Measure the current (amperes) flowing through
channel. Output may vary from current-limit setpoint outside of constant current mode. ReturnsNoneif unavailable.
- get_output_status(
- channel: int,
- **kwargs,
Query whether the output on
channelis enabled. ReturnsNoneif unavailable.
- get_voltage_setpoint(
- channel: int,
- **kwargs,
Query the configured voltage setpoint (volts) on
channel. Output may vary from actual measured voltage outside of constant voltage mode. ReturnsNoneif unavailable.
- get_operating_mode(
- channel: int,
- **kwargs,
Query whether
channelis regulating in constant voltage, constant current, unregulated, or off (published as a string).
- get_current_setpoint(
- channel: int,
- **kwargs,
Query the configured current-limit setpoint (amperes) on
channel. Output may vary from actual measured current outside of constant current mode. ReturnsNoneif unavailable.
- set_overvoltage_protection_level( ) Command[source]#
Set the overvoltage protection threshold (volts) on
channel.
- get_overvoltage_protection_level(
- channel: int,
- **kwargs,
Query the overvoltage protection threshold (volts) on
channel. ReturnsNoneif unavailable.
- set_overvoltage_protection_enabled( ) Command[source]#
Enable or disable overvoltage protection on
channel.
- get_overvoltage_protection_enabled(
- channel: int,
- **kwargs,
Query whether overvoltage protection is enabled on
channel. ReturnsNoneif unavailable.
- set_overvoltage_protection_delay( ) Command[source]#
Set the overvoltage protection trip delay (seconds) on
channel.
- get_overvoltage_protection_delay(
- channel: int,
- **kwargs,
Query the overvoltage protection trip delay (seconds) on
channel. ReturnsNoneif unavailable.
- set_overcurrent_protection_level( ) Command[source]#
Set the overcurrent protection threshold (amperes) on
channel.
- get_overcurrent_protection_level(
- channel: int,
- **kwargs,
Query the overcurrent protection threshold (amperes) on
channel. ReturnsNoneif unavailable.
- set_overcurrent_protection_enabled( ) Command[source]#
Enable or disable overcurrent protection on
channel.
- get_overcurrent_protection_enabled(
- channel: int,
- **kwargs,
Query whether overcurrent protection is enabled on
channel. ReturnsNoneif unavailable.
- clear_protection(
- channel: int,
- **kwargs,
Clear every latched protection trip on
channel. PublishesTrueon theprotection.clearcommand channel.The output stays off after the clear; re-enable it with
output_enableonce the cause is fixed.
- get_overvoltage_protection_tripped(
- channel: int,
- **kwargs,
Query whether overvoltage protection has tripped on
channeland not been cleared.Raises
NotImplementedErrorif the driver does not implement the query, orFeatureNotSupportedErrorif the supply has no overvoltage protection.
- get_overcurrent_protection_tripped(
- channel: int,
- **kwargs,
Query whether overcurrent protection has tripped on
channeland not been cleared.Raises
NotImplementedErrorif the driver does not implement the query, orFeatureNotSupportedErrorif the supply has no overcurrent protection.
- get_remote_sense_enabled(
- channel: int,
- **kwargs,
Query whether remote sense is enabled on
channel. ReturnsNoneif unavailable.
- 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.
- 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.