Alarm Condition¶
Condition objects define conditions that can raise alarms. They are used by Alarm_Rule
s.
Each has to define a Condition.check()
method that accepts SensorValues
.
The method should return True
if the alarm condition is met, and False
otherwise.
Conditions can be added (+
) together to make compound conditions, and a single call to check
will only return true
if both conditions return true. If any condition in the chain returns false, evaluation is stopped and
the alarm is not raised.
Conditions can
Classes:
|
An enumeration. |
|
Alarm is above or below a certain severity. |
|
An enumeration. |
|
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 |
|
Structured class for communicating sensor readings throughout PVP. |
|
value goes out of range for specific amount of time |
|
Value is greater or lesser than some max/min |
|
Canonical names of all values used in PVP. |
Functions:
-
class
pvp.alarm.condition.
Condition
(depends: dict = None, *args, **kwargs)[source]¶ Bases:
object
Base class for specifying alarm test conditions
Subclasses must define
Condition.check()
andConditino.reset()
Condition objects can be added together to create compound conditions.
- Parameters
Methods:
__init__
([depends])- param depends
check
(sensor_values)Every Condition subclass needs to define this method that accepts
SensorValues
and returns a booleanreset
()If a condition is stateful, need to provide some method of resetting the state
Attributes:
The active alarm manager, used to get status of alarms
-
property
manager
¶ The active alarm manager, used to get status of alarms
-
check
(sensor_values) → bool[source]¶ Every Condition subclass needs to define this method that accepts
SensorValues
and returns a boolean- Parameters
sensor_values (
SensorValues
) – SensorValues used to compute alarm status- Returns
bool
-
class
pvp.alarm.condition.
ValueCondition
(value_name: pvp.common.values.ValueName, limit: (<class 'int'>, <class 'float'>), mode: str, *args, **kwargs)[source]¶ Bases:
pvp.alarm.condition.Condition
Value is greater or lesser than some max/min
- Parameters
-
operator
¶ Either the less than or greater than operators, depending on whether mode is
'min'
or'max'
- Type
callable
Methods:
__init__
(value_name, limit, mode, *args, …)- param value_name
Which value to check
check
(sensor_values)Check that the relevant value in SensorValues is either greater or lesser than the limit
reset
()not stateful, do nothing.
Attributes:
One of ‘min’ or ‘max’, defines how the incoming sensor values are compared to the set value
-
__init__
(value_name: pvp.common.values.ValueName, limit: (<class 'int'>, <class 'float'>), mode: str, *args, **kwargs)[source]¶ - Parameters
-
operator
¶ Either the less than or greater than operators, depending on whether mode is
'min'
or'max'
- Type
callable
-
property
mode
¶ One of ‘min’ or ‘max’, defines how the incoming sensor values are compared to the set value
Returns:
-
check
(sensor_values)[source]¶ Check that the relevant value in SensorValues is either greater or lesser than the limit
- Parameters
sensor_values (
SensorValues
) –- Returns
bool
-
class
pvp.alarm.condition.
CycleValueCondition
(n_cycles: int, *args, **kwargs)[source]¶ Bases:
pvp.alarm.condition.ValueCondition
Value goes out of range for a specific number of breath cycles
- Parameters
n_cycles (int) – number of cycles required
-
_mid_check
¶ whether a value has left the acceptable range and we are counting consecutive breath cycles
- Type
- Parameters
-
operator
¶ Either the less than or greater than operators, depending on whether mode is
'min'
or'max'
- Type
callable
Methods:
check
(sensor_values)Check if outside of range, and then check if number of breath cycles have elapsed
reset
()Reset check status and start cycle
Attributes:
Number of cycles required
-
property
n_cycles
¶ Number of cycles required
-
class
pvp.alarm.condition.
TimeValueCondition
(time, *args, **kwargs)[source]¶ Bases:
pvp.alarm.condition.ValueCondition
value goes out of range for specific amount of time
Warning
Not implemented!
- 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)Check that the relevant value in SensorValues is either greater or lesser than the limit
reset
()not stateful, do nothing.
-
__init__
(time, *args, **kwargs)[source]¶ - Parameters
time (float) – number of seconds value must be out of range
*args –
**kwargs –
-
check
(sensor_values)[source]¶ Check that the relevant value in SensorValues is either greater or lesser than the limit
- Parameters
sensor_values (
SensorValues
) –- Returns
bool
-
class
pvp.alarm.condition.
AlarmSeverityCondition
(alarm_type: pvp.alarm.AlarmType, severity: pvp.alarm.AlarmSeverity, mode: str = 'min', *args, **kwargs)[source]¶ Bases:
pvp.alarm.condition.Condition
Alarm is above or below a certain severity.
Get alarm severity status from
Alarm_Manager.get_alarm_severity()
.- Parameters
alarm_type (
AlarmType
) – Alarm type to checkseverity (
AlarmSeverity
) – Alarm severity to check againstmode (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])Alarm is above or below a certain severity.
check
(sensor_values)Every Condition subclass needs to define this method that accepts
SensorValues
and returns a booleanreset
()If a condition is stateful, need to provide some method of resetting the state
Attributes:
‘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’.
-
__init__
(alarm_type: pvp.alarm.AlarmType, severity: pvp.alarm.AlarmSeverity, mode: str = 'min', *args, **kwargs)[source]¶ Alarm is above or below a certain severity.
Get alarm severity status from
Alarm_Manager.get_alarm_severity()
.- Parameters
alarm_type (
AlarmType
) – Alarm type to checkseverity (
AlarmSeverity
) – Alarm severity to check againstmode (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
¶ ‘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 <
- Returns
one of ‘min’, ‘equals’, or ‘max’.
- Return type
-
check
(sensor_values)[source]¶ Every Condition subclass needs to define this method that accepts
SensorValues
and returns a boolean- Parameters
sensor_values (
SensorValues
) – SensorValues used to compute alarm status- Returns
bool
-
class
pvp.alarm.condition.
CycleAlarmSeverityCondition
(n_cycles, *args, **kwargs)[source]¶ Bases:
pvp.alarm.condition.AlarmSeverityCondition
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
-
_mid_check
¶ whether a value has left the acceptable range and we are counting consecutive breath cycles
- Type
Alarm is above or below a certain severity.
Get alarm severity status from
Alarm_Manager.get_alarm_severity()
.- Parameters
alarm_type (
AlarmType
) – Alarm type to checkseverity (
AlarmSeverity
) – Alarm severity to check againstmode (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:
check
(sensor_values)Every Condition subclass needs to define this method that accepts
SensorValues
and returns a booleanreset
()If a condition is stateful, need to provide some method of resetting the state
Attributes:
-
property
n_cycles
¶
-
check
(sensor_values)[source]¶ Every Condition subclass needs to define this method that accepts
SensorValues
and returns a boolean- Parameters
sensor_values (
SensorValues
) – SensorValues used to compute alarm status- Returns
bool
-