Closed sneakers-the-rat closed 4 years ago
i'll go thru and make line-by-line comments as needed after dinner
Changes Missing Coverage | Covered Lines | Changed/Added Lines | % | ||
---|---|---|---|---|---|
vent/alarm/alarm.py | 42 | 43 | 97.67% | ||
vent/alarm/rule.py | 23 | 24 | 95.83% | ||
vent/controller/control_module.py | 13 | 14 | 92.86% | ||
vent/gui/alarm_manager.py | 1 | 2 | 50.0% | ||
vent/gui/main.py | 4 | 5 | 80.0% | ||
vent/io/devices/base.py | 9 | 10 | 90.0% | ||
vent/gui/widgets/status_bar.py | 4 | 10 | 40.0% | ||
vent/common/message.py | 27 | 37 | 72.97% | ||
vent/gui/widgets/components.py | 1 | 14 | 7.14% | ||
vent/alarm/alarm_manager.py | 126 | 144 | 87.5% | ||
<!-- | Total: | 422 | 500 | 84.4% | --> |
Files with Coverage Reduction | New Missed Lines | % | ||
---|---|---|---|---|
vent/gui/alarm_manager.py | 2 | 41.03% | ||
vent/controller/control_module.py | 15 | 84.85% | ||
<!-- | Total: | 17 | --> |
Totals | |
---|---|
Change from base Build 250: | 4.7% |
Covered Lines: | 2222 |
Relevant Lines: | 3011 |
one of each alarm type can be active at a time. put another way, all alarm types can be active at the same time. the GUI will manage a coherent display that prioritizes and manages them.
sorry for not merging -- forgot we said for PR submitter to merge after we discuss. Will merge in now
OK this is thee alarm system. might be easier to get an overview from the docs: https://ventilator.readthedocs.io/en/gui/alarm.html
Overview (sorry this is all out of order i'm really really hungry and am racing to go eat):
AlarmType
- There a specific set of alarms that can be triggered, rather than any out-of-bounds value, so it's actually an alarm system.AlarmSeverity
- Explicit enum allows alarm severity to be compared numericallyAlarm_Rule
s describe how an alarm behaves, including what triggers what severity of alarm. They consist of a tuple of(AlarmSeverity, Condition)
tuples. They also define whether an alarmlatches
or not (persistent
) alarms are not implementedCondition
s have essentially onecheck
method that takesSensorValues
. They can be subclassed to add iteratively complex behavior (easier to just see for yourself i think), and can also be+
added together to require multiple conditions to be true for a given alarm severity.Conditions
can also declare dependencies like being some transformation (subtract, multiple, any callable) of aControlSetting
. eg 115% of PIP. (tests are not finished for this)Alarm_Rule
check
s each of its conditions -- each 'multiple (added)' Condition terminates at its firstFalse
so they're not super wasteful -- and emits the highest severity alarm that is trueAlarm_Rules
are declared in/vent/alarm/__init__.py
Alarm_Manager
handles all the logic of raising, suppressing, and storing alarms. There can only be oneAlarm_Manager
instance, so it is safe to use instantiation to get a reference to it. The alarm manager loads the default alarms on creation. The alarm manager acceptsSensorValues
in itsupdate
method, which then checks all of itsrules
.Alarm_Manager
is evented -- it doesn't poll, but can be updated with new SensorValues whenever needed. You are not supposed to poll theAlarm_Manager
(likeget_alarms
) - instead you shouldadd_callback
and give it a callable that will be called with anAlarm
anytime it is emitted.rule
is OFF AND the user callsdismiss_alarm
.emit
method, alarms are turned off by emitting an alarm with a severity ofOFF
.logged_alarms
but this needs to be integrated with whatever logging module @mschottdorf (i believe?) cooks up. Since theAlarm_Manager
is evented, each Alarm object is self-descriptive, and turning alarmsOFF
is implemented using the same methods and objects (rather than by, say, deleting objects), logging should only need to be implemented in a single method that is added to the Alarm_Manager's callbacks.~Other stuff~
GREEN, YELLOW, RED
toOFF, LOW, MEDIUM, HIGH
SensorValues
now ensures that it is given a value for every item invalues.SENSOR
, and takes them as a dictionary rather than by unpacking **kwargs. as such no emptySensorValues
objects can be instantiatedSensorValues
has__getitem__
and__setitem__
so sensor values can be accessed and set both as instance attributes but also like a dictionary (sensor['PRESSURE']
)SensorValues
now has anadditional_values
attribute that keeps track of the values that the controller generates and sends like timestamp, cycle counter, etc. there's certainly a better way of doing that but it works for now.SensorValues
and thecontrol_module
have been updated to also track the current breath cycle (withitertools.count
, otherwise just slipped into your existing code @mschottdorf ) -- this is useful for alarms that depend on, well, breath cycles. I'll need some help writing a test to make sure that number is actually accurate and i did it rightvalues
now has all values inValueName
declared inVALUES
.CONTROL
andSENSOR
are built fromVALUE
based on two new parameters,control
andsensor
.vent/io/devices/base
~ TODO ~
but otherwise ya what up