Skip to content
Snippets Groups Projects
Commit dc070e14 authored by Jan David Mol's avatar Jan David Mol
Browse files

Merge branch 'L2SS-271-statistics-base-class' into 'master'

L2SS-271: Emergency patches

Closes L2SS-271

See merge request !93
parents 39654b4d b90f9c9e
No related branches found
No related tags found
1 merge request!93L2SS-271: Emergency patches
...@@ -26,7 +26,7 @@ from tango import AttrWriteType ...@@ -26,7 +26,7 @@ from tango import AttrWriteType
from clients.attribute_wrapper import attribute_wrapper from clients.attribute_wrapper import attribute_wrapper
from clients.opcua_client import OPCUAConnection from clients.opcua_client import OPCUAConnection
from clients.StatisticsClient import StatisticsClient from clients.statistics_client import StatisticsClient
from devices.hardware_device import hardware_device from devices.hardware_device import hardware_device
......
...@@ -120,7 +120,7 @@ class Statistics(hardware_device, metaclass=ABCMeta): ...@@ -120,7 +120,7 @@ class Statistics(hardware_device, metaclass=ABCMeta):
""" user code here. is called when the sate is set to INIT """ """ user code here. is called when the sate is set to INIT """
"""Initialises the attributes and properties of the statistics device.""" """Initialises the attributes and properties of the statistics device."""
self.statistics_client = StasticsClient(self.STATISTICS_COLLECTOR_CLASS, "0.0.0.0", self.Statistics_Client_Port, self.Fault, self) self.statistics_client = StatisticsClient(self.STATISTICS_COLLECTOR_CLASS, "0.0.0.0", self.Statistics_Client_Port, self.Fault, self)
self.OPCUA_client = OPCUAConnection("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), "http://lofar.eu", self.OPC_Time_Out, self.Fault, self) self.OPCUA_client = OPCUAConnection("opc.tcp://{}:{}/".format(self.OPC_Server_Name, self.OPC_Server_Port), "http://lofar.eu", self.OPC_Time_Out, self.Fault, self)
......
...@@ -23,7 +23,13 @@ class StatisticsCollector(Thread): ...@@ -23,7 +23,13 @@ class StatisticsCollector(Thread):
self.queue = queue self.queue = queue
self.last_packet = None self.last_packet = None
self.parameters = { self.parameters = self._default_parameters()
super().__init__()
self.start()
def _default_parameters(self):
return {
"nof_packets": numpy.uint64(0), "nof_packets": numpy.uint64(0),
# Packet count for packets that could not be parsed # Packet count for packets that could not be parsed
...@@ -33,9 +39,6 @@ class StatisticsCollector(Thread): ...@@ -33,9 +39,6 @@ class StatisticsCollector(Thread):
"last_invalid_packet": numpy.zeros((9000,), dtype=numpy.uint8), "last_invalid_packet": numpy.zeros((9000,), dtype=numpy.uint8),
} }
super().__init__()
self.start()
def run(self): def run(self):
logger.info("Starting statistics thread") logger.info("Starting statistics thread")
...@@ -54,7 +57,7 @@ class StatisticsCollector(Thread): ...@@ -54,7 +57,7 @@ class StatisticsCollector(Thread):
except Exception as e: except Exception as e:
logger.exception("Could not parse statistics UDP packet") logger.exception("Could not parse statistics UDP packet")
self.parameters["last_invalid_packet"] = numpy.frombuffer(packet, dtype=numpy.uint8) self.parameters["last_invalid_packet"] = numpy.frombuffer(self.last_packet, dtype=numpy.uint8)
self.parameters["nof_invalid_packets"] += numpy.uint64(1) self.parameters["nof_invalid_packets"] += numpy.uint64(1)
logger.info("Stopped statistics thread") logger.info("Stopped statistics thread")
...@@ -92,10 +95,10 @@ class SSTCollector(StatisticsCollector): ...@@ -92,10 +95,10 @@ class SSTCollector(StatisticsCollector):
# Maximum number of subbands we support (used to determine array sizes) # Maximum number of subbands we support (used to determine array sizes)
MAX_SUBBANDS = 512 MAX_SUBBANDS = 512
def __init__(self, queue): def _default_parameters(self):
super().__init__(queue) defaults = super()._default_parameters()
self.parameters.extend({ defaults.update({
# Number of packets received so far that we could parse correctly and do not have a payload error # Number of packets received so far that we could parse correctly and do not have a payload error
"nof_valid_payloads": numpy.zeros((self.MAX_INPUTS,), dtype=numpy.uint64), "nof_valid_payloads": numpy.zeros((self.MAX_INPUTS,), dtype=numpy.uint64),
...@@ -108,6 +111,8 @@ class SSTCollector(StatisticsCollector): ...@@ -108,6 +111,8 @@ class SSTCollector(StatisticsCollector):
"integration_intervals": numpy.zeros((self.MAX_INPUTS,), dtype=numpy.float32), "integration_intervals": numpy.zeros((self.MAX_INPUTS,), dtype=numpy.float32),
}) })
return defaults
def process_packet(self, packet): def process_packet(self, packet):
fields = SSTPacket(packet) fields = SSTPacket(packet)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment