From e7ab011e52abfd1f9b284a5e7aa1f3a1b7401ab1 Mon Sep 17 00:00:00 2001 From: Jan David Mol <mol@astron.nl> Date: Mon, 2 May 2022 13:47:13 +0200 Subject: [PATCH] L2SS-769: Fix interface to BeamTracker --- .../tangostationcontrol/devices/beam_device.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tangostationcontrol/tangostationcontrol/devices/beam_device.py b/tangostationcontrol/tangostationcontrol/devices/beam_device.py index 0ef253508..e69a10c3b 100644 --- a/tangostationcontrol/tangostationcontrol/devices/beam_device.py +++ b/tangostationcontrol/tangostationcontrol/devices/beam_device.py @@ -174,7 +174,7 @@ class beam_device(lofar_device): self._tracking_enabled_rw = True # Create a thread object to update beam weights - self.Beam_tracker = BeamTracker(self.update_pointing, self.Fault) + self.Beam_tracker = BeamTracker(self.Beam_tracking_interval, self.Beam_tracking_preparation_period, self.update_pointing, self.Fault) @log_exceptions() def configure_for_on(self): @@ -309,8 +309,10 @@ class BeamTracker(): DISCONNECT_TIMEOUT = 3.0 """ Object that encapsulates a Thread, resposible for beam tracking operations """ - def __init__(self, update_pointing_callback, fault_callback): + def __init__(self, interval, preparation_period, update_pointing_callback, fault_callback): self.thread = None + self.interval = interval + self.preparation_period = preparation_period self.update_pointing_callback = update_pointing_callback self.fault_callback = fault_callback @@ -374,13 +376,13 @@ class BeamTracker(): now = datetime.datetime.now().timestamp() # Computes the left seconds before the next update - next_update_in = self.device.Beam_tracking_interval - (now % self.device.Beam_tracking_interval) + next_update_in = self.interval - (now % self.interval) # Computes the needed sleep time before the next update - sleep_time = next_update_in - self.device.Beam_tracking_preparation_period + sleep_time = next_update_in - self.preparation_period # If sleep time is negative, add the tracking interval for the next update if sleep_time < 0: - return sleep_time + self.device.Beam_tracking_interval + return sleep_time + self.interval else: return sleep_time -- GitLab