Loading csp-lmc-mid/csp_lmc_mid/MidCspSubarrayBase.py +17 −8 Original line number Diff line number Diff line Loading @@ -216,8 +216,14 @@ class MidCspSubarrayBase(CspSubarray): # self.state_model.perform_action(action) # self.logger.info("ObsState:{}".format(self.state_model.obs_state)) class RemoveReceptorsCommand(SKASubarray.ReleaseResourcesCommand): class RemoveResourcesCommand(SKASubarray.ReleaseResourcesCommand): def do(self, argin): config = json.loads(argin) receptor_list = list(map(int, config['receptorIDList'])) return self.remove_receptors(receptor_list) def remove_receptors(self, argin): device = self.target # check if the CspSubarray is already connected to the CbfSubarray if not device._is_sc_subarray_running(device.CbfSubarray): Loading Loading @@ -294,8 +300,11 @@ class MidCspSubarrayBase(CspSubarray): message = str(attr_err) return (ResultCode.FAILED, message) class RemoveAllReceptorsCommand(SKASubarray.ReleaseAllResourcesCommand): class ReleaseAllResourcesCommand(SKASubarray.ReleaseAllResourcesCommand): def do(self): return self.remove_all_receptors() def remove_all_receptors(self): self.logger.info("RemoveAllReceptorsCommand") device = self.target try: Loading @@ -303,7 +312,7 @@ class MidCspSubarrayBase(CspSubarray): #receptors = device._get_cbfsubarray_assigned_receptors() receptors = device._receptors.assigned_to_subarray(device.SubID) self.logger.info("assigned receptors:{}".format(receptors)) return device._removereceptors_cmd_obj.do(receptors[:]) return device._removeresources_cmd_obj.do({"receptorIDList":receptors[:]}) return (ResultCode.OK, "No receptor to remove") except tango.DevFailed as df: log_msg = ("RemoveAllReceptors failure. Reason: {} " Loading Loading @@ -592,7 +601,7 @@ class MidCspSubarrayBase(CspSubarray): self._sc_subarray_cmd_exec_state[device][cmd_name] = CmdExecState.IDLE self._cmd_execution_state[cmd_name] = CmdExecState.IDLE self.logger.info("Receptors removed with success") return self._removereceptors_cmd_obj.succeeded() return self._removeresources_cmd_obj.succeeded() #@command( # dtype_in='DevString', Loading @@ -610,10 +619,10 @@ class MidCspSubarrayBase(CspSubarray): args = (self, self.state_model, self.logger) self._assignresources_cmd_obj = self.AssignResourcesCommand(*args) self._removereceptors_cmd_obj = self.RemoveReceptorsCommand(*args) self.register_command_object("AssignResources", self.AssignResourcesCommand(*args)) self.register_command_object("RemoveReceptors", self.RemoveReceptorsCommand(*args)) self.register_command_object("RemoveAllReceptors", self.RemoveAllReceptorsCommand(*args)) self._removeresources_cmd_obj = self.RemoveReceptorsCommand(*args) #self.register_command_object("AssignResources", self.AssignResourcesCommand(*args)) #self.register_command_object("RemoveReceptors", self.RemoveReceptorsCommand(*args)) #self.register_command_object("RemoveAllReceptors", self.RemoveAllReceptorsCommand(*args)) # PROTECTED REGION END # // MidCspSubarrayBase.private_methods Loading csp-lmc-mid/tests/integration/MidCspSubarray_test.py +3 −3 Original line number Diff line number Diff line Loading @@ -141,7 +141,7 @@ class TestCspSubarray(TestBase): LOGGER.info("Receptor assigned to the subarray {}".format(receptors)) try: LOGGER.info("invoke remove all receptors") self.midcsp_subarray01.RemoveAllReceptors() self.midcsp_subarray01.RemoveAllResources() except Exception as e: LOGGER.info(str(e)) # wait for the transition to EMPTY Loading Loading @@ -331,7 +331,7 @@ class TestCspSubarray(TestBase): receptor_to_remove.append(i) # Exercise the system: remove only one receptor (with a random ID) LOGGER.info(f"Remove one receptor from CSP subarray01") self.midcsp_subarray01.RemoveReceptors(receptor_to_remove) self.midcsp_subarray01.RemoveResources({"receptorIDList":receptor_to_remove}) # check prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.IDLE, f"Wrong CSP Subarray obsState") Loading @@ -357,7 +357,7 @@ class TestCspSubarray(TestBase): assigned_receptors = self.midcsp_subarray01.assignedReceptors assert assigned_receptors.any() LOGGER.info(f"Remove all receptors from CSP subarray01") self.midcsp_subarray01.RemoveAllReceptors() self.midcsp_subarray01.RemoveAllResources() prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.EMPTY, f"Wrong CSP Subarray obsState") Poller(10, 0.2).check(prober_obs_state) Loading csp-lmc-mid/tests/unit/midcspsubarray_unit_test.py +3 −3 Original line number Diff line number Diff line Loading @@ -242,10 +242,10 @@ def test_removereceptors_command_WHEN_subarray_is_in_wrong_state(): obs_state = tango_context.device.obsState assert obs_state == ObsState.READY with pytest.raises(tango.DevFailed) as df: tango_context.device.RemoveAllReceptors() tango_context.device.RemoveAllResources() if df: err_msg = str(df.value.args[0].desc) assert "Error executing command RemoveAllReceptorsCommand" in err_msg assert "Error executing command RemoveAllResourcesCommand" in err_msg def test_midcspsubarray_obsstate_WHEN_cbfsubarray_raises_an_exception(): """ Loading Loading
csp-lmc-mid/csp_lmc_mid/MidCspSubarrayBase.py +17 −8 Original line number Diff line number Diff line Loading @@ -216,8 +216,14 @@ class MidCspSubarrayBase(CspSubarray): # self.state_model.perform_action(action) # self.logger.info("ObsState:{}".format(self.state_model.obs_state)) class RemoveReceptorsCommand(SKASubarray.ReleaseResourcesCommand): class RemoveResourcesCommand(SKASubarray.ReleaseResourcesCommand): def do(self, argin): config = json.loads(argin) receptor_list = list(map(int, config['receptorIDList'])) return self.remove_receptors(receptor_list) def remove_receptors(self, argin): device = self.target # check if the CspSubarray is already connected to the CbfSubarray if not device._is_sc_subarray_running(device.CbfSubarray): Loading Loading @@ -294,8 +300,11 @@ class MidCspSubarrayBase(CspSubarray): message = str(attr_err) return (ResultCode.FAILED, message) class RemoveAllReceptorsCommand(SKASubarray.ReleaseAllResourcesCommand): class ReleaseAllResourcesCommand(SKASubarray.ReleaseAllResourcesCommand): def do(self): return self.remove_all_receptors() def remove_all_receptors(self): self.logger.info("RemoveAllReceptorsCommand") device = self.target try: Loading @@ -303,7 +312,7 @@ class MidCspSubarrayBase(CspSubarray): #receptors = device._get_cbfsubarray_assigned_receptors() receptors = device._receptors.assigned_to_subarray(device.SubID) self.logger.info("assigned receptors:{}".format(receptors)) return device._removereceptors_cmd_obj.do(receptors[:]) return device._removeresources_cmd_obj.do({"receptorIDList":receptors[:]}) return (ResultCode.OK, "No receptor to remove") except tango.DevFailed as df: log_msg = ("RemoveAllReceptors failure. Reason: {} " Loading Loading @@ -592,7 +601,7 @@ class MidCspSubarrayBase(CspSubarray): self._sc_subarray_cmd_exec_state[device][cmd_name] = CmdExecState.IDLE self._cmd_execution_state[cmd_name] = CmdExecState.IDLE self.logger.info("Receptors removed with success") return self._removereceptors_cmd_obj.succeeded() return self._removeresources_cmd_obj.succeeded() #@command( # dtype_in='DevString', Loading @@ -610,10 +619,10 @@ class MidCspSubarrayBase(CspSubarray): args = (self, self.state_model, self.logger) self._assignresources_cmd_obj = self.AssignResourcesCommand(*args) self._removereceptors_cmd_obj = self.RemoveReceptorsCommand(*args) self.register_command_object("AssignResources", self.AssignResourcesCommand(*args)) self.register_command_object("RemoveReceptors", self.RemoveReceptorsCommand(*args)) self.register_command_object("RemoveAllReceptors", self.RemoveAllReceptorsCommand(*args)) self._removeresources_cmd_obj = self.RemoveReceptorsCommand(*args) #self.register_command_object("AssignResources", self.AssignResourcesCommand(*args)) #self.register_command_object("RemoveReceptors", self.RemoveReceptorsCommand(*args)) #self.register_command_object("RemoveAllReceptors", self.RemoveAllReceptorsCommand(*args)) # PROTECTED REGION END # // MidCspSubarrayBase.private_methods Loading
csp-lmc-mid/tests/integration/MidCspSubarray_test.py +3 −3 Original line number Diff line number Diff line Loading @@ -141,7 +141,7 @@ class TestCspSubarray(TestBase): LOGGER.info("Receptor assigned to the subarray {}".format(receptors)) try: LOGGER.info("invoke remove all receptors") self.midcsp_subarray01.RemoveAllReceptors() self.midcsp_subarray01.RemoveAllResources() except Exception as e: LOGGER.info(str(e)) # wait for the transition to EMPTY Loading Loading @@ -331,7 +331,7 @@ class TestCspSubarray(TestBase): receptor_to_remove.append(i) # Exercise the system: remove only one receptor (with a random ID) LOGGER.info(f"Remove one receptor from CSP subarray01") self.midcsp_subarray01.RemoveReceptors(receptor_to_remove) self.midcsp_subarray01.RemoveResources({"receptorIDList":receptor_to_remove}) # check prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.IDLE, f"Wrong CSP Subarray obsState") Loading @@ -357,7 +357,7 @@ class TestCspSubarray(TestBase): assigned_receptors = self.midcsp_subarray01.assignedReceptors assert assigned_receptors.any() LOGGER.info(f"Remove all receptors from CSP subarray01") self.midcsp_subarray01.RemoveAllReceptors() self.midcsp_subarray01.RemoveAllResources() prober_obs_state = Probe(self.midcsp_subarray01, 'obsState', ObsState.EMPTY, f"Wrong CSP Subarray obsState") Poller(10, 0.2).check(prober_obs_state) Loading
csp-lmc-mid/tests/unit/midcspsubarray_unit_test.py +3 −3 Original line number Diff line number Diff line Loading @@ -242,10 +242,10 @@ def test_removereceptors_command_WHEN_subarray_is_in_wrong_state(): obs_state = tango_context.device.obsState assert obs_state == ObsState.READY with pytest.raises(tango.DevFailed) as df: tango_context.device.RemoveAllReceptors() tango_context.device.RemoveAllResources() if df: err_msg = str(df.value.args[0].desc) assert "Error executing command RemoveAllReceptorsCommand" in err_msg assert "Error executing command RemoveAllResourcesCommand" in err_msg def test_midcspsubarray_obsstate_WHEN_cbfsubarray_raises_an_exception(): """ Loading