Loading csp-lmc-common/csp_lmc_common/CspMaster.py +36 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ from tango import AttrWriteType, DeviceProxy # from ska.base import SKAMaster from ska.base import utils from ska.base.commands import ResultCode from ska.base.control_model import HealthState, AdminMode, ObsState, LoggingLevel from .utils.decorators import AdminModeCheck, CmdInputArgsCheck from .utils.cspcommons import CmdExecState Loading Loading @@ -593,6 +594,41 @@ class CspMaster(SKAMaster): 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' master_state = self.get_state() if (enable, master_state) not in [(True, tango.DevState.ON), (False, 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) 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)) else: (result_code, msg) = reply.get_data() if result_code == ResultCode.FAILED: self.logger.error(msg[0]) elif result_code == ResultCode.OK: self.logger.info(msg[0]) except (TypeError, ArgumentError) as ex: self.logger.error("TANGO Group command failed") def _se_write_adminMode(self, value, device_fqdn): """ *Class method.* Loading csp-lmc-common/csp_lmc_common/CspSubarray.py +18 −12 Original line number Diff line number Diff line Loading @@ -343,11 +343,14 @@ class CspSubarray(SKASubarray): class OffCommand(SKASubarray.OffCommand): def do(self): super().do() device = self.target self.logger.info("Call Off Command") device = self.target 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 (result_code, message) = device._sc_subarray_proxies[fqdn].Off() if result_code == ResultCode.FAILED: self.logger.error("Off command failed on device {}".format(fqdn)) Loading Loading @@ -1174,8 +1177,11 @@ class CspSubarray(SKASubarray): str(evt.attr_value.value)) self.logger.info(log_msg) # update CSP sub-array SCM if evt.attr_value.name.lower() in ["state", "healthstate", "adminmode", "obsstate"]: self.update_subarray_state() #07-2020: with the new base classes, transitions are handled via actions. #if evt.attr_value.name.lower() in ["state", "healthstate", "adminmode", "obsstate"]: # self.update_subarray_state() if evt.attr_value.name.lower() == "healthstate": self._update_subarray_health_state() except tango.DevFailed as df: self.logger.error(str(df.args[0].desc)) except Exception as except_occurred: Loading @@ -1196,8 +1202,11 @@ class CspSubarray(SKASubarray): # TODO how report obsState? # adminMode can't be change otherwise the State and healthState # are note updated # 07-2020 # Note: with new base classes transition are handled via actions. But here we # have to be careful....need to review this part # update the State and healthState of the CSP sub-array self.update_subarray_state() #self.update_subarray_state() log_msg = item.reason + ": on attribute " + str(evt.attr_name) self.logger.warning(log_msg) Loading Loading @@ -1316,7 +1325,6 @@ class CspSubarray(SKASubarray): :return: None """ self.logger.info("CspSubarray") self._update_subarray_health_state() if self._command_thread: Loading @@ -1328,18 +1336,16 @@ class CspSubarray(SKASubarray): # CSP state reflects the status of CBF. Only if CBF is present # CSP can work. The state of PSS and PST sub-elements only contributes # to determine the CSP health state. self.set_state(self._sc_subarray_state[self.CbfSubarray]) if self.get_state() == DevState.OFF: if self._sc_subarray_state[self.CbfSubarray] == DevState.OFF: if self._sc_subarray_obs_state[self.CbfSubarray] == ObsState.EMPTY: self.logger.info("1") self.off_cmd_obj.succeeded() if self.get_state() == DevState.ON: self.logger.info("state: {} status {}".format(self.get_state(), self.get_status())) if self._sc_subarray_state[self.CbfSubarray] == DevState.ON: if self._sc_subarray_obs_state[self.CbfSubarray] == ObsState.EMPTY: self.logger.info("2") self.on_cmd_obj.succeeded() if self._sc_subarray_obs_state[self.CbfSubarray] == ObsState.READY: self.configure_cmd_obj.succeeded() self.logger.info("3") #self.set_state(self._sc_subarray_state[self.CbfSubarray]) #self.logger.info("Csp subarray state: {} obsState: {}".format(self.get_state(), self.state_model._obs_state)) return True Loading Loading
csp-lmc-common/csp_lmc_common/CspMaster.py +36 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ from tango import AttrWriteType, DeviceProxy # from ska.base import SKAMaster from ska.base import utils from ska.base.commands import ResultCode from ska.base.control_model import HealthState, AdminMode, ObsState, LoggingLevel from .utils.decorators import AdminModeCheck, CmdInputArgsCheck from .utils.cspcommons import CmdExecState Loading Loading @@ -593,6 +594,41 @@ class CspMaster(SKAMaster): 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' master_state = self.get_state() if (enable, master_state) not in [(True, tango.DevState.ON), (False, 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) 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)) else: (result_code, msg) = reply.get_data() if result_code == ResultCode.FAILED: self.logger.error(msg[0]) elif result_code == ResultCode.OK: self.logger.info(msg[0]) except (TypeError, ArgumentError) as ex: self.logger.error("TANGO Group command failed") def _se_write_adminMode(self, value, device_fqdn): """ *Class method.* Loading
csp-lmc-common/csp_lmc_common/CspSubarray.py +18 −12 Original line number Diff line number Diff line Loading @@ -343,11 +343,14 @@ class CspSubarray(SKASubarray): class OffCommand(SKASubarray.OffCommand): def do(self): super().do() device = self.target self.logger.info("Call Off Command") device = self.target 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 (result_code, message) = device._sc_subarray_proxies[fqdn].Off() if result_code == ResultCode.FAILED: self.logger.error("Off command failed on device {}".format(fqdn)) Loading Loading @@ -1174,8 +1177,11 @@ class CspSubarray(SKASubarray): str(evt.attr_value.value)) self.logger.info(log_msg) # update CSP sub-array SCM if evt.attr_value.name.lower() in ["state", "healthstate", "adminmode", "obsstate"]: self.update_subarray_state() #07-2020: with the new base classes, transitions are handled via actions. #if evt.attr_value.name.lower() in ["state", "healthstate", "adminmode", "obsstate"]: # self.update_subarray_state() if evt.attr_value.name.lower() == "healthstate": self._update_subarray_health_state() except tango.DevFailed as df: self.logger.error(str(df.args[0].desc)) except Exception as except_occurred: Loading @@ -1196,8 +1202,11 @@ class CspSubarray(SKASubarray): # TODO how report obsState? # adminMode can't be change otherwise the State and healthState # are note updated # 07-2020 # Note: with new base classes transition are handled via actions. But here we # have to be careful....need to review this part # update the State and healthState of the CSP sub-array self.update_subarray_state() #self.update_subarray_state() log_msg = item.reason + ": on attribute " + str(evt.attr_name) self.logger.warning(log_msg) Loading Loading @@ -1316,7 +1325,6 @@ class CspSubarray(SKASubarray): :return: None """ self.logger.info("CspSubarray") self._update_subarray_health_state() if self._command_thread: Loading @@ -1328,18 +1336,16 @@ class CspSubarray(SKASubarray): # CSP state reflects the status of CBF. Only if CBF is present # CSP can work. The state of PSS and PST sub-elements only contributes # to determine the CSP health state. self.set_state(self._sc_subarray_state[self.CbfSubarray]) if self.get_state() == DevState.OFF: if self._sc_subarray_state[self.CbfSubarray] == DevState.OFF: if self._sc_subarray_obs_state[self.CbfSubarray] == ObsState.EMPTY: self.logger.info("1") self.off_cmd_obj.succeeded() if self.get_state() == DevState.ON: self.logger.info("state: {} status {}".format(self.get_state(), self.get_status())) if self._sc_subarray_state[self.CbfSubarray] == DevState.ON: if self._sc_subarray_obs_state[self.CbfSubarray] == ObsState.EMPTY: self.logger.info("2") self.on_cmd_obj.succeeded() if self._sc_subarray_obs_state[self.CbfSubarray] == ObsState.READY: self.configure_cmd_obj.succeeded() self.logger.info("3") #self.set_state(self._sc_subarray_state[self.CbfSubarray]) #self.logger.info("Csp subarray state: {} obsState: {}".format(self.get_state(), self.state_model._obs_state)) return True Loading