alarm¶
Main Alarm Module¶
Classes
An enumeration. |
|
An enumeration. |
-
class
vent.alarm.
AlarmType
[source]¶ An enumeration.
Attributes
int([x]) -> integer
int([x]) -> integer
int([x]) -> integer
int([x]) -> integer
int([x]) -> integer
int([x]) -> integer
int([x]) -> integer
int([x]) -> integer
int([x]) -> integer
int([x]) -> integer
-
LOW_PRESSURE
= 1¶
-
HIGH_PRESSURE
= 2¶
-
LOW_VTE
= 3¶
-
HIGH_VTE
= 4¶
-
LOW_PEEP
= 5¶
-
HIGH_PEEP
= 6¶
-
LOW_O2
= 7¶
-
HIGH_O2
= 8¶
-
OBSTRUCTION
= 9¶
-
LEAK
= 10¶
-
Alarm Manager¶
Classes
|
-
class
vent.alarm.alarm_manager.
Alarm_Manager
[source]¶ Attributes
dict() -> new empty dictionary
Built-in mutable sequence.
Built-in mutable sequence.
dict() -> new empty dictionary
Built-in mutable sequence.
Built-in mutable sequence.
dict() -> new empty dictionary
dict() -> new empty dictionary
Methods
add_callback
(callback)check_rule
(rule, sensor_values)deactivate_alarm
(alarm)Mark an alarm’s internal active flags and remove from
active_alarms
dismiss_alarm
(alarm_type, duration)GUI or other object requests an alarm to be dismissed & deactivated
emit_alarm
(alarm_type, severity)Emit alarm (by calling all callbacks with it).
get_alarm_severity
(alarm_type)load_rule
(alarm_rule)register_alarm
(alarm)Add alarm to registry.
register_dependency
(condition, dependency)Add dependency in a Condition object to be updated when values are changed
reset
()reset all conditions, callbacks, and other stateful attributes and clear alarms
update
(sensor_values)update_dependencies
(control_setting)Update Condition objects that update their value according to some control parameter
-
cleared_alarms
¶ of
AlarmType
s, alarms that have been cleared but have not dropped back into the ‘off’ range to enable re-raising- Type
-
snoozed_alarms
¶ of
AlarmType
s : times, alarms that should not be raised because they have been silenced for a period of time- Type
If an Alarm_Manager already exists, when initing just return that one
-
_instance
= None¶
-
active_alarms
: Dict[vent.alarm.AlarmType, vent.alarm.alarm.Alarm] = {}¶
-
logged_alarms
: List[vent.alarm.alarm.Alarm] = []¶
-
dependencies
= {}¶
-
pending_clears
= []¶
-
cleared_alarms
= []¶
-
snoozed_alarms
= {}¶
-
callbacks
= []¶
-
rules
= {}¶
-
load_rule
(alarm_rule: vent.alarm.rule.Alarm_Rule)[source]¶
-
update
(sensor_values: vent.common.message.SensorValues)[source]¶
-
check_rule
(rule: vent.alarm.rule.Alarm_Rule, sensor_values: vent.common.message.SensorValues)[source]¶
-
emit_alarm
(alarm_type: vent.alarm.AlarmType, severity: vent.alarm.AlarmSeverity)[source]¶ Emit alarm (by calling all callbacks with it).
Note
This method emits and clears alarms – a cleared alarm is emitted with
AlarmSeverity.OFF
- Parameters
alarm_type (
AlarmType
) –severity (
AlarmSeverity
) –
-
deactivate_alarm
(alarm: (<enum 'AlarmType'>, <class 'vent.alarm.alarm.Alarm'>))[source]¶ Mark an alarm’s internal active flags and remove from
active_alarms
Note
This does not alert listeners that an alarm has been cleared, for that emit an alarm with AlarmSeverity.OFF
- Parameters
alarm –
Returns:
-
dismiss_alarm
(alarm_type: vent.alarm.AlarmType, duration: float = None)[source]¶ GUI or other object requests an alarm to be dismissed & deactivated
GUI will wait until it receives an emit_alarm of severity == OFF to remove alarm widgets. If the alarm is not latched
If the alarm is latched, alarm_manager will not decrement alarm severity or emit OFF until a) the condition returns to OFF, and b) the user dismisses the alarm
-
get_alarm_severity
(alarm_type: vent.alarm.AlarmType)[source]¶
-
register_alarm
(alarm: vent.alarm.alarm.Alarm)[source]¶ Add alarm to registry.
- Parameters
alarm (
Alarm
) –
-
register_dependency
(condition: vent.alarm.condition.Condition, dependency: dict)[source]¶ Add dependency in a Condition object to be updated when values are changed
- Parameters
condition –
dependency (dict) – either a (ValueName, attribute_name) or optionally also + transformation callable
-
update_dependencies
(control_setting: vent.common.message.ControlSetting)[source]¶ Update Condition objects that update their value according to some control parameter
- Parameters
control_setting (
ControlSetting
) –
Returns:
-
Alarm¶
Classes
|
Class used by the program to control and coordinate alarms. |
-
class
vent.alarm.alarm.
Alarm
(alarm_type: vent.alarm.AlarmType, severity: vent.alarm.AlarmSeverity, start_time: float = None, latch=True, persistent=True, value=None, message=None, managed=False)[source]¶ Class used by the program to control and coordinate alarms.
Parameterized by a
Alarm_Rule
and managed byAlarm_Manager
- Parameters
alarm_type –
severity –
start_time –
value (int, float) – optional - numerical value that generated the alarm
message (str) – optional - override default text generated by
AlarmManager
managed (bool) – if created by the alarm_manager, don’t register
Methods
__init__
(alarm_type, severity, start_time[, …])- param alarm_type
Attributes
used to generate unique IDs for each alarm
have ta do it this janky way to avoid circular imports
-
id_counter
= count(0)¶ used to generate unique IDs for each alarm
- Type
itertools.count
-
__init__
(alarm_type: vent.alarm.AlarmType, severity: vent.alarm.AlarmSeverity, start_time: float = None, latch=True, persistent=True, value=None, message=None, managed=False)[source]¶ - Parameters
alarm_type –
severity –
start_time –
value (int, float) – optional - numerical value that generated the alarm
message (str) – optional - override default text generated by
AlarmManager
managed (bool) – if created by the alarm_manager, don’t register
-
property
manager
¶ have ta do it this janky way to avoid circular imports
-
property
severity
¶
-
property
alarm_type
¶
Condition¶
Classes
|
|
|
Base class for specifying alarm test conditions |
|
alarm goes out of range for a specific number of breath cycles |
|
value goes out of range for a specific number of breath cycles |
|
value goes out of range for specific amount of time |
|
value is greater or lesser than some max/min |
Functions
-
class
vent.alarm.condition.
Condition
(depends: dict = None, *args, **kwargs)[source]¶ Base class for specifying alarm test conditions
Need to be able to condition alarms based on * value ranges * value ranges & durations * levels of other alarms
Methods
__init__
(depends, *args, **kwargs)- param depends
check
(sensor_values)reset
()If a condition is stateful, need to provide some method of resetting the state
Attributes
-
manager
¶ alarm manager, used to get status of alarms
- Parameters
-
property
manager
¶
-
class
vent.alarm.condition.
ValueCondition
(value_name: vent.common.values.ValueName, limit: (<class 'int'>, <class 'float'>), mode: str, *args, **kwargs)[source]¶ value is greater or lesser than some max/min
- Parameters
Methods
__init__
(value_name, limit, mode, *args, …)- param value_name
Which value to check
check
(sensor_values)reset
()not stateful, do nothing.
Attributes
-
__init__
(value_name: vent.common.values.ValueName, limit: (<class 'int'>, <class 'float'>), mode: str, *args, **kwargs)[source]¶
-
property
mode
¶
-
class
vent.alarm.condition.
CycleValueCondition
(n_cycles, *args, **kwargs)[source]¶ value goes out of range for a specific number of breath cycles
Methods
check
(sensor_values)reset
()not stateful, do nothing.
Attributes
-
_mid_check
¶ whether a value has left the acceptable range and we are counting consecutive breath cycles
- Type
Args: value_name (ValueName): Which value to check limit (int, float): value to check against mode (‘min’, ‘max’): whether the limit is a minimum or maximum *args: **kwargs:
-
property
n_cycles
¶
-
-
class
vent.alarm.condition.
TimeValueCondition
(time, *args, **kwargs)[source]¶ value goes out of range for specific amount of time
- Parameters
time (float) – number of seconds value must be out of range
*args –
**kwargs –
Methods
__init__
(time, *args, **kwargs)- param time
number of seconds value must be out of range
check
(sensor_values)reset
()not stateful, do nothing.
-
class
vent.alarm.condition.
AlarmSeverityCondition
(alarm_type: vent.alarm.AlarmType, severity: vent.alarm.AlarmSeverity, mode: str = 'min', *args, **kwargs)[source]¶ - Parameters
alarm_type –
severity –
mode (str) –
one of ‘min’, ‘equals’, or ‘max’. ‘min’ returns true if the alarm is at least this value (note the difference from ValueCondition which returns true if the alarm is less than..) and vice versa for ‘max’.
Note
’min’ and ‘max’ use >= and <= rather than > and <
*args –
**kwargs –
Methods
__init__
(alarm_type, severity, mode, *args, …)- param alarm_type
check
(sensor_values)reset
()If a condition is stateful, need to provide some method of resetting the state
Attributes
-
__init__
(alarm_type: vent.alarm.AlarmType, severity: vent.alarm.AlarmSeverity, mode: str = 'min', *args, **kwargs)[source]¶ - Parameters
alarm_type –
severity –
mode (str) –
one of ‘min’, ‘equals’, or ‘max’. ‘min’ returns true if the alarm is at least this value (note the difference from ValueCondition which returns true if the alarm is less than..) and vice versa for ‘max’.
Note
’min’ and ‘max’ use >= and <= rather than > and <
*args –
**kwargs –
-
property
mode
¶
-
class
vent.alarm.condition.
CycleAlarmSeverityCondition
(n_cycles, *args, **kwargs)[source]¶ alarm goes out of range for a specific number of breath cycles
Todo
note that this is exactly the same as CycleValueCondition. Need to do the multiple inheritance thing
Methods
check
(sensor_values)reset
()If a condition is stateful, need to provide some method of resetting the state
Attributes
-
_mid_check
¶ whether a value has left the acceptable range and we are counting consecutive breath cycles
- Type
Args: alarm_type: severity: mode (str): one of ‘min’, ‘equals’, or ‘max’.
‘min’ returns true if the alarm is at least this value (note the difference from ValueCondition which returns true if the alarm is less than..) and vice versa for ‘max’.
Note
‘min’ and ‘max’ use >= and <= rather than > and <
-
property
n_cycles
¶
-
Alarm Rule¶
Class to declare alarm rules
Classes
|
|
-
class
vent.alarm.rule.
Alarm_Rule
(name: vent.alarm.AlarmType, conditions, latch=True, persistent=True, technical=False)[source]¶ name of rule
conditions: ((alarm_type, (condition_1, condition_2)), …)
persistent (bool): if True, alarm will not be visually dismissed until alarm conditions are no longer true
latch (bool): if True, alarm severity cannot be decremented until user manually dismisses
silencing/overriding rules
Methods
check
(sensor_values)Check all of our
conditions
.reset
()Attributes
Last Alarm Severity from
.check()
-
property
severity
¶ Last Alarm Severity from
.check()
:returns:AlarmSeverity