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
09713e56
Commit
09713e56
authored
May 11, 2021
by
Tiago Sarmento
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixing and alarm popup click
parent
de2eb63b
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
304 additions
and
67 deletions
+304
-67
NativeUI.py
NativeUI/NativeUI.py
+13
-5
alarm_popup.py
NativeUI/alarm_widgets/alarm_popup.py
+4
-12
startup_config.json
NativeUI/configs/startup_config.json
+1
-1
global_send_popup.py
NativeUI/global_widgets/global_send_popup.py
+19
-8
global_spinbox.py
NativeUI/global_widgets/global_spinbox.py
+9
-6
global_typeval_popup.py
NativeUI/global_widgets/global_typeval_popup.py
+180
-4
mode_handler.py
NativeUI/mode_widgets/mode_handler.py
+5
-6
ui_layout.py
NativeUI/ui_layout.py
+5
-1
ui_widgets.py
NativeUI/ui_widgets.py
+15
-13
expert_handler.py
NativeUI/widget_library/expert_handler.py
+1
-1
line_edit_widget.py
NativeUI/widget_library/line_edit_widget.py
+14
-6
numpad_widget.py
NativeUI/widget_library/numpad_widget.py
+31
-0
spin_buttons_widget.py
NativeUI/widget_library/spin_buttons_widget.py
+6
-3
startup_handler.py
NativeUI/widget_library/startup_handler.py
+1
-1
No files found.
NativeUI/NativeUI.py
View file @
09713e56
...
...
@@ -58,8 +58,8 @@ 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
from
global_widgets.global_typeval_popup
import
TypeValuePopup
,
AbstractTypeValPopup
from
widget_library.numpad_widget
import
NumberpadWidget
,
AlphapadWidget
logging
.
basicConfig
(
level
=
logging
.
INFO
,
...
...
@@ -164,7 +164,8 @@ class NativeUI(HEVClient, QMainWindow):
self
.
alarm_handler
,
]
self
.
messageCommandPopup
=
SetConfirmPopup
(
self
)
self
.
typeValPopup
=
TypeValuePopup
(
self
)
self
.
typeValPopupNum
=
AbstractTypeValPopup
(
self
,
'numeric'
)
#TypeValuePopup(self, NumberpadWidget(self))
self
.
typeValPopupAlpha
=
AbstractTypeValPopup
(
self
,
'alpha'
)
#TypeValuePopup(self, AlphapadWidget(self))
# Create all of the widgets and place them in the layout.
self
.
widgets
=
Widgets
(
self
)
...
...
@@ -174,6 +175,7 @@ class NativeUI(HEVClient, QMainWindow):
# a time.
self
.
messageCommandPopup
=
SetConfirmPopup
(
self
)
self
.
confirmPopup
=
confirmPopup
(
self
,
self
)
self
.
confirmPopup
.
show
()
self
.
main_display
=
QWidget
(
self
)
self
.
main_display
.
setLayout
(
self
.
layouts
.
global_layout
())
self
.
startupWidget
=
QDialog
(
self
)
...
...
@@ -183,8 +185,10 @@ class NativeUI(HEVClient, QMainWindow):
self
.
display_stack
=
QStackedWidget
(
self
)
for
widget
in
[
self
.
typeValPopupNum
,
self
.
typeValPopupAlpha
,
self
.
messageCommandPopup
,
self
.
confirmPopup
,
#
self.confirmPopup,
self
.
main_display
,
self
.
startupWidget
,
]:
...
...
@@ -612,9 +616,13 @@ class NativeUI(HEVClient, QMainWindow):
logging
.
debug
(
"to MCU: cmd:
%
s"
,
cmd
)
check
=
self
.
send_cmd
(
cmdtype
=
cmdtype
,
cmd
=
cmd
,
param
=
param
)
if
check
:
print
(
'confirmed this command '
+
cmdtype
+
' '
+
cmd
)
self
.
confirmPopup
.
addConfirmation
(
cmdtype
+
" "
+
cmd
)
print
(
'added popup'
)
return
0
return
1
else
:
print
(
'failed this command '
+
cmdtype
+
' '
+
cmd
)
return
1
@
Slot
(
str
)
def
q_ack_alarm
(
self
,
alarm
:
str
)
->
int
:
...
...
NativeUI/alarm_widgets/alarm_popup.py
View file @
09713e56
...
...
@@ -63,12 +63,11 @@ class AlarmWidget(QtWidgets.QWidget):
# self.timer.setInterval(500) # just faster than 60Hz
# self.timer.timeout.connect(self.checkAlarm)
# self.timer.start()
#
self.installEventFilter(self)
self
.
installEventFilter
(
self
)
def
eventFilter
(
self
,
source
,
event
):
if
(
event
.
type
()
==
QtCore
.
QEvent
.
MouseButtonPress
):
self
.
NativeUI
.
leftBar
.
tab_page_buttons
.
button_alarms
.
click
()
self
.
NativeUI
.
alarms_view
.
alarmButton
.
click
()
self
.
NativeUI
.
widgets
.
page_buttons
.
alarms_button
.
click
()
return
False
def
get_priority
(
self
):
...
...
@@ -225,21 +224,14 @@ class AlarmExtrasWidget(QtWidgets.QWidget):
self
.
setLayout
(
self
.
layout
)
self
.
setStyleSheet
(
"background-color:red;"
)
#self.priority = "PRIORITY_LOW"
self
.
installEventFilter
(
self
)
def
update_text
(
self
,
num
):
self
.
textLabel
.
setText
(
str
(
num
)
+
' More Alarms'
)
#self.code =
# self.timer = QtCore.QTimer()
# self.timer.setInterval(500) # just faster than 60Hz
# self.timer.timeout.connect(self.checkAlarm)
# self.timer.start()
# self.installEventFilter(self)
def
eventFilter
(
self
,
source
,
event
):
if
(
event
.
type
()
==
QtCore
.
QEvent
.
MouseButtonPress
):
self
.
NativeUI
.
leftBar
.
tab_page_buttons
.
button_alarms
.
click
()
self
.
NativeUI
.
alarms_view
.
alarmButton
.
click
()
self
.
NativeUI
.
widgets
.
page_buttons
.
alarms_button
.
click
()
return
False
def
get_priority
(
self
):
...
...
NativeUI/configs/startup_config.json
View file @
09713e56
{
"calibration"
:
{
"label"
:
"calibration"
,
"last_performed"
:
162
1426912
,
"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"
}}
{
"calibration"
:
{
"label"
:
"calibration"
,
"last_performed"
:
162
0695901
,
"cmd_code"
:
"calib_rate"
},
"leak_test"
:
{
"label"
:
"Leak Test"
,
"last_performed"
:
1620695902
,
"cmd_code"
:
"leak_test"
},
"maintenance"
:
{
"label"
:
"maintenance"
,
"last_performed"
:
1620695905
,
"cmd_code"
:
"main_tenance"
}}
\ No newline at end of file
NativeUI/global_widgets/global_send_popup.py
View file @
09713e56
...
...
@@ -149,7 +149,7 @@ class confirmWidget(QtWidgets.QWidget):
self
.
setParent
(
None
)
class
confirmPopup
(
QtWidgets
.
Q
Widget
):
class
confirmPopup
(
QtWidgets
.
Q
Dialog
):
"""Popup when a command is confirmed by microcontroller.
This popup is a frame containing a confirmWidget object for
each successful command."""
...
...
@@ -159,15 +159,26 @@ class confirmPopup(QtWidgets.QWidget):
self
.
NativeUI
=
NativeUI
self
.
confirmDict
=
{}
self
.
vlayout
=
QtWidgets
.
QVBoxLayout
()
self
.
vlayout
.
setSpacing
(
0
)
self
.
vlayout
.
setMargin
(
0
)
self
.
setLayout
(
self
.
vlayout
)
self
.
setStyleSheet
(
"background-color:green;"
)
self
.
location_on_window
()
self
.
setWindowFlags
(
QtCore
.
Qt
.
FramelessWindowHint
|
QtCore
.
Qt
.
Dialog
|
QtCore
.
Qt
.
WindowStaysOnTopHint
)
# no window title
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
500
)
# just faster than 60Hz
self
.
timer
.
timeout
.
connect
(
self
.
adjustSize
)
self
.
timer
.
start
()
def
addConfirmation
(
self
,
confirmMessage
):
print
(
'adding confirmation'
)
"""Add a confirmation to the popup. Triggered when UI receives a confirmation from the microcontroller"""
self
.
confirmDict
[
confirmMessage
]
=
confirmWidget
(
self
.
NativeUI
,
confirmMessage
...
...
@@ -175,9 +186,9 @@ class confirmPopup(QtWidgets.QWidget):
self
.
vlayout
.
addWidget
(
self
.
confirmDict
[
confirmMessage
])
return
0
#
def location_on_window(self):
#
screen = QtWidgets.QDesktopWidget().screenGeometry()
#
# widget = self.geometry()
#
x = screen.width() - screen.width() / 2
#
y = 0 # screen.height() - widget.height()
#
self.move(x, y)
def
location_on_window
(
self
):
screen
=
QtWidgets
.
QDesktopWidget
()
.
screenGeometry
()
# widget = self.geometry()
x
=
screen
.
width
()
-
screen
.
width
()
/
2
y
=
0
# screen.height() - widget.height()
self
.
move
(
x
,
y
)
NativeUI/global_widgets/global_spinbox.py
View file @
09713e56
...
...
@@ -27,7 +27,7 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
manualChanged
=
QtCore
.
Signal
()
programmaticallyChanged
=
QtCore
.
Signal
()
def
__init__
(
self
,
NativeUI
,
label_text
,
min
,
max
,
initVal
,
step
,
decPlaces
):
def
__init__
(
self
,
NativeUI
,
popup
,
label_text
,
min
,
max
,
initVal
,
step
,
decPlaces
):
super
()
.
__init__
()
self
.
lineEdit
()
.
installEventFilter
(
self
)
self
.
editable
=
True
...
...
@@ -36,8 +36,9 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
self
.
setSingleStep
(
step
)
self
.
setDecimals
(
decPlaces
)
self
.
setValue
(
initVal
)
self
.
NativeUI
=
NativeUI
#self.populateVals = [label_text, min, max, initVal, step, decPlaces]
self
.
popUp
=
NativeUI
.
typeValP
opup
# TypeValuePopup(NativeUI, label_text, min, max, initVal, step, decPlaces)
self
.
popUp
=
p
opup
# TypeValuePopup(NativeUI, label_text, min, max, initVal, step, decPlaces)
#self.popUp.okButton.clicked.connect(self.okButtonPressed)
#self.popUp.cancelButton.clicked.connect(self.cancelButtonPressed)
...
...
@@ -78,8 +79,10 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
return
#self.popUp.lineEdit.setText(str(self.value()))
#self.popUp.lineEdit.setFocus()
self
.
popUp
.
populatePopup
(
self
)
self
.
popUp
.
show
()
self
.
popUp
.
populatePopup
(
self
,
self
.
NativeUI
.
display_stack
.
currentWidget
())
self
.
NativeUI
.
display_stack
.
setCurrentWidget
(
self
.
popUp
)
#self.popUp.show()
return
True
return
False
...
...
@@ -89,7 +92,7 @@ class labelledSpin(QtWidgets.QWidget):
It is created by an information array which indicates labels, units, command type and code for value setting,
and the range of permitted values"""
def
__init__
(
self
,
NativeUI
,
infoArray
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
popup
,
infoArray
,
*
args
,
**
kwargs
):
super
(
labelledSpin
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
...
...
@@ -122,7 +125,7 @@ class labelledSpin(QtWidgets.QWidget):
self
.
nameLabel
.
setFont
(
NativeUI
.
text_font
)
self
.
nameLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignRight
|
QtCore
.
Qt
.
AlignVCenter
)
self
.
simpleSpin
=
signallingSpinBox
(
NativeUI
,
self
.
label
,
self
.
min
,
self
.
max
,
self
.
initVal
,
self
.
step
,
self
.
decPlaces
)
self
.
simpleSpin
=
signallingSpinBox
(
NativeUI
,
popup
,
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)
...
...
NativeUI/global_widgets/global_typeval_popup.py
View file @
09713e56
...
...
@@ -17,14 +17,179 @@ 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
from
widget_library.numpad_widget
import
NumberpadWidget
,
AlphapadWidget
class
TypeValue
Popup
(
QtWidgets
.
QDialog
):
class
AbstractTypeVal
Popup
(
QtWidgets
.
QDialog
):
"""Popup takes user input to put in spin box. """
okPressed
=
QtCore
.
Signal
(
str
)
cancelPressed
=
QtCore
.
Signal
()
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
characterType
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
# 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
.
characterType
=
characterType
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
(
"QLineEdit{"
" background-color: white;"
" border-radius: 4px;"
"}"
"QLineEdit[colour = '0']{"
" color: green;"
"}"
"QLineEdit[colour = '1']{"
" color: rgb(144, 231, 211);"
"}"
"QLineEdit[colour = '2']{"
" color: red;"
"}"
)
self
.
lineEdit
.
setFont
(
NativeUI
.
text_font
)
self
.
lineEdit
.
setProperty
(
"colour"
,
"1"
)
self
.
lineEdit
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
lineEdit
.
saveVal
=
''
# self.lineEdit.text()
hlayout
=
QtWidgets
.
QHBoxLayout
()
if
characterType
==
'numeric'
:
self
.
lineEdit
.
setValidator
(
QtGui
.
QDoubleValidator
(
0.0
,
100.0
,
5
)
)
# ensures only doubles can be typed, do
#self.lineEdit.textEdited.connect(self.setTextColour(1))
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
)
hlayout
.
addWidget
(
self
.
decreaseButton
)
hlayout
.
addWidget
(
self
.
lineEdit
)
hlayout
.
addWidget
(
self
.
increaseButton
)
if
characterType
==
'alpha'
:
self
.
numberpad
=
AlphapadWidget
(
NativeUI
)
self
.
numberpad
.
numberPressed
.
connect
(
self
.
handle_alphapress
)
hlayout
.
addWidget
(
self
.
lineEdit
)
# grid.addWidget(self.lineEdit, 0, 0, 1, 2)
self
.
hlayout2
=
QtWidgets
.
QHBoxLayout
()
self
.
okButton
=
OkButtonWidget
(
NativeUI
)
self
.
okButton
.
setEnabled
(
True
)
self
.
okButton
.
pressed
.
connect
(
self
.
handle_ok_press
)
self
.
hlayout2
.
addWidget
(
self
.
okButton
)
# grid.addWidget(self.okButton, 1, 0)
self
.
cancelButton
=
CancelButtonWidget
(
NativeUI
)
self
.
cancelButton
.
setEnabled
(
True
)
self
.
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
((
self
.
hlayout2
))
self
.
setLayout
(
vlayout
)
self
.
setWindowFlags
(
QtCore
.
Qt
.
FramelessWindowHint
|
QtCore
.
Qt
.
WindowStaysOnTopHint
)
# no window title
def
handle_ok_press
(
self
):
val
=
self
.
lineEdit
.
text
()
if
self
.
characterType
==
'numeric'
:
val
=
float
(
val
)
self
.
NativeUI
.
display_stack
.
setCurrentWidget
(
self
.
return_stack_widget
)
if
val
!=
self
.
currentWidg
.
value
():
self
.
currentWidg
.
setValue
(
val
)
self
.
currentWidg
.
manualChanged
.
emit
()
def
populatePopup
(
self
,
currentWidg
,
return_widget
):
self
.
currentWidg
=
currentWidg
self
.
return_stack_widget
=
return_widget
if
self
.
characterType
==
'numeric'
:
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
else
:
self
.
label_text
=
currentWidg
.
label_text
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
handle_alphapress
(
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
.
isalpha
():
newText
=
oldText
+
symbol
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
()
class
TypeValuePopup
():
"""Popup takes user input to put in spin box. """
okPressed
=
QtCore
.
Signal
(
str
)
cancelPressed
=
QtCore
.
Signal
()
def
__init__
(
self
,
NativeUI
,
keyboard
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
#self.label_text = label_text
...
...
@@ -64,7 +229,7 @@ class TypeValuePopup(QtWidgets.QDialog):
)
# ensures only doubles can be typed, do
# self.lineEdit.textEdited.connect(self.setTextColour(1))
self
.
numberpad
=
NumberpadWidget
(
NativeUI
)
self
.
numberpad
=
keyboard
#
NumberpadWidget(NativeUI)
self
.
numberpad
.
numberPressed
.
connect
(
self
.
handle_numberpress
)
self
.
increaseButton
=
OkButtonWidget
(
NativeUI
)
...
...
@@ -137,6 +302,17 @@ class TypeValuePopup(QtWidgets.QDialog):
elif
symbol
==
'<'
:
self
.
lineEdit
.
setText
(
oldText
[
0
:
-
1
])
def
handle_alphapress
(
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
.
isalpha
():
newText
=
oldText
+
symbol
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
()
...
...
NativeUI/mode_widgets/mode_handler.py
View file @
09713e56
...
...
@@ -57,7 +57,6 @@ class ModeHandler(PayloadHandler):
outdict
[
key
]
=
target_data
[
key
]
except
KeyError
:
logging
.
debug
(
"Invalid key
%
s in measurement database"
,
key
)
self
.
UpdateModes
.
emit
(
outdict
)
return
0
...
...
@@ -68,7 +67,7 @@ class ModeHandler(PayloadHandler):
for
widget
in
self
.
spinDict
:
if
(
mode
in
widget
)
and
self
.
spinDict
[
widget
]
.
manuallyUpdated
:
setVal
=
self
.
spinDict
[
widget
]
.
get_value
()
setVal
=
round
(
setVal
,
widget
.
decPlaces
)
setVal
=
round
(
setVal
,
self
.
spinDict
[
widget
]
.
decPlaces
)
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
...
...
@@ -87,7 +86,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
)
setVal
=
round
(
setVal
,
self
.
mainSpinDict
[
widget
]
.
decPlaces
)
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
...
...
@@ -100,13 +99,15 @@ class ModeHandler(PayloadHandler):
# command sending should occur in handler
self
.
commandList
=
command
self
.
OpenPopup
.
emit
(
message
)
self
.
OpenPopup
.
emit
(
self
,
message
)
def
sendCommands
(
self
):
if
self
.
commandList
==
[]:
a
=
1
else
:
for
command
in
self
.
commandList
:
print
(
'sending commands'
)
print
(
command
)
self
.
NativeUI
.
q_send_cmd
(
*
command
)
self
.
modeSwitched
.
emit
(
self
.
activeMode
)
self
.
commandSent
()
...
...
@@ -167,10 +168,8 @@ class ModeHandler(PayloadHandler):
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 @
09713e56
...
...
@@ -680,7 +680,11 @@ class Layout:
vlayout
.
addLayout
(
hButtonLayout
)
return
expert_tab
passlock_stack
=
QtWidgets
.
QStackedWidget
()
passlock_stack
.
addWidget
(
self
.
NativeUI
.
widgets
.
expert_password_widget
)
passlock_stack
.
addWidget
(
expert_tab
)
#break this here
return
passlock_stack
#expert_tab
def
layout_main_spin_buttons
(
self
)
->
QtWidgets
.
QWidget
:
hlayout
=
QtWidgets
.
QHBoxLayout
()
...
...
NativeUI/ui_widgets.py
View file @
09713e56
...
...
@@ -61,7 +61,7 @@ from widget_library.ventilator_start_stop_buttons_widget import (
VentilatorStartStopButtonsWidget
,
)
from
widget_library.line_edit_widget
import
LabelledLineEditWidget
from
global_widgets.global_typeval_popup
import
TypeValuePopup
,
AbstractTypeValPopup
# from widget_library.NativeUI.expert_handler import ExpertHandler
# from mode_widgets.NativeUI.personal_handler import PersonalHandler
...
...
@@ -163,24 +163,24 @@ class Widgets:
attrName
=
"clinical_spin_"
+
setting
[
0
][
2
]
if
len
(
setting
)
==
1
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
0
]),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
[
0
]),
attrName
+
"_lim"
,
NativeUI
.
clinical_handler
,
)
if
len
(
setting
)
>=
2
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
0
]),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
[
0
]),
attrName
+
"_min"
,
NativeUI
.
clinical_handler
,
)
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
-
1
]),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
[
-
1
]),
attrName
+
"_max"
,
NativeUI
.
clinical_handler
,
)
if
len
(
setting
)
==
3
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
[
1
]),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
[
1
]),
attrName
+
"_set"
,
NativeUI
.
clinical_handler
,
)
...
...
@@ -209,8 +209,9 @@ class Widgets:
for
setting
in
modeDict
[
"settings"
]:
if
setting
[
0
]
in
modeDict
[
"mainPageSettings"
]:
attrName
=
"CURRENT_"
+
setting
[
2
]
#setting[3] = setting[3].replace('SET_TARGET_', 'SET_TARGET_CURRENT')
self
.
add_handled_widget
(
SpinButton
(
NativeUI
,
setting
),
attrName
,
NativeUI
.
mode_handler
SpinButton
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
),
attrName
,
NativeUI
.
mode_handler
)
self
.
add_handled_widget
(
...
...
@@ -237,13 +238,13 @@ class Widgets:
]
if
startup
==
"_startup"
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
targettedSetting
),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
targettedSetting
),
"spin_"
+
attrName
,
self
.
startup_handler
,
)
else
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
targettedSetting
),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
targettedSetting
),
"spin_"
+
attrName
,
NativeUI
.
mode_handler
,
)
...
...
@@ -290,26 +291,26 @@ class Widgets:
if
setting
[
0
]
in
textBoxes
:
if
startup
==
"startup_"
:
self
.
add_handled_widget
(
LabelledLineEditWidget
(
NativeUI
,
setting
),
LabelledLineEditWidget
(
NativeUI
,
NativeUI
.
typeValPopupAlpha
,
setting
),
"text_"
+
startup
+
attrName
,
self
.
startup_handler
,
)
else
:
self
.
add_handled_widget
(
LabelledLineEditWidget
(
NativeUI
,
setting
),
LabelledLineEditWidget
(
NativeUI
,
NativeUI
.
typeValPopupAlpha
,
setting
),
"text_"
+
startup
+
attrName
,
NativeUI
.
personal_handler
,
)
else
:
if
startup
==
"startup_"
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
),
"spin_"
+
startup
+
attrName
,
self
.
startup_handler
,
)
else
:
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
),
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
),
"spin_"
+
startup
+
attrName
,
NativeUI
.
personal_handler
,
)
...
...
@@ -329,6 +330,7 @@ class Widgets:
)
##### Settings Tab: Expert and Charts tabs
self
.
add_widget
(
AbstractTypeValPopup
(
NativeUI
,
'numeric'
),
'expert_password_widget'
)
# Expert Tab
# self.expert_confirm_popup = SetConfirmPopup(NativeUI)
...
...
@@ -343,7 +345,7 @@ class Widgets:
for
setting
in
controlDict
[
key
]:
attrName
=
"expert_spin_"
+
setting
[
2
]
self
.
add_handled_widget
(
labelledSpin
(
NativeUI
,
setting
),
attrName
,
NativeUI
.
expert_handler
labelledSpin
(
NativeUI
,
NativeUI
.
typeValPopupNum
,
setting
),
attrName
,
NativeUI
.
expert_handler
)
self
.
add_handled_widget
(
...
...
NativeUI/widget_library/expert_handler.py
View file @
09713e56
...
...
@@ -47,7 +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
)
setVal
=
round
(
setVal
,
self
.
spindict
[
widget
]
.
decPlaces
)
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
...
...
NativeUI/widget_library/line_edit_widget.py
View file @
09713e56
...
...
@@ -5,10 +5,12 @@ from global_widgets.global_typeval_popup import TypeValuePopup
class
SignallingLineEditWidget
(
QtWidgets
.
QLineEdit
):
manualChanged
=
QtCore
.
Signal
()
def
__init__
(
self
,
NativeUI
):
def
__init__
(
self
,
NativeUI
,
popup
,
label
):
super
()
.
__init__
()
self
.
installEventFilter
(
self
)
self
.
label_text
=
label
self
.
NativeUI
=
NativeUI
self
.
popUp
=
popup
#NativeUI.typeValPopupAlpha
#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)
...
...
@@ -26,14 +28,20 @@ class SignallingLineEditWidget(QtWidgets.QLineEdit):
def
eventFilter
(
self
,
source
,
event
):
if
source
is
self
and
event
.
type
()
==
QtCore
.
QEvent
.
MouseButtonDblClick
:
self
.
popUp
.
lineEdit
.
setText
(
str
(
self
.
text
()
))
self
.
popUp
.
show
(
)
self
.
popUp
.
populatePopup
(
self
,
self
.
NativeUI
.
display_stack
.
currentWidget
(
))
self
.
NativeUI
.
display_stack
.
setCurrentWidget
(
self
.
popUp
)
return
True
return
False
def
value
(
self
):
return
self
.
text
()
def
setValue
(
self
,
value
):
self
.
setText
(
str
(
value
))
class
LabelledLineEditWidget
(
QtWidgets
.
QWidget
):
def
__init__
(
self
,
NativeUI
,
infoArray
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
popup
,
infoArray
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
# print(infoArray)
self
.
NativeUI
=
NativeUI
...
...
@@ -59,7 +67,7 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
self
.
nameLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignRight
)
widgetList
.
append
(
self
.
nameLabel
)
self
.
simpleSpin
=
SignallingLineEditWidget
(
NativeUI
)
self
.
simpleSpin
=
SignallingLineEditWidget
(
NativeUI
,
popup
,
self
.
label
)
self
.
simpleSpin
.
setText
(
self
.
initText
)
self
.
simpleSpin
.
setStyleSheet
(
"""QDoubleSpinBox{ width:100px; font:16pt}
...
...
NativeUI/widget_library/numpad_widget.py
View file @
09713e56
...
...
@@ -45,6 +45,37 @@ class NumberpadWidget(QtWidgets.QWidget):
self
.
setLayout
(
grid
)
def
buttonPressed
(
self
,
symbol
:
str
):
"""Emit a signal with the button's character"""
self
.
numberPressed
.
emit
(
symbol
)
class
AlphapadWidget
(
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
=
[
'Q'
,
'W'
,
'E'
,
'R'
,
'T'
,
'Y'
,
'U'
,
'I'
,
'O'
,
'P'
,
'A'
,
'S'
,
'D'
,
'F'
,
'G'
,
'H'
,
'J'
,
'K'
,
'L'
,
'Z'
,
'X'
,
'C'
,
'V'
,
'B'
,
'N'
,
'M'
,
'<'
]
newLineCharacters
=
[
'P'
,
'L'
]
button_dict
=
{}
grid
=
QtWidgets
.
QGridLayout
()
ncolumns
=
3
i
=
0
j
=
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
],
j
,
i
)
i
=
i
+
1
if
symbol
in
newLineCharacters
:
i
=
0
j
=
j
+
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 @
09713e56
...
...
@@ -27,7 +27,7 @@ from global_widgets.global_spinbox import signallingSpinBox
class
SpinButton
(
QtWidgets
.
QFrame
):
"""TO DO: Implement command sending"""
def
__init__
(
self
,
NativeUI
,
infoArray
):
def
__init__
(
self
,
NativeUI
,
popup
,
infoArray
):
super
()
.
__init__
()
self
.
manuallyUpdated
=
False
...
...
@@ -37,6 +37,9 @@ class SpinButton(QtWidgets.QFrame):
self
.
label_text
,
self
.
units
,
self
.
tag
,
self
.
cmd_type
,
self
.
cmd_code
,
self
.
min
,
self
.
max
,
self
.
initVal
,
self
.
step
,
self
.
decPlaces
=
(
infoArray
)
#print('before')
#print(self.cmd_type)
self
.
cmd_type
=
self
.
cmd_type
.
replace
(
'SET_TARGET_'
,
'SET_TARGET_CURRENT'
)
#self.cmd_type = settings[3]
#self.cmd_code = settings[4]
#self.tag = settings[2]
...
...
@@ -63,7 +66,7 @@ class SpinButton(QtWidgets.QFrame):
self
.
layout
.
addWidget
(
self
.
label
)
#self.setFont(NativeUI.text_font)
self
.
simpleSpin
=
signallingSpinBox
(
NativeUI
,
self
.
label_text
,
self
.
min
,
self
.
max
,
self
.
initVal
,
self
.
step
,
self
.
decPlaces
)
self
.
simpleSpin
=
signallingSpinBox
(
NativeUI
,
popup
,
self
.
label_text
,
self
.
min
,
self
.
max
,
self
.
initVal
,
self
.
step
,
self
.
decPlaces
)
self
.
simpleSpin
.
lineEdit
()
.
setStyleSheet
(
"border:blue;"
)
# self.simpleSpin.setFixedHeight(100)
# self.simpleSpin.setFont(NativeUI.text_font)
...
...
@@ -121,7 +124,7 @@ class SpinButton(QtWidgets.QFrame):
self
.
simpleSpin
.
setValue
(
newVal
[
self
.
tag
])
self
.
setTextColour
(
1
)
else
:
if
int
(
self
.
simpleSpin
.
value
())
==
int
(
newVal
[
self
.
tag
]
):
if
round
(
self
.
simpleSpin
.
value
(),
self
.
decPlaces
)
==
round
(
newVal
[
self
.
tag
],
self
.
decPlaces
):
self
.
manuallyUpdated
=
False
self
.
setTextColour
(
1
)
...
...
NativeUI/widget_library/startup_handler.py
View file @
09713e56
...
...
@@ -102,7 +102,7 @@ class StartupHandler(
message
,
command
=
[],
[]
for
widget
in
self
.
spinDict
:
setVal
=
self
.
spinDict
[
widget
]
.
get_value
()
setVal
=
round
(
setVal
,
widget
.
decPlaces
)
setVal
=
round
(
setVal
,
self
.
spinDict
[
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