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
digraph inheritance14800c5c76 { bgcolor=transparent; rankdir=LR; size="8.0, 12.0"; "pvp.alarm.condition.AlarmSeverityCondition" [URL="#pvp.alarm.condition.AlarmSeverityCondition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top"]; "pvp.alarm.condition.Condition" -> "pvp.alarm.condition.AlarmSeverityCondition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "pvp.alarm.condition.Condition" [URL="#pvp.alarm.condition.Condition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Base class for specifying alarm test conditions"]; "pvp.alarm.condition.CycleAlarmSeverityCondition" [URL="#pvp.alarm.condition.CycleAlarmSeverityCondition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="alarm goes out of range for a specific number of breath cycles"]; "pvp.alarm.condition.AlarmSeverityCondition" -> "pvp.alarm.condition.CycleAlarmSeverityCondition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "pvp.alarm.condition.CycleValueCondition" [URL="#pvp.alarm.condition.CycleValueCondition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Value goes out of range for a specific number of breath cycles"]; "pvp.alarm.condition.ValueCondition" -> "pvp.alarm.condition.CycleValueCondition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "pvp.alarm.condition.TimeValueCondition" [URL="#pvp.alarm.condition.TimeValueCondition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="value goes out of range for specific amount of time"]; "pvp.alarm.condition.ValueCondition" -> "pvp.alarm.condition.TimeValueCondition" [arrowsize=0.5,style="setlinewidth(0.5)"]; "pvp.alarm.condition.ValueCondition" [URL="#pvp.alarm.condition.ValueCondition",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=10,height=0.25,shape=box,style="setlinewidth(0.5),filled",target="_top",tooltip="Value is greater or lesser than some max/min"]; "pvp.alarm.condition.Condition" -> "pvp.alarm.condition.ValueCondition" [arrowsize=0.5,style="setlinewidth(0.5)"]; }Functions:
Classes:
|
Base class for specifying alarm test conditions |
|
Value is greater or lesser than some max/min |
|
Value goes out of range for a specific number of breath cycles |
|
value goes out of range for specific amount of time |
|
Alarm is above or below a certain severity. |
|
alarm goes out of range for a specific number of breath cycles |
- class pvp.alarm.condition.Condition(depends: Optional[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
Attributes:
Number of cycles required
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
- 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: str¶
‘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=None)[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 –
Attributes:
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
- 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