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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LOFAR2.0
tango
Commits
ae351682
Commit
ae351682
authored
Jun 16, 2021
by
Jan David Mol
Browse files
Options
Downloads
Patches
Plain Diff
Added comments and improved naming.
parent
a8970e5e
No related branches found
No related tags found
1 merge request
!56
L2SS-244: Expose the SSTs in MPs
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
devices/Statistics.py
+3
-3
3 additions, 3 deletions
devices/Statistics.py
devices/clients/sst_client.py
+33
-15
33 additions, 15 deletions
devices/clients/sst_client.py
with
36 additions
and
18 deletions
devices/Statistics.py
+
3
−
3
View file @
ae351682
...
@@ -55,10 +55,10 @@ class Statistics(hardware_device):
...
@@ -55,10 +55,10 @@ class Statistics(hardware_device):
queue_fill_percentage_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
queue_fill_percentage
"
},
datatype
=
numpy
.
float32
)
queue_fill_percentage_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
queue_fill_percentage
"
},
datatype
=
numpy
.
float32
)
nof_invalid_packets_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
nof_invalid_packets
"
},
datatype
=
numpy
.
uint64
)
nof_invalid_packets_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
nof_invalid_packets
"
},
datatype
=
numpy
.
uint64
)
nof_valid_pa
cket
s_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
nof_valid_pa
cket
s
"
},
dims
=
(
SST_collector
.
MAX_INPUTS
,),
datatype
=
numpy
.
uint64
)
nof_valid_pa
yload
s_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
nof_valid_pa
yload
s
"
},
dims
=
(
SST_collector
.
MAX_INPUTS
,),
datatype
=
numpy
.
uint64
)
nof_payload_errors_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
nof_payload_errors
"
},
dims
=
(
SST_collector
.
MAX_INPUTS
,),
datatype
=
numpy
.
uint64
)
nof_payload_errors_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
nof_payload_errors
"
},
dims
=
(
SST_collector
.
MAX_INPUTS
,),
datatype
=
numpy
.
uint64
)
la
st_
value_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
la
st_values
"
},
dims
=
(
SST_collector
.
MAX_SUBBANDS
,
SST_collector
.
MAX_INPUTS
),
datatype
=
numpy
.
uint64
)
s
st_
R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
s
st_values
"
},
dims
=
(
SST_collector
.
MAX_SUBBANDS
,
SST_collector
.
MAX_INPUTS
),
datatype
=
numpy
.
uint64
)
la
st_timestamp_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
la
st_timestamps
"
},
dims
=
(
SST_collector
.
MAX_INPUTS
,),
datatype
=
numpy
.
uint64
)
s
st_timestamp_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
s
st_timestamps
"
},
dims
=
(
SST_collector
.
MAX_INPUTS
,),
datatype
=
numpy
.
uint64
)
integration_interval_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
integration_intervals
"
},
dims
=
(
SST_collector
.
MAX_INPUTS
,),
datatype
=
numpy
.
float32
)
integration_interval_R
=
attribute_wrapper
(
comms_annotation
=
{
"
parameter
"
:
"
integration_intervals
"
},
dims
=
(
SST_collector
.
MAX_INPUTS
,),
datatype
=
numpy
.
float32
)
# --------
# --------
...
...
This diff is collapsed.
Click to expand it.
devices/clients/sst_client.py
+
33
−
15
View file @
ae351682
...
@@ -56,6 +56,10 @@ class sst_client(CommClient):
...
@@ -56,6 +56,10 @@ class sst_client(CommClient):
return
super
().
connect
()
return
super
().
connect
()
def
disconnect
(
self
):
def
disconnect
(
self
):
# explicit disconnect, instead of waiting for the GC to kick in after "del" below
self
.
sst
.
join
()
self
.
udp
.
join
()
del
self
.
udp
del
self
.
udp
del
self
.
sst
del
self
.
sst
del
self
.
queue
del
self
.
queue
...
@@ -113,10 +117,16 @@ class UDP_Receiver(Thread):
...
@@ -113,10 +117,16 @@ class UDP_Receiver(Thread):
self
.
host
=
host
self
.
host
=
host
self
.
port
=
port
self
.
port
=
port
logger
.
debug
(
"
binding a socket on UDP port {}
and host
{}
"
.
format
(
self
.
por
t
,
self
.
hos
t
))
logger
.
debug
(
"
binding a socket on UDP port {}
:
{}
"
.
format
(
self
.
hos
t
,
self
.
por
t
))
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
self
.
sock
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_DGRAM
)
# allow binding even if there are still lingering packets for a previous listener
self
.
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
self
.
sock
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
# specify what host and port to listen on
self
.
sock
.
bind
((
self
.
host
,
self
.
port
))
self
.
sock
.
bind
((
self
.
host
,
self
.
port
))
# make sure we can stop receiving packets even if none arrive
self
.
sock
.
settimeout
(
timeout
)
self
.
sock
.
settimeout
(
timeout
)
self
.
stream_on
=
True
self
.
stream_on
=
True
...
@@ -126,7 +136,7 @@ class UDP_Receiver(Thread):
...
@@ -126,7 +136,7 @@ class UDP_Receiver(Thread):
def
run
(
self
):
def
run
(
self
):
# all variables are manually defined and are updated each time
# all variables are manually defined and are updated each time
logger
.
debug
(
"
s
tarting UDP thread
with p
or
t
{}
and host
{}
"
.
format
(
self
.
por
t
,
self
.
hos
t
))
logger
.
info
(
"
S
tarting UDP thread
f
or {}
:
{}
"
.
format
(
self
.
hos
t
,
self
.
por
t
))
while
self
.
stream_on
:
while
self
.
stream_on
:
try
:
try
:
...
@@ -135,12 +145,18 @@ class UDP_Receiver(Thread):
...
@@ -135,12 +145,18 @@ class UDP_Receiver(Thread):
except
socket
.
timeout
:
except
socket
.
timeout
:
pass
pass
except
queue
.
Full
:
except
queue
.
Full
:
# overflow -- just discard
pass
pass
def
disconnect
(
self
):
logger
.
info
(
"
Stopping UDP thread for {}:{}
"
.
format
(
self
.
host
,
self
.
port
))
def
join
(
self
,
timeout
=
0
):
logging
.
info
(
"
Sending shutdown to UDP thread for {}:{}
"
.
format
(
self
.
host
,
self
.
port
))
self
.
stream_on
=
False
self
.
stream_on
=
False
self
.
join
()
self
.
join
(
timeout
)
# shutdown the socket so that others can listen on this port
self
.
sock
.
shutdown
(
socket
.
SHUT_RDWR
)
self
.
sock
.
shutdown
(
socket
.
SHUT_RDWR
)
def
__del__
(
self
):
def
__del__
(
self
):
...
@@ -166,15 +182,15 @@ class SST_collector(Thread):
...
@@ -166,15 +182,15 @@ class SST_collector(Thread):
# Packet count for packets that could not be parsed as SSTs
# Packet count for packets that could not be parsed as SSTs
"
nof_invalid_packets
"
:
numpy
.
uint64
(
0
),
"
nof_invalid_packets
"
:
numpy
.
uint64
(
0
),
# Number of packets received so far that we could parse correctly
# Number of packets received so far that we could parse correctly
and do not have a payload error
"
nof_valid_pa
cket
s
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,),
dtype
=
numpy
.
uint64
),
"
nof_valid_pa
yload
s
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,),
dtype
=
numpy
.
uint64
),
# Packets that reported a payload error
# Packets that reported a payload error
"
nof_payload_errors
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,),
dtype
=
numpy
.
uint64
),
"
nof_payload_errors
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,),
dtype
=
numpy
.
uint64
),
# Last value array we've constructed out of the packets
# Last value array we've constructed out of the packets
"
la
st_values
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,
self
.
MAX_SUBBANDS
),
dtype
=
numpy
.
uint64
),
"
s
st_values
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,
self
.
MAX_SUBBANDS
),
dtype
=
numpy
.
uint64
),
"
la
st_timestamps
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,),
dtype
=
numpy
.
float64
),
"
s
st_timestamps
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,),
dtype
=
numpy
.
float64
),
"
integration_intervals
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,),
dtype
=
numpy
.
float32
),
"
integration_intervals
"
:
numpy
.
zeros
((
self
.
MAX_INPUTS
,),
dtype
=
numpy
.
float32
),
}
}
...
@@ -182,7 +198,7 @@ class SST_collector(Thread):
...
@@ -182,7 +198,7 @@ class SST_collector(Thread):
self
.
start
()
self
.
start
()
def
run
(
self
):
def
run
(
self
):
logging
.
info
(
"
s
tarting SST thread
"
)
logging
.
info
(
"
S
tarting SST thread
"
)
while
True
:
while
True
:
self
.
last_packet
=
self
.
queue
.
get
()
self
.
last_packet
=
self
.
queue
.
get
()
...
@@ -192,11 +208,12 @@ class SST_collector(Thread):
...
@@ -192,11 +208,12 @@ class SST_collector(Thread):
self
.
process_packet
(
self
.
last_packet
)
self
.
process_packet
(
self
.
last_packet
)
logging
.
info
(
"
shutting down
SST thread
"
)
logging
.
info
(
"
Stopping
SST thread
"
)
def
join
(
self
,
timeout
=
0
):
def
join
(
self
,
timeout
=
0
):
logging
.
info
(
"
s
ending shutdown to SST thread
"
)
logging
.
info
(
"
S
ending shutdown to SST thread
"
)
self
.
queue
.
put
(
None
)
self
.
queue
.
put
(
None
)
super
().
join
(
timeout
)
super
().
join
(
timeout
)
def
process_packet
(
self
,
packet
):
def
process_packet
(
self
,
packet
):
...
@@ -218,6 +235,7 @@ class SST_collector(Thread):
...
@@ -218,6 +235,7 @@ class SST_collector(Thread):
self
.
parameters
[
"
nof_invalid_packets
"
]
+=
numpy
.
uint64
(
1
)
self
.
parameters
[
"
nof_invalid_packets
"
]
+=
numpy
.
uint64
(
1
)
return
return
# which input this packet contains data for
input_index
=
fields
.
sst_signal_input_index
input_index
=
fields
.
sst_signal_input_index
if
input_index
>=
self
.
MAX_INPUTS
:
if
input_index
>=
self
.
MAX_INPUTS
:
...
@@ -231,12 +249,12 @@ class SST_collector(Thread):
...
@@ -231,12 +249,12 @@ class SST_collector(Thread):
return
return
# process the packet
# process the packet
self
.
parameters
[
"
nof_valid_pa
cket
s
"
][
input_index
]
+=
numpy
.
uint64
(
1
)
self
.
parameters
[
"
nof_valid_pa
yload
s
"
][
input_index
]
+=
numpy
.
uint64
(
1
)
self
.
parameters
[
"
la
st_values
"
][
input_index
][:
fields
.
nof_statistics_per_packet
]
=
fields
.
payload_sst
self
.
parameters
[
"
s
st_values
"
][
input_index
][:
fields
.
nof_statistics_per_packet
]
=
fields
.
payload_sst
self
.
parameters
[
"
la
st_timestamps
"
][
input_index
]
=
numpy
.
float64
(
fields
.
timestamp
().
timestamp
())
self
.
parameters
[
"
s
st_timestamps
"
][
input_index
]
=
numpy
.
float64
(
fields
.
timestamp
().
timestamp
())
self
.
parameters
[
"
integration_intervals
"
][
input_index
]
=
fields
.
integration_interval
()
self
.
parameters
[
"
integration_intervals
"
][
input_index
]
=
fields
.
integration_interval
()
except
Exception
as
e
:
except
Exception
as
e
:
# This is unexpected, so print a stack trace
# This is unexpected, so print a stack trace
logging
.
exception
(
"
Could not parse UDP packet
"
)
logging
.
exception
(
"
Could not parse
SST
UDP packet
"
)
self
.
parameters
[
"
nof_invalid_packets
"
]
+=
numpy
.
uint64
(
1
)
self
.
parameters
[
"
nof_invalid_packets
"
]
+=
numpy
.
uint64
(
1
)
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