diff --git a/tangostationcontrol/tangostationcontrol/devices/beam_device.py b/tangostationcontrol/tangostationcontrol/devices/beam_device.py index 0ef2535081b2965888568cfcce8588407675d059..e69a10c3b584a0275f364aa1c92eccb2aee651e3 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