Skip to content
Snippets Groups Projects
Commit a5502c48 authored by Stefano Di Frischia's avatar Stefano Di Frischia
Browse files

L2SS-869: improve query procedure

parent 5dd23b69
No related branches found
No related tags found
1 merge request!426Resolve L2SS-869 "Improve querying in stats writer"
......@@ -181,7 +181,7 @@ class TestStatisticsWriterSST(BaseIntegrationTestCase):
)
self.assertIsNotNone(stat)
self.assertEqual(121, stat.data_id_signal_input_index)
# Test RECV attributes
# Test RECV attributes
self.assertEqual(stat.rcu_attenuator_dB, None)
self.assertEqual(stat.rcu_band_select, None)
self.assertEqual(stat.rcu_dth_on, None)
......
......@@ -120,6 +120,9 @@ class HDF5Writer(ABC):
# grab the timestamp
statistics_timestamp = statistics_packet.timestamp()
# query the device attributes for updated values
self.retrieve_attribute_values()
# ignore packets with no timestamp, as they indicate FPGA processing was
# disabled and are useless anyway.
if statistics_packet.block_serial_number == 0:
......@@ -239,6 +242,10 @@ class HDF5Writer(ABC):
else:
current_group.attrs[k] = v
@abstractmethod
def retrieve_attribute_values(self):
pass
@abstractmethod
def write_values_matrix(self, current_group):
pass
......@@ -323,6 +330,19 @@ class SstHdf5Writer(HDF5Writer):
def new_collector(self):
return StationSSTCollector(self.device)
def retrieve_attribute_values(self):
attribute_names = ["rcu_attenuator_dB", "rcu_band_select", "rcu_dth_on"]
attribute_types = {"rcu_attenuator_dB": numpy.int64, "rcu_band_select" : numpy.int64, "rcu_dth_on" : bool}
# write the device attributes
for a in attribute_names:
try:
if self.current_matrix.parameters[a] is None:
self.device_attributes[a] = h5py.Empty("f")
else:
self.device_attributes[a] = self.current_matrix.parameters[a].flatten().astype(attribute_types[a])
except AttributeError:
self.device_attributes[a] = h5py.Empty("f")
def write_values_matrix(self, current_group):
# store the SST values
......@@ -334,15 +354,6 @@ class SstHdf5Writer(HDF5Writer):
compression="gzip",
)
# write the device attributes
attribute_names = ["rcu_attenuator_dB", "rcu_band_select", "rcu_dth_on"]
attribute_types = {"rcu_attenuator_dB": numpy.int64, "rcu_band_select" : numpy.int64, "rcu_dth_on" : bool}
for a in attribute_names:
try:
self.device_attributes[a] = self.current_matrix.parameters[a].astype(attribute_types[a])
except AttributeError:
self.device_attributes[a] = h5py.Empty("f")
for k,v in self.device_attributes.items():
current_group.attrs[k] = v
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment