vent.gui package

Submodules

vent.gui.alarm_manager module

Classes

AlarmManager()

Functions

get_alarm_manager()

vent.gui.alarm_manager.get_alarm_manager()[source]
class vent.gui.alarm_manager.AlarmManager[source]

Bases: PySide2.QtCore.QObject

Methods

monitor_alarm(alarm)

Parse a tentative alarm from a monitor – we should have already gotten an alarm from the controller, so this largely serves as a double check.

parse_message(alarm)

If an alarm doesn’t have a message attr, make one for it.

update_alarms(alarms)

new_alarm(*args, **kwargs) = <PySide2.QtCore.Signal object>
update_alarms(alarms)[source]
monitor_alarm(alarm)[source]

Parse a tentative alarm from a monitor – we should have already gotten an alarm from the controller, so this largely serves as a double check.

Doesn’t use the Alarm class because creating a new alarm increments the counter.

Parameters

alarm (tuple) – (monitor_name, monitor_value, timestamp)

parse_message(alarm)[source]

If an alarm doesn’t have a message attr, make one for it.

staticMetaObject = <PySide2.QtCore.QMetaObject object>

vent.gui.main module

Classes

Vent_Gui(coordinator[, update_period])

The Main GUI window.

Functions

launch_gui(coordinator)

class vent.gui.main.Vent_Gui(coordinator, update_period=0.1)[source]

Bases: PySide2.QtWidgets.QMainWindow

The Main GUI window.

Only one instance can be created at a time. Uses set_gui_instance() to store a reference to itself. after initialization, use get_gui_instance to retrieve a reference.

Attributes

CONTROL

see gui.defaults.CONTROL

MONITOR

see gui.defaults.SENSOR

PLOTS

see gui.defaults.PLOTS

alarm_state

alarms_updated(*args, **kwargs)

PySide2.QtCore.Signal emitted whenever alarms are updated.

control_width

int([x]) -> integer

gui_closing(*args, **kwargs)

PySide2.QtCore.Signal emitted when the GUI is closing.

main_height

int([x]) -> integer

monitor_width

int([x]) -> integer

plot_width

int([x]) -> integer

status_height

int([x]) -> integer

total_height

computed from status_height+main_height

total_width

computed from monitor_width+plot_width+control_width

update_period

Methods

__init__(coordinator[, update_period])

The Main GUI window.

alarm_state_changed(state)

closeEvent(event)

Emit gui_closing and close!

handle_alarm(alarm)

handle_cleared_alarm(alarm)

init_controls()

on startup, set controls in coordinator to ensure init state is synchronized

init_ui()

Create the UI components for the ventilator screen

init_ui_controls()

init_ui_monitor()

init_ui_plots()

init_ui_signals()

Connect Qt signals and slots

init_ui_status_bar()

set_plot_duration(dur)

set_value(new_value[, value_name])

Set a control value with the coordinator

start()

Click the start() button

update_gui()

update_value(value_name, new_value)

param value_name

Name of key in Vent_Gui.monitor and Vent_Gui.plots to update

monitor

Dictionary mapping values.SENSOR keys to widgets.Monitor_Value objects

Type

dict

plots

Dictionary mapping gui.PLOT keys to widgets.Plot objects

Type

dict

controls

Dictionary mapping values.CONTROL keys to widgets.Control objects

Type

dict

coordinator

Some coordinator object that we use to communicate with the controller

Type

vent.coordinator.coordinator.CoordinatorBase

control_module

Reference to the control module, retrieved from coordinator

Type

vent.controller.control_module.ControlModuleBase

start_time

Start time as returned by time.time()

Type

float

update_period

The global delay between redraws of the GUI (seconds)

Type

float

alarm_manager
Type

AlarmManager

Parameters
  • update_period (float) – The global delay between redraws of the GUI (seconds)

  • test (bool) – Whether the monitored values and plots should be fed sine waves for visual testing.

gui_closing(*args, **kwargs) = <PySide2.QtCore.Signal object>

PySide2.QtCore.Signal emitted when the GUI is closing.

alarms_updated(*args, **kwargs) = <PySide2.QtCore.Signal object>

PySide2.QtCore.Signal emitted whenever alarms are updated.

Returns the result of self.coordinator.get_active_alarms, so will emit an empty dict if there are no active alarms.

MONITOR = OrderedDict([(<ValueName.FIO2: 8>, <vent.common.values.Value object>), (<ValueName.TEMP: 9>, <vent.common.values.Value object>), (<ValueName.HUMIDITY: 10>, <vent.common.values.Value object>), (<ValueName.VTE: 11>, <vent.common.values.Value object>), (<ValueName.PRESSURE: 12>, <vent.common.values.Value object>), (<ValueName.PIP: 1>, <vent.common.values.Value object>), (<ValueName.INSPIRATION_TIME_SEC: 6>, <vent.common.values.Value object>), (<ValueName.PEEP: 3>, <vent.common.values.Value object>), (<ValueName.BREATHS_PER_MINUTE: 5>, <vent.common.values.Value object>)])

see gui.defaults.SENSOR

CONTROL = OrderedDict([(<ValueName.PIP: 1>, <vent.common.values.Value object>), (<ValueName.PIP_TIME: 2>, <vent.common.values.Value object>), (<ValueName.INSPIRATION_TIME_SEC: 6>, <vent.common.values.Value object>), (<ValueName.PEEP: 3>, <vent.common.values.Value object>), (<ValueName.PEEP_TIME: 4>, <vent.common.values.Value object>), (<ValueName.BREATHS_PER_MINUTE: 5>, <vent.common.values.Value object>)])

see gui.defaults.CONTROL

PLOTS = OrderedDict([(<ValueName.PRESSURE: 12>, {'name': 'Pressure', 'units': 'mmH2O', 'abs_range': (0, 70), 'safe_range': (0, 60), 'decimals': 1, 'default': None, 'control': False, 'sensor': True, 'color': '#FF6319'}), (<ValueName.TEMP: 9>, {'name': 'Temp', 'units': '°C', 'abs_range': (35, 40), 'safe_range': (36, 39), 'decimals': 1, 'default': None, 'control': False, 'sensor': True, 'color': '#EE352E'}), (<ValueName.HUMIDITY: 10>, {'name': 'Humidity', 'units': '%', 'abs_range': (0, 100), 'safe_range': (70, 100), 'decimals': 1, 'default': None, 'control': False, 'sensor': True, 'color': '#0039A6'})])

see gui.defaults.PLOTS

monitor_width = 2
plot_width = 4
control_width = 2
total_width = 8

computed from monitor_width+plot_width+control_width

status_height = 1
main_height = 5
total_height = 6

computed from status_height+main_height

__init__(coordinator, update_period=0.1)[source]

The Main GUI window.

Only one instance can be created at a time. Uses set_gui_instance() to store a reference to itself. after initialization, use get_gui_instance to retrieve a reference.

monitor

Dictionary mapping values.SENSOR keys to widgets.Monitor_Value objects

Type

dict

plots

Dictionary mapping gui.PLOT keys to widgets.Plot objects

Type

dict

controls

Dictionary mapping values.CONTROL keys to widgets.Control objects

Type

dict

coordinator

Some coordinator object that we use to communicate with the controller

Type

vent.coordinator.coordinator.CoordinatorBase

control_module

Reference to the control module, retrieved from coordinator

Type

vent.controller.control_module.ControlModuleBase

start_time

Start time as returned by time.time()

Type

float

update_period

The global delay between redraws of the GUI (seconds)

Type

float

alarm_manager
Type

AlarmManager

Parameters
  • update_period (float) – The global delay between redraws of the GUI (seconds)

  • test (bool) – Whether the monitored values and plots should be fed sine waves for visual testing.

property update_period
init_controls()[source]

on startup, set controls in coordinator to ensure init state is synchronized

set_value(new_value, value_name=None)[source]

Set a control value with the coordinator

Parameters

new_value (float) – Som

update_gui()[source]
update_value(value_name, new_value)[source]
Parameters
init_ui()[source]

Create the UI components for the ventilator screen

init_ui_status_bar()[source]
init_ui_monitor()[source]
init_ui_plots()[source]
init_ui_controls()[source]
init_ui_signals()[source]

Connect Qt signals and slots

staticMetaObject = <PySide2.QtCore.QMetaObject object>
handle_alarm(alarm)[source]
handle_cleared_alarm(alarm)[source]
property alarm_state
alarm_state_changed(state)[source]
set_plot_duration(dur)[source]
closeEvent(event)[source]

Emit gui_closing and close!

start()[source]

Click the start() button

Returns:

vent.gui.main.launch_gui(coordinator)[source]

vent.gui.styles module

Data

MONITOR_UPDATE_INTERVAL

inter-update interval (seconds) for Monitor

Functions

set_dark_palette(app)

Apply Dark Theme to the Qt application instance.

vent.gui.styles.MONITOR_UPDATE_INTERVAL = 0.5

inter-update interval (seconds) for Monitor

Type

(float)

vent.gui.styles.set_dark_palette(app)[source]

Apply Dark Theme to the Qt application instance.

borrowed from https://github.com/gmarull/qtmodern/blob/master/qtmodern/styles.py
Args:

app (QApplication): QApplication instance.

Module contents

Data

LIMIT_GUI_INSTANCE

whether there hsould only be one GUI instance at a time. disabled during testing.

PLOTS

Values to plot.

Functions

get_gui_instance()

Retreive the currently running instance of the GUI

limit_gui([limit])

load_mono_font()

Load the monospaced font and set the module-global _MONO_FONT object.

mono_font()

module function to return a PySide2.QtGui.QFont to use as the mono font.

set_gui_instance(instance)

Store the current instance of the GUI

vent.gui.LIMIT_GUI_INSTANCE = False

whether there hsould only be one GUI instance at a time. disabled during testing.

Type

(bool)

vent.gui.limit_gui(limit=None)[source]
vent.gui.PLOTS = OrderedDict([(<ValueName.PRESSURE: 12>, {'name': 'Pressure', 'units': 'mmH2O', 'abs_range': (0, 70), 'safe_range': (0, 60), 'decimals': 1, 'default': None, 'control': False, 'sensor': True, 'color': '#FF6319'}), (<ValueName.TEMP: 9>, {'name': 'Temp', 'units': '°C', 'abs_range': (35, 40), 'safe_range': (36, 39), 'decimals': 1, 'default': None, 'control': False, 'sensor': True, 'color': '#EE352E'}), (<ValueName.HUMIDITY: 10>, {'name': 'Humidity', 'units': '%', 'abs_range': (0, 100), 'safe_range': (70, 100), 'decimals': 1, 'default': None, 'control': False, 'sensor': True, 'color': '#0039A6'})])

Values to plot.

Should have the same key as some key in SENSOR. If it does, it will be mutually connected to the resulting gui.widgets.Monitor_Value such that the set limit range is updated when the horizontal bars on the plot are updated.:

{
    'name' (str): title of plot,
    'abs_range' (tuple): absolute limit of plot range,
    'safe_range' (tuple): safe range, will be discolored outside of this range,
    'color' (str): hex color of line (like "#FF0000")
}
vent.gui.set_gui_instance(instance)[source]

Store the current instance of the GUI

Parameters

instance (Vent_Gui) –

vent.gui.mono_font()[source]

module function to return a PySide2.QtGui.QFont to use as the mono font.

use this instead of just making because PySide2.QtGui.QFontDatabase can’t be instantiated before the PySide2.QtWidgets.QApplication is instantiated, so we load the font after the app

vent.gui.load_mono_font()[source]

Load the monospaced font and set the module-global _MONO_FONT object.

Note

Must be called after PySide2.QtWidgets.QApplication is instantiated!

vent.gui.get_gui_instance()[source]

Retreive the currently running instance of the GUI

Returns

Vent_Gui