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
2263ae3e
Commit
2263ae3e
authored
Jun 04, 2021
by
Tiago Sarmento
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
small changes to many files, add alarm mute
parent
fabb9426
Pipeline
#1764
failed with stages
Changes
25
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
25 changed files
with
843 additions
and
515 deletions
+843
-515
NativeUI.py
NativeUI/NativeUI.py
+71
-8
alarm_list.py
NativeUI/alarm_widgets/alarm_list.py
+7
-4
alarm_popup.py
NativeUI/alarm_widgets/alarm_popup.py
+1
-0
clinical_config.json
NativeUI/configs/clinical_config.json
+1
-1
startup_config.json
NativeUI/configs/startup_config.json
+1
-1
global_send_popup.py
NativeUI/global_widgets/global_send_popup.py
+5
-1
global_spinbox.py
NativeUI/global_widgets/global_spinbox.py
+23
-14
global_typeval_popup.py
NativeUI/global_widgets/global_typeval_popup.py
+216
-161
tab_modeswitch_button.py
NativeUI/global_widgets/tab_modeswitch_button.py
+23
-5
mode_handler.py
NativeUI/mode_widgets/mode_handler.py
+16
-10
personal_handler.py
NativeUI/mode_widgets/personal_handler.py
+54
-3
tab_modes.py
NativeUI/mode_widgets/tab_modes.py
+0
-198
tab_personal.py
NativeUI/mode_widgets/tab_personal.py
+0
-55
ui_layout.py
NativeUI/ui_layout.py
+49
-19
ui_widgets.py
NativeUI/ui_widgets.py
+7
-3
alarm_control_widget.py
NativeUI/widget_library/alarm_control_widget.py
+148
-0
line_edit_widget.py
NativeUI/widget_library/line_edit_widget.py
+35
-20
numpad_widget.py
NativeUI/widget_library/numpad_widget.py
+8
-3
page_buttons_widget.py
NativeUI/widget_library/page_buttons_widget.py
+6
-0
spin_buttons_widget.py
NativeUI/widget_library/spin_buttons_widget.py
+1
-2
hevclient.py
raspberry-backend/hevclient.py
+1
-1
CommsCommon.py
raspberry-dataserver/CommsCommon.py
+138
-0
CommsControl.py
raspberry-dataserver/CommsControl.py
+9
-0
hevclient.py
raspberry-dataserver/hevclient.py
+1
-1
hevserver.py
raspberry-dataserver/hevserver.py
+22
-5
No files found.
NativeUI/NativeUI.py
View file @
2263ae3e
...
@@ -30,6 +30,7 @@ from threading import Lock
...
@@ -30,6 +30,7 @@ from threading import Lock
import
git
import
git
from
global_widgets.global_send_popup
import
confirmPopup
,
SetConfirmPopup
from
global_widgets.global_send_popup
import
confirmPopup
,
SetConfirmPopup
from
global_widgets.tab_modeswitch_button
import
ModeswitchPopup
from
widget_library.ok_cancel_buttons_widget
import
(
from
widget_library.ok_cancel_buttons_widget
import
(
OkButtonWidget
,
OkButtonWidget
,
OkSendButtonWidget
,
OkSendButtonWidget
,
...
@@ -61,7 +62,7 @@ from mode_widgets.clinical_handler import ClinicalHandler
...
@@ -61,7 +62,7 @@ from mode_widgets.clinical_handler import ClinicalHandler
from
alarm_widgets.alarm_handler
import
AlarmHandler
from
alarm_widgets.alarm_handler
import
AlarmHandler
# from handler_library.readback_handler import ReadbackHandler
# from handler_library.readback_handler import ReadbackHandler
from
global_widgets.global_typeval_popup
import
TypeValuePopup
,
AbstractTypeValPopup
from
global_widgets.global_typeval_popup
import
AbstractTypeValPopup
from
widget_library.numpad_widget
import
NumberpadWidget
,
AlphapadWidget
from
widget_library.numpad_widget
import
NumberpadWidget
,
AlphapadWidget
logging
.
basicConfig
(
logging
.
basicConfig
(
...
@@ -118,13 +119,15 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -118,13 +119,15 @@ class NativeUI(HEVClient, QMainWindow):
# store variable to change editability of screen - implemented in screen locking
# store variable to change editability of screen - implemented in screen locking
self
.
enableState
=
True
self
.
enableState
=
True
self
.
saveStateDict
=
{}
# 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
]
# Set up available modes
# Set up available modes
self
.
modeList
=
[
"PC/AC"
,
"PC/AC-PRVC"
,
"PC-PSV"
,
"CPAP"
]
#self.modeList = ["PC/AC", "PC/AC-PRVC", "PC-PSV", "CPAP"]
self
.
modeList
=
[
"PC/AC"
,
"PC-PSV"
]
self
.
currentMode
=
self
.
modeList
[
0
]
self
.
currentMode
=
self
.
modeList
[
0
]
# Import settings from config files.
# Import settings from config files.
...
@@ -207,7 +210,9 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -207,7 +210,9 @@ class NativeUI(HEVClient, QMainWindow):
)
# TypeValuePopup(self, NumberpadWidget(self))
)
# TypeValuePopup(self, NumberpadWidget(self))
self
.
typeValPopupAlpha
=
AbstractTypeValPopup
(
self
.
typeValPopupAlpha
=
AbstractTypeValPopup
(
self
,
"alpha"
self
,
"alpha"
)
# TypeValuePopup(self, AlphapadWidget(self))
)
#self.mode_switch_popup = ModeswitchPopup(self)
# TypeValuePopup(self, AlphapadWidget(self))
# Create all of the widgets and place them in the layout.
# Create all of the widgets and place them in the layout.
self
.
widgets
=
Widgets
(
self
)
self
.
widgets
=
Widgets
(
self
)
...
@@ -230,6 +235,7 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -230,6 +235,7 @@ class NativeUI(HEVClient, QMainWindow):
self
.
typeValPopupNum
,
self
.
typeValPopupNum
,
self
.
typeValPopupAlpha
,
self
.
typeValPopupAlpha
,
self
.
messageCommandPopup
,
self
.
messageCommandPopup
,
#self.mode_switch_popup,
# self.confirmPopup,
# self.confirmPopup,
self
.
main_display
,
self
.
main_display
,
self
.
startupWidget
,
self
.
startupWidget
,
...
@@ -346,6 +352,7 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -346,6 +352,7 @@ 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
)
self
.
widgets
.
lock_button
.
PageButtonPressed
.
connect
(
self
.
toggle_editability
)
# Startup next button should send the ventilator start command.
# Startup next button should send the ventilator start command.
self
.
widgets
.
nextButton
.
pressed
.
connect
(
self
.
widgets
.
nextButton
.
pressed
.
connect
(
...
@@ -358,7 +365,7 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -358,7 +365,7 @@ class NativeUI(HEVClient, QMainWindow):
)
)
# Personal Display should update when personal info is changed.
# Personal Display should update when personal info is changed.
self
.
personal_handler
.
UpdatePersonal
Display
.
connect
(
self
.
personal_handler
.
UpdatePersonal
.
connect
(
self
.
widgets
.
personal_display
.
update_status
self
.
widgets
.
personal_display
.
update_status
)
)
...
@@ -395,8 +402,14 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -395,8 +402,14 @@ class NativeUI(HEVClient, QMainWindow):
self
.
typeValPopupNum
.
okButton
.
pressed
.
connect
(
self
.
typeValPopupNum
.
okButton
.
pressed
.
connect
(
self
.
typeValPopupNum
.
handle_ok_press
self
.
typeValPopupNum
.
handle_ok_press
)
)
self
.
typeValPopupNum
.
cancelButton
.
pressed
.
connect
(
self
.
typeValPopupNum
.
handle_cancel_press
)
self
.
typeValPopupAlpha
.
okButton
.
pressed
.
connect
(
self
.
typeValPopupAlpha
.
okButton
.
pressed
.
connect
(
self
.
typeValPopupNum
.
handle_ok_press
self
.
typeValPopupAlpha
.
handle_ok_press
)
self
.
typeValPopupAlpha
.
cancelButton
.
pressed
.
connect
(
self
.
typeValPopupAlpha
.
handle_cancel_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
...
@@ -426,6 +439,10 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -426,6 +439,10 @@ class NativeUI(HEVClient, QMainWindow):
self
.
mode_handler
.
modeSwitched
.
connect
(
self
.
mode_handler
.
refresh_button_colour
)
self
.
mode_handler
.
modeSwitched
.
connect
(
self
.
mode_handler
.
refresh_button_colour
)
# when mode is switched from modeSwitch button, other locations must respond
# when mode is switched from modeSwitch button, other locations must respond
#self.widgets.tab_modeswitch.openSwitchPopup.connect(lambda i= self.mode_switch_popup: self.display_stack.setCurrentWidget(i))
#self.mode_switch_popup.openSwitchPopup.connect(
# lambda i=self.mode_switch_popup: self.display_stack.setCurrentWidget(i))
self
.
widgets
.
tab_modeswitch
.
modeSwitched
.
connect
(
self
.
widgets
.
tab_modeswitch
.
modeSwitched
.
connect
(
lambda
i
:
self
.
set_current_mode
(
i
)
lambda
i
:
self
.
set_current_mode
(
i
)
)
)
...
@@ -521,6 +538,12 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -521,6 +538,12 @@ class NativeUI(HEVClient, QMainWindow):
)
)
self
.
messageCommandPopup
.
ExpertSend
.
connect
(
self
.
expert_handler
.
sendCommands
)
self
.
messageCommandPopup
.
ExpertSend
.
connect
(
self
.
expert_handler
.
sendCommands
)
self
.
personal_handler
.
OpenPopup
.
connect
(
self
.
messageCommandPopup
.
populatePopup
)
self
.
personal_handler
.
OpenPopup
.
connect
(
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
messageCommandPopup
)
)
self
.
messageCommandPopup
.
PersonalSend
.
connect
(
self
.
personal_handler
.
sendCommands
)
self
.
clinical_handler
.
OpenPopup
.
connect
(
self
.
messageCommandPopup
.
populatePopup
)
self
.
clinical_handler
.
OpenPopup
.
connect
(
self
.
messageCommandPopup
.
populatePopup
)
self
.
messageCommandPopup
.
ClinicalSend
.
connect
(
self
.
messageCommandPopup
.
ClinicalSend
.
connect
(
self
.
clinical_handler
.
sendCommands
self
.
clinical_handler
.
sendCommands
...
@@ -547,6 +570,32 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -547,6 +570,32 @@ class NativeUI(HEVClient, QMainWindow):
lambda
i
=
key
:
self
.
expert_handler
.
handle_manual_change
(
i
)
lambda
i
=
key
:
self
.
expert_handler
.
handle_manual_change
(
i
)
)
)
# Expert handler should respond to manual value changes
for
key
,
spin_widget
in
self
.
personal_handler
.
spinDict
.
items
():
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
key
:
self
.
personal_handler
.
handle_manual_change
(
i
)
)
for
key
,
spin_widget
in
self
.
personal_handler
.
textDict
.
items
():
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
key
:
self
.
personal_handler
.
handle_manual_change
(
i
)
)
for
widget
in
self
.
personal_handler
.
spinDict
.
values
():
self
.
personal_handler
.
UpdatePersonal
.
connect
(
widget
.
update_value
)
for
widget
in
self
.
personal_handler
.
textDict
.
values
():
self
.
personal_handler
.
UpdatePersonal
.
connect
(
widget
.
update_value
)
for
key
,
button_widget
in
self
.
personal_handler
.
buttonDict
.
items
():
if
isinstance
(
button_widget
,
OkButtonWidget
)
or
isinstance
(
button_widget
,
OkSendButtonWidget
):
button_widget
.
pressed
.
connect
(
lambda
i
=
key
:
self
.
personal_handler
.
handle_okbutton_click
(
i
)
)
elif
isinstance
(
button_widget
,
CancelButtonWidget
):
button_widget
.
pressed
.
connect
(
self
.
personal_handler
.
commandSent
)
# mode_handler should respond to ok, send, or cancel presses
# mode_handler should respond to ok, send, or cancel presses
for
key
,
button_widget
in
self
.
expert_handler
.
buttonDict
.
items
():
for
key
,
button_widget
in
self
.
expert_handler
.
buttonDict
.
items
():
if
isinstance
(
button_widget
,
OkButtonWidget
)
or
isinstance
(
if
isinstance
(
button_widget
,
OkButtonWidget
)
or
isinstance
(
...
@@ -609,6 +658,7 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -609,6 +658,7 @@ class NativeUI(HEVClient, QMainWindow):
self
.
alarm_handler
.
RemoveAlarm
.
connect
(
self
.
widgets
.
alarm_popup
.
removeAlarm
)
self
.
alarm_handler
.
RemoveAlarm
.
connect
(
self
.
widgets
.
alarm_popup
.
removeAlarm
)
self
.
alarm_handler
.
RemoveAlarm
.
connect
(
self
.
widgets
.
alarm_list
.
removeAlarm
)
self
.
alarm_handler
.
RemoveAlarm
.
connect
(
self
.
widgets
.
alarm_list
.
removeAlarm
)
self
.
widgets
.
acknowledge_button
.
pressed
.
connect
(
self
.
widgets
.
alarm_list
.
acknowledge_all
)
# Localisation needs to update widgets
# Localisation needs to update widgets
self
.
widgets
.
localisation_button
.
SetLocalisation
.
connect
(
self
.
widgets
.
localisation_button
.
SetLocalisation
.
connect
(
...
@@ -683,8 +733,18 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -683,8 +733,18 @@ class NativeUI(HEVClient, QMainWindow):
def
toggle_editability
(
self
):
def
toggle_editability
(
self
):
"""Set all widgets disabled to lock screen"""
"""Set all widgets disabled to lock screen"""
print
(
'toggling'
)
self
.
q_send_cmd
(
"DO_CALIBRATION"
,
"DO_CALIBRATIONING"
)
self
.
q_send_cmd
(
"MUTE_ALARM"
,
"TRUE"
)
#self.q_send_cmd("GENERAL", "START")
self
.
enableState
=
not
self
.
enableState
self
.
enableState
=
not
self
.
enableState
if
self
.
enableState
==
False
:
for
attribute
in
dir
(
self
.
widgets
):
widg
=
self
.
widgets
.
get_widget
(
attribute
)
if
isinstance
(
widg
,
QWidget
):
self
.
saveStateDict
[
attribute
]
=
widg
.
isEnabled
()
if
self
.
enableState
:
if
self
.
enableState
:
self
.
alt_palette
.
setColor
(
QPalette
.
Window
,
self
.
colors
[
"page_background"
])
self
.
alt_palette
.
setColor
(
QPalette
.
Window
,
self
.
colors
[
"page_background"
])
else
:
else
:
...
@@ -693,7 +753,10 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -693,7 +753,10 @@ class NativeUI(HEVClient, QMainWindow):
for
attribute
in
dir
(
self
.
widgets
):
for
attribute
in
dir
(
self
.
widgets
):
widg
=
self
.
widgets
.
get_widget
(
attribute
)
widg
=
self
.
widgets
.
get_widget
(
attribute
)
if
isinstance
(
widg
,
QWidget
):
if
isinstance
(
widg
,
QWidget
):
widg
.
setEnabled
(
self
.
enableState
)
if
self
.
enableState
:
widg
.
setEnabled
(
self
.
saveStateDict
[
attribute
])
else
:
widg
.
setEnabled
(
self
.
enableState
)
self
.
widgets
.
lock_button
.
setEnabled
(
True
)
self
.
widgets
.
lock_button
.
setEnabled
(
True
)
@
Slot
(
str
)
@
Slot
(
str
)
...
@@ -708,7 +771,7 @@ class NativeUI(HEVClient, QMainWindow):
...
@@ -708,7 +771,7 @@ class NativeUI(HEVClient, QMainWindow):
return
0
return
0
@
Slot
(
str
,
str
,
float
)
@
Slot
(
str
,
str
,
float
)
def
q_send_cmd
(
self
,
cmdtype
:
str
,
cmd
:
str
,
param
:
float
=
None
)
->
int
:
def
q_send_cmd
(
self
,
cmdtype
:
str
,
cmd
:
str
=
None
,
param
:
float
=
None
)
->
int
:
"""
"""
Send command to hevserver via socket.
Send command to hevserver via socket.
"""
"""
...
...
NativeUI/alarm_widgets/alarm_list.py
View file @
2263ae3e
...
@@ -21,7 +21,7 @@ from datetime import datetime
...
@@ -21,7 +21,7 @@ from datetime import datetime
class
AlarmList
(
QtWidgets
.
QListWidget
):
class
AlarmList
(
QtWidgets
.
QListWidget
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
AlarmList
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
AlarmList
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
labelList
=
[]
self
.
labelList
=
[]
self
.
setSizePolicy
(
self
.
setSizePolicy
(
QtWidgets
.
QSizePolicy
.
Expanding
,
QtWidgets
.
QSizePolicy
.
Expanding
QtWidgets
.
QSizePolicy
.
Expanding
,
QtWidgets
.
QSizePolicy
.
Expanding
...
@@ -39,9 +39,12 @@ class AlarmList(QtWidgets.QListWidget):
...
@@ -39,9 +39,12 @@ class AlarmList(QtWidgets.QListWidget):
self
.
addItem
(
newItem
)
self
.
addItem
(
newItem
)
def
acknowledge_all
(
self
):
def
acknowledge_all
(
self
):
for
x
in
range
(
self
.
count
()
-
1
):
# print('acknowledging')
self
.
item
(
x
)
.
setText
(
"acknowledgedAlarm"
)
# for x in range(self.count() - 1):
self
.
item
(
x
)
.
setIcon
(
self
.
regularBell
)
# self.item(x).setText("acknowledgedAlarm")
# self.item(x).setIcon(self.regularBell)
self
.
NativeUI
.
q_send_cmd
(
'RESET_ALARM'
,
'TRUE'
)
def
addAlarm
(
self
,
abstractAlarm
):
def
addAlarm
(
self
,
abstractAlarm
):
timestamp
=
str
(
abstractAlarm
.
startTime
)[:
-
3
]
timestamp
=
str
(
abstractAlarm
.
startTime
)[:
-
3
]
...
...
NativeUI/alarm_widgets/alarm_popup.py
View file @
2263ae3e
...
@@ -70,6 +70,7 @@ class AlarmWidget(QtWidgets.QWidget):
...
@@ -70,6 +70,7 @@ class AlarmWidget(QtWidgets.QWidget):
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
()
self
.
NativeUI
.
widgets
.
alarms_page
.
setTab
(
self
.
NativeUI
.
widgets
.
alarms_page
.
button_list
[
0
])
return
False
return
False
def
get_priority
(
self
):
def
get_priority
(
self
):
...
...
NativeUI/configs/clinical_config.json
View file @
2263ae3e
...
@@ -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
,
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
]],
[[
"FIO2"
,
"%"
,
"HIGH_FIO2"
,
"SET_THRESHOLD_MIN"
,
"HIGH_FIO2"
,
-10
,
0
,
-5
,
1
,
0
],[
"Percentage O2"
,
""
,
"fiO2_percent"
,
"SET_TARGET_CURRENT"
,
"FIO2_PERCENT"
,
21
,
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/startup_config.json
View file @
2263ae3e
{
"calibration"
:
{
"label"
:
"calibration"
,
"last_performed"
:
162
1526657
,
"cmd_code"
:
"calib_rate"
},
"leak_test"
:
{
"label"
:
"Leak Test"
,
"last_performed"
:
1621526657
,
"cmd_code"
:
"leak_test"
},
"maintenance"
:
{
"label"
:
"maintenance"
,
"last_performed"
:
1621526658
,
"cmd_code"
:
"main_tenance"
}}
{
"calibration"
:
{
"label"
:
"calibration"
,
"last_performed"
:
162
2683719
,
"cmd_code"
:
"calib_rate"
},
"leak_test"
:
{
"label"
:
"Leak Test"
,
"last_performed"
:
1622683720
,
"cmd_code"
:
"leak_test"
},
"maintenance"
:
{
"label"
:
"maintenance"
,
"last_performed"
:
1622683721
,
"cmd_code"
:
"main_tenance"
}}
\ No newline at end of file
NativeUI/global_widgets/global_send_popup.py
View file @
2263ae3e
...
@@ -140,12 +140,15 @@ class confirmWidget(QtWidgets.QWidget):
...
@@ -140,12 +140,15 @@ class confirmWidget(QtWidgets.QWidget):
# create timer to handle timeout
# create timer to handle timeout
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
10
000
)
self
.
timer
.
setInterval
(
2
000
)
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"""
"""Widget should expire after a defined time"""
print
(
'confirming timeout lets go'
)
print
(
self
.
parent
()
.
confirmDict
.
keys
())
print
(
self
.
confirmMessage
.
replace
(
"/"
,
"_"
)
.
replace
(
"-"
,
"_"
))
self
.
parent
()
.
confirmDict
.
pop
(
self
.
parent
()
.
confirmDict
.
pop
(
self
.
confirmMessage
.
replace
(
"/"
,
"_"
)
.
replace
(
"-"
,
"_"
)
# - and / are not used in dictionary keys
self
.
confirmMessage
.
replace
(
"/"
,
"_"
)
.
replace
(
"-"
,
"_"
)
# - and / are not used in dictionary keys
)
)
...
@@ -180,6 +183,7 @@ class confirmPopup(QtWidgets.QDialog):
...
@@ -180,6 +183,7 @@ class confirmPopup(QtWidgets.QDialog):
self
.
timer
.
timeout
.
connect
(
self
.
adjustSize
)
# container needs to adjust to a new number of confirmWidgets
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
):
"""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
(
...
...
NativeUI/global_widgets/global_spinbox.py
View file @
2263ae3e
...
@@ -13,7 +13,7 @@ __email__ = "tiago.sarmento@stfc.ac.uk"
...
@@ -13,7 +13,7 @@ __email__ = "tiago.sarmento@stfc.ac.uk"
__status__
=
"Prototype"
__status__
=
"Prototype"
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
from
global_widgets.global_typeval_popup
import
TypeValuePopup
#
from global_widgets.global_typeval_popup import TypeValuePopup
from
CommsCommon
import
ReadbackFormat
from
CommsCommon
import
ReadbackFormat
...
@@ -36,6 +36,7 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
...
@@ -36,6 +36,7 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
self
.
setSingleStep
(
step
)
self
.
setSingleStep
(
step
)
self
.
setDecimals
(
decPlaces
)
self
.
setDecimals
(
decPlaces
)
self
.
setValue
(
initVal
)
self
.
setValue
(
initVal
)
self
.
setButtonSymbols
(
QtWidgets
.
QAbstractSpinBox
.
NoButtons
)
self
.
NativeUI
=
NativeUI
self
.
NativeUI
=
NativeUI
#self.populateVals = [label_text, min, max, initVal, step, decPlaces]
#self.populateVals = [label_text, min, max, initVal, step, decPlaces]
self
.
popUp
=
popup
# TypeValuePopup(NativeUI, label_text, min, max, initVal, step, decPlaces)
self
.
popUp
=
popup
# TypeValuePopup(NativeUI, label_text, min, max, initVal, step, decPlaces)
...
@@ -160,18 +161,14 @@ class labelledSpin(QtWidgets.QWidget):
...
@@ -160,18 +161,14 @@ class labelledSpin(QtWidgets.QWidget):
self
.
simpleSpin
.
setFont
(
NativeUI
.
text_font
)
self
.
simpleSpin
.
setFont
(
NativeUI
.
text_font
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
self
.
simpleSpin
.
setProperty
(
"bgColour"
,
"1"
)
self
.
simpleSpin
.
setProperty
(
"bgColour"
,
"1"
)
self
.
simpleSpin
.
setButtonSymbols
(
QtWidgets
.
QAbstractSpinBox
.
ButtonSymbols
.
PlusMinus
)
self
.
simpleSpin
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
simpleSpin
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
if
self
.
cmd_type
==
""
:
if
self
.
cmd_type
==
""
:
self
.
simpleSpin
.
setReadOnly
(
True
)
self
.
simpleSpin
.
setReadOnly
(
True
)
# self.simpleSpin.setProperty("bgColour", "1")
# self.simpleSpin.setProperty("textColour", "2")
self
.
simpleSpin
.
setEditability
(
False
)
self
.
simpleSpin
.
setEditability
(
False
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
self
.
unitLabel
=
QtWidgets
.
QLabel
(
self
.
units
)
self
.
unitLabel
=
QtWidgets
.
QLabel
(
self
.
units
)
self
.
unitLabel
.
setFont
(
NativeUI
.
text_font
)
self
.
unitLabel
.
setStyleSheet
(
textStyle
)
self
.
unitLabel
.
setStyleSheet
(
textStyle
)
self
.
unitLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignLeft
|
QtCore
.
Qt
.
AlignVCenter
)
self
.
unitLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignLeft
|
QtCore
.
Qt
.
AlignVCenter
)
...
@@ -200,7 +197,12 @@ class labelledSpin(QtWidgets.QWidget):
...
@@ -200,7 +197,12 @@ class labelledSpin(QtWidgets.QWidget):
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
return
0
return
0
def
isEnabled
(
self
,
*
args
,
**
kwargs
):
"""Override isEnabled to return value of base spinbox"""
return
self
.
simpleSpin
.
isEnabled
()
def
setEnabled
(
self
,
bool
):
def
setEnabled
(
self
,
bool
):
"""Override isEnabled to set value of base spinbox and modify colour"""
self
.
simpleSpin
.
setEnabled
(
bool
)
self
.
simpleSpin
.
setEnabled
(
bool
)
self
.
simpleSpin
.
setProperty
(
"bgColour"
,
str
(
int
(
bool
)))
self
.
simpleSpin
.
setProperty
(
"bgColour"
,
str
(
int
(
bool
)))
self
.
simpleSpin
.
setProperty
(
"textColour"
,
str
(
int
(
bool
)))
self
.
simpleSpin
.
setProperty
(
"textColour"
,
str
(
int
(
bool
)))
...
@@ -219,15 +221,18 @@ class labelledSpin(QtWidgets.QWidget):
...
@@ -219,15 +221,18 @@ class labelledSpin(QtWidgets.QWidget):
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
def
insertWidget
(
self
,
widget
,
position
):
def
insertWidget
(
self
,
widget
):
"""Insert a widget with the nameLabel. Used to put a radio button in specific spin boxes"""
self
.
insertedWidget
=
widget
self
.
insertedWidget
=
widget
self
.
widgetList
.
insert
(
position
,
widget
)
self
.
insertedWidget
.
setFixedWidth
(
30
)
for
i
in
reversed
(
range
(
self
.
layout
.
count
())):
mini_hlayout
=
QtWidgets
.
QHBoxLayout
()
# create new layout to ensure label and new widget aligned as one
self
.
layout
.
itemAt
(
i
)
.
widget
()
.
setParent
(
None
)
mini_hlayout
.
addWidget
(
self
.
nameLabel
)
# newLayout = QtWidgets.QHBoxLayout()
mini_hlayout
.
addWidget
(
self
.
insertedWidget
)
for
widget
in
self
.
widgetList
:
self
.
layout
.
addLayout
(
mini_hlayout
)
self
.
layout
.
addWidget
(
widget
)
self
.
layout
.
addWidget
(
self
.
simpleSpin
)
self
.
layout
.
addWidget
(
self
.
unitLabel
)
self
.
setLayout
(
self
.
layout
)
self
.
setLayout
(
self
.
layout
)
return
0
def
get_value
(
self
):
def
get_value
(
self
):
return
self
.
simpleSpin
.
value
()
return
self
.
simpleSpin
.
value
()
...
@@ -239,13 +244,17 @@ class labelledSpin(QtWidgets.QWidget):
...
@@ -239,13 +244,17 @@ class labelledSpin(QtWidgets.QWidget):
return
0
return
0
def
set_maximum
(
self
,
max
):
def
set_maximum
(
self
,
max
):
"""Update maximum and correct existing value"""
self
.
max
=
max
self
.
max
=
max
if
self
.
simpleSpin
.
value
()
>
self
.
max
:
if
self
.
simpleSpin
.
value
()
>
self
.
max
:
self
.
simpleSpin
.
set_value
(
max
)
self
.
simpleSpin
.
set_value
(
max
)
self
.
simpleSpin
.
setRange
(
self
.
min
,
self
.
max
)
self
.
simpleSpin
.
setRange
(
self
.
min
,
self
.
max
)
return
0
def
set_minimum
(
self
,
min
):
def
set_minimum
(
self
,
min
):
"""Update minimimum and correct existing value"""
self
.
min
=
min
self
.
min
=
min
if
self
.
simpleSpin
.
value
()
<
self
.
min
:
if
self
.
simpleSpin
.
value
()
<
self
.
min
:
self
.
simpleSpin
.
stepBy
(
self
.
min
-
self
.
simpleSpin
.
value
())
self
.
simpleSpin
.
stepBy
(
self
.
min
-
self
.
simpleSpin
.
value
())
self
.
simpleSpin
.
setRange
(
self
.
min
,
self
.
max
)
self
.
simpleSpin
.
setRange
(
self
.
min
,
self
.
max
)
\ No newline at end of file
return
0
\ No newline at end of file
NativeUI/global_widgets/global_typeval_popup.py
View file @
2263ae3e
This diff is collapsed.
Click to expand it.
NativeUI/global_widgets/tab_modeswitch_button.py
View file @
2263ae3e
...
@@ -56,7 +56,7 @@ class TabModeswitchButton(QtWidgets.QWidget):
...
@@ -56,7 +56,7 @@ class TabModeswitchButton(QtWidgets.QWidget):
def
switch_button_pressed
(
self
):
def
switch_button_pressed
(
self
):
"""Button pressed, open popup, ensure correct mode is selected in popup."""
"""Button pressed, open popup, ensure correct mode is selected in popup."""
if
self
.
mode_popup
==
False
:
if
self
.
mode_popup
==
False
:
self
.
mode_popup
=
m
odeswitchPopup
(
self
.
NativeUI
)
self
.
mode_popup
=
M
odeswitchPopup
(
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
()
...
@@ -72,11 +72,11 @@ class TabModeswitchButton(QtWidgets.QWidget):
...
@@ -72,11 +72,11 @@ class TabModeswitchButton(QtWidgets.QWidget):
return
0
return
0
class
m
odeswitchPopup
(
QtWidgets
.
QWidget
):
class
M
odeswitchPopup
(
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
"""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."""
and to navigate to mode setting page to edit those values."""
super
(
m
odeswitchPopup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
M
odeswitchPopup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
NativeUI
=
NativeUI
with
open
(
"NativeUI/configs/mode_config.json"
)
as
json_file
:
with
open
(
"NativeUI/configs/mode_config.json"
)
as
json_file
:
...
@@ -91,6 +91,7 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -91,6 +91,7 @@ class modeswitchPopup(QtWidgets.QWidget):
for
mode
in
modeList
:
for
mode
in
modeList
:
button
=
QtWidgets
.
QRadioButton
(
mode
)
button
=
QtWidgets
.
QRadioButton
(
mode
)
goto_button
=
QtWidgets
.
QPushButton
(
mode
)
goto_button
=
QtWidgets
.
QPushButton
(
mode
)
goto_button
.
setFont
(
self
.
NativeUI
.
text_font
)
goto_button
.
pressed
.
connect
(
lambda
j
=
mode
:
self
.
goto_pressed
(
j
))
goto_button
.
pressed
.
connect
(
lambda
j
=
mode
:
self
.
goto_pressed
(
j
))
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
.
addWidget
(
button
)
hlayout
.
addWidget
(
button
)
...
@@ -147,10 +148,10 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -147,10 +148,10 @@ class modeswitchPopup(QtWidgets.QWidget):
## Ok Cancel Buttons
## Ok Cancel Buttons
hbuttonlayout
=
QtWidgets
.
QHBoxLayout
()
hbuttonlayout
=
QtWidgets
.
QHBoxLayout
()
self
.
okbutton
=
OkButtonWidget
(
NativeUI
)
self
.
okbutton
=
OkButtonWidget
(
NativeUI
)
self
.
okbutton
.
set
Enabled
(
True
)
self
.
okbutton
.
set
Colour
(
'1'
)
self
.
okbutton
.
pressed
.
connect
(
self
.
ok_button_pressed
)
self
.
okbutton
.
pressed
.
connect
(
self
.
ok_button_pressed
)
self
.
cancelbutton
=
CancelButtonWidget
(
NativeUI
)
self
.
cancelbutton
=
CancelButtonWidget
(
NativeUI
)
self
.
cancelbutton
.
set
Enabled
(
True
)
self
.
cancelbutton
.
set
Colour
(
'1'
)
self
.
cancelbutton
.
pressed
.
connect
(
self
.
cancel_button_pressed
)
self
.
cancelbutton
.
pressed
.
connect
(
self
.
cancel_button_pressed
)
hbuttonlayout
.
addWidget
(
self
.
okbutton
)
hbuttonlayout
.
addWidget
(
self
.
okbutton
)
hbuttonlayout
.
addWidget
(
self
.
cancelbutton
)
hbuttonlayout
.
addWidget
(
self
.
cancelbutton
)
...
@@ -178,6 +179,8 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -178,6 +179,8 @@ class modeswitchPopup(QtWidgets.QWidget):
"color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
";"
"color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
";"
"font: 16pt bold;"
"font: 16pt bold;"
)
)
self
.
location_on_window
()
# self.radioButtons[self.NativeUI.currentMode].click()
# self.radioButtons[self.NativeUI.currentMode].click()
def
goto_pressed
(
self
,
mode
):
def
goto_pressed
(
self
,
mode
):
...
@@ -187,6 +190,9 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -187,6 +190,9 @@ class modeswitchPopup(QtWidgets.QWidget):
)
)
self
.
NativeUI
.
widgets
.
page_buttons
.
set_pressed
([
"modes_button"
])
self
.
NativeUI
.
widgets
.
page_buttons
.
set_pressed
([
"modes_button"
])
# Ensure mode settings are shown, not personal settings
self
.
NativeUI
.
widgets
.
modes_page
.
setTab
(
self
.
NativeUI
.
widgets
.
modes_page
.
button_list
[
0
])
# Switch to the specific mode tab
# Switch to the specific mode tab
for
button
in
self
.
NativeUI
.
widgets
.
modes_page
.
widget_list
[
for
button
in
self
.
NativeUI
.
widgets
.
modes_page
.
widget_list
[
0
0
...
@@ -196,6 +202,7 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -196,6 +202,7 @@ class modeswitchPopup(QtWidgets.QWidget):
# Close the popup
# Close the popup
self
.
close
()
self
.
close
()
return
0
def
update_settings_data
(
self
,
button
):
def
update_settings_data
(
self
,
button
):
"""Respond to button press and update labels in modeswitch popup"""
"""Respond to button press and update labels in modeswitch popup"""
...
@@ -210,6 +217,7 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -210,6 +217,7 @@ class modeswitchPopup(QtWidgets.QWidget):
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
)))
return
0
def
ok_button_pressed
(
self
):
def
ok_button_pressed
(
self
):
"""Switch to selected mode"""
"""Switch to selected mode"""
...
@@ -231,3 +239,13 @@ class modeswitchPopup(QtWidgets.QWidget):
...
@@ -231,3 +239,13 @@ class modeswitchPopup(QtWidgets.QWidget):
def
update_mode
(
self
,
mode
):
def
update_mode
(
self
,
mode
):
"""When mode is changed the popup radio buttons should show the new 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
()
return
0
def
location_on_window
(
self
):
"""Position the popup as defined here"""
screen
=
QtWidgets
.
QDesktopWidget
()
.
screenGeometry
()
x
=
screen
.
width
()
-
screen
.
width
()
/
2
-
self
.
width
()
/
2
y
=
screen
.
height
()
/
2
#+ self.height()/2# - widget.height()
self
.
move
(
x
,
y
)
return
0
NativeUI/mode_widgets/mode_handler.py
View file @
2263ae3e
...
@@ -25,7 +25,7 @@ class ModeHandler(PayloadHandler):
...
@@ -25,7 +25,7 @@ class ModeHandler(PayloadHandler):
self
.
commandList
=
[]
self
.
commandList
=
[]
self
.
mainSpinDict
=
{}
self
.
mainSpinDict
=
{}
self
.
mainButtonDict
=
{}
self
.
mainButtonDict
=
{}
self
.
modeList
=
[
"PC/AC"
,
"PC/AC-PRVC"
,
"PC-PSV"
,
"CPAP"
,
'CURRENT'
]
self
.
modeList
=
self
.
NativeUI
.
modeList
#
["PC/AC", "PC/AC-PRVC", "PC-PSV", "CPAP", 'CURRENT']
self
.
manuallyUpdatedBoolDict
=
{
mode
:
False
for
mode
in
self
.
modeList
}
self
.
manuallyUpdatedBoolDict
=
{
mode
:
False
for
mode
in
self
.
modeList
}
self
.
mainManuallyUpdated
=
False
self
.
mainManuallyUpdated
=
False
self
.
activeMode
=
self
.
modeList
[
0
]
self
.
activeMode
=
self
.
modeList
[
0
]
...
@@ -35,7 +35,7 @@ class ModeHandler(PayloadHandler):
...
@@ -35,7 +35,7 @@ class ModeHandler(PayloadHandler):
self
.
relevantKeys
=
[
setting
[
2
]
for
setting
in
modeDict
[
'settings'
]]
self
.
relevantKeys
=
[
setting
[
2
]
for
setting
in
modeDict
[
'settings'
]]
def
add_widget
(
self
,
widget
,
key
:
str
):
def
add_widget
(
self
,
widget
:
QtWidgets
.
QWidget
,
key
:
str
):
if
isinstance
(
widget
,
labelledSpin
):
if
isinstance
(
widget
,
labelledSpin
):
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
):
...
@@ -47,6 +47,8 @@ class ModeHandler(PayloadHandler):
...
@@ -47,6 +47,8 @@ class ModeHandler(PayloadHandler):
self
.
radioDict
[
key
]
=
widget
self
.
radioDict
[
key
]
=
widget
if
isinstance
(
widget
,
SpinButton
):
if
isinstance
(
widget
,
SpinButton
):
self
.
mainSpinDict
[
key
]
=
widget
self
.
mainSpinDict
[
key
]
=
widget
if
isinstance
(
widget
,
QtWidgets
.
QStackedWidget
):
self
.
stack
=
widget
def
active_payload
(
self
,
*
args
)
->
int
:
def
active_payload
(
self
,
*
args
)
->
int
:
target_data
=
self
.
get_db
()
target_data
=
self
.
get_db
()
...
@@ -61,7 +63,7 @@ class ModeHandler(PayloadHandler):
...
@@ -61,7 +63,7 @@ class ModeHandler(PayloadHandler):
return
0
return
0
def
handle_okbutton_click
(
self
,
key
):
def
handle_okbutton_click
(
self
,
key
:
str
):
mode
=
self
.
get_mode
(
key
)
mode
=
self
.
get_mode
(
key
)
message
,
command
=
[],
[]
message
,
command
=
[],
[]
for
widget
in
self
.
spinDict
:
for
widget
in
self
.
spinDict
:
...
@@ -116,7 +118,7 @@ class ModeHandler(PayloadHandler):
...
@@ -116,7 +118,7 @@ class ModeHandler(PayloadHandler):
self
.
commandSent
()
self
.
commandSent
()
return
0
return
0
def
handle_cancel_pressed
(
self
,
buttonMode
):
def
handle_cancel_pressed
(
self
,
buttonMode
:
str
):
for
widget
in
self
.
spinDict
:
for
widget
in
self
.
spinDict
:
if
buttonMode
in
widget
:
if
buttonMode
in
widget
:
self
.
spinDict
[
widget
]
.
manuallyUpdated
=
False
self
.
spinDict
[
widget
]
.
manuallyUpdated
=
False
...
@@ -148,15 +150,16 @@ class ModeHandler(PayloadHandler):
...
@@ -148,15 +150,16 @@ class ModeHandler(PayloadHandler):
self
.
refresh_button_colour
()
self
.
refresh_button_colour
()
self
.
refresh_main_button_colour
()
self
.
refresh_main_button_colour
()
def
handle_radio_toggled
(
self
,
radioButtonState
,
radioKey
):
def
handle_radio_toggled
(
self
,
radioButtonState
:
bool
,
radioKey
:
str
):
"""
TODO Docstring
"""
"""
On radio toggle enable/disable corresponding spin box. Also modify the values shown on the main page
"""
mode
=
self
.
get_mode
(
radioKey
)
mode
=
self
.
get_mode
(
radioKey
)
spinKey
=
radioKey
.
replace
(
'radio'
,
'spin'
)
spinKey
=
radioKey
.
replace
(
'radio'
,
'spin'
)
spinBox
=
self
.
spinDict
[
spinKey
]
spinBox
=
self
.
spinDict
[
spinKey
]
spinBox
.
setEnabled
(
radioButtonState
)
spinBox
.
setEnabled
(
radioButtonState
)
if
mode
==
self
.
NativeUI
.
currentMode
and
radioButtonState
:
if
mode
==
self
.
NativeUI
.
currentMode
:
mainKey
=
spinKey
.
replace
(
mode
+
'_'
,
''
)
.
replace
(
'spin'
,
'CURRENT'
)
self
.
settingToggle
.
emit
(
spinBox
.
label
)
self
.
stack
.
setCurrentWidget
(
self
.
mainSpinDict
[
mainKey
])
return
0
def
refresh_button_colour
(
self
):
def
refresh_button_colour
(
self
):
self
.
manuallyUpdatedBoolDict
=
{
mode
:
False
for
mode
in
self
.
modeList
}
self
.
manuallyUpdatedBoolDict
=
{
mode
:
False
for
mode
in
self
.
modeList
}
...
@@ -171,7 +174,9 @@ class ModeHandler(PayloadHandler):
...
@@ -171,7 +174,9 @@ class ModeHandler(PayloadHandler):
else
:
else
:
self
.
buttonDict
[
button
]
.
setColour
(
str
(
int
(
self
.
manuallyUpdatedBoolDict
[
mode
])))
self
.
buttonDict
[
button
]
.
setColour
(
str
(
int
(
self
.
manuallyUpdatedBoolDict
[
mode
])))
def
propagate_modevalchange
(
self
,
widget
):
def
propagate_modevalchange
(
self
,
widget
:
QtWidgets
.
QWidget
):
"""Called when a value is changed in clinical limits page. Ensures all spin boxes representing the same values
actually display the same values when user edits. """
for
spin
in
self
.
mainSpinDict
.
values
():
for
spin
in
self
.
mainSpinDict
.
values
():
if
spin
.
tag
==
widget
.
tag
:
if
spin
.
tag
==
widget
.
tag
:
if
spin
.
get_value
()
!=
widget
.
get_value
():
if
spin
.
get_value
()
!=
widget
.
get_value
():
...
@@ -191,6 +196,7 @@ class ModeHandler(PayloadHandler):
...
@@ -191,6 +196,7 @@ class ModeHandler(PayloadHandler):
self
.
mainButtonDict
[
button
]
.
setColour
(
str
(
int
(
self
.
manuallyUpdatedBoolDict
[
'CURRENT'
])))
self
.
mainButtonDict
[
button
]
.
setColour
(
str
(
int
(
self
.
manuallyUpdatedBoolDict
[
'CURRENT'
])))
def
get_mode
(
self
,
key
:
str
):
def
get_mode
(
self
,
key
:
str
):
"""Get mode from the widget's corresponding key."""
for
mode
in
self
.
modeList
:
for
mode
in
self
.
modeList
:
if
mode
in
key
:
if
mode
in
key
:
return
mode
return
mode
NativeUI/mode_widgets/personal_handler.py
View file @
2263ae3e
...
@@ -8,7 +8,8 @@ from PySide2 import QtWidgets, QtGui, QtCore
...
@@ -8,7 +8,8 @@ from PySide2 import QtWidgets, QtGui, QtCore
class
PersonalHandler
(
PayloadHandler
):
# chose QWidget over QDialog family because easier to modify
class
PersonalHandler
(
PayloadHandler
):
# chose QWidget over QDialog family because easier to modify
UpdatePersonalDisplay
=
Signal
(
dict
)
UpdatePersonal
=
Signal
(
dict
)
OpenPopup
=
QtCore
.
Signal
(
PayloadHandler
,
list
)
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
()
.
__init__
([
'PERSONAL'
],
*
args
,
**
kwargs
)
super
()
.
__init__
([
'PERSONAL'
],
*
args
,
**
kwargs
)
...
@@ -34,5 +35,55 @@ class PersonalHandler(PayloadHandler): # chose QWidget over QDialog family beca
...
@@ -34,5 +35,55 @@ class PersonalHandler(PayloadHandler): # chose QWidget over QDialog family beca
outdict
=
{}
outdict
=
{}
for
key
in
[
"name"
,
"patient_id"
,
"age"
,
"sex"
,
"height"
,
"weight"
]:
for
key
in
[
"name"
,
"patient_id"
,
"age"
,
"sex"
,
"height"
,
"weight"
]:
outdict
[
key
]
=
current_data
[
key
]
outdict
[
key
]
=
current_data
[
key
]
self
.
UpdatePersonalDisplay
.
emit
(
outdict
)
self
.
UpdatePersonal
.
emit
(
outdict
)
return
0
return
0
\ No newline at end of file
def
handle_okbutton_click
(
self
,
key
):
message
,
command
=
[],
[]
for
key
,
widget
in
dict
(
self
.
spinDict
,
**
self
.
textDict
)
.
items
():
if
widget
.
manuallyUpdated
:
setVal
=
widget
.
get_value
()
if
isinstance
(
setVal
,
float
)
or
isinstance
(
setVal
,
int
):
setVal
=
round
(
setVal
,
widget
.
decPlaces
)
message
.
append
(
"set"
+
key
+
" to "
+
str
(
setVal
))
command
.
append
(
[
widget
.
cmd_type
,
widget
.
cmd_code
,
setVal
,
]
)
print
(
command
)
self
.
commandList
=
command
if
'send'
in
key
:
self
.
sendCommands
()
else
:
print
(
'open popup please'
)
self
.
OpenPopup
.
emit
(
self
,
message
)
def
sendCommands
(
self
):
if
self
.
commandList
==
[]:
a
=
1
else
:
for
command
in
self
.
commandList
:
self
.
NativeUI
.
q_send_cmd
(
*
command
)
self
.
commandSent
()
return
0
def
commandSent
(
self
):
self
.
commandList
=
[]
for
widget
in
dict
(
self
.
spinDict
,
**
self
.
textDict
)
.
values
():
widget
.
manuallyUpdated
=
False
self
.
refresh_button_colour
()
def
handle_manual_change
(
self
,
changed_spin_key
):
self
.
refresh_button_colour
()
def
refresh_button_colour
(
self
):
self
.
manuallyUpdated
=
False
for
key
,
widget
in
dict
(
self
.
spinDict
,
**
self
.
textDict
)
.
items
():
self
.
manuallyUpdated
=
self
.
manuallyUpdated
or
widget
.
manuallyUpdated
for
button
in
self
.
buttonDict
:
self
.
buttonDict
[
button
]
.
setColour
(
str
(
int
(
self
.
manuallyUpdated
)))
\ No newline at end of file
NativeUI/mode_widgets/tab_modes.py
deleted
100644 → 0
View file @
fabb9426
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
from
global_widgets.global_select_button
import
selectorButton
# from global_widgets.global_spinbox import signallingSpinBox
from
global_widgets.template_main_pages
import
TemplateMainPages
from
global_widgets.template_set_values
import
TemplateSetValues
class
TabModes
(
TemplateMainPages
):
# chose QWidget over QDialog family because easier to modify
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
TabModes
,
self
)
.
__init__
(
NativeUI
,
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
settingsList
=
[
[
"Respiratory Rate"
,
"/min"
,
"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"
],
]
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
.
setSpacing
(
0
)
self
.
pcacButton
=
selectorButton
(
NativeUI
,
"PC/AC"
)
self
.
pcacButton
.
setProperty
(
"selected"
,
"1"
)
self
.
pcacButton
.
style
()
.
polish
(
self
.
pcacButton
)
self
.
pcacEnable
=
[
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
]
self
.
pcacVals
=
[
1
,
2
,
3
,
4
,
5
,
6
,
7
,
8
]
self
.
pcacPage
=
TemplateSetValues
(
NativeUI
)
self
.
prvcButton
=
selectorButton
(
NativeUI
,
"PC/AC-PRVC"
)
self
.
prvcEnable
=
[
1
,
1
,
0
,
1
,
0
,
1
,
1
,
1
]
self
.
prvcVals
=
[
2
,
3
,
4
,
5
,
6
,
7
,
8
,
9
]
self
.
prvcPage
=
TemplateSetValues
(
NativeUI
)
self
.
psvButton
=
selectorButton
(
NativeUI
,
"PC-PSV"
)
self
.
psvEnable
=
[
1
,
1
,
0
,
1
,
0
,
1
,
0
,
1
]
self
.
psvVals
=
[
3
,
4
,
5
,
6
,
7
,
8
,
9
,
1
]
self
.
psvPage
=
TemplateSetValues
(
NativeUI
)
self
.
cpapButton
=
selectorButton
(
NativeUI
,
"CPAP"
)
self
.
cpapEnable
=
[
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
]
self
.
cpapVals
=
[
4
,
5
,
6
,
7
,
8
,
9
,
1
,
2
]
self
.
cpapPage
=
TemplateSetValues
(
NativeUI
)
self
.
buttonWidgets
=
[
self
.
pcacButton
,
self
.
prvcButton
,
self
.
psvButton
,
self
.
cpapButton
,
]
enableList
=
[
self
.
pcacEnable
,
self
.
prvcEnable
,
self
.
psvEnable
,
self
.
cpapEnable
]
self
.
tabsDict
=
{
'PC/AC'
:
self
.
pcacPage
,
'PC/AC-PRVC'
:
self
.
prvcPage
,
'PC-PSV'
:
self
.
psvPage
,
'CPAP'
:
self
.
cpapPage
}
self
.
valsList
=
[
self
.
pcacVals
,
self
.
prvcVals
,
self
.
psvVals
,
self
.
cpapVals
]
self
.
modeList
=
self
.
NativeUI
.
modeList
self
.
spinDict
=
{}
for
tab
,
mode
,
enable
,
vals
in
zip
(
self
.
tabsDict
.
values
(),
self
.
modeList
,
enableList
,
self
.
valsList
):
#mode = mode.replace("/", "_")
#mode = mode.replace("-", "_")
tempSettingsList
=
[
[
target
.
replace
(
"SET_TARGET_"
,
"SET_TARGET_"
+
mode
.
replace
(
"/"
,
"_"
)
.
replace
(
"-"
,
"_"
))
for
target
in
spinInfo
]
for
spinInfo
in
self
.
settingsList
]
tab
.
addSpinSingleCol
(
tempSettingsList
)
tab
.
mode
=
mode
tab
.
buttonGroup
=
QtWidgets
.
QButtonGroup
()
for
labelledSpin
in
tab
.
spinDict
:
if
tab
.
spinDict
[
labelledSpin
]
.
label
==
"Inhale Time"
:
tab
.
radioButtonTime
=
QtWidgets
.
QRadioButton
()
tab
.
radioButtonTime
.
setChecked
(
bool
(
enable
[
1
]))
tab
.
radioButtonTime
.
toggled
.
connect
(
lambda
i
=
tab
.
radioButtonTime
,
j
=
tab
.
spinDict
[
labelledSpin
],
k
=
tab
.
mode
:
self
.
radioPressed
(
i
,
j
,
k
)
)
tab
.
spinDict
[
labelledSpin
]
.
insertWidget
(
tab
.
radioButtonTime
,
1
)
tab
.
buttonGroup
.
addButton
(
tab
.
radioButtonTime
)
if
tab
.
spinDict
[
labelledSpin
]
.
label
==
"IE Ratio"
:
tab
.
radioButtonRat
=
QtWidgets
.
QRadioButton
()
tab
.
radioButtonRat
.
setChecked
(
bool
(
enable
[
2
]))
tab
.
radioButtonRat
.
toggled
.
connect
(
lambda
i
=
tab
.
radioButtonRat
,
j
=
tab
.
spinDict
[
labelledSpin
],
k
=
tab
.
mode
:
self
.
radioPressed
(
i
,
j
,
k
)
)
tab
.
spinDict
[
labelledSpin
]
.
insertWidget
(
tab
.
radioButtonRat
,
1
)
tab
.
buttonGroup
.
addButton
(
tab
.
radioButtonRat
)
tab
.
addModeButtons
()
tab
.
finaliseLayout
()
self
.
_setEnabled
(
tab
,
enable
,
vals
)
self
.
spinDict
[
mode
]
=
tab
.
spinDict
# self.addRadioButtons()
self
.
tabsList
=
self
.
tabsDict
.
values
()
self
.
buildPage
(
self
.
buttonWidgets
,
self
.
tabsList
)
# def addRadioButtons(self):
# for tab in self.tabsList:
# tab.buttonGroup = QtWidgets.QButtonGroup()
# for labelledSpin in tab.spinDict:
# if tab.spinDict[labelledSpin].label == "Inhale Time":
# tab.radioButtonTime = QtWidgets.QRadioButton()
# tab.radioButtonTime.toggled.connect(
# lambda i=tab.radioButtonTime, j=tab.spinDict[
# labelledSpin
# ], k=tab.mode: self.radioPressed(i, j, k)
# )
# tab.spinDict[labelledSpin].insertWidget(tab.radioButtonTime, 1)
# tab.buttonGroup.addButton(tab.radioButtonTime)
# if tab.spinDict[labelledSpin].label == "IE Ratio":
# tab.radioButtonRat = QtWidgets.QRadioButton()
# tab.radioButtonRat.toggled.connect(
# lambda i=tab.radioButtonRat, j=tab.spinDict[
# labelledSpin
# ]: self.radioPressed(i, j, k)
# )
# tab.spinDict[labelledSpin].insertWidget(tab.radioButtonRat, 1)
# tab.buttonGroup.addButton(tab.radioButtonRat)
def
radioPressed
(
self
,
radioButtonState
,
labelledSpin
,
tabMode
):
labelledSpin
.
simpleSpin
.
setEnabled
(
radioButtonState
)
labelledSpin
.
simpleSpin
.
setProperty
(
"bgColour"
,
str
(
int
(
not
radioButtonState
)))
labelledSpin
.
simpleSpin
.
setProperty
(
"textColour"
,
str
(
int
(
not
radioButtonState
))
)
labelledSpin
.
simpleSpin
.
style
()
.
unpolish
(
labelledSpin
.
simpleSpin
)
labelledSpin
.
simpleSpin
.
style
()
.
polish
(
labelledSpin
.
simpleSpin
)
if
tabMode
==
self
.
NativeUI
.
currentMode
:
a
=
1
self
.
NativeUI
.
widgets
.
spin_buttons
.
setStackWidget
(
labelledSpin
.
label
)
def
_setColour
(
self
,
buttonWidg
):
for
button
,
box
in
zip
(
self
.
buttonWidgets
,
self
.
pageList
):
if
button
==
buttonWidg
:
button
.
setProperty
(
"selected"
,
"1"
)
self
.
stack
.
setCurrentWidget
(
box
)
else
:
button
.
setProperty
(
"selected"
,
"0"
)
button
.
style
()
.
unpolish
(
button
)
button
.
style
()
.
polish
(
button
)
def
_modeSwitch
(
self
,
box
):
self
.
stack
.
setCurrentWidget
(
box
)
def
_setEnabled
(
self
,
box
,
enableList
,
values
):
for
widget
,
enableBool
,
value
in
zip
(
box
.
spinDict
,
enableList
,
values
):
box
.
spinDict
[
widget
]
.
simpleSpin
.
setEnabled
(
enableBool
)
if
enableBool
==
1
:
box
.
spinDict
[
widget
]
.
simpleSpin
.
setProperty
(
"bgColour"
,
"0"
)
box
.
spinDict
[
widget
]
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
if
enableBool
==
0
:
box
.
spinDict
[
widget
]
.
simpleSpin
.
setProperty
(
"bgColour"
,
"1"
)
box
.
spinDict
[
widget
]
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
box
.
spinDict
[
widget
]
.
simpleSpin
.
style
()
.
unpolish
(
box
.
spinDict
[
widget
]
.
simpleSpin
)
box
.
spinDict
[
widget
]
.
simpleSpin
.
style
()
.
polish
(
box
.
spinDict
[
widget
]
.
simpleSpin
)
box
.
spinDict
[
widget
]
.
simpleSpin
.
setValue
(
value
)
NativeUI/mode_widgets/tab_personal.py
deleted
100644 → 0
View file @
fabb9426
#!/usr/bin/env python3
"""
tab_personal.py
"""
__author__
=
[
"Benjamin Mummery"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__license__
=
"GPL"
__version__
=
"0.0.1"
__maintainer__
=
"Tiago Sarmento"
__email__
=
"tiago.sarmento@stfc.ac.uk"
__status__
=
"Development"
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
import
sys
sys
.
path
.
append
(
"~/Documents/hev/NativeUI/"
)
from
global_widgets.template_set_values
import
TemplateSetValues
class
TabPersonal
(
TemplateSetValues
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
TabPersonal
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
settingsList
=
[
[
"Name"
,
"/min"
,
"name"
,
"SET_PERSONAL"
,
"NAME"
],
[
"Patient ID"
,
"s"
,
"patient_id"
,
"SET_PERSONAL"
,
"PATIENT_ID"
],
[
"Age"
,
""
,
"age"
,
"SET_PERSONAL"
,
"AGE"
],
[
"Sex"
,
""
,
"sex"
,
"SET_PERSONAL"
,
"SEX"
],
[
"Weight"
,
""
,
"weight"
,
"SET_PERSONAL"
,
"WEIGHT"
],
[
"Height"
,
""
,
"height"
,
"SET_PERSONAL"
,
"HEIGHT"
],
]
textBoxes
=
[
"Name"
,
"Patient ID"
,
"Sex"
]
self
.
setPacketType
(
"personal"
)
self
.
addPersonalCol
(
settingsList
,
textBoxes
)
self
.
addButtons
()
self
.
finaliseLayout
()
@
QtCore
.
Slot
(
dict
)
def
localise_text
(
self
,
text
:
dict
)
->
int
:
self
.
spinDict
[
"Name"
]
.
nameLabel
.
setText
(
text
[
"personal_tab_name"
])
self
.
spinDict
[
"Patient ID"
]
.
nameLabel
.
setText
(
text
[
"personal_tab_patientid"
])
self
.
spinDict
[
"Age"
]
.
nameLabel
.
setText
(
text
[
"personal_tab_age"
])
self
.
spinDict
[
"Sex"
]
.
nameLabel
.
setText
(
text
[
"personal_tab_sex"
])
self
.
spinDict
[
"Weight"
]
.
nameLabel
.
setText
(
text
[
"personal_tab_weight"
])
self
.
spinDict
[
"Height"
]
.
nameLabel
.
setText
(
text
[
"personal_tab_height"
])
return
0
if
__name__
==
"__main__"
:
# sys.path.append("../")
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
widg
=
TabPersonal
()
widg
.
show
()
sys
.
exit
(
app
.
exec_
())
NativeUI/ui_layout.py
View file @
2263ae3e
...
@@ -122,6 +122,7 @@ class Layout:
...
@@ -122,6 +122,7 @@ class Layout:
vlayout
.
addWidget
(
self
.
widgets
.
calibration
)
vlayout
.
addWidget
(
self
.
widgets
.
calibration
)
vlayout
.
addWidget
(
self
.
widgets
.
leak_test
)
vlayout
.
addWidget
(
self
.
widgets
.
leak_test
)
vlayout
.
addWidget
(
self
.
widgets
.
maintenance
)
vlayout
.
addWidget
(
self
.
widgets
.
maintenance
)
vlayout
.
addWidget
(
self
.
widgets
.
alarm_control_startup
)
widg
=
QtWidgets
.
QWidget
()
widg
=
QtWidgets
.
QWidget
()
widg
.
setLayout
(
vlayout
)
widg
.
setLayout
(
vlayout
)
return
widg
return
widg
...
@@ -131,15 +132,19 @@ class Layout:
...
@@ -131,15 +132,19 @@ class Layout:
vlayout
=
QtWidgets
.
QVBoxLayout
()
vlayout
=
QtWidgets
.
QVBoxLayout
()
# Define Sizes
# Define Sizes
f_mode
=
0.
2
5
f_mode
=
0.
1
5
f_battery
=
0.2
f_battery
=
0.2
f_lock
=
0.1
f_localisation
=
0.1
f_localisation
=
0.1
f_personal
=
1
-
(
f_mode
+
f_battery
+
f_localisation
)
f_alarm
=
0.2
f_personal
=
1
-
(
f_mode
+
f_battery
+
f_lock
+
f_localisation
+
f_alarm
)
mode_display_width
=
int
(
self
.
screen_width
*
f_mode
)
mode_display_width
=
int
(
self
.
screen_width
*
f_mode
)
personal_display_width
=
int
(
self
.
screen_width
*
f_personal
)
personal_display_width
=
int
(
self
.
screen_width
*
f_personal
)
localisation_display_width
=
int
(
self
.
screen_width
*
f_localisation
)
localisation_display_width
=
int
(
self
.
screen_width
*
f_localisation
)
battery_display_width
=
int
(
self
.
screen_width
*
f_battery
)
battery_display_width
=
int
(
self
.
screen_width
*
f_battery
)
alarm_control_width
=
int
(
self
.
screen_width
*
f_alarm
)
lock_display_width
=
int
(
self
.
screen_width
*
f_lock
)
# Define the stack of pages (used by the page buttons to set the current page)
# Define the stack of pages (used by the page buttons to set the current page)
self
.
widgets
.
add_widget
(
self
.
widgets
.
add_widget
(
...
@@ -185,6 +190,7 @@ class Layout:
...
@@ -185,6 +190,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
.
alarm_control
,
self
.
widgets
.
lock_button
,
self
.
widgets
.
lock_button
,
]
]
)
)
...
@@ -207,6 +213,11 @@ class Layout:
...
@@ -207,6 +213,11 @@ class Layout:
)
)
self
.
widgets
.
battery_display
.
setFont
(
self
.
NativeUI
.
text_font
)
self
.
widgets
.
battery_display
.
setFont
(
self
.
NativeUI
.
text_font
)
self
.
widgets
.
alarm_control
.
set_size
(
alarm_control_width
,
self
.
top_bar_height
)
self
.
widgets
.
lock_button
.
setFixedWidth
(
lock_display_width
)
self
.
widgets
.
lock_button
.
setFixedHeight
(
self
.
top_bar_height
)
self
.
widgets
.
lock_button
.
setStyleSheet
(
'background-color: '
+
self
.
NativeUI
.
colors
[
'display_foreground'
]
.
name
())
vlayout
.
addLayout
(
hlayout
)
vlayout
.
addLayout
(
hlayout
)
return
vlayout
return
vlayout
...
@@ -288,6 +299,7 @@ class Layout:
...
@@ -288,6 +299,7 @@ class Layout:
"""
"""
Layout for the alarms page.
Layout for the alarms page.
"""
"""
self
.
widgets
.
acknowledge_button
.
setFont
(
self
.
NativeUI
.
text_font
)
alarm_tab_widgets
=
[
self
.
widgets
.
alarm_list
,
self
.
widgets
.
acknowledge_button
]
alarm_tab_widgets
=
[
self
.
widgets
.
alarm_list
,
self
.
widgets
.
acknowledge_button
]
alarm_table_tab_widgets
=
[
self
.
widgets
.
alarm_table
]
alarm_table_tab_widgets
=
[
self
.
widgets
.
alarm_table
]
...
@@ -351,14 +363,6 @@ class Layout:
...
@@ -351,14 +363,6 @@ class Layout:
"""
"""
Layout for the Modes page.
Layout for the Modes page.
"""
"""
# self.widgets.add_widget(
# SwitchableStackWidget(
# self.NativeUI,
# [QtWidgets.QLabel("1"), QtWidgets.QLabel("2"), QtWidgets.QLabel("3"), QtWidgets.QLabel("4")],
# ["PC/AC", "PC/AC-PRVC", "PC-PSV", "CPAP"]
# ),
# "mode_settings_tab"
# )
modes_stack
=
SwitchableStackWidget
(
modes_stack
=
SwitchableStackWidget
(
self
.
NativeUI
.
colors
,
self
.
NativeUI
.
colors
,
...
@@ -454,10 +458,10 @@ class Layout:
...
@@ -454,10 +458,10 @@ class Layout:
def
layout_tab_alarm_list
(
self
,
widgets
:
list
)
->
QtWidgets
.
QWidget
:
def
layout_tab_alarm_list
(
self
,
widgets
:
list
)
->
QtWidgets
.
QWidget
:
"""
"""
Construct the layout for the
'normal' plots and measurements display.
Construct the layout for the
alarm list and acknowledge button
"""
"""
tab_alarm_list
=
QtWidgets
.
QWidget
()
tab_alarm_list
=
QtWidgets
.
QWidget
()
tab_alarm_list_layout
=
QtWidgets
.
Q
H
BoxLayout
(
tab_alarm_list
)
tab_alarm_list_layout
=
QtWidgets
.
Q
V
BoxLayout
(
tab_alarm_list
)
for
widget
in
widgets
:
for
widget
in
widgets
:
tab_alarm_list_layout
.
addWidget
(
widget
)
tab_alarm_list_layout
.
addWidget
(
widget
)
tab_alarm_list
.
setLayout
(
tab_alarm_list_layout
)
tab_alarm_list
.
setLayout
(
tab_alarm_list_layout
)
...
@@ -530,11 +534,15 @@ class Layout:
...
@@ -530,11 +534,15 @@ class Layout:
self
.
NativeUI
.
widgets
.
get_widget
(
self
.
NativeUI
.
widgets
.
get_widget
(
"radio_"
+
mode
+
startup
+
"_"
+
widget
.
tag
"radio_"
+
mode
+
startup
+
"_"
+
widget
.
tag
),
),
1
,
)
)
self
.
NativeUI
.
widgets
.
get_widget
(
self
.
NativeUI
.
widgets
.
get_widget
(
"spin_"
+
mode
+
startup
+
"_"
+
widget
.
tag
"spin_"
+
mode
+
startup
+
"_"
+
widget
.
tag
)
.
setEnabled
(
bool
(
enableBool
))
)
.
setEnabled
(
bool
(
enableBool
))
else
:
self
.
NativeUI
.
widgets
.
get_widget
(
"spin_"
+
mode
+
startup
+
"_"
+
widget
.
tag
)
.
setEnabled
(
bool
(
enableBool
))
#print('setting enable to be ' + str(bool(enableBool)))
if
buttons
==
True
:
if
buttons
==
True
:
hButtonLayout
=
QtWidgets
.
QHBoxLayout
()
hButtonLayout
=
QtWidgets
.
QHBoxLayout
()
...
@@ -716,10 +724,15 @@ class Layout:
...
@@ -716,10 +724,15 @@ class Layout:
widg
=
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
)
widg
=
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
)
if
setting
[
0
]
in
modeDict
[
"radioSettings"
]:
if
setting
[
0
]
in
modeDict
[
"radioSettings"
]:
stack
.
addWidget
(
widg
)
stack
.
addWidget
(
widg
)
if
"IE Ratio"
in
widg
.
label_text
:
print
(
'is checked'
)
stack
.
setCurrentWidget
(
widg
)
else
:
else
:
hlayout
.
addWidget
(
widg
)
hlayout
.
addWidget
(
widg
)
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
main_mode_stack
)
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
main_mode_stack
)
stack
.
setCurrentWidget
vbuttonLayout
=
QtWidgets
.
QVBoxLayout
()
vbuttonLayout
=
QtWidgets
.
QVBoxLayout
()
okButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
"CURRENT_ok_button"
)
okButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
"CURRENT_ok_button"
)
okButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
okButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
...
@@ -772,6 +785,10 @@ class Layout:
...
@@ -772,6 +785,10 @@ class Layout:
for
setting
in
clinicalDict
[
"settings"
]:
for
setting
in
clinicalDict
[
"settings"
]:
attrName
=
"clinical_spin_"
+
setting
[
0
][
2
]
attrName
=
"clinical_spin_"
+
setting
[
0
][
2
]
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
=
QtWidgets
.
QHBoxLayout
()
#hlayout.setMargin(0)
#hlayout.setSpacing(0)
#hlayout.addStretch(5)
if
len
(
setting
)
>=
2
:
if
len
(
setting
)
>=
2
:
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
if
len
(
setting
)
==
3
:
if
len
(
setting
)
==
3
:
...
@@ -781,7 +798,11 @@ class Layout:
...
@@ -781,7 +798,11 @@ class Layout:
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
))
elif
len
(
setting
)
==
1
:
elif
len
(
setting
)
==
1
:
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_lim"
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_lim"
))
#items = (hlayout.itemAt(i) for i in range(hlayout.count()))
#for w in items:
# print(w)
# w.setAlignment(QtCore.Qt.AlignLeft)
hlayout
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
vlayout
.
addLayout
(
hlayout
)
vlayout
.
addLayout
(
hlayout
)
hbuttonlayout
=
QtWidgets
.
QHBoxLayout
()
hbuttonlayout
=
QtWidgets
.
QHBoxLayout
()
...
@@ -796,20 +817,29 @@ class Layout:
...
@@ -796,20 +817,29 @@ class Layout:
def
layout_startup_confirmation
(
self
):
def
layout_startup_confirmation
(
self
):
vlayout
=
QtWidgets
.
QVBoxLayout
()
vlayout
=
QtWidgets
.
QVBoxLayout
()
vlayout
.
setSpacing
(
0
)
vlayout
.
setMargin
(
0
)
hlayout
=
QtWidgets
.
QHBoxLayout
()
i
=
0
i
=
0
for
key
,
spinBox
in
self
.
NativeUI
.
widgets
.
get_widget
(
for
key
,
spinBox
in
self
.
NativeUI
.
widgets
.
get_widget
(
"startup_handler"
"startup_handler"
)
.
spinDict
.
items
():
)
.
spinDict
.
items
():
i
=
i
+
1
i
=
i
+
1
hlayout
=
QtWidgets
.
QHBoxLayout
()
nameLabel
=
QtWidgets
.
QLabel
(
key
)
nameLabel
=
QtWidgets
.
QLabel
(
spinBox
.
label
)
nameLabel
.
setFont
(
self
.
NativeUI
.
text_font
)
valLabel
=
QtWidgets
.
QLabel
(
str
(
spinBox
.
get_value
()))
valLabel
=
QtWidgets
.
QLabel
(
str
(
spinBox
.
get_value
()))
valLabel
.
setFont
(
self
.
NativeUI
.
text_font
)
hlayout
.
addWidget
(
nameLabel
)
hlayout
.
addWidget
(
nameLabel
)
hlayout
.
addWidget
(
valLabel
)
hlayout
.
addWidget
(
valLabel
)
vlayout
.
addLayout
(
hlayout
)
if
(
i
%
2
==
0
)
or
spinBox
.
label
==
'Percentage O2'
:
if
i
==
10
:
vlayout
.
addLayout
(
hlayout
)
hlayout
=
QtWidgets
.
QHBoxLayout
()
elif
i
==
len
(
self
.
NativeUI
.
widgets
.
get_widget
(
"startup_handler"
)
.
spinDict
):
vlayout
.
addLayout
(
hlayout
)
if
i
==
30
:
print
(
'reach or dont'
)
break
break
widg
=
QtWidgets
.
QWidget
()
widg
=
QtWidgets
.
QWidget
()
widg
.
setLayout
(
vlayout
)
widg
.
setLayout
(
vlayout
)
return
widg
return
widg
NativeUI/ui_widgets.py
View file @
2263ae3e
...
@@ -43,7 +43,7 @@ from widget_library.info_display_widgets import (
...
@@ -43,7 +43,7 @@ from widget_library.info_display_widgets import (
MaintenanceTimeDisplayWidget
,
MaintenanceTimeDisplayWidget
,
UpdateTimeDisplayWidget
,
UpdateTimeDisplayWidget
,
)
)
from
widget_library.alarm_control_widget
import
AlarmControlWidget
# 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
...
@@ -61,7 +61,7 @@ from widget_library.ventilator_start_stop_buttons_widget import (
...
@@ -61,7 +61,7 @@ from widget_library.ventilator_start_stop_buttons_widget import (
VentilatorStartStopButtonsWidget
,
VentilatorStartStopButtonsWidget
,
)
)
from
widget_library.line_edit_widget
import
LabelledLineEditWidget
from
widget_library.line_edit_widget
import
LabelledLineEditWidget
from
global_widgets.global_typeval_popup
import
TypeValuePopup
,
AbstractTypeValPopup
from
global_widgets.global_typeval_popup
import
AbstractTypeValPopup
# from widget_library.NativeUI.expert_handler import ExpertHandler
# from widget_library.NativeUI.expert_handler import ExpertHandler
# from mode_widgets.NativeUI.personal_handler import PersonalHandler
# from mode_widgets.NativeUI.personal_handler import PersonalHandler
...
@@ -130,6 +130,8 @@ class Widgets:
...
@@ -130,6 +130,8 @@ class Widgets:
self
.
localisation_button
=
LocalisationButtonWidget
(
self
.
localisation_button
=
LocalisationButtonWidget
(
NativeUI
.
localisation_files
,
NativeUI
.
colors
NativeUI
.
localisation_files
,
NativeUI
.
colors
)
)
self
.
alarm_control
=
AlarmControlWidget
(
NativeUI
)
self
.
alarm_control_startup
=
AlarmControlWidget
(
NativeUI
,
test
=
True
)
# Left Bar widgets
# Left Bar widgets
self
.
page_buttons
=
PageButtonsWidget
(
NativeUI
)
self
.
page_buttons
=
PageButtonsWidget
(
NativeUI
)
...
@@ -155,7 +157,7 @@ class Widgets:
...
@@ -155,7 +157,7 @@ class Widgets:
self
.
alarm_handler
=
AlarmHandler
(
NativeUI
)
self
.
alarm_handler
=
AlarmHandler
(
NativeUI
)
self
.
alarm_popup
=
AlarmPopup
(
NativeUI
)
self
.
alarm_popup
=
AlarmPopup
(
NativeUI
)
self
.
alarm_list
=
AlarmList
(
NativeUI
)
self
.
alarm_list
=
AlarmList
(
NativeUI
)
self
.
acknowledge_button
=
QPushButton
()
self
.
acknowledge_button
=
QPushButton
(
'Reset Alarms'
)
self
.
alarm_table
=
AlarmTable
(
NativeUI
)
self
.
alarm_table
=
AlarmTable
(
NativeUI
)
self
.
clinical_tab
=
QWidget
()
# TabClinical(NativeUI)
self
.
clinical_tab
=
QWidget
()
# TabClinical(NativeUI)
...
@@ -177,12 +179,14 @@ class Widgets:
...
@@ -177,12 +179,14 @@ class Widgets:
attrName
+
"_min"
,
attrName
+
"_min"
,
NativeUI
.
clinical_handler
,
NativeUI
.
clinical_handler
,
)
)
setting
[
-
1
][
0
]
=
""
self
.
add_handled_widget
(
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
[
-
1
]),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
[
-
1
]),
attrName
+
"_max"
,
attrName
+
"_max"
,
NativeUI
.
clinical_handler
,
NativeUI
.
clinical_handler
,
)
)
if
len
(
setting
)
==
3
:
if
len
(
setting
)
==
3
:
setting
[
1
][
0
]
=
""
self
.
add_handled_widget
(
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
[
1
]),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
[
1
]),
attrName
+
"_set"
,
attrName
+
"_set"
,
...
...
NativeUI/widget_library/alarm_control_widget.py
0 → 100644
View file @
2263ae3e
#!/usr/bin/env python3
"""
alarm_control_widget.py
"""
__author__
=
[
"Benjamin Mummery"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__license__
=
"GPL"
__version__
=
"0.0.1"
__maintainer__
=
"Tiago Sarmento"
__email__
=
"tiago.sarmento@stfc.ac.uk"
__status__
=
"Prototype"
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
import
os
class
AlarmControlWidget
(
QtWidgets
.
QWidget
):
"""Button controlling alarm volume and mute"""
def
__init__
(
self
,
NativeUI
,
test
=
False
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
volState
=
2
nVolSteps
=
3
self
.
volButtonsList
=
[]
self
.
volTruth
=
[
0
]
*
nVolSteps
hlayout
=
QtWidgets
.
QHBoxLayout
()
for
i
in
range
(
0
,
nVolSteps
):
self
.
volButtonsList
.
append
(
QtWidgets
.
QPushButton
())
self
.
volButtonsList
[
-
1
]
.
setStyleSheet
(
"QPushButton{"
" background-color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
"; border:none;"
"}"
"QPushButton[bgColour='1']{"
" background-color:"
+
NativeUI
.
colors
[
"button_background_highlight"
]
.
name
()
+
";border: none;"
"}"
"QPushButton[bgColour='0']{"
" background-color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
"; border:none;"
"}"
)
self
.
volButtonsList
[
-
1
]
.
pressed
.
connect
(
lambda
k
=
i
:
self
.
buttonPushed
(
k
))
hlayout
.
addWidget
(
self
.
volButtonsList
[
-
1
])
self
.
buttonPushed
(
self
.
volState
)
self
.
iconStack
=
QtWidgets
.
QStackedWidget
()
self
.
onSpeakers
=
QtWidgets
.
QPushButton
()
self
.
onSpeakers
.
pressed
.
connect
(
self
.
mute_pressed
)
self
.
onSpeakers
.
setStyleSheet
(
'background-color: '
+
NativeUI
.
colors
[
'button_background_enabled'
]
.
name
()
+
'; border:none;'
)
self
.
iconStack
.
addWidget
(
self
.
onSpeakers
)
self
.
offSpeakers
=
QtWidgets
.
QPushButton
()
self
.
offSpeakers
.
pressed
.
connect
(
self
.
unmute_pressed
)
self
.
offSpeakers
.
setStyleSheet
(
'background-color: '
+
NativeUI
.
colors
[
'button_background_enabled'
]
.
name
()
+
'; border:none;'
)
self
.
iconStack
.
addWidget
(
self
.
offSpeakers
)
hlayout
.
addWidget
(
self
.
iconStack
)
if
test
:
self
.
testSpeakers
=
QtWidgets
.
QPushButton
(
'Test'
)
self
.
setMaximumHeight
(
100
)
self
.
iconStack
.
addWidget
(
self
.
testSpeakers
)
self
.
iconStack
.
setCurrentWidget
(
self
.
testSpeakers
)
self
.
testSpeakers
.
pressed
.
connect
(
self
.
test_speakers
)
self
.
__icon_path
=
os
.
path
.
join
(
NativeUI
.
iconpath
,
"bell-solid.png"
)
pixmap
=
QtGui
.
QPixmap
(
self
.
__icon_path
)
mask
=
pixmap
.
mask
()
pixmap
.
fill
(
NativeUI
.
colors
[
"plot_pressure_flow"
])
pixmap
.
setMask
(
mask
)
self
.
onSpeakers
.
setIcon
(
QtGui
.
QIcon
(
pixmap
))
#self.onSpeakers.setStyleSheet('back')
self
.
__icon_path
=
os
.
path
.
join
(
NativeUI
.
iconpath
,
"bell-regular.png"
)
pixmap
=
QtGui
.
QPixmap
(
self
.
__icon_path
)
mask
=
pixmap
.
mask
()
pixmap
.
fill
(
NativeUI
.
colors
[
"plot_flow"
])
pixmap
.
setMask
(
mask
)
self
.
offSpeakers
.
setIcon
(
QtGui
.
QIcon
(
pixmap
))
#self.self.offSpeakers.setStyleSheet('back'
timeLabel
=
QtWidgets
.
QLabel
(
'100s'
)
hlayout
.
addWidget
(
timeLabel
)
self
.
setLayout
(
hlayout
)
def
mute_pressed
(
self
):
# print('big ol mute pressed')
# color = self.NativeUI.colors["page_foreground"]
# pixmap = QtGui.QPixmap(self.__icon_path)
# mask = pixmap.mask() # mask from alpha
# pixmap.fill(color) # fill with color
# pixmap.setMask(mask) # reapply mask
# self.onSpeakers.setIcon(QtGui.QIcon(pixmap))
self
.
buttonPushed
(
-
1
)
self
.
iconStack
.
setCurrentWidget
(
self
.
offSpeakers
)
self
.
NativeUI
.
q_send_cmd
(
"MUTE_ALARM"
,
"TRUE"
)
def
unmute_pressed
(
self
):
# print('big ol mute pressed')
# color = self.NativeUI.colors["page_foreground"]
# pixmap = QtGui.QPixmap(self.__icon_path)
# mask = pixmap.mask() # mask from alpha
# pixmap.fill(color) # fill with color
# pixmap.setMask(mask) # reapply mask
# self.onSpeakers.setIcon(QtGui.QIcon(pixmap))
self
.
buttonPushed
(
self
.
volState
)
self
.
iconStack
.
setCurrentWidget
(
self
.
onSpeakers
)
self
.
NativeUI
.
q_send_cmd
(
"MUTE_ALARM"
,
"FALSE"
)
#self.onSpeakers.
def
test_speakers
(
self
):
print
(
'testin!'
)
print
(
self
.
volState
)
self
.
NativeUI
.
q_send_cmd
(
"TEST_AUDIO_ALARM"
)
def
buttonPushed
(
self
,
index
):
if
index
!=
-
1
:
self
.
volState
=
index
for
i
in
range
(
0
,
index
+
1
):
#self.volTruth[i] = int(not self.volTruth[i]
self
.
volButtonsList
[
i
]
.
setProperty
(
"bgColour"
,
str
(
1
))
self
.
volButtonsList
[
i
]
.
style
()
.
polish
(
self
.
volButtonsList
[
i
])
for
i
in
range
(
index
+
1
,
len
(
self
.
volButtonsList
)):
self
.
volButtonsList
[
i
]
.
setProperty
(
"bgColour"
,
str
(
0
))
self
.
volButtonsList
[
i
]
.
style
()
.
polish
(
self
.
volButtonsList
[
i
])
#self.volButtonsList[i].style().polish(self.volButtonsList[index])
self
.
style
()
.
polish
(
self
)
if
index
==
-
1
:
for
i
in
range
(
0
,
len
(
self
.
volButtonsList
)):
self
.
volButtonsList
[
i
]
.
setProperty
(
"bgColour"
,
str
(
0
))
self
.
volButtonsList
[
i
]
.
style
()
.
polish
(
self
.
volButtonsList
[
i
])
elif
index
>=
0
:
self
.
NativeUI
.
q_send_cmd
(
"SET_VOLUME"
,
index
)
def
set_size
(
self
,
x
:
int
,
y
:
int
,
spacing
=
10
)
->
int
:
self
.
setFixedSize
(
x
,
y
)
return
0
if
__name__
==
"__main__"
:
import
sys
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
widg
=
AlarmControlButton
(
'a'
)
widg
.
show
()
sys
.
exit
(
app
.
exec_
())
\ No newline at end of file
NativeUI/widget_library/line_edit_widget.py
View file @
2263ae3e
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
from
global_widgets.global_typeval_popup
import
TypeValuePopup
#
from global_widgets.global_typeval_popup import TypeValuePopup
class
SignallingLineEditWidget
(
QtWidgets
.
QLineEdit
):
class
SignallingLineEditWidget
(
QtWidgets
.
QLineEdit
):
...
@@ -59,28 +59,40 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
...
@@ -59,28 +59,40 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
self
.
manuallyUpdated
=
False
self
.
manuallyUpdated
=
False
layout
=
QtWidgets
.
QHBoxLayout
()
layout
=
QtWidgets
.
QHBoxLayout
()
widgetList
=
[]
widgetList
=
[]
textStyle
=
"color:white; font: 16pt"
if
self
.
label
!=
""
:
if
self
.
label
!=
""
:
self
.
nameLabel
=
QtWidgets
.
QLabel
(
self
.
label
)
self
.
nameLabel
=
QtWidgets
.
QLabel
(
self
.
label
)
self
.
nameLabel
.
setStyleSheet
(
textStyle
)
self
.
nameLabel
.
setFont
(
NativeUI
.
text_font
)
self
.
nameLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignRight
)
#self.nameLabel.setStyleSheet("color:" + NativeUI.colors["page_foreground"].name() + "}")
self
.
nameLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignRight
|
QtCore
.
Qt
.
AlignVCenter
)
widgetList
.
append
(
self
.
nameLabel
)
widgetList
.
append
(
self
.
nameLabel
)
self
.
simpleSpin
=
SignallingLineEditWidget
(
NativeUI
,
popup
,
self
.
label
)
self
.
simpleSpin
=
SignallingLineEditWidget
(
NativeUI
,
popup
,
self
.
label
)
self
.
simpleSpin
.
setText
(
self
.
initText
)
self
.
simpleSpin
.
setText
(
self
.
initText
)
self
.
simpleSpin
.
setStyleSheet
(
self
.
simpleSpin
.
setStyleSheet
(
"""QDoubleSpinBox{ width:100px; font:16pt}
"QLineEdit{"
QDoubleSpinBox[bgColour="0"]{background-color:white; }
" color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
";"
QDoubleSpinBox[bgColour="1"]{background-color:grey; }
"}"
QDoubleSpinBox[textColour="0"]{color:black}
"QLineEdit[bgColour='1']{"
QDoubleSpinBox[textColour="1"]{color:red}
" background-color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
";"
QDoubleSpinBox::up-button{width:20; border:solid white; color:black }
"}"
QDoubleSpinBox::down-button{width:20; }
"QLineEdit[bgColour='0']{"
"""
" background-color:"
+
NativeUI
.
colors
[
"page_background"
]
.
name
()
+
";"
"}"
"QLineEdit[textColour='1']{"
" color:"
+
NativeUI
.
colors
[
"page_background"
]
.
name
()
+
";"
"}"
"QLineEdit[textColour='0']{"
" color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
";"
"}"
"QLineEdit[textColour='2']{"
" color:"
+
NativeUI
.
colors
[
"red"
]
.
name
()
+
";"
"}"
)
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
self
.
simpleSpin
.
setFixedWidth
(
600
)
self
.
simpleSpin
.
setProperty
(
"bgColour"
,
"0"
)
self
.
simpleSpin
.
setFont
(
NativeUI
.
text_font
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
self
.
simpleSpin
.
setProperty
(
"bgColour"
,
"1"
)
self
.
simpleSpin
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
simpleSpin
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
simpleSpin
.
textChanged
.
connect
(
self
.
textUpdate
)
self
.
simpleSpin
.
textChanged
.
connect
(
self
.
textUpdate
)
if
self
.
cmd_type
==
""
:
if
self
.
cmd_type
==
""
:
...
@@ -90,8 +102,9 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
...
@@ -90,8 +102,9 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
if
self
.
units
!=
""
:
if
self
.
units
!=
""
:
self
.
unitLabel
=
QtWidgets
.
QLabel
(
self
.
units
)
self
.
unitLabel
=
QtWidgets
.
QLabel
(
self
.
units
)
self
.
unitLabel
.
setStyleSheet
(
textStyle
)
self
.
unitLabel
.
setFont
(
NativeUI
.
text_font
)
self
.
unitLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignLeft
)
self
.
unitLabel
.
setStyleSheet
(
"color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
""
)
self
.
unitLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignLeft
|
QtCore
.
Qt
.
AlignVCenter
)
widgetList
.
append
(
self
.
unitLabel
)
widgetList
.
append
(
self
.
unitLabel
)
for
widget
in
widgetList
:
for
widget
in
widgetList
:
...
@@ -101,16 +114,18 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
...
@@ -101,16 +114,18 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
def
textUpdate
(
self
):
def
textUpdate
(
self
):
self
.
manuallyUpdated
=
True
self
.
manuallyUpdated
=
True
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"2"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
def
update_value
(
self
,
placeholdertemp
):
def
update_value
(
self
,
db
):
newVal
=
self
.
NativeUI
.
get_db
(
"personal"
)
newVal
=
db
[
self
.
tag
]
if
newVal
==
{}:
if
newVal
==
{}:
a
=
1
# do nothing
a
=
1
# do nothing
else
:
else
:
print
(
'got a personal db'
)
print
(
'got a personal db'
)
self
.
simpleSpin
.
setText
(
newVal
[
self
.
tag
]
)
self
.
simpleSpin
.
setText
(
newVal
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"
0
"
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"
1
"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
def
get_value
(
self
):
def
get_value
(
self
):
...
...
NativeUI/widget_library/numpad_widget.py
View file @
2263ae3e
...
@@ -21,7 +21,7 @@ class NumberpadButton(QtWidgets.QPushButton):
...
@@ -21,7 +21,7 @@ class NumberpadButton(QtWidgets.QPushButton):
super
()
.
__init__
(
*
args
,
**
kwargs
)
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
setStyleSheet
(
"background-color: "
+
NativeUI
.
colors
[
"button_background_enabled"
]
.
name
()
+
";"
self
.
setStyleSheet
(
"background-color: "
+
NativeUI
.
colors
[
"button_background_enabled"
]
.
name
()
+
";"
"color: "
+
NativeUI
.
colors
[
"label_foreground"
]
.
name
())
"color: "
+
NativeUI
.
colors
[
"label_foreground"
]
.
name
())
self
.
setFont
(
NativeUI
.
text
_font
)
self
.
setFont
(
NativeUI
.
value
_font
)
class
NumberpadWidget
(
QtWidgets
.
QWidget
):
class
NumberpadWidget
(
QtWidgets
.
QWidget
):
...
@@ -36,7 +36,12 @@ class NumberpadWidget(QtWidgets.QWidget):
...
@@ -36,7 +36,12 @@ class NumberpadWidget(QtWidgets.QWidget):
button_dict
=
{}
button_dict
=
{}
grid
=
QtWidgets
.
QGridLayout
()
grid
=
QtWidgets
.
QGridLayout
()
ncolumns
=
3
ncolumns
=
3
i
=
0
button_dict
[
'CLEAR'
]
=
NumberpadButton
(
NativeUI
,
'CLEAR'
)
button_dict
[
'CLEAR'
]
.
pressed
.
connect
(
lambda
j
=
'CLEAR'
:
self
.
buttonPressed
(
j
))
grid
.
addWidget
(
button_dict
[
'CLEAR'
],
0
,
0
,
1
,
3
)
i
=
3
for
symbol
in
symbol_list
:
for
symbol
in
symbol_list
:
button_dict
[
symbol
]
=
NumberpadButton
(
NativeUI
,
symbol
)
button_dict
[
symbol
]
=
NumberpadButton
(
NativeUI
,
symbol
)
button_dict
[
symbol
]
.
pressed
.
connect
(
lambda
j
=
symbol
:
self
.
buttonPressed
(
j
))
button_dict
[
symbol
]
.
pressed
.
connect
(
lambda
j
=
symbol
:
self
.
buttonPressed
(
j
))
...
@@ -58,7 +63,7 @@ class AlphapadWidget(QtWidgets.QWidget):
...
@@ -58,7 +63,7 @@ class AlphapadWidget(QtWidgets.QWidget):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
super
()
.
__init__
(
*
args
,
**
kwargs
)
symbol_list
=
[
'Q'
,
'W'
,
'E'
,
'R'
,
'T'
,
'Y'
,
'U'
,
'I'
,
'O'
,
'P'
,
'A'
,
'S'
,
'D'
,
'F'
,
'G'
,
'H'
,
'J'
,
'K'
,
'L'
,
'Z'
,
'X'
,
'C'
,
'V'
,
'B'
,
'N'
,
'M'
,
'<'
]
symbol_list
=
[
'Q'
,
'W'
,
'E'
,
'R'
,
'T'
,
'Y'
,
'U'
,
'I'
,
'O'
,
'P'
,
'A'
,
'S'
,
'D'
,
'F'
,
'G'
,
'H'
,
'J'
,
'K'
,
'L'
,
'Z'
,
'X'
,
'C'
,
'V'
,
'B'
,
'N'
,
'M'
,
'<'
,
'CLEAR'
]
newLineCharacters
=
[
'P'
,
'L'
]
newLineCharacters
=
[
'P'
,
'L'
]
button_dict
=
{}
button_dict
=
{}
grid
=
QtWidgets
.
QGridLayout
()
grid
=
QtWidgets
.
QGridLayout
()
...
...
NativeUI/widget_library/page_buttons_widget.py
View file @
2263ae3e
...
@@ -188,3 +188,9 @@ class PageButton(QtWidgets.QPushButton):
...
@@ -188,3 +188,9 @@ class PageButton(QtWidgets.QPushButton):
def
localise_text
(
self
,
*
args
,
**
kwargs
)
->
int
:
def
localise_text
(
self
,
*
args
,
**
kwargs
)
->
int
:
pass
pass
def
setFixedWidth
(
self
,
*
args
,
**
kwargs
):
self
.
setIconSize
(
QSize
(
args
[
0
],
self
.
frameGeometry
()
.
height
()))
def
setFixedHeight
(
self
,
*
args
,
**
kwargs
):
self
.
setIconSize
(
QSize
(
self
.
frameGeometry
()
.
width
(),
args
[
0
]))
NativeUI/widget_library/spin_buttons_widget.py
View file @
2263ae3e
...
@@ -16,7 +16,7 @@ __status__ = "Development"
...
@@ -16,7 +16,7 @@ __status__ = "Development"
import
sys
import
sys
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
from
global_widgets.global_typeval_popup
import
TypeValuePopup
#
from global_widgets.global_typeval_popup import TypeValuePopup
# from global_widgets.global_ok_cancel_buttons import okButton, cancelButton
# from global_widgets.global_ok_cancel_buttons import okButton, cancelButton
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
...
@@ -165,4 +165,3 @@ class SpinButton(QtWidgets.QFrame):
...
@@ -165,4 +165,3 @@ class SpinButton(QtWidgets.QFrame):
"""
"""
self
.
simpleSpin
.
setFont
(
font
)
self
.
simpleSpin
.
setFont
(
font
)
return
0
return
0
raspberry-backend/hevclient.py
View file @
2263ae3e
...
@@ -194,7 +194,7 @@ class HEVClient(object):
...
@@ -194,7 +194,7 @@ class HEVClient(object):
logging
.
info
(
f
"Request type {reqtype} sent successfully"
)
logging
.
info
(
f
"Request type {reqtype} sent successfully"
)
return
True
return
True
else
:
else
:
logging
.
warning
(
f
"Request type {reqtype} failed"
)
logging
.
warning
(
f
"Request type {reqtype} failed
1
"
)
return
False
return
False
def
send_cmd
(
self
,
cmdtype
:
str
,
cmd
:
str
,
param
:
Union
[
float
,
int
]
=
None
)
->
bool
:
def
send_cmd
(
self
,
cmdtype
:
str
,
cmd
:
str
,
param
:
Union
[
float
,
int
]
=
None
)
->
bool
:
...
...
raspberry-dataserver/CommsCommon.py
View file @
2263ae3e
...
@@ -65,6 +65,8 @@ class CMD_TYPE(Enum):
...
@@ -65,6 +65,8 @@ class CMD_TYPE(Enum):
DO_CALIBRATION
=
20
DO_CALIBRATION
=
20
MUTE_ALARM
=
21
MUTE_ALARM
=
21
RESET_ALARM
=
22
RESET_ALARM
=
22
SET_VOLUME
=
23
GET_EXPERT_INFO
=
24
...
@@ -76,6 +78,10 @@ class CMD_GENERAL(Enum):
...
@@ -76,6 +78,10 @@ class CMD_GENERAL(Enum):
STANDBY
=
4
STANDBY
=
4
GET_PERSONAL
=
5
GET_PERSONAL
=
5
@
unique
class
CMD_MUTE_ALARM
(
Enum
):
FALSE
=
0
TRUE
=
1
# Taken from the FSM doc. Correct as of 1400 on 20200417
# Taken from the FSM doc. Correct as of 1400 on 20200417
@
unique
@
unique
...
@@ -128,6 +134,10 @@ class CMD_SET_PID(Enum):
...
@@ -128,6 +134,10 @@ class CMD_SET_PID(Enum):
MAX_PATIENT_PRESSURE
=
7
MAX_PATIENT_PRESSURE
=
7
@
unique
class
CMD_DO_CALIBRATION
(
Enum
):
DO_CALIBRATIONING
=
0
@
unique
@
unique
class
CMD_SET_TARGET
(
Enum
):
class
CMD_SET_TARGET
(
Enum
):
INSPIRATORY_PRESSURE
=
1
INSPIRATORY_PRESSURE
=
1
...
@@ -161,6 +171,11 @@ class ALARM_TYPE(Enum):
...
@@ -161,6 +171,11 @@ class ALARM_TYPE(Enum):
PRIORITY_MEDIUM
=
2
PRIORITY_MEDIUM
=
2
PRIORITY_HIGH
=
3
PRIORITY_HIGH
=
3
@
unique
class
THRESHOLD_TYPE
(
Enum
):
NONE
=
0
MIN
=
1
MAX
=
2
@
unique
@
unique
class
ALARM_CODES
(
Enum
):
class
ALARM_CODES
(
Enum
):
...
@@ -217,6 +232,10 @@ class CMD_MAP(Enum):
...
@@ -217,6 +232,10 @@ class CMD_MAP(Enum):
GET_THRESHOLD_MIN
=
ALARM_CODES
GET_THRESHOLD_MIN
=
ALARM_CODES
GET_THRESHOLD_MAX
=
ALARM_CODES
GET_THRESHOLD_MAX
=
ALARM_CODES
GET_TARGETS
=
VENTILATION_MODE
GET_TARGETS
=
VENTILATION_MODE
DO_CALIBRATION
=
CMD_DO_CALIBRATION
MUTE_ALARM
=
CMD_MUTE_ALARM
RESET_ALARM
=
CMD_MUTE_ALARM
# SET_PERSONAL = CMD_SET_PERSONAL
# SET_PERSONAL = CMD_SET_PERSONAL
...
@@ -256,6 +275,7 @@ class PAYLOAD_TYPE(IntEnum):
...
@@ -256,6 +275,7 @@ class PAYLOAD_TYPE(IntEnum):
PERSONAL
=
13
PERSONAL
=
13
ALARM_MUTE
=
14
ALARM_MUTE
=
14
BAD_THRESHOLD
=
15
BAD_THRESHOLD
=
15
EXPERT_INFO
=
16
...
@@ -945,3 +965,121 @@ class AlarmFormat(PayloadFormat):
...
@@ -945,3 +965,121 @@ class AlarmFormat(PayloadFormat):
self
.
alarm_code
=
ALARM_CODES
(
alarm
)
self
.
alarm_code
=
ALARM_CODES
(
alarm
)
self
.
payload_type
=
PAYLOAD_TYPE
(
tmp_payload_type
)
self
.
payload_type
=
PAYLOAD_TYPE
(
tmp_payload_type
)
self
.
_byteArray
=
byteArray
self
.
_byteArray
=
byteArray
# =======================================
# alarm mute payload
# =======================================
@
dataclass
class
AlarmMuteFormat
(
PayloadFormat
):
_dataStruct
=
Struct
(
"<BIB?I"
)
payload_type
:
PAYLOAD_TYPE
=
PAYLOAD_TYPE
.
ALARM_MUTE
is_muted
:
bool
=
False
time_remaining
:
int
=
0.0
# def __eq__(self, other):
# return (self.alarm_type == other.alarm_type) and (
# self.alarm_code == other.alarm_code
# )
def
fromByteArray
(
self
,
byteArray
):
#alarm = 0
#priority = 0
#tmp_payload_type = 0
(
self
.
version
,
self
.
timestamp
,
tmp_payload_type
,
self
.
is_muted
,
self
.
time_remaining
,
)
=
self
.
_dataStruct
.
unpack
(
byteArray
)
self
.
checkVersion
()
#self.alarm_type = ALARM_TYPE(priority)
#self.alarm_code = ALARM_CODES(alarm)
self
.
payload_type
=
PAYLOAD_TYPE
(
tmp_payload_type
)
#self.is_muted =
self
.
_byteArray
=
byteArray
# =======================================
# Bad threshold format
# =======================================
@
dataclass
class
BadThresholdFormat
(
PayloadFormat
):
_dataStruct
=
Struct
(
"<BIBfff"
)
payload_type
:
PAYLOAD_TYPE
=
PAYLOAD_TYPE
.
BAD_THRESHOLD
current_value
:
float
=
0.0
targeted_value
:
float
=
0.0
most_extreme_allowed_value
:
float
=
0.0
# def __eq__(self, other):
# return (self.alarm_type == other.alarm_type) and (
# self.alarm_code == other.alarm_code
# )
def
fromByteArray
(
self
,
byteArray
):
#alarm = 0
#priority = 0
#tmp_payload_type = 0
(
self
.
version
,
self
.
timestamp
,
tmp_threshold_type
,
self
.
current_value
,
self
.
targeted_value
,
self
.
most_extreme_allowed_value
)
=
self
.
_dataStruct
.
unpack
(
byteArray
)
self
.
checkVersion
()
#self.alarm_type = ALARM_TYPE(priority)
#self.alarm_code = ALARM_CODES(alarm)
self
.
threshold_type
=
THRESHOLD_TYPE
(
tmp_threshold_type
)
#self.is_muted =
self
.
_byteArray
=
byteArray
# =======================================
# Bad threshold format
# =======================================
@
dataclass
class
ExpertInfoFormat
(
PayloadFormat
):
_dataStruct
=
Struct
(
"<BIBIIBBB"
)
payload_type
:
PAYLOAD_TYPE
=
PAYLOAD_TYPE
.
EXPERT_INFO
operational_hrs
:
int
=
0.0
uptime_hrs
:
int
=
0.0
version_major
:
int
=
0.0
version_minor
:
int
=
0.0
version_mpatch
:
int
=
0.0
# def __eq__(self, other):
# return (self.alarm_type == other.alarm_type) and (
# self.alarm_code == other.alarm_code
# )
def
fromByteArray
(
self
,
byteArray
):
#alarm = 0
#priority = 0
#tmp_payload_type = 0
(
self
.
version
,
self
.
timestamp
,
tmp_payload_type
,
self
.
operational_hrs
,
self
.
uptime_hrs
,
self
.
version_major
,
self
.
version_minor
,
self
.
version_patch
)
=
self
.
_dataStruct
.
unpack
(
byteArray
)
self
.
checkVersion
()
#self.alarm_type = ALARM_TYPE(priority)
#self.alarm_code = ALARM_CODES(alarm)
self
.
threshold_type
=
PAYLOAD_TYPE
(
tmp_payload_type
)
#self.is_muted =
self
.
_byteArray
=
byteArray
raspberry-dataserver/CommsControl.py
View file @
2263ae3e
...
@@ -286,6 +286,15 @@ class CommsControl:
...
@@ -286,6 +286,15 @@ class CommsControl:
payload
=
CommsCommon
.
TargetFormat
()
payload
=
CommsCommon
.
TargetFormat
()
elif
data_type
==
CommsCommon
.
PAYLOAD_TYPE
.
PERSONAL
:
elif
data_type
==
CommsCommon
.
PAYLOAD_TYPE
.
PERSONAL
:
payload
=
CommsCommon
.
PersonalFormat
()
payload
=
CommsCommon
.
PersonalFormat
()
elif
data_type
==
CommsCommon
.
PAYLOAD_TYPE
.
ALARM_MUTE
:
print
(
'alarm mute package received, this message printed in CommsControl'
)
payload
=
CommsCommon
.
AlarmMuteFormat
()
elif
data_type
==
CommsCommon
.
PAYLOAD_TYPE
.
BAD_THRESHOLD
:
print
(
'bad threshold package received, this message printed in CommsControl'
)
payload
=
CommsCommon
.
BadThresholdFormat
()
elif
data_type
==
CommsCommon
.
PAYLOAD_TYPE
.
EXPERT_INFO
:
print
(
'expert info package received, this message printed in CommsControl'
)
payload
=
CommsCommon
.
ExpertInfoFormat
()
elif
data_type
==
CommsCommon
.
PAYLOAD_TYPE
.
THRESHOLDS
:
elif
data_type
==
CommsCommon
.
PAYLOAD_TYPE
.
THRESHOLDS
:
# FIXME: nothing yet defined, TBD!!
# FIXME: nothing yet defined, TBD!!
return
False
return
False
...
...
raspberry-dataserver/hevclient.py
View file @
2263ae3e
...
@@ -221,7 +221,7 @@ class HEVClient(object):
...
@@ -221,7 +221,7 @@ class HEVClient(object):
logging
.
info
(
f
"Request type {reqtype} sent successfully"
)
logging
.
info
(
f
"Request type {reqtype} sent successfully"
)
return
True
return
True
else
:
else
:
logging
.
warning
(
f
"Request type {reqtype} failed"
)
logging
.
warning
(
f
"Request type {reqtype} failed
2
"
)
return
False
return
False
def
send_cmd
(
self
,
cmdtype
:
str
,
cmd
:
str
,
param
:
Union
[
float
,
int
]
=
None
)
->
bool
:
def
send_cmd
(
self
,
cmdtype
:
str
,
cmd
:
str
,
param
:
Union
[
float
,
int
]
=
None
)
->
bool
:
...
...
raspberry-dataserver/hevserver.py
View file @
2263ae3e
...
@@ -148,7 +148,8 @@ class HEVServer(object):
...
@@ -148,7 +148,8 @@ class HEVServer(object):
data
=
await
reader
.
readuntil
(
separator
=
b
"
\0
"
)
data
=
await
reader
.
readuntil
(
separator
=
b
"
\0
"
)
data
=
data
[:
-
1
]
# snip off nullbyte
data
=
data
[:
-
1
]
# snip off nullbyte
request
=
json
.
loads
(
data
.
decode
(
"utf-8"
))
request
=
json
.
loads
(
data
.
decode
(
"utf-8"
))
print
(
'in hevserver'
)
print
(
request
)
# logging
# logging
addr
=
writer
.
get_extra_info
(
"peername"
)
addr
=
writer
.
get_extra_info
(
"peername"
)
logging
.
info
(
f
"Answering request from {addr}"
)
logging
.
info
(
f
"Answering request from {addr}"
)
...
@@ -156,20 +157,35 @@ class HEVServer(object):
...
@@ -156,20 +157,35 @@ class HEVServer(object):
try
:
try
:
reqtype
=
request
[
"type"
]
reqtype
=
request
[
"type"
]
if
reqtype
==
"CMD"
:
if
reqtype
==
"CMD"
:
reqcmd
=
request
[
"cmd"
]
print
(
'req cmd is '
)
reqcmd
=
request
[
"cmd"
]
if
request
[
"cmd"
]
is
not
None
else
0
print
(
reqcmd
)
print
(
2
)
print
(
'reqcmdtype is '
)
reqcmdtype
=
request
[
"cmdtype"
]
reqcmdtype
=
request
[
"cmdtype"
]
print
(
reqcmdtype
)
print
(
3
)
print
(
'reqparam is '
)
reqparam
=
request
[
"param"
]
if
request
[
"param"
]
is
not
None
else
0
reqparam
=
request
[
"param"
]
if
request
[
"param"
]
is
not
None
else
0
print
(
reqparam
)
print
(
4
)
print
(
'cmd type'
)
print
(
CMD_TYPE
)
print
(
reqcmdtype
)
print
(
CMD_TYPE
[
reqcmdtype
]
.
value
)
print
(
CMD_MAP
[
reqcmdtype
]
.
value
[
reqcmd
]
.
value
)
print
(
reqparam
)
command
=
CommandFormat
(
command
=
CommandFormat
(
cmd_type
=
CMD_TYPE
[
reqcmdtype
]
.
value
,
cmd_type
=
CMD_TYPE
[
reqcmdtype
]
.
value
,
cmd_code
=
CMD_MAP
[
reqcmdtype
]
.
value
[
reqcmd
]
.
value
,
cmd_code
=
CMD_MAP
[
reqcmdtype
]
.
value
[
reqcmd
]
.
value
,
param
=
reqparam
,
param
=
reqparam
,
)
)
print
(
5
)
# print('***sending cmd ')
# print('***sending cmd ')
# print(command)
# print(command)
self
.
_comms_lli
.
writePayload
(
command
)
self
.
_comms_lli
.
writePayload
(
command
)
print
(
6
)
# processed and sent to controller, send ack to GUI since it's in enum
# processed and sent to controller, send ack to GUI since it's in enum
payload
=
{
"type"
:
"ack"
}
payload
=
{
"type"
:
"ack"
}
...
@@ -240,6 +256,7 @@ class HEVServer(object):
...
@@ -240,6 +256,7 @@ class HEVServer(object):
except
(
NameError
,
KeyError
,
HEVPacketError
,
StructError
)
as
e
:
except
(
NameError
,
KeyError
,
HEVPacketError
,
StructError
)
as
e
:
# invalid request: reject immediately
# invalid request: reject immediately
logging
.
warning
(
f
"Invalid packet: {e}"
)
logging
.
warning
(
f
"Invalid packet: {e}"
)
print
(
'in hevserver making a nack'
)
payload
=
{
"type"
:
"nack"
}
payload
=
{
"type"
:
"nack"
}
except
Exception
as
e
:
except
Exception
as
e
:
logging
.
critical
(
e
)
logging
.
critical
(
e
)
...
...
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