controller module¶
Classes
|
This is a imple physics simulator for inflating a balloon. |
This is an abstract class for controlling simulation and hardware. |
|
Functions
|
-
class
vent.controller.control_module.
ControlModuleBase
[source]¶ Bases:
object
This is an abstract class for controlling simulation and hardware.
- All internal variables fall in three classes, denoted by the beginning of the variable:
“COPY_varname”: These are copies (see 1.) that are regularly sync’ed with internal variables.
“__varname”: These are variables only used in the ControlModuleBase-Class
“_varname”: These are variables used in derived classes.
- Internal variables should only to be accessed though the set_ and get_ functions.
These functions act on COPIES of internal variables (“__” and “_”), that are sync’d every few iterations. How often this is done is adjusted by the variable self._NUMBER_CONTROLL_LOOPS_UNTIL_UPDATE. To avoid multiple threads manipulating the same variables at the same time, every manipulation of “COPY_” is surrounded by a thread lock.
Methods
This goes through the last waveform, and updates VTE, PEEP, PIP, PIP_TIME, I_PHASE, FIRST_PEEP and BPM.
_ControlModuleBase__get_PID_error
(ytarget, …)This tests whether a variable is within bounds.
This goes through the values obtained from the last waveform, and updates alarms.
resets the PID cycle to zero
_PID_update
(dt)This instantiates the control algorithms.
This is the PID controlled signal on the inspiratory side
This is the control signal (open/close) on the expiratory side
get_control
(control_setting_name)Gets values of the COPY of the control settings.
set_control
(control_setting)Updates the entry of COPY contained in the control settings
start
()stop
()- Public Methods:
get_sensors(): Returns a copy of the current sensor values. get_alarms(): Returns a List of all alarms, active and logged get_active_alarms(): Returns a Dictionary of all currently active alarms. get_logged_alarms(): Returns a List of logged alarms, up to maximum lengh of self._RINGBUFFER_SIZE get_control(ControlSetting): Sets a controll-setting. Is updated at latest within self._NUMBER_CONTROLL_LOOPS_UNTIL_UPDATE get_past_waveforms(): Returns a List of waveforms of pressure and volume during at the last N breath cycles, N<self._RINGBUFFER_SIZE, AND clears this archive. get_target_waveform(): Returns a step-wise linear target waveform, as defined by the current settings. start(): Starts the main-loop of the controller stop(): Stops the main-loop of the controller
-
get_sensors
() → vent.common.message.SensorValues[source]¶
-
get_logged_alarms
() → List[vent.alarm.alarm.Alarm][source]¶
-
set_control
(control_setting: vent.common.message.ControlSetting)[source]¶ Updates the entry of COPY contained in the control settings
-
get_control
(control_setting_name: vent.common.values.ValueName) → vent.common.message.ControlSetting[source]¶ Gets values of the COPY of the control settings.
-
_PID_update
(dt)[source]¶ This instantiates the control algorithms. During the breathing cycle, it goes through the four states:
Rise to PIP
Sustain PIP pressure
Quick fall to PEEP
Sustaint PEEP pressure
Once the cycle is complete, it checks the cycle for any alarms, and starts a new one. A record of pressure/volume waveforms is kept in self.__cycle_waveform_archive
dt: Time since last update in seconds
-
_ControlModuleBase__analyze_last_waveform
()¶ This goes through the last waveform, and updates VTE, PEEP, PIP, PIP_TIME, I_PHASE, FIRST_PEEP and BPM.
-
_ControlModuleBase__calculate_control_signal_in
()¶
-
_ControlModuleBase__get_PID_error
(ytarget, yis, dt)¶
-
_ControlModuleBase__test_critical_levels
(min, max, value, name)¶ This tests whether a variable is within bounds. If it is, and an alarm existed, then the “alarm_end_time” is set. If it is NOT, a new alarm is generated and appendede to the alarm-list. Input:
min: minimum value (e.g. 2) max: maximum value (e.g. 5) value: test value (e.g. 3) name: parameter type (e.g. “PIP”, “PEEP” etc.)
-
_ControlModuleBase__update_alarms
()¶ This goes through the values obtained from the last waveform, and updates alarms.
-
class
vent.controller.control_module.
ControlModuleDevice
[source]¶ Bases:
vent.controller.control_module.ControlModuleBase
Methods
-
class
vent.controller.control_module.
Balloon_Simulator
(leak)[source]¶ Bases:
object
This is a imple physics simulator for inflating a balloon. For math, see https://en.wikipedia.org/wiki/Two-balloon_experiment
Methods
OUupdate
(variable, dt, mu, sigma, tau)This is a simple function to produce an OU process.
_reset
()resets the ballon to standard parameters.
set_flow_in
(Qin, dt)set_flow_out
(Qout, dt)update
(dt)-
OUupdate
(variable, dt, mu, sigma, tau)[source]¶ This is a simple function to produce an OU process. It is used as model for fluctuations in measurement variables. inputs: variable: float value at previous time step dt : timestep mu : mean sigma : noise amplitude tau : time scale returns: new_variable : value of “variable” at next time step
-
-
class
vent.controller.control_module.
ControlModuleSimulator
[source]¶ Bases:
vent.controller.control_module.ControlModuleBase
Methods
This simulates the action of a proportional valve.
Depending on x, set flow to a binary value.
-
_ControlModuleSimulator__SimulatedPropValve
(x, dt)¶ This simulates the action of a proportional valve. Flow-current-curve eye-balled from the datasheet of SMC PVQ31-5G-23-01N https://www.ocpneumatics.com/content/pdfs/PVQ.pdf
x: Input current [mA] dt: Time since last setting in seconds [for the LP filter]
-
_ControlModuleSimulator__SimulatedSolenoid
(x)¶ Depending on x, set flow to a binary value. Here: flow is either 0 or 1l/sec
-