From 7a039651c13857742a1d08e57d1c3a2c4e25028b Mon Sep 17 00:00:00 2001
From: stedif <stefano.difrischia@inaf.it>
Date: Wed, 3 Aug 2022 12:55:52 +0200
Subject: [PATCH] L2SS-827: move RCUs initialise from recv to antennafield

---
 .../devices/antennafield.py                   | 21 +++++++++++++++++++
 .../tangostationcontrol/devices/recv.py       |  9 --------
 2 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/tangostationcontrol/tangostationcontrol/devices/antennafield.py b/tangostationcontrol/tangostationcontrol/devices/antennafield.py
index 6a2f02253..80709b1d8 100644
--- a/tangostationcontrol/tangostationcontrol/devices/antennafield.py
+++ b/tangostationcontrol/tangostationcontrol/devices/antennafield.py
@@ -369,6 +369,27 @@ class AntennaField(lofar_device):
         self.__setup_all_receiver_proxies()
         self.__setup_mapper()
     
+    @log_exceptions()
+    def _prepare_hardware(self):
+        # Initialise the RCU hardware.
+        for recv_proxy in self.recv_proxies:
+            RCU_mask = recv_proxy.RCU_mask_RW
+            # Set the mask to all Trues
+            recv_proxy.RCU_mask_RW = [True] * 32
+            # Turn off the RCUs
+            recv_proxy.RCU_off()
+
+            # TODO(Stefano): restore wait attribute
+            #recv_proxy.wait_attribute("RECVTR_translator_busy_R", False, recv_proxy.RCU_On_Off_timeout)
+            
+            # Restore the mask
+            recv_proxy.RCU_mask_RW = RCU_mask
+            # Turn on the RCUs
+            recv_proxy.RCU_on()
+
+            # TODO(Stefano): restore wait attribute
+            #recv_proxy.wait_attribute("RECVTR_translator_busy_R", False, recv_proxy.RCU_On_Off_timeout)
+    
     @log_exceptions()
     def _initialise_hardware(self):
         # Disable controlling the tiles that fall outside the mask
diff --git a/tangostationcontrol/tangostationcontrol/devices/recv.py b/tangostationcontrol/tangostationcontrol/devices/recv.py
index ff2e4166f..3817a5793 100644
--- a/tangostationcontrol/tangostationcontrol/devices/recv.py
+++ b/tangostationcontrol/tangostationcontrol/devices/recv.py
@@ -319,15 +319,6 @@ class RECV(opcua_device):
         """
         self.opcua_connection.call_method(["RCU_DTH_on"])
 
-    def _initialise_hardware(self):
-        """ Initialise the RCU hardware. """
-
-        # Cycle RCUs
-        self.RCU_off()
-        self.wait_attribute("RECVTR_translator_busy_R", False, self.RCU_On_Off_timeout)
-        self.RCU_on()
-        self.wait_attribute("RECVTR_translator_busy_R", False, self.RCU_On_Off_timeout)
-
 # ----------
 # Run server
 # ----------
-- 
GitLab