Loading csp-lmc-common/csp_lmc_common/CspMaster.py +35 −22 Original line number Diff line number Diff line Loading @@ -592,42 +592,48 @@ class CspMaster(SKAMaster): # reset the CSP command execution flag with self._cmd_exec_state_lock: self._cmd_execution_state[cmd_name] = CmdExecState.IDLE self._update_csp_state() self.logger.info("CSP State:{}".format(self.get_state())) self._enable_subarrays(tango_cmd_name) def _enable_subarrays(self, tango_cmd_name): enable = False subarray_cmd = tango_cmd_name if tango_cmd_name == 'On': enable = True if tango_cmd_name == 'Standby': subarray_cmd = 'Off' """ Helper method to execute the On[Off] command on the CSP subarrays. :param tangp_cmd_name: The command to execute :type tamgo_cmd_name: string :return: None """ subarray_action = tango_cmd_name.lower() if subarray_action not in ['on', 'off']: self.logger.warning(f"Invalid command {subarray_action} to issue on CSP subarray") return master_state = self.get_state() if (enable, master_state) not in [(True, tango.DevState.ON), (False, tango.DevState.STANDBY)]: if (subarray_action, master_state) not in [('on', tango.DevState.ON), ('off', tango.DevState.STANDBY)]: self.logger.warning("CSPMaster is not in the proper state ({})".format(self.get_state())) return try: subarray_group = tango.Group("CSPSubarray") for subarray in self.CspSubarrays: subarray_group.add(subarray) self.logger.info("Issue command {} on subarray group".format(subarray_cmd)) answers = subarray_group.command_inout(subarray_cmd) self.logger.info("Going to switch-{} the subarrays".format(subarray_action)) answers = subarray_group.command_inout(subarray_action) for reply in answers: if reply.has_failed(): self.logger.info("stack: {}".format(len(reply.get_err_stack()))) for err in reply.get_err_stack(): self.logger.info("err {} reason {}".format(err.desc, err.reason) ) self.logger.warning("Subarray {} failed executing command {}".format(reply.dev_name(), subarray_cmd)) subarray_action)) else: (result_code, msg) = reply.get_data() if result_code == ResultCode.FAILED: self.logger.error(msg[0]) self.logger.error(f"Subarray {reply.dev_name()}: {msg[0]}") elif result_code == ResultCode.OK: self.logger.info(msg[0]) self.logger.info(f"Subarray {reply.dev_name()}: {msg[0]}") except tango.DevFailed as df: log_msg = (f"Failure in command {subarray_action} " "for device {str(fqdn)}: {str(df.args[0].reason)}") self.logger.error(log_msg) except Exception: self.logger.error("TANGO Group command failed") self.logger.error("command {} failed on subarray".format(subarray_action)) def _se_write_adminMode(self, value, device_fqdn): """ Loading Loading @@ -1885,8 +1891,11 @@ class CspMaster(SKAMaster): self._cmd_execution_state['on'] = CmdExecState.RUNNING self._command_thread['on'].start() self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items())) # sleep for a while to let the thread start #time.sleep(0.1) # To temporarily solve SKB-26 -> join the thread to synchronize the command self._command_thread['on'].join() self._update_csp_state() self.logger.info("CSP State:{}".format(self.get_state())) self._enable_subarrays('On') except Exception: # reset the sub-element command exec state self._se_cmd_execution_state.clear() Loading Loading @@ -1970,8 +1979,9 @@ class CspMaster(SKAMaster): self._cmd_execution_state['off'] = CmdExecState.RUNNING # start the thread self._command_thread['off'].start() # sleep for a while to let the thread start #time.sleep(0.1) self._command_thread['off'].join() self._update_csp_state() self.logger.info("CSP State:{}".format(self.get_state())) except Exception: # reset the sub-element command exec state self._se_cmd_execution_state.clear() Loading Loading @@ -2054,8 +2064,11 @@ class CspMaster(SKAMaster): # start the thread self._command_thread['standby'].start() self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items())) # sleep for a while to let the thread start #time.sleep(0.1) # To temprarily solve the SKB-26 -> join the thread to synchronize the command self._command_thread['standby'].join() self._update_csp_state() self.logger.info("CSP State:{}".format(self.get_state())) self._enable_subarrays('Off') except Exception: # reset the sub-element command exec state self._se_cmd_execution_state.clear() Loading Loading
csp-lmc-common/csp_lmc_common/CspMaster.py +35 −22 Original line number Diff line number Diff line Loading @@ -592,42 +592,48 @@ class CspMaster(SKAMaster): # reset the CSP command execution flag with self._cmd_exec_state_lock: self._cmd_execution_state[cmd_name] = CmdExecState.IDLE self._update_csp_state() self.logger.info("CSP State:{}".format(self.get_state())) self._enable_subarrays(tango_cmd_name) def _enable_subarrays(self, tango_cmd_name): enable = False subarray_cmd = tango_cmd_name if tango_cmd_name == 'On': enable = True if tango_cmd_name == 'Standby': subarray_cmd = 'Off' """ Helper method to execute the On[Off] command on the CSP subarrays. :param tangp_cmd_name: The command to execute :type tamgo_cmd_name: string :return: None """ subarray_action = tango_cmd_name.lower() if subarray_action not in ['on', 'off']: self.logger.warning(f"Invalid command {subarray_action} to issue on CSP subarray") return master_state = self.get_state() if (enable, master_state) not in [(True, tango.DevState.ON), (False, tango.DevState.STANDBY)]: if (subarray_action, master_state) not in [('on', tango.DevState.ON), ('off', tango.DevState.STANDBY)]: self.logger.warning("CSPMaster is not in the proper state ({})".format(self.get_state())) return try: subarray_group = tango.Group("CSPSubarray") for subarray in self.CspSubarrays: subarray_group.add(subarray) self.logger.info("Issue command {} on subarray group".format(subarray_cmd)) answers = subarray_group.command_inout(subarray_cmd) self.logger.info("Going to switch-{} the subarrays".format(subarray_action)) answers = subarray_group.command_inout(subarray_action) for reply in answers: if reply.has_failed(): self.logger.info("stack: {}".format(len(reply.get_err_stack()))) for err in reply.get_err_stack(): self.logger.info("err {} reason {}".format(err.desc, err.reason) ) self.logger.warning("Subarray {} failed executing command {}".format(reply.dev_name(), subarray_cmd)) subarray_action)) else: (result_code, msg) = reply.get_data() if result_code == ResultCode.FAILED: self.logger.error(msg[0]) self.logger.error(f"Subarray {reply.dev_name()}: {msg[0]}") elif result_code == ResultCode.OK: self.logger.info(msg[0]) self.logger.info(f"Subarray {reply.dev_name()}: {msg[0]}") except tango.DevFailed as df: log_msg = (f"Failure in command {subarray_action} " "for device {str(fqdn)}: {str(df.args[0].reason)}") self.logger.error(log_msg) except Exception: self.logger.error("TANGO Group command failed") self.logger.error("command {} failed on subarray".format(subarray_action)) def _se_write_adminMode(self, value, device_fqdn): """ Loading Loading @@ -1885,8 +1891,11 @@ class CspMaster(SKAMaster): self._cmd_execution_state['on'] = CmdExecState.RUNNING self._command_thread['on'].start() self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items())) # sleep for a while to let the thread start #time.sleep(0.1) # To temporarily solve SKB-26 -> join the thread to synchronize the command self._command_thread['on'].join() self._update_csp_state() self.logger.info("CSP State:{}".format(self.get_state())) self._enable_subarrays('On') except Exception: # reset the sub-element command exec state self._se_cmd_execution_state.clear() Loading Loading @@ -1970,8 +1979,9 @@ class CspMaster(SKAMaster): self._cmd_execution_state['off'] = CmdExecState.RUNNING # start the thread self._command_thread['off'].start() # sleep for a while to let the thread start #time.sleep(0.1) self._command_thread['off'].join() self._update_csp_state() self.logger.info("CSP State:{}".format(self.get_state())) except Exception: # reset the sub-element command exec state self._se_cmd_execution_state.clear() Loading Loading @@ -2054,8 +2064,11 @@ class CspMaster(SKAMaster): # start the thread self._command_thread['standby'].start() self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items())) # sleep for a while to let the thread start #time.sleep(0.1) # To temprarily solve the SKB-26 -> join the thread to synchronize the command self._command_thread['standby'].join() self._update_csp_state() self.logger.info("CSP State:{}".format(self.get_state())) self._enable_subarrays('Off') except Exception: # reset the sub-element command exec state self._se_cmd_execution_state.clear() Loading