diff --git a/tangostationcontrol/devices/base_device_classes/antennafield_device.py b/tangostationcontrol/devices/base_device_classes/antennafield_device.py index 28f95e0e3b45ea8eee0be5642c92ad59ff3734f5..2a44b6e2fc563eb9731b4e76f871d8643e63428e 100644 --- a/tangostationcontrol/devices/base_device_classes/antennafield_device.py +++ b/tangostationcontrol/devices/base_device_classes/antennafield_device.py @@ -968,20 +968,31 @@ class AF(LOFARDevice): [False] * self.nr_antennas, ) - def _power_hardware_off(self): + def power_antennas_off(self, mask: numpy.ndarray): + # Power the specified antennas off, do not touch other antennas. + # + # Mask: a boolean array indicating which antennas should be powered OFF + # Save actual mask values ANT_mask_RW = self.read_attribute("ANT_mask_RW") - # Enable controlling all antennas - self.proxy.write_attribute("ANT_mask_RW", [True] * len(ANT_mask_RW)) + # Enable controlling all requested antennas + self.proxy.write_attribute("ANT_mask_RW", mask) try: - # Turn off power to all antennas - self.proxy.write_attribute("RCU_PWR_ANT_on_RW", [False] * len(ANT_mask_RW)) + # make sure we update RCU_PWR_ANT_on_RW neatly with our mask + RCU_PWR_ANT_on_RW = self.read_attribute("RCU_PWR_ANT_on_RW") and ~mask + + # Turn off power to all antennas (in the requested mask) + self.proxy.write_attribute("RCU_PWR_ANT_on_RW", RCU_PWR_ANT_on_RW) finally: # Restore original mask self.proxy.write_attribute("ANT_mask_RW", ANT_mask_RW) + def _power_hardware_off(self): + # Power all antennas off + self.power_antennas_off([True] * self.nr_antennas()) + # -------- # Commands # -------- @@ -993,6 +1004,10 @@ class AF(LOFARDevice): def configure_recv(self): """Configure RECV to process our antennas.""" + # Power off what should be off, f.e. if they got turned off in the mask + # but are still powered. + self.power_antennas_off(~self.read_attribute("Antenna_Usage_Mask_R")) + # Disable controlling the tiles that fall outside the mask self.proxy.write_attribute( "ANT_mask_RW", self.read_attribute("Antenna_Usage_Mask_R") diff --git a/tangostationcontrol/devices/base_device_classes/mapper.py b/tangostationcontrol/devices/base_device_classes/mapper.py index 6c984cb17573a6660e798d498fbd293f4656a031..e7f6bc16fcc1c249999fb36c9f2db70e755a9708 100644 --- a/tangostationcontrol/devices/base_device_classes/mapper.py +++ b/tangostationcontrol/devices/base_device_classes/mapper.py @@ -717,9 +717,9 @@ class RecvDeviceWalker: if recv <= 0: continue - recv_ant_masks[recv - 1][rcu_input // N_rcu_inp][rcu_input % N_rcu_inp] = ( - True - ) + recv_ant_masks[recv - 1][rcu_input // N_rcu_inp][ + rcu_input % N_rcu_inp + ] = True return recv_ant_masks diff --git a/tangostationcontrol/devices/station_manager.py b/tangostationcontrol/devices/station_manager.py index 7f2e09f3dde426ddae31399e1106f7565c2826c7..c25bea1864a438cd84bad40349cada1fbb4fe1c7 100644 --- a/tangostationcontrol/devices/station_manager.py +++ b/tangostationcontrol/devices/station_manager.py @@ -91,6 +91,10 @@ class StationManager(AsyncDevice): def station_state_R(self): return self.station_state_name + @attribute(dtype=bool, fisallowed="is_attribute_access_allowed", doc="Should antennas be powered on in this station state?") + def antennas_powered_on_R(self): + return self.station_state == StationStateEnum.ON + @attribute(dtype=StationStateEnum, fisallowed="is_attribute_access_allowed") def requested_station_state_R(self): return self.requested_station_state