From ad37b39db411ba3e8f401b21593b7de5c124d441 Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Wed, 3 Nov 2021 08:04:25 +0100
Subject: [PATCH] L2SS-470: Allow initialisation commands to be called in
 STANDBY state, and fix references to APSCT power functions.

---
 tangostationcontrol/tangostationcontrol/devices/apsct.py | 8 ++++----
 tangostationcontrol/tangostationcontrol/devices/recv.py  | 8 ++++----
 tangostationcontrol/tangostationcontrol/devices/unb2.py  | 6 +++---
 3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/devices/apsct.py b/tangostationcontrol/tangostationcontrol/devices/apsct.py
index 90a8be0d5..5d2ddf5b0 100644
--- a/tangostationcontrol/tangostationcontrol/devices/apsct.py
+++ b/tangostationcontrol/tangostationcontrol/devices/apsct.py
@@ -74,9 +74,9 @@ class APSCT(opcua_device):
         """ Initialise the APSCT hardware. """
 
         # Cycle clock
-        self.CLK_off()
+        self.APSCT_off()
         self.wait_attribute("APSCTTR_translator_busy_R", False, 10)
-        self.CLK_on()
+        self.APSCT_on()
         self.wait_attribute("APSCTTR_translator_busy_R", False, 10)
 
         if not self.proxy.APSCT_PLL_200MHz_locked_R:
@@ -91,7 +91,7 @@ class APSCT(opcua_device):
 
     @command()
     @DebugIt()
-    @only_when_on()
+    @only_in_states([DevState.STANDBY, DevState.ON])
     def APSCT_off(self):
         """
 
@@ -101,7 +101,7 @@ class APSCT(opcua_device):
 
     @command()
     @DebugIt()
-    @only_when_on()
+    @only_in_states([DevState.STANDBY, DevState.ON])
     def APSCT_on(self):
         """
 
diff --git a/tangostationcontrol/tangostationcontrol/devices/recv.py b/tangostationcontrol/tangostationcontrol/devices/recv.py
index c713690b7..5070b8cef 100644
--- a/tangostationcontrol/tangostationcontrol/devices/recv.py
+++ b/tangostationcontrol/tangostationcontrol/devices/recv.py
@@ -110,7 +110,7 @@ class RECV(opcua_device):
     # --------
     @command()
     @DebugIt()
-    @only_when_on()
+    @only_in_states([DevState.STANDBY, DevState.ON])
     def RCU_off(self):
         """
 
@@ -120,7 +120,7 @@ class RECV(opcua_device):
 
     @command()
     @DebugIt()
-    @only_when_on()
+    @only_in_states([DevState.STANDBY, DevState.ON])
     def RCU_on(self):
         """
 
@@ -130,7 +130,7 @@ class RECV(opcua_device):
 
     @command()
     @DebugIt()
-    @only_when_on()
+    @only_in_states([DevState.STANDBY, DevState.ON])
     def RCU_DTH_off(self):
         """
 
@@ -140,7 +140,7 @@ class RECV(opcua_device):
 
     @command()
     @DebugIt()
-    @only_when_on()
+    @only_in_states([DevState.STANDBY, DevState.ON])
     def RCU_DTH_on(self):
         """
 
diff --git a/tangostationcontrol/tangostationcontrol/devices/unb2.py b/tangostationcontrol/tangostationcontrol/devices/unb2.py
index c4f623c5d..a937f8d42 100644
--- a/tangostationcontrol/tangostationcontrol/devices/unb2.py
+++ b/tangostationcontrol/tangostationcontrol/devices/unb2.py
@@ -21,7 +21,7 @@ from tangostationcontrol.common.entrypoint import entry
 from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper
 from tangostationcontrol.devices.opcua_device import opcua_device
 from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions
-from tangostationcontrol.devices.device_decorators import only_when_on
+from tangostationcontrol.devices.device_decorators import only_in_states
 
 import numpy
 
@@ -124,7 +124,7 @@ class UNB2(opcua_device):
 
     @command()
     @DebugIt()
-    @only_when_on()
+    @only_in_states([DevState.STANDBY, DevState.ON])
     def UNB2_off(self):
         """
 
@@ -134,7 +134,7 @@ class UNB2(opcua_device):
 
     @command()
     @DebugIt()
-    @only_when_on()
+    @only_in_states([DevState.STANDBY, DevState.ON])
     def UNB2_on(self):
         """
 
-- 
GitLab