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
705d721d
Commit
705d721d
authored
Jun 23, 2021
by
Benjamin Mummery
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
separated maintenance from startup handler
parent
d742f838
Pipeline
#1847
failed with stages
Changes
9
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
167 additions
and
24 deletions
+167
-24
NativeUI.py
NativeUI/NativeUI.py
+9
-4
maintenance_config.json
NativeUI/configs/maintenance_config.json
+8
-0
maintenance_config_default.json
NativeUI/configs/maintenance_config_default.json
+8
-0
startup_config_default.json
NativeUI/configs/startup_config_default.json
+0
-6
maintenance_handler.py
NativeUI/handler_library/maintenance_handler.py
+91
-0
ui_layout.py
NativeUI/ui_layout.py
+14
-6
ui_widgets.py
NativeUI/ui_widgets.py
+27
-2
info_display_widgets.py
NativeUI/widget_library/info_display_widgets.py
+5
-0
startup_handler.py
NativeUI/widget_library/startup_handler.py
+5
-6
No files found.
NativeUI/NativeUI.py
View file @
705d721d
...
...
@@ -331,7 +331,6 @@ class NativeUI(HEVClient, QMainWindow):
self
.
messagePopup
.
cancelButton
.
pressed
.
connect
(
lambda
i
=
self
.
startupWidget
:
self
.
display_stack
.
setCurrentWidget
(
i
)
)
self
.
widgets
.
calibration
.
button
.
pressed
.
connect
(
lambda
i
=
self
.
widgets
.
calibration
:
self
.
widgets
.
startup_handler
.
handle_calibrationPress
(
i
...
...
@@ -340,7 +339,6 @@ class NativeUI(HEVClient, QMainWindow):
self
.
widgets
.
calibration
.
button
.
pressed
.
connect
(
lambda
i
=
self
.
messagePopup
:
self
.
display_stack
.
setCurrentWidget
(
i
)
)
self
.
widgets
.
leak_test
.
button
.
pressed
.
connect
(
lambda
i
=
self
.
widgets
.
leak_test
:
self
.
widgets
.
startup_handler
.
handle_calibrationPress
(
i
...
...
@@ -366,6 +364,9 @@ class NativeUI(HEVClient, QMainWindow):
i
,
j
)
)
self
.
widgets
.
maintenance_handler
.
MaintenanceConfigUpdate
.
connect
(
self
.
widgets
.
maintenance_time_display_widget
.
update_time
)
# Startup next and skip buttons should move from the startup widget to the main
# display
...
...
@@ -525,8 +526,12 @@ class NativeUI(HEVClient, QMainWindow):
button_widget
.
pressed
.
connect
(
self
.
clinical_handler
.
commandSent
)
elif
isinstance
(
button_widget
,
CancelButtonWidget
):
# mode = self.mode_handler.get_mode(key)
button_widget
.
clicked
.
connect
(
lambda
i
=
key
:
self
.
mode_handler
.
commandSent
(
i
))
button_widget
.
pressed
.
connect
(
lambda
i
=
key
:
self
.
clinical_handler
.
commandSent
(
i
))
button_widget
.
clicked
.
connect
(
lambda
i
=
key
:
self
.
mode_handler
.
commandSent
(
i
)
)
button_widget
.
pressed
.
connect
(
lambda
i
=
key
:
self
.
clinical_handler
.
commandSent
(
i
)
)
for
key
,
spin_widget
in
self
.
clinical_handler
.
limSpinDict
.
items
():
spin_widget
.
simpleSpin
.
manualChanged
.
connect
(
...
...
NativeUI/configs/maintenance_config.json
0 → 100644
View file @
705d721d
{
"maintenance"
:
{
"label"
:
"maintenance"
,
"last_performed"
:
0
,
"cmd_code"
:
"main_tenance"
,
"message"
:
"Was maintenance carried out successfully?"
}
}
NativeUI/configs/maintenance_config_default.json
0 → 100644
View file @
705d721d
{
"maintenance"
:
{
"label"
:
"maintenance"
,
"last_performed"
:
0
,
"cmd_code"
:
"main_tenance"
,
"message"
:
"Was maintenance carried out successfully?"
}
}
NativeUI/configs/startup_config_default.json
View file @
705d721d
...
...
@@ -10,11 +10,5 @@
"last_performed"
:
0
,
"cmd_code"
:
"leak_test"
,
"message"
:
"Ensure patient is disconnected from ventilator"
},
"maintenance"
:
{
"label"
:
"maintenance"
,
"last_performed"
:
0
,
"cmd_code"
:
"main_tenance"
,
"message"
:
"Was maintenance carried out successfully?"
}
}
NativeUI/handler_library/maintenance_handler.py
0 → 100644
View file @
705d721d
from
global_widgets.global_spinbox
import
labelledSpin
from
widget_library.startup_calibration_widget
import
calibrationWidget
from
widget_library.ok_cancel_buttons_widget
import
(
OkButtonWidget
,
CancelButtonWidget
,
OkSendButtonWidget
,
)
from
global_widgets.global_send_popup
import
SetConfirmPopup
from
PySide2.QtWidgets
import
QRadioButton
from
datetime
import
datetime
import
json
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
import
logging
class
MaintenanceHandler
(
QtWidgets
.
QWidget
):
# chose QWidget over QDialog family because easier to modify
OpenPopup
=
QtCore
.
Signal
(
list
)
MaintenanceConfigUpdate
=
QtCore
.
Signal
(
dict
)
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
calibDict
=
{}
self
.
calibs_done_dict
=
{}
self
.
activeWidget
=
None
def
add_widget
(
self
,
widget
,
key
:
str
):
if
isinstance
(
widget
,
labelledSpin
):
self
.
spinDict
[
key
]
=
widget
widget
.
cmd_type
=
widget
.
cmd_type
.
replace
(
"startup"
,
"CURRENT"
)
if
isinstance
(
widget
,
calibrationWidget
):
self
.
calibDict
[
key
]
=
widget
if
(
isinstance
(
widget
,
OkButtonWidget
)
or
isinstance
(
widget
,
CancelButtonWidget
)
or
isinstance
(
widget
,
OkSendButtonWidget
)
):
self
.
buttonDict
[
key
]
=
widget
if
isinstance
(
widget
,
QRadioButton
):
if
widget
.
text
()
in
self
.
NativeUI
.
modeList
:
self
.
modeRadioDict
[
key
]
=
widget
else
:
self
.
settingsRadioDict
[
key
]
=
widget
def
handle_calibrationPress
(
self
,
calibrationWidget
)
->
int
:
"""
When a calibration buttonis pressed, run the corresponding calibration. If all
calibrations are completed, emit the CalibrationComplete signal.
Currently doesn't actually do any calibrations, just a placeholder for now.
"""
self
.
activeWidget
=
calibrationWidget
print
(
self
.
activeWidget
)
print
(
NativeUI
.
messagePopup
)
self
.
NativeUI
.
messagePopup
.
setLabelText
(
calibrationWidget
.
infoDict
[
"message"
])
def
carryout_calibration
(
self
)
->
int
:
assert
self
.
activeWidget
is
not
None
calibrationWidget
=
self
.
activeWidget
if
"calibration"
in
calibrationWidget
.
infoDict
[
"label"
]:
self
.
NativeUI
.
q_send_cmd
(
"DO_CALIBRATION"
,
"DO_CALIBRATION"
)
elif
"Leak_Test"
in
calibrationWidget
.
infoDict
[
"label"
]:
self
.
NativeUI
.
q_send_cmd
()
else
:
logging
.
debug
(
"ERROR: label does not mach any calibration procedure"
)
# self.NativeUI.display_stack.setCurrentWidget(self.NativeUI.startupWidget)
calibrationWidget
.
progBar
.
setValue
(
100
)
calibrationWidget
.
lineEdit
.
setText
(
"completed"
)
with
open
(
"NativeUI/configs/maintenance_config.json"
,
"r"
)
as
json_file
:
startupDict
=
json
.
load
(
json_file
)
startupDict
[
calibrationWidget
.
key
][
"last_performed"
]
=
int
(
datetime
.
now
()
.
timestamp
()
)
with
open
(
"NativeUI/configs/maintenance_config.json"
,
"w"
)
as
json_file
:
json
.
dump
(
startupDict
,
json_file
)
self
.
MaintenanceConfigUpdate
.
emit
(
startupDict
)
logging
.
debug
(
"Writing to
%
s"
,
json_file
)
self
.
calibs_done_dict
[
calibrationWidget
.
key
]
=
True
return
0
def
localise_text
(
self
,
text
:
dict
)
->
int
:
"""
Change the language of text elements.
"""
pass
NativeUI/ui_layout.py
View file @
705d721d
...
...
@@ -411,13 +411,16 @@ class Layout:
# Create the system info tab
sysinfo_widgets
=
[
self
.
widgets
.
version_display_widget
,
self
.
widgets
.
maintenance_time_display_widget
,
self
.
widgets
.
maintenance
,
[
self
.
widgets
.
maintenance
,
self
.
widgets
.
maintenance_time_display_widget
],
self
.
widgets
.
update_time_display_widget
,
]
tab_info
=
self
.
layout_tab_info
(
sysinfo_widgets
)
for
widget
in
sysinfo_widgets
:
widget
.
setFont
(
self
.
NativeUI
.
text_font
)
for
entry
in
sysinfo_widgets
:
if
isinstance
(
entry
,
list
):
for
widget
in
entry
:
widget
.
setFont
(
self
.
NativeUI
.
text_font
)
else
:
entry
.
setFont
(
self
.
NativeUI
.
text_font
)
# Create the stack
page_settings
=
SwitchableStackWidget
(
...
...
@@ -527,8 +530,13 @@ class Layout:
"""
tab_info
=
LocalisedQWidget
()
tab_info_layout
=
QtWidgets
.
QVBoxLayout
(
tab_info
)
for
widget
in
widgets
:
tab_info_layout
.
addWidget
(
widget
)
for
entry
in
widgets
:
if
isinstance
(
entry
,
list
):
for
widget
in
entry
:
tab_info_layout
.
addWidget
(
widget
)
else
:
tab_info_layout
.
addWidget
(
entry
)
tab_info_layout
.
addStretch
()
tab_info
.
setLayout
(
tab_info_layout
)
return
tab_info
...
...
NativeUI/ui_widgets.py
View file @
705d721d
...
...
@@ -27,6 +27,7 @@ from global_widgets.global_spinbox import labelledSpin
from
global_widgets.global_send_popup
import
SetConfirmPopup
from
widget_library.localisation_button_widget
import
LocalisationButtonWidget
from
widget_library.startup_handler
import
StartupHandler
from
handler_library.maintenance_handler
import
MaintenanceHandler
from
widget_library.startup_calibration_widget
import
calibrationWidget
from
widget_library.ok_cancel_buttons_widget
import
(
OkButtonWidget
,
...
...
@@ -83,25 +84,31 @@ class Widgets:
# Start up procedure
self
.
startup_confirm_popup
=
SetConfirmPopup
(
NativeUI
)
self
.
maintenance_confirm_popup
=
SetConfirmPopup
(
NativeUI
)
self
.
startup_handler
=
StartupHandler
(
NativeUI
,
self
.
startup_confirm_popup
)
self
.
maintenance_handler
=
MaintenanceHandler
(
NativeUI
,
self
.
maintenance_confirm_popup
)
self
.
localisation_startup_button
=
LocalisedQPushButton
(
NativeUI
,
"language_name"
)
self
.
widget_list
=
self
.
widget_list
+
[
self
.
startup_confirm_popup
,
self
.
maintenance_confirm_popup
,
self
.
startup_handler
,
self
.
maintenance_handler
,
self
.
localisation_startup_button
,
]
if
not
os
.
path
.
isfile
(
"NativeUI/configs/startup_config.json"
):
logging
.
warning
(
"startup_config not found. If this is the first time using this ventilator you can safely ignore this warning."
"startup_config not found. If this is the first time using this "
"ventilator you can safely ignore this warning."
)
shutil
.
copyfile
(
"NativeUI/configs/startup_config_default.json"
,
"NativeUI/configs/startup_config.json"
,
)
with
open
(
"NativeUI/configs/startup_config.json"
)
as
json_file
:
startupDict
=
json
.
load
(
json_file
)
for
key
,
procedureDict
in
startupDict
.
items
():
...
...
@@ -111,6 +118,24 @@ class Widgets:
self
.
startup_handler
,
)
if
not
os
.
path
.
isfile
(
"NativeUI/configs/maintenance_config.json"
):
logging
.
warning
(
"maintenance_config not found. If this is the first time using this "
"ventilator you can safely ignore this warning."
)
shutil
.
copyfile
(
"NativeUI/configs/maintenance_config_default.json"
,
"NativeUI/configs/maintenance_config.json"
,
)
with
open
(
"NativeUI/configs/maintenance_config.json"
)
as
json_file
:
maintenanceDict
=
json
.
load
(
json_file
)
for
key
,
procedureDict
in
maintenanceDict
.
items
():
self
.
add_handled_widget
(
calibrationWidget
(
NativeUI
,
key
,
procedureDict
),
key
,
self
.
maintenance_handler
,
)
for
mode
in
NativeUI
.
modeList
:
self
.
add_handled_widget
(
LocalisedQRadioButton
(
mode
),
...
...
NativeUI/widget_library/info_display_widgets.py
View file @
705d721d
...
...
@@ -146,6 +146,11 @@ class MaintenanceTimeDisplayWidget(QtWidgets.QLabel):
self
.
setStyleSheet
(
"color:
%
s"
%
self
.
__normal_color
)
return
0
@
QtCore
.
Slot
(
dict
)
def
update_time
(
self
,
calib_dict
):
last_maintenance
=
calib_dict
[
"maintenance"
][
"last_performed"
]
print
(
last_maintenance
)
@
QtCore
.
Slot
(
str
,
str
,
bool
)
def
set_time_values
(
self
,
...
...
NativeUI/widget_library/startup_handler.py
View file @
705d721d
...
...
@@ -77,12 +77,12 @@ class StartupHandler(
def
carryout_calibration
(
self
)
->
int
:
assert
self
.
activeWidget
is
not
None
calibrationWidget
=
self
.
activeWidget
if
'calibration'
in
calibrationWidget
.
infoDict
[
'label'
]:
if
"calibration"
in
calibrationWidget
.
infoDict
[
"label"
]:
self
.
NativeUI
.
q_send_cmd
(
"DO_CALIBRATION"
,
"DO_CALIBRATION"
)
elif
'Leak_Test'
in
calibrationWidget
.
infoDict
[
'label'
]:
elif
"Leak_Test"
in
calibrationWidget
.
infoDict
[
"label"
]:
self
.
NativeUI
.
q_send_cmd
()
else
:
logging
.
debug
(
'ERROR: label does not mach any calibration procedure'
)
logging
.
debug
(
"ERROR: label does not mach any calibration procedure"
)
# self.NativeUI.display_stack.setCurrentWidget(self.NativeUI.startupWidget)
calibrationWidget
.
progBar
.
setValue
(
100
)
...
...
@@ -95,6 +95,7 @@ class StartupHandler(
)
with
open
(
"NativeUI/configs/startup_config.json"
,
"w"
)
as
json_file
:
json
.
dump
(
startupDict
,
json_file
)
logging
.
debug
(
"Writing to
%
s"
,
json_file
)
self
.
calibs_done_dict
[
calibrationWidget
.
key
]
=
True
if
self
.
all_calibs_done
():
...
...
@@ -110,9 +111,7 @@ class StartupHandler(
comparing the self.calibs_done_dict to the self.calibDict.
"""
for
key
in
self
.
calibDict
:
if
"maintenance"
in
key
:
pass
elif
key
not
in
self
.
calibs_done_dict
:
if
key
not
in
self
.
calibs_done_dict
:
return
False
return
True
...
...
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