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
de2eb63b
Commit
de2eb63b
authored
May 19, 2021
by
Benjamin Mummery
💻
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'temp_merge_prep2' into ui_dev
parents
9f2e14e7
02903e33
Pipeline
#1558
failed with stages
Changes
17
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
495 additions
and
379 deletions
+495
-379
.gitignore
.gitignore
+1
-0
NativeUI.py
NativeUI/NativeUI.py
+59
-26
alarm_popup.py
NativeUI/alarm_widgets/alarm_popup.py
+3
-2
clinical_config.json
NativeUI/configs/clinical_config.json
+10
-9
mode_config.json
NativeUI/configs/mode_config.json
+2
-1
startup_config.json
NativeUI/configs/startup_config.json
+1
-1
global_spinbox.py
NativeUI/global_widgets/global_spinbox.py
+43
-41
global_typeval_popup.py
NativeUI/global_widgets/global_typeval_popup.py
+97
-11
clinical_handler.py
NativeUI/mode_widgets/clinical_handler.py
+108
-19
mode_handler.py
NativeUI/mode_widgets/mode_handler.py
+22
-8
ui_layout.py
NativeUI/ui_layout.py
+42
-45
ui_widgets.py
NativeUI/ui_widgets.py
+25
-31
expert_handler.py
NativeUI/widget_library/expert_handler.py
+1
-0
line_edit_widget.py
NativeUI/widget_library/line_edit_widget.py
+5
-5
numpad_widget.py
NativeUI/widget_library/numpad_widget.py
+50
-0
spin_buttons_widget.py
NativeUI/widget_library/spin_buttons_widget.py
+25
-180
startup_handler.py
NativeUI/widget_library/startup_handler.py
+1
-0
No files found.
.gitignore
View file @
de2eb63b
...
...
@@ -19,6 +19,7 @@ env/
ansible/playbooks/hosts
.idea
scratch_*
NativeUI/configs/startup_config.json
# python virtual env created using ansible
.hev_env
...
...
NativeUI/NativeUI.py
View file @
de2eb63b
...
...
@@ -58,6 +58,7 @@ from mode_widgets.clinical_handler import ClinicalHandler
from
alarm_widgets.alarm_handler
import
AlarmHandler
# from handler_library.readback_handler import ReadbackHandler
from
global_widgets.global_typeval_popup
import
TypeValuePopup
logging
.
basicConfig
(
...
...
@@ -162,6 +163,8 @@ class NativeUI(HEVClient, QMainWindow):
self
.
clinical_handler
,
self
.
alarm_handler
,
]
self
.
messageCommandPopup
=
SetConfirmPopup
(
self
)
self
.
typeValPopup
=
TypeValuePopup
(
self
)
# Create all of the widgets and place them in the layout.
self
.
widgets
=
Widgets
(
self
)
...
...
@@ -346,9 +349,22 @@ class NativeUI(HEVClient, QMainWindow):
# When mode is switched from mode page, various other locations must respond
for
widget
in
self
.
mode_handler
.
spinDict
.
values
():
self
.
mode_handler
.
UpdateModes
.
connect
(
widget
.
update_value
)
widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
widget
:
self
.
clinical_handler
.
setpoint_changed
(
i
)
)
widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
widget
:
self
.
mode_handler
.
propagate_modevalchange
(
i
)
)
for
widget
in
self
.
mode_handler
.
mainSpinDict
.
values
():
self
.
mode_handler
.
UpdateModes
.
connect
(
widget
.
update_value
)
widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
widget
:
self
.
clinical_handler
.
setpoint_changed
(
i
)
)
widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
widget
:
self
.
mode_handler
.
propagate_modevalchange
(
i
)
)
# widget.simpleSpin.manualChanged.connect(lambda i=widget: self.mode_handler.mode_value(i))
self
.
mode_handler
.
modeSwitched
.
connect
(
lambda
i
:
self
.
set_current_mode
(
i
))
self
.
mode_handler
.
modeSwitched
.
connect
(
...
...
@@ -369,11 +385,18 @@ class NativeUI(HEVClient, QMainWindow):
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
key
:
self
.
mode_handler
.
handle_manual_change
(
i
)
)
# if 'clinical' in key:
# spin_widget.simpleSpin.manualChanged.connect(
# lambda i=spin_widget, j=key: self.clinical_handler.setpoint_changed(i,j)
# )
for
key
,
spin_widget
in
self
.
mode_handler
.
mainSpinDict
.
items
():
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
key
:
self
.
mode_handler
.
handle_manual_change
(
i
)
)
spin_widget
.
simpleSpin
.
programmaticallyChanged
.
connect
(
lambda
i
=
key
:
self
.
mode_handler
.
handle_manual_change
(
i
)
)
# mode_handler should respond to user selection of radio button
for
key
,
radio_widget
in
self
.
mode_handler
.
radioDict
.
items
():
...
...
@@ -399,28 +422,41 @@ class NativeUI(HEVClient, QMainWindow):
elif
isinstance
(
button_widget
,
CancelButtonWidget
):
# mode = self.mode_handler.get_mode(key)
button_widget
.
clicked
.
connect
(
self
.
mode_handler
.
commandSent
)
#
# for key, spin_widget in self.clinical_handler.spinDict.items():
# spin_widget.simpleSpin.manualChanged.connect(
# lambda i=key: self.clinical_handler.handle_manual_change(i)
# )
#
# for key, button_widget in self.clinical_handler.buttonDict.items():
# if isinstance(button_widget, (OkButtonWidget)):
# button_widget.clicked.connect(
# self.clinical_handler.handle_okbutton_click
# )
# elif isinstance(button_widget, CancelButtonWidget):
# button_widget.clicked.connect(
# self.clinical_handler.commandSent
# )
for
key
,
spin_widget
in
self
.
clinical_handler
.
limSpinDict
.
items
():
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
key
:
self
.
clinical_handler
.
handle_manual_change
(
i
)
)
for
key
,
spin_widget
in
self
.
clinical_handler
.
setSpinDict
.
items
():
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
spin_widget
:
self
.
clinical_handler
.
setpoint_changed
(
i
)
)
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
key
:
self
.
clinical_handler
.
handle_manual_change
(
i
)
)
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
spin_widget
:
self
.
mode_handler
.
propagate_modevalchange
(
i
)
)
for
key
,
button_widget
in
self
.
clinical_handler
.
buttonDict
.
items
():
if
isinstance
(
button_widget
,
(
OkButtonWidget
)):
button_widget
.
clicked
.
connect
(
self
.
clinical_handler
.
handle_okbutton_click
)
elif
isinstance
(
button_widget
,
CancelButtonWidget
):
button_widget
.
clicked
.
connect
(
self
.
clinical_handler
.
handle_cancelbutton_click
)
# for widget in (self.clinical_handler.setSpinDict.values()):
# self.clinical_handler.UpdateClinical.connect(widget.update_value)
self
.
mode_handler
.
OpenPopup
.
connect
(
self
.
messageCommandPopup
.
populatePopup
)
self
.
mode_handler
.
OpenPopup
.
connect
(
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
messageCommandPopup
)
)
self
.
messageCommandPopup
.
ModeSend
.
connect
(
self
.
mode_handler
.
sendCommands
)
# self.messageCommandPopup.okButton.pressed.connect(self.mode_handler.sendCommands)
self
.
expert_handler
.
OpenPopup
.
connect
(
self
.
messageCommandPopup
.
populatePopup
)
self
.
expert_handler
.
OpenPopup
.
connect
(
...
...
@@ -428,9 +464,10 @@ class NativeUI(HEVClient, QMainWindow):
)
self
.
messageCommandPopup
.
ExpertSend
.
connect
(
self
.
expert_handler
.
sendCommands
)
# self.clinical_handler.OpenPopup.connect(self.messageCommandPopup.populatePopup)
# self.messageCommandPopup.ClinicalSend.connect(self.expert_handler.sendCommands)
# self.messageCommandPopup.okButton.pressed.connect(self.expert_handler.sendCommands)
self
.
clinical_handler
.
OpenPopup
.
connect
(
self
.
messageCommandPopup
.
populatePopup
)
self
.
messageCommandPopup
.
ClinicalSend
.
connect
(
self
.
clinical_handler
.
sendCommands
)
self
.
messageCommandPopup
.
cancelButton
.
pressed
.
connect
(
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
main_display
)
...
...
@@ -455,7 +492,7 @@ class NativeUI(HEVClient, QMainWindow):
lambda
i
=
key
:
self
.
expert_handler
.
handle_okbutton_click
(
i
)
)
elif
isinstance
(
button_widget
,
CancelButtonWidget
):
button_widget
.
pressed
.
connect
(
lambda
:
self
.
expert_handler
.
commandSent
)
button_widget
.
pressed
.
connect
(
self
.
expert_handler
.
commandSent
)
for
widget
in
self
.
expert_handler
.
spinDict
.
values
():
self
.
expert_handler
.
UpdateExpert
.
connect
(
widget
.
update_value
)
...
...
@@ -477,12 +514,8 @@ class NativeUI(HEVClient, QMainWindow):
# self.timer.timeout.connect(self.expert_handler.update_values)
self
.
timer
.
start
()
self
.
widgets
.
startup_handler
.
settingToggle
.
connect
(
self
.
widgets
.
spin_buttons
.
setStackWidget
)
self
.
mode_handler
.
settingToggle
.
connect
(
self
.
widgets
.
spin_buttons
.
setStackWidget
)
# self.widgets.startup_handler.settingToggle.connect(self.widgets.spin_buttons.setStackWidget)
# self.mode_handler.settingToggle.connect(self.widgets.spin_buttons.setStackWidget)
self
.
alarm_handler
.
UpdateAlarm
.
connect
(
self
.
alarm_handler
.
handle_newAlarm
)
self
.
alarm_handler
.
NewAlarm
.
connect
(
self
.
widgets
.
alarm_popup
.
addAlarm
)
...
...
NativeUI/alarm_widgets/alarm_popup.py
View file @
de2eb63b
...
...
@@ -42,9 +42,10 @@ class AlarmWidget(QtWidgets.QWidget):
self
.
layout
.
addWidget
(
iconLabel
)
self
.
textLabel
=
QtWidgets
.
QLabel
()
alarmLevel
=
self
.
alarmPayload
[
"alarm_type"
]
.
replace
(
'PRIORITY_'
,
''
)
self
.
textLabel
.
setText
(
self
.
alarmPayload
[
"alarm_type"
]
+
" - "
+
self
.
alarmPayload
[
"alarm_code"
]
)
#remove priority_
alarmLevel
+
" - "
+
self
.
alarmPayload
[
"alarm_code"
]
)
self
.
textLabel
.
setFixedWidth
(
400
)
self
.
textLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
textLabel
.
setFont
(
NativeUI
.
text_font
)
...
...
NativeUI/configs/clinical_config.json
View file @
de2eb63b
{
"settings"
:[
[[
"APNEA"
,
"ms"
,
"APNEA"
,
"SET_THRESHOLD_MIN"
,
"APNEA"
],[
"APNEA"
,
"ms"
,
"APNEA"
,
"SET_THRESHOLD_MAX"
,
"APNEA"
]],
[[
"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"
]],
[[
"FIO2"
,
"%"
,
"HIGH_FIO2"
,
"SET_THRESHOLD_MIN"
,
"HIGH_FIO2"
,
-10
,
0
,
5
,
1
,
0
],[
"FIO2"
,
"%"
,
"fiO2_percent"
,
"SET_TARGET_"
,
"FIO2_PERCENT"
,
20
,
100
,
21
,
1
,
0
],[
"FIO2"
,
"%"
,
"HIGH_FIO2"
,
"SET_THRESHOLD_MAX"
,
"HIGH_FIO2"
,
0
,
10
,
5
,
1
,
0
]],
[[
"Pressure"
,
" "
,
"HIGH_PRESSURE"
,
"SET_THRESHOLD_
"
,
"HIGH_PRESSURE"
],[
"Pressure"
,
" "
,
"HIGH_PRESSURE"
,
"SET_THRESHOLD_"
,
"HIGH_PRESSURE"
],[
"Pressure"
,
" "
,
"HIGH_PRESSURE"
,
"SET_THRESHOLD_
"
,
"HIGH_PRESSURE"
]],
[[
"Respiratory Rate"
,
" "
,
"HIGH_RR"
,
"SET_THRESHOLD_
"
,
"HIGH_RR"
],[
"Respiratory Rate"
,
" "
,
"HIGH_RR"
,
"SET_THRESHOLD_"
,
"HIGH_RR"
],[
"Respiratory Rate"
,
" "
,
"HIGH_RR"
,
"SET_THRESHOLD_"
,
"HIGH_RR"
]],
[[
"VTE"
,
" "
,
"HIGH_VTE"
,
"SET_THRESHOLD_
"
,
"HIGH_VTE"
],[
"VTE"
,
" "
,
"HIGH_VTE"
,
"SET_THRESHOLD_"
,
"HIGH_VTE"
],[
"VTE"
,
" "
,
"HIGH_VTE"
,
"SET_THRESHOLD_"
,
"HIGH_VTE"
]],
[[
"VTI"
,
" "
,
"HIGH_VTI"
,
"SET_THRESHOLD_
"
,
"HIGH_VTI"
],[
"VTI"
,
" "
,
"HIGH_VTI"
,
"SET_THRESHOLD_"
,
"HIGH_VTI"
],[
"VTI"
,
" "
,
"HIGH_VTI"
,
"SET_THRESHOLD_"
,
"HIGH_VTI"
]],
[[
"Occlusion"
,
" "
,
"OCCLUSION"
,
"SET_THRESHOLD_
"
,
"OCCLUSION"
],[
"Occlusion"
,
" "
,
"OCCLUSION"
,
"SET_THRESHOLD_"
,
"OCCLUSION"
],[
"Occlusion"
,
" "
,
"OCCLUSION"
,
"SET_THRESHOLD_"
,
"OCCLUSION"
]],
[[
"PEEP"
,
" "
,
"HIGH_PEEP"
,
"SET_THRESHOLD_
"
,
"HIGH_PEEP"
],[
"PEEP"
,
" "
,
"HIGH_PEEP"
,
"SET_THRESHOLD_"
,
"HIGH_PEEP"
],[
"PEEP"
,
" "
,
"HIGH_PEEP"
,
"SET_THRESHOLD_"
,
"HIGH_PEEP"
]]
[[
"FIO2"
,
"%"
,
"HIGH_FIO2"
,
"SET_THRESHOLD_MIN"
,
"HIGH_FIO2"
,
-10
,
0
,
-5
,
0.1
,
1
],[
"Percentage O2"
,
""
,
"fiO2_percent"
,
"SET_TARGET_CURRENT"
,
"FIO2_PERCENT"
,
20
,
100
,
21
,
1
,
0
],[
"FIO2"
,
"%"
,
"HIGH_FIO2"
,
"SET_THRESHOLD_MAX"
,
"HIGH_FIO2"
,
0
,
10
,
5
,
0.1
,
1
]],
[[
"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
]],
[[
"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
]],
[[
"VTI"
,
" "
,
"HIGH_VTI"
,
"SET_THRESHOLD_
MIN"
,
"HIGH_VTI"
,
-10
,
0
,
-5
,
1
,
0
],[
"VTI"
,
" "
,
"HIGH_VTI"
,
"SET_THRESHOLD_MAX"
,
"HIGH_VTI"
,
0
,
10
,
5
,
1
,
0
]],
[[
"Occlusion"
,
" "
,
"OCCLUSION"
,
"SET_THRESHOLD_
MIN"
,
"OCCLUSION"
,
5
,
20
,
15
,
1
,
0
]],
[[
"PEEP"
,
" "
,
"HIGH_PEEP"
,
"SET_THRESHOLD_
MIN"
,
"HIGH_PEEP"
,
-2
,
0
,
-2
,
1
,
0
],[
"PEEP"
,
"cm h2o"
,
"peep"
,
"SET_TARGET_CURRENT"
,
"PEEP"
,
0
,
100
,
15
,
0.1
,
1
],[
"PEEP"
,
" "
,
"HIGH_PEEP"
,
"SET_THRESHOLD_MAX"
,
"HIGH_PEEP"
,
0
,
2
,
2
,
1
,
0
]]
],
"HighLowLimits"
:
[
"High Pressure"
,
"Occlusion"
]
"SingleThresholds"
:
[
"APNEA"
,
"Occlusion"
],
"AbsoluteLimits"
:
[
"Percentage O2"
,
"FIO2"
,
"PEEP"
]
}
\ No newline at end of file
NativeUI/configs/mode_config.json
View file @
de2eb63b
{
"settings"
:[
[
"Respiratory Rate"
,
"/min"
,
"respiratory_rate"
,
"SET_TARGET_"
,
"RESPIRATORY_RATE"
,
0
,
20
,
15
,
0.1
,
1
],
[
"PEEP"
,
"cm h2o"
,
"peep"
,
"SET_TARGET_"
,
"PEEP"
,
0
,
100
,
15
,
0.1
,
1
],
[
"Inhale Time"
,
"s"
,
"inhale_time"
,
"SET_TARGET_"
,
"INHALE_TIME"
,
0
,
20
,
1
,
0.1
,
1
],
[
"IE Ratio"
,
""
,
"ie_ratio"
,
"SET_TARGET_"
,
"IE_RATIO"
,
0
,
1
,
0.338
,
0.001
,
3
],
[
"Inhale Trigger Sensitivity"
,
""
,
"inhale_trigger_threshold"
,
"SET_TARGET_"
,
"INHALE_TRIGGER_THRESHOLD"
,
0
,
20
,
5
,
0.2
,
1
],
...
...
@@ -8,6 +9,6 @@
[
"Inhale Volume"
,
""
,
"volume"
,
"SET_TARGET_"
,
"VOLUME"
,
200
,
800
,
400
,
20
,
0
],
[
"Percentage O2"
,
""
,
"fiO2_percent"
,
"SET_TARGET_"
,
"FIO2_PERCENT"
,
20
,
100
,
21
,
1
,
0
]],
"radioSettings"
:
[
"Inhale Time"
,
"IE Ratio"
],
"enableDict"
:{
"PC/AC"
:[
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
],
"PC/AC-PRVC"
:[
1
,
1
,
0
,
1
,
0
,
1
,
1
,
1
],
"PC-PSV"
:[
1
,
1
,
0
,
1
,
0
,
1
,
0
,
1
],
"CPAP"
:[
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
]},
"enableDict"
:{
"PC/AC"
:[
1
,
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
],
"PC/AC-PRVC"
:[
1
,
1
,
1
,
0
,
1
,
0
,
1
,
1
,
1
],
"PC-PSV"
:[
1
,
1
,
1
,
0
,
1
,
0
,
1
,
0
,
1
],
"CPAP"
:[
1
,
1
,
0
,
1
,
1
,
0
,
1
,
0
,
1
]},
"mainPageSettings"
:
[
"Inhale Pressure"
,
"Respiratory Rate"
,
"Inhale Time"
,
"IE Ratio"
,
"Percentage O2"
]
}
\ No newline at end of file
NativeUI/configs/startup_config.json
View file @
de2eb63b
{
"calibration"
:
{
"label"
:
"calibration"
,
"last_performed"
:
162142
0941
,
"cmd_code"
:
"calib_rate"
},
"leak_test"
:
{
"label"
:
"Leak Test"
,
"last_performed"
:
1621420942
,
"cmd_code"
:
"leak_test"
},
"maintenance"
:
{
"label"
:
"maintenance"
,
"last_performed"
:
1621420943
,
"cmd_code"
:
"main_tenance"
}}
{
"calibration"
:
{
"label"
:
"calibration"
,
"last_performed"
:
162142
6912
,
"cmd_code"
:
"calib_rate"
},
"leak_test"
:
{
"label"
:
"Leak Test"
,
"last_performed"
:
1621426913
,
"cmd_code"
:
"leak_test"
},
"maintenance"
:
{
"label"
:
"maintenance"
,
"last_performed"
:
1621426914
,
"cmd_code"
:
"main_tenance"
}}
NativeUI/global_widgets/global_spinbox.py
View file @
de2eb63b
...
...
@@ -25,15 +25,21 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
"""
manualChanged
=
QtCore
.
Signal
()
programmaticallyChanged
=
QtCore
.
Signal
()
def
__init__
(
self
,
NativeUI
):
def
__init__
(
self
,
NativeUI
,
label_text
,
min
,
max
,
initVal
,
step
,
decPlaces
):
super
()
.
__init__
()
self
.
lineEdit
()
.
installEventFilter
(
self
)
self
.
editable
=
True
self
.
popUp
=
TypeValuePopup
(
NativeUI
)
self
.
popUp
.
okButton
.
clicked
.
connect
(
self
.
okButtonPressed
)
self
.
popUp
.
cancelButton
.
clicked
.
connect
(
self
.
cancelButtonPressed
)
self
.
label_text
,
self
.
min
,
self
.
max
,
self
.
initVal
,
self
.
step
,
self
.
decPlaces
=
label_text
,
min
,
max
,
initVal
,
step
,
decPlaces
self
.
setRange
(
min
,
max
)
self
.
setSingleStep
(
step
)
self
.
setDecimals
(
decPlaces
)
self
.
setValue
(
initVal
)
#self.populateVals = [label_text, min, max, initVal, step, decPlaces]
self
.
popUp
=
NativeUI
.
typeValPopup
# TypeValuePopup(NativeUI, label_text, min, max, initVal, step, decPlaces)
#self.popUp.okButton.clicked.connect(self.okButtonPressed)
#self.popUp.cancelButton.clicked.connect(self.cancelButtonPressed)
def
setEditability
(
self
,
setBool
):
self
.
editable
=
setBool
...
...
@@ -58,6 +64,10 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
if
self
.
value
()
!=
value
:
self
.
manualChanged
.
emit
()
def
set_value
(
self
,
value
):
self
.
setValue
(
value
)
self
.
programmaticallyChanged
.
emit
()
def
eventFilter
(
self
,
source
,
event
):
"""Overrides event filter to implement response to double click """
if
(
...
...
@@ -66,7 +76,9 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
):
if
not
self
.
editable
:
return
self
.
popUp
.
lineEdit
.
setText
(
str
(
self
.
value
()))
#self.popUp.lineEdit.setText(str(self.value()))
#self.popUp.lineEdit.setFocus()
self
.
popUp
.
populatePopup
(
self
)
self
.
popUp
.
show
()
return
True
return
False
...
...
@@ -79,14 +91,12 @@ class labelledSpin(QtWidgets.QWidget):
def
__init__
(
self
,
NativeUI
,
infoArray
,
*
args
,
**
kwargs
):
super
(
labelledSpin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
# print(infoArray)
# a = ReadbackFormat()
# print(a)
self
.
NativeUI
=
NativeUI
self
.
cmd_type
,
self
.
cmd_code
=
""
,
""
self
.
min
,
self
.
max
,
self
.
step
=
0
,
10000
,
0.3
self
.
initVal
=
1
self
.
currentDbValue
=
self
.
initVal
self
.
decPlaces
=
2
self
.
label
=
"default"
if
len
(
infoArray
)
==
10
:
...
...
@@ -112,11 +122,11 @@ class labelledSpin(QtWidgets.QWidget):
self
.
nameLabel
.
setFont
(
NativeUI
.
text_font
)
self
.
nameLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignRight
|
QtCore
.
Qt
.
AlignVCenter
)
self
.
simpleSpin
=
signallingSpinBox
(
NativeUI
)
self
.
simpleSpin
.
setValue
(
self
.
initVal
)
self
.
simpleSpin
.
setRange
(
self
.
min
,
self
.
max
)
self
.
simpleSpin
.
setSingleStep
(
self
.
step
)
self
.
simpleSpin
.
setDecimals
(
self
.
decPlaces
)
self
.
simpleSpin
=
signallingSpinBox
(
NativeUI
,
self
.
label
,
self
.
min
,
self
.
max
,
self
.
initVal
,
self
.
step
,
self
.
decPlaces
)
# self.simpleSpin.setRange(self.min, self.max
)
# self.simpleSpin.setSingleStep(self.step
)
# self.simpleSpin.setDecimals(self.decPlaces
)
# self.simpleSpin.setValue(self.initVal
)
self
.
simpleSpin
.
setStyleSheet
(
"QDoubleSpinBox{"
" width:100px;"
# TODO: unhardcode
...
...
@@ -168,6 +178,7 @@ class labelledSpin(QtWidgets.QWidget):
self
.
setLayout
(
self
.
layout
)
self
.
simpleSpin
.
manualChanged
.
connect
(
self
.
manualStep
)
self
.
simpleSpin
.
programmaticallyChanged
.
connect
(
self
.
manualStep
)
# self.simpleSpin.valueChanged.connect(self.valChange)
def
manualStep
(
self
):
...
...
@@ -205,33 +216,6 @@ class labelledSpin(QtWidgets.QWidget):
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
# def update_readback_value(self):
# newVal = self.NativeUI.get_db("readback")
# if newVal == {} or self.manuallyUpdated:
# a = 1 # do nothing
# else:
# self.simpleSpin.setValue(newVal[self.tag])
# self.simpleSpin.setProperty("textColour", "0")
# self.simpleSpin.style().polish(self.simpleSpin)
# def update_targets_value(self):
# newVal = self.NativeUI.get_db("targets")
# if (newVal == {}) or (self.tag == "") or self.manuallyUpdated:
# a = 1 # do nothing
# else:
# self.simpleSpin.setValue(newVal[self.tag])
# self.simpleSpin.setProperty("textColour", "0")
# self.simpleSpin.style().polish(self.simpleSpin)
# def update_personal_value(self):
# newVal = self.NativeUI.get_db("personal")
# if (newVal == {}) or (self.tag == ""):
# a = 1 # do nothing
# else:
# self.simpleSpin.setValue(newVal[self.tag])
# self.simpleSpin.setProperty("textColour", "0")
# self.simpleSpin.style().polish(self.simpleSpin)
def
insertWidget
(
self
,
widget
,
position
):
self
.
insertedWidget
=
widget
self
.
widgetList
.
insert
(
position
,
widget
)
...
...
@@ -244,3 +228,21 @@ class labelledSpin(QtWidgets.QWidget):
def
get_value
(
self
):
return
self
.
simpleSpin
.
value
()
def
set_value
(
self
,
value
):
self
.
simpleSpin
.
setValue
(
value
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
return
0
def
set_maximum
(
self
,
max
):
self
.
max
=
max
if
self
.
simpleSpin
.
value
()
>
self
.
max
:
self
.
simpleSpin
.
set_value
(
max
)
self
.
simpleSpin
.
setRange
(
self
.
min
,
self
.
max
)
def
set_minimum
(
self
,
min
):
self
.
min
=
min
if
self
.
simpleSpin
.
value
()
<
self
.
min
:
self
.
simpleSpin
.
stepBy
(
self
.
min
-
self
.
simpleSpin
.
value
())
self
.
simpleSpin
.
setRange
(
self
.
min
,
self
.
max
)
\ No newline at end of file
NativeUI/global_widgets/global_typeval_popup.py
View file @
de2eb63b
...
...
@@ -14,21 +14,30 @@ __status__ = "Prototype"
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
import
os
os
.
environ
[
"QT_IM_MODULE"
]
=
"qtvirtualkeyboard"
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
from
widget_library.numpad_widget
import
NumberpadWidget
class
TypeValuePopup
(
QtWidgets
.
QDialog
):
"""Popup takes user input to put in spin box. """
okPressed
=
QtCore
.
Signal
(
str
)
cancelPressed
=
QtCore
.
Signal
()
def
__init__
(
self
,
NativeUI
):
super
()
.
__init__
()
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
#self.label_text = label_text
#self.min, self.max, self.initVal, self.step, self.decPlaces = min, max, initVal, step, decPlaces
grid
=
QtWidgets
.
QGridLayout
()
grid
.
setSpacing
(
1
)
self
.
setStyleSheet
(
"border-radius:4px; background-color:black"
)
self
.
label
=
QtWidgets
.
QLabel
()
#self.label_text)
self
.
label
.
setFont
(
NativeUI
.
text_font
)
self
.
label
.
setStyleSheet
(
'color: '
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
())
self
.
lineEdit
=
QtWidgets
.
QLineEdit
()
self
.
lineEdit
.
setText
(
"4"
)
self
.
lineEdit
.
setStyleSheet
(
...
...
@@ -49,25 +58,102 @@ class TypeValuePopup(QtWidgets.QDialog):
self
.
lineEdit
.
setFont
(
NativeUI
.
text_font
)
self
.
lineEdit
.
setProperty
(
"colour"
,
"1"
)
self
.
lineEdit
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
lineEdit
.
saveVal
=
self
.
lineEdit
.
text
()
self
.
lineEdit
.
saveVal
=
''
#
self.lineEdit.text()
self
.
lineEdit
.
setValidator
(
QtGui
.
QDoubleValidator
(
0.0
,
100.0
,
2
)
)
# ensures only doubles can be typed
QtGui
.
QDoubleValidator
(
0.0
,
100.0
,
5
)
)
# ensures only doubles can be typed
, do
# self.lineEdit.textEdited.connect(self.setTextColour(1))
grid
.
addWidget
(
self
.
lineEdit
,
0
,
0
,
1
,
2
)
self
.
numberpad
=
NumberpadWidget
(
NativeUI
)
self
.
numberpad
.
numberPressed
.
connect
(
self
.
handle_numberpress
)
self
.
increaseButton
=
OkButtonWidget
(
NativeUI
)
self
.
increaseButton
.
clicked
.
connect
(
self
.
increase_button_clicked
)
self
.
increaseButton
.
setEnabled
(
True
)
self
.
decreaseButton
=
CancelButtonWidget
(
NativeUI
)
self
.
decreaseButton
.
clicked
.
connect
(
self
.
decrease_button_clicked
)
self
.
decreaseButton
.
setEnabled
(
True
)
#grid.addWidget(self.lineEdit, 0, 0, 1, 2)
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
.
addWidget
(
self
.
decreaseButton
)
hlayout
.
addWidget
(
self
.
lineEdit
)
hlayout
.
addWidget
(
self
.
increaseButton
)
hlayout2
=
QtWidgets
.
QHBoxLayout
()
self
.
okButton
=
OkButtonWidget
(
NativeUI
)
self
.
okButton
.
setEnabled
(
True
)
grid
.
addWidget
(
self
.
okButton
,
1
,
0
)
self
.
okButton
.
pressed
.
connect
(
self
.
handle_ok_press
)
hlayout2
.
addWidget
(
self
.
okButton
)
#grid.addWidget(self.okButton, 1, 0)
self
.
cancelButton
=
CancelButtonWidget
(
NativeUI
)
self
.
cancelButton
.
setEnabled
(
True
)
grid
.
addWidget
(
self
.
cancelButton
,
1
,
1
)
self
.
setLayout
(
grid
)
hlayout2
.
addWidget
(
self
.
cancelButton
)
#grid.addWidget(self.cancelButton, 1, 1)
vlayout
=
QtWidgets
.
QVBoxLayout
()
vlayout
.
addWidget
(
self
.
label
)
vlayout
.
addLayout
(
hlayout
)
vlayout
.
addWidget
(
self
.
numberpad
)
vlayout
.
addLayout
((
hlayout2
))
self
.
setLayout
(
vlayout
)
self
.
setWindowFlags
(
QtCore
.
Qt
.
FramelessWindowHint
|
QtCore
.
Qt
.
WindowStaysOnTopHint
)
# no window title
def
getValue
(
self
):
def
handle_ok_press
(
self
):
val
=
self
.
lineEdit
.
text
()
self
.
currentWidg
.
setValue
(
float
(
val
))
self
.
close
()
self
.
currentWidg
.
manualChanged
.
emit
()
def
populatePopup
(
self
,
currentWidg
):
self
.
currentWidg
=
currentWidg
self
.
label_text
,
self
.
min
,
self
.
max
,
self
.
initVal
,
self
.
step
,
self
.
decPlaces
=
currentWidg
.
label_text
,
currentWidg
.
min
,
currentWidg
.
max
,
currentWidg
.
initVal
,
currentWidg
.
step
,
currentWidg
.
decPlaces
self
.
label
.
setText
(
self
.
label_text
)
self
.
lineEdit
.
setText
(
str
(
currentWidg
.
value
()))
def
handle_numberpress
(
self
,
symbol
):
"""Handle number pad button press. Put button value in line edit text, and handle inputs
outside accepted range or number of decimal places. Handle backspace"""
oldText
=
self
.
lineEdit
.
text
()
if
symbol
.
isnumeric
()
or
(
symbol
==
'.'
):
newText
=
oldText
+
symbol
if
float
(
newText
)
>
self
.
max
:
newText
=
str
(
self
.
max
)
elif
float
(
newText
)
<
self
.
min
:
newText
=
str
(
self
.
min
)
elif
'.'
in
newText
:
if
len
(
newText
.
split
(
'.'
)[
1
])
>
self
.
decPlaces
:
newText
=
oldText
self
.
lineEdit
.
setText
(
newText
)
elif
symbol
==
'<'
:
self
.
lineEdit
.
setText
(
oldText
[
0
:
-
1
])
def
increase_button_clicked
(
self
):
"""Handle increase step button click"""
currentVal
=
self
.
get_value
()
newVal
=
round
(
float
(
currentVal
)
+
self
.
step
,
self
.
decPlaces
)
if
newVal
>=
self
.
max
:
newVal
=
self
.
max
self
.
lineEdit
.
setText
(
str
(
newVal
))
return
0
def
decrease_button_clicked
(
self
):
"""Handle decrease step button click"""
currentVal
=
self
.
get_value
()
newVal
=
round
(
float
(
currentVal
)
-
self
.
step
,
self
.
decPlaces
)
if
newVal
<=
self
.
min
:
newVal
=
self
.
min
self
.
lineEdit
.
setText
(
str
(
newVal
))
return
0
def
get_value
(
self
):
return
self
.
lineEdit
.
text
()
NativeUI/mode_widgets/clinical_handler.py
View file @
de2eb63b
from
global_widgets.global_spinbox
import
labelledSpin
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
,
OkSendButtonWidget
#from global_widgets.global_send_popup import SetConfirmPopup
from
widget_library.spin_buttons_widget
import
SpinButton
,
SpinButtonsWidget
from
widget_library.spin_buttons_widget
import
SpinButton
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
from
handler_library.handler
import
PayloadHandler
...
...
@@ -16,22 +16,44 @@ class ClinicalHandler(PayloadHandler):
#settingToggle = QtCore.Signal(str)
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
()
.
__init__
([
''
],
*
args
,
**
kwargs
)
super
()
.
__init__
([
'
TARGET
'
],
*
args
,
**
kwargs
)
#super(TabModes, self).__init__(NativeUI, *args, **kwargs)
self
.
NativeUI
=
NativeUI
self
.
spinDict
=
{}
self
.
limSpinDict
=
{}
self
.
setSpinDict
=
{}
self
.
buttonDict
=
{}
self
.
radioDict
=
{}
self
.
commandList
=
[]
self
.
manuallyUpdated
=
False
self
.
valueDict
=
{}
with
open
(
"NativeUI/configs/clinical_config.json"
)
as
json_file
:
clinicalDict
=
json
.
load
(
json_file
)
#self.relevantKeys = [setting for setting in clinicalDict['settings']]
self
.
singleThresholds
=
clinicalDict
[
"SingleThresholds"
]
self
.
absoluteLimits
=
clinicalDict
[
"AbsoluteLimits"
]
self
.
limit_to_mode_dict
=
{}
self
.
relevantKeys
=
[]
for
setting
in
clinicalDict
[
'settings'
]:
if
len
(
setting
)
==
3
:
limit_code
=
setting
[
0
][
2
]
mode_code
=
setting
[
1
][
2
]
mode_minimum
=
setting
[
1
][
5
]
mode_maximum
=
setting
[
1
][
6
]
limit_minimum
=
setting
[
0
][
5
]
limit_maximum
=
setting
[
-
1
][
6
]
self
.
limit_to_mode_dict
[
limit_code
]
=
[
mode_code
,
mode_minimum
,
mode_maximum
,
limit_minimum
,
limit_maximum
]
self
.
relevantKeys
.
append
(
setting
[
1
][
2
])
def
add_widget
(
self
,
widget
,
key
:
str
):
if
isinstance
(
widget
,
labelledSpin
):
self
.
spinDict
[
key
]
=
widget
if
'min'
in
key
or
'max'
in
key
:
self
.
limSpinDict
[
key
]
=
widget
elif
'set'
in
key
:
self
.
setSpinDict
[
key
]
=
widget
self
.
valueDict
[
key
]
=
widget
.
get_value
()
if
isinstance
(
widget
,
OkButtonWidget
)
or
isinstance
(
widget
,
CancelButtonWidget
)
or
isinstance
(
widget
,
OkSendButtonWidget
):
self
.
buttonDict
[
key
]
=
widget
if
isinstance
(
widget
,
QtWidgets
.
QRadioButton
):
...
...
@@ -42,6 +64,7 @@ class ClinicalHandler(PayloadHandler):
target_data
=
self
.
get_db
()
outdict
=
{}
for
key
in
self
.
relevantKeys
:
try
:
outdict
[
key
]
=
target_data
[
key
]
...
...
@@ -53,18 +76,25 @@ class ClinicalHandler(PayloadHandler):
def
handle_okbutton_click
(
self
):
print
(
'ok'
)
message
,
command
=
[],
[]
for
widget
in
self
.
spinDict
:
if
self
.
spinDict
[
widget
]
.
manuallyUpdated
:
print
(
'True'
)
setVal
=
self
.
spinDict
[
widget
]
.
get_value
()
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
for
key
,
widget
in
dict
(
self
.
limSpinDict
,
**
self
.
setSpinDict
)
.
items
():
if
widget
.
manuallyUpdated
:
setVal
=
widget
.
get_value
()
if
(
'set'
not
in
key
):
setkey
=
key
.
replace
(
'min'
,
'set'
)
.
replace
(
'max'
,
'set'
)
if
(
widget
.
label
in
self
.
absoluteLimits
):
multiplier
=
1
else
:
multiplier
=
self
.
setSpinDict
[
setkey
]
.
get_value
()
/
100
setVal
=
self
.
setSpinDict
[
setkey
]
.
get_value
()
+
setVal
*
multiplier
setVal
=
round
(
setVal
,
widget
.
decPlaces
)
message
.
append
(
"set"
+
key
+
" to "
+
str
(
setVal
))
command
.
append
(
[
self
.
spinDict
[
widget
]
.
cmd_type
,
self
.
spinDict
[
widget
]
.
cmd_code
,
widget
.
cmd_type
,
widget
.
cmd_code
,
setVal
,
]
)
...
...
@@ -82,24 +112,83 @@ class ClinicalHandler(PayloadHandler):
self
.
commandSent
()
return
0
def
handle_cancelbutton_click
(
self
):
for
key
,
widget
in
dict
(
self
.
limSpinDict
,
**
self
.
setSpinDict
)
.
items
():
widget
.
manuallyUpdated
=
False
widget
.
set_value
(
self
.
valueDict
[
key
])
self
.
active_payload
()
self
.
refresh_button_colour
()
def
commandSent
(
self
):
self
.
commandList
=
[]
for
widget
in
self
.
spinDict
:
self
.
spinDict
[
widget
]
.
manuallyUpdated
=
False
for
key
,
widget
in
dict
(
self
.
limSpinDict
,
**
self
.
setSpinDict
)
.
items
():
widget
.
manuallyUpdated
=
False
self
.
valueDict
[
key
]
=
widget
.
get_value
()
widget
.
set_value
(
widget
.
get_value
())
self
.
active_payload
()
self
.
refresh_button_colour
()
def
handle_manual_change
(
self
,
changed_spin_key
):
self
.
active_payload
()
self
.
refresh_button_colour
()
def
setpoint_changed
(
self
,
widget
):
"""Respond to change in operational settings to modify alarm limits. If setpoint is close to an absolute maximum
or minimum the alarm limits should respond.
Takes the modified widget, uses its tag to identify corresponding alarm limits"""
cmd_code
=
widget
.
tag
for
key
,
infoList
in
self
.
limit_to_mode_dict
.
items
():
if
cmd_code
in
infoList
[
0
]:
# find entry in dictionary corresponding to the modified widget
setValue
=
widget
.
get_value
()
minValue
=
float
(
infoList
[
1
])
maxValue
=
float
(
infoList
[
2
])
limMin
=
float
(
infoList
[
3
])
limMax
=
float
(
infoList
[
4
])
attrName
=
'clinical_spin_'
+
key
minLimitWidget
=
self
.
limSpinDict
[
attrName
+
'_min'
]
maxLimitWidget
=
self
.
limSpinDict
[
attrName
+
'_max'
]
if
widget
is
not
self
.
setSpinDict
[
attrName
+
'_set'
]:
# handle incoming value from 'set point' spin boxes elsewhere in ui
if
isinstance
(
widget
,
labelledSpin
):
if
self
.
NativeUI
.
currentMode
.
replace
(
'/'
,
'_'
)
.
replace
(
'-'
,
'_'
)
in
widget
.
cmd_type
:
self
.
setSpinDict
[
attrName
+
'_set'
]
.
simpleSpin
.
set_value
(
widget
.
get_value
())
elif
isinstance
(
widget
,
SpinButton
):
self
.
setSpinDict
[
attrName
+
'_set'
]
.
simpleSpin
.
set_value
(
widget
.
get_value
())
if
widget
.
label
in
self
.
absoluteLimits
:
denominator
=
100
# just get difference if looking for absolute limit
else
:
denominator
=
setValue
# get percentage if looking for percentage
pct_to_max
=
100
*
(
maxValue
-
setValue
)
/
denominator
pct_to_min
=
100
*
(
minValue
-
setValue
)
/
denominator
# print('maximum is ' + str(limMax))
# print('pct to max is ' + str(pct_to_max))
# print('maxval is ' + str(maxValue))
# print('setVal is ' + str(setValue))
# print('denom is ' + str(denominator))
if
round
(
pct_to_max
,
4
)
<=
round
(
limMax
,
4
):
# round to avoid errors with floating point numbers
maxLimitWidget
.
set_maximum
(
pct_to_max
)
elif
round
(
pct_to_min
,
4
)
>=
round
(
limMin
,
4
):
minLimitWidget
.
set_minimum
(
pct_to_min
)
else
:
maxLimitWidget
.
set_maximum
(
10
)
minLimitWidget
.
set_minimum
(
-
10
)
self
.
refresh_button_colour
()
def
refresh_button_colour
(
self
):
'''Refresh button colour based on whether there are any manually updated spin widgets or not'''
self
.
manuallyUpdated
=
False
for
spin
in
dict
(
self
.
spinDict
):
self
.
manuallyUpdated
=
self
.
manuallyUpdated
or
s
elf
.
spinDict
[
spin
]
.
manuallyUpdated
for
button
in
dict
(
self
.
buttonDict
)
:
for
spin
in
dict
(
self
.
limSpinDict
,
**
self
.
setSpinDict
)
.
values
(
):
self
.
manuallyUpdated
=
self
.
manuallyUpdated
or
s
pin
.
manuallyUpdated
for
button
in
self
.
buttonDict
:
if
isinstance
(
self
.
buttonDict
[
button
],
OkSendButtonWidget
):
self
.
buttonDict
[
button
]
.
setColour
(
str
(
int
(
True
)))
else
:
...
...
NativeUI/mode_widgets/mode_handler.py
View file @
de2eb63b
from
global_widgets.global_spinbox
import
labelledSpin
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
,
OkSendButtonWidget
#from global_widgets.global_send_popup import SetConfirmPopup
from
widget_library.spin_buttons_widget
import
SpinButton
,
SpinButtonsWidget
from
widget_library.spin_buttons_widget
import
SpinButton
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
from
handler_library.handler
import
PayloadHandler
...
...
@@ -63,15 +63,12 @@ class ModeHandler(PayloadHandler):
def
handle_okbutton_click
(
self
,
key
):
print
(
'ok'
)
print
(
key
)
mode
=
self
.
get_mode
(
key
)
print
(
mode
)
message
,
command
=
[],
[]
for
widget
in
self
.
spinDict
:
if
(
mode
in
widget
)
and
self
.
spinDict
[
widget
]
.
manuallyUpdated
:
print
(
'True'
)
setVal
=
self
.
spinDict
[
widget
]
.
get_value
()
setVal
=
round
(
setVal
,
widget
.
decPlaces
)
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
...
...
@@ -90,6 +87,7 @@ class ModeHandler(PayloadHandler):
for
widget
in
self
.
mainSpinDict
:
if
self
.
mainSpinDict
[
widget
]
.
manuallyUpdated
:
setVal
=
self
.
mainSpinDict
[
widget
]
.
get_value
()
setVal
=
round
(
setVal
,
widget
.
decPlaces
)
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
...
...
@@ -128,6 +126,7 @@ class ModeHandler(PayloadHandler):
self
.
refresh_main_button_colour
()
def
handle_manual_change
(
self
,
changed_spin_key
):
print
(
'handle manual change'
)
self
.
active_payload
()
self
.
refresh_button_colour
()
self
.
refresh_main_button_colour
()
...
...
@@ -144,19 +143,34 @@ class ModeHandler(PayloadHandler):
def
refresh_button_colour
(
self
):
self
.
manuallyUpdatedBoolDict
=
{
mode
:
False
for
mode
in
self
.
modeList
}
for
spin
in
dict
(
self
.
spinDict
):
self
.
manuallyUpdatedBoolDict
[
self
.
get_mode
(
spin
)]
=
self
.
manuallyUpdatedBoolDict
[
self
.
get_mode
(
spin
)]
or
self
.
spinDict
[
spin
]
.
manuallyUpdated
for
button
in
dict
(
self
.
buttonDict
):
for
spin
in
self
.
spinDict
:
mode
=
self
.
get_mode
(
spin
)
if
mode
==
None
:
continue
self
.
manuallyUpdatedBoolDict
[
mode
]
=
self
.
manuallyUpdatedBoolDict
[
mode
]
or
self
.
spinDict
[
spin
]
.
manuallyUpdated
for
button
in
self
.
buttonDict
:
mode
=
str
(
self
.
get_mode
(
button
))
if
isinstance
(
self
.
buttonDict
[
button
],
OkSendButtonWidget
)
and
(
mode
!=
self
.
NativeUI
.
currentMode
):
self
.
buttonDict
[
button
]
.
setColour
(
str
(
int
(
True
)))
else
:
self
.
buttonDict
[
button
]
.
setColour
(
str
(
int
(
self
.
manuallyUpdatedBoolDict
[
mode
])))
def
propagate_modevalchange
(
self
,
widget
):
for
spin
in
self
.
mainSpinDict
.
values
():
if
spin
.
tag
==
widget
.
tag
:
if
spin
.
get_value
()
!=
widget
.
get_value
():
spin
.
set_value
(
widget
.
get_value
())
for
spin
in
self
.
spinDict
.
values
():
if
spin
.
tag
==
widget
.
tag
:
if
self
.
NativeUI
.
currentMode
.
replace
(
'/'
,
'_'
)
.
replace
(
'-'
,
'_'
)
in
spin
.
cmd_type
:
if
spin
.
get_value
()
!=
widget
.
get_value
():
spin
.
simpleSpin
.
set_value
(
widget
.
get_value
())
def
refresh_main_button_colour
(
self
):
print
(
'refreshing main buttons'
)
self
.
manuallyUpdatedBoolDict
[
'CURRENT'
]
=
False
for
spin
in
self
.
mainSpinDict
:
print
(
spin
+
'is '
+
str
(
self
.
mainSpinDict
[
spin
]
.
manuallyUpdated
))
self
.
manuallyUpdatedBoolDict
[
'CURRENT'
]
=
self
.
manuallyUpdatedBoolDict
[
'CURRENT'
]
or
self
.
mainSpinDict
[
spin
]
.
manuallyUpdated
for
button
in
self
.
mainButtonDict
:
self
.
mainButtonDict
[
button
]
.
setColour
(
str
(
int
(
self
.
manuallyUpdatedBoolDict
[
'CURRENT'
])))
...
...
NativeUI/ui_layout.py
View file @
de2eb63b
...
...
@@ -261,19 +261,13 @@ class Layout:
page_main_center_layout
=
QtWidgets
.
QHBoxLayout
()
page_main_bottom_layout
=
QtWidgets
.
QHBoxLayout
()
spin_buttons
=
self
.
layout_main_spin_buttons
()
center_widgets
=
[
self
.
widgets
.
plot_stack
]
bottom_widgets
=
[
self
.
widgets
.
history_buttons
,
s
elf
.
layout_main_spin_buttons
()
]
bottom_widgets
=
[
self
.
widgets
.
history_buttons
,
s
pin_buttons
]
self
.
widgets
.
history_buttons
.
set_size
(
None
,
self
.
main_page_bottom_bar_height
,
spacing
=
self
.
widget_spacing
)
self
.
widgets
.
history_buttons
.
setFont
(
self
.
NativeUI
.
text_font
)
self
.
widgets
.
spin_buttons
.
set_size
(
self
.
screen_width
-
self
.
left_bar_width
-
self
.
main_page_bottom_bar_height
,
self
.
main_page_bottom_bar_height
,
spacing
=
self
.
widget_spacing
,
)
self
.
widgets
.
spin_buttons
.
set_label_font
(
self
.
NativeUI
.
text_font
)
self
.
widgets
.
spin_buttons
.
set_value_font
(
self
.
NativeUI
.
value_font
)
for
widget
in
center_widgets
:
page_main_center_layout
.
addWidget
(
widget
)
...
...
@@ -716,6 +710,36 @@ class Layout:
combined_spin_buttons
=
QtWidgets
.
QWidget
()
combined_spin_buttons
.
setLayout
(
hlayout
)
x
=
self
.
screen_width
-
self
.
left_bar_width
-
self
.
main_page_bottom_bar_height
y
=
self
.
main_page_bottom_bar_height
spacing
=
self
.
widget_spacing
combined_spin_buttons
.
setFixedSize
(
x
,
y
)
x_spin
=
int
(
x
/
hlayout
.
count
()
-
spacing
)
y_spin
=
y
-
spacing
for
setting
in
modeDict
[
"settings"
]:
if
setting
[
0
]
in
modeDict
[
"mainPageSettings"
]:
attrName
=
"CURRENT_"
+
setting
[
2
]
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
)
.
setFixedSize
(
x_spin
,
y_spin
)
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
)
.
simpleSpin
.
setFixedSize
(
x_spin
,
0.7
*
y_spin
)
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
)
.
simpleSpin
.
setFont
(
self
.
NativeUI
.
text_font
)
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
)
.
label
.
setFont
(
self
.
NativeUI
.
text_font
)
stack
.
setFixedSize
(
x_spin
,
y_spin
)
cancelButton
.
setFixedSize
(
x_spin
,
int
(
y_spin
/
2
)
-
spacing
)
okButton
.
setFixedSize
(
x_spin
,
int
(
y_spin
/
2
)
-
spacing
)
# spin_buttons.set_label_font(self.NativeUI.text_font)
# spin_buttons.set_value_font(self.NativeUI.value_font
return
combined_spin_buttons
def
layout_tab_clinical_limits
(
self
):
...
...
@@ -726,8 +750,16 @@ class Layout:
for
setting
in
clinicalDict
[
"settings"
]:
attrName
=
"clinical_spin_"
+
setting
[
0
][
2
]
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
))
if
len
(
setting
)
>=
2
:
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
if
len
(
setting
)
==
3
:
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_set"
)
)
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
))
elif
len
(
setting
)
==
1
:
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_lim"
))
vlayout
.
addLayout
(
hlayout
)
hbuttonlayout
=
QtWidgets
.
QHBoxLayout
()
...
...
@@ -736,45 +768,10 @@ class Layout:
self
.
NativeUI
.
widgets
.
get_widget
(
"clinical_cancel_button"
)
)
vlayout
.
addLayout
(
hbuttonlayout
)
# hlayoutMeta.addLayout(vlayout)
# hlayoutMeta.addLayout(vlayout2)
clinical_page
=
QtWidgets
.
QWidget
()
clinical_page
.
setLayout
(
vlayout
)
return
clinical_page
# def layout_tab_clinical_limits(self):
# with open("NativeUI/configs/clinical_config.json") as json_file:
# clinicalDict = json.load(json_file)
#
#
# grid = QtWidgets.QGridLayout()
# #grid.setHorizontalSpacing(0)
# vlayout = QtWidgets.QVBoxLayout()
# vlayout2 = QtWidgets.QVBoxLayout()
# i = 0
# for setting in clinicalDict['settings']:
# attrName = 'spin_' + setting[2]
# if setting[0] in clinicalDict['HighLowLimits']:
#
# grid.addWidget(self.NativeUI.widgets.get_widget(attrName), int(i / 2), 2 * (i % 2), 1, 1)
# grid.addWidget(self.NativeUI.widgets.get_widget(attrName + '_2'), int(i / 2), 2 * (i % 2) + 1, 1, 1)
# else:
# grid.addWidget(self.NativeUI.widgets.get_widget(attrName), int(i / 2), 2 * (i % 2), 1, 2)
#
# i = i + 1
#
# vlayout.addLayout(grid)
# hbuttonlayout = QtWidgets.QHBoxLayout()
# hbuttonlayout.addWidget(self.NativeUI.widgets.get_widget('clinical_ok_button'))
# hbuttonlayout.addWidget(self.NativeUI.widgets.get_widget('clinical_cancel_button'))
# vlayout.addLayout(hbuttonlayout)
# # hlayoutMeta.addLayout(vlayout)
# # hlayoutMeta.addLayout(vlayout2)
# clinical_page = QtWidgets.QWidget()
# clinical_page.setLayout(vlayout)
# return clinical_page
#
def
layout_startup_confirmation
(
self
):
vlayout
=
QtWidgets
.
QVBoxLayout
()
i
=
0
...
...
NativeUI/ui_widgets.py
View file @
de2eb63b
...
...
@@ -54,7 +54,7 @@ from widget_library.plot_widget import (
CirclePlotsWidget
,
TimePlotsWidget
,
)
from
widget_library.spin_buttons_widget
import
SpinButton
sWidget
,
SpinButton
from
widget_library.spin_buttons_widget
import
SpinButton
# from widget_library.tab_expert import TabExpert
from
widget_library.ventilator_start_stop_buttons_widget
import
(
...
...
@@ -139,9 +139,7 @@ class Widgets:
# Main Page Widgets
# self.spin_buttons = SpinButtonsWidget(NativeUI)
self
.
add_handled_widget
(
SpinButtonsWidget
(
NativeUI
),
"spin_buttons"
,
NativeUI
.
mode_handler
)
# self.add_handled_widget(SpinButtonsWidget(NativeUI), 'spin_buttons', NativeUI.mode_handler)
self
.
history_buttons
=
HistoryButtonsWidget
(
NativeUI
)
self
.
normal_plots
=
TimePlotsWidget
(
NativeUI
)
self
.
detailed_plots
=
TimePlotsWidget
(
NativeUI
)
...
...
@@ -161,32 +159,31 @@ class Widgets:
with
open
(
"NativeUI/configs/clinical_config.json"
)
as
json_file
:
clinicalDict
=
json
.
load
(
json_file
)
# radioSettings = modeDict["radioSettings"]
# modes = NativeUI.modeList
# self.add_handled_widget(QStackedWidget(), 'main_mode_stack', NativeUI.mode_handler)
for
setting
in
clinicalDict
[
"settings"
]:
# print(setting)
attrName
=
"clinical_spin_"
+
setting
[
0
][
2
]
# setting[0][3] = setting[0][3] + 'MIN'
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
0
]),
attrName
+
"_min"
,
NativeUI
.
clinical_handler
,
)
# setting[0][3] = setting[0][3] + 'MAX'
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
1
]),
attrName
+
"_max"
,
NativeUI
.
clinical_handler
,
)
# setting[3] = 'SET_TARGET'
# if setting[0] in clinicalDict['HighLowLimits']:
# self.add_handled_widget(labelledSpin(NativeUI, [setting[0], "", setting[2]]), attrName, NativeUI.clinical_handler)
# self.add_handled_widget(labelledSpin(NativeUI, ["", setting[1], setting[2]]), attrName + '_2', NativeUI.clinical_handler)
# else:
# self.add_handled_widget(labelledSpin(NativeUI, setting), attrName, NativeUI.clinical_handler)
if
len
(
setting
)
==
1
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
0
]),
attrName
+
"_lim"
,
NativeUI
.
clinical_handler
,
)
if
len
(
setting
)
>=
2
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
0
]),
attrName
+
"_min"
,
NativeUI
.
clinical_handler
,
)
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
-
1
]),
attrName
+
"_max"
,
NativeUI
.
clinical_handler
,
)
if
len
(
setting
)
==
3
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
1
]),
attrName
+
"_set"
,
NativeUI
.
clinical_handler
,
)
self
.
add_handled_widget
(
OkButtonWidget
(
NativeUI
),
"clinical_ok_button"
,
NativeUI
.
clinical_handler
...
...
@@ -200,9 +197,6 @@ class Widgets:
#### Mode settings tab: Mode (x4), Personal
# Modes Page Widgets
# self.mode_confirm_popup = SetConfirmPopup(NativeUI)
# NativeUI.mode_handler = ModeHandler(NativeUI, self.mode_confirm_popup)
with
open
(
"NativeUI/configs/mode_config.json"
)
as
json_file
:
modeDict
=
json
.
load
(
json_file
)
...
...
NativeUI/widget_library/expert_handler.py
View file @
de2eb63b
...
...
@@ -47,6 +47,7 @@ class ExpertHandler(PayloadHandler): # chose QWidget over QDialog family becaus
for
widget
in
self
.
spinDict
:
if
self
.
spinDict
[
widget
]
.
manuallyUpdated
:
setVal
=
self
.
spinDict
[
widget
]
.
get_value
()
setVal
=
round
(
setVal
,
widget
.
decPlaces
)
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
...
...
NativeUI/widget_library/line_edit_widget.py
View file @
de2eb63b
...
...
@@ -9,10 +9,10 @@ class SignallingLineEditWidget(QtWidgets.QLineEdit):
super
()
.
__init__
()
self
.
installEventFilter
(
self
)
self
.
popUp
=
TypeValuePopup
(
NativeUI
)
self
.
popUp
.
lineEdit
.
setValidator
(
None
)
# nsure it accepts text
self
.
popUp
.
okButton
.
clicked
.
connect
(
self
.
okButtonPressed
)
self
.
popUp
.
cancelButton
.
clicked
.
connect
(
self
.
cancelButtonPressed
)
#self.popUp = TypeValuePopup(NativeUI)#,'text edit',0,1,2,3,4
)
#
self.popUp.lineEdit.setValidator(None) # nsure it accepts text
#
self.popUp.okButton.clicked.connect(self.okButtonPressed)
#
self.popUp.cancelButton.clicked.connect(self.cancelButtonPressed)
def
okButtonPressed
(
self
):
val
=
self
.
popUp
.
lineEdit
.
text
()
...
...
@@ -21,7 +21,7 @@ class SignallingLineEditWidget(QtWidgets.QLineEdit):
self
.
manualChanged
.
emit
()
def
cancelButtonPressed
(
self
):
self
.
popUp
.
lineEdit
.
setText
(
self
.
popUp
.
lineEdit
.
saveVal
)
self
.
popUp
.
lineEdit
.
setText
(
self
.
popUp
.
lineEdit
p
.
saveVal
)
self
.
popUp
.
close
()
def
eventFilter
(
self
,
source
,
event
):
...
...
NativeUI/widget_library/numpad_widget.py
0 → 100644
View file @
de2eb63b
#!/usr/bin/env python3
"""
numpad_wdget.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
class
NumberpadButton
(
QtWidgets
.
QPushButton
):
"""Individual numberpad buttons are styled here. Consider moving this to NumberpadWidget."""
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
setStyleSheet
(
"background-color: "
+
NativeUI
.
colors
[
"button_background_enabled"
]
.
name
()
+
";"
"color: "
+
NativeUI
.
colors
[
"label_foreground"
]
.
name
())
self
.
setFont
(
NativeUI
.
text_font
)
class
NumberpadWidget
(
QtWidgets
.
QWidget
):
"""A widget with digits 0-9, a decimal point '.', and a backspace '<'.
Has one signal for any button pressed, the corresponding character is emitted with the signal.
"""
numberPressed
=
QtCore
.
Signal
(
str
)
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
symbol_list
=
[
'0'
,
'.'
,
'<'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
]
button_dict
=
{}
grid
=
QtWidgets
.
QGridLayout
()
ncolumns
=
3
i
=
0
for
symbol
in
symbol_list
:
button_dict
[
symbol
]
=
NumberpadButton
(
NativeUI
,
symbol
)
button_dict
[
symbol
]
.
pressed
.
connect
(
lambda
j
=
symbol
:
self
.
buttonPressed
(
j
))
grid
.
addWidget
(
button_dict
[
symbol
],
int
(
i
/
ncolumns
),
i
%
ncolumns
)
i
=
i
+
1
self
.
setLayout
(
grid
)
def
buttonPressed
(
self
,
symbol
:
str
):
"""Emit a signal with the button's character"""
self
.
numberPressed
.
emit
(
symbol
)
\ No newline at end of file
NativeUI/widget_library/spin_buttons_widget.py
View file @
de2eb63b
This diff is collapsed.
Click to expand it.
NativeUI/widget_library/startup_handler.py
View file @
de2eb63b
...
...
@@ -102,6 +102,7 @@ class StartupHandler(
message
,
command
=
[],
[]
for
widget
in
self
.
spinDict
:
setVal
=
self
.
spinDict
[
widget
]
.
get_value
()
setVal
=
round
(
setVal
,
widget
.
decPlaces
)
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
self
.
spinDict
[
widget
]
.
cmd_type
,
self
.
spinDict
[
widget
]
.
cmd_code
,
setVal
]
...
...
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