alarm¶
Main Alarm Module¶
Classes
|
An enumeration. |
|
An enumeration. |
-
class
pvp.alarm.
AlarmType
(value)[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
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¶
-
SENSORS_STUCK
= 11¶
-
BAD_SENSOR_READINGS
= 12¶
-
MISSED_HEARTBEAT
= 13¶
-
property
human_name
¶
-
Alarm Manager¶
Classes
|
-
class
pvp.alarm.alarm_manager.
Alarm_Manager
[source]¶ Attributes
dict() -> new empty dictionary
Built-in mutable sequence.
Built-in mutable sequence.
dict() -> new empty dictionary
When we
update_dependencies()
, we send back aControlSetting
with the new min/maxBuilt-in mutable sequence.
Instances of the Logger class represent a single logging channel.
Built-in mutable sequence.
dict() -> new empty dictionary
dict() -> new empty dictionary
Methods
add_callback
(callback)add_dependency_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[pvp.alarm.AlarmType, pvp.alarm.alarm.Alarm] = {}¶
-
logged_alarms
: List[pvp.alarm.alarm.Alarm] = []¶
-
dependencies
= {}¶
-
pending_clears
= []¶
-
cleared_alarms
= []¶
-
snoozed_alarms
= {}¶
-
callbacks
= []¶
-
depends_callbacks
= []¶ When we
update_dependencies()
, we send back aControlSetting
with the new min/max
-
rules
= {}¶
-
logger
= <Logger pvp.alarm.alarm_manager (WARNING)>¶
-
load_rule
(alarm_rule: pvp.alarm.rule.Alarm_Rule)[source]¶
-
update
(sensor_values: pvp.common.message.SensorValues)[source]¶
-
check_rule
(rule: pvp.alarm.rule.Alarm_Rule, sensor_values: pvp.common.message.SensorValues)[source]¶
-
emit_alarm
(alarm_type: pvp.alarm.AlarmType, severity: pvp.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 'pvp.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: pvp.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: pvp.alarm.AlarmType)[source]¶
-
register_alarm
(alarm: pvp.alarm.alarm.Alarm)[source]¶ Add alarm to registry.
- Parameters
alarm (
Alarm
) –
-
register_dependency
(condition: pvp.alarm.condition.Condition, dependency: dict, severity: pvp.alarm.AlarmSeverity)[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
severity (
AlarmSeverity
) – severity of dependency
-
update_dependencies
(control_setting: pvp.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
pvp.alarm.alarm.
Alarm
(alarm_type: pvp.alarm.AlarmType, severity: pvp.alarm.AlarmSeverity, start_time: float = None, latch: bool = True, persistent: bool = True, cause: list = None, value=None, message=None)[source]¶ Class used by the program to control and coordinate alarms.
Parameterized by a
Alarm_Rule
and managed byAlarm_Manager
Methods
__init__
(alarm_type, severity, start_time, …)-
pvp.alarm.alarm.
id
¶
Attributes
itertools.count
: used to generate unique IDs for each alarm- Parameters
-
id_counter
= count(0)¶ used to generate unique IDs for each alarm
- Type
itertools.count
-
__init__
(alarm_type: pvp.alarm.AlarmType, severity: pvp.alarm.AlarmSeverity, start_time: float = None, latch: bool = True, persistent: bool = True, cause: list = None, value=None, message=None)[source]¶
-
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
pvp.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
pvp.alarm.condition.
ValueCondition
(value_name: pvp.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: pvp.common.values.ValueName, limit: (<class 'int'>, <class 'float'>), mode: str, *args, **kwargs)[source]¶
-
property
mode
¶
-
class
pvp.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
pvp.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
pvp.alarm.condition.
AlarmSeverityCondition
(alarm_type: pvp.alarm.AlarmType, severity: pvp.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: pvp.alarm.AlarmType, severity: pvp.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
pvp.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
pvp.alarm.rule.
Alarm_Rule
(name: pvp.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
Get all ValueNames whose alarm limits depend on this alarm rule
Last Alarm Severity from
.check()
Get all ValueNames specified as value_names in alarm conditions
-
property
severity
¶ Last Alarm Severity from
.check()
:returns:AlarmSeverity
-
property
depends
¶ Get all ValueNames whose alarm limits depend on this alarm rule :returns: list[ValueName]
-
property
value_names
¶ Get all ValueNames specified as value_names in alarm conditions
- Returns
list[ValueName]