From fdd1b7b43b428f242505947c0c5ef53b3040a79e Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Wed, 2 Mar 2022 11:41:12 +0100
Subject: [PATCH] L2SS-667: Do not stop beam tracking if it hasn't been started

---
 .../tangostationcontrol/devices/beam.py              | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/devices/beam.py b/tangostationcontrol/tangostationcontrol/devices/beam.py
index d62a49e36..afcdf7887 100644
--- a/tangostationcontrol/tangostationcontrol/devices/beam.py
+++ b/tangostationcontrol/tangostationcontrol/devices/beam.py
@@ -87,6 +87,13 @@ class Beam(lofar_device):
     # --------
     # overloaded functions
     # --------
+
+    def init_device(self):
+        super().init_device()
+
+        # thread to perform beam tracking
+        self.HBAT_beam_tracker = None
+
     @log_exceptions()
     def configure_for_initialise(self):
         super().configure_for_initialise()
@@ -126,8 +133,9 @@ class Beam(lofar_device):
     
     @log_exceptions()
     def configure_for_off(self):
-        # Stop thread object
-        self.HBAT_beam_tracker.stop()
+        if self.HBAT_beam_tracker:
+            # Stop thread object
+            self.HBAT_beam_tracker.stop()
 
         super().configure_for_off()
 
-- 
GitLab