Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
HEV - High Energy Ventilator
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
5
Issues
5
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
HEV - High Energy Ventilator
Commits
05db8768
Commit
05db8768
authored
May 26, 2021
by
Karol Hennessy
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ui_dev' into test_UI_new_state_machines_merge
parents
d7013674
fabb9426
Pipeline
#1589
failed with stages
Changes
20
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
424 additions
and
306 deletions
+424
-306
NativeUI.py
NativeUI/NativeUI.py
+67
-11
alarm_popup.py
NativeUI/alarm_widgets/alarm_popup.py
+34
-28
alarm_table.py
NativeUI/alarm_widgets/alarm_table.py
+25
-38
clinical_config.json
NativeUI/configs/clinical_config.json
+1
-1
colors.json
NativeUI/configs/colors.json
+10
-10
mode_config.json
NativeUI/configs/mode_config.json
+2
-2
global_send_popup.py
NativeUI/global_widgets/global_send_popup.py
+18
-14
global_typeval_popup.py
NativeUI/global_widgets/global_typeval_popup.py
+12
-9
tab_modeswitch_button.py
NativeUI/global_widgets/tab_modeswitch_button.py
+34
-68
clinical_handler.py
NativeUI/mode_widgets/clinical_handler.py
+7
-0
mode_handler.py
NativeUI/mode_widgets/mode_handler.py
+17
-1
ui_layout.py
NativeUI/ui_layout.py
+8
-7
ui_widgets.py
NativeUI/ui_widgets.py
+10
-8
expert_handler.py
NativeUI/widget_library/expert_handler.py
+3
-0
page_buttons_widget.py
NativeUI/widget_library/page_buttons_widget.py
+23
-33
plot_widget.py
NativeUI/widget_library/plot_widget.py
+7
-7
spin_buttons_widget.py
NativeUI/widget_library/spin_buttons_widget.py
+0
-1
switchable_stack_widget.py
NativeUI/widget_library/switchable_stack_widget.py
+6
-1
CommsCommon.py
raspberry-dataserver/CommsCommon.py
+17
-0
hevserver.py
raspberry-dataserver/hevserver.py
+123
-67
No files found.
NativeUI/NativeUI.py
View file @
05db8768
...
@@ -7,12 +7,15 @@ Command-line arguments:
...
@@ -7,12 +7,15 @@ Command-line arguments:
-d, --debug : set the level of debug output.Include once for INFO, twice for DEBUG
-d, --debug : set the level of debug output.Include once for INFO, twice for DEBUG
-w, --windowed : run the user interface in windowed mode.
-w, --windowed : run the user interface in windowed mode.
-r, --resolution : set the window size in pixels. E.g. -r 1920x1080
-r, --resolution : set the window size in pixels. E.g. -r 1920x1080
--no-startup : start the UI without going through the calibration startup sequence.
-l, --language : set the initial language for the UI (can later be set within the
interface). Defaults to English.
"""
"""
__author__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tiago Sarmento"
]
__author__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__license__
=
"GPL"
__license__
=
"GPL"
__version__
=
"0.1.
1
"
__version__
=
"0.1.
2
"
__maintainer__
=
"Benjamin Mummery"
__maintainer__
=
"Benjamin Mummery"
__email__
=
"benjamin.mummery@stfc.ac.uk"
__email__
=
"benjamin.mummery@stfc.ac.uk"
__status__
=
"Prototype"
__status__
=
"Prototype"
...
@@ -113,6 +116,9 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -113,6 +116,9 @@ class NativeUI(HEVClient, QMainWindow):
):
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
super
()
.
__init__
(
*
args
,
**
kwargs
)
# store variable to change editability of screen - implemented in screen locking
self
.
enableState
=
True
# Set the resolution of the display window
# Set the resolution of the display window
self
.
screen_width
=
resolution
[
0
]
self
.
screen_width
=
resolution
[
0
]
self
.
screen_height
=
resolution
[
1
]
self
.
screen_height
=
resolution
[
1
]
...
@@ -148,8 +154,12 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -148,8 +154,12 @@ class NativeUI(HEVClient, QMainWindow):
# Set up fonts based on the screen resolution. text_font and value_font are 20
# Set up fonts based on the screen resolution. text_font and value_font are 20
# and 40px respectively for 1920*1080.
# and 40px respectively for 1920*1080.
self
.
text_font
=
QFont
(
"Sans Serif"
,
resolution
[
0
]
/
96
)
self
.
text_font
=
QFont
(
"Sans Serif"
,
int
(
resolution
[
0
]
/
96
))
self
.
value_font
=
QFont
(
"Sans Serif"
,
2
*
resolution
[
0
]
/
96
)
self
.
value_font
=
QFont
(
"Sans Serif"
,
int
(
2
*
resolution
[
0
]
/
96
))
# Set the popup size based on the screen resolution. alarm_popup_width is 400
# for 1920*1080
self
.
alarm_popup_width
=
int
(
resolution
[
0
]
/
4.8
)
# Import icons
# Import icons
self
.
icons
=
{
self
.
icons
=
{
...
@@ -157,6 +167,7 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -157,6 +167,7 @@ class NativeUI(HEVClient, QMainWindow):
"button_alarms_page"
:
"exclamation-triangle-solid"
,
"button_alarms_page"
:
"exclamation-triangle-solid"
,
"button_modes_page"
:
"fan-solid"
,
"button_modes_page"
:
"fan-solid"
,
"button_settings_page"
:
"sliders-h-solid"
,
"button_settings_page"
:
"sliders-h-solid"
,
"lock_screen"
:
"lock-solid"
,
}
}
self
.
iconext
=
"png"
self
.
iconext
=
"png"
self
.
iconpath
=
self
.
__find_icons
(
self
.
iconext
)
self
.
iconpath
=
self
.
__find_icons
(
self
.
iconext
)
...
@@ -169,6 +180,8 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -169,6 +180,8 @@ class NativeUI(HEVClient, QMainWindow):
palette
=
self
.
palette
()
palette
=
self
.
palette
()
palette
.
setColor
(
QPalette
.
Window
,
self
.
colors
[
"page_background"
])
palette
.
setColor
(
QPalette
.
Window
,
self
.
colors
[
"page_background"
])
self
.
alt_palette
=
self
.
palette
()
# Set up the handlers
# Set up the handlers
self
.
battery_handler
=
BatteryHandler
()
self
.
battery_handler
=
BatteryHandler
()
self
.
data_handler
=
DataHandler
(
plot_history_length
=
1000
)
self
.
data_handler
=
DataHandler
(
plot_history_length
=
1000
)
...
@@ -324,7 +337,8 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -324,7 +337,8 @@ class NativeUI(HEVClient, QMainWindow):
)
)
)
)
# TODO: command sending
# Startup next and skip buttons should move from the startup widget to the main
# display
self
.
widgets
.
nextButton
.
pressed
.
connect
(
self
.
widgets
.
nextButton
.
pressed
.
connect
(
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
main_display
)
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
main_display
)
)
)
...
@@ -332,6 +346,12 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -332,6 +346,12 @@ class NativeUI(HEVClient, QMainWindow):
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
main_display
)
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
main_display
)
)
)
self
.
widgets
.
lock_button
.
PageButtonPressed
.
connect
(
self
.
toggle_editability
)
# Startup next button should send the ventilator start command.
self
.
widgets
.
nextButton
.
pressed
.
connect
(
lambda
:
self
.
q_send_cmd
(
"GENERAL"
,
"START"
)
)
# Battery Display should update when we get battery info
# Battery Display should update when we get battery info
self
.
battery_handler
.
UpdateBatteryDisplay
.
connect
(
self
.
battery_handler
.
UpdateBatteryDisplay
.
connect
(
self
.
widgets
.
battery_display
.
update_status
self
.
widgets
.
battery_display
.
update_status
...
@@ -372,6 +392,12 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -372,6 +392,12 @@ class NativeUI(HEVClient, QMainWindow):
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
startupWidget
)
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
startupWidget
)
)
)
self
.
typeValPopupNum
.
okButton
.
pressed
.
connect
(
self
.
typeValPopupNum
.
handle_ok_press
)
self
.
typeValPopupAlpha
.
okButton
.
pressed
.
connect
(
self
.
typeValPopupNum
.
handle_ok_press
)
##### Mode:
##### Mode:
# When mode is switched from mode page, various other locations must respond
# When mode is switched from mode page, various other locations must respond
for
widget
in
self
.
mode_handler
.
spinDict
.
values
():
for
widget
in
self
.
mode_handler
.
spinDict
.
values
():
...
@@ -433,18 +459,26 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -433,18 +459,26 @@ class NativeUI(HEVClient, QMainWindow):
button_widget
.
pressed
.
connect
(
button_widget
.
pressed
.
connect
(
lambda
i
=
key
:
self
.
mode_handler
.
handle_okbutton_click
(
i
)
lambda
i
=
key
:
self
.
mode_handler
.
handle_okbutton_click
(
i
)
)
)
button_widget
.
pressed
.
connect
(
self
.
clinical_handler
.
commandSent
)
elif
isinstance
(
button_widget
,
CancelButtonWidget
):
elif
isinstance
(
button_widget
,
CancelButtonWidget
):
mode
=
self
.
mode_handler
.
get_mode
(
key
)
buttonMode
=
self
.
mode_handler
.
get_mode
(
key
)
button_widget
.
pressed
.
connect
(
self
.
mode_handler
.
commandSent
)
button_widget
.
pressed
.
connect
(
lambda
i
=
buttonMode
:
self
.
mode_handler
.
handle_cancel_pressed
(
i
)
)
button_widget
.
pressed
.
connect
(
lambda
i
=
buttonMode
:
self
.
clinical_handler
.
handle_cancel_pressed
(
i
)
)
for
key
,
button_widget
in
self
.
mode_handler
.
mainButtonDict
.
items
():
for
key
,
button_widget
in
self
.
mode_handler
.
mainButtonDict
.
items
():
if
isinstance
(
button_widget
,
(
OkButtonWidget
)):
if
isinstance
(
button_widget
,
(
OkButtonWidget
)):
button_widget
.
clicked
.
connect
(
button_widget
.
clicked
.
connect
(
self
.
mode_handler
.
handle_mainokbutton_click
self
.
mode_handler
.
handle_mainokbutton_click
)
)
button_widget
.
pressed
.
connect
(
self
.
clinical_handler
.
commandSent
)
elif
isinstance
(
button_widget
,
CancelButtonWidget
):
elif
isinstance
(
button_widget
,
CancelButtonWidget
):
# mode = self.mode_handler.get_mode(key)
# mode = self.mode_handler.get_mode(key)
button_widget
.
clicked
.
connect
(
self
.
mode_handler
.
commandSent
)
button_widget
.
clicked
.
connect
(
self
.
mode_handler
.
commandSent
)
button_widget
.
pressed
.
connect
(
self
.
clinical_handler
.
commandSent
)
for
key
,
spin_widget
in
self
.
clinical_handler
.
limSpinDict
.
items
():
for
key
,
spin_widget
in
self
.
clinical_handler
.
limSpinDict
.
items
():
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
...
@@ -472,8 +506,8 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -472,8 +506,8 @@ class NativeUI(HEVClient, QMainWindow):
self
.
clinical_handler
.
handle_cancelbutton_click
self
.
clinical_handler
.
handle_cancelbutton_click
)
)
# for widget in (self.clinical_handler.setSpinDict.values()
):
for
widget
in
self
.
clinical_handler
.
setSpinDict
.
values
(
):
#
self.clinical_handler.UpdateClinical.connect(widget.update_value)
self
.
clinical_handler
.
UpdateClinical
.
connect
(
widget
.
update_value
)
self
.
mode_handler
.
OpenPopup
.
connect
(
self
.
messageCommandPopup
.
populatePopup
)
self
.
mode_handler
.
OpenPopup
.
connect
(
self
.
messageCommandPopup
.
populatePopup
)
self
.
mode_handler
.
OpenPopup
.
connect
(
self
.
mode_handler
.
OpenPopup
.
connect
(
...
@@ -500,6 +534,13 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -500,6 +534,13 @@ class NativeUI(HEVClient, QMainWindow):
)
)
##### Expert Settings:
##### Expert Settings:
self
.
widgets
.
expert_password_widget
.
okButton
.
pressed
.
connect
(
self
.
widgets
.
expert_password_widget
.
submit_password
)
self
.
widgets
.
expert_password_widget
.
correctPassword
.
connect
(
lambda
:
self
.
widgets
.
expert_passlock_stack
.
setCurrentIndex
(
1
)
)
# Expert handler should respond to manual value changes
# Expert handler should respond to manual value changes
for
key
,
spin_widget
in
self
.
expert_handler
.
spinDict
.
items
():
for
key
,
spin_widget
in
self
.
expert_handler
.
spinDict
.
items
():
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
...
@@ -640,12 +681,30 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -640,12 +681,30 @@ class NativeUI(HEVClient, QMainWindow):
return
0
return
0
def
toggle_editability
(
self
):
"""Set all widgets disabled to lock screen"""
self
.
enableState
=
not
self
.
enableState
if
self
.
enableState
:
self
.
alt_palette
.
setColor
(
QPalette
.
Window
,
self
.
colors
[
"page_background"
])
else
:
self
.
alt_palette
.
setColor
(
QPalette
.
Window
,
self
.
colors
[
"page_foreground"
])
self
.
setPalette
(
self
.
alt_palette
)
for
attribute
in
dir
(
self
.
widgets
):
widg
=
self
.
widgets
.
get_widget
(
attribute
)
if
isinstance
(
widg
,
QWidget
):
widg
.
setEnabled
(
self
.
enableState
)
self
.
widgets
.
lock_button
.
setEnabled
(
True
)
@
Slot
(
str
)
@
Slot
(
str
)
def
change_page
(
self
,
page_to_show
:
str
)
->
int
:
def
change_page
(
self
,
page_to_show
:
str
)
->
int
:
"""
"""
Change the page shown in page_stack.
Change the page shown in page_stack.
"""
"""
self
.
widgets
.
page_stack
.
setCurrentWidget
(
getattr
(
self
.
widgets
,
page_to_show
))
self
.
widgets
.
page_stack
.
setCurrentWidget
(
getattr
(
self
.
widgets
,
page_to_show
))
self
.
widgets
.
expert_passlock_stack
.
setCurrentIndex
(
0
)
# reset password lock on expert settings
return
0
return
0
@
Slot
(
str
,
str
,
float
)
@
Slot
(
str
,
str
,
float
)
...
@@ -656,12 +715,9 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -656,12 +715,9 @@ class NativeUI(HEVClient, QMainWindow):
logging
.
debug
(
"to MCU: cmd:
%
s"
,
cmd
)
logging
.
debug
(
"to MCU: cmd:
%
s"
,
cmd
)
check
=
self
.
send_cmd
(
cmdtype
=
cmdtype
,
cmd
=
cmd
,
param
=
param
)
check
=
self
.
send_cmd
(
cmdtype
=
cmdtype
,
cmd
=
cmd
,
param
=
param
)
if
check
:
if
check
:
print
(
"confirmed this command "
+
cmdtype
+
" "
+
cmd
)
self
.
confirmPopup
.
addConfirmation
(
cmdtype
+
" "
+
cmd
)
self
.
confirmPopup
.
addConfirmation
(
cmdtype
+
" "
+
cmd
)
print
(
"added popup"
)
return
0
return
0
else
:
else
:
print
(
"failed this command "
+
cmdtype
+
" "
+
cmd
)
return
1
return
1
@
Slot
(
str
)
@
Slot
(
str
)
...
...
NativeUI/alarm_widgets/alarm_popup.py
View file @
05db8768
...
@@ -24,6 +24,7 @@ class AlarmWidget(QtWidgets.QWidget):
...
@@ -24,6 +24,7 @@ class AlarmWidget(QtWidgets.QWidget):
def
__init__
(
self
,
NativeUI
,
abstractAlarm
,
alarmCarrier
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
abstractAlarm
,
alarmCarrier
,
*
args
,
**
kwargs
):
super
(
AlarmWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
AlarmWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
popup_height
=
int
(
NativeUI
.
alarm_popup_width
/
10.0
)
self
.
NativeUI
=
NativeUI
self
.
NativeUI
=
NativeUI
self
.
alarmCarrier
=
alarmCarrier
# Needs to refer to its containing object
self
.
alarmCarrier
=
alarmCarrier
# Needs to refer to its containing object
...
@@ -37,27 +38,28 @@ class AlarmWidget(QtWidgets.QWidget):
...
@@ -37,27 +38,28 @@ class AlarmWidget(QtWidgets.QWidget):
iconpath_check
=
os
.
path
.
join
(
iconpath_check
=
os
.
path
.
join
(
self
.
NativeUI
.
iconpath
,
"exclamation-triangle-solid.png"
self
.
NativeUI
.
iconpath
,
"exclamation-triangle-solid.png"
)
)
pixmap
=
QtGui
.
QPixmap
(
iconpath_check
)
.
scaledToHeight
(
40
)
pixmap
=
QtGui
.
QPixmap
(
iconpath_check
)
.
scaledToHeight
(
popup_height
)
iconLabel
.
setPixmap
(
pixmap
)
iconLabel
.
setPixmap
(
pixmap
)
self
.
layout
.
addWidget
(
iconLabel
)
self
.
layout
.
addWidget
(
iconLabel
)
self
.
textLabel
=
QtWidgets
.
QLabel
()
self
.
textLabel
=
QtWidgets
.
QLabel
()
alarmLevel
=
self
.
alarmPayload
[
"alarm_type"
]
.
replace
(
'PRIORITY_'
,
''
)
alarmLevel
=
self
.
alarmPayload
[
"alarm_type"
]
#
.replace('PRIORITY_', '')
self
.
textLabel
.
setText
(
self
.
textLabel
.
setText
(
alarmLevel
+
" - "
+
self
.
alarmPayload
[
"alarm_code"
]
self
.
alarmPayload
[
"alarm_code"
]
+
" - ("
+
alarmLevel
+
")"
)
)
self
.
textLabel
.
setFixedWidth
(
400
)
self
.
textLabel
.
setFixedWidth
(
NativeUI
.
alarm_popup_width
)
self
.
textLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
textLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
textLabel
.
setFont
(
NativeUI
.
text_font
)
self
.
textLabel
.
setFont
(
NativeUI
.
text_font
)
#self.textLabel.setStyleSheet("font-size: " + NativeUI.text_size + ";")
#
self.textLabel.setStyleSheet("font-size: " + NativeUI.text_size + ";")
self
.
layout
.
addWidget
(
self
.
textLabel
)
self
.
layout
.
addWidget
(
self
.
textLabel
)
self
.
setFixedHeight
(
40
)
self
.
setFixedHeight
(
popup_height
)
self
.
setLayout
(
self
.
layout
)
self
.
setLayout
(
self
.
layout
)
if
self
.
alarmPayload
[
"alarm_type"
]
==
"PRIORITY_HIGH"
:
if
self
.
alarmPayload
[
"alarm_type"
]
==
"PRIORITY_HIGH"
:
self
.
setStyleSheet
(
"background-color:red;"
)
self
.
setStyleSheet
(
"background-color:red;"
)
elif
self
.
alarmPayload
[
"alarm_type"
]
==
"PRIORITY_MEDIUM"
:
elif
self
.
alarmPayload
[
"alarm_type"
]
==
"PRIORITY_MEDIUM"
:
self
.
setStyleSheet
(
"background-color:orange;"
)
self
.
setStyleSheet
(
"background-color:orange;"
)
self
.
setFixedSize
(
NativeUI
.
alarm_popup_width
+
popup_height
,
popup_height
)
# self.timer = QtCore.QTimer()
# self.timer = QtCore.QTimer()
# self.timer.setInterval(500) # just faster than 60Hz
# self.timer.setInterval(500) # just faster than 60Hz
...
@@ -66,14 +68,13 @@ class AlarmWidget(QtWidgets.QWidget):
...
@@ -66,14 +68,13 @@ class AlarmWidget(QtWidgets.QWidget):
self
.
installEventFilter
(
self
)
self
.
installEventFilter
(
self
)
def
eventFilter
(
self
,
source
,
event
):
def
eventFilter
(
self
,
source
,
event
):
if
(
event
.
type
()
==
QtCore
.
QEvent
.
MouseButtonPress
)
:
if
event
.
type
()
==
QtCore
.
QEvent
.
MouseButtonPress
:
self
.
NativeUI
.
widgets
.
page_buttons
.
alarms_button
.
click
()
self
.
NativeUI
.
widgets
.
page_buttons
.
alarms_button
.
click
()
return
False
return
False
def
get_priority
(
self
):
def
get_priority
(
self
):
return
self
.
alarmPayload
[
"alarm_type"
]
return
self
.
alarmPayload
[
"alarm_type"
]
def
setFont
(
self
,
font
)
->
int
:
def
setFont
(
self
,
font
)
->
int
:
"""
"""
Set the font for textLabel.
Set the font for textLabel.
...
@@ -95,12 +96,13 @@ class AlarmWidget(QtWidgets.QWidget):
...
@@ -95,12 +96,13 @@ class AlarmWidget(QtWidgets.QWidget):
class
AlarmPopup
(
QtWidgets
.
QDialog
):
class
AlarmPopup
(
QtWidgets
.
QDialog
):
"""Container class for alarm widgets. Handles ordering and positioning of alarms.
"""Container class for alarm widgets. Handles ordering and positioning of alarms.
Needs to adjust its size whenever a widget is deleted"""
Needs to adjust its size whenever a widget is deleted"""
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
AlarmPopup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
AlarmPopup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
setParent
(
NativeUI
)
# ensures popup closes when main UI does
self
.
setParent
(
NativeUI
)
# ensures popup closes when main UI does
self
.
alarmDict
=
{}
self
.
alarmDict
=
{}
self
.
NativeUI
=
NativeUI
self
.
NativeUI
=
NativeUI
self
.
extraAlarms
=
AlarmExtrasWidget
(
NativeUI
,
self
)
self
.
extraAlarms
=
AlarmExtrasWidget
(
NativeUI
,
self
)
self
.
layout
=
QtWidgets
.
QVBoxLayout
()
self
.
layout
=
QtWidgets
.
QVBoxLayout
()
self
.
layout
.
setSpacing
(
0
)
self
.
layout
.
setSpacing
(
0
)
...
@@ -141,7 +143,7 @@ class AlarmPopup(QtWidgets.QDialog):
...
@@ -141,7 +143,7 @@ class AlarmPopup(QtWidgets.QDialog):
self
.
NativeUI
,
abstractAlarm
,
self
self
.
NativeUI
,
abstractAlarm
,
self
)
)
self
.
refresh_alarm_ordering
()
self
.
refresh_alarm_ordering
()
#self.layout.addWidget(self.alarmDict[abstractAlarm.alarmPayload["alarm_code"]])
#
self.layout.addWidget(self.alarmDict[abstractAlarm.alarmPayload["alarm_code"]])
return
0
return
0
def
removeAlarm
(
self
,
abstractAlarm
):
def
removeAlarm
(
self
,
abstractAlarm
):
...
@@ -157,25 +159,26 @@ class AlarmPopup(QtWidgets.QDialog):
...
@@ -157,25 +159,26 @@ class AlarmPopup(QtWidgets.QDialog):
self
.
layout
.
removeWidget
(
self
.
alarmDict
[
key
])
self
.
layout
.
removeWidget
(
self
.
alarmDict
[
key
])
for
key
in
self
.
alarmDict
:
for
key
in
self
.
alarmDict
:
if
self
.
alarmDict
[
key
]
.
get_priority
()
==
'PRIORITY_HIGH'
:
if
self
.
alarmDict
[
key
]
.
get_priority
()
==
"PRIORITY_HIGH"
:
if
self
.
layout
.
count
()
==
4
:
if
self
.
layout
.
count
()
==
4
:
self
.
extraAlarms
.
update_text
(
1
+
len
(
self
.
alarmDict
)
-
self
.
layout
.
count
())
self
.
extraAlarms
.
update_text
(
1
+
len
(
self
.
alarmDict
)
-
self
.
layout
.
count
()
)
self
.
layout
.
addWidget
(
self
.
extraAlarms
)
self
.
layout
.
addWidget
(
self
.
extraAlarms
)
break
break
self
.
layout
.
addWidget
(
self
.
alarmDict
[
key
])
self
.
layout
.
addWidget
(
self
.
alarmDict
[
key
])
if
self
.
layout
.
count
()
<
5
:
if
self
.
layout
.
count
()
<
5
:
for
key
in
self
.
alarmDict
:
for
key
in
self
.
alarmDict
:
if
self
.
layout
.
count
()
==
3
:
if
self
.
layout
.
count
()
==
3
:
self
.
extraAlarms
.
update_text
(
len
(
self
.
alarmDict
)
-
self
.
layout
.
count
())
self
.
extraAlarms
.
update_text
(
len
(
self
.
alarmDict
)
-
self
.
layout
.
count
()
)
self
.
layout
.
addWidget
(
self
.
extraAlarms
)
self
.
layout
.
addWidget
(
self
.
extraAlarms
)
break
break
if
self
.
alarmDict
[
key
]
.
get_priority
()
==
'PRIORITY_LOW'
:
if
self
.
alarmDict
[
key
]
.
get_priority
()
==
"PRIORITY_LOW"
:
self
.
layout
.
addWidget
(
self
.
alarmDict
[
key
])
self
.
layout
.
addWidget
(
self
.
alarmDict
[
key
])
# def resetTimer(self, alarmPayload):
# def resetTimer(self, alarmPayload):
# self.alarmDict[alarmPayload["alarm_code"]].timer.start()
# self.alarmDict[alarmPayload["alarm_code"]].timer.start()
...
@@ -188,49 +191,52 @@ class AlarmPopup(QtWidgets.QDialog):
...
@@ -188,49 +191,52 @@ class AlarmPopup(QtWidgets.QDialog):
return
0
return
0
class
AlarmExtrasWidget
(
QtWidgets
.
QWidget
):
class
AlarmExtrasWidget
(
QtWidgets
.
QWidget
):
"""Object containing information particular to one alarm.
"""Object containing information particular to one alarm.
Created when alarm received from microcontroller, timeout after alarm signal stops.
Created when alarm received from microcontroller, timeout after alarm signal stops.
Is contained within alarmPopup"""
Is contained within alarmPopup"""
def
__init__
(
self
,
NativeUI
,
alarmCarrier
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
alarmCarrier
,
*
args
,
**
kwargs
):
super
(
AlarmExtrasWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
AlarmExtrasWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
popup_height
=
int
(
NativeUI
.
alarm_popup_width
/
10.0
)
self
.
NativeUI
=
NativeUI
self
.
NativeUI
=
NativeUI
self
.
alarmCarrier
=
alarmCarrier
# Needs to refer to its containing object
self
.
alarmCarrier
=
alarmCarrier
# Needs to refer to its containing object
self
.
layout
=
QtWidgets
.
QHBoxLayout
()
self
.
layout
=
QtWidgets
.
QHBoxLayout
()
self
.
layout
.
setSpacing
(
0
)
self
.
layout
.
setSpacing
(
0
)
self
.
layout
.
setMargin
(
0
)
self
.
layout
.
setMargin
(
0
)
#self.alarmPayload = abstractAlarm.alarmPayload
#
self.alarmPayload = abstractAlarm.alarmPayload
iconLabel
=
QtWidgets
.
QLabel
()
iconLabel
=
QtWidgets
.
QLabel
()
iconpath_check
=
os
.
path
.
join
(
iconpath_check
=
os
.
path
.
join
(
self
.
NativeUI
.
iconpath
,
"exclamation-triangle-solid.png"
self
.
NativeUI
.
iconpath
,
"exclamation-triangle-solid.png"
)
)
pixmap
=
QtGui
.
QPixmap
(
iconpath_check
)
.
scaledToHeight
(
40
)
pixmap
=
QtGui
.
QPixmap
(
iconpath_check
)
.
scaledToHeight
(
popup_height
)
iconLabel
.
setPixmap
(
pixmap
)
iconLabel
.
setPixmap
(
pixmap
)
self
.
layout
.
addWidget
(
iconLabel
)
self
.
layout
.
addWidget
(
iconLabel
)
self
.
textLabel
=
QtWidgets
.
QLabel
()
self
.
textLabel
=
QtWidgets
.
QLabel
()
self
.
textLabel
.
setText
(
'1 More Alarms'
)
self
.
textLabel
.
setText
(
"1 More Alarms"
)
self
.
textLabel
.
setFixedWidth
(
400
)
self
.
textLabel
.
setFixedWidth
(
NativeUI
.
alarm_popup_width
)
self
.
textLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
textLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
textLabel
.
setFont
(
NativeUI
.
text_font
)
self
.
textLabel
.
setFont
(
NativeUI
.
text_font
)
#self.textLabel.setStyleSheet("font-size: " + NativeUI.text_size + ";")
#
self.textLabel.setStyleSheet("font-size: " + NativeUI.text_size + ";")
self
.
layout
.
addWidget
(
self
.
textLabel
)
self
.
layout
.
addWidget
(
self
.
textLabel
)
self
.
setFixedHeight
(
40
)
self
.
setFixedHeight
(
popup_height
)
self
.
setLayout
(
self
.
layout
)
self
.
setLayout
(
self
.
layout
)
self
.
setStyleSheet
(
"background-color:red;"
)
self
.
setStyleSheet
(
"background-color:red;"
)
#
self.priority = "PRIORITY_LOW"
#
self.priority = "PRIORITY_LOW"
self
.
installEventFilter
(
self
)
self
.
installEventFilter
(
self
)
self
.
setFixedSize
(
NativeUI
.
alarm_popup_width
+
popup_height
,
popup_height
)
def
update_text
(
self
,
num
):
def
update_text
(
self
,
num
):
self
.
textLabel
.
setText
(
str
(
num
)
+
' More Alarms'
)
self
.
textLabel
.
setText
(
str
(
num
)
+
" More Alarms"
)
def
eventFilter
(
self
,
source
,
event
):
def
eventFilter
(
self
,
source
,
event
):
if
(
event
.
type
()
==
QtCore
.
QEvent
.
MouseButtonPress
)
:
if
event
.
type
()
==
QtCore
.
QEvent
.
MouseButtonPress
:
self
.
NativeUI
.
widgets
.
page_buttons
.
alarms_button
.
click
()
self
.
NativeUI
.
widgets
.
page_buttons
.
alarms_button
.
click
()
return
False
return
False
...
...
NativeUI/alarm_widgets/alarm_table.py
View file @
05db8768
...
@@ -19,10 +19,10 @@ from datetime import datetime
...
@@ -19,10 +19,10 @@ from datetime import datetime
class
AlarmTable
(
QtWidgets
.
QTableWidget
):
class
AlarmTable
(
QtWidgets
.
QTableWidget
):
"""Table containing all of the alarms since power up are contained. Easily sorted"""
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
AlarmTable
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
AlarmTable
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
alarmDict
=
{}
self
.
setSizePolicy
(
self
.
setSizePolicy
(
QtWidgets
.
QSizePolicy
.
Expanding
,
QtWidgets
.
QSizePolicy
.
Expanding
QtWidgets
.
QSizePolicy
.
Expanding
,
QtWidgets
.
QSizePolicy
.
Expanding
)
)
...
@@ -40,40 +40,33 @@ class AlarmTable(QtWidgets.QTableWidget):
...
@@ -40,40 +40,33 @@ class AlarmTable(QtWidgets.QTableWidget):
self
.
payloadKeys
=
[
"alarm_type"
,
"alarm_code"
]
self
.
payloadKeys
=
[
"alarm_type"
,
"alarm_code"
]
self
.
resizeColumnsToContents
()
self
.
resizeColumnsToContents
()
self
.
alarmDict
=
{}
self
.
alarm
Cell
Dict
=
{}
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
100
)
self
.
timer
.
setInterval
(
100
)
# self.timer.timeout.connect(self.updateDuration)
# self.timer.timeout.connect(self.updateDuration)
self
.
timer
.
start
()
self
.
timer
.
start
()
def
addAlarm
(
self
,
abstractAlarm
):
# def addAlarm(self, abstractAlarm):
timestamp
=
str
(
datetime
.
now
())[:
-
3
]
# timestamp = str(datetime.now())[:-3]
newItem
=
QtWidgets
.
QListWidgetItem
(
# newItem = QtWidgets.QListWidgetItem(
self
.
solidBell
,
# self.solidBell,
timestamp
# timestamp
+
": "
# + ": "
+
abstractAlarm
.
alarmPayload
[
"alarm_type"
]
# + abstractAlarm.alarmPayload["alarm_type"]
+
" - "
# + " - "
+
abstractAlarm
.
alarmPayload
[
"alarm_code"
],
# + abstractAlarm.alarmPayload["alarm_code"],
)
# )
self
.
insertItem
(
0
,
newItem
)
# add to the top
# self.insertItem(0, newItem) # add to the top
# self.labelList
# def removeAlarm(self, abstractAlarm):
# widg = self.cellWidget(rowNumber, 4)
# for x in range(self.count() - 1):
# cellItem.setText(str(abstractAlarm.duration))
# if abstractAlarm.alarmPayload["alarm_code"] in self.item(x).text():
# abstractAlarm.alarmExpired.connect(lambda i =newItem, j = abstractAlarm: self.update_duration(i,j))
# self.takeItem(x)
# self.setItem(self.nrows, colnum, newItem)
# tableItem.setText(str(abstractAlarm.duration))
def
removeAlarm
(
self
,
abstractAlarm
):
for
x
in
range
(
self
.
count
()
-
1
):
if
abstractAlarm
.
alarmPayload
[
"alarm_code"
]
in
self
.
item
(
x
)
.
text
():
self
.
takeItem
(
x
)
def
addAlarmRow
(
self
,
abstractAlarm
):
def
addAlarmRow
(
self
,
abstractAlarm
):
"""Add a new row 1 cell at a time. Goes through alarm payload to fill information"""
self
.
setSortingEnabled
(
False
)
self
.
setSortingEnabled
(
False
)
self
.
setRowCount
(
self
.
nrows
+
1
)
self
.
setRowCount
(
self
.
nrows
+
1
)
colnum
=
0
newItem
=
QtWidgets
.
QTableWidgetItem
(
str
(
abstractAlarm
.
startTime
)[:
-
3
])
newItem
=
QtWidgets
.
QTableWidgetItem
(
str
(
abstractAlarm
.
startTime
)[:
-
3
])
self
.
setItem
(
self
.
nrows
,
0
,
newItem
)
self
.
setItem
(
self
.
nrows
,
0
,
newItem
)
...
@@ -85,26 +78,20 @@ class AlarmTable(QtWidgets.QTableWidget):
...
@@ -85,26 +78,20 @@ class AlarmTable(QtWidgets.QTableWidget):
self
.
setItem
(
self
.
nrows
,
2
,
newItem
)
self
.
setItem
(
self
.
nrows
,
2
,
newItem
)
newItem
=
QtWidgets
.
QTableWidgetItem
(
" "
)
newItem
=
QtWidgets
.
QTableWidgetItem
(
" "
)
self
.
alarmDict
[
self
.
nrows
]
=
newItem
self
.
alarm
Cell
Dict
[
self
.
nrows
]
=
newItem
self
.
setItem
(
self
.
nrows
,
3
,
self
.
alarmDict
[
self
.
nrows
])
self
.
setItem
(
self
.
nrows
,
3
,
self
.
alarm
Cell
Dict
[
self
.
nrows
])
# abstractAlarm.alarmExpired.connect(lambda i = self.alarmDict[self.nrows], j = abstractAlarm: self.update_duration(i,j))
# abstractAlarm.alarmExpired.connect(lambda i = self.alarm
Cell
Dict[self.nrows], j = abstractAlarm: self.update_duration(i,j))
self
.
timer
.
timeout
.
connect
(
self
.
timer
.
timeout
.
connect
(
lambda
i
=
self
.
alarmDict
[
self
.
nrows
],
j
=
abstractAlarm
:
self
.
update_duration
(
lambda
i
=
self
.
alarm
Cell
Dict
[
self
.
nrows
],
j
=
abstractAlarm
:
self
.
update_duration
(
i
,
j
i
,
j
)
)
)
)
if
self
.
nrows
==
1
:
#
if self.nrows == 1:
self
.
resizeColumnsToContents
()
self
.
resizeColumnsToContents
()
self
.
nrows
=
self
.
nrows
+
1
self
.
nrows
=
self
.
nrows
+
1
self
.
setSortingEnabled
(
True
)
self
.
setSortingEnabled
(
True
)
def
update_duration
(
self
,
cellItem
,
abstractAlarm
):
def
update_duration
(
self
,
cellItem
,
abstractAlarm
):
cellItem
.
setText
(
str
(
abstractAlarm
.
duration
))
cellItem
.
setText
(
str
(
abstractAlarm
.
duration
))
if
__name__
==
"__main__"
:
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
widg
=
alarmList
()
widg
.
show
()
sys
.
exit
(
app
.
exec_
())
NativeUI/configs/clinical_config.json
View file @
05db8768
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
"settings"
:[
"settings"
:[
[[
"APNEA"
,
"ms"
,
"APNEA"
,
"SET_THRESHOLD_MIN"
,
"APNEA"
,
5
,
20
,
10
,
1
,
0
]],
[[
"APNEA"
,
"ms"
,
"APNEA"
,
"SET_THRESHOLD_MIN"
,
"APNEA"
,
5
,
20
,
10
,
1
,
0
]],
[[
"Check Pressure Patient"
,
"ms"
,
"CHECK_P_PATIENT"
,
"SET_THRESHOLD_MIN"
,
"CHECK_P_PATIENT"
],[
"Check Pressure Patient"
,
"ms"
,
"CHECK_P_PATIENT"
,
"SET_THRESHOLD_MAX"
,
"CHECK_P_PATIENT"
]],
[[
"Check Pressure Patient"
,
"ms"
,
"CHECK_P_PATIENT"
,
"SET_THRESHOLD_MIN"
,
"CHECK_P_PATIENT"
],[
"Check Pressure Patient"
,
"ms"
,
"CHECK_P_PATIENT"
,
"SET_THRESHOLD_MAX"
,
"CHECK_P_PATIENT"
]],
[[
"FIO2"
,
"%"
,
"HIGH_FIO2"
,
"SET_THRESHOLD_MIN"
,
"HIGH_FIO2"
,
-10
,
0
,
-5
,
0.1
,
1
],[
"Percentage O2"
,
""
,
"fiO2_percent"
,
"SET_TARGET_CURRENT"
,
"FIO2_PERCENT"
,
20
,
100
,
21
,
1
,
0
],[
"FIO2"
,
"%"
,
"HIGH_FIO2"
,
"SET_THRESHOLD_MAX"
,
"HIGH_FIO2"
,
0
,
10
,
5
,
0.1
,
1
]],
[[
"FIO2"
,
"%"
,
"HIGH_FIO2"
,
"SET_THRESHOLD_MIN"
,
"HIGH_FIO2"
,
-10
,
0
,
-5
,
1
,
0
],[
"Percentage O2"
,
""
,
"fiO2_percent"
,
"SET_TARGET_CURRENT"
,
"FIO2_PERCENT"
,
0
,
100
,
51
,
1
,
0
],[
"FIO2"
,
"%"
,
"HIGH_FIO2"
,
"SET_THRESHOLD_MAX"
,
"HIGH_FIO2"
,
0
,
10
,
5
,
1
,
0
]],
[[
"Pressure"
,
" "
,
"HIGH_PRESSURE"
,
"SET_THRESHOLD_MIN"
,
"HIGH_PRESSURE"
],[
"Inhale Pressure"
,
""
,
"inspiratory_pressure"
,
"SET_TARGET_CURRENT"
,
"INSPIRATORY_PRESSURE"
,
10
,
50
,
17
,
1
,
0
],[
"Pressure"
,
" "
,
"HIGH_PRESSURE"
,
"SET_THRESHOLD_MAX"
,
"HIGH_PRESSURE"
],[
"Pressure"
,
" "
,
"HIGH_PRESSURE"
,
"SET_THRESHOLD_MAX"
,
"HIGH_PRESSURE"
]],
[[
"Pressure"
,
" "
,
"HIGH_PRESSURE"
,
"SET_THRESHOLD_MIN"
,
"HIGH_PRESSURE"
],[
"Inhale Pressure"
,
""
,
"inspiratory_pressure"
,
"SET_TARGET_CURRENT"
,
"INSPIRATORY_PRESSURE"
,
10
,
50
,
17
,
1
,
0
],[
"Pressure"
,
" "
,
"HIGH_PRESSURE"
,
"SET_THRESHOLD_MAX"
,
"HIGH_PRESSURE"
],[
"Pressure"
,
" "
,
"HIGH_PRESSURE"
,
"SET_THRESHOLD_MAX"
,
"HIGH_PRESSURE"
]],
[[
"Respiratory Rate"
,
" "
,
"HIGH_RR"
,
"SET_THRESHOLD_MIN"
,
"HIGH_RR"
,
-10
,
0
,
-5
,
0.1
,
1
],[
"Respiratory Rate"
,
"/min"
,
"respiratory_rate"
,
"SET_TARGET_CURRENT"
,
"RESPIRATORY_RATE"
,
10
,
20
,
15
,
0.1
,
1
],[
"Respiratory Rate"
,
" "
,
"HIGH_RR"
,
"SET_THRESHOLD_MAX"
,
"HIGH_RR"
,
0
,
10
,
5
,
0.1
,
1
]],
[[
"Respiratory Rate"
,
" "
,
"HIGH_RR"
,
"SET_THRESHOLD_MIN"
,
"HIGH_RR"
,
-10
,
0
,
-5
,
0.1
,
1
],[
"Respiratory Rate"
,
"/min"
,
"respiratory_rate"
,
"SET_TARGET_CURRENT"
,
"RESPIRATORY_RATE"
,
10
,
20
,
15
,
0.1
,
1
],[
"Respiratory Rate"
,
" "
,
"HIGH_RR"
,
"SET_THRESHOLD_MAX"
,
"HIGH_RR"
,
0
,
10
,
5
,
0.1
,
1
]],
[[
"VTE"
,
" "
,
"HIGH_VTE"
,
"SET_THRESHOLD_MIN"
,
"HIGH_VTE"
,
-10
,
0
,
-5
,
1
,
0
],[
"Inhale Volume"
,
""
,
"volume"
,
"SET_TARGET_CURRENT"
,
"VOLUME"
,
200
,
800
,
400
,
20
,
0
],[
"VTE"
,
" "
,
"HIGH_VTE"
,
"SET_THRESHOLD_MAX"
,
"HIGH_VTE"
,
0
,
10
,
5
,
1
,
0
]],
[[
"VTE"
,
" "
,
"HIGH_VTE"
,
"SET_THRESHOLD_MIN"
,
"HIGH_VTE"
,
-10
,
0
,
-5
,
1
,
0
],[
"Inhale Volume"
,
""
,
"volume"
,
"SET_TARGET_CURRENT"
,
"VOLUME"
,
200
,
800
,
400
,
20
,
0
],[
"VTE"
,
" "
,
"HIGH_VTE"
,
"SET_THRESHOLD_MAX"
,
"HIGH_VTE"
,
0
,
10
,
5
,
1
,
0
]],
...
...
NativeUI/configs/colors.json
View file @
05db8768
...
@@ -5,22 +5,22 @@
...
@@ -5,22 +5,22 @@
"button_background_disabled"
:[
100
,
100
,
100
],
"button_background_disabled"
:[
100
,
100
,
100
],
"button_foreground_enabled"
:[
200
,
200
,
200
],
"button_foreground_enabled"
:[
200
,
200
,
200
],
"button_foreground_disabled"
:[
30
,
30
,
30
],
"button_foreground_disabled"
:[
30
,
30
,
30
],
"button_background_highlight"
:[
30
,
93
,
248
],
"button_foreground_highlight"
:[
200
,
200
,
200
],
"label_background"
:[
0
,
0
,
0
],
"label_background"
:[
0
,
0
,
0
],
"label_foreground"
:[
200
,
200
,
200
],
"label_foreground"
:[
200
,
200
,
200
],
"display_background"
:[
200
,
200
,
200
],
"display_background"
:[
200
,
200
,
200
],
"display_foreground"
:[
0
,
0
,
0
],
"display_foreground"
:[
0
,
0
,
0
],
"display_foreground_changed"
:[
0
,
200
,
0
],
"display_foreground_changed"
:[
0
,
200
,
0
],
"display_foreground_red"
:[
200
,
0
,
0
],
"display_foreground_red"
:[
200
,
0
,
0
],
"plot_pressure"
:[
0
,
114
,
178
],
"plot_volume"
:[
0
,
158
,
115
],
"plot_flow"
:[
240
,
228
,
66
],
"plot_pressure_flow"
:[
230
,
159
,
0
],
"plot_flow_volume"
:[
204
,
121
,
167
],
"plot_volume_pressure"
:[
86
,
180
,
233
],
"highligh"
:[
30
,
93
,
248
],
"baby_blue"
:[
144
,
231
,
211
],
"baby_blue"
:[
144
,
231
,
211
],
"red"
:[
200
,
0
,
0
],
"red"
:[
200
,
0
,
0
],
"green"
:[
0
,
200
,
0
],
"green"
:[
0
,
200
,
0
]
"pressure_plot"
:[
0
,
114
,
178
],
"volume_plot"
:[
0
,
158
,
115
],
"flow_plot"
:[
240
,
228
,
66
],
"pressure_flow_plot"
:[
230
,
159
,
0
],
"flow_volume_plot"
:[
204
,
121
,
167
],
"volume_pressure_plot"
:[
86
,
180
,
233
],
"red"
:[
255
,
0
,
0
],
"green"
:[
0
,
255
,
0
],
"baby-blue"
:[
0
,
0
,
200
]
}
}
NativeUI/configs/mode_config.json
View file @
05db8768
...
@@ -7,8 +7,8 @@
...
@@ -7,8 +7,8 @@
[
"Exhale Trigger Sensitivity"
,
""
,
"exhale_trigger_threshold"
,
"SET_TARGET_"
,
"EXHALE_TRIGGER_THRESHOLD"
,
0
,
50
,
25
,
0.2
,
1
],
[
"Exhale Trigger Sensitivity"
,
""
,
"exhale_trigger_threshold"
,
"SET_TARGET_"
,
"EXHALE_TRIGGER_THRESHOLD"
,
0
,
50
,
25
,
0.2
,
1
],
[
"Inhale Pressure"
,
""
,
"inspiratory_pressure"
,
"SET_TARGET_"
,
"INSPIRATORY_PRESSURE"
,
10
,
50
,
17
,
1
,
0
],
[
"Inhale Pressure"
,
""
,
"inspiratory_pressure"
,
"SET_TARGET_"
,
"INSPIRATORY_PRESSURE"
,
10
,
50
,
17
,
1
,
0
],
[
"Inhale Volume"
,
""
,
"volume"
,
"SET_TARGET_"
,
"VOLUME"
,
200
,
800
,
400
,
20
,
0
],
[
"Inhale Volume"
,
""
,
"volume"
,
"SET_TARGET_"
,
"VOLUME"
,
200
,
800
,
400
,
20
,
0
],
[
"Percentage O2"
,
""
,
"fiO2_percent"
,
"SET_TARGET_"
,
"FIO2_PERCENT"
,
20
,
100
,
21
,
1
,
0
]],
[
"Percentage O2"
,
""
,
"fiO2_percent"
,
"SET_TARGET_"
,
"FIO2_PERCENT"
,
20
,
100
,
51
,
0.1
,
1
]],
"radioSettings"
:
[
"Inhale Time"
,
"IE Ratio"
],
"radioSettings"
:
[
"Inhale Time"
,
"IE Ratio"
],
"enableDict"
:{
"PC/AC"
:[
1
,
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
],
"PC/AC-PRVC"
:[
1
,
1
,
1
,
0
,
1
,
0
,
1
,
1
,
1
],
"PC-PSV"
:[
1
,
1
,
1
,
0
,
1
,
0
,
1
,
0
,
1
],
"CPAP"
:[
1
,
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
]},
"enableDict"
:{
"PC/AC"
:[
1
,
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
],
"PC/AC-PRVC"
:[
1
,
1
,
1
,
0
,
1
,
0
,
1
,
1
,
1
],
"PC-PSV"
:[
1
,
1
,
1
,
0
,
1
,
0
,
1
,
0
,
1
],
"CPAP"
:[
1
,
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
]},
"mainPageSettings"
:
[
"Inhale Pressure"
,
"Respiratory Rate"
,
"Inhale Time"
,
"IE Ratio"
,
"Percentage O2"
]
"mainPageSettings"
:
[
"Inhale Pressure"
,
"Respiratory Rate"
,
"Inhale Time"
,
"IE Ratio"
,
"Percentage O2"
,
"PEEP"
]
}
}
\ No newline at end of file
NativeUI/global_widgets/global_send_popup.py
View file @
05db8768
...
@@ -30,6 +30,7 @@ class SetConfirmPopup(QtWidgets.QDialog):
...
@@ -30,6 +30,7 @@ class SetConfirmPopup(QtWidgets.QDialog):
"""Popup called when user wants to send new values to microcontroller.
"""Popup called when user wants to send new values to microcontroller.
This popup shows changes and asks for confirmation"""
This popup shows changes and asks for confirmation"""
# a signal for each handler, so the UI knows which values were updated
ExpertSend
=
QtCore
.
Signal
()
ExpertSend
=
QtCore
.
Signal
()
ModeSend
=
QtCore
.
Signal
()
ModeSend
=
QtCore
.
Signal
()
PersonalSend
=
QtCore
.
Signal
()
PersonalSend
=
QtCore
.
Signal
()
...
@@ -41,6 +42,7 @@ class SetConfirmPopup(QtWidgets.QDialog):
...
@@ -41,6 +42,7 @@ class SetConfirmPopup(QtWidgets.QDialog):
self
.
NativeUI
=
NativeUI
self
.
NativeUI
=
NativeUI
self
.
handler
=
None
self
.
handler
=
None
# list widget displays the changes to be sent to MCU in human readable way
self
.
listWidget
=
QtWidgets
.
QListWidget
()
self
.
listWidget
=
QtWidgets
.
QListWidget
()
self
.
listWidget
.
setVerticalScrollBarPolicy
(
QtCore
.
Qt
.
ScrollBarAlwaysOff
)
self
.
listWidget
.
setVerticalScrollBarPolicy
(
QtCore
.
Qt
.
ScrollBarAlwaysOff
)
self
.
listWidget
.
setHorizontalScrollBarPolicy
(
QtCore
.
Qt
.
ScrollBarAlwaysOff
)
self
.
listWidget
.
setHorizontalScrollBarPolicy
(
QtCore
.
Qt
.
ScrollBarAlwaysOff
)
...
@@ -61,18 +63,19 @@ class SetConfirmPopup(QtWidgets.QDialog):
...
@@ -61,18 +63,19 @@ class SetConfirmPopup(QtWidgets.QDialog):
vlayout
.
addLayout
(
buttonHLayout
)
vlayout
.
addLayout
(
buttonHLayout
)
self
.
setLayout
(
vlayout
)
self
.
setLayout
(
vlayout
)
# self.setAttribute(QtCore.Qt.WA_NoSystemBackground, True)
# self.setWindowOpacity(0.5)
def
populatePopup
(
self
,
handlerWidget
,
messageList
):
def
populatePopup
(
self
,
handlerWidget
,
messageList
):
"""One popup is used for all the handlers. It is populated when called by a particular handler"""
self
.
handler
=
handlerWidget
self
.
handler
=
handlerWidget
self
.
clearPopup
()
self
.
listWidget
.
clear
()
if
messageList
==
[]:
if
messageList
==
[]:
messageList
=
[
"no values were set"
]
messageList
=
[
"no values were set"
]
for
item
in
messageList
:
for
item
in
messageList
:
listItem
=
QtWidgets
.
QListWidgetItem
(
item
)
listItem
=
QtWidgets
.
QListWidgetItem
(
item
)
listItem
.
setFlags
(
QtCore
.
Qt
.
NoItemFlags
)
listItem
.
setFlags
(
QtCore
.
Qt
.
NoItemFlags
)
self
.
listWidget
.
addItem
(
listItem
)
self
.
listWidget
.
addItem
(
listItem
)
# adjust size according to list contents
self
.
listWidget
.
setFixedHeight
(
self
.
listWidget
.
setFixedHeight
(
self
.
listWidget
.
sizeHintForRow
(
0
)
*
self
.
listWidget
.
count
()
+
10
self
.
listWidget
.
sizeHintForRow
(
0
)
*
self
.
listWidget
.
count
()
+
10
)
)
...
@@ -82,14 +85,10 @@ class SetConfirmPopup(QtWidgets.QDialog):
...
@@ -82,14 +85,10 @@ class SetConfirmPopup(QtWidgets.QDialog):
self
.
listWidget
.
update
()
self
.
listWidget
.
update
()
self
.
update
()
self
.
update
()
return
0
def
clearPopup
(
self
):
self
.
listWidget
.
clear
()
self
.
commandList
=
[]
def
ok_button_pressed
(
self
):
def
ok_button_pressed
(
self
):
"""Send commands when ok button is clicked"""
"""Emit signal to connect with handler corresponding to editted values."""
# self.parentTemplate.liveUpdating = True
if
self
.
handler
is
None
:
if
self
.
handler
is
None
:
logging
.
error
(
"Popup ok_button_pressed called before popupatePopup"
)
logging
.
error
(
"Popup ok_button_pressed called before popupatePopup"
)
return
1
return
1
...
@@ -114,6 +113,8 @@ class SetConfirmPopup(QtWidgets.QDialog):
...
@@ -114,6 +113,8 @@ class SetConfirmPopup(QtWidgets.QDialog):
class
confirmWidget
(
QtWidgets
.
QWidget
):
class
confirmWidget
(
QtWidgets
.
QWidget
):
"""A widget displaying an individual command confirmation from the MCU. Is contained in confirmPopup"""
def
__init__
(
self
,
NativeUI
,
confirmMessage
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
confirmMessage
,
*
args
,
**
kwargs
):
super
(
confirmWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
confirmWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
hlayout
=
QtWidgets
.
QHBoxLayout
()
self
.
hlayout
=
QtWidgets
.
QHBoxLayout
()
...
@@ -137,16 +138,18 @@ class confirmWidget(QtWidgets.QWidget):
...
@@ -137,16 +138,18 @@ class confirmWidget(QtWidgets.QWidget):
self
.
setLayout
(
self
.
hlayout
)
self
.
setLayout
(
self
.
hlayout
)
self
.
setFixedHeight
(
50
)
self
.
setFixedHeight
(
50
)
# create timer to handle timeout
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
10000
)
self
.
timer
.
setInterval
(
10000
)
self
.
timer
.
timeout
.
connect
(
self
.
confirmTimeout
)
self
.
timer
.
timeout
.
connect
(
self
.
confirmTimeout
)
self
.
timer
.
start
()
self
.
timer
.
start
()
def
confirmTimeout
(
self
):
def
confirmTimeout
(
self
):
"""Widget should expire after a defined time"""
self
.
parent
()
.
confirmDict
.
pop
(
self
.
parent
()
.
confirmDict
.
pop
(
self
.
confirmMessage
.
replace
(
"/"
,
"_"
)
.
replace
(
"-"
,
"_"
)
self
.
confirmMessage
.
replace
(
"/"
,
"_"
)
.
replace
(
"-"
,
"_"
)
# - and / are not used in dictionary keys
)
)
self
.
setParent
(
None
)
self
.
setParent
(
None
)
# delete self
class
confirmPopup
(
QtWidgets
.
QDialog
):
class
confirmPopup
(
QtWidgets
.
QDialog
):
...
@@ -173,12 +176,11 @@ class confirmPopup(QtWidgets.QDialog):
...
@@ -173,12 +176,11 @@ class confirmPopup(QtWidgets.QDialog):
)
# no window title
)
# no window title
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
500
)
# just faster than 60Hz
self
.
timer
.
setInterval
(
500
)
self
.
timer
.
timeout
.
connect
(
self
.
adjustSize
)
self
.
timer
.
timeout
.
connect
(
self
.
adjustSize
)
# container needs to adjust to a new number of confirmWidgets
self
.
timer
.
start
()
self
.
timer
.
start
()
def
addConfirmation
(
self
,
confirmMessage
):
def
addConfirmation
(
self
,
confirmMessage
):
print
(
'adding confirmation'
)
"""Add a confirmation to the popup. Triggered when UI receives a confirmation from the microcontroller"""
"""Add a confirmation to the popup. Triggered when UI receives a confirmation from the microcontroller"""
self
.
confirmDict
[
confirmMessage
]
=
confirmWidget
(
self
.
confirmDict
[
confirmMessage
]
=
confirmWidget
(
self
.
NativeUI
,
confirmMessage
self
.
NativeUI
,
confirmMessage
...
@@ -187,8 +189,10 @@ class confirmPopup(QtWidgets.QDialog):
...
@@ -187,8 +189,10 @@ class confirmPopup(QtWidgets.QDialog):
return
0
return
0
def
location_on_window
(
self
):
def
location_on_window
(
self
):
"""Places confirmWidgets at the top center of the screen"""
screen
=
QtWidgets
.
QDesktopWidget
()
.
screenGeometry
()
screen
=
QtWidgets
.
QDesktopWidget
()
.
screenGeometry
()
# widget = self.geometry()
# widget = self.geometry()
x
=
screen
.
width
()
-
screen
.
width
()
/
2
x
=
screen
.
width
()
-
screen
.
width
()
/
2
y
=
0
# screen.height() - widget.height()
y
=
0
# screen.height() - widget.height()
self
.
move
(
x
,
y
)
self
.
move
(
x
,
y
)
return
0
NativeUI/global_widgets/global_typeval_popup.py
View file @
05db8768
...
@@ -23,6 +23,7 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
...
@@ -23,6 +23,7 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
"""Popup takes user input to put in spin box. """
"""Popup takes user input to put in spin box. """
okPressed
=
QtCore
.
Signal
(
str
)
okPressed
=
QtCore
.
Signal
(
str
)
cancelPressed
=
QtCore
.
Signal
()
cancelPressed
=
QtCore
.
Signal
()
correctPassword
=
QtCore
.
Signal
()
def
__init__
(
self
,
NativeUI
,
characterType
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
characterType
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
super
()
.
__init__
(
*
args
,
**
kwargs
)
...
@@ -32,6 +33,8 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
...
@@ -32,6 +33,8 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
grid
=
QtWidgets
.
QGridLayout
()
grid
=
QtWidgets
.
QGridLayout
()
grid
.
setSpacing
(
1
)
grid
.
setSpacing
(
1
)
#self.label_text, self.min, self.max, self.initVal, self.step, self.decPlaces = 'Enter Password', 0, 10000, 0, 0, 0
self
.
setStyleSheet
(
"border-radius:4px; background-color:black"
)
self
.
setStyleSheet
(
"border-radius:4px; background-color:black"
)
self
.
characterType
=
characterType
self
.
characterType
=
characterType
self
.
label
=
QtWidgets
.
QLabel
()
# self.label_text)
self
.
label
=
QtWidgets
.
QLabel
()
# self.label_text)
...
@@ -84,24 +87,17 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
...
@@ -84,24 +87,17 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
self
.
numberpad
.
numberPressed
.
connect
(
self
.
handle_alphapress
)
self
.
numberpad
.
numberPressed
.
connect
(
self
.
handle_alphapress
)
hlayout
.
addWidget
(
self
.
lineEdit
)
hlayout
.
addWidget
(
self
.
lineEdit
)
# grid.addWidget(self.lineEdit, 0, 0, 1, 2)
self
.
hlayout2
=
QtWidgets
.
QHBoxLayout
()
self
.
hlayout2
=
QtWidgets
.
QHBoxLayout
()
self
.
okButton
=
OkButtonWidget
(
NativeUI
)
self
.
okButton
=
OkButtonWidget
(
NativeUI
)
self
.
okButton
.
setEnabled
(
True
)
self
.
okButton
.
setEnabled
(
True
)
self
.
okButton
.
pressed
.
connect
(
self
.
handle_ok_press
)
self
.
hlayout2
.
addWidget
(
self
.
okButton
)
self
.
hlayout2
.
addWidget
(
self
.
okButton
)
# grid.addWidget(self.okButton, 1, 0)
self
.
cancelButton
=
CancelButtonWidget
(
NativeUI
)
self
.
cancelButton
=
CancelButtonWidget
(
NativeUI
)
self
.
cancelButton
.
setEnabled
(
True
)
self
.
cancelButton
.
setEnabled
(
True
)
self
.
hlayout2
.
addWidget
(
self
.
cancelButton
)
self
.
hlayout2
.
addWidget
(
self
.
cancelButton
)
# grid.addWidget(self.cancelButton, 1, 1)
vlayout
=
QtWidgets
.
QVBoxLayout
()
vlayout
=
QtWidgets
.
QVBoxLayout
()
vlayout
.
addWidget
(
self
.
label
)
vlayout
.
addWidget
(
self
.
label
)
vlayout
.
addLayout
(
hlayout
)
vlayout
.
addLayout
(
hlayout
)
...
@@ -112,6 +108,13 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
...
@@ -112,6 +108,13 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
self
.
setWindowFlags
(
self
.
setWindowFlags
(
QtCore
.
Qt
.
FramelessWindowHint
|
QtCore
.
Qt
.
WindowStaysOnTopHint
QtCore
.
Qt
.
FramelessWindowHint
|
QtCore
.
Qt
.
WindowStaysOnTopHint
)
# no window title
)
# no window title
self
.
password
=
'A'
def
submit_password
(
self
):
val
=
self
.
lineEdit
.
text
()
if
val
==
self
.
password
:
self
.
correctPassword
.
emit
()
self
.
lineEdit
.
setText
(
''
)
# reset text whether or not password was successful
def
handle_ok_press
(
self
):
def
handle_ok_press
(
self
):
val
=
self
.
lineEdit
.
text
()
val
=
self
.
lineEdit
.
text
()
...
@@ -131,7 +134,7 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
...
@@ -131,7 +134,7 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
self
.
label_text
=
currentWidg
.
label_text
self
.
label_text
=
currentWidg
.
label_text
self
.
label
.
setText
(
self
.
label_text
)
self
.
label
.
setText
(
self
.
label_text
)
self
.
lineEdit
.
setText
(
str
(
currentWidg
.
value
()))
self
.
lineEdit
.
setText
(
''
)
#
str(currentWidg.value()))
def
handle_numberpress
(
self
,
symbol
):
def
handle_numberpress
(
self
,
symbol
):
"""Handle number pad button press. Put button value in line edit text, and handle inputs
"""Handle number pad button press. Put button value in line edit text, and handle inputs
...
...
NativeUI/global_widgets/tab_modeswitch_button.py
View file @
05db8768
...
@@ -14,6 +14,7 @@ __status__ = "Prototype"
...
@@ -14,6 +14,7 @@ __status__ = "Prototype"
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
import
json
# from global_widgets.global_ok_cancel_buttons import okButton, cancelButton
# from global_widgets.global_ok_cancel_buttons import okButton, cancelButton
...
@@ -23,6 +24,8 @@ class TabModeswitchButton(QtWidgets.QWidget):
...
@@ -23,6 +24,8 @@ class TabModeswitchButton(QtWidgets.QWidget):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
super
()
.
__init__
(
*
args
,
**
kwargs
)
"""Button opens popup for user to switch modes.
The label is updated to show the current operating mode"""
self
.
NativeUI
=
NativeUI
self
.
NativeUI
=
NativeUI
...
@@ -46,19 +49,19 @@ class TabModeswitchButton(QtWidgets.QWidget):
...
@@ -46,19 +49,19 @@ class TabModeswitchButton(QtWidgets.QWidget):
# self.mode_popup.okbutton.pressed.connect(self.changeText)
# self.mode_popup.okbutton.pressed.connect(self.changeText)
def
update_mode
(
self
,
mode
):
def
update_mode
(
self
,
mode
):
print
(
"updating mode"
)
"""Update button text to show operating mode"""
print
(
mode
)
self
.
switchButton
.
setText
(
mode
)
self
.
switchButton
.
setText
(
mode
)
# self.mode_popup.update_mode(mode)
return
0
def
switch_button_pressed
(
self
):
def
switch_button_pressed
(
self
):
"""Button pressed, open popup, ensure correct mode is selected in popup."""
if
self
.
mode_popup
==
False
:
if
self
.
mode_popup
==
False
:
self
.
mode_popup
=
modeswitchPopup
(
self
.
NativeUI
)
self
.
mode_popup
=
modeswitchPopup
(
self
.
NativeUI
)
self
.
mode_popup
.
okbutton
.
pressed
.
connect
(
self
.
changeText
)
self
.
mode_popup
.
okbutton
.
pressed
.
connect
(
self
.
changeText
)
else
:
else
:
self
.
mode_popup
.
radioButtons
[
self
.
NativeUI
.
currentMode
]
.
click
()
self
.
mode_popup
.
radioButtons
[
self
.
NativeUI
.
currentMode
]
.
click
()
self
.
mode_popup
.
show
()
self
.
mode_popup
.
show
()
return
0
def
changeText
(
self
):
def
changeText
(
self
):
self
.
switchButton
.
setText
(
self
.
mode_popup
.
mode
)
self
.
switchButton
.
setText
(
self
.
mode_popup
.
mode
)
...
@@ -71,43 +74,15 @@ class TabModeswitchButton(QtWidgets.QWidget):
...
@@ -71,43 +74,15 @@ class TabModeswitchButton(QtWidgets.QWidget):
class
modeswitchPopup
(
QtWidgets
.
QWidget
):
class
modeswitchPopup
(
QtWidgets
.
QWidget
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
"""A popup used to switch modes. Allows the user to compare the values they are setting with current setting
and to navigate to mode setting page to edit those values."""
super
(
modeswitchPopup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
modeswitchPopup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
NativeUI
=
NativeUI
self
.
settingsList
=
[
with
open
(
"NativeUI/configs/mode_config.json"
)
as
json_file
:
[
modeDict
=
json
.
load
(
json_file
)
"Respiratory Rate"
,
"/min"
,
self
.
settingsList
=
modeDict
[
'settings'
]
"respiratory_rate"
,
"SET_TARGET_"
,
"RESPIRATORY_RATE"
,
],
[
"Inhale Time"
,
"s"
,
"inhale_time"
,
"SET_TARGET_"
,
"INHALE_TIME"
],
[
"IE Ratio"
,
""
,
"ie_ratio"
,
"SET_TARGET_"
,
"IE_RATIO"
],
[
"Inhale Trigger Sensitivity"
,
""
,
"inhale_trigger_threshold"
,
"SET_TARGET_"
,
"INHALE_TRIGGER_THRESHOLD"
,
],
[
"Exhale Trigger Sensitivity"
,
""
,
"exhale_trigger_threshold"
,
"SET_TARGET_"
,
"EXHALE_TRIGGER_THRESHOLD"
,
],
[
"Inhale Pressure"
,
""
,
"inspiratory_pressure"
,
"SET_TARGET_"
,
"INSPIRATORY_PRESSURE"
,
],
[
"Inhale Volume"
,
""
,
"volume"
,
"SET_TARGET_"
,
"VOLUME"
],
[
"Percentage O2"
,
""
,
"fiO2_percent"
,
"SET_TARGET_"
,
"FIO2_PERCENT"
],
]
# self.NativeUI.modes_view.modeTab.settingsList
modeList
=
self
.
NativeUI
.
modeList
modeList
=
self
.
NativeUI
.
modeList
vradioLayout
=
QtWidgets
.
QVBoxLayout
()
vradioLayout
=
QtWidgets
.
QVBoxLayout
()
...
@@ -115,29 +90,27 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -115,29 +90,27 @@ class modeswitchPopup(QtWidgets.QWidget):
self
.
radioButtons
=
{}
self
.
radioButtons
=
{}
for
mode
in
modeList
:
for
mode
in
modeList
:
button
=
QtWidgets
.
QRadioButton
(
mode
)
button
=
QtWidgets
.
QRadioButton
(
mode
)
go
ToB
utton
=
QtWidgets
.
QPushButton
(
mode
)
go
to_b
utton
=
QtWidgets
.
QPushButton
(
mode
)
go
ToButton
.
pressed
.
connect
(
lambda
j
=
mode
:
self
.
goToP
ressed
(
j
))
go
to_button
.
pressed
.
connect
(
lambda
j
=
mode
:
self
.
goto_p
ressed
(
j
))
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
.
addWidget
(
button
)
hlayout
.
addWidget
(
button
)
hlayout
.
addWidget
(
go
ToB
utton
)
hlayout
.
addWidget
(
go
to_b
utton
)
self
.
radioButtons
[
mode
]
=
button
self
.
radioButtons
[
mode
]
=
button
vradioLayout
.
addLayout
(
hlayout
)
vradioLayout
.
addLayout
(
hlayout
)
button
.
pressed
.
connect
(
lambda
i
=
button
:
self
.
update_settings_data
(
i
))
if
mode
==
self
.
NativeUI
.
currentMode
:
button
.
click
()
groupBox
.
setLayout
(
vradioLayout
)
groupBox
.
setLayout
(
vradioLayout
)
## Values display
## Values display
valuesLayout
=
QtWidgets
.
QHBoxLayout
()
valuesLayout
=
QtWidgets
.
QHBoxLayout
()
# Title labels:
initLabel
=
QtWidgets
.
QLabel
(
" "
)
# titles
initLabel
=
QtWidgets
.
QLabel
(
" "
)
initVal
=
QtWidgets
.
QLabel
(
"Current"
)
initVal
=
QtWidgets
.
QLabel
(
"Current"
)
initVal
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
initVal
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
newVal
=
QtWidgets
.
QLabel
(
"New"
)
newVal
=
QtWidgets
.
QLabel
(
"New"
)
newVal
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
newVal
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
newVal
.
setStyleSheet
(
"color: red"
)
newVal
.
setStyleSheet
(
"color: red"
)
# Populate actual values in loop
self
.
labelList
,
self
.
currentLabelList
,
self
.
newLabelList
=
[],
[],
[]
self
.
labelList
,
self
.
currentLabelList
,
self
.
newLabelList
=
[],
[],
[]
vlayout1
,
vlayout2
,
vlayout3
=
(
vlayout1
,
vlayout2
,
vlayout3
=
(
QtWidgets
.
QVBoxLayout
(),
QtWidgets
.
QVBoxLayout
(),
...
@@ -186,6 +159,12 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -186,6 +159,12 @@ class modeswitchPopup(QtWidgets.QWidget):
vlayout
.
addLayout
(
hlayout
)
vlayout
.
addLayout
(
hlayout
)
vlayout
.
addLayout
(
hbuttonlayout
)
vlayout
.
addLayout
(
hbuttonlayout
)
for
mode
in
modeList
:
button
=
self
.
radioButtons
[
mode
]
button
.
pressed
.
connect
(
lambda
i
=
button
:
self
.
update_settings_data
(
i
))
if
mode
==
self
.
NativeUI
.
currentMode
:
button
.
click
()
## Final, general, initiation steps
## Final, general, initiation steps
self
.
setLayout
(
vlayout
)
self
.
setLayout
(
vlayout
)
...
@@ -201,8 +180,8 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -201,8 +180,8 @@ class modeswitchPopup(QtWidgets.QWidget):
)
)
# self.radioButtons[self.NativeUI.currentMode].click()
# self.radioButtons[self.NativeUI.currentMode].click()
def
go
ToP
ressed
(
self
,
mode
):
def
go
to_p
ressed
(
self
,
mode
):
# Switch to the modes page
"""On button press, show mode page in UI"""
self
.
NativeUI
.
widgets
.
page_stack
.
setCurrentWidget
(
self
.
NativeUI
.
widgets
.
page_stack
.
setCurrentWidget
(
self
.
NativeUI
.
widgets
.
modes_page
self
.
NativeUI
.
widgets
.
modes_page
)
)
...
@@ -219,25 +198,21 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -219,25 +198,21 @@ class modeswitchPopup(QtWidgets.QWidget):
self
.
close
()
self
.
close
()
def
update_settings_data
(
self
,
button
):
def
update_settings_data
(
self
,
button
):
self
.
spinDict
=
self
.
NativeUI
.
widgets
.
mode_handler
.
spinDict
"""Respond to button press and update labels in modeswitch popup"""
self
.
mode
=
button
.
text
()
# .replace("/", "_").replace("-", "_")
self
.
spinDict
=
self
.
NativeUI
.
mode_handler
.
spinDict
self
.
mode
=
button
.
text
()
data
=
self
.
NativeUI
.
get_db
(
"targets"
)
for
settings
,
currentLabel
,
newLabel
in
zip
(
for
settings
,
currentLabel
,
newLabel
in
zip
(
self
.
settingsList
,
self
.
currentLabelList
,
self
.
newLabelList
self
.
settingsList
,
self
.
currentLabelList
,
self
.
newLabelList
):
):
currentVal
=
self
.
spinDict
[
currentVal
=
self
.
spinDict
[
"spin_"
+
self
.
NativeUI
.
currentMode
+
"_"
+
settings
[
2
]
"spin_"
+
self
.
NativeUI
.
currentMode
+
"_"
+
settings
[
2
]
]
.
get_value
()
]
.
get_value
()
# currentVal = self.spinDict[
# self.NativeUI.currentMode # .replace("/", "_").replace("-", "_")
# ][settings].get_value()
currentLabel
.
setText
(
str
(
round
(
currentVal
,
4
)))
currentLabel
.
setText
(
str
(
round
(
currentVal
,
4
)))
setVal
=
self
.
spinDict
[
"spin_"
+
self
.
mode
+
"_"
+
settings
[
2
]]
.
get_value
()
setVal
=
self
.
spinDict
[
"spin_"
+
self
.
mode
+
"_"
+
settings
[
2
]]
.
get_value
()
newLabel
.
setText
(
str
(
round
(
setVal
,
4
)))
newLabel
.
setText
(
str
(
round
(
setVal
,
4
)))
print
(
"done"
)
def
ok_button_pressed
(
self
):
def
ok_button_pressed
(
self
):
"""Switch to selected mode"""
if
self
.
NativeUI
.
currentMode
==
self
.
mode
:
if
self
.
NativeUI
.
currentMode
==
self
.
mode
:
a
=
1
# do nothing
a
=
1
# do nothing
else
:
else
:
...
@@ -246,22 +221,13 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -246,22 +221,13 @@ class modeswitchPopup(QtWidgets.QWidget):
)
)
self
.
NativeUI
.
currentMode
=
self
.
mode
self
.
NativeUI
.
currentMode
=
self
.
mode
self
.
close
()
self
.
close
()
# ensure main page buttons display IE Ratio or Inhale Time as enabled
return
0
# if self.NativeUI.widgets.mode_settings_tab.tabsDict[
# self.mode
# ].radioButtonRat.isChecked():
# # self.NativeUI.main_view.tab_spin.setStackWidget("IE Ratio")
# self.NativeUI.widgets.spin_buttons.setStackWidget("IE Ratio")
# else:
# # self.NativeUI.main_view.tab_spin.setStackWidget("Inhale Time")
# self.NativeUI.widgets.spin_buttons.setStackWidget("Inhale Time")
# self.modeSwitched.emit()
return
0
def
cancel_button_pressed
(
self
):
def
cancel_button_pressed
(
self
):
"""Close popup without doing anything"""
self
.
close
()
self
.
close
()
return
0
return
0
def
update_mode
(
self
,
mode
):
def
update_mode
(
self
,
mode
):
"""When mode is changed the popup radio buttons should show the new mode"""
self
.
mode_popup
.
radioButtons
[
mode
]
.
click
()
self
.
mode_popup
.
radioButtons
[
mode
]
.
click
()
NativeUI/mode_widgets/clinical_handler.py
View file @
05db8768
...
@@ -121,6 +121,13 @@ class ClinicalHandler(PayloadHandler):
...
@@ -121,6 +121,13 @@ class ClinicalHandler(PayloadHandler):
self
.
active_payload
()
self
.
active_payload
()
self
.
refresh_button_colour
()
self
.
refresh_button_colour
()
def
handle_cancel_pressed
(
self
,
buttonMode
):
if
buttonMode
==
self
.
NativeUI
.
currentMode
:
print
(
'modes match '
)
self
.
commandSent
()
else
:
print
(
'do nothing in clinical'
)
def
commandSent
(
self
):
def
commandSent
(
self
):
self
.
commandList
=
[]
self
.
commandList
=
[]
for
key
,
widget
in
dict
(
self
.
limSpinDict
,
**
self
.
setSpinDict
)
.
items
():
for
key
,
widget
in
dict
(
self
.
limSpinDict
,
**
self
.
setSpinDict
)
.
items
():
...
...
NativeUI/mode_widgets/mode_handler.py
View file @
05db8768
...
@@ -76,6 +76,9 @@ class ModeHandler(PayloadHandler):
...
@@ -76,6 +76,9 @@ class ModeHandler(PayloadHandler):
setVal
,
setVal
,
]
]
)
)
if
isinstance
(
self
.
buttonDict
[
key
],
OkSendButtonWidget
):
message
.
append
(
"change mode to "
+
str
(
mode
))
command
.
append
([
"SET_MODE"
,
mode
.
replace
(
"/"
,
"_"
)
.
replace
(
"-"
,
"_"
)])
# create a signal emitting message, command, handler identifier - in nativeui connect to a popup widget
# create a signal emitting message, command, handler identifier - in nativeui connect to a popup widget
# command sending should occur in handler
# command sending should occur in handler
self
.
commandList
=
command
self
.
commandList
=
command
...
@@ -113,6 +116,20 @@ class ModeHandler(PayloadHandler):
...
@@ -113,6 +116,20 @@ class ModeHandler(PayloadHandler):
self
.
commandSent
()
self
.
commandSent
()
return
0
return
0
def
handle_cancel_pressed
(
self
,
buttonMode
):
for
widget
in
self
.
spinDict
:
if
buttonMode
in
widget
:
self
.
spinDict
[
widget
]
.
manuallyUpdated
=
False
if
buttonMode
==
self
.
NativeUI
.
currentMode
:
print
(
'modes match '
)
for
widget
in
self
.
mainSpinDict
:
self
.
mainSpinDict
[
widget
]
.
manuallyUpdated
=
False
else
:
print
(
'do nothing in clinical'
)
self
.
active_payload
()
self
.
refresh_button_colour
()
self
.
refresh_main_button_colour
()
def
commandSent
(
self
):
def
commandSent
(
self
):
self
.
commandList
=
[]
self
.
commandList
=
[]
for
widget
in
self
.
spinDict
:
for
widget
in
self
.
spinDict
:
...
@@ -127,7 +144,6 @@ class ModeHandler(PayloadHandler):
...
@@ -127,7 +144,6 @@ class ModeHandler(PayloadHandler):
self
.
refresh_main_button_colour
()
self
.
refresh_main_button_colour
()
def
handle_manual_change
(
self
,
changed_spin_key
):
def
handle_manual_change
(
self
,
changed_spin_key
):
print
(
'handle manual change'
)
self
.
active_payload
()
self
.
active_payload
()
self
.
refresh_button_colour
()
self
.
refresh_button_colour
()
self
.
refresh_main_button_colour
()
self
.
refresh_main_button_colour
()
...
...
NativeUI/ui_layout.py
View file @
05db8768
...
@@ -185,6 +185,7 @@ class Layout:
...
@@ -185,6 +185,7 @@ class Layout:
self
.
widgets
.
personal_display
,
self
.
widgets
.
personal_display
,
self
.
widgets
.
localisation_button
,
self
.
widgets
.
localisation_button
,
self
.
widgets
.
battery_display
,
self
.
widgets
.
battery_display
,
self
.
widgets
.
lock_button
,
]
]
)
)
)
)
...
@@ -335,11 +336,11 @@ class Layout:
...
@@ -335,11 +336,11 @@ class Layout:
page_settings
=
SwitchableStackWidget
(
page_settings
=
SwitchableStackWidget
(
self
.
NativeUI
.
colors
,
self
.
NativeUI
.
colors
,
self
.
NativeUI
.
text
,
self
.
NativeUI
.
text
,
[
self
.
layout_settings_expert
(),
tab_charts
,
tab_info
],
[
tab_charts
,
tab_info
,
self
.
layout_settings_expert
(),
],
[
[
"button_label_settings_expert"
,
"button_label_settings_charts"
,
"button_label_settings_charts"
,
"button_label_settings_info"
,
"button_label_settings_info"
,
"button_label_settings_expert"
,
],
],
)
)
page_settings
.
setFont
(
self
.
NativeUI
.
text_font
)
page_settings
.
setFont
(
self
.
NativeUI
.
text_font
)
...
@@ -697,11 +698,11 @@ class Layout:
...
@@ -697,11 +698,11 @@ class Layout:
vlayout
.
addLayout
(
hButtonLayout
)
vlayout
.
addLayout
(
hButtonLayout
)
passlock_stack
=
QtWidgets
.
QStackedWidget
()
#passlock_stack = #
QtWidgets.QStackedWidget()
passlock_stack
.
addWidget
(
self
.
NativeUI
.
widgets
.
expert_password_widget
)
self
.
NativeUI
.
widgets
.
expert_
passlock_stack
.
addWidget
(
self
.
NativeUI
.
widgets
.
expert_password_widget
)
passlock_stack
.
addWidget
(
expert_tab
)
self
.
NativeUI
.
widgets
.
expert_
passlock_stack
.
addWidget
(
expert_tab
)
#
break this here
#break this here
return
passlock_stack
#
expert_tab
return
self
.
NativeUI
.
widgets
.
expert_passlock_stack
#
expert_tab
def
layout_main_spin_buttons
(
self
)
->
QtWidgets
.
QWidget
:
def
layout_main_spin_buttons
(
self
)
->
QtWidgets
.
QWidget
:
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
=
QtWidgets
.
QHBoxLayout
()
...
...
NativeUI/ui_widgets.py
View file @
05db8768
...
@@ -47,7 +47,7 @@ from widget_library.info_display_widgets import (
...
@@ -47,7 +47,7 @@ from widget_library.info_display_widgets import (
# from widget_library.tab_charts import TabChart
# from widget_library.tab_charts import TabChart
from
widget_library.chart_buttons_widget
import
ChartButtonsWidget
from
widget_library.chart_buttons_widget
import
ChartButtonsWidget
from
widget_library.page_buttons_widget
import
PageButtonsWidget
from
widget_library.page_buttons_widget
import
PageButtonsWidget
,
PageButton
from
widget_library.personal_display_widget
import
PersonalDisplayWidget
from
widget_library.personal_display_widget
import
PersonalDisplayWidget
from
widget_library.plot_widget
import
(
from
widget_library.plot_widget
import
(
ChartsPlotWidget
,
ChartsPlotWidget
,
...
@@ -136,10 +136,14 @@ class Widgets:
...
@@ -136,10 +136,14 @@ class Widgets:
self
.
ventilator_start_stop_buttons_widget
=
VentilatorStartStopButtonsWidget
(
self
.
ventilator_start_stop_buttons_widget
=
VentilatorStartStopButtonsWidget
(
NativeUI
NativeUI
)
)
self
.
lock_button
=
PageButton
(
NativeUI
,
""
,
signal_value
=
"lock_screen"
,
icon
=
NativeUI
.
icons
[
"lock_screen"
],
)
# Main Page Widgets
# Main Page Widgets
# self.spin_buttons = SpinButtonsWidget(NativeUI)
# self.add_handled_widget(SpinButtonsWidget(NativeUI), 'spin_buttons', NativeUI.mode_handler)
self
.
history_buttons
=
HistoryButtonsWidget
(
NativeUI
)
self
.
history_buttons
=
HistoryButtonsWidget
(
NativeUI
)
self
.
normal_plots
=
TimePlotsWidget
(
NativeUI
)
self
.
normal_plots
=
TimePlotsWidget
(
NativeUI
)
self
.
detailed_plots
=
TimePlotsWidget
(
NativeUI
)
self
.
detailed_plots
=
TimePlotsWidget
(
NativeUI
)
...
@@ -209,7 +213,6 @@ class Widgets:
...
@@ -209,7 +213,6 @@ class Widgets:
for
setting
in
modeDict
[
"settings"
]:
for
setting
in
modeDict
[
"settings"
]:
if
setting
[
0
]
in
modeDict
[
"mainPageSettings"
]:
if
setting
[
0
]
in
modeDict
[
"mainPageSettings"
]:
attrName
=
"CURRENT_"
+
setting
[
2
]
attrName
=
"CURRENT_"
+
setting
[
2
]
#setting[3] = setting[3].replace('SET_TARGET_', 'SET_TARGET_CURRENT')
self
.
add_handled_widget
(
self
.
add_handled_widget
(
SpinButton
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
),
attrName
,
NativeUI
.
mode_handler
SpinButton
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
),
attrName
,
NativeUI
.
mode_handler
)
)
...
@@ -330,12 +333,10 @@ class Widgets:
...
@@ -330,12 +333,10 @@ class Widgets:
)
)
##### Settings Tab: Expert and Charts tabs
##### Settings Tab: Expert and Charts tabs
self
.
add_widget
(
AbstractTypeValPopup
(
NativeUI
,
'numeric'
),
'expert_password_widget'
)
self
.
add_widget
(
QStackedWidget
(),
'expert_passlock_stack'
)
self
.
add_handled_widget
(
AbstractTypeValPopup
(
NativeUI
,
'alpha'
),
'expert_password_widget'
,
NativeUI
.
expert_handler
)
# Expert Tab
# Expert Tab
# self.expert_confirm_popup = SetConfirmPopup(NativeUI)
# NativeUI.expert_handler = ExpertHandler(NativeUI, self.expert_confirm_popup)
print
(
os
.
listdir
())
with
open
(
"NativeUI/configs/expert_config.json"
)
as
json_file
:
with
open
(
"NativeUI/configs/expert_config.json"
)
as
json_file
:
controlDict
=
json
.
load
(
json_file
)
controlDict
=
json
.
load
(
json_file
)
...
@@ -378,6 +379,7 @@ class Widgets:
...
@@ -378,6 +379,7 @@ class Widgets:
return
0
return
0
def
add_handled_widget
(
self
,
widget
,
name
,
handler
)
->
int
:
def
add_handled_widget
(
self
,
widget
,
name
,
handler
)
->
int
:
"""Add a widget to Widgets and pass it into a handler"""
setattr
(
self
,
name
,
widget
)
setattr
(
self
,
name
,
widget
)
handler
.
add_widget
(
widget
,
name
)
handler
.
add_widget
(
widget
,
name
)
return
0
return
0
...
...
NativeUI/widget_library/expert_handler.py
View file @
05db8768
from
global_widgets.global_spinbox
import
labelledSpin
from
global_widgets.global_spinbox
import
labelledSpin
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
,
OkSendButtonWidget
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
,
OkSendButtonWidget
from
global_widgets.global_typeval_popup
import
AbstractTypeValPopup
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
from
handler_library.handler
import
PayloadHandler
from
handler_library.handler
import
PayloadHandler
...
@@ -29,6 +30,8 @@ class ExpertHandler(PayloadHandler): # chose QWidget over QDialog family becaus
...
@@ -29,6 +30,8 @@ class ExpertHandler(PayloadHandler): # chose QWidget over QDialog family becaus
self
.
spinDict
[
key
]
=
widget
self
.
spinDict
[
key
]
=
widget
if
isinstance
(
widget
,
OkButtonWidget
)
or
isinstance
(
widget
,
CancelButtonWidget
)
or
isinstance
(
widget
,
OkSendButtonWidget
):
if
isinstance
(
widget
,
OkButtonWidget
)
or
isinstance
(
widget
,
CancelButtonWidget
)
or
isinstance
(
widget
,
OkSendButtonWidget
):
self
.
buttonDict
[
key
]
=
widget
self
.
buttonDict
[
key
]
=
widget
if
isinstance
(
widget
,
AbstractTypeValPopup
):
self
.
password_lock
=
widget
def
active_payload
(
self
,
*
args
)
->
int
:
def
active_payload
(
self
,
*
args
)
->
int
:
...
...
NativeUI/widget_library/page_buttons_widget.py
View file @
05db8768
...
@@ -36,10 +36,7 @@ class PageButtonsWidget(QtWidgets.QWidget):
...
@@ -36,10 +36,7 @@ class PageButtonsWidget(QtWidgets.QWidget):
layout
=
QtWidgets
.
QVBoxLayout
()
layout
=
QtWidgets
.
QVBoxLayout
()
self
.
main_button
=
PageButton
(
self
.
main_button
=
PageButton
(
NativeUI
,
""
,
signal_value
=
"main_page"
,
icon
=
NativeUI
.
icons
[
"button_main_page"
]
""
,
signal_value
=
"main_page"
,
icon
=
NativeUI
.
icons
[
"button_main_page"
],
)
)
self
.
alarms_button
=
PageButton
(
self
.
alarms_button
=
PageButton
(
""
,
signal_value
=
"alarms_page"
,
icon
=
NativeUI
.
icons
[
"button_alarms_page"
]
""
,
signal_value
=
"alarms_page"
,
icon
=
NativeUI
.
icons
[
"button_alarms_page"
]
...
@@ -64,17 +61,20 @@ class PageButtonsWidget(QtWidgets.QWidget):
...
@@ -64,17 +61,20 @@ class PageButtonsWidget(QtWidgets.QWidget):
"QPushButton{"
"QPushButton{"
" border:none"
" border:none"
"}"
"}"
"QPushButton
:disabled
{"
"QPushButton
[selected='0']
{"
" background-color:"
" background-color:"
+
NativeUI
.
colors
[
"button_background_
dis
abled"
]
.
name
()
+
NativeUI
.
colors
[
"button_background_
en
abled"
]
.
name
()
+
";"
+
";"
" border:none"
"}"
"}"
"QPushButton
:enabled
{"
"QPushButton
[selected='1']
{"
" background-color:"
" background-color:"
+
NativeUI
.
colors
[
"button_background_enabled"
]
.
name
()
+
NativeUI
.
colors
[
"button_background_highlight"
]
.
name
()
+
";"
"}"
"QPushButton:disabled{"
" background-color:"
+
NativeUI
.
colors
[
"button_background_disabled"
]
.
name
()
+
";"
+
";"
" border:none"
"}"
"}"
)
)
...
@@ -82,19 +82,14 @@ class PageButtonsWidget(QtWidgets.QWidget):
...
@@ -82,19 +82,14 @@ class PageButtonsWidget(QtWidgets.QWidget):
# set button appearance
# set button appearance
button
.
setStyleSheet
(
stylesheet
)
button
.
setStyleSheet
(
stylesheet
)
button
.
setIconColor
(
NativeUI
.
colors
[
"page_foreground"
])
button
.
setIconColor
(
NativeUI
.
colors
[
"page_foreground"
])
button
.
pressed
.
connect
(
lambda
i
=
button
:
self
.
set_pressed
(
i
))
layout
.
addWidget
(
button
)
layout
.
addWidget
(
button
)
self
.
setLayout
(
layout
)
self
.
setLayout
(
layout
)
self
.
set_pressed
(
self
.
buttons
[
0
])
# Connect the buttons so that pressing one enables all of the others
def
set_pressed
(
self
,
button_pressed
)
->
int
:
for
pressed_button
in
self
.
buttons
:
for
unpressed_button
in
self
.
buttons
:
if
pressed_button
==
unpressed_button
:
continue
pressed_button
.
pressed
.
connect
(
unpressed_button
.
enable
)
def
set_pressed
(
self
,
pressed
:
str
)
->
int
:
"""
"""
Set the specified buttons to enabled (unpressed) or disabled (pressed) states.
Set the specified buttons to enabled (unpressed) or disabled (pressed) states.
By default, all buttons in self.buttons will be made enabled except those in the
By default, all buttons in self.buttons will be made enabled except those in the
...
@@ -102,13 +97,13 @@ class PageButtonsWidget(QtWidgets.QWidget):
...
@@ -102,13 +97,13 @@ class PageButtonsWidget(QtWidgets.QWidget):
pressed can be str or list of str.
pressed can be str or list of str.
"""
"""
if
isinstance
(
pressed
,
str
):
pressed
=
[
pressed
]
for
button
in
self
.
buttons
:
for
button
in
self
.
buttons
:
button
.
setEnabled
(
True
)
if
button
==
button_pressed
:
for
button_name
in
pressed
:
button
.
setProperty
(
"selected"
,
"1"
)
button
=
getattr
(
self
,
button_name
)
else
:
button
.
setEnabled
(
False
)
button
.
setProperty
(
"selected"
,
"0"
)
button
.
style
()
.
unpolish
(
button
)
button
.
style
()
.
polish
(
button
)
return
0
return
0
def
set_size
(
self
,
x
:
int
,
y
:
int
,
spacing
:
int
=
10
)
->
int
:
def
set_size
(
self
,
x
:
int
,
y
:
int
,
spacing
:
int
=
10
)
->
int
:
...
@@ -165,9 +160,7 @@ class PageButtonsWidget(QtWidgets.QWidget):
...
@@ -165,9 +160,7 @@ class PageButtonsWidget(QtWidgets.QWidget):
class
PageButton
(
QtWidgets
.
QPushButton
):
class
PageButton
(
QtWidgets
.
QPushButton
):
PageButtonPressed
=
Signal
(
str
)
PageButtonPressed
=
Signal
(
str
)
def
__init__
(
def
__init__
(
self
,
*
args
,
signal_value
:
str
=
None
,
icon
:
str
=
None
,
**
kwargs
):
self
,
NativeUI
,
*
args
,
signal_value
:
str
=
None
,
icon
:
str
=
None
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
__signal_value
=
signal_value
self
.
__signal_value
=
signal_value
self
.
__icon_path
=
icon
self
.
__icon_path
=
icon
...
@@ -186,15 +179,12 @@ class PageButton(QtWidgets.QPushButton):
...
@@ -186,15 +179,12 @@ class PageButton(QtWidgets.QPushButton):
self
.
setIcon
(
QtGui
.
QIcon
(
pixmap
))
self
.
setIcon
(
QtGui
.
QIcon
(
pixmap
))
return
0
return
0
@
Slot
()
def
enable
(
self
):
self
.
setEnabled
(
True
)
return
0
def
on_press
(
self
):
def
on_press
(
self
):
"""
"""
When the button is pressed, disable it and emit the PageButtonPressed signal.
When the button is pressed, disable it and emit the PageButtonPressed signal.
"""
"""
self
.
setEnabled
(
False
)
self
.
PageButtonPressed
.
emit
(
self
.
__signal_value
)
self
.
PageButtonPressed
.
emit
(
self
.
__signal_value
)
return
0
return
0
def
localise_text
(
self
,
*
args
,
**
kwargs
)
->
int
:
pass
NativeUI/widget_library/plot_widget.py
View file @
05db8768
...
@@ -88,21 +88,21 @@ class TimePlotsWidget(QtWidgets.QWidget):
...
@@ -88,21 +88,21 @@ class TimePlotsWidget(QtWidgets.QWidget):
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
NativeUI
.
text
[
"plot_line_label_pressure"
],
NativeUI
.
text
[
"plot_line_label_pressure"
],
NativeUI
.
colors
[
"p
ressure_plot
"
]
.
name
(),
NativeUI
.
colors
[
"p
lot_pressure
"
]
.
name
(),
)
)
self
.
flow_line
=
self
.
plot
(
self
.
flow_line
=
self
.
plot
(
self
.
flow_plot
,
self
.
flow_plot
,
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
NativeUI
.
text
[
"plot_line_label_flow"
],
NativeUI
.
text
[
"plot_line_label_flow"
],
NativeUI
.
colors
[
"
flow_plot
"
]
.
name
(),
NativeUI
.
colors
[
"
plot_flow
"
]
.
name
(),
)
)
self
.
volume_line
=
self
.
plot
(
self
.
volume_line
=
self
.
plot
(
self
.
volume_plot
,
self
.
volume_plot
,
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
NativeUI
.
text
[
"plot_line_label_volume"
],
NativeUI
.
text
[
"plot_line_label_volume"
],
NativeUI
.
colors
[
"
volume_plot
"
]
.
name
(),
NativeUI
.
colors
[
"
plot_volume
"
]
.
name
(),
)
)
self
.
setLayout
(
layout
)
self
.
setLayout
(
layout
)
...
@@ -227,21 +227,21 @@ class CirclePlotsWidget(QtWidgets.QWidget):
...
@@ -227,21 +227,21 @@ class CirclePlotsWidget(QtWidgets.QWidget):
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
NativeUI
.
text
[
"plot_line_label_pressure_flow"
],
NativeUI
.
text
[
"plot_line_label_pressure_flow"
],
NativeUI
.
colors
[
"p
ressure_flow_plot
"
]
.
name
(),
NativeUI
.
colors
[
"p
lot_pressure_flow
"
]
.
name
(),
)
)
self
.
flow_volume_line
=
self
.
plot
(
self
.
flow_volume_line
=
self
.
plot
(
self
.
flow_volume_plot
,
self
.
flow_volume_plot
,
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
NativeUI
.
text
[
"plot_line_label_flow_volume"
],
NativeUI
.
text
[
"plot_line_label_flow_volume"
],
NativeUI
.
colors
[
"
flow_volume_plot
"
]
.
name
(),
NativeUI
.
colors
[
"
plot_flow_volume
"
]
.
name
(),
)
)
self
.
volume_pressure_line
=
self
.
plot
(
self
.
volume_pressure_line
=
self
.
plot
(
self
.
volume_pressure_plot
,
self
.
volume_pressure_plot
,
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
[
0
,
0
],
NativeUI
.
text
[
"plot_line_label_volume_pressure"
],
NativeUI
.
text
[
"plot_line_label_volume_pressure"
],
NativeUI
.
colors
[
"
volume_pressure_plot
"
]
.
name
(),
NativeUI
.
colors
[
"
plot_volume_pressure
"
]
.
name
(),
)
)
self
.
setLayout
(
layout
)
self
.
setLayout
(
layout
)
...
@@ -332,7 +332,7 @@ class ChartsPlotWidget(QtWidgets.QWidget):
...
@@ -332,7 +332,7 @@ class ChartsPlotWidget(QtWidgets.QWidget):
}
}
# Store the colors of the lines
# Store the colors of the lines
self
.
colors
=
{
"pressure"
:
colors
[
"p
ressure_plot"
],
"flow"
:
colors
[
"flow_plot
"
]}
self
.
colors
=
{
"pressure"
:
colors
[
"p
lot_pressure"
],
"flow"
:
colors
[
"plot_flow
"
]}
self
.
graph_widget
.
setContentsMargins
(
0.0
,
0.0
,
0.0
,
0.0
)
self
.
graph_widget
.
setContentsMargins
(
0.0
,
0.0
,
0.0
,
0.0
)
self
.
graph_widget
.
setBackground
(
colors
[
"page_background"
])
self
.
graph_widget
.
setBackground
(
colors
[
"page_background"
])
...
...
NativeUI/widget_library/spin_buttons_widget.py
View file @
05db8768
...
@@ -140,7 +140,6 @@ class SpinButton(QtWidgets.QFrame):
...
@@ -140,7 +140,6 @@ class SpinButton(QtWidgets.QFrame):
def
manualChanged
(
self
):
def
manualChanged
(
self
):
print
(
"manually changed"
+
self
.
label
.
text
())
"""Called when user manually makes a change. Stops value from updating and changes colour"""
"""Called when user manually makes a change. Stops value from updating and changes colour"""
self
.
manuallyUpdated
=
True
self
.
manuallyUpdated
=
True
self
.
setTextColour
(
2
)
self
.
setTextColour
(
2
)
...
...
NativeUI/widget_library/switchable_stack_widget.py
View file @
05db8768
...
@@ -125,7 +125,12 @@ class SelectorButtonWidget(QtWidgets.QPushButton):
...
@@ -125,7 +125,12 @@ class SelectorButtonWidget(QtWidgets.QPushButton):
" border:none"
" border:none"
"}"
"}"
"QPushButton[selected='1']{"
"QPushButton[selected='1']{"
" color: "
+
colors
[
"button_foreground_disabled"
]
.
name
()
+
";"
" color: "
+
colors
[
"button_foreground_highlight"
]
.
name
()
+
";"
" background-color:"
+
colors
[
"button_background_highlight"
]
.
name
()
+
";"
" border:none"
"}"
"QPushButton:disabled{"
" color:"
+
colors
[
"button_foreground_disabled"
]
.
name
()
+
";"
" background-color:"
+
colors
[
"button_background_disabled"
]
.
name
()
+
";"
" background-color:"
+
colors
[
"button_background_disabled"
]
.
name
()
+
";"
" border:none"
" border:none"
"}"
"}"
...
...
raspberry-dataserver/CommsCommon.py
View file @
05db8768
...
@@ -60,6 +60,12 @@ class CMD_TYPE(Enum):
...
@@ -60,6 +60,12 @@ class CMD_TYPE(Enum):
SET_PERSONAL
=
15
SET_PERSONAL
=
15
GET_THRESHOLD_MIN
=
16
GET_THRESHOLD_MIN
=
16
GET_THRESHOLD_MAX
=
17
GET_THRESHOLD_MAX
=
17
TEST_AUDIO_ALARM
=
18
SKIP_NEXT_CALIBRATION
=
19
DO_CALIBRATION
=
20
MUTE_ALARM
=
21
RESET_ALARM
=
22
@
unique
@
unique
...
@@ -184,6 +190,14 @@ class ALARM_CODES(Enum):
...
@@ -184,6 +190,14 @@ class ALARM_CODES(Enum):
O2_FAIL
=
23
# HP
O2_FAIL
=
23
# HP
PRESSURE_SENSOR_FAULT
=
24
# HP
PRESSURE_SENSOR_FAULT
=
24
# HP
ARDUINO_FAIL
=
25
# HP
ARDUINO_FAIL
=
25
# HP
ALARM_TEST
=
26
# HP
HIGH_VME
=
27
# MP
LOW_VME
=
28
# MP
HIGH_VMI
=
29
# MP
LOW_VMI
=
30
# MP
EXTENDED_HIGH_PRESSURE
=
31
# HP
ALARMS_COUNT
=
32
class
CMD_MAP
(
Enum
):
class
CMD_MAP
(
Enum
):
...
@@ -240,6 +254,9 @@ class PAYLOAD_TYPE(IntEnum):
...
@@ -240,6 +254,9 @@ class PAYLOAD_TYPE(IntEnum):
BATTERY
=
11
BATTERY
=
11
LOOP_STATUS
=
12
LOOP_STATUS
=
12
PERSONAL
=
13
PERSONAL
=
13
ALARM_MUTE
=
14
BAD_THRESHOLD
=
15
class
HEVVersionError
(
Exception
):
class
HEVVersionError
(
Exception
):
...
...
raspberry-dataserver/hevserver.py
View file @
05db8768
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment