Loading csp-lmc-common/csp_lmc_common/CspSubarray.py +46 −32 Original line number Diff line number Diff line Loading @@ -349,24 +349,41 @@ class CspSubarray(SKASubarray): class OffCommand(SKASubarray.OffCommand): def do(self): self.results = None self.logger.info("Call Off Command") device = self.target subelement_thr = {} for fqdn in device._sc_subarray_fqdn: try: # check if the sub-element subarray is already in the # requested state if device._sc_subarray_state[fqdn] == tango.DevState.OFF: continue if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: device._command_thread['offsequenze'] = threading.Thread(target=self.off_sequence, subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, name="Thread-OffSequence", args=(fqdn,self.results)) args=(fqdn,)) subelement_thr[fqdn].start() for fqdn in subelement_thr.keys(): subelement_thr[fqdn].join() if fqdn != device.CbfSubarray: device._health_state = HealthState.DEGRADED continue else: return (ResultCode.FAILED, message) try: except tango.DevFailed as tango_err: message = str(tango_err.args[0].desc) return (ResultCode.FAILED, message) (result_code, message) = self.results if result_code == ResultCode.FAILED: self.logger.error("Off command failed on device {}".format(fqdn)) Loading @@ -380,38 +397,35 @@ class CspSubarray(SKASubarray): self.logger.info(message) return (ResultCode.OK, message) except tango.DevFailed as tango_err: message = str(tango_err.args[0].desc) return (ResultCode.FAILED, message) def off_sequence(self, fqdn): #Off command send the device in the state:OFF, ObsState:EMPTY 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: # 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') device._sc_subarray_proxies[fqdn].Abort() while device._sc_subarray_obs_state is not ObsState.ABORTED: if device._sc_subarray_obs_state==ObsState.FAULT: while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.ABORTED: if device._sc_subarray_obs_state[fqdn]==ObsState.FAULT: break pass except ska.base.commands.CommandError: pass time.sleep(0.1) except ska.base.commands.CommandError 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 ska.base.commands.CommandError: pass except ska.base.commands.CommandError as msg: self.logger.info(msg) time.sleep(0.1) #IF SUCCESS if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: self.results = device._sc_subarray_proxies[fqdn].Off() # comando succeded. #IF TIMEOUT if (time.time() - starting_time) > timeout: # if ObsState is: RESOURCING, ABORTING start again to wait end of the transition Loading Loading
csp-lmc-common/csp_lmc_common/CspSubarray.py +46 −32 Original line number Diff line number Diff line Loading @@ -349,24 +349,41 @@ class CspSubarray(SKASubarray): class OffCommand(SKASubarray.OffCommand): def do(self): self.results = None self.logger.info("Call Off Command") device = self.target subelement_thr = {} for fqdn in device._sc_subarray_fqdn: try: # check if the sub-element subarray is already in the # requested state if device._sc_subarray_state[fqdn] == tango.DevState.OFF: continue if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: device._command_thread['offsequenze'] = threading.Thread(target=self.off_sequence, subelement_thr[fqdn] = threading.Thread(target=self.off_sequence, name="Thread-OffSequence", args=(fqdn,self.results)) args=(fqdn,)) subelement_thr[fqdn].start() for fqdn in subelement_thr.keys(): subelement_thr[fqdn].join() if fqdn != device.CbfSubarray: device._health_state = HealthState.DEGRADED continue else: return (ResultCode.FAILED, message) try: except tango.DevFailed as tango_err: message = str(tango_err.args[0].desc) return (ResultCode.FAILED, message) (result_code, message) = self.results if result_code == ResultCode.FAILED: self.logger.error("Off command failed on device {}".format(fqdn)) Loading @@ -380,38 +397,35 @@ class CspSubarray(SKASubarray): self.logger.info(message) return (ResultCode.OK, message) except tango.DevFailed as tango_err: message = str(tango_err.args[0].desc) return (ResultCode.FAILED, message) def off_sequence(self, fqdn): #Off command send the device in the state:OFF, ObsState:EMPTY 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: # 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') device._sc_subarray_proxies[fqdn].Abort() while device._sc_subarray_obs_state is not ObsState.ABORTED: if device._sc_subarray_obs_state==ObsState.FAULT: while (time.time() - starting_time) < timeout and device._sc_subarray_obs_state[fqdn] is not ObsState.ABORTED: if device._sc_subarray_obs_state[fqdn]==ObsState.FAULT: break pass except ska.base.commands.CommandError: pass time.sleep(0.1) except ska.base.commands.CommandError 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 ska.base.commands.CommandError: pass except ska.base.commands.CommandError as msg: self.logger.info(msg) time.sleep(0.1) #IF SUCCESS if device._sc_subarray_obs_state[fqdn] is not ObsState.EMPTY: self.results = device._sc_subarray_proxies[fqdn].Off() # comando succeded. #IF TIMEOUT if (time.time() - starting_time) > timeout: # if ObsState is: RESOURCING, ABORTING start again to wait end of the transition Loading