stoner_measurement.instruments.simulated.SimulatedTemperatureController

class stoner_measurement.instruments.simulated.SimulatedTemperatureController(transport=None, protocol=None)[source]

Bases: TemperatureController

Simple simulated temperature controller.

get_capabilities() → ControllerCapabilities[source]

Return the static capability descriptor for this controller driver.

Returns:

Descriptor advertising the number of inputs, loops, and which optional feature groups are supported.

Return type:

(ControllerCapabilities)

Examples

>>> caps = tc.get_capabilities()
>>> caps.num_loops
1
>>> caps.has_ramp
True
get_heater_output(loop: int) → float[source]

Return the heater output percentage for control loop.

Parameters:

loop (int) – Control loop number (1-based).

Returns:

Heater output as a percentage (0–100 %).

Return type:

(float)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_heater_output(1)
50.0
get_heater_range(loop: int) → int[source]

Return the current heater range index for control loop.

The meaning of the returned index is instrument-specific. A value of 0 conventionally means “heater off”.

Drivers that support reading the heater range should override this method. The default implementation raises NotImplementedError.

Parameters:

loop (int) – Control loop number (1-based).

Returns:

Current heater range index.

Return type:

(int)

Raises:

Examples

>>> tc.get_heater_range(1)
0
get_input_channel(loop: int) → str[source]

Return the sensor channel currently assigned to control loop.

Parameters:

loop (int) – Control loop number (1-based).

Returns:

Channel identifier of the sensor driving this loop.

Return type:

(str)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_input_channel(1)
'A'
get_loop_mode(loop: int) → ControlMode[source]

Return the active control mode for loop.

Parameters:

loop (int) – Control loop number (1-based).

Returns:

Current control mode of the loop.

Return type:

(ControlMode)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_loop_mode(1)
<ControlMode.CLOSED_LOOP: 'closed_loop'>
get_pid(loop: int) → PIDParameters[source]

Return the PID parameters for control loop.

Parameters:

loop (int) – Control loop number (1-based).

Returns:

Current proportional, integral and derivative gain values.

Return type:

(PIDParameters)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_pid(1)
PIDParameters(p=50.0, i=1.0, d=0.0)
get_ramp_enabled(loop: int) → bool[source]

Return True if setpoint ramping is enabled for loop.

Parameters:

loop (int) – Control loop number (1-based).

Returns:

True when the ramp function is active.

Return type:

(bool)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_ramp_enabled(1)
False
get_ramp_rate(loop: int) → float[source]

Return the setpoint ramp rate for loop in Kelvin per minute.

Parameters:

loop (int) – Control loop number (1-based).

Returns:

Ramp rate in Kelvin per minute.

Return type:

(float)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_ramp_rate(1)
5.0
get_ramp_state(loop: int) → RampState[source]

Return the current ramp state for loop.

The default implementation infers the state from get_ramp_enabled(); override in subclasses that can query the actual hardware ramp state directly.

Parameters:

loop (int) – Control loop number (1-based).

Returns:

RAMPING when the ramp function is active, IDLE otherwise.

Return type:

(RampState)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_ramp_state(1)
<RampState.IDLE: 'idle'>
get_sensor_status(channel: str) → SensorStatus[source]

Return the validity/range status of the sensor on channel.

Parameters:

channel (str) – Sensor channel identifier (instrument-specific, e.g. "A").

Returns:

Current validity and range status of the sensor reading.

Return type:

(SensorStatus)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_sensor_status("A")
<SensorStatus.OK: 'ok'>
get_setpoint(loop: int) → float[source]

Return the current setpoint for control loop in Kelvin.

Parameters:

loop (int) – Control loop number (1-based).

Returns:

Setpoint temperature in Kelvin.

Return type:

(float)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_setpoint(1)
300.0
get_temperature(channel: str) → float[source]

Return the current temperature for channel in Kelvin.

Parameters:

channel (str) – Sensor channel identifier (instrument-specific, e.g. "A").

Returns:

Current temperature in Kelvin.

Return type:

(float)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> tc.get_temperature("A")
300.0
identify() → str[source]

Return the instrument identification string (*IDN?).

Sends the standard IEEE 488.2 *IDN? query and returns the response. Instruments that do not support *IDN? should override this method.

Returns:

Identification string returned by the instrument.

Return type:

(str)

Raises:

ConnectionError – If the transport is not open.

Examples

>>> from stoner_measurement.instruments.transport import NullTransport
>>> from stoner_measurement.instruments.protocol import ScpiProtocol
>>> from stoner_measurement.instruments.base_instrument import BaseInstrument
>>> t = NullTransport(responses=[b"ACME,Model1,SN001,v1.0\n"])
>>> instr = BaseInstrument(t, ScpiProtocol())
>>> instr.connect()
>>> instr.identify()
'ACME,Model1,SN001,v1.0'
>>> instr.disconnect()
set_heater_range(loop: int, range_: int) → None[source]

Set the heater range for control loop.

The meaning of range_ is instrument-specific. A value of 0 conventionally means “heater off”.

Parameters:
  • loop (int) – Control loop number (1-based).

  • range (int) – Heater range index (instrument-specific).

Raises:

ConnectionError – If the transport is not open.

set_input_channel(loop: int, channel: str) → None[source]

Assign sensor channel as the input for control loop.

Parameters:
  • loop (int) – Control loop number (1-based).

  • channel (str) – Sensor channel identifier to assign.

Raises:
  • ConnectionError – If the transport is not open.

  • ValueError – If channel is not a valid sensor input for this instrument.

set_loop_mode(loop: int, mode: ControlMode) → None[source]

Set the control mode for loop.

Parameters:
  • loop (int) – Control loop number (1-based).

  • mode (ControlMode) – Desired control mode.

Raises:
set_pid(loop: int, p: float, i: float, d: float) → None[source]

Set the PID parameters for control loop.

Parameters:
  • loop (int) – Control loop number (1-based).

  • p (float) – Proportional gain.

  • i (float) – Integral gain (reset).

  • d (float) – Derivative gain (rate).

Raises:
  • ConnectionError – If the transport is not open.

  • ValueError – If any gain value is outside the instrument’s valid range.

set_ramp_enabled(loop: int, enabled: bool) → None[source]

Enable or disable setpoint ramping for loop.

Parameters:
  • loop (int) – Control loop number (1-based).

  • enabled (bool) – True to activate the ramp function, False to disable it.

Raises:

ConnectionError – If the transport is not open.

set_ramp_rate(loop: int, rate: float) → None[source]

Set the setpoint ramp rate for loop.

Parameters:
  • loop (int) – Control loop number (1-based).

  • rate (float) – Ramp rate in Kelvin per minute. A value of 0 typically disables ramping or sets an unlimited rate (instrument-specific).

Raises:
  • ConnectionError – If the transport is not open.

  • ValueError – If rate is negative or exceeds the instrument’s maximum.

set_setpoint(loop: int, value: float) → None[source]

Set the target temperature for control loop.

Parameters:
  • loop (int) – Control loop number (1-based).

  • value (float) – Desired setpoint in Kelvin.

Raises: