Alarm Class¶
The Alarm class is a StateMachine that manages the lifecycle of a specific alarm instance. It observes a Tag and transitions between states (e.g., Normal -> Unacknowledged -> Acknowledged) based on the tag's value and operator actions.
automation.alarms.Alarm(name, tag, alarm_type, alarm_setpoint, description='', state=None, timestamp=None, ack_timestamp=None, alarm_deadband=Represents an Alarm entity with state machine logic.
Implements the standard alarm lifecycle defined in ISA 18.2, including states like Normal, Unacknowledged, Acknowledged, Shelved, and Suppressed.
It monitors a Tag value against a Trigger condition and transitions states accordingly.
set_socketio(self, sio)Sets the SocketIO instance for real-time updates.
Parameters:
- sio (SocketIO): The SocketIO server instance.
notify(*args, **kwargs)abnormal_condition(self)Triggers transition to an alarm state (abnormal).
normal_condition(self)Triggers transition to normal or return-to-normal states.
acknowledge(self, user=None)Acknowledges the alarm.
Parameters:
- user (User, optional): User performing the acknowledgment.
shelve(self, user=None, **options)Temporarily suppresses the alarm (Shelving).
Parameters:
- options: Time duration arguments (days, hours, minutes, seconds).
unshelve(self, user=None, current_value=None)Manually un-shelves the alarm, returning it to service. After unshelving, re-evaluates the current tag value to determine the correct state.
Parameters:
- user (User, optional): User performing the unshelve action.
- current_value (Quantity, optional): Current tag value. If not provided, will be obtained from the tag.
designed_suppression(self, user=None)Suppresses the alarm by design (e.g., maintenance mode).
designed_unsuppression(self, user=None)Removes designed suppression.
remove_from_service(self, user=None)Takes the alarm out of service entirely.
return_to_service(self, user=None)Returns the alarm to service from 'Out of Service'.
attach(self, machine, tag)put(self, user=None, name=None, tag=None, description=None, alarm_type=None, trigger_value=None)Updates the alarm configuration.
Parameters:
- name (str): Alarm name.
- tag (str): Tag bound to alarm.
- description (str): Alarm description.
- alarm_type (TriggerType): Alarm type ['HIGH-HIGH', 'HIGH', 'LOW', 'LOW-LOW', 'BOOL'].
- trigger_value (float): Alarm trigger value.
Returns:
- tuple: (Alarm instance, status message)
get_operator_actions(self)Returns a list of available actions for the operator based on current state.
Returns:
- dict: Map of Action Name -> Action Method.
serialize(self)Serializes the alarm object to a JSON-compatible dictionary.
Returns:
- dict: Alarm data including state, setpoint, and metadata.