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
213d6f75
Commit
213d6f75
authored
Jun 18, 2021
by
Tiago Sarmento
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ui_dev' of
https://ohwr.org/project/hev
into ui_dev
parents
d2b199da
8a157ea5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
136 additions
and
112 deletions
+136
-112
global_spinbox.py
NativeUI/global_widgets/global_spinbox.py
+4
-4
global_typeval_popup.py
NativeUI/global_widgets/global_typeval_popup.py
+1
-1
clinical_handler.py
NativeUI/handler_library/clinical_handler.py
+71
-53
extras_handler.py
NativeUI/handler_library/extras_handler.py
+4
-5
mode_handler.py
NativeUI/handler_library/mode_handler.py
+4
-5
hev_alarms.py
NativeUI/hev_alarms.py
+2
-1
personal_handler.py
NativeUI/mode_widgets/personal_handler.py
+26
-21
ui_layout.py
NativeUI/ui_layout.py
+3
-4
alarm_control_widget.py
NativeUI/widget_library/alarm_control_widget.py
+3
-2
line_edit_widget.py
NativeUI/widget_library/line_edit_widget.py
+6
-5
startup_handler.py
NativeUI/widget_library/startup_handler.py
+2
-1
hevclient.py
raspberry-dataserver/hevclient.py
+10
-10
No files found.
NativeUI/global_widgets/global_spinbox.py
View file @
213d6f75
...
...
@@ -312,10 +312,10 @@ class labelledSpin(QtWidgets.QWidget):
if
x
is
not
None
:
self
.
setFixedWidth
(
x
)
x_widget
=
int
(
x
/
4
-
spacing
)
self
.
nameLabel
.
setFixedWidth
(
x_widget
)
self
.
simpleSpin
.
setFixedWidth
(
2
*
x_widget
)
self
.
unitLabel
.
setFixedWidth
(
x_widget
)
x_widget
=
int
(
x
/
8
)
self
.
nameLabel
.
setFixedWidth
(
3
*
x_widget
-
spacing
)
self
.
simpleSpin
.
setFixedWidth
(
3
*
x_widget
-
spacing
)
self
.
unitLabel
.
setFixedWidth
(
2
*
x_widget
-
spacing
)
if
y
is
not
None
:
self
.
setFixedHeight
(
y
)
for
widget
in
self
.
widgetList
:
...
...
NativeUI/global_widgets/global_typeval_popup.py
View file @
213d6f75
...
...
@@ -176,7 +176,7 @@ class AbstractTypeValPopup(QtWidgets.QDialog):
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"""
print
(
symbol
)
logging
.
debug
(
symbol
)
oldText
=
self
.
lineEdit
.
text
()
newText
=
oldText
if
symbol
.
isnumeric
()
or
(
symbol
==
"."
):
...
...
NativeUI/handler_library/clinical_handler.py
View file @
213d6f75
This diff is collapsed.
Click to expand it.
NativeUI/handler_library/extras_handler.py
View file @
213d6f75
...
...
@@ -4,6 +4,7 @@ personal_handler.py
from
handler_library.handler
import
PayloadHandler
from
PySide2.QtCore
import
Signal
import
logging
class
ExtraHandler
(
PayloadHandler
):
...
...
@@ -11,7 +12,6 @@ class ExtraHandler(PayloadHandler):
temporay - just to check new payloads make it through to nativeUI
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
()
.
__init__
([
"ALARM_MUTE"
,
"BAD_THRESHOLD"
],
*
args
,
**
kwargs
)
...
...
@@ -21,10 +21,9 @@ class ExtraHandler(PayloadHandler):
and emit the UpdatePersonalDisplay signal.
"""
current_data
=
self
.
get_db
()
print
(
'got a new payload'
)
print
(
current_data
)
logging
.
info
(
"got a new payload:
\n
"
,
current_data
)
outdict
=
{}
#for key in ["name", "patient_id", "age", "sex", "height", "weight"]:
#
for key in ["name", "patient_id", "age", "sex", "height", "weight"]:
# outdict[key] = current_data[key]
#self.UpdatePersonalDisplay.emit(outdict)
#
self.UpdatePersonalDisplay.emit(outdict)
return
0
NativeUI/handler_library/mode_handler.py
View file @
213d6f75
...
...
@@ -122,8 +122,7 @@ class ModeHandler(PayloadHandler):
a
=
1
else
:
for
command
in
self
.
commandList
:
print
(
"sending commands"
)
print
(
command
)
logging
.
info
(
"sending commands:"
,
command
)
self
.
NativeUI
.
q_send_cmd
(
*
command
)
self
.
modeSwitched
.
emit
(
self
.
activeMode
)
self
.
commandSent
()
...
...
@@ -134,11 +133,11 @@ class ModeHandler(PayloadHandler):
if
buttonMode
in
widget
:
self
.
spinDict
[
widget
]
.
manuallyUpdated
=
False
if
buttonMode
==
self
.
NativeUI
.
currentMode
:
print
(
"modes match "
)
logging
.
debug
(
"modes match "
)
for
widget
in
self
.
mainSpinDict
:
self
.
mainSpinDict
[
widget
]
.
manuallyUpdated
=
False
else
:
print
(
"do nothing in clinical"
)
logging
.
debug
(
"do nothing in clinical"
)
self
.
active_payload
()
self
.
refresh_button_colour
()
self
.
refresh_main_button_colour
()
...
...
@@ -227,6 +226,6 @@ class ModeHandler(PayloadHandler):
def
get_mode
(
self
,
key
:
str
):
"""Get mode from the widget's corresponding key."""
for
mode
in
self
.
modeList
+
[
'CURRENT'
]:
for
mode
in
self
.
modeList
+
[
"CURRENT"
]:
if
mode
in
key
:
return
mode
NativeUI/hev_alarms.py
View file @
213d6f75
...
...
@@ -19,6 +19,7 @@ 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
import
logging
class
AlarmView
(
TemplateMainPages
):
...
...
@@ -58,7 +59,7 @@ class AlarmView(TemplateMainPages):
self
.
timer
.
start
()
def
updateAlarms
(
self
):
print
(
"attempting new alarms"
)
logging
.
info
(
"attempting new alarms"
)
newAlarmPayload
=
self
.
NativeUI
.
get_db
(
"alarms"
)
if
newAlarmPayload
==
[]:
return
...
...
NativeUI/mode_widgets/personal_handler.py
View file @
213d6f75
from
global_widgets.global_spinbox
import
labelledSpin
from
widget_library.ok_cancel_buttons_widget
import
OkButtonWidget
,
CancelButtonWidget
,
OkSendButtonWidget
#from global_widgets.global_send_popup import SetConfirmPopup
from
widget_library.ok_cancel_buttons_widget
import
(
OkButtonWidget
,
CancelButtonWidget
,
OkSendButtonWidget
,
)
# from global_widgets.global_send_popup import SetConfirmPopup
from
widget_library.line_edit_widget
import
LabelledLineEditWidget
from
handler_library.handler
import
PayloadHandler
from
PySide2.QtCore
import
Signal
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
import
logging
class
PersonalHandler
(
PayloadHandler
):
# chose QWidget over QDialog family because easier to modify
class
PersonalHandler
(
PayloadHandler
):
# chose QWidget over QDialog family because easier to modify
UpdatePersonal
=
Signal
(
dict
)
OpenPopup
=
QtCore
.
Signal
(
PayloadHandler
,
list
)
def
__init__
(
self
,
NativeUI
,
*
args
,
**
kwargs
):
super
()
.
__init__
([
'PERSONAL'
],
*
args
,
**
kwargs
)
super
()
.
__init__
([
"PERSONAL"
],
*
args
,
**
kwargs
)
self
.
NativeUI
=
NativeUI
self
.
spinDict
=
{}
self
.
buttonDict
=
{}
...
...
@@ -23,7 +32,11 @@ class PersonalHandler(PayloadHandler): # chose QWidget over QDialog family beca
self
.
spinDict
[
key
]
=
widget
if
isinstance
(
widget
,
LabelledLineEditWidget
):
self
.
textDict
[
key
]
=
widget
if
isinstance
(
widget
,
OkButtonWidget
)
or
isinstance
(
widget
,
CancelButtonWidget
)
or
isinstance
(
widget
,
OkSendButtonWidget
):
if
(
isinstance
(
widget
,
OkButtonWidget
)
or
isinstance
(
widget
,
CancelButtonWidget
)
or
isinstance
(
widget
,
OkSendButtonWidget
)
):
self
.
buttonDict
[
key
]
=
widget
def
active_payload
(
self
,
*
args
,
**
kwargs
)
->
int
:
...
...
@@ -38,33 +51,26 @@ class PersonalHandler(PayloadHandler): # chose QWidget over QDialog family beca
self
.
UpdatePersonal
.
emit
(
outdict
)
return
0
def
handle_okbutton_click
(
self
,
key
):
message
,
command
=
[],
[]
for
key
,
widget
in
dict
(
self
.
spinDict
,
**
self
.
textDict
)
.
items
():
if
widget
.
manuallyUpdated
:
setVal
=
widget
.
get_value
()
if
isinstance
(
setVal
,
float
)
or
isinstance
(
setVal
,
int
):
if
isinstance
(
setVal
,
float
)
or
isinstance
(
setVal
,
int
):
setVal
=
round
(
setVal
,
widget
.
decPlaces
)
message
.
append
(
"set"
+
key
+
" to "
+
str
(
setVal
))
command
.
append
(
[
widget
.
cmd_type
,
widget
.
cmd_code
,
setVal
,
]
)
print
(
command
)
command
.
append
([
widget
.
cmd_type
,
widget
.
cmd_code
,
setVal
])
logging
.
info
(
command
)
self
.
commandList
=
command
if
'send'
in
key
:
if
"send"
in
key
:
self
.
sendCommands
()
else
:
print
(
'open popup please'
)
self
.
OpenPopup
.
emit
(
self
,
message
)
logging
.
debug
(
"open popup please"
)
self
.
OpenPopup
.
emit
(
self
,
message
)
def
sendCommands
(
self
):
if
self
.
commandList
==
[]:
a
=
1
a
=
1
else
:
for
command
in
self
.
commandList
:
self
.
NativeUI
.
q_send_cmd
(
*
command
)
...
...
@@ -77,7 +83,6 @@ class PersonalHandler(PayloadHandler): # chose QWidget over QDialog family beca
widget
.
manuallyUpdated
=
False
self
.
refresh_button_colour
()
def
handle_manual_change
(
self
,
changed_spin_key
):
self
.
refresh_button_colour
()
...
...
@@ -86,4 +91,4 @@ class PersonalHandler(PayloadHandler): # chose QWidget over QDialog family beca
for
key
,
widget
in
dict
(
self
.
spinDict
,
**
self
.
textDict
)
.
items
():
self
.
manuallyUpdated
=
self
.
manuallyUpdated
or
widget
.
manuallyUpdated
for
button
in
self
.
buttonDict
:
self
.
buttonDict
[
button
]
.
setColour
(
str
(
int
(
self
.
manuallyUpdated
)))
\ No newline at end of file
self
.
buttonDict
[
button
]
.
setColour
(
str
(
int
(
self
.
manuallyUpdated
)))
NativeUI/ui_layout.py
View file @
213d6f75
...
...
@@ -167,7 +167,7 @@ class Layout:
vlayout
.
addWidget
(
widget
)
widget
.
setFont
(
self
.
NativeUI
.
text_font
)
widget
.
set_size
(
int
(
self
.
screen_width
/
2
-
self
.
widget_spacing
),
int
(
panel_width
-
self
.
widget_spacing
),
self
.
min_button_height
,
spacing
=
self
.
widget_spacing
,
)
...
...
@@ -176,6 +176,7 @@ class Layout:
# self.widgets.alarm_control_startup.set_size(None, self.min_button_height)
widg
=
LocalisedQWidget
()
widg
.
setLayout
(
vlayout
)
widg
.
setFixedWidth
(
panel_width
)
return
widg
def
global_layout
(
self
):
...
...
@@ -615,9 +616,7 @@ class Layout:
spinList
.
append
(
self
.
NativeUI
.
widgets
.
get_widget
(
attrName
))
if
len
(
spinList
)
!=
len
(
enableList
):
print
(
"lengths do not match, error!"
)
print
(
spinList
)
print
(
enableList
)
logging
.
error
(
"lengths do not match, error!
\n
"
,
spinList
,
"
\n
"
,
enableList
)
radioWidgets
=
[
"Inhale Time"
,
"IE Ratio"
]
vLayout
=
QtWidgets
.
QVBoxLayout
()
...
...
NativeUI/widget_library/alarm_control_widget.py
View file @
213d6f75
...
...
@@ -14,6 +14,7 @@ __status__ = "Prototype"
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
import
os
import
logging
class
AlarmControlWidget
(
QtWidgets
.
QWidget
):
...
...
@@ -127,8 +128,8 @@ class AlarmControlWidget(QtWidgets.QWidget):
self
.
NativeUI
.
q_send_cmd
(
"MUTE_ALARM"
,
"FALSE"
)
def
test_speakers
(
self
):
print
(
"testin!"
)
print
(
self
.
volState
)
logging
.
debug
(
"testin!"
)
logging
.
debug
(
self
.
volState
)
self
.
NativeUI
.
q_send_cmd
(
"TEST_AUDIO_ALARM"
)
def
buttonPushed
(
self
,
index
):
...
...
NativeUI/widget_library/line_edit_widget.py
View file @
213d6f75
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
import
logging
# from global_widgets.global_typeval_popup import TypeValuePopup
...
...
@@ -130,7 +131,7 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
if
newVal
==
{}:
a
=
1
# do nothing
else
:
print
(
"got a personal db"
)
logging
.
debug
(
"got a personal db"
)
self
.
simpleSpin
.
setText
(
newVal
)
self
.
simpleSpin
.
setProperty
(
"textColour"
,
"1"
)
self
.
simpleSpin
.
style
()
.
polish
(
self
.
simpleSpin
)
...
...
@@ -146,10 +147,10 @@ class LabelledLineEditWidget(QtWidgets.QWidget):
if
x
is
not
None
:
self
.
setFixedWidth
(
x
)
x_widget
=
int
(
x
/
4
-
spacing
)
self
.
nameLabel
.
setFixedWidth
(
x_widget
)
self
.
simpleSpin
.
setFixedWidth
(
2
*
x_widget
)
self
.
unitLabel
.
setFixedWidth
(
x_widget
)
x_widget
=
int
(
x
/
8
)
self
.
nameLabel
.
setFixedWidth
(
3
*
x_widget
-
spacing
)
self
.
simpleSpin
.
setFixedWidth
(
3
*
x_widget
-
spacing
)
self
.
unitLabel
.
setFixedWidth
(
2
*
x_widget
-
spacing
)
if
y
is
not
None
:
self
.
setFixedHeight
(
y
)
for
widget
in
self
.
widgetList
:
...
...
NativeUI/widget_library/startup_handler.py
View file @
213d6f75
...
...
@@ -10,6 +10,7 @@ from PySide2.QtWidgets import QRadioButton
from
datetime
import
datetime
import
json
from
PySide2
import
QtWidgets
,
QtGui
,
QtCore
import
logging
class
StartupHandler
(
...
...
@@ -137,7 +138,7 @@ class StartupHandler(
self
.
buttonDict
[
"backButton"
]
.
setColour
(
1
)
def
handle_backbutton
(
self
,
stack
):
print
(
"backbutton pressed"
)
logging
.
debug
(
"backbutton pressed"
)
currentIndex
=
stack
.
currentIndex
()
nextIndex
=
currentIndex
-
1
stack
.
setCurrentIndex
(
nextIndex
)
...
...
raspberry-dataserver/hevclient.py
View file @
213d6f75
...
...
@@ -61,8 +61,8 @@ class HEVClient(object):
self
.
_target
=
None
# db for sensor values
self
.
_logmsg
=
None
# db for sensor values
self
.
_thresholds
=
None
# db for sensor values
self
.
_alarm_mute
=
None
# db for alarm mute state
self
.
_bad_threshold
=
None
# db for bad threshold warnings
self
.
_alarm_mute
=
None
# db for alarm mute state
self
.
_bad_threshold
=
None
# db for bad threshold warnings
self
.
_thresholds
=
[]
# db for threshold settings
self
.
_polling
=
polling
# keep reading data into db
self
.
_lock
=
threading
.
Lock
()
# lock for the database
...
...
@@ -308,17 +308,17 @@ if __name__ == "__main__":
hevclient
=
HEVClient
()
time
.
sleep
(
2
)
print
(
hevclient
.
send_cmd
(
"GENERAL"
,
"START"
))
logging
.
info
(
hevclient
.
send_cmd
(
"GENERAL"
,
"START"
))
# Play with sensor values and alarms
for
i
in
range
(
20
):
values
=
hevclient
.
get_values
()
# returns a dict or None
alarms
=
hevclient
.
get_alarms
()
# returns a list of alarms currently ongoing
print
(
values
)
logging
.
info
(
values
)
if
values
is
None
:
i
=
i
+
1
if
i
>
0
else
0
else
:
print
(
f
"Values: {json.dumps(values, indent=4)}"
)
print
(
f
"Alarms: {alarms}"
)
logging
.
info
(
f
"Values: {json.dumps(values, indent=4)}"
)
logging
.
info
(
f
"Alarms: {alarms}"
)
time
.
sleep
(
1
)
# acknowledge the oldest alarm
...
...
@@ -328,15 +328,15 @@ if __name__ == "__main__":
logging
.
info
(
"No alarms received"
)
time
.
sleep
(
2
)
print
(
f
"Alarms: {hevclient.get_alarms()}"
)
logging
.
info
(
f
"Alarms: {hevclient.get_alarms()}"
)
# set a timeout
hevclient
.
send_cmd
(
"SET_DURATION"
,
"INHALE"
,
1111
)
# check for the readback
for
i
in
range
(
10
):
print
(
f
"Readback: {json.dumps(hevclient.get_readback(), indent=4)}"
)
print
(
f
"Alarms: {hevclient.get_alarms()}"
)
logging
.
info
(
f
"Readback: {json.dumps(hevclient.get_readback(), indent=4)}"
)
logging
.
info
(
f
"Alarms: {hevclient.get_alarms()}"
)
time
.
sleep
(
1
)
print
(
hevclient
.
send_cmd
(
"GENERAL"
,
"STOP"
))
logging
.
info
(
hevclient
.
send_cmd
(
"GENERAL"
,
"STOP"
))
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