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
8bf9bf16
Commit
8bf9bf16
authored
May 17, 2021
by
Benjamin Mummery
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added 'info' page with placeholders for version info, time since maintenance, and time since update
parent
59491a40
Pipeline
#1548
failed with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
357 additions
and
68 deletions
+357
-68
NativeUI.py
NativeUI/NativeUI.py
+9
-0
ui_layout.py
NativeUI/ui_layout.py
+52
-23
ui_widgets.py
NativeUI/ui_widgets.py
+86
-45
info_display_widgets.py
NativeUI/widget_library/info_display_widgets.py
+210
-0
No files found.
NativeUI/NativeUI.py
View file @
8bf9bf16
...
...
@@ -179,6 +179,8 @@ class NativeUI(HEVClient, QMainWindow):
palette
.
setColor
(
QPalette
.
Window
,
self
.
colors
[
"page_background"
])
self
.
setPalette
(
palette
)
self
.
setAutoFillBackground
(
True
)
self
.
widgets
.
version_display_widget
.
update_UI_version
(
__version__
)
self
.
widgets
.
version_display_widget
.
update_UI_hash
(
self
.
__get_hash
())
self
.
startupWidget
=
QDialog
(
self
)
self
.
startupWidget
.
setLayout
(
self
.
layouts
.
startup_layout
())
...
...
@@ -192,6 +194,13 @@ class NativeUI(HEVClient, QMainWindow):
# Update page buttons to match the shown view
self
.
widgets
.
page_buttons
.
buttons
[
0
]
.
on_press
()
def
__get_hash
(
self
)
->
str
:
"""
Get the hash of the current commit.
"""
repo
=
git
.
Repo
(
search_parent_directories
=
True
)
return
repo
.
head
.
object
.
hexsha
def
__define_connections
(
self
)
->
int
:
"""
Connect the signals and slots necessary for the UI to function.
...
...
NativeUI/ui_layout.py
View file @
8bf9bf16
...
...
@@ -15,7 +15,8 @@ __email__ = "benjamin.mummery@stfc.ac.uk"
__status__
=
"Prototype"
from
PySide2
import
QtWidgets
,
QtCore
,
QtGui
#from PySide2.QtGui import QFont, QSizePolicy
# from PySide2.QtGui import QFont, QSizePolicy
from
widget_library.switchable_stack_widget
import
SwitchableStackWidget
import
json
...
...
@@ -86,7 +87,7 @@ class Layout:
self
.
layout_startup_main
(),
self
.
layout_mode_startup
(),
# self, settings, mode:str, enableList:list, buttons: bool)
self
.
layout_mode_personal
(
"startup_"
,
False
),
self
.
layout_startup_confirmation
()
self
.
layout_startup_confirmation
()
,
]
),
"startup_stack"
,
...
...
@@ -309,11 +310,21 @@ class Layout:
self
.
left_bar_width
,
None
,
spacing
=
self
.
widget_spacing
)
# Create the system info tab
sysinfo_widgets
=
[
self
.
widgets
.
version_display_widget
,
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
)
# Create the stack
page_settings
=
SwitchableStackWidget
(
self
.
NativeUI
,
[
self
.
layout_settings_expert
(),
tab_charts
],
[
"Expert"
,
"Charts"
],
[
self
.
layout_settings_expert
(),
tab_charts
,
tab_info
],
[
"Expert"
,
"Charts"
,
"Info"
],
)
page_settings
.
setFont
(
self
.
NativeUI
.
text_font
)
self
.
widgets
.
add_widget
(
page_settings
,
"setting_stack"
)
...
...
@@ -393,6 +404,9 @@ class Layout:
return
tab_main_detailed
def
layout_tab_charts
(
self
,
widgets
:
list
)
->
QtWidgets
.
QWidget
:
"""
Construct the layout for the charts page.
"""
tab_charts
=
QtWidgets
.
QWidget
()
tab_charts_layout
=
QtWidgets
.
QHBoxLayout
(
tab_charts
)
for
widget
in
widgets
:
...
...
@@ -400,6 +414,17 @@ class Layout:
tab_charts
.
setLayout
(
tab_charts_layout
)
return
tab_charts
def
layout_tab_info
(
self
,
widgets
:
list
)
->
QtWidgets
.
QWidget
:
"""
Construct the layout for the info page.
"""
tab_info
=
QtWidgets
.
QWidget
()
tab_info_layout
=
QtWidgets
.
QVBoxLayout
(
tab_info
)
for
widget
in
widgets
:
tab_info_layout
.
addWidget
(
widget
)
tab_info
.
setLayout
(
tab_info_layout
)
return
tab_info
def
__make_stack
(
self
,
widgets
):
"""
Make a stack of widgets
...
...
@@ -533,7 +558,9 @@ class Layout:
hRadioLayout
=
QtWidgets
.
QHBoxLayout
()
for
mode
in
self
.
NativeUI
.
modeList
:
hRadioLayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
'startup_radio_'
+
mode
))
hRadioLayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
"startup_radio_"
+
mode
)
)
vlayout
=
QtWidgets
.
QVBoxLayout
()
vlayout
.
addWidget
(
mode_stack
)
...
...
@@ -658,23 +685,23 @@ class Layout:
modeDict
=
json
.
load
(
json_file
)
stack
=
self
.
NativeUI
.
widgets
.
main_mode_stack
for
setting
in
modeDict
[
'settings'
]:
if
setting
[
0
]
in
modeDict
[
'mainPageSettings'
]:
attrName
=
'CURRENT_'
+
setting
[
2
]
for
setting
in
modeDict
[
"settings"
]:
if
setting
[
0
]
in
modeDict
[
"mainPageSettings"
]:
attrName
=
"CURRENT_"
+
setting
[
2
]
widg
=
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
)
if
setting
[
0
]
in
modeDict
[
'radioSettings'
]:
if
setting
[
0
]
in
modeDict
[
"radioSettings"
]:
stack
.
addWidget
(
widg
)
else
:
hlayout
.
addWidget
(
widg
)
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
main_mode_stack
)
vbuttonLayout
=
QtWidgets
.
QVBoxLayout
()
okButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
'CURRENT_ok_button'
)
okButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
vbuttonLayout
=
QtWidgets
.
QVBoxLayout
()
okButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
"CURRENT_ok_button"
)
okButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
vbuttonLayout
.
addWidget
(
okButton
)
cancelButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
'CURRENT_cancel_button'
)
cancelButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
cancelButton
=
self
.
NativeUI
.
widgets
.
get_widget
(
"CURRENT_cancel_button"
)
cancelButton
.
setSizePolicy
(
QtGui
.
QSizePolicy
.
Expanding
,
QtGui
.
QSizePolicy
.
Fixed
)
vbuttonLayout
.
addWidget
(
cancelButton
)
hlayout
.
addLayout
(
vbuttonLayout
)
...
...
@@ -687,16 +714,18 @@ class Layout:
clinicalDict
=
json
.
load
(
json_file
)
vlayout
=
QtWidgets
.
QVBoxLayout
()
for
setting
in
clinicalDict
[
'settings'
]:
attrName
=
'clinical_spin_'
+
setting
[
0
][
2
]
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'
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_min"
))
hlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
+
"_max"
))
vlayout
.
addLayout
(
hlayout
)
hbuttonlayout
=
QtWidgets
.
QHBoxLayout
()
hbuttonlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
'clinical_ok_button'
))
hbuttonlayout
.
addWidget
(
self
.
NativeUI
.
widgets
.
get_widget
(
'clinical_cancel_button'
))
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)
...
...
@@ -740,7 +769,9 @@ class Layout:
def
layout_startup_confirmation
(
self
):
vlayout
=
QtWidgets
.
QVBoxLayout
()
i
=
0
for
key
,
spinBox
in
self
.
NativeUI
.
widgets
.
get_widget
(
'startup_handler'
)
.
spinDict
.
items
():
for
key
,
spinBox
in
self
.
NativeUI
.
widgets
.
get_widget
(
"startup_handler"
)
.
spinDict
.
items
():
i
=
i
+
1
hlayout
=
QtWidgets
.
QHBoxLayout
()
nameLabel
=
QtWidgets
.
QLabel
(
key
)
...
...
@@ -751,8 +782,6 @@ class Layout:
if
i
==
10
:
break
widg
=
QtWidgets
.
QWidget
()
widg
.
setLayout
(
vlayout
)
return
widg
NativeUI/ui_widgets.py
View file @
8bf9bf16
...
...
@@ -13,7 +13,14 @@ __maintainer__ = "Benjamin Mummery"
__email__
=
"benjamin.mummery@stfc.ac.uk"
__status__
=
"Prototype"
from
PySide2.QtWidgets
import
QWidget
,
QPushButton
,
QRadioButton
,
QButtonGroup
,
QLabel
,
QStackedWidget
from
PySide2.QtWidgets
import
(
QWidget
,
QPushButton
,
QRadioButton
,
QButtonGroup
,
QLabel
,
QStackedWidget
,
)
from
global_widgets.tab_modeswitch_button
import
TabModeswitchButton
from
global_widgets.global_spinbox
import
labelledSpin
from
global_widgets.global_send_popup
import
SetConfirmPopup
...
...
@@ -31,6 +38,11 @@ from widget_library.measurements_widget import (
ExpertMeasurementsBloackWidget
,
)
from
widget_library.battery_display_widget
import
BatteryDisplayWidget
from
widget_library.info_display_widgets
import
(
VersionDisplayWidget
,
MaintenanceTimeDisplayWidget
,
UpdateTimeDisplayWidget
,
)
# from widget_library.tab_charts import TabChart
from
widget_library.chart_buttons_widget
import
ChartButtonsWidget
...
...
@@ -49,6 +61,7 @@ from widget_library.ventilator_start_stop_buttons_widget import (
VentilatorStartStopButtonsWidget
,
)
from
widget_library.line_edit_widget
import
LabelledLineEditWidget
# from widget_library.NativeUI.expert_handler import ExpertHandler
# from mode_widgets.NativeUI.personal_handler import PersonalHandler
...
...
@@ -125,8 +138,10 @@ class Widgets:
)
# Main Page Widgets
#self.spin_buttons = SpinButtonsWidget(NativeUI)
self
.
add_handled_widget
(
SpinButtonsWidget
(
NativeUI
),
'spin_buttons'
,
NativeUI
.
mode_handler
)
# self.spin_buttons = SpinButtonsWidget(NativeUI)
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
)
...
...
@@ -139,8 +154,6 @@ class Widgets:
self
.
alarm_popup
=
AlarmPopup
(
NativeUI
)
self
.
alarm_list
=
AlarmList
(
NativeUI
)
self
.
acknowledge_button
=
QPushButton
()
# self.alarm_table_tab = TabAlarmTable(NativeUI)
self
.
alarm_table
=
AlarmTable
(
NativeUI
)
self
.
clinical_tab
=
QWidget
()
# TabClinical(NativeUI)
...
...
@@ -148,35 +161,47 @@ class Widgets:
with
open
(
"NativeUI/configs/clinical_config.json"
)
as
json_file
:
clinicalDict
=
json
.
load
(
json_file
)
#radioSettings = modeDict["radioSettings"]
#modes = NativeUI.modeList
#
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'
# 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']:
#
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:
#
else:
# self.add_handled_widget(labelledSpin(NativeUI, setting), attrName, NativeUI.clinical_handler)
self
.
add_handled_widget
(
OkButtonWidget
(
NativeUI
),
'clinical_ok_button'
,
NativeUI
.
clinical_handler
)
self
.
add_handled_widget
(
CancelButtonWidget
(
NativeUI
),
'clinical_cancel_button'
,
NativeUI
.
clinical_handler
)
self
.
add_handled_widget
(
OkButtonWidget
(
NativeUI
),
"clinical_ok_button"
,
NativeUI
.
clinical_handler
)
self
.
add_handled_widget
(
CancelButtonWidget
(
NativeUI
),
"clinical_cancel_button"
,
NativeUI
.
clinical_handler
,
)
#### Mode settings tab: Mode (x4), Personal
# Modes Page Widgets
#self.mode_confirm_popup = SetConfirmPopup(NativeUI)
#NativeUI.mode_handler = ModeHandler(NativeUI, self.mode_confirm_popup)
#
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
)
...
...
@@ -184,14 +209,22 @@ class Widgets:
radioSettings
=
modeDict
[
"radioSettings"
]
modes
=
NativeUI
.
modeList
self
.
add_handled_widget
(
QStackedWidget
(),
'main_mode_stack'
,
NativeUI
.
mode_handler
)
for
setting
in
modeDict
[
'settings'
]:
if
setting
[
0
]
in
modeDict
[
'mainPageSettings'
]:
attrName
=
'CURRENT_'
+
setting
[
2
]
self
.
add_handled_widget
(
SpinButton
(
NativeUI
,
setting
),
attrName
,
NativeUI
.
mode_handler
)
self
.
add_handled_widget
(
QStackedWidget
(),
"main_mode_stack"
,
NativeUI
.
mode_handler
)
for
setting
in
modeDict
[
"settings"
]:
if
setting
[
0
]
in
modeDict
[
"mainPageSettings"
]:
attrName
=
"CURRENT_"
+
setting
[
2
]
self
.
add_handled_widget
(
SpinButton
(
NativeUI
,
setting
),
attrName
,
NativeUI
.
mode_handler
)
self
.
add_handled_widget
(
OkButtonWidget
(
NativeUI
),
'CURRENT_ok_button'
,
NativeUI
.
mode_handler
)
self
.
add_handled_widget
(
CancelButtonWidget
(
NativeUI
),
'CURRENT_cancel_button'
,
NativeUI
.
mode_handler
)
self
.
add_handled_widget
(
OkButtonWidget
(
NativeUI
),
"CURRENT_ok_button"
,
NativeUI
.
mode_handler
)
self
.
add_handled_widget
(
CancelButtonWidget
(
NativeUI
),
"CURRENT_cancel_button"
,
NativeUI
.
mode_handler
)
self
.
groupDict
=
{}
for
mode
in
modes
:
...
...
@@ -226,21 +259,18 @@ class Widgets:
self
.
groupDict
[
mode
+
startup
]
.
addButton
(
radioButton
)
if
startup
==
"_startup"
:
self
.
add_handled_widget
(
radioButton
,
"radio_"
+
attrName
,
self
.
startup_handler
,
radioButton
,
"radio_"
+
attrName
,
self
.
startup_handler
)
else
:
self
.
add_handled_widget
(
radioButton
,
"radio_"
+
attrName
,
NativeUI
.
mode_handler
,
radioButton
,
"radio_"
+
attrName
,
NativeUI
.
mode_handler
)
if
startup
!=
"_startup"
:
self
.
add_handled_widget
(
OkButtonWidget
(
NativeUI
),
"ok_button_"
+
mode
,
NativeUI
.
mode_handler
OkButtonWidget
(
NativeUI
),
"ok_button_"
+
mode
,
NativeUI
.
mode_handler
,
)
self
.
add_handled_widget
(
OkSendButtonWidget
(
NativeUI
),
...
...
@@ -254,8 +284,8 @@ class Widgets:
)
# Personal tab widgets
#self.personal_confirm_popup = SetConfirmPopup(NativeUI)
#NativeUI.personal_handler = PersonalHandler(NativeUI, self.personal_confirm_popup)
#
self.personal_confirm_popup = SetConfirmPopup(NativeUI)
#
NativeUI.personal_handler = PersonalHandler(NativeUI, self.personal_confirm_popup)
with
open
(
"NativeUI/configs/personal_config.json"
)
as
json_file
:
personalDict
=
json
.
load
(
json_file
)
...
...
@@ -307,8 +337,8 @@ class Widgets:
##### Settings Tab: Expert and Charts tabs
# Expert Tab
#self.expert_confirm_popup = SetConfirmPopup(NativeUI)
#NativeUI.expert_handler = ExpertHandler(NativeUI, self.expert_confirm_popup)
#
self.expert_confirm_popup = SetConfirmPopup(NativeUI)
#
NativeUI.expert_handler = ExpertHandler(NativeUI, self.expert_confirm_popup)
print
(
os
.
listdir
())
with
open
(
"NativeUI/configs/expert_config.json"
)
as
json_file
:
controlDict
=
json
.
load
(
json_file
)
...
...
@@ -326,16 +356,27 @@ class Widgets:
OkButtonWidget
(
NativeUI
),
"ok_button_expert"
,
NativeUI
.
expert_handler
)
self
.
add_handled_widget
(
OkSendButtonWidget
(
NativeUI
),
"ok_send_button_expert"
,
NativeUI
.
expert_handler
OkSendButtonWidget
(
NativeUI
),
"ok_send_button_expert"
,
NativeUI
.
expert_handler
,
)
self
.
add_handled_widget
(
CancelButtonWidget
(
NativeUI
),
"cancel_button_expert"
,
NativeUI
.
expert_handler
CancelButtonWidget
(
NativeUI
),
"cancel_button_expert"
,
NativeUI
.
expert_handler
,
)
# Chart Tab
self
.
charts_widget
=
ChartsPlotWidget
(
colors
=
NativeUI
.
colors
)
self
.
chart_buttons_widget
=
ChartButtonsWidget
(
colors
=
NativeUI
.
colors
)
# Info Tab
self
.
version_display_widget
=
VersionDisplayWidget
(
NativeUI
.
colors
)
self
.
maintenance_time_display_widget
=
MaintenanceTimeDisplayWidget
(
NativeUI
.
colors
)
self
.
update_time_display_widget
=
UpdateTimeDisplayWidget
(
NativeUI
.
colors
)
def
add_widget
(
self
,
widget
,
name
)
->
int
:
setattr
(
self
,
name
,
widget
)
return
0
...
...
NativeUI/widget_library/info_display_widgets.py
0 → 100644
View file @
8bf9bf16
#!/usr/bin/env python3
"""
info_display_widgets.py
Simple widgets to display various system information parameters including version
number(s), time since last maintenance, and time since last update.
"""
__author__
=
[
"Benjamin Mummery"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__license__
=
"GPL"
__version__
=
"0.1.0"
__maintainer__
=
"Benjamin Mummery"
__email__
=
"benjamin.mummery@stfc.ac.uk"
__status__
=
"Development"
import
logging
from
PySide2
import
QtCore
,
QtWidgets
class
VersionDisplayWidget
(
QtWidgets
.
QLabel
):
"""
Widget that displays the current version number.
We don't need to override setFont as long as we're just subclassing the QLabel
widget. If we later expand this class to include more complexity, we'll have to add
setFont as a method to propogate the font to any subwidgets.
"""
def
__init__
(
self
,
colors
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
__mcu_version
:
str
=
"???"
self
.
__mcu_hash
:
str
=
None
self
.
__ui_version
:
str
=
"???"
self
.
__ui_hash
:
str
=
None
self
.
setStyleSheet
(
"background-color:"
+
colors
[
"page_background"
]
.
name
()
+
";"
"border: none;"
"color:"
+
colors
[
"page_foreground"
]
.
name
()
+
";"
)
self
.
__refresh_display
()
def
__refresh_display
(
self
)
->
int
:
"""
Update the display to show the current values of __ui_version and __mcu_version.
"""
display_text
=
""
display_text
+=
"MCU Software Version:
%
s"
%
self
.
__mcu_version
if
self
.
__mcu_hash
is
not
None
:
display_text
+=
" (
%
s)"
%
self
.
__mcu_hash
display_text
+=
"<br>UI Software Version:
%
s"
%
self
.
__ui_version
if
self
.
__ui_hash
is
not
None
:
display_text
+=
" (
%
s)"
%
self
.
__ui_hash
self
.
setText
(
display_text
)
return
0
@
QtCore
.
Slot
(
str
)
def
update_UI_version
(
self
,
version
:
str
)
->
int
:
"""
Update the value shown for the UI version
"""
self
.
__ui_version
=
version
self
.
__refresh_display
()
return
0
@
QtCore
.
Slot
(
str
)
def
update_UI_hash
(
self
,
hash
:
str
)
->
int
:
"""
Update the value shown for the UI hash
"""
self
.
__ui_hash
=
hash
self
.
__refresh_display
()
return
0
@
QtCore
.
Slot
(
str
)
def
update_mcu_version
(
self
,
version
:
str
)
->
int
:
"""
Update the value shown for the MCU version
"""
self
.
__mcu_version
=
version
self
.
__refresh_display
()
return
0
@
QtCore
.
Slot
(
str
)
def
update_mcu_version
(
self
,
hash
:
str
)
->
int
:
"""
Update the value shown for the MCU hash
"""
self
.
__mcu_hash
=
hash
self
.
__refresh_display
()
return
0
def
set_size
(
self
,
x
:
int
,
y
:
int
)
->
int
:
"""
Set the size of the widget.
"""
self
.
setFixedSize
(
x
,
y
)
return
0
class
MaintenanceTimeDisplayWidget
(
QtWidgets
.
QLabel
):
"""
Widget that displays the time since the last maintenance.
"""
def
__init__
(
self
,
colors
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
__time_since_maintenance
:
str
=
"???"
self
.
__time_to_maintenance
:
str
=
"???"
self
.
__maintenance_needed
:
bool
=
True
self
.
__normal_color
=
colors
[
"page_foreground"
]
.
name
()
self
.
__alert_color
=
colors
[
"red"
]
.
name
()
self
.
setStyleSheet
(
"background-color:"
+
colors
[
"page_background"
]
.
name
()
+
";"
"border: none;"
"color:"
+
self
.
__normal_color
+
";"
)
self
.
__refresh_display
()
def
__refresh_display
(
self
)
->
int
:
"""
Update the display to show the current values of time to, and since,
maintenance.
"""
self
.
setText
(
"
%
s since last maintenance. Maintenance due in
%
s."
%
(
self
.
__time_since_maintenance
,
self
.
__time_to_maintenance
)
)
if
self
.
__maintenance_needed
:
self
.
setStyleSheet
(
"color:
%
s"
%
self
.
__alert_color
)
else
:
self
.
setStyleSheet
(
"color:
%
s"
%
self
.
__normal_color
)
return
0
@
QtCore
.
Slot
(
str
,
str
,
bool
)
def
set_time_values
(
self
,
time_since_maintenance
:
str
,
time_to_maintenance
:
str
,
maintenance_needed
:
bool
,
)
->
int
:
"""
set the time since and to maintenance, and whether maintenance is needed.
"""
self
.
__time_since_maintenance
=
time_since_maintenance
self
.
__time_to_maintenance
=
time_to_maintenance
self
.
__maintenance_needed
=
maintenance_needed
return
self
.
__refresh_display
()
class
UpdateTimeDisplayWidget
(
QtWidgets
.
QLabel
):
"""
Widget that displays the time since the last update.
"""
def
__init__
(
self
,
colors
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
__time_since_update
:
str
=
"???"
self
.
__time_to_update_check
:
str
=
"???"
self
.
__update_check_needed
:
bool
=
True
self
.
__normal_color
=
colors
[
"page_foreground"
]
.
name
()
self
.
__alert_color
=
colors
[
"red"
]
.
name
()
self
.
setStyleSheet
(
"background-color:"
+
colors
[
"page_background"
]
.
name
()
+
";"
"border: none;"
"color:"
+
self
.
__normal_color
+
";"
)
self
.
__refresh_display
()
def
__refresh_display
(
self
)
->
int
:
"""
Update the display to show the current values of time to, and since,
update.
"""
self
.
setText
(
"
%
s since last update. Check for updates due in
%
s."
%
(
self
.
__time_since_update
,
self
.
__time_to_update_check
)
)
if
self
.
__update_check_needed
:
self
.
setStyleSheet
(
"color:
%
s"
%
self
.
__alert_color
)
else
:
self
.
setStyleSheet
(
"color:
%
s"
%
self
.
__normal_color
)
return
0
@
QtCore
.
Slot
(
str
,
str
,
bool
)
def
set_time_values
(
self
,
time_since_update
:
str
,
time_to_update_check
:
str
,
update_check_needed
:
bool
,
)
->
int
:
"""
set the time since and to maintenance, and whether maintenance is needed.
"""
self
.
__time_since_update
=
time_since_update
self
.
__time_to_update_check
=
time_to_update_check
self
.
__update_check_needed
=
update_check_needed
return
self
.
__refresh_display
()
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