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
e06401f0
Commit
e06401f0
authored
Mar 02, 2021
by
Tiago Sarmento
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implement hold buttons
parent
39c9c9f5
Pipeline
#997
failed
Changes
8
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
183 additions
and
40 deletions
+183
-40
alarm_popup.py
NativeUI/alarm_widgets/alarm_popup.py
+9
-4
global_ok_cancel_buttons.py
NativeUI/global_widgets/global_ok_cancel_buttons.py
+8
-6
global_send_popup.py
NativeUI/global_widgets/global_send_popup.py
+0
-5
global_spinbox.py
NativeUI/global_widgets/global_spinbox.py
+12
-3
tab_hold_buttons.py
NativeUI/global_widgets/tab_hold_buttons.py
+126
-0
tab_page_buttons.py
NativeUI/global_widgets/tab_page_buttons.py
+4
-1
tab_start_stop_buttons.py
NativeUI/global_widgets/tab_start_stop_buttons.py
+7
-5
tab_spin_buttons.py
NativeUI/main_widgets/tab_spin_buttons.py
+17
-16
No files found.
NativeUI/alarm_widgets/alarm_popup.py
View file @
e06401f0
...
...
@@ -3,10 +3,11 @@ from PySide2 import QtCore, QtGui, QtWidgets
class
alarmWidget
(
QtWidgets
.
QWidget
):
def
__init__
(
self
,
NativeUI
,
alarmPayload
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
alarmPayload
,
alarmCarrier
,
*
args
,
**
kwargs
):
super
(
alarmWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
alarmCarrier
=
alarmCarrier
self
.
layout
=
QtWidgets
.
QHBoxLayout
()
self
.
layout
.
setSpacing
(
0
)
...
...
@@ -35,12 +36,16 @@ class alarmWidget(QtWidgets.QWidget):
self
.
setStyleSheet
(
"background-color:orange;"
)
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
500
0
)
# just faster than 60Hz
self
.
timer
.
setInterval
(
500
)
# just faster than 60Hz
self
.
timer
.
timeout
.
connect
(
self
.
checkAlarm
)
self
.
timer
.
start
()
def
checkAlarm
(
self
):
self
.
parent
()
.
alarmDict
.
pop
(
self
.
alarmPayload
[
"alarm_code"
])
self
.
ongoingAlarms
=
self
.
NativeUI
.
ongoingAlarms
for
alarm
in
self
.
ongoingAlarms
:
if
self
.
alarmPayload
[
"alarm_code"
]
==
alarm
[
"alarm_code"
]:
return
self
.
alarmCarrier
.
alarmDict
.
pop
(
self
.
alarmPayload
[
"alarm_code"
])
self
.
setParent
(
None
)
...
...
@@ -81,7 +86,7 @@ class alarmPopup(QtWidgets.QDialog):
def
addAlarm
(
self
,
alarmPayload
):
self
.
alarmDict
[
alarmPayload
[
"alarm_code"
]]
=
alarmWidget
(
self
.
NativeUI
,
alarmPayload
self
.
NativeUI
,
alarmPayload
,
self
)
self
.
layout
.
addWidget
(
self
.
alarmDict
[
alarmPayload
[
"alarm_code"
]])
...
...
NativeUI/global_widgets/global_ok_cancel_buttons.py
View file @
e06401f0
...
...
@@ -12,14 +12,15 @@ class okButton(
# set icon color
pixmap
=
QtGui
.
QPixmap
(
iconpath_check
)
mask
=
pixmap
.
mask
()
pixmap
.
fill
(
NativeUI
.
colors
[
"
fore
ground"
])
pixmap
.
fill
(
NativeUI
.
colors
[
"
back
ground"
])
pixmap
.
setMask
(
mask
)
self
.
setIcon
(
QtGui
.
QIcon
(
pixmap
))
self
.
setStyleSheet
(
"background-color: "
+
NativeUI
.
colors
[
"
background-enable
d"
]
.
name
()
+
";"
"color: "
+
NativeUI
.
colors
[
"
fore
ground"
]
.
name
()
+
";"
"background-color: "
+
NativeUI
.
colors
[
"
foregroun
d"
]
.
name
()
+
";"
"color: "
+
NativeUI
.
colors
[
"
back
ground"
]
.
name
()
+
";"
"border-color: "
+
NativeUI
.
colors
[
"foreground"
]
.
name
()
+
";"
"border-radius: 8px;"
"border:none"
)
...
...
@@ -37,14 +38,15 @@ class cancelButton(
# set icon color
pixmap
=
QtGui
.
QPixmap
(
iconpath_cross
)
mask
=
pixmap
.
mask
()
pixmap
.
fill
(
NativeUI
.
colors
[
"
fore
ground"
])
pixmap
.
fill
(
NativeUI
.
colors
[
"
back
ground"
])
pixmap
.
setMask
(
mask
)
self
.
setIcon
(
QtGui
.
QIcon
(
pixmap
))
self
.
setStyleSheet
(
"background-color: "
+
NativeUI
.
colors
[
"
background-enable
d"
]
.
name
()
+
";"
"color: "
+
NativeUI
.
colors
[
"
fore
ground"
]
.
name
()
+
";"
"background-color: "
+
NativeUI
.
colors
[
"
foregroun
d"
]
.
name
()
+
";"
"color: "
+
NativeUI
.
colors
[
"
back
ground"
]
.
name
()
+
";"
"border-color: "
+
NativeUI
.
colors
[
"foreground"
]
.
name
()
+
";"
"border-radius: 8px;"
"border:none"
)
...
...
NativeUI/global_widgets/global_send_popup.py
View file @
e06401f0
...
...
@@ -11,11 +11,6 @@ class SetConfirmPopup(
super
()
.
__init__
(
*
args
,
**
kwargs
)
# self.setStyleSheet("background-color:rgba(255,0,255,50%);color:rgb(0,255,0)")
# if NativeUI is None:
# iconpath = "hev-display/svg/check-solid.svg"
# else:
# iconpath_check = os.path.join(NativeUI.iconpath, "check-solid.png")
# iconpath_cross = os.path.join(NativeUI.iconpath, "times-solid.png")
self
.
NativeUI
=
NativeUI
if
setList
==
[]:
setList
=
[
"no values were set"
]
...
...
NativeUI/global_widgets/global_spinbox.py
View file @
e06401f0
...
...
@@ -25,6 +25,7 @@ class signallingSpinBox(QtWidgets.QDoubleSpinBox):
def
stepBy
(
self
,
step
):
value
=
self
.
value
()
self
.
prevValue
=
value
super
(
signallingSpinBox
,
self
)
.
stepBy
(
step
)
if
self
.
value
()
!=
value
:
self
.
manualChanged
.
emit
()
...
...
@@ -47,10 +48,12 @@ class labelledSpin(QtWidgets.QWidget):
self
.
NativeUI
=
NativeUI
self
.
template
=
template
self
.
cmd_type
,
self
.
cmd_code
=
""
,
""
self
.
min
,
self
.
max
,
self
.
step
=
0
,
10000
,
0.3
self
.
min
,
self
.
max
,
self
.
step
=
0
,
10000
,
0.3
self
.
decPlaces
=
2
if
len
(
infoArray
)
==
9
:
self
.
label
,
self
.
units
,
self
.
tag
,
self
.
cmd_type
,
self
.
cmd_code
,
self
.
min
,
self
.
max
,
self
.
step
,
self
.
decPlaces
=
infoArray
self
.
label
,
self
.
units
,
self
.
tag
,
self
.
cmd_type
,
self
.
cmd_code
,
self
.
min
,
self
.
max
,
self
.
step
,
self
.
decPlaces
=
(
infoArray
)
elif
len
(
infoArray
)
==
5
:
self
.
label
,
self
.
units
,
self
.
tag
,
self
.
cmd_type
,
self
.
cmd_code
=
infoArray
elif
len
(
infoArray
)
==
3
:
...
...
@@ -105,9 +108,15 @@ class labelledSpin(QtWidgets.QWidget):
# self.simpleSpin.valueChanged.connect(self.valChange)
def
manualStep
(
self
):
if
self
.
manuallyUpdated
!=
True
:
self
.
oldValue
=
self
.
simpleSpin
.
prevValue
self
.
template
.
liveUpdating
=
False
self
.
manuallyUpdated
=
True
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
if
self
.
simpleSpin
.
value
()
!=
self
.
oldValue
:
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
else
:
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
self
.
manuallyUpdated
=
False
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
def
update_readback_value
(
self
):
...
...
NativeUI/global_widgets/tab_hold_buttons.py
0 → 100644
View file @
e06401f0
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
from
global_widgets.global_ok_cancel_buttons
import
okButton
,
cancelButton
import
time
class
timerConfirmPopup
(
QtWidgets
.
QWidget
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
timerConfirmPopup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
setAttribute
(
QtCore
.
Qt
.
WA_ShowWithoutActivating
)
self
.
setWindowFlags
(
QtCore
.
Qt
.
WindowStaysOnTopHint
|
QtCore
.
Qt
.
FramelessWindowHint
)
# ensures focus is not stolen by alarm or confirmation
self
.
setStyleSheet
(
"background-color: "
+
NativeUI
.
colors
[
"background-enabled"
]
.
name
()
+
";"
"color: "
+
NativeUI
.
colors
[
"foreground"
]
.
name
()
+
";"
"border-color: "
+
NativeUI
.
colors
[
"foreground"
]
.
name
()
+
";"
"border:none"
)
self
.
stack
=
QtWidgets
.
QStackedWidget
()
vlayout
=
QtWidgets
.
QVBoxLayout
()
self
.
label
=
QtWidgets
.
QLabel
(
"progressing"
)
vlayout
.
addWidget
(
self
.
label
)
self
.
progressBar
=
QtWidgets
.
QProgressBar
()
self
.
progressBar
.
setMaximum
(
3000
)
self
.
progressBar
.
setFormat
(
""
)
# self.progressBar
vlayout
.
addWidget
(
self
.
progressBar
)
self
.
progressWidg
=
QtWidgets
.
QWidget
()
self
.
progressWidg
.
setLayout
(
vlayout
)
self
.
stack
.
addWidget
(
self
.
progressWidg
)
# self.setLayout(vlayout)
self
.
completeLayout
=
QtWidgets
.
QVBoxLayout
()
self
.
completeLabel
=
QtWidgets
.
QLabel
(
"confirm it"
)
buttonLayout
=
QtWidgets
.
QHBoxLayout
()
self
.
okButton
=
okButton
(
NativeUI
)
buttonLayout
.
addWidget
(
self
.
okButton
)
self
.
cancelButton
=
cancelButton
(
NativeUI
)
buttonLayout
.
addWidget
(
self
.
cancelButton
)
self
.
completeLayout
.
addWidget
(
self
.
completeLabel
)
self
.
completeLayout
.
addLayout
(
buttonLayout
)
self
.
completeWidg
=
QtWidgets
.
QWidget
()
self
.
completeWidg
.
setLayout
(
self
.
completeLayout
)
self
.
stack
.
addWidget
(
self
.
completeWidg
)
stackLayout
=
QtWidgets
.
QVBoxLayout
()
stackLayout
.
addWidget
(
self
.
stack
)
self
.
setLayout
(
stackLayout
)
class
holdButton
(
QtWidgets
.
QPushButton
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
holdButton
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
timeOut
=
3000
self
.
timeStep
=
60
self
.
setAutoRepeat
(
True
)
self
.
setAutoRepeatDelay
(
self
.
timeStep
)
self
.
setAutoRepeatInterval
(
self
.
timeStep
)
self
.
pressTime
=
0
self
.
state
=
0
self
.
complete
=
False
self
.
clicked
.
connect
(
self
.
handleClick
)
self
.
popUp
=
timerConfirmPopup
(
NativeUI
)
self
.
popUp
.
okButton
.
pressed
.
connect
(
self
.
okButtonPressed
)
self
.
popUp
.
cancelButton
.
pressed
.
connect
(
self
.
closePopup
)
def
handleClick
(
self
):
self
.
now
=
time
.
time
()
if
self
.
state
==
0
:
# print('pressed')
self
.
popUp
.
show
()
self
.
initial
=
time
.
time
()
if
self
.
isDown
():
if
self
.
pressTime
==
self
.
timeOut
:
self
.
complete
=
True
print
(
self
.
now
-
self
.
initial
)
self
.
popUp
.
stack
.
setCurrentWidget
(
self
.
popUp
.
completeWidg
)
self
.
pressTime
=
self
.
pressTime
+
self
.
timeStep
self
.
state
=
1
self
.
popUp
.
progressBar
.
setValue
(
self
.
pressTime
)
self
.
popUp
.
progressBar
.
update
()
else
:
self
.
pressTime
=
0
print
(
"aa"
)
print
(
self
.
complete
)
print
(
self
.
state
)
if
self
.
state
==
1
:
print
(
"released"
)
if
not
self
.
complete
:
self
.
popUp
.
close
()
self
.
state
=
0
def
okButtonPressed
(
self
):
self
.
NativeUI
.
q_send_cmd
(
"GENERAL"
,
self
.
text
())
self
.
closePopup
()
def
closePopup
(
self
):
self
.
popUp
.
progressBar
.
setValue
(
0
)
self
.
popUp
.
stack
.
setCurrentWidget
(
self
.
popUp
.
progressWidg
)
self
.
popUp
.
close
()
if
__name__
==
"__main__"
:
import
sys
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
widg
=
holdButton
(
"Standby"
)
widg
.
show
()
sys
.
exit
(
app
.
exec_
())
NativeUI/global_widgets/tab_page_buttons.py
View file @
e06401f0
...
...
@@ -60,7 +60,10 @@ class TabPageButtons(QtWidgets.QWidget):
"background-color: "
+
NativeUI
.
colors
[
"background-enabled"
]
.
name
()
+
";"
"border-color: "
+
NativeUI
.
colors
[
"background"
]
.
name
()
+
";"
+
"border-color: "
+
NativeUI
.
colors
[
"background"
]
.
name
()
+
";"
+
"border:none;"
"}"
"QPushButton:disabled{"
"background-color: "
...
...
NativeUI/global_widgets/tab_start_stop_buttons.py
View file @
e06401f0
...
...
@@ -4,6 +4,7 @@ TODO
import
logging
from
PySide2
import
QtGui
,
QtWidgets
from
PySide2.QtCore
import
QSize
from
global_widgets.tab_hold_buttons
import
holdButton
class
TabStartStopStandbyButtons
(
QtWidgets
.
QWidget
):
...
...
@@ -23,15 +24,17 @@ class TabStartStopStandbyButtons(QtWidgets.QWidget):
layout
=
QtWidgets
.
QVBoxLayout
()
self
.
button_start
=
QtWidgets
.
QPushButton
()
self
.
button_stop
=
QtWidgets
.
QPushButton
()
self
.
button_standby
=
QtWidgets
.
QPushButton
()
self
.
button_start
=
holdButton
(
NativeUI
)
#
QtWidgets.QPushButton()
self
.
button_stop
=
holdButton
(
NativeUI
)
#
QtWidgets.QPushButton()
self
.
button_standby
=
holdButton
(
NativeUI
)
#
QtWidgets.QPushButton()
self
.
__buttons
=
[
self
.
button_start
,
self
.
button_stop
,
self
.
button_standby
]
self
.
__buttontext
=
[
"START"
,
"STOP"
,
"STANDBY"
]
self
.
__buttoncommand
=
[
""
]
for
button
,
text
in
zip
(
self
.
__buttons
,
self
.
__buttontext
):
button
.
setText
(
text
)
button
.
popUp
.
completeLabel
.
setText
(
"Ventilation "
+
text
)
layout
.
addWidget
(
button
)
button
.
setStyleSheet
(
"background-color: "
...
...
@@ -39,8 +42,7 @@ class TabStartStopStandbyButtons(QtWidgets.QWidget):
+
";"
"border-color: "
+
NativeUI
.
colors
[
"foreground"
]
.
name
()
+
";"
"font-size: 20pt;"
"color: "
+
NativeUI
.
colors
[
"foreground"
]
.
name
()
+
";"
+
"border:none"
"color: "
+
NativeUI
.
colors
[
"foreground"
]
.
name
()
+
";"
+
"border:none"
)
button
.
setFixedSize
(
self
.
__button_size
)
...
...
NativeUI/main_widgets/tab_spin_buttons.py
View file @
e06401f0
...
...
@@ -6,6 +6,7 @@ from global_widgets.global_typeval_popup import TypeValuePopup
from
global_widgets.global_ok_cancel_buttons
import
okButton
,
cancelButton
from
global_widgets.global_spinbox
import
signallingSpinBox
class
SpinButton
(
QtWidgets
.
QFrame
):
def
__init__
(
self
,
NativeUI
):
super
()
.
__init__
()
...
...
@@ -91,7 +92,6 @@ class SpinButton(QtWidgets.QFrame):
def
manualChanged
(
self
):
self
.
liveUpdating
=
False
def
eventFilter
(
self
,
source
,
event
):
if
(
source
is
self
.
doubleSpin
.
lineEdit
()
...
...
@@ -133,12 +133,12 @@ class TabSpinButtons(QtWidgets.QWidget):
self
.
__spins
=
[
self
.
spinInsp
,
self
.
spinRR
,
self
.
spinFIo2
,
self
.
spinInhaleT
]
self
.
__labels
=
[
"in
halation
_pressure"
,
"in
spiratory
_pressure"
,
"respiratory_rate"
,
"fiO2_percent"
,
"
lung_complianc
e"
,
"
inhale_tim
e"
,
]
for
spin
,
label
in
zip
(
self
.
__spins
,
self
.
__labels
):
for
spin
,
label
in
zip
(
self
.
__spins
,
self
.
__labels
):
spin
.
label
.
setText
(
label
)
self
.
layout
.
addWidget
(
spin
)
...
...
@@ -159,22 +159,23 @@ class TabSpinButtons(QtWidgets.QWidget):
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
160
)
self
.
timer
.
timeout
.
connect
(
self
.
update
Cycle
)
self
.
timer
.
timeout
.
connect
(
self
.
update
targets
)
self
.
timer
.
start
()
def
update
Cycle
(
self
):
cycle
=
self
.
NativeUI
.
get_cycle
_db
()
if
cycle
==
{}:
def
update
targets
(
self
):
targets
=
self
.
NativeUI
.
get_targets
_db
()
if
targets
==
{}:
return
for
spin
,
label
in
zip
(
self
.
__spins
,
self
.
__labels
):
if
spin
.
doubleSpin
.
value
()
!=
float
(
cycle
[
label
]):
if
spin
.
liveUpdating
:
spin
.
doubleSpin
.
setValue
(
float
(
cycle
[
label
]))
spin
.
setTextColour
(
"2"
)
if
targets
[
"mode"
]
==
"CURRENT"
:
for
spin
,
label
in
zip
(
self
.
__spins
,
self
.
__labels
):
if
spin
.
doubleSpin
.
value
()
!=
float
(
targets
[
label
]):
if
spin
.
liveUpdating
:
spin
.
doubleSpin
.
setValue
(
float
(
targets
[
label
]))
spin
.
setTextColour
(
"2"
)
else
:
spin
.
setTextColour
(
"0"
)
else
:
spin
.
setTextColour
(
"0"
)
else
:
spin
.
setTextColour
(
"2"
)
spin
.
setTextColour
(
"2"
)
def
ok_button_pressed
(
self
):
for
spin
in
self
.
__spins
:
...
...
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