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
4ee8013a
Commit
4ee8013a
authored
Apr 19, 2021
by
Benjamin Mummery
💻
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed my various failed attempts to revert things
parent
03b42629
Pipeline
#1290
canceled with stages
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
68 additions
and
84 deletions
+68
-84
NativeUI.py
NativeUI/NativeUI.py
+29
-81
tab_alarms.py
NativeUI/alarm_widgets/tab_alarms.py
+1
-1
ui_layout.py
NativeUI/ui_layout.py
+3
-0
personal_display_widget.py
NativeUI/widget_library/personal_display_widget.py
+35
-2
No files found.
NativeUI/NativeUI.py
View file @
4ee8013a
...
...
@@ -123,7 +123,7 @@ class NativeUI(HEVClient, QMainWindow):
"flow_axis_range"
:
[
-
40
,
80
],
"volume_axis_range"
:
[
0
,
80
],
}
self
.
__alarms
=
[]
self
.
__alarms
=
{}
self
.
__targets
=
{}
self
.
__personal
=
{}
self
.
ongoingAlarms
=
{}
...
...
@@ -267,10 +267,9 @@ class NativeUI(HEVClient, QMainWindow):
self
.
MeasurementSignal
.
emit
(
self
.
get_db
(
"cycle"
),
self
.
get_db
(
"readback"
))
return
0
def
get_db
(
self
,
database_name
:
str
)
->
str
:
def
__check_db_name
(
self
,
database_name
:
str
)
->
str
:
"""
Return the contents of the specified database dict, assuming that it is present
in __database_list.
Check that the specified name is an actual database in NativeUI.
"""
# Add "__" to database_name if it isn't already present.
if
not
database_name
.
startswith
(
"__"
):
...
...
@@ -283,64 +282,34 @@ class NativeUI(HEVClient, QMainWindow):
"
%
s is not a recognised database in NativeUI"
%
database_name
)
# Return the database.
with
self
.
db_lock
:
# temp = getattr(self, "_%s%s" % (type(self).__name__, database_name))
return
getattr
(
self
,
"_
%
s
%
s"
%
(
type
(
self
)
.
__name__
,
database_name
))
def
set_data_db
(
self
,
payload
):
"""
Set the contents of the __data database. Uses lock to avoid race
conditions.
"""
logging
.
debug
(
"setting data db"
)
with
self
.
db_lock
:
for
key
in
payload
:
self
.
__data
[
key
]
=
payload
[
key
]
return
0
def
set_targets_db
(
self
,
payload
):
"""
Set the contents of the __targets database. Uses lock to avoid race
conditions.
"""
logging
.
debug
(
"setting targets db"
)
with
self
.
db_lock
:
for
key
in
payload
:
self
.
__targets
[
key
]
=
payload
[
key
]
return
0
def
set_readback_db
(
self
,
payload
):
"""
Set the contents of the __readback database. Uses lock to avoid race
conditions.
"""
logging
.
debug
(
"setting readback db"
)
with
self
.
db_lock
:
for
key
in
payload
:
self
.
__readback
[
key
]
=
payload
[
key
]
return
0
return
database_name
def
set_cycle_db
(
self
,
payload
):
def
get_db
(
self
,
database_name
:
str
):
"""
Set the contents of the __cycle database. Uses lock to avoid race
conditions
.
Return the contents of the specified database dict, assuming that it is present
in __database_list
.
"""
logging
.
debug
(
"setting cycle db"
)
with
self
.
db_lock
:
for
key
in
payload
:
self
.
__cycle
[
key
]
=
payload
[
key
]
return
0
return
getattr
(
self
,
"_
%
s
%
s"
%
(
type
(
self
)
.
__name__
,
self
.
__check_db_name
(
database_name
)),
)
raise
RuntimeError
(
"Could not acquire database"
)
def
set_battery_db
(
self
,
payload
)
:
def
__set_db
(
self
,
database_name
:
str
,
payload
)
->
int
:
"""
Set the contents of the
__battery database. Uses lock to avoid race
conditions.
Set the contents of the
specified database dict, assuming that it is present in
__database_list. Uses lock to avoid race
conditions.
"""
logging
.
debug
(
"setting battery db"
)
temp
=
self
.
get_db
(
database_name
)
for
key
in
payload
:
temp
[
key
]
=
payload
[
key
]
with
self
.
db_lock
:
for
key
in
payload
:
self
.
__battery
[
key
]
=
payload
[
key
]
setattr
(
self
,
"_
%
s
%
s"
%
(
type
(
self
)
.
__name__
,
self
.
__check_db_name
(
database_name
)),
temp
,
)
return
0
def
set_plots_db
(
self
,
payload
):
...
...
@@ -387,27 +356,6 @@ class NativeUI(HEVClient, QMainWindow):
]
return
0
def
set_alarms_db
(
self
,
payload
):
"""
Set the contents of the __alarms database. Uses lock to avoid race
conditions.
"""
logging
.
debug
(
"setting alarms db"
)
with
self
.
db_lock
:
self
.
__alarms
=
payload
return
0
def
set_personal_db
(
self
,
payload
):
"""
Set the contents of the __personal database. Uses lock to avoid race
conditions.
"""
logging
.
debug
(
"setting personal db"
)
with
self
.
db_lock
:
for
key
in
payload
:
self
.
__personal
[
key
]
=
payload
[
key
]
return
0
def
start_client
(
self
):
"""
Poll the microcontroller for current settings information.
...
...
@@ -432,22 +380,22 @@ class NativeUI(HEVClient, QMainWindow):
logging
.
debug
(
"revieved payload of type
%
s"
%
payload
[
"type"
])
try
:
if
payload
[
"type"
]
==
"DATA"
:
self
.
set_data_db
(
payload
[
"DATA"
])
self
.
__set_db
(
"data"
,
payload
[
"DATA"
])
self
.
set_plots_db
(
payload
[
"DATA"
])
self
.
ongoingAlarms
=
payload
[
"alarms"
]
if
payload
[
"type"
]
==
"BATTERY"
:
self
.
__set_db
(
"battery"
,
payload
[
"BATTERY"
])
self
.
BatterySignal
.
emit
(
self
.
get_db
(
"battery"
))
if
payload
[
"type"
]
==
"ALARM"
:
self
.
set_alarms_db
(
payload
[
"ALARM"
])
self
.
__set_db
(
"alarms"
,
payload
[
"ALARM"
])
if
payload
[
"type"
]
==
"TARGET"
:
self
.
set_targets_db
(
payload
[
"TARGET"
])
self
.
__set_db
(
"targets"
,
payload
[
"TARGET"
])
if
payload
[
"type"
]
==
"READBACK"
:
self
.
set_readback_db
(
payload
[
"READBACK"
])
self
.
__set_db
(
"readback"
,
payload
[
"READBACK"
])
if
payload
[
"type"
]
==
"PERSONAL"
:
self
.
set_personal_db
(
payload
[
"PERSONAL"
])
self
.
__set_db
(
"personal"
,
payload
[
"PERSONAL"
])
if
payload
[
"type"
]
==
"CYCLE"
:
self
.
set_cycle_db
(
payload
[
"CYCLE"
])
self
.
__set_db
(
"cycle"
,
payload
[
"CYCLE"
])
except
KeyError
:
logging
.
warning
(
f
"Invalid payload: {payload}"
)
...
...
NativeUI/alarm_widgets/tab_alarms.py
View file @
4ee8013a
...
...
@@ -51,7 +51,7 @@ class TabAlarm(QtWidgets.QWidget):
def
update_alarms
(
self
):
newAlarmPayload
=
self
.
NativeUI
.
get_db
(
"alarms"
)
if
newAlarmPayload
==
[]
:
if
newAlarmPayload
==
{}
:
return
if
newAlarmPayload
[
"alarm_code"
]
in
self
.
alarmDict
:
a
=
1
...
...
NativeUI/ui_layout.py
View file @
4ee8013a
...
...
@@ -107,7 +107,10 @@ class Layout:
)
)
self
.
widgets
.
battery_display
.
set_size
(
400
,
self
.
top_bar_height
)
self
.
widgets
.
personal_display
.
set_size
(
None
,
self
.
top_bar_height
)
self
.
widgets
.
battery_display
.
setFont
(
self
.
NativeUI
.
text_font
)
self
.
widgets
.
personal_display
.
setFont
(
self
.
NativeUI
.
text_font
)
vlayout
.
addLayout
(
hlayout
)
return
vlayout
...
...
NativeUI/widget_library/personal_display_widget.py
View file @
4ee8013a
...
...
@@ -12,7 +12,7 @@ __maintainer__ = "Tiago Sarmento"
__email__
=
"tiago.sarmento@stfc.ac.uk"
__status__
=
"Prototype"
from
PySide2
import
QtWidgets
,
QtCore
from
PySide2
import
Qt
Gui
,
Qt
Widgets
,
QtCore
class
PersonalDisplayWidget
(
QtWidgets
.
QWidget
):
...
...
@@ -25,10 +25,43 @@ class PersonalDisplayWidget(QtWidgets.QWidget):
self
.
info_label
=
QtWidgets
.
QLabel
(
"Person person, 55kg"
)
self
.
info_label
.
setStyleSheet
(
"font:"
+
NativeUI
.
text_size
+
";"
"color:"
+
NativeUI
.
colors
[
"page_foreground"
]
.
name
()
+
";"
)
self
.
info_label
.
setAlignment
(
QtCore
.
Qt
.
AlignCenter
)
hlayout
=
QtWidgets
.
QHBoxLayout
()
hlayout
.
addWidget
(
self
.
info_label
)
self
.
setLayout
(
hlayout
)
def
set_size
(
self
,
x
:
int
,
y
:
int
)
->
int
:
"""
Set the size of the personal display widget.
A size can be left free to change by setting its value to None.
"""
x_set
,
y_set
=
False
,
False
if
x
is
not
None
:
x_set
=
True
if
y
is
not
None
:
y_set
=
True
if
x_set
and
y_set
:
self
.
setFixedSize
(
x
,
y
)
self
.
info_label
.
setFixedSize
(
x
,
y
)
elif
x_set
and
not
y_set
:
self
.
setFixedWidth
(
x
)
self
.
info_label
.
setFixedWidth
(
x
)
elif
y_set
and
not
x_set
:
self
.
setFixedHeight
(
y
)
self
.
info_label
.
setFixedHeight
(
y
)
else
:
raise
ValueError
(
"set_size called with no size information"
)
return
0
def
setFont
(
self
,
font
:
QtGui
.
QFont
)
->
int
:
"""
Overrides the existing setFont method in order to propogate the change to
subwidgets.
"""
self
.
info_label
.
setFont
(
font
)
return
0
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