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
46977796
Commit
46977796
authored
Apr 06, 2021
by
Tiago Sarmento
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
alarm table implement
parent
a5ba9899
Pipeline
#1178
failed with stages
in 9 seconds
Changes
17
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
501 additions
and
235 deletions
+501
-235
NativeUI.py
NativeUI/NativeUI.py
+1
-1
alarm_list.py
NativeUI/alarm_widgets/alarm_list.py
+18
-22
alarm_popup.py
NativeUI/alarm_widgets/alarm_popup.py
+85
-30
alarm_table.py
NativeUI/alarm_widgets/alarm_table.py
+101
-0
tab_alarm_table.py
NativeUI/alarm_widgets/tab_alarm_table.py
+36
-0
tab_alarms.py
NativeUI/alarm_widgets/tab_alarms.py
+27
-14
global_lineEdit.py
NativeUI/global_widgets/global_lineEdit.py
+11
-1
global_send_popup.py
NativeUI/global_widgets/global_send_popup.py
+88
-0
global_sendconfirm_popup.py
NativeUI/global_widgets/global_sendconfirm_popup.py
+0
-107
global_spinbox.py
NativeUI/global_widgets/global_spinbox.py
+52
-33
global_typeval_popup.py
NativeUI/global_widgets/global_typeval_popup.py
+2
-0
tab_hold_buttons.py
NativeUI/global_widgets/tab_hold_buttons.py
+2
-0
tab_modeswitch_button.py
NativeUI/global_widgets/tab_modeswitch_button.py
+2
-2
template_set_values.py
NativeUI/global_widgets/template_set_values.py
+19
-16
hev_alarms.py
NativeUI/hev_alarms.py
+40
-3
tab_spin_buttons.py
NativeUI/main_widgets/tab_spin_buttons.py
+11
-0
tab_personal.py
NativeUI/mode_widgets/tab_personal.py
+6
-6
No files found.
NativeUI/NativeUI.py
View file @
46977796
...
...
@@ -30,7 +30,7 @@ import numpy as np
# from alarm_widgets.tab_alarms import TabAlarm
from
global_widgets.tab_top_bar
import
TabTopBar
from
global_widgets.tab_left_bar
import
TabLeftBar
from
global_widgets.global_send
confirm
_popup
import
confirmPopup
from
global_widgets.global_send_popup
import
confirmPopup
from
hev_main
import
MainView
from
hev_settings
import
SettingsView
from
hev_alarms
import
AlarmView
...
...
NativeUI/alarm_widgets/alarm_list.py
View file @
46977796
...
...
@@ -15,11 +15,10 @@ __status__ = "Prototype"
import
sys
import
os
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
from
datetime
import
datetime
path
=
"/home/pi/Documents/hev/hev-display/assets/svg/"
class
alarmList
(
QtWidgets
.
QWidget
):
class
alarmList
(
QtWidgets
.
QListWidget
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
alarmList
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
...
...
@@ -37,29 +36,26 @@ class alarmList(QtWidgets.QWidget):
self
.
solidBell
=
QtGui
.
QIcon
(
iconpath_bell
)
self
.
regularBell
=
QtGui
.
QIcon
(
iconpath_bellReg
)
self
.
vlayout
=
QtWidgets
.
QVBoxLayout
()
self
.
alarmList
=
QtWidgets
.
QListWidget
()
self
.
alarmList
.
addItem
(
"ring the alarm"
)
self
.
alarmList
.
addItem
(
"alarm the ring"
)
self
.
vlayout
.
addWidget
(
self
.
alarmList
)
self
.
setLayout
(
self
.
vlayout
)
# self.alarmList.itemClicked.connect(self.selected)
newItem
=
QtWidgets
.
QListWidgetItem
(
' '
)
self
.
addItem
(
newItem
)
# def selected(self):
# items = self.test.selectedItems()
# for item in items:
# item.setText("newtestText")
# item.setIcon(self.regularBell)
def
acknowledge_all
(
self
):
for
x
in
range
(
self
.
alarmList
.
count
()
-
1
):
self
.
alarmList
.
item
(
x
)
.
setText
(
"acknowledgedAlarm"
)
self
.
alarmList
.
item
(
x
)
.
setIcon
(
self
.
regularBell
)
for
x
in
range
(
self
.
count
()
-
1
):
self
.
item
(
x
)
.
setText
(
"acknowledgedAlarm"
)
self
.
item
(
x
)
.
setIcon
(
self
.
regularBell
)
def
addAlarm
(
self
,
abstractAlarm
):
timestamp
=
str
(
abstractAlarm
.
startTime
)[:
-
3
]
newItem
=
QtWidgets
.
QListWidgetItem
(
self
.
solidBell
,
timestamp
+
': '
+
abstractAlarm
.
alarmPayload
[
'alarm_type'
]
+
' - '
+
abstractAlarm
.
alarmPayload
[
"alarm_code"
])
self
.
insertItem
(
0
,
newItem
)
# add to the top
#self.labelList
def
removeAlarm
(
self
,
abstractAlarm
):
for
x
in
range
(
self
.
count
()
-
1
):
if
abstractAlarm
.
alarmPayload
[
"alarm_code"
]
in
self
.
item
(
x
)
.
text
():
self
.
takeItem
(
x
)
def
addAlarm
(
self
,
alarmPayload
):
newItem
=
QtWidgets
.
QListWidgetItem
(
self
.
solidBell
,
alarmPayload
[
"alarm_code"
])
self
.
alarmList
.
insertItem
(
0
,
newItem
)
# add to the top
if
__name__
==
"__main__"
:
...
...
NativeUI/alarm_widgets/alarm_popup.py
View file @
46977796
...
...
@@ -14,13 +14,54 @@ __status__ = "Prototype"
import
os
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
from
datetime
import
datetime
class
abstractAlarm
(
QtWidgets
.
QWidget
):
alarmExpired
=
QtCore
.
Signal
()
def
__init__
(
self
,
NativeUI
,
alarmPayload
,
*
args
,
**
kwargs
):
super
(
abstractAlarm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
alarmPayload
=
alarmPayload
self
.
startTime
=
datetime
.
now
()
self
.
duration
=
datetime
.
now
()
-
self
.
startTime
self
.
finishTime
=
-
1
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
1500
)
# just faster than 60Hz
self
.
timer
.
timeout
.
connect
(
self
.
timeoutDelete
)
self
.
timer
.
start
()
def
timeoutDelete
(
self
):
# """Check alarm still exists in ongoingAlarms object. If present do nothing, otherwise delete."""
self
.
alarmExpired
.
emit
()
self
.
setParent
(
None
)
# delete self
return
0
def
resetTimer
(
self
):
self
.
timer
.
start
()
return
0
def
freezeTimer
(
self
):
self
.
timer
.
stop
()
return
0
def
recordFinishTime
(
self
):
self
.
finishTime
=
datetime
.
now
()
self
.
duration
=
self
.
finishTime
-
self
.
startTime
def
calculateDuration
(
self
):
self
.
duration
=
datetime
.
now
()
-
self
.
startTime
class
alarmWidget
(
QtWidgets
.
QWidget
):
"""Object containing information particular to one alarm.
Created when alarm received from microcontroller, timeout after alarm signal stops.
Is contained within alarmPopup"""
def
__init__
(
self
,
NativeUI
,
a
larmPayload
,
alarmCarrier
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
NativeUI
,
a
bstractAlarm
,
alarmCarrier
,
*
args
,
**
kwargs
):
super
(
alarmWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
...
...
@@ -29,7 +70,7 @@ class alarmWidget(QtWidgets.QWidget):
self
.
layout
=
QtWidgets
.
QHBoxLayout
()
self
.
layout
.
setSpacing
(
0
)
self
.
layout
.
setMargin
(
0
)
self
.
alarmPayload
=
alarmPayload
self
.
alarmPayload
=
a
bstractAlarm
.
a
larmPayload
iconLabel
=
QtWidgets
.
QLabel
()
iconpath_check
=
os
.
path
.
join
(
...
...
@@ -39,34 +80,41 @@ class alarmWidget(QtWidgets.QWidget):
iconLabel
.
setPixmap
(
pixmap
)
self
.
layout
.
addWidget
(
iconLabel
)
textLabel
=
QtWidgets
.
QLabel
()
textLabel
.
setText
(
self
.
alarmPayload
[
"alarm_code"
])
textLabel
.
setFixedWidth
(
15
0
)
textLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
textLabel
.
setStyleSheet
(
"font-size: "
+
NativeUI
.
text_size
+
";"
)
self
.
layout
.
addWidget
(
textLabel
)
self
.
textLabel
=
QtWidgets
.
QLabel
()
self
.
textLabel
.
setText
(
self
.
alarmPayload
[
'alarm_type'
]
+
' - '
+
self
.
alarmPayload
[
"alarm_code"
])
self
.
textLabel
.
setFixedWidth
(
40
0
)
self
.
textLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
textLabel
.
setStyleSheet
(
"font-size: "
+
NativeUI
.
text_size
+
";"
)
self
.
layout
.
addWidget
(
self
.
textLabel
)
self
.
setFixedHeight
(
40
)
self
.
setLayout
(
self
.
layout
)
if
alarmPayload
[
"alarm_type"
]
==
"PRIORITY_HIGH"
:
if
self
.
alarmPayload
[
"alarm_type"
]
==
"PRIORITY_HIGH"
:
self
.
setStyleSheet
(
"background-color:red;"
)
elif
alarmPayload
[
"alarm_type"
]
==
"PRIORITY_MEDIUM"
:
elif
self
.
alarmPayload
[
"alarm_type"
]
==
"PRIORITY_MEDIUM"
:
self
.
setStyleSheet
(
"background-color:orange;"
)
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
500
)
# just faster than 60Hz
self
.
timer
.
timeout
.
connect
(
self
.
checkAlarm
)
self
.
timer
.
start
()
def
checkAlarm
(
self
):
"""Check alarm still exists in ongoingAlarms object. If present do nothing, otherwise delete."""
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
)
# delete self
return
0
# 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
()
return
False
# def checkAlarm(self):
# """Check alarm still exists in ongoingAlarms object. If present do nothing, otherwise delete."""
# 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) # delete self
# return 0
class
alarmPopup
(
QtWidgets
.
QDialog
):
...
...
@@ -107,16 +155,23 @@ class alarmPopup(QtWidgets.QDialog):
self
.
alarmDict
=
{}
return
0
def
addAlarm
(
self
,
a
larmPayload
):
def
addAlarm
(
self
,
a
bstractAlarm
):
"""Creates a new alarmWidget and adds it to the container"""
self
.
alarmDict
[
alarmPayload
[
"alarm_code"
]]
=
alarmWidget
(
self
.
NativeUI
,
a
larmPayload
,
self
self
.
alarmDict
[
a
bstractAlarm
.
a
larmPayload
[
"alarm_code"
]]
=
alarmWidget
(
self
.
NativeUI
,
a
bstractAlarm
,
self
)
self
.
layout
.
addWidget
(
self
.
alarmDict
[
alarmPayload
[
"alarm_code"
]])
self
.
layout
.
addWidget
(
self
.
alarmDict
[
abstractAlarm
.
alarmPayload
[
"alarm_code"
]])
return
0
def
removeAlarm
(
self
,
abstractAlarm
):
"""Creates a new alarmWidget and adds it to the container"""
self
.
alarmDict
[
abstractAlarm
.
alarmPayload
[
"alarm_code"
]]
.
setParent
(
None
)
self
.
alarmDict
.
pop
(
abstractAlarm
.
alarmPayload
[
"alarm_code"
])
return
0
def
resetTimer
(
self
,
alarmPayload
):
self
.
alarmDict
[
alarmPayload
[
"alarm_code"
]]
.
timer
.
start
()
#
def resetTimer(self, alarmPayload):
#
self.alarmDict[alarmPayload["alarm_code"]].timer.start()
def
location_on_window
(
self
):
"""Position the popup as defined here"""
...
...
NativeUI/alarm_widgets/alarm_table.py
0 → 100644
View file @
46977796
#!/usr/bin/env python3
"""
alarm_list.py
"""
__author__
=
[
"Benjamin Mummery"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__license__
=
"GPL"
__version__
=
"0.0.1"
__maintainer__
=
"Tiago Sarmento"
__email__
=
"tiago.sarmento@stfc.ac.uk"
__status__
=
"Prototype"
import
sys
import
os
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
from
datetime
import
datetime
class
alarmTable
(
QtWidgets
.
QTableWidget
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
alarmTable
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
alarmDict
=
{}
self
.
setSizePolicy
(
QtWidgets
.
QSizePolicy
.
Expanding
,
QtWidgets
.
QSizePolicy
.
Expanding
)
self
.
setStyleSheet
(
"background-color:white;"
"font-size: "
+
NativeUI
.
text_size
+
";"
)
self
.
nrows
=
0
self
.
setColumnCount
(
4
)
self
.
setSortingEnabled
(
True
)
if
self
.
nrows
==
0
:
self
.
setHorizontalHeaderLabels
([
'Timestamp'
,
'Priority Level'
,
'Alarm Code'
,
'Duration'
])
self
.
payloadKeys
=
[
'alarm_type'
,
'alarm_code'
]
self
.
resizeColumnsToContents
()
self
.
alarmDict
=
{}
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
100
)
#self.timer.timeout.connect(self.updateDuration)
self
.
timer
.
start
()
def
addAlarm
(
self
,
abstractAlarm
):
timestamp
=
str
(
datetime
.
now
())[:
-
3
]
newItem
=
QtWidgets
.
QListWidgetItem
(
self
.
solidBell
,
timestamp
+
': '
+
abstractAlarm
.
alarmPayload
[
'alarm_type'
]
+
' - '
+
abstractAlarm
.
alarmPayload
[
"alarm_code"
])
self
.
insertItem
(
0
,
newItem
)
# add to the top
#self.labelList
#widg = self.cellWidget(rowNumber, 4)
#cellItem.setText(str(abstractAlarm.duration))
# abstractAlarm.alarmExpired.connect(lambda i =newItem, j = abstractAlarm: self.update_duration(i,j))
# self.setItem(self.nrows, colnum, newItem)
# tableItem.setText(str(abstractAlarm.duration))
def
removeAlarm
(
self
,
abstractAlarm
):
for
x
in
range
(
self
.
count
()
-
1
):
if
abstractAlarm
.
alarmPayload
[
"alarm_code"
]
in
self
.
item
(
x
)
.
text
():
self
.
takeItem
(
x
)
def
addAlarmRow
(
self
,
abstractAlarm
):
self
.
setSortingEnabled
(
False
)
self
.
setRowCount
(
self
.
nrows
+
1
)
colnum
=
0
newItem
=
QtWidgets
.
QTableWidgetItem
(
str
(
abstractAlarm
.
startTime
)[:
-
3
])
self
.
setItem
(
self
.
nrows
,
0
,
newItem
)
newItem
=
QtWidgets
.
QTableWidgetItem
(
abstractAlarm
.
alarmPayload
[
'alarm_type'
])
self
.
setItem
(
self
.
nrows
,
1
,
newItem
)
newItem
=
QtWidgets
.
QTableWidgetItem
(
abstractAlarm
.
alarmPayload
[
'alarm_code'
])
self
.
setItem
(
self
.
nrows
,
2
,
newItem
)
newItem
=
QtWidgets
.
QTableWidgetItem
(
' '
)
self
.
alarmDict
[
self
.
nrows
]
=
newItem
self
.
setItem
(
self
.
nrows
,
3
,
self
.
alarmDict
[
self
.
nrows
])
#abstractAlarm.alarmExpired.connect(lambda i = self.alarmDict[self.nrows], j = abstractAlarm: self.update_duration(i,j))
self
.
timer
.
timeout
.
connect
(
lambda
i
=
self
.
alarmDict
[
self
.
nrows
],
j
=
abstractAlarm
:
self
.
update_duration
(
i
,
j
))
if
self
.
nrows
==
1
:
self
.
resizeColumnsToContents
()
self
.
nrows
=
self
.
nrows
+
1
self
.
setSortingEnabled
(
True
)
def
update_duration
(
self
,
cellItem
,
abstractAlarm
):
cellItem
.
setText
(
str
(
abstractAlarm
.
duration
))
if
__name__
==
"__main__"
:
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
widg
=
alarmList
()
widg
.
show
()
sys
.
exit
(
app
.
exec_
())
NativeUI/alarm_widgets/tab_alarm_table.py
0 → 100644
View file @
46977796
#!/usr/bin/env python3
"""
tab_alarms.py
"""
__author__
=
[
"Benjamin Mummery"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__license__
=
"GPL"
__version__
=
"0.0.1"
__maintainer__
=
"Tiago Sarmento"
__email__
=
"tiago.sarmento@stfc.ac.uk"
__status__
=
"Prototype"
import
sys
#from alarm_widgets.alarm_popup import alarmPopup, abstractAlarm
from
alarm_widgets.alarm_table
import
alarmTable
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
class
TabAlarmTable
(
QtWidgets
.
QWidget
):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
TabAlarmTable
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
table
=
alarmTable
(
NativeUI
)
vlayout
=
QtWidgets
.
QVBoxLayout
()
vlayout
.
addWidget
(
self
.
table
)
self
.
acknowledgeButton
=
QtWidgets
.
QPushButton
(
'table button'
)
#self.acknowledgeButton.pressed.connect(self.acknowledge_pressed)
vlayout
.
addWidget
(
self
.
acknowledgeButton
)
self
.
setLayout
(
vlayout
)
\ No newline at end of file
NativeUI/alarm_widgets/tab_alarms.py
View file @
46977796
...
...
@@ -14,7 +14,7 @@ __status__ = "Prototype"
import
sys
from
alarm_widgets.alarm_popup
import
alarmPopup
from
alarm_widgets.alarm_popup
import
alarmPopup
,
abstractAlarm
from
alarm_widgets.alarm_list
import
alarmList
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
...
...
@@ -24,6 +24,8 @@ class TabAlarm(QtWidgets.QWidget):
super
(
TabAlarm
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
#self.alarmDict = {}
self
.
popup
=
alarmPopup
(
NativeUI
,
self
)
self
.
popup
.
show
()
...
...
@@ -37,21 +39,32 @@ class TabAlarm(QtWidgets.QWidget):
self
.
setLayout
(
vlayout
)
# fdd
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
160
)
self
.
timer
.
timeout
.
connect
(
self
.
updateAlarms
)
self
.
timer
.
start
()
#
self.timer = QtCore.QTimer()
#
self.timer.setInterval(160)
#
self.timer.timeout.connect(self.updateAlarms)
#
self.timer.start()
def
acknowledge_pressed
(
self
):
self
.
popup
.
clearAlarms
()
self
.
list
.
acknowledge_all
()
def
updateAlarms
(
self
):
newAlarm
=
self
.
NativeUI
.
get_db
(
"alarms"
)
if
newAlarm
==
[]:
return
if
newAlarm
[
"alarm_code"
]
in
self
.
popup
.
alarmDict
:
self
.
popup
.
resetTimer
(
newAlarm
)
else
:
self
.
popup
.
addAlarm
(
newAlarm
)
self
.
list
.
addAlarm
(
newAlarm
)
# def updateAlarms(self):
# newAlarmPayload = self.NativeUI.get_db("alarms")
# if newAlarmPayload == []:
# return
# if newAlarmPayload["alarm_code"] in self.alarmDict:
# a = 1
# #self.alarmDict[newAlarmPayload["alarm_code"]].resetTimer()
# #self.popup.resetTimer(newAlarm)
# else:
# newAbstractAlarm = abstractAlarm(self.NativeUI, newAlarmPayload)
# self.alarmDict[newAlarmPayload["alarm_code"]] = newAbstractAlarm
# newAbstractAlarm.alarmExpired.connect(lambda i = newAbstractAlarm: self.handleAlarmExpiry(i))
# self.popup.addAlarm(newAbstractAlarm)
# self.list.addAlarm(newAbstractAlarm)
# def handleAlarmExpiry(self, abstractAlarm):
# abstractAlarm.freezeTimer()
# self.popup.removeAlarm(abstractAlarm)
# self.list.removeAlarm(abstractAlarm)
# abstractAlarm.recordFinishTime()
NativeUI/global_widgets/global_lineEdit.py
View file @
46977796
...
...
@@ -74,6 +74,7 @@ class labelledLineEdit(QtWidgets.QWidget):
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
self
.
simpleSpin
.
setProperty
(
"bgColour"
,
"0"
)
self
.
simpleSpin
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
simpleSpin
.
textChanged
.
connect
(
self
.
textUpdate
)
if
self
.
cmd_type
==
""
:
self
.
simpleSpin
.
setReadOnly
(
True
)
self
.
simpleSpin
.
setProperty
(
"bgColour"
,
"1"
)
...
...
@@ -90,11 +91,20 @@ class labelledLineEdit(QtWidgets.QWidget):
self
.
setLayout
(
layout
)
def
update_personal_value
(
self
):
def
textUpdate
(
self
):
self
.
manuallyUpdated
=
True
def
update_value
(
self
,
placeholdertemp
):
newVal
=
self
.
NativeUI
.
get_db
(
"personal"
)
if
newVal
==
{}:
a
=
1
# do nothing
else
:
print
(
'got a personal db'
)
self
.
simpleSpin
.
setText
(
newVal
[
self
.
tag
])
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
def
get_value
(
self
):
return
self
.
simpleSpin
.
text
()
NativeUI/global_widgets/global_send_popup.py
View file @
46977796
...
...
@@ -53,10 +53,12 @@ class SetConfirmPopup(
buttonHLayout
=
QtWidgets
.
QHBoxLayout
()
self
.
okButton
=
okButton
(
self
.
NativeUI
)
self
.
okButton
.
setEnabled
(
True
)
self
.
okButton
.
pressed
.
connect
(
self
.
ok_button_pressed
)
buttonHLayout
.
addWidget
(
self
.
okButton
)
self
.
cancelButton
=
cancelButton
(
self
.
NativeUI
)
self
.
cancelButton
.
setEnabled
(
True
)
self
.
cancelButton
.
pressed
.
connect
(
self
.
cancel_button_pressed
)
buttonHLayout
.
addWidget
(
self
.
cancelButton
)
...
...
@@ -83,6 +85,92 @@ class SetConfirmPopup(
return
0
class
confirmWidget
(
QtWidgets
.
QWidget
):
def
__init__
(
self
,
NativeUI
,
confirmMessage
,
*
args
,
**
kwargs
):
super
(
confirmWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
hlayout
=
QtWidgets
.
QHBoxLayout
()
self
.
hlayout
.
setSpacing
(
0
)
self
.
hlayout
.
setMargin
(
0
)
self
.
confirmMessage
=
confirmMessage
iconLabel
=
QtWidgets
.
QLabel
()
iconpath_check
=
os
.
path
.
join
(
NativeUI
.
iconpath
,
"exclamation-circle-solid.png"
)
pixmap
=
QtGui
.
QPixmap
(
iconpath_check
)
.
scaledToHeight
(
40
)
iconLabel
.
setPixmap
(
pixmap
)
self
.
hlayout
.
addWidget
(
iconLabel
)
textLabel
=
QtWidgets
.
QLabel
()
textLabel
.
setText
(
self
.
confirmMessage
)
textLabel
.
setFixedHeight
(
40
)
textLabel
.
setFixedWidth
(
400
)
textLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
hlayout
.
addWidget
(
textLabel
)
self
.
setLayout
(
self
.
hlayout
)
self
.
setFixedHeight
(
50
)
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
10000
)
self
.
timer
.
timeout
.
connect
(
self
.
confirmTimeout
)
self
.
timer
.
start
()
def
confirmTimeout
(
self
):
self
.
parent
()
.
confirmDict
.
pop
(
self
.
confirmMessage
)
self
.
setParent
(
None
)
class
confirmPopup
(
QtWidgets
.
QWidget
):
"""Popup when a command is confirmed by microcontroller.
This popup is a frame containing a confirmWidget object for
each successful command."""
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
confirmPopup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
confirmDict
=
{}
self
.
vlayout
=
QtWidgets
.
QVBoxLayout
()
self
.
vlayout
.
setSpacing
(
0
)
self
.
vlayout
.
setMargin
(
0
)
self
.
setLayout
(
self
.
vlayout
)
self
.
location_on_window
()
self
.
setWindowFlags
(
QtCore
.
Qt
.
FramelessWindowHint
|
QtCore
.
Qt
.
Dialog
|
QtCore
.
Qt
.
WindowStaysOnTopHint
)
# no window title
self
.
setStyleSheet
(
"background-color:green;"
)
# self.shadow = QtWidgets.QGraphicsDropShadowEffect()
# self.shadow.setBlurRadius(20)
# self.shadow.setXOffset(10)
# self.shadow.setYOffset(10)
#
# self.timer = QtCore.QTimer()
# self.timer.setInterval(100)
# self.timer.timeout.connect(self.adjustSize)
# self.timer.start()
def
addConfirmation
(
self
,
confirmMessage
):
"""Add a confirmation to the popup. Triggered when UI receives a confirmation from the microcontroller"""
self
.
confirmDict
[
confirmMessage
]
=
confirmWidget
(
self
.
NativeUI
,
confirmMessage
)
# record in dictionary so it can be accessed and deleted
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
)
if
__name__
==
"__main__"
:
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
widg
=
SetConfirmPopup
(
...
...
NativeUI/global_widgets/global_sendconfirm_popup.py
deleted
100644 → 0
View file @
a5ba9899
#!/usr/bin/env python3
"""
global_sendconfirm_popup.py
"""
__author__
=
[
"Benjamin Mummery"
,
"Tiago Sarmento"
]
__credits__
=
[
"Benjamin Mummery"
,
"Dónal Murray"
,
"Tim Powell"
,
"Tiago Sarmento"
]
__license__
=
"GPL"
__version__
=
"0.0.1"
__maintainer__
=
"Tiago Sarmento"
__email__
=
"tiago.sarmento@stfc.ac.uk"
__status__
=
"Prototype"
from
PySide2
import
QtCore
,
QtGui
,
QtWidgets
import
sys
import
os
class
confirmWidget
(
QtWidgets
.
QWidget
):
def
__init__
(
self
,
NativeUI
,
confirmMessage
,
*
args
,
**
kwargs
):
super
(
confirmWidget
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
hlayout
=
QtWidgets
.
QHBoxLayout
()
self
.
hlayout
.
setSpacing
(
0
)
self
.
hlayout
.
setMargin
(
0
)
self
.
confirmMessage
=
confirmMessage
iconLabel
=
QtWidgets
.
QLabel
()
iconpath_check
=
os
.
path
.
join
(
NativeUI
.
iconpath
,
"exclamation-circle-solid.png"
)
pixmap
=
QtGui
.
QPixmap
(
iconpath_check
)
.
scaledToHeight
(
40
)
iconLabel
.
setPixmap
(
pixmap
)
self
.
hlayout
.
addWidget
(
iconLabel
)
textLabel
=
QtWidgets
.
QLabel
()
textLabel
.
setText
(
self
.
confirmMessage
)
textLabel
.
setFixedHeight
(
40
)
textLabel
.
setFixedWidth
(
400
)
textLabel
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
self
.
hlayout
.
addWidget
(
textLabel
)
self
.
setLayout
(
self
.
hlayout
)
self
.
setFixedHeight
(
50
)
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
10000
)
self
.
timer
.
timeout
.
connect
(
self
.
confirmTimeout
)
self
.
timer
.
start
()
def
confirmTimeout
(
self
):
self
.
parent
()
.
confirmDict
.
pop
(
self
.
confirmMessage
)
self
.
setParent
(
None
)
class
confirmPopup
(
QtWidgets
.
QWidget
):
"""Popup when a command is confirmed by microcontroller.
This popup is a frame containing a confirmWidget object for
each successful command."""
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
confirmPopup
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
confirmDict
=
{}
self
.
vlayout
=
QtWidgets
.
QVBoxLayout
()
self
.
vlayout
.
setSpacing
(
0
)
self
.
vlayout
.
setMargin
(
0
)
self
.
setLayout
(
self
.
vlayout
)
self
.
location_on_window
()
self
.
setWindowFlags
(
QtCore
.
Qt
.
FramelessWindowHint
|
QtCore
.
Qt
.
Dialog
|
QtCore
.
Qt
.
WindowStaysOnTopHint
)
# no window title
self
.
setStyleSheet
(
"background-color:green;"
)
# self.shadow = QtWidgets.QGraphicsDropShadowEffect()
# self.shadow.setBlurRadius(20)
# self.shadow.setXOffset(10)
# self.shadow.setYOffset(10)
#
# self.timer = QtCore.QTimer()
# self.timer.setInterval(100)
# self.timer.timeout.connect(self.adjustSize)
# self.timer.start()
def
addConfirmation
(
self
,
confirmMessage
):
"""Add a confirmation to the popup. Triggered when UI receives a confirmation from the microcontroller"""
self
.
confirmDict
[
confirmMessage
]
=
confirmWidget
(
self
.
NativeUI
,
confirmMessage
)
# record in dictionary so it can be accessed and deleted
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
)
if
__name__
==
"__main__"
:
app
=
QtWidgets
.
QApplication
(
sys
.
argv
)
widg
=
confirmPopup
()
widg
.
addConfirmation
(
"new confirmation"
)
widg
.
addConfirmation
(
"new confirmation2"
)
widg
.
show
()
sys
.
exit
(
app
.
exec_
())
NativeUI/global_widgets/global_spinbox.py
View file @
46977796
...
...
@@ -127,7 +127,7 @@ class labelledSpin(QtWidgets.QWidget):
" color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
";"
"}"
"QDoubleSpinBox[textColour='2']{"
" color:"
+
NativeUI
.
colors
[
"
baby_blue
"
]
.
name
()
+
";"
" color:"
+
NativeUI
.
colors
[
"
red
"
]
.
name
()
+
";"
"}"
"QDoubleSpinBox::up-button{"
"width:20; "
...
...
@@ -167,42 +167,58 @@ class labelledSpin(QtWidgets.QWidget):
def
manualStep
(
self
):
"""Handle changes in value. Change colour if different to set value, set updating values."""
if
self
.
manuallyUpdated
!=
True
:
self
.
oldValue
=
self
.
simpleSpin
.
prevValue
self
.
manuallyUpdated
=
True
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
):
newVal
=
self
.
NativeUI
.
get_db
(
"readback"
)
if
newVal
==
{}
or
self
.
manuallyUpdated
:
a
=
1
# do nothing
else
:
self
.
simpleSpin
.
setValue
(
newVal
[
self
.
tag
])
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
def
update_targets_value
(
self
):
newVal
=
self
.
NativeUI
.
get_db
(
"targets"
)
if
(
newVal
==
{})
or
(
self
.
tag
==
""
)
or
self
.
manuallyUpdated
:
a
=
1
# do nothing
else
:
self
.
simpleSpin
.
setValue
(
newVal
[
self
.
tag
])
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
if
not
self
.
manuallyUpdated
:
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"2"
)
self
.
manuallyUpdated
=
True
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
return
0
def
update_personal_value
(
self
):
newVal
=
self
.
NativeUI
.
get_db
(
"personal"
)
if
(
newVal
==
{})
or
(
self
.
tag
==
""
):
def
update_value
(
self
,
db
):
if
(
self
.
tag
==
""
)
:
a
=
1
# do nothing
else
:
self
.
simpleSpin
.
setValue
(
newVal
[
self
.
tag
])
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
newVal
=
db
[
self
.
tag
]
if
self
.
manuallyUpdated
:
roundVal
=
round
(
newVal
,
self
.
decPlaces
)
if
self
.
decPlaces
==
0
:
roundVal
=
int
(
roundVal
)
if
self
.
simpleSpin
.
value
()
==
roundVal
:
self
.
manuallyUpdated
=
False
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
print
(
'reverting back'
)
else
:
self
.
simpleSpin
.
setValue
(
newVal
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"0"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
# def update_readback_value(self):
# newVal = self.NativeUI.get_db("readback")
# if newVal == {} or self.manuallyUpdated:
# a = 1 # do nothing
# else:
# self.simpleSpin.setValue(newVal[self.tag])
# self.simpleSpin.setProperty("textColour", "0")
# self.simpleSpin.style().polish(self.simpleSpin)
# def update_targets_value(self):
# newVal = self.NativeUI.get_db("targets")
# if (newVal == {}) or (self.tag == "") or self.manuallyUpdated:
# a = 1 # do nothing
# else:
# self.simpleSpin.setValue(newVal[self.tag])
# self.simpleSpin.setProperty("textColour", "0")
# self.simpleSpin.style().polish(self.simpleSpin)
# def update_personal_value(self):
# newVal = self.NativeUI.get_db("personal")
# if (newVal == {}) or (self.tag == ""):
# a = 1 # do nothing
# else:
# self.simpleSpin.setValue(newVal[self.tag])
# self.simpleSpin.setProperty("textColour", "0")
# self.simpleSpin.style().polish(self.simpleSpin)
def
insertWidget
(
self
,
widget
,
position
):
self
.
insertedWidget
=
widget
...
...
@@ -213,3 +229,6 @@ class labelledSpin(QtWidgets.QWidget):
for
widget
in
self
.
widgetList
:
self
.
layout
.
addWidget
(
widget
)
self
.
setLayout
(
self
.
layout
)
def
get_value
(
self
):
return
self
.
simpleSpin
.
value
()
\ No newline at end of file
NativeUI/global_widgets/global_typeval_popup.py
View file @
46977796
...
...
@@ -57,9 +57,11 @@ class TypeValuePopup(QtWidgets.QDialog):
grid
.
addWidget
(
self
.
lineEdit
,
0
,
0
,
1
,
2
)
self
.
okButton
=
okButton
(
NativeUI
)
self
.
okButton
.
setEnabled
(
True
)
grid
.
addWidget
(
self
.
okButton
,
1
,
0
)
self
.
cancelButton
=
cancelButton
(
NativeUI
)
self
.
cancelButton
.
setEnabled
(
True
)
grid
.
addWidget
(
self
.
cancelButton
,
1
,
1
)
self
.
setLayout
(
grid
)
...
...
NativeUI/global_widgets/tab_hold_buttons.py
View file @
46977796
...
...
@@ -59,8 +59,10 @@ class timerConfirmPopup(QtWidgets.QWidget):
buttonLayout
=
QtWidgets
.
QHBoxLayout
()
self
.
okButton
=
okButton
(
NativeUI
)
self
.
okButton
.
setEnabled
(
True
)
buttonLayout
.
addWidget
(
self
.
okButton
)
self
.
cancelButton
=
cancelButton
(
NativeUI
)
self
.
cancelButton
.
setEnabled
(
True
)
buttonLayout
.
addWidget
(
self
.
cancelButton
)
self
.
completeLayout
.
addWidget
(
self
.
completeLabel
)
...
...
NativeUI/global_widgets/tab_modeswitch_button.py
View file @
46977796
...
...
@@ -174,9 +174,9 @@ class modeswitchPopup(QtWidgets.QWidget):
):
currentVal
=
self
.
spinDict
[
self
.
NativeUI
.
currentMode
.
replace
(
"/"
,
"_"
)
.
replace
(
"-"
,
"_"
)
][
settings
]
.
simpleSpin
.
value
()
][
settings
]
.
get_
value
()
currentLabel
.
setText
(
str
(
round
(
currentVal
,
4
)))
setVal
=
self
.
spinDict
[
self
.
mode
][
settings
]
.
simpleSpin
.
value
()
setVal
=
self
.
spinDict
[
self
.
mode
][
settings
]
.
get_
value
()
newLabel
.
setText
(
str
(
round
(
setVal
,
4
)))
def
ok_button_pressed
(
self
):
...
...
NativeUI/global_widgets/template_set_values.py
View file @
46977796
...
...
@@ -26,7 +26,7 @@ class TemplateSetValues(QtWidgets.QWidget):
self
.
layoutList
=
[]
self
.
spinDict
=
{}
self
.
NativeUI
=
NativeUI
self
.
packet
=
"target"
self
.
packet
=
"target
s
"
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
500
)
# just faster than 60Hz
...
...
@@ -141,8 +141,10 @@ class TemplateSetValues(QtWidgets.QWidget):
for
info
in
settingsList
:
if
info
[
0
]
in
textBoxes
:
self
.
spinDict
[
info
[
0
]]
=
labelledLineEdit
(
self
.
NativeUI
,
info
)
self
.
spinDict
[
info
[
0
]]
.
simpleSpin
.
textChanged
.
connect
(
lambda
textignore
,
i
=
1
:
self
.
colourButtons
(
i
))
else
:
self
.
spinDict
[
info
[
0
]]
=
labelledSpin
(
self
.
NativeUI
,
info
)
self
.
spinDict
[
info
[
0
]]
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
1
:
self
.
colourButtons
(
i
))
vOptionLayout
.
addWidget
(
self
.
spinDict
[
info
[
0
]])
self
.
layoutList
.
append
(
vOptionLayout
)
...
...
@@ -159,7 +161,7 @@ class TemplateSetValues(QtWidgets.QWidget):
self
.
layoutList
.
append
(
hlayout
)
for
spin
in
self
.
spinDict
:
self
.
spinDict
[
spin
]
.
simpleSpin
.
manualChanged
.
connect
(
self
.
colourButtons
)
self
.
spinDict
[
spin
]
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
1
:
self
.
colourButtons
(
i
)
)
def
addModeButtons
(
self
):
hlayout
=
QtWidgets
.
QHBoxLayout
()
...
...
@@ -178,28 +180,29 @@ class TemplateSetValues(QtWidgets.QWidget):
self
.
layoutList
.
append
(
hlayout
)
for
spin
in
self
.
spinDict
:
self
.
spinDict
[
spin
]
.
simpleSpin
.
manualChanged
.
connect
(
self
.
colourButtons
)
self
.
spinDict
[
spin
]
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
1
:
self
.
colourButtons
(
i
)
)
def
colourButtons
(
self
):
def
colourButtons
(
self
,
option
):
for
button
in
self
.
buttonsList
:
button
.
setColour
(
1
)
button
.
setColour
(
str
(
option
)
)
def
update_settings_data
(
self
):
for
widget
in
self
.
spinDict
:
if
self
.
packet
==
"target"
:
self
.
spinDict
[
widget
]
.
update_targets_value
()
# pass database elif self.packet == "readback":
elif
self
.
packet
==
"readback"
:
self
.
spinDict
[
widget
]
.
update_readback_value
()
elif
self
.
packet
==
"personal"
:
self
.
spinDict
[
widget
]
.
update_personal_value
()
liveUpdatingCheck
=
True
db
=
self
.
NativeUI
.
get_db
(
self
.
packet
)
if
db
==
{}:
return
0
# do nothing
else
:
for
widget
in
self
.
spinDict
:
self
.
spinDict
[
widget
]
.
update_value
(
db
)
liveUpdatingCheck
=
liveUpdatingCheck
and
not
self
.
spinDict
[
widget
]
.
manuallyUpdated
if
liveUpdatingCheck
:
self
.
colourButtons
(
0
)
def
okButtonPressed
(
self
):
message
,
command
=
[],
[]
for
widget
in
self
.
spinDict
:
if
self
.
spinDict
[
widget
]
.
manuallyUpdated
:
setVal
=
self
.
spinDict
[
widget
]
.
simpleSpin
.
value
()
setVal
=
self
.
spinDict
[
widget
]
.
get_
value
()
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
...
...
@@ -216,7 +219,7 @@ class TemplateSetValues(QtWidgets.QWidget):
message
,
command
=
[],
[]
for
widget
in
self
.
spinDict
:
if
self
.
spinDict
[
widget
]
.
manuallyUpdated
:
setVal
=
self
.
spinDict
[
widget
]
.
simpleSpin
.
value
()
setVal
=
self
.
spinDict
[
widget
]
.
get_
value
()
message
.
append
(
"set"
+
widget
+
" to "
+
str
(
setVal
))
command
.
append
(
[
...
...
NativeUI/hev_alarms.py
View file @
46977796
...
...
@@ -13,10 +13,12 @@ __email__ = "tiago.sarmento@stfc.ac.uk"
__status__
=
"Prototype"
from
alarm_widgets.tab_alarms
import
TabAlarm
from
alarm_widgets.tab_alarm_table
import
TabAlarmTable
from
alarm_widgets.tab_clinical
import
TabClinical
from
global_widgets.global_select_button
import
selectorButton
from
global_widgets.template_main_pages
import
TemplateMainPages
from
alarm_widgets.alarm_popup
import
abstractAlarm
from
PySide2
import
QtCore
class
AlarmView
(
TemplateMainPages
):
"""Subclasses TemplateMainPages to display alarms."""
...
...
@@ -24,14 +26,49 @@ class AlarmView(TemplateMainPages):
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
(
AlarmView
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
alarmButton
=
selectorButton
(
NativeUI
,
"List of Alarms"
)
self
.
alarmTableButton
=
selectorButton
(
NativeUI
,
"Alarm Table"
)
self
.
clinicalButton
=
selectorButton
(
NativeUI
,
"Clinical Limits"
)
#self.techButton = selectorButton(NativeUI, "Technical Limits")
self
.
buttonWidgets
=
[
self
.
alarmButton
,
self
.
clinicalButton
]
#, self.techButton]
self
.
buttonWidgets
=
[
self
.
alarmButton
,
self
.
alarmTableButton
,
self
.
clinicalButton
]
#, self.techButton]
self
.
alarmTab
=
TabAlarm
(
NativeUI
)
self
.
alarmTableTab
=
TabAlarmTable
(
NativeUI
)
self
.
clinicalTab
=
TabClinical
(
NativeUI
)
#self.technicalTab = TabClinical(NativeUI)
self
.
tabsList
=
[
self
.
alarmTab
,
self
.
clinicalTab
]
#, self.technicalTab]
self
.
tabsList
=
[
self
.
alarmTab
,
self
.
alarmTableTab
,
self
.
clinicalTab
]
#, self.technicalTab]
self
.
buildPage
(
self
.
buttonWidgets
,
self
.
tabsList
)
self
.
alarmDict
=
{}
self
.
timer
=
QtCore
.
QTimer
()
self
.
timer
.
setInterval
(
300
)
self
.
timer
.
timeout
.
connect
(
self
.
updateAlarms
)
self
.
timer
.
start
()
def
updateAlarms
(
self
):
newAlarmPayload
=
self
.
NativeUI
.
get_db
(
"alarms"
)
if
newAlarmPayload
==
[]:
return
if
newAlarmPayload
[
"alarm_code"
]
in
self
.
alarmDict
:
a
=
1
self
.
alarmDict
[
newAlarmPayload
[
"alarm_code"
]]
.
resetTimer
()
self
.
alarmDict
[
newAlarmPayload
[
"alarm_code"
]]
.
calculateDuration
()
else
:
newAbstractAlarm
=
abstractAlarm
(
self
.
NativeUI
,
newAlarmPayload
)
self
.
alarmDict
[
newAlarmPayload
[
"alarm_code"
]]
=
newAbstractAlarm
newAbstractAlarm
.
alarmExpired
.
connect
(
lambda
i
=
newAbstractAlarm
:
self
.
handleAlarmExpiry
(
i
))
self
.
alarmTab
.
popup
.
addAlarm
(
newAbstractAlarm
)
self
.
alarmTab
.
list
.
addAlarm
(
newAbstractAlarm
)
self
.
alarmTableTab
.
table
.
addAlarmRow
(
newAbstractAlarm
)
def
handleAlarmExpiry
(
self
,
abstractAlarm
):
abstractAlarm
.
freezeTimer
()
self
.
alarmTab
.
popup
.
removeAlarm
(
abstractAlarm
)
self
.
alarmTab
.
list
.
removeAlarm
(
abstractAlarm
)
self
.
alarmDict
.
pop
(
abstractAlarm
.
alarmPayload
[
"alarm_code"
])
abstractAlarm
.
recordFinishTime
()
NativeUI/main_widgets/tab_spin_buttons.py
View file @
46977796
...
...
@@ -161,6 +161,7 @@ class TabSpinButtons(QtWidgets.QWidget):
self
.
spinDict
=
{}
for
settings
in
self
.
settingsList
:
self
.
spinDict
[
settings
[
0
]]
=
SpinButton
(
NativeUI
,
settings
)
self
.
spinDict
[
settings
[
0
]]
.
simpleSpin
.
manualChanged
.
connect
(
lambda
i
=
1
:
self
.
colourButtons
(
i
))
self
.
layout
.
addWidget
(
self
.
spinDict
[
settings
[
0
]])
self
.
buttonLayout
=
QtWidgets
.
QVBoxLayout
()
...
...
@@ -183,10 +184,18 @@ class TabSpinButtons(QtWidgets.QWidget):
self
.
timer
.
timeout
.
connect
(
self
.
update_targets
)
self
.
timer
.
start
()
def
colourButtons
(
self
,
option
):
self
.
okButton
.
setColour
(
str
(
option
))
self
.
cancelButton
.
setColour
(
str
(
option
))
def
update_targets
(
self
):
"""Update values on all spinboxes"""
liveUpdatingCheck
=
True
for
spin
in
self
.
spinDict
:
self
.
spinDict
[
spin
]
.
update_targets_value
()
liveUpdatingCheck
=
liveUpdatingCheck
and
self
.
spinDict
[
spin
]
.
liveUpdating
if
liveUpdatingCheck
:
self
.
colourButtons
(
0
)
return
0
def
ok_button_pressed
(
self
):
...
...
@@ -213,12 +222,14 @@ class TabSpinButtons(QtWidgets.QWidget):
for
spin
in
self
.
spinDict
:
self
.
spinDict
[
spin
]
.
liveUpdating
=
True
self
.
spinDict
[
spin
]
.
setTextColour
(
"1"
)
self
.
colourButtons
(
0
)
def
cancel_button_pressed
(
self
):
"""Respond to cancel button pressed by changing text colour and liveUpdating to True"""
for
spin
in
self
.
spinDict
:
self
.
spinDict
[
spin
]
.
liveUpdating
=
True
self
.
spinDict
[
spin
]
.
setTextColour
(
"1"
)
self
.
colourButtons
(
0
)
# targets = self.NativeUI.get_targets_db()
# if targets == {}:
...
...
NativeUI/mode_widgets/tab_personal.py
View file @
46977796
...
...
@@ -23,12 +23,12 @@ class TabPersonal(TemplateSetValues):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
TabPersonal
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
settingsList
=
[
[
"Name"
,
"/min"
,
"
respiratory_rat
e"
,
"SET_PERSONAL"
,
"NAME"
],
[
"Patient ID"
,
"s"
,
"
inhale_time
"
,
"SET_PERSONAL"
,
"PATIENT_ID"
],
[
"Age"
,
""
,
"
ie_ratio
"
,
"SET_PERSONAL"
,
"AGE"
],
[
"Sex"
,
""
,
"
inhale_trigger_threshold
"
,
"SET_PERSONAL"
,
"SEX"
],
[
"Weight"
,
""
,
"
exhale_trigger_threshold
"
,
"SET_PERSONAL"
,
"WEIGHT"
],
[
"Height"
,
""
,
"
inspiratory_pressure
"
,
"SET_PERSONAL"
,
"HEIGHT"
],
[
"Name"
,
"/min"
,
"
nam
e"
,
"SET_PERSONAL"
,
"NAME"
],
[
"Patient ID"
,
"s"
,
"
patient_id
"
,
"SET_PERSONAL"
,
"PATIENT_ID"
],
[
"Age"
,
""
,
"
age
"
,
"SET_PERSONAL"
,
"AGE"
],
[
"Sex"
,
""
,
"
sex
"
,
"SET_PERSONAL"
,
"SEX"
],
[
"Weight"
,
""
,
"
weight
"
,
"SET_PERSONAL"
,
"WEIGHT"
],
[
"Height"
,
""
,
"
height
"
,
"SET_PERSONAL"
,
"HEIGHT"
],
]
textBoxes
=
[
"Name"
,
"Patient ID"
,
"Sex"
]
self
.
setPacketType
(
"personal"
)
...
...
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