Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tango
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira issues
Open Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
2f85e1aa
Commit
2f85e1aa
authored
3 years ago
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
L2SS-244
: Fields are all big endian.
parent
f64f7717
No related branches found
No related tags found
1 merge request
!56
L2SS-244: Expose the SSTs in MPs
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
devices/clients/StatisticsPacket.py
+12
-12
12 additions, 12 deletions
devices/clients/StatisticsPacket.py
with
12 additions
and
12 deletions
devices/clients/StatisticsPacket.py
+
12
−
12
View file @
2f85e1aa
...
...
@@ -68,13 +68,13 @@ class StatisticsPacket(object):
def
observation_id
(
self
)
->
int
:
"""
Return the ID of the observation running when this packet was generated.
"""
return
unpack
(
"
<
I
"
,
self
.
packet
[
2
:
6
])[
0
]
return
unpack
(
"
>
I
"
,
self
.
packet
[
2
:
6
])[
0
]
@property
def
station_id
(
self
)
->
int
:
"""
Return the number of the station this packet was generated on.
"""
return
unpack
(
"
<
H
"
,
self
.
packet
[
6
:
8
])[
0
]
return
unpack
(
"
>
H
"
,
self
.
packet
[
6
:
8
])[
0
]
@property
def
source_info
(
self
)
->
int
:
...
...
@@ -94,7 +94,7 @@ class StatisticsPacket(object):
reserved: reserved bits
gn_index: global index of FPGA that emitted this packet.
"""
bits
=
unpack
(
"
<
H
"
,
self
.
packet
[
8
:
10
])[
0
]
bits
=
unpack
(
"
>
H
"
,
self
.
packet
[
8
:
10
])[
0
]
return
{
"
_raw
"
:
bits
,
...
...
@@ -123,8 +123,8 @@ class StatisticsPacket(object):
def
integration_interval_raw
(
self
)
->
int
:
"""
Returns the integration interval, in blocks.
"""
# This field is 3 bytes,
little
endian, so we need to
a
ppend a 0 to parse it as a 32-bit integer.
return
unpack
(
"
<
I
"
,
self
.
packet
[
11
:
14
]
+
b
'
0
'
)[
0
]
# This field is 3 bytes,
big
endian, so we need to p
re
pend a 0 to parse it as a 32-bit integer.
return
unpack
(
"
>
I
"
,
b
'
0
'
+
self
.
packet
[
11
:
14
])[
0
]
def
integration_interval
(
self
)
->
float
:
"""
Returns the integration interval, in seconds.
"""
...
...
@@ -136,7 +136,7 @@ class StatisticsPacket(object):
def
data_id_raw
(
self
)
->
int
:
"""
Returns the generic data identifier.
"""
return
unpack
(
"
<
I
"
,
self
.
packet
[
14
:
18
])[
0
]
return
unpack
(
"
>
I
"
,
self
.
packet
[
14
:
18
])[
0
]
@property
def
sst_signal_input_index
(
self
)
->
int
:
...
...
@@ -180,25 +180,25 @@ class StatisticsPacket(object):
@property
def
nof_signal_inputs
(
self
)
->
int
:
"""
Number of inputs that were used for constructing the payload.
"""
return
unpack
(
"
<
B
"
,
self
.
packet
[
18
:
19
])[
0
]
return
unpack
(
"
>
B
"
,
self
.
packet
[
18
:
19
])[
0
]
@property
def
nof_bytes_per_statistic
(
self
)
->
int
:
"""
Word size for the payload.
"""
return
unpack
(
"
<
B
"
,
self
.
packet
[
19
:
20
])[
0
]
return
unpack
(
"
>
B
"
,
self
.
packet
[
19
:
20
])[
0
]
@property
def
nof_statistics_per_packet
(
self
)
->
int
:
"""
Number of data points in the payload.
"""
return
unpack
(
"
<
H
"
,
self
.
packet
[
20
:
22
])[
0
]
return
unpack
(
"
>
H
"
,
self
.
packet
[
20
:
22
])[
0
]
@property
def
block_period_raw
(
self
)
->
int
:
"""
Return the block period, in nanoseconds.
"""
return
unpack
(
"
<
H
"
,
self
.
packet
[
22
:
24
])[
0
]
return
unpack
(
"
>
H
"
,
self
.
packet
[
22
:
24
])[
0
]
def
block_period
(
self
)
->
float
:
"""
Return the block period, in seconds.
"""
...
...
@@ -209,7 +209,7 @@ class StatisticsPacket(object):
def
block_serial_number
(
self
)
->
int
:
"""
Block index since epoch (1970).
"""
return
unpack
(
"
<
Q
"
,
self
.
packet
[
24
:
32
])[
0
]
return
unpack
(
"
>
Q
"
,
self
.
packet
[
24
:
32
])[
0
]
def
timestamp
(
self
)
->
datetime
:
"""
Returns the timestamp of the data in this packet.
...
...
@@ -271,7 +271,7 @@ class StatisticsPacket(object):
# derive which and how many elements to read from the packet header
bytecount_to_unsigned_struct_type
=
{
1
:
'
B
'
,
2
:
'
H
'
,
4
:
'
I
'
,
8
:
'
Q
'
}
format_str
=
"
<
{}{}
"
.
format
(
self
.
nof_statistics_per_packet
,
bytecount_to_unsigned_struct_type
[
self
.
nof_bytes_per_statistic
])
format_str
=
"
>
{}{}
"
.
format
(
self
.
nof_statistics_per_packet
,
bytecount_to_unsigned_struct_type
[
self
.
nof_bytes_per_statistic
])
return
numpy
.
array
(
unpack
(
format_str
,
self
.
packet
[
32
:
32
+
calcsize
(
format_str
)]))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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