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

__analyze_last_waveform()

This goes through the last waveform, and updates VTE, PEEP, PIP, PIP_TIME, I_PHASE, FIRST_PEEP and BPM.

__calculate_control_signal_in()

__get_PID_error(ytarget, yis, dt)

__get_pressure_derivative(dt)

__test_critical_levels(min, max, value, name)

This tests whether a variable is within bounds.

__update_alarms()

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

_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_alarms()

get_control(control_setting_name)

Gets values of the COPY of the control settings.

get_logged_alarms()

get_past_waveforms()

get_sensors()

heartbeat()

only used for fiddling

is_running()

set_control(control_setting)

Updates the entry of COPY contained in the control settings

start()

stop()

Attributes

running

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. 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]
__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.)

__analyze_last_waveform()

This goes through the last waveform, and updates VTE, PEEP, PIP, PIP_TIME, I_PHASE, FIRST_PEEP and BPM.

__update_alarms()

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

get_sensors()vent.common.message.SensorValues[source]
get_alarms() → List[vent.common.message.Alarm][source]
get_active_alarms()[source]
get_logged_alarms() → List[vent.common.message.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_PID_error(ytarget, yis, dt)
__calculate_control_signal_in()
_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

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

only used for fiddling

property running
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.

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

class vent.controller.control_module.ControlModuleSimulator[source]

Bases: vent.controller.control_module.ControlModuleBase

Methods

__SimulatedPropValve(x, dt)

This simulates the action of a proportional valve.

__SimulatedSolenoid(x)

Depending on x, set flow to a binary value.

_sensor_to_COPY()

_start_mainloop()

__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]

__SimulatedSolenoid(x)

Depending on x, set flow to a binary value. Here: flow is either 0 or 1l/sec

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