Loading csp-lmc-common/csp_lmc_common/CspSubarray.py +10 −8 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ class CspSubarray(SKASubarray): self.logger.info("Call Off Command") device = self.target subelement_thr = {} self.thread_succeeded = [] self.thread_succeeded = {} try: # First loop that start the sub-element threads to get the ObsState.EMPTY for fqdn in device._sc_subarray_fqdn: Loading @@ -360,7 +360,7 @@ class CspSubarray(SKASubarray): # requested state if device._sc_subarray_state[fqdn] == tango.DevState.OFF: continue if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: if device._sc_subarray_obs_state[fqdn] != ObsState.EMPTY: subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, name="Thread-OffSequence", args=(fqdn,)) Loading Loading @@ -398,33 +398,35 @@ class CspSubarray(SKASubarray): def off_sequence(self, fqdn): #Off command send the device in the state:OFF, ObsState:EMPTY self.logger.info('off sequence started!') self.logger.info(f'FQDN: {fqdn}') device = self.target starting_time = time.time() timeout = device._sc_subarray_cmd_duration_expected[fqdn]['off'] while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: while (time.time() - starting_time) < timeout and (device._sc_subarray_obs_state[fqdn] != ObsState.EMPTY): # Try to send Abort Command. # Device goes to ABORTED in case ObsState is: IDLE, READY, CONFIGURING, SCANNING, RESETTING try: self.logger.info('Try to execute Abort command') self.logger.info(f'ObState: {device._sc_subarray_obs_state[fqdn]}') device._sc_subarray_proxies[fqdn].Abort() while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.ABORTED: while (time.time() - starting_time) < timeout and (device._sc_subarray_obs_state[fqdn] != ObsState.ABORTED): if device._sc_subarray_obs_state[fqdn] == ObsState.FAULT: break time.sleep(0.1) except CommandError as msg: except Exception as msg: self.logger.info(msg) # Try to send Restart Command. # Device goes to EMPTY if ObsState is: FAULT, ABORTED # ObsState could be aborted from above try section try: self.logger.info('Try to execute Restart command') device._sc_subarray_obs_state[fqdn].Restart() except CommandError as msg: device._sc_subarray_proxies[fqdn].Restart() except Exception as msg: self.logger.info(msg) time.sleep(0.1) # if ObsState is: RESOURCING, ABORTING start again to wait end of the transition if device._sc_subarray_obs_state[fqdn] is ObsState.EMPTY: if device._sc_subarray_obs_state[fqdn] == ObsState.EMPTY: self.thread_succeeded[fqdn] = True else: self.thread_succeeded[fqdn] = False Loading csp-lmc-mid/csp_lmc_mid/MidCspSubarrayBase.py +3 −3 Original line number Diff line number Diff line Loading @@ -116,14 +116,14 @@ class MidCspSubarrayBase(CspSubarray): try: resources_dict = json.loads(argin) subarray_id = resources_dict['subarrayID'] if subarray_id != self.target.SubID: if subarray_id != int(self.target.SubID): msg = f"Mismatch in subarrayID. Received: {subarray_id} {self.target.SubID}" self.logger.error(msg) #return (ResultCode.FAILED, msg) return (ResultCode.FAILED, msg) receptor_list = list(map(int, resources_dict['dish']['receptorIDList'])) except (KeyError, json.JSONDecodeError) as error: msg = f"Something wrong in Json input string: {error}" raise ValueError(msg) return (ResultCode.FAILED, msg) return self._add_receptors(receptor_list) def _add_receptors(self, argin): Loading csp-lmc-mid/tests/integration/MidCspSubarray_test.py +19 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,12 @@ class TestCspSubarray(TestBase): f"Wrong CSP Subarray obsState {self.midcsp_subarray01.obsState}") Poller(5, 0.2).check(prober_subarray_obstate) def _build_resources(self, argin): param = { 'subarrayID': 1, 'dish': { 'receptorIDList': list(map(str, argin))}} return json.dumps(param) @pytest.mark.csp_k8s def test_AFTER_initialization(self): """ Loading Loading @@ -202,13 +208,26 @@ class TestCspSubarray(TestBase): @pytest.mark.csp_k8s def test_OffCommand_after_RESOURCING(self): self._setup_subarray json_config= self._build_resources([1,2]) self.midcsp_subarray01.AssignResources(json_config) self.midcsp_subarray01.Off() prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") Poller(4, 0.2).check(prober_subarray_state) prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") Poller(4, 0.2).check(prober_subarray_obsstate) @pytest.mark.csp_k8s def test_OffCommand_after_IDLE(self): self._setup_subarray() self._assign_receptors() self.midcsp_subarray01.Off() prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") Poller(4, 0.2).check(prober_subarray_state) prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") Poller(4, 0.2).check(prober_subarray_obsstate) @pytest.mark.cps_k8s def test_OffCommand_after_CONFIGURE(self): self._setup_subarray() self._configure_scan() Loading Loading
csp-lmc-common/csp_lmc_common/CspSubarray.py +10 −8 Original line number Diff line number Diff line Loading @@ -352,7 +352,7 @@ class CspSubarray(SKASubarray): self.logger.info("Call Off Command") device = self.target subelement_thr = {} self.thread_succeeded = [] self.thread_succeeded = {} try: # First loop that start the sub-element threads to get the ObsState.EMPTY for fqdn in device._sc_subarray_fqdn: Loading @@ -360,7 +360,7 @@ class CspSubarray(SKASubarray): # requested state if device._sc_subarray_state[fqdn] == tango.DevState.OFF: continue if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: if device._sc_subarray_obs_state[fqdn] != ObsState.EMPTY: subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, name="Thread-OffSequence", args=(fqdn,)) Loading Loading @@ -398,33 +398,35 @@ class CspSubarray(SKASubarray): def off_sequence(self, fqdn): #Off command send the device in the state:OFF, ObsState:EMPTY self.logger.info('off sequence started!') self.logger.info(f'FQDN: {fqdn}') device = self.target starting_time = time.time() timeout = device._sc_subarray_cmd_duration_expected[fqdn]['off'] while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: while (time.time() - starting_time) < timeout and (device._sc_subarray_obs_state[fqdn] != ObsState.EMPTY): # Try to send Abort Command. # Device goes to ABORTED in case ObsState is: IDLE, READY, CONFIGURING, SCANNING, RESETTING try: self.logger.info('Try to execute Abort command') self.logger.info(f'ObState: {device._sc_subarray_obs_state[fqdn]}') device._sc_subarray_proxies[fqdn].Abort() while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.ABORTED: while (time.time() - starting_time) < timeout and (device._sc_subarray_obs_state[fqdn] != ObsState.ABORTED): if device._sc_subarray_obs_state[fqdn] == ObsState.FAULT: break time.sleep(0.1) except CommandError as msg: except Exception as msg: self.logger.info(msg) # Try to send Restart Command. # Device goes to EMPTY if ObsState is: FAULT, ABORTED # ObsState could be aborted from above try section try: self.logger.info('Try to execute Restart command') device._sc_subarray_obs_state[fqdn].Restart() except CommandError as msg: device._sc_subarray_proxies[fqdn].Restart() except Exception as msg: self.logger.info(msg) time.sleep(0.1) # if ObsState is: RESOURCING, ABORTING start again to wait end of the transition if device._sc_subarray_obs_state[fqdn] is ObsState.EMPTY: if device._sc_subarray_obs_state[fqdn] == ObsState.EMPTY: self.thread_succeeded[fqdn] = True else: self.thread_succeeded[fqdn] = False Loading
csp-lmc-mid/csp_lmc_mid/MidCspSubarrayBase.py +3 −3 Original line number Diff line number Diff line Loading @@ -116,14 +116,14 @@ class MidCspSubarrayBase(CspSubarray): try: resources_dict = json.loads(argin) subarray_id = resources_dict['subarrayID'] if subarray_id != self.target.SubID: if subarray_id != int(self.target.SubID): msg = f"Mismatch in subarrayID. Received: {subarray_id} {self.target.SubID}" self.logger.error(msg) #return (ResultCode.FAILED, msg) return (ResultCode.FAILED, msg) receptor_list = list(map(int, resources_dict['dish']['receptorIDList'])) except (KeyError, json.JSONDecodeError) as error: msg = f"Something wrong in Json input string: {error}" raise ValueError(msg) return (ResultCode.FAILED, msg) return self._add_receptors(receptor_list) def _add_receptors(self, argin): Loading
csp-lmc-mid/tests/integration/MidCspSubarray_test.py +19 −0 Original line number Diff line number Diff line Loading @@ -170,6 +170,12 @@ class TestCspSubarray(TestBase): f"Wrong CSP Subarray obsState {self.midcsp_subarray01.obsState}") Poller(5, 0.2).check(prober_subarray_obstate) def _build_resources(self, argin): param = { 'subarrayID': 1, 'dish': { 'receptorIDList': list(map(str, argin))}} return json.dumps(param) @pytest.mark.csp_k8s def test_AFTER_initialization(self): """ Loading Loading @@ -202,13 +208,26 @@ class TestCspSubarray(TestBase): @pytest.mark.csp_k8s def test_OffCommand_after_RESOURCING(self): self._setup_subarray json_config= self._build_resources([1,2]) self.midcsp_subarray01.AssignResources(json_config) self.midcsp_subarray01.Off() prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") Poller(4, 0.2).check(prober_subarray_state) prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") Poller(4, 0.2).check(prober_subarray_obsstate) @pytest.mark.csp_k8s def test_OffCommand_after_IDLE(self): self._setup_subarray() self._assign_receptors() self.midcsp_subarray01.Off() prober_subarray_state = Probe(self.midcsp_subarray01, "State", DevState.OFF, f"CSP Subarray not OFF") Poller(4, 0.2).check(prober_subarray_state) prober_subarray_obsstate = Probe(self.midcsp_subarray01, "obsState", ObsState.EMPTY, f"CSP Subarray not EMPTY") Poller(4, 0.2).check(prober_subarray_obsstate) @pytest.mark.cps_k8s def test_OffCommand_after_CONFIGURE(self): self._setup_subarray() self._configure_scan() Loading