diff --git a/tangostationcontrol/tangostationcontrol/clients/statistics_client.py b/tangostationcontrol/tangostationcontrol/clients/statistics_client.py index 2075f2f6aa3ca2552d8a6648754014646fbe4b67..6981c31a5437b96af04171981f5bf3d6562963d5 100644 --- a/tangostationcontrol/tangostationcontrol/clients/statistics_client.py +++ b/tangostationcontrol/tangostationcontrol/clients/statistics_client.py @@ -97,7 +97,7 @@ class StatisticsClient(AsyncCommClient): # redirect to right object. this works as long as the parameter names are unique among them. if annotation["type"] == "statistics": def read_function(): - process_statistics_annotation(annotation, attribute, parameter) + return _process_statistics_annotation() elif annotation["type"] == "udp": def read_function(): return self.udp.parameters[parameter] @@ -111,17 +111,10 @@ class StatisticsClient(AsyncCommClient): else: raise ValueError(f"Unknown queue parameter requested: {parameter}") elif annotation["type"] == "replicator": - parameters_dict = {"clients": numpy.array(self.tcp.clients(),dtype=numpy.str), - "nof_bytes_sent": numpy.uint64(self.tcp.nof_bytes_sent), - "nof_packets_sent": numpy.uint64(self.tcp.nof_packets_sent), - "nof_tasks_pending": numpy.uint64(self.tcp.nof_tasks_pending)} - for k,v in parameters_dict.items(): - if parameter == k: - def read_function(): - return v - raise ValueError(f"Unknown replicator parameter requested: {parameter}") + def read_function(): + return _process_replicator_annotation() - def process_statistics_annotation(annotation, attribute, parameter): + def _process_statistics_annotation(): if annotation.get("reshape", False): # force array into the shape of the attribute if attribute.dim_y > 1: @@ -131,6 +124,16 @@ class StatisticsClient(AsyncCommClient): else: return self.collector.parameters[parameter] + def _process_replicator_annotation(): + parameters_dict = {"clients": numpy.array(self.tcp.clients(),dtype=numpy.str), + "nof_bytes_sent": numpy.uint64(self.tcp.nof_bytes_sent), + "nof_packets_sent": numpy.uint64(self.tcp.nof_packets_sent), + "nof_tasks_pending": numpy.uint64(self.tcp.nof_tasks_pending)} + for k,v in parameters_dict.items(): + if parameter == k: + return v + raise ValueError(f"Unknown replicator parameter requested: {parameter}") + def write_function(value): """ Not used here