Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HEV - High Energy Ventilator
Manage
Activity
Members
Labels
Plan
Issues
5
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
HEV - High Energy Ventilator
Commits
dca6c726
Commit
dca6c726
authored
4 years ago
by
Dónal Murray
Browse files
Options
Downloads
Patches
Plain Diff
Get hevtestdata working with hevserver changes
parent
78cf183b
Branches
Branches containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
raspberry-dataserver/hevserver.py
+1
-5
1 addition, 5 deletions
raspberry-dataserver/hevserver.py
raspberry-dataserver/hevtestdata.py
+20
-32
20 additions, 32 deletions
raspberry-dataserver/hevtestdata.py
with
21 additions
and
37 deletions
raspberry-dataserver/hevserver.py
+
1
−
5
View file @
dca6c726
...
...
@@ -152,7 +152,6 @@ class HEVServer(object):
values
:
List
[
float
]
=
self
.
_values
alarms
=
self
.
_alarms
if
len
(
self
.
_alarms
)
>
0
else
None
print
(
values
.
getType
())
data_type
=
values
.
getType
().
name
broadcast_packet
=
{
"
type
"
:
data_type
}
...
...
@@ -218,6 +217,7 @@ class HEVServer(object):
if
__name__
==
"
__main__
"
:
tasks
=
[]
# asyncio tasks
loop
=
asyncio
.
get_event_loop
()
try
:
#parser to allow us to pass arguments to hevserver
parser
=
argparse
.
ArgumentParser
(
description
=
'
Arguments to run hevserver
'
)
...
...
@@ -254,7 +254,6 @@ if __name__ == "__main__":
# initialise low level interface
try
:
# setup serial device and init server
loop
=
asyncio
.
get_event_loop
()
lli
=
CommsLLI
(
loop
)
comms
=
lli
.
main
(
port_device
,
115200
)
tasks
.
append
(
comms
)
...
...
@@ -277,6 +276,3 @@ if __name__ == "__main__":
logging
.
info
(
"
Server stopped
"
)
except
StructError
:
logging
.
error
(
"
Failed to parse packet
"
)
finally
:
loop
.
close
()
This diff is collapsed.
Click to expand it.
raspberry-dataserver/hevtestdata.py
+
20
−
32
View file @
dca6c726
...
...
@@ -57,7 +57,7 @@ class HEVTestData:
self
.
current_timestamp
=
2
**
32
-
5_000
self
.
_send_message
(
self
.
current_timestamp
)
interval
=
50
for
i
in
range
(
0
,
10_000
,
interval
):
for
_
in
range
(
0
,
10_000
,
interval
):
self
.
current_timestamp
+=
interval
self
.
_send_message
(
self
.
current_timestamp
)
time
.
sleep
(
interval
/
1_000
)
...
...
@@ -97,24 +97,24 @@ class HEVTestData:
def
_send_message
(
self
,
timestamp
):
# directly setting private member variables in this edge case
payload
=
CommsCommon
.
DataFormat
()
payload
.
_
version
=
payload
.
_RPI_VERSION
payload
.
_
timestamp
=
timestamp
%
2
**
32
payload
.
_
fsm_state
=
"
IDLE
"
payload
.
_
pressure_air_supply
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
_
pressure_air_regulated
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
_
pressure_o2_supply
=
abs
(
math
.
sin
((
0.5
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
657
payload
.
_
pressure_o2_regulated
=
abs
(
math
.
sin
((
1.0
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
653
payload
.
_
pressure_buffer
=
abs
(
math
.
sin
((
1.5
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
496
payload
.
_
pressure_inhale
=
abs
(
math
.
sin
((
2.0
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
481
payload
.
_
pressure_patient
=
abs
(
math
.
sin
((
2.5
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
772
payload
.
_
temperature_buffer
=
math
.
sin
((
3.0
+
timestamp
/
1000
)
*
(
math
.
pi
))
*
1000
payload
.
_
pressure_diff_patient
=
abs
(
math
.
sin
((
3.5
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
61
payload
.
_
readback_valve_air_in
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
_
readback_valve_o2_in
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
_
readback_valve_inhale
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
_
readback_valve_exhale
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
_
readback_valve_purge
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
_
readback_mode
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
version
=
payload
.
_RPI_VERSION
payload
.
timestamp
=
timestamp
%
2
**
32
payload
.
fsm_state
=
CommsCommon
.
BL_STATES
.
IDLE
payload
.
pressure_air_supply
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
pressure_air_regulated
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
pressure_o2_supply
=
abs
(
math
.
sin
((
0.5
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
657
payload
.
pressure_o2_regulated
=
abs
(
math
.
sin
((
1.0
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
653
payload
.
pressure_buffer
=
abs
(
math
.
sin
((
1.5
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
496
payload
.
pressure_inhale
=
abs
(
math
.
sin
((
2.0
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
481
payload
.
pressure_patient
=
abs
(
math
.
sin
((
2.5
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
772
payload
.
temperature_buffer
=
math
.
sin
((
3.0
+
timestamp
/
1000
)
*
(
math
.
pi
))
*
1000
payload
.
pressure_diff_patient
=
abs
(
math
.
sin
((
3.5
+
timestamp
/
1000
)
*
(
math
.
pi
)))
*
61
payload
.
readback_valve_air_in
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
readback_valve_o2_in
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
readback_valve_inhale
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
readback_valve_exhale
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
readback_valve_purge
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
payload
.
readback_mode
=
abs
(
math
.
sin
((
timestamp
/
1000
)
*
(
math
.
pi
)))
*
0
self
.
payloadrecv
=
payload
# callback to dependants to read the received payload
...
...
@@ -124,23 +124,11 @@ class HEVTestData:
@payloadrecv.setter
def
payloadrecv
(
self
,
payload
):
self
.
_payloadrecv
.
append
(
payload
)
logging
.
debug
(
f
"
Pushed
{
payload
}
to FIFO
"
)
for
callback
in
self
.
_observers
:
# peek at the leftmost item, don't pop until receipt confirmed
callback
(
self
.
_payloadrecv
[
0
])
callback
(
payload
)
def
writePayload
(
self
,
payload
):
logging
.
info
(
f
"
CMD received:
{
payload
}
"
)
def
bind_to
(
self
,
callback
):
self
.
_observers
.
append
(
callback
)
def
pop_payloadrecv
(
self
):
# from callback. confirmed receipt, pop value
poppedval
=
self
.
_payloadrecv
.
popleft
()
logging
.
debug
(
f
"
Popped
{
poppedval
}
from FIFO
"
)
if
len
(
self
.
_payloadrecv
)
>
0
:
# purge full queue if Dependant goes down when it comes back up
for
callback
in
self
.
_observers
:
callback
(
self
.
_payloadrecv
[
0
])
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment