phoenix6.status_signal#

Module Contents#

Attributes#

T

phoenix6.status_signal.T#
class phoenix6.status_signal.StatusSignal(error: phoenix6.status_code.StatusCode, device_identifier: phoenix6.hardware.device_identifier.DeviceIdentifier, spn: int, report_if_old_func: Callable[[], None], generator: Callable[[], dict[int, StatusSignal]], signal_name: str, signal_type: type)#

Bases: phoenix6.base_status_signal.BaseStatusSignal, Generic[T]

Represents a status signal with data of type T, and operations available to retrieve information about the signal.

property value: T#

Gets the value inside this StatusSignal

Returns:

The value of this StatusSignal

Return type:

T

refresh(report_error: bool = True) StatusSignal[T]#

Refreshes the value of this status signal.

If the user application caches this StatusSignal object instead of periodically fetching it from the hardware device, this function must be called to fetch fresh data.

This performs a non-blockin refresh operation. If you want to wait until you receive data, call wait_for_update instead.

Parameters:

report_error (bool, optional) – Whether to report any errors to the console, defaults to True

Returns:

Reference to itself

Return type:

StatusSignal[T]

wait_for_update(timeout_seconds: phoenix6.units.second, report_error: bool = True) StatusSignal[T]#

Waits up to timeout_seconds to get up-to-date status signal value.

This performs a blocking refresh operation. If you want to non-blocking refresh the signal, call refresh instead.

Parameters:
  • timeout_seconds (second) – Maximum time to wait for a signal to update

  • report_error (bool, optional) – Whether to report any errors to the console, defaults to True

Returns:

Reference to itself

Return type:

StatusSignal[T]

set_update_frequency(frequency_hz: phoenix6.units.hertz, timeout_seconds: phoenix6.units.second = 0.05) phoenix6.status_code.StatusCode#

Sets the rate at which the device will publish this signal.

A frequency of 0 Hz will turn off the signal. Otherwise, the minimum supported signal frequency is 4 Hz, and the maximum is 1000 Hz.

If other StatusSignals in the same status frame have been set to an update frequency, the fastest requested update frequency will be applied to the frame.

Parameters:
  • frequency_hz (hertz) – Rate to publish the signal in Hz

  • timeout_seconds (second) – Maximum amount of time to wait when performing the action

Returns:

Status code of setting the update frequency

Return type:

StatusCode

get_applied_update_frequency() phoenix6.units.hertz#

Gets the rate at which the device will publish this signal.

This is typically the last value passed into set_update_frequency. The returned value may be higher if another StatusSignal in the same status frame has been set to a higher update frequency.

Returns:

Applied update frequency of the signal in Hz

Return type:

hertz

as_supplier() Callable[[], T]#

Returns a lambda that calls refresh and value on this object. This is useful for command-based programming.

Returns:

Lambda that refreshes this signal and returns it

Return type:

Callable[[], T]