controller module

Classes

Balloon_Simulator(leak)

This is a imple physics simulator for inflating a balloon.

ControlModuleBase()

This is an abstract class for controlling simulation and hardware.

ControlModuleDevice()

ControlModuleSimulator()

Functions

get_control_module([sim_mode])

class vent.controller.control_module.ControlModuleBase[source]

Bases: object

This is an abstract class for controlling simulation and hardware.

  1. 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.

  2. 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

_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, …)

_ControlModuleBase__test_critical_levels(…)

This tests whether a variable is within bounds.

_ControlModuleBase__update_alarms()

This goes through the values obtained from the last waveform, and updates alarms.

_PID_reset()

resets the PID cycle to zero

_PID_update(dt)

This instantiates the control algorithms.

_alarm_to_COPY()

_controls_from_COPY()

_get_control_signal_in()

This is the PID controlled signal on the inspiratory side

_get_control_signal_out()

This is the control signal (open/close) on the expiratory side

_initialize_set_to_COPY()

_sensor_to_COPY()

_start_mainloop()

do_pid_control()

do_state_control()

get_active_alarms()

get_control(control_setting_name)

Gets values of the COPY of the control settings.

get_logged_alarms()

get_past_waveforms()

get_sensors()

get_target_waveform()

is_running()

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

_initialize_set_to_COPY()[source]
_alarm_to_COPY()[source]
_sensor_to_COPY()[source]
_controls_from_COPY()[source]
get_sensors()vent.common.message.SensorValues[source]
get_active_alarms()[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.

_get_control_signal_in()[source]

This is the PID controlled signal on the inspiratory side

_get_control_signal_out()[source]

This is the control signal (open/close) on the expiratory side

_PID_reset()[source]

resets the PID cycle to zero

_PID_update(dt)[source]

This instantiates the control algorithms. During the breathing cycle, it goes through the four states:

  1. Rise to PIP

  2. Sustain PIP pressure

  3. Quick fall to PEEP

  4. 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

get_past_waveforms()[source]
get_target_waveform()[source]
_start_mainloop()[source]
start()[source]
stop()[source]
is_running()[source]
do_pid_control()[source]
do_state_control()[source]
_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

_sensor_to_COPY()

_start_mainloop()

_sensor_to_COPY()[source]
_start_mainloop()[source]
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.

get_pressure()

get_volume()

set_flow_in(Qin, dt)

set_flow_out(Qout, dt)

update(dt)

get_pressure()[source]
get_volume()[source]
set_flow_in(Qin, dt)[source]
set_flow_out(Qout, dt)[source]
update(dt)[source]
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

_reset()[source]

resets the ballon to standard parameters.

class vent.controller.control_module.ControlModuleSimulator[source]

Bases: vent.controller.control_module.ControlModuleBase

Methods

_ControlModuleSimulator__SimulatedPropValve(x, dt)

This simulates the action of a proportional valve.

_ControlModuleSimulator__SimulatedSolenoid(x)

Depending on x, set flow to a binary value.

_sensor_to_COPY()

_start_mainloop()

_sensor_to_COPY()[source]
_start_mainloop()[source]
_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

vent.controller.control_module.get_control_module(sim_mode=False)[source]