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
9f2e14e7
Commit
9f2e14e7
authored
May 19, 2021
by
Benjamin Mummery
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Full-screen startup procedure
parent
6bbf2d58
Pipeline
#1556
canceled with stages
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
53 deletions
+102
-53
NativeUI.py
NativeUI/NativeUI.py
+15
-11
startup_config.json
NativeUI/configs/startup_config.json
+1
-1
ui_layout.py
NativeUI/ui_layout.py
+24
-15
ui_widgets.py
NativeUI/ui_widgets.py
+2
-2
startup_handler.py
NativeUI/widget_library/startup_handler.py
+60
-24
No files found.
NativeUI/NativeUI.py
View file @
9f2e14e7
...
...
@@ -12,7 +12,7 @@ Command-line arguments:
__author__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__license__
=
"GPL"
__version__
=
"0.
0
.1"
__version__
=
"0.
1
.1"
__maintainer__
=
"Benjamin Mummery"
__email__
=
"benjamin.mummery@stfc.ac.uk"
__status__
=
"Prototype"
...
...
@@ -201,7 +201,7 @@ class NativeUI(HEVClient, QMainWindow):
self
.
__define_connections
()
# Update page buttons to match the shown view
self
.
display_stack
.
setCurrentWidget
(
self
.
messageCommandPopup
)
self
.
display_stack
.
setCurrentWidget
(
self
.
startupWidget
)
self
.
widgets
.
page_buttons
.
buttons
[
0
]
.
on_press
()
def
__find_localisation_files
(
self
,
config_path
:
str
)
->
list
:
...
...
@@ -284,20 +284,24 @@ class NativeUI(HEVClient, QMainWindow):
i
,
j
)
)
# TODO: command sending
self
.
widgets
.
nextButton
.
pressed
.
connect
(
lambda
i
=
self
.
widgets
.
startup_stack
:
self
.
widgets
.
startup_handler
.
handle_nextbutton
(
i
)
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
main_display
)
)
self
.
widgets
.
skipButton
.
pressed
.
connect
(
self
.
widgets
.
startup_handler
.
handle_sendbutton
)
self
.
widgets
.
backButton
.
pressed
.
connect
(
lambda
i
=
self
.
widgets
.
startup_stack
:
self
.
widgets
.
startup_handler
.
handle_backbutton
(
i
)
lambda
:
self
.
display_stack
.
setCurrentWidget
(
self
.
main_display
)
)
# self.widgets.skipButton.pressed.connect(
# self.widgets.startup_handler.handle_sendbutton
# )
# self.widgets.backButton.pressed.connect(
# lambda i=self.widgets.startup_stack: self.widgets.startup_handler.handle_backbutton(
# i
# )
# )
# Battery Display should update when we get battery info
self
.
battery_handler
.
UpdateBatteryDisplay
.
connect
(
self
.
widgets
.
battery_display
.
update_status
...
...
NativeUI/configs/startup_config.json
View file @
9f2e14e7
{
"calibration"
:
{
"label"
:
"calibration"
,
"last_performed"
:
1618759676
,
"cmd_code"
:
"calib_rate"
},
"leak_test"
:
{
"label"
:
"Leak Test"
,
"last_performed"
:
1618758793
,
"cmd_code"
:
"leak_test"
},
"maintenance"
:
{
"label"
:
"maintenance"
,
"last_performed"
:
1618753313
,
"cmd_code"
:
"main_tenance"
}}
\ No newline at end of file
{
"calibration"
:
{
"label"
:
"calibration"
,
"last_performed"
:
1621420941
,
"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"
}}
NativeUI/ui_layout.py
View file @
9f2e14e7
...
...
@@ -76,32 +76,41 @@ class Layout:
return
0
def
startup_layout
(
self
):
vlayout
=
QtWidgets
.
QVBoxLayout
()
with
open
(
"NativeUI/configs/mode_config.json"
)
as
json_file
:
modeDict
=
json
.
load
(
json_file
)
v
_
layout
=
QtWidgets
.
QVBoxLayout
()
h_layout
=
QtWidgets
.
QHBoxLayout
()
h_button_layout
=
QtWidgets
.
QHBoxLayout
(
)
#
Define the stack of pages (used by the page buttons to set the current page)
#
Stack the data collection pages.
self
.
widgets
.
add_widget
(
self
.
__make_stack
(
SwitchableStackWidget
(
self
.
NativeUI
,
[
self
.
layout_startup_main
(),
self
.
layout_mode_startup
(),
# self, settings, mode:str, enableList:list, buttons: bool)
self
.
layout_mode_startup
(),
self
.
layout_mode_personal
(
"startup_"
,
False
),
self
.
layout_startup_confirmation
(),
]
],
[
"Mode Settings"
,
"Personal Settings"
,
"Summary"
],
),
"startup_stack"
,
)
self
.
widgets
.
startup_stack
.
setFont
(
self
.
NativeUI
.
text_font
)
vlayout
.
addWidget
(
self
.
widgets
.
startup_stack
)
hButtonLayout
=
QtWidgets
.
QHBoxLayout
()
hButtonLayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
backButton
)
hButtonLayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
skipButton
)
hButtonLayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
nextButton
)
vlayout
.
addLayout
(
hButtonLayout
)
# Add buttons
h_button_layout
.
addWidget
(
self
.
NativeUI
.
widgets
.
backButton
)
h_button_layout
.
addWidget
(
self
.
NativeUI
.
widgets
.
skipButton
)
h_button_layout
.
addWidget
(
self
.
NativeUI
.
widgets
.
nextButton
)
return
vlayout
# Put the layouts together
h_layout
.
addWidget
(
self
.
layout_startup_main
())
h_layout
.
addWidget
(
self
.
widgets
.
startup_stack
)
v_layout
.
addLayout
(
h_layout
)
v_layout
.
addLayout
(
h_button_layout
)
# Ensure that next and skip buttons are disabled by default.
self
.
NativeUI
.
widgets
.
skipButton
.
setEnabled
(
False
)
self
.
NativeUI
.
widgets
.
nextButton
.
setEnabled
(
False
)
return
v_layout
def
layout_startup_main
(
self
):
vlayout
=
QtWidgets
.
QVBoxLayout
()
...
...
NativeUI/ui_widgets.py
View file @
9f2e14e7
...
...
@@ -114,11 +114,11 @@ class Widgets:
self
.
add_handled_widget
(
OkButtonWidget
(
NativeUI
),
"nextButton"
,
self
.
startup_handler
)
self
.
nextButton
.
setColour
(
1
)
self
.
nextButton
.
setColour
(
0
)
self
.
add_handled_widget
(
OkSendButtonWidget
(
NativeUI
),
"skipButton"
,
self
.
startup_handler
)
self
.
skipButton
.
setColour
(
1
)
self
.
skipButton
.
setColour
(
0
)
self
.
add_handled_widget
(
CancelButtonWidget
(
NativeUI
),
"backButton"
,
self
.
startup_handler
)
...
...
NativeUI/widget_library/startup_handler.py
View file @
9f2e14e7
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
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
class
StartupHandler
(
QtWidgets
.
QWidget
):
# chose QWidget over QDialog family because easier to modify
class
StartupHandler
(
QtWidgets
.
QWidget
):
# chose QWidget over QDialog family because easier to modify
UpdateModes
=
QtCore
.
Signal
(
dict
)
OpenPopup
=
QtCore
.
Signal
(
list
)
...
...
@@ -21,14 +28,19 @@ class StartupHandler(QtWidgets.QWidget): # chose QWidget over QDialog family be
self
.
calibDict
=
{}
self
.
modeRadioDict
=
{}
self
.
settingsRadioDict
=
{}
self
.
calibs_done_dict
=
{}
def
add_widget
(
self
,
widget
,
key
:
str
):
if
isinstance
(
widget
,
labelledSpin
):
self
.
spinDict
[
key
]
=
widget
widget
.
cmd_type
=
widget
.
cmd_type
.
replace
(
'startup'
,
'CURRENT'
)
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
):
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
:
...
...
@@ -43,23 +55,48 @@ class StartupHandler(QtWidgets.QWidget): # chose QWidget over QDialog family be
def
handle_settings_radiobutton
(
self
,
radioButtonState
,
radioKey
):
"""TODO Docstring"""
mode
=
self
.
get_mode
(
radioKey
)
spinKey
=
radioKey
.
replace
(
'radio'
,
'spin'
)
spinKey
=
radioKey
.
replace
(
"radio"
,
"spin"
)
spinBox
=
self
.
spinDict
[
spinKey
]
spinBox
.
setEnabled
(
radioButtonState
)
if
mode
==
self
.
NativeUI
.
currentMode
:
self
.
settingToggle
.
emit
(
spinBox
.
label
)
def
handle_calibrationPress
(
self
,
calibrationWidget
):
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.
"""
calibrationWidget
.
progBar
.
setValue
(
100
)
calibrationWidget
.
lineEdit
.
setText
(
'completed'
)
calibrationWidget
.
lineEdit
.
setText
(
"completed"
)
with
open
(
'NativeUI/configs/startup_config.json'
,
'r'
)
as
json_file
:
with
open
(
"NativeUI/configs/startup_config.json"
,
"r"
)
as
json_file
:
startupDict
=
json
.
load
(
json_file
)
startupDict
[
calibrationWidget
.
key
][
'last_performed'
]
=
int
(
datetime
.
now
()
.
timestamp
())
with
open
(
'NativeUI/configs/startup_config.json'
,
'w'
)
as
json_file
:
startupDict
[
calibrationWidget
.
key
][
"last_performed"
]
=
int
(
datetime
.
now
()
.
timestamp
()
)
with
open
(
"NativeUI/configs/startup_config.json"
,
"w"
)
as
json_file
:
json
.
dump
(
startupDict
,
json_file
)
self
.
calibs_done_dict
[
calibrationWidget
.
key
]
=
True
if
self
.
all_calibs_done
():
for
key
in
[
"nextButton"
,
"skipButton"
]:
self
.
buttonDict
[
key
]
.
setEnabled
(
True
)
self
.
buttonDict
[
key
]
.
setColour
(
1
)
return
0
def
all_calibs_done
(
self
)
->
bool
:
"""
Check if all required calibrations are complete. For now this is as simple as
comparing the self.calibs_done_dict to the self.calibDict.
"""
for
key
in
self
.
calibDict
:
if
key
not
in
self
.
calibs_done_dict
:
return
False
return
True
def
handle_sendbutton
(
self
):
message
,
command
=
[],
[]
...
...
@@ -67,11 +104,7 @@ class StartupHandler(QtWidgets.QWidget): # chose QWidget over QDialog family be
setVal
=
self
.
spinDict
[
widget
]
.
get_value
()
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
self
.
spinDict
[
widget
]
.
cmd_type
,
self
.
spinDict
[
widget
]
.
cmd_code
,
setVal
,
]
[
self
.
spinDict
[
widget
]
.
cmd_type
,
self
.
spinDict
[
widget
]
.
cmd_code
,
setVal
]
)
for
com
in
command
:
self
.
NativeUI
.
q_send_cmd
(
*
com
)
...
...
@@ -79,27 +112,30 @@ class StartupHandler(QtWidgets.QWidget): # chose QWidget over QDialog family be
"SET_MODE"
,
self
.
NativeUI
.
currentMode
.
replace
(
"/"
,
"_"
)
.
replace
(
"-"
,
"_"
)
)
def
handle_nextbutton
(
self
,
stack
):
def
handle_nextbutton
(
self
,
stack
)
->
int
:
"""
Handle the pressing of the nextbutton
"""
currentIndex
=
stack
.
currentIndex
()
nextIndex
=
currentIndex
+
1
totalLength
=
stack
.
count
()
stack
.
setCurrentIndex
(
nextIndex
)
if
nextIndex
==
totalLength
-
1
:
self
.
buttonDict
[
'nextButton'
]
.
setColour
(
0
)
if
nextIndex
==
totalLength
-
1
:
self
.
buttonDict
[
"nextButton"
]
.
setColour
(
0
)
else
:
self
.
buttonDict
[
'nextButton'
]
.
setColour
(
1
)
self
.
buttonDict
[
'backButton'
]
.
setColour
(
1
)
self
.
buttonDict
[
"nextButton"
]
.
setColour
(
1
)
self
.
buttonDict
[
"backButton"
]
.
setColour
(
1
)
def
handle_backbutton
(
self
,
stack
):
print
(
"backbutton pressed"
)
currentIndex
=
stack
.
currentIndex
()
nextIndex
=
currentIndex
-
1
stack
.
setCurrentIndex
(
nextIndex
)
if
nextIndex
==
0
:
self
.
buttonDict
[
'backButton'
]
.
setColour
(
0
)
self
.
buttonDict
[
"backButton"
]
.
setColour
(
0
)
else
:
self
.
buttonDict
[
'backButton'
]
.
setColour
(
1
)
self
.
buttonDict
[
'nextButton'
]
.
setColour
(
1
)
self
.
buttonDict
[
"backButton"
]
.
setColour
(
1
)
self
.
buttonDict
[
"nextButton"
]
.
setColour
(
1
)
def
get_mode
(
self
,
key
:
str
):
for
mode
in
self
.
NativeUI
.
modeList
:
...
...
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