phoenix6.status_signal¶
Module Contents¶
Attributes¶
- phoenix6.status_signal.T¶
- class phoenix6.status_signal.SignalMeasurement¶
Bases:
Generic[T]Information from a single measurement of a status signal.
- name: str = ''¶
The name of the signal
- value: T¶
The value of the signal
- timestamp: phoenix6.units.second = 0.0¶
Timestamp of when the data point was taken, in seconds
- units = ''¶
The units of the signal measurement
- status¶
Status code response of getting the data
- class phoenix6.status_signal.StatusSignal(error: phoenix6.status_code.StatusCode | None, device_identifier: phoenix6.hardware.device_identifier.DeviceIdentifier, spn: int, signal_name: str, report_if_old_func: Callable[[], None], units_generator: Callable[[], dict[int, str]] | None, signal_type: type[T])¶
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.
Construct a StatusSignal object
- Parameters:
error (StatusCode) – Status code to construct this with. If this is not None, this StatusSignal will be an error-only StatusSignal
device_identifier (DeviceIdentifier) – Device Identifier for this signal
spn (int) – SPN for this signal
report_if_old_func (Callable[[], None]) – Function to call if device is too old
units_generator (Callable[[], dict[int, StatusSignal]]) – Callable function that returns a dictionary mapping a signal to its units
signal_name (str) – Name of signal
signal_type (type) – Type of signal for the generic
- 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]
- is_near(target: T, tolerance: T) bool¶
Checks whether the signal is near a target value within the given tolerance. This signal must be a numeric type.
- Parameters:
target (T) – The target value of the signal
tolerance (T) – The error tolerance between the target and measured values
- Returns:
Whether the signal is near the target value
- Return type:
bool
- 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]
- get_data_copy() SignalMeasurement[T]¶
Get a basic data-only container with this information, to be used for things such as data logging.
If looking for Phoenix 6 logging features, see the SignalLogger class instead.
This function returns a new object every call. As a result, we recommend that this is not called inside a tight loop.
- Returns:
Basic structure with all relevant information
- Return type: