Display¶
Unified monitor & control widget
Displays sensor values, and can optionally control system settings.
The PVP_Gui
instantiates display widgets according to the contents of values.DISPLAY_CONTROL
and values.DISPLAY_MONITOR
Classes:
|
An enumeration. |
|
Message containing ventilation control parameters. |
|
Unified widget for display of sensor values and control of ventilation parameters |
|
Slider capable of representing floats |
|
Editable label https://gist.github.com/mfessenden/baa2b87b8addb0b60e54a11c1da48046 |
|
Widget to display current value in a bar graph along with alarm limits |
|
|
|
Class to parameterize how a value is used in PVP. |
|
Canonical names of all values used in PVP. |
Functions:
|
Initialize a logger for logging events. |
|
module function to return a |
|
Creates a dialog box to display a message. |
-
class
pvp.gui.widgets.display.
Display
(value: pvp.common.values.Value, update_period: float = 0.5, enum_name: pvp.common.values.ValueName = None, button_orientation: str = 'left', control_type: Union[None, str] = None, style: str = 'dark', *args, **kwargs)[source]¶ Unified widget for display of sensor values and control of ventilation parameters
Displayed values are updated according to
Dispaly.timed_update()
- Parameters
value (
Value
) – Value object to representupdate_period (float) – Amount of time between updates of the textual display of values
enum_name (
ValueName
) – Value name of object to representbutton_orientation ('left', 'right') – whether the controls are drawn on the
'left'
or'right'
control_type (None, 'slider', 'record') – type of control - either
None
(no control),slider
(a slider can be opened to set a value), orrecord
where recent sensor values are averaged and used to set the control value. Both types of control allow values to be input from the keyboard by clicking on the editable labelstyle ('light', 'dark') – whether the widget is
'dark'
(light text on dark background) or'light'
(dark text on light background**kwargs (*args,) –
passed on to
PySide2.QtWidgets.QWidget
-
self.
name
¶ Unpacked from
value
-
self.
units
¶ Unpacked from
value
-
self.
abs_range
¶ Unpacked from
value
-
self.
safe_range
¶ Unpacked from
value
-
self.
alarm_range
¶ initialized from
value
, but updated by alarm manager
-
self.
decimals
¶ Unpacked from
value
-
self.
orientation
¶ whether the controls are drawn on the
'left'
or'right'
- Type
‘left’, ‘right’
-
self.
control
¶ type of control - either
None
(no control),slider
(a slider can be opened to set a value), orrecord
where recent sensor values are averaged and used to set the control value.- Type
None, ‘slider’, ‘record’
-
self.
_style
¶ whether the widget is
'dark'
(light text on dark background) or'light'
(dark text on light background)- Type
‘light’, ‘dark’
Methods:
_value_changed
(new_value)“outward-directed” method to emit new changed control value when changed by this widget
init_ui
()UI is initialized in several stages
Basically two methods.
Create widgets to display sensed value alongside set value
redraw
()Redraw all graphical elements to ensure internal model matches view
set_locked
(locked)Set locked status of control
set_units
(units)Set pressure units to display as cmH2O or hPa.
Refresh textual sensor values only periodically to prevent them from being totally unreadable from being changed too fast.
toggle_control
(state)Toggle the appearance of the slider, if a slider
toggle_record
(state)Toggle the recording state, if a recording control
update_limits
(control)Update the alarm range and the GUI elements corresponding to it
update_sensor_value
(new_value)Receive new sensor value and update display widgets
update_set_value
(new_value)Update to reflect new control value set from elsewhere (inwardly directed setter)
Attributes:
Current visual display of alarm severity
Check if value has been set for this control.
value_changed
(*args, **kwargs)Signal emitted when controlled value of display object has changed.
-
value_changed
(*args, **kwargs) = <PySide2.QtCore.Signal object>¶ Signal emitted when controlled value of display object has changed.
Contains new value (float)
-
init_ui
()[source]¶ UI is initialized in several stages
0: this method, get stylesheets based on
self._style
and call remaining initialization methods1:
Display.init_ui_labels()
- create generic labels shared by all display objects2:
Display.init_ui_toggle_button()
- create the toggle or record button used by controls3:
Display.init_ui_limits()
- create a plot that displays the sensor value graphically relative to the alarm limits4:
Display.init_ui_slider()
orDisplay.ini_ui_record()
- depending on what type of control this is5:
Display.init_ui_layout()
since the results of the previous steps varies, do all layout at the end depending on orientation6:
Display.init_ui_signals()
connect slots and signals
-
init_ui_layout
()[source]¶ Basically two methods… lay objects out depending on whether we’re oriented with our button to the left or right
-
toggle_control
(state)[source]¶ Toggle the appearance of the slider, if a slider
- Parameters
state (bool) – Whether to show or hide the slider
-
toggle_record
(state)[source]¶ Toggle the recording state, if a recording control
- Parameters
state (bool) – Whether recording should be started or stopped. when started, start storing new sensor values in a list. when stopped, average thgem and emit new value.
-
_value_changed
(new_value: float)[source]¶ “outward-directed” method to emit new changed control value when changed by this widget
Pop a confirmation dialog if values are set outside the safe range.
-
update_set_value
(new_value: float)[source]¶ Update to reflect new control value set from elsewhere (inwardly directed setter)
- Parameters
new_value (float) – new value to set!
-
update_sensor_value
(new_value: float)[source]¶ Receive new sensor value and update display widgets
- Parameters
new_value (float) – new sensor value!
-
update_limits
(control: pvp.common.message.ControlSetting)[source]¶ Update the alarm range and the GUI elements corresponding to it
- Parameters
control (
ControlSetting
) – control setting with min_value or max_value
-
redraw
()[source]¶ Redraw all graphical elements to ensure internal model matches view
Typically used when changing units
-
timed_update
()[source]¶ Refresh textual sensor values only periodically to prevent them from being totally unreadable from being changed too fast.
-
set_units
(units: str)[source]¶ Set pressure units to display as cmH2O or hPa.
Uses functions from
pvp.common.unit_conversion
such thatself._convert_in
converts internal, canonical units to displayed units (eg.cmH2O
is used by all other modules, so we convert it tohPa
self._convert_out
converts displayed units to send to other parts of the system
Note
currently unit conversion is only supported for Pressure.
- Parameters
units ('cmH2O', 'hPa') – new units to display
-
set_locked
(locked: bool)[source]¶ Set locked status of control
- Parameters
locked (bool) – If True, disable all controlling widgets, if False, re-enable.
-
property
is_set
¶ Check if value has been set for this control.
Used to check if all settings have been set preflight by
PVP_Gui
- Returns
whether we have an
Display.set_value
- Return type
-
property
alarm_state
¶ Current visual display of alarm severity
Change sensor value color to reflect the alarm state of that set parameter –
eg. if we have a HAPA alarm, set the PIP control to display as red.
- Returns
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
class
pvp.gui.widgets.display.
Limits_Plot
(style: str = 'light', *args, **kwargs)[source]¶ Widget to display current value in a bar graph along with alarm limits
- Parameters
style ('light', 'dark') – Whether we are being displayed in a light or dark styled
Display
widget
-
set_value
¶ Set value of control, displayed as horizontal black line always set at center of bar
- Type
When initializing PlotWidget, parent and background are passed to
GraphicsWidget.__init__()
and all others are passed toPlotItem.__init__()
.Methods:
init_ui
()Create bar chart and horizontal lines to reflect
update_value
([min, max, sensor_value, set_value])Move the lines! Pass any of the represented values.
Set yrange to ensure that the set value is always in the center of the plot and that all the values are in range.
Attributes:
-
staticMetaObject
= <PySide2.QtCore.QMetaObject object>¶
-
init_ui
()[source]¶ Create bar chart and horizontal lines to reflect
Sensor Value
Set Value
High alarm limit
Low alarm limit