Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.backend.python
Commits
890da671
Commit
890da671
authored
Mar 15, 2017
by
Philip ABBET
Browse files
Inputs: receive data indexes alongside data units
parent
f0c66547
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/backend/python/inputs.py
View file @
890da671
...
...
@@ -68,8 +68,11 @@ class Input:
self
.
data_format
=
data_format
self
.
socket
=
socket
self
.
data
=
None
self
.
data_index
=
-
1
self
.
data_index_end
=
-
1
self
.
group
=
None
self
.
comm_time
=
0.
#total time spent on communication
self
.
nb_data_blocks_read
=
0
def
isDataUnitDone
(
self
):
...
...
@@ -108,15 +111,19 @@ class Input:
self
.
socket
.
send
(
'nxt'
,
zmq
.
SNDMORE
)
self
.
socket
.
send
(
self
.
group
.
channel
,
zmq
.
SNDMORE
)
self
.
socket
.
send
(
self
.
name
)
self
.
data_index
=
int
(
self
.
socket
.
recv
())
self
.
data_index_end
=
int
(
self
.
socket
.
recv
())
self
.
unpack
(
self
.
socket
.
recv
())
self
.
comm_time
+=
time
.
time
()
-
_start
self
.
nb_data_blocks_read
+=
1
def
unpack
(
self
,
packed
):
"""Receives data through socket"""
self
.
data
=
self
.
data_format
.
type
()
logger
.
debug
(
'recv: <bin> (size=%d)'
,
len
(
packed
))
logger
.
debug
(
'recv: <bin> (size=%d), indexes=(%d, %d)'
,
len
(
packed
),
self
.
data_index
,
self
.
data_index_end
)
self
.
data
.
unpack
(
packed
)
...
...
@@ -239,7 +246,10 @@ class InputGroup:
"channel `%s' while performing `next' operation on this group "
\
"(current reading position is %d/%d)"
%
\
(
name
,
self
.
channel
,
k
,
n
))
inpt
.
data_index
=
int
(
parts
.
pop
(
0
))
inpt
.
data_index_end
=
int
(
parts
.
pop
(
0
))
inpt
.
unpack
(
parts
.
pop
(
0
))
inpt
.
nb_data_blocks_read
+=
1
self
.
comm_time
+=
time
.
time
()
-
_start
...
...
Write
Preview
Supports
Markdown
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