def subarray_health_subscribe_event(self): """ Method to subscribe to health state change event on SubarrayNode. :raises: Devfailed exception if erroe occures while subscribing event. """ for subarray_fqdn in self.this_server.read_property( "TMLowSubarrayNodes"): subarray_client = TangoClient(subarray_fqdn) # updating the subarray_health_state_map with device name (as ska_mid/tm_subarray_node/1) and its value which is required in callback try: event_id = subarray_client.subscribe_attribute( const.EVT_SUBSR_HEALTH_STATE, self.health_state_cb) self.health_state_event_map[subarray_client] = event_id except DevFailed as dev_failed: log_msg = f"{const.ERR_SUBSR_SA_HEALTH_STATE}{dev_failed}" self.logger.exception(dev_failed) self.this_server.write_attr("activityMessage", const.ERR_SUBSR_SA_HEALTH_STATE, False) tango.Except.throw_exception( const.STR_CMD_FAILED, log_msg, "CentralNode.HealthStateSubscribeEvent", tango.ErrSeverity.ERR, )
def check_allowed(self): """ Checks whether this command is allowed to be run in current device state :return: True if this command is allowed to be run in current device state :rtype: boolean :raises: DevFailed if this command is not allowed to be run in current device state """ self.this_server = TangoServerHelper.get_instance() sdp_subarray_fqdn = self.this_server.read_property( "SdpSubarrayFQDN")[0] self.sdp_sa_ln_client_obj = TangoClient(sdp_subarray_fqdn) if self.state_model.op_state in [DevState.UNKNOWN, DevState.DISABLE]: tango.Except.throw_exception( f"Restart() is not allowed in current state {self.state_model.op_state}", "Failed to invoke Restart command on SdpSubarrayLeafNode.", "sdpsubarrayleafnode.Restart()", tango.ErrSeverity.ERR, ) if self.sdp_sa_ln_client_obj.get_attribute("obsState").value not in [ ObsState.ABORTED, ObsState.FAULT ]: tango.Except.throw_exception(const.ERR_DEVICE_NOT_ABORTED_FAULT, const.ERR_RESTART_INVOKING_CMD, "SdpSubarrayLeafNode.Restart()", tango.ErrSeverity.ERR) return True
def _subscribe_cmd_res_attribute_events(self, attributes): """Method to subscribe the commandResult attributes""" device_data = DeviceData.get_instance() mccs_controller_client = TangoClient(device_data.mccs_controller_fqdn) device_data.attr_event_map[ "mccs_controller_client"] = mccs_controller_client for attribute_name in attributes: try: device_data.attr_event_map[ attribute_name] = mccs_controller_client.subscribe_attribute( attribute_name, self.command_result_cb) except DevFailed as dev_failed: self.logger.exception(dev_failed) log_message = ( f"Exception occurred while subscribing to mccs attribute: {attribute_name}" ) self.this_server.write_attr("activityMessage", log_message, False) tango.Except.re_throw_exception( dev_failed, "Exception in StartupTelescope command", log_message, "CentralNode.{}Command".format("StartUpTelescope"), tango.ErrSeverity.ERR, )
def check_allowed(self): """ Checks whether this command is allowed to be run in current device state :return: True if this command is allowed to be run in current device state :rtype: boolean :raises: DevFailed if this command is not allowed to be run in current device state """ if self.state_model.op_state in [DevState.UNKNOWN, DevState.DISABLE]: log_msg = f"ObsReset() is not allowed in {self.state_model.op_state}" tango.Except.throw_exception( log_msg, "Failed to invoke ObsReset command on MccsSubarrayLeafNode.", "mccssubarrayleafnode.ObsReset()", tango.ErrSeverity.ERR, ) self.this_server = TangoServerHelper.get_instance() self.mccs_sa_fqdn = self.this_server.read_property( "MccsSubarrayFQDN")[0] self.mccs_sa_client = TangoClient(self.mccs_sa_fqdn) if self.mccs_sa_client.get_attribute("obsState").value not in [ ObsState.ABORTED, ObsState.FAULT ]: tango.Except.throw_exception( const.ERR_DEVICE_NOT_IN_VALID_OBSTATE, const.ERR_OBSRESET_INVOKING_CMD, "MccsSubarrayLeafNode.ObsResetCommand", tango.ErrSeverity.ERR) return True
def check_allowed(self): """ Checks whether this command is allowed to be run in current device state return: True if this command is allowed to be run in current device state rtype: boolean raises: DevFailed if this command is not allowed to be run in current device state """ if self.state_model.op_state in [DevState.UNKNOWN, DevState.DISABLE]: tango.Except.throw_exception( f"Restart() is not allowed in current state {self.state_model.op_state}", "Failed to invoke Restart command on CspSubarrayLeafNode.", "cspsubarrayleafnode.Restart()", tango.ErrSeverity.ERR, ) this_server = TangoServerHelper.get_instance() csp_subarray_fqdn = this_server.read_property("CspSubarrayFQDN")[0] csp_sa_client = TangoClient(csp_subarray_fqdn) if csp_sa_client.get_attribute("obsState").value not in [ ObsState.FAULT, ObsState.ABORTED ]: tango.Except.throw_exception(const.ERR_UNABLE_RESTART_CMD, const.ERR_RESTART_INVOKING_CMD, "CspSubarrayLeafNode.RestartCommand", tango.ErrSeverity.ERR) return True
def check_allowed(self): """ Checks whether this command is allowed to be run in current device state. :return: True if this command is allowed to be run in current device state. :rtype: boolean :raises: Exception if command execution throws any type of exception. """ self.this_server = TangoServerHelper.get_instance() sdp_subarray_fqdn = self.this_server.read_property( "SdpSubarrayFQDN")[0] self.sdp_sa_ln_client_obj = TangoClient(sdp_subarray_fqdn) if self.state_model.op_state in [ DevState.FAULT, DevState.UNKNOWN, DevState.DISABLE, ]: tango.Except.throw_exception( f"Scan() is not allowed in current state {self.state_model.op_state}", "Failed to invoke Scan command on SdpSubarrayLeafNode.", "sdpsubarrayleafnode.Scan()", tango.ErrSeverity.ERR, ) if self.sdp_sa_ln_client_obj.get_attribute( "obsState").value != ObsState.READY: tango.Except.throw_exception( const.ERR_DEVICE_NOT_READY, const.STR_SCAN_EXEC, "SdpSubarrayLeafNode.StartScanCommand", tango.ErrSeverity.ERR) return True
def do(self, argin): """ Invokes Endscan command on DishMaster. param argin: timestamp raises: DevFailed If error occurs while invoking StopCapture command on DishMaster. """ command_name = "EndScan" cmd_ended_cb = CommandCallBack(self.logger).cmd_ended_cb try: this_server = TangoServerHelper.get_instance() self.dish_master_fqdn = "" property_value = this_server.read_property("DishMasterFQDN") self.dish_master_fqdn = self.dish_master_fqdn.join(property_value) dish_client = TangoClient(self.dish_master_fqdn) dish_client.send_command_async("StopCapture", callback_method=cmd_ended_cb) self.logger.info("'%s' command executed successfully.", command_name) except DevFailed as dev_failed: self.logger.exception(dev_failed) log_message = ( f"Exception occured while executing the '{command_name}' command." ) this_server.write_attr("activityMessage", log_message, False) tango.Except.re_throw_exception( dev_failed, f"Exception in '{command_name}' command.", log_message, "EndScan.do()", tango.ErrSeverity.ERR, )
def do(self): """ Method to invoke Standby command on SDP Master. :param argin: None. return: None """ this_server = TangoServerHelper.get_instance() try: sdp_master_ln_fqdn = "" property_val = this_server.read_property("SdpMasterFQDN")[0] sdp_master_ln_fqdn = sdp_master_ln_fqdn.join(property_val) sdp_mln_client_obj = TangoClient(sdp_master_ln_fqdn) sdp_mln_client_obj.send_command_async( const.CMD_STANDBY, callback_method=self.standby_cmd_ended_cb ) log_msg = const.CMD_STANDBY + const.STR_COMMAND + const.STR_INVOKE_SUCCESS self.logger.debug(log_msg) except DevFailed as dev_failed: self.logger.exception(dev_failed) log_msg = f"{const.ERR_STANDBY_CMD_FAIL}{dev_failed}" tango.Except.re_throw_exception( dev_failed, const.ERR_INVOKING_CMD, log_msg, "SdpMasterLeafNode.StandbyCommand()", tango.ErrSeverity.ERR, )
def check_allowed(self): """ Checks whether this command is allowed to be run in current device state :return: True if this command is allowed to be run in current device state :rtype: boolean :raises: Exception if command execution throws any type of exception """ self.this_server = TangoServerHelper.get_instance() sdp_subarray_fqdn = self.this_server.read_property("SdpSubarrayFQDN")[0] self.sdp_sa_ln_client_obj = TangoClient(sdp_subarray_fqdn) if self.state_model.op_state in [ DevState.FAULT, DevState.UNKNOWN, DevState.DISABLE, ]: tango.Except.throw_exception( f"ReleaseAllResources() is not allowed in current state {self.state_model.op_state}", "Failed to invoke ReleaseAllResources command on " "SdpSubarrayLeafNode.", "SdpSubarrayLeafNode.ReleaseAllResources()", tango.ErrSeverity.ERR, ) if self.sdp_sa_ln_client_obj.get_attribute("obsState").value != ObsState.IDLE: tango.Except.throw_exception(const.STR_RELEASE_RES_EXEC, const.ERR_RELEASE_RESOURCES, "SdpSubarrayLeafNode.ReleaseAllResources()", tango.ErrSeverity.ERR) return True
def check_allowed(self): """ Checks whether the command is allowed to be run in the current state :return: True if this command is allowed to be run in current device state :rtype: boolean :raises: DevFailed if this command is not allowed to be run in current device state """ if self.state_model.op_state in [ DevState.FAULT, DevState.UNKNOWN, DevState.DISABLE, ]: tango.Except.throw_exception( f"ReleaseAllResources() is not allowed in current state {self.state_model.op_state}", "Failed to invoke ReleaseAllResources command on " "cspsubarrayleafnode.", "cspsubarrayleafnode.ReleaseAllResources()", tango.ErrSeverity.ERR, ) this_server = TangoServerHelper.get_instance() csp_subarray_fqdn = this_server.read_property("CspSubarrayFQDN")[0] csp_sa_client = TangoClient(csp_subarray_fqdn) if csp_sa_client.get_attribute("obsState").value != ObsState.IDLE: tango.Except.throw_exception( const.ERR_DEVICE_NOT_IDLE, "Failed to invoke ReleaseAllResourcesCommand command on cspsubarrayleafnode.", "CspSubarrayLeafNode.ReleaseAllResourcesCommand", tango.ErrSeverity.ERR) return True
def do(self): """ Method to invoke Endscan command on CSP Subarray. return: None raises: DevFailed if the command execution is not successful """ try: this_server = TangoServerHelper.get_instance() csp_subarray_fqdn = "" property_val = this_server.read_property("CspSubarrayFQDN") csp_subarray_fqdn = csp_subarray_fqdn.join(property_val) csp_sub_client_obj = TangoClient(csp_subarray_fqdn) csp_sub_client_obj.send_command_async(const.CMD_ENDSCAN, None, self.endscan_cmd_ended_cb) this_server.write_attr("activityMessage", const.STR_ENDSCAN_SUCCESS, False) self.logger.info(const.STR_ENDSCAN_SUCCESS) except DevFailed as dev_failed: log_msg = f"{const.ERR_ENDSCAN_INVOKING_CMD}{dev_failed}" this_server.write_attr("activityMessage", log_msg, False) self.logger.exception(dev_failed) tango.Except.throw_exception( const.STR_ENDSCAN_EXEC, log_msg, "CspSubarrayLeafNode.EndScanCommand", tango.ErrSeverity.ERR, )
def do(self): """ This command invokes Abort command on CSP Subarray. return: None raises: DevFailed if error occurs while invoking command on CSP Subarray. """ try: this_server = TangoServerHelper.get_instance() csp_subarray_fqdn = "" property_val = this_server.read_property("CspSubarrayFQDN") csp_subarray_fqdn = csp_subarray_fqdn.join(property_val) csp_sub_client_obj = TangoClient(csp_subarray_fqdn) csp_sub_client_obj.send_command_async(const.CMD_ABORT, None, self.abort_cmd_ended_cb) this_server.write_attr("activityMessage", const.STR_ABORT_SUCCESS, False) self.logger.info(const.STR_ABORT_SUCCESS) except DevFailed as dev_failed: log_msg = f"{const.ERR_ABORT_INVOKING_CMD}{dev_failed}" this_server.write_attr("activityMessage", log_msg, False) self.logger.exception(dev_failed) tango.Except.throw_exception( const.STR_ABORT_EXEC, log_msg, "CspSubarrayLeafNode.AbortCommand", tango.ErrSeverity.ERR, )
class PssHealthStateAttributeUpdator: """ This class handles subscription of healthState attribute of PSS master device - PssHealthStateAttribute - Forwarded attribute to provide CSP Master Health State - _csp_pss_health_state_log - Variable to provide activity log """ def __init__(self, logger=None): if logger == None: self.logger = logging.getLogger(__name__) else: self.logger = logger self.device_data = DeviceData.get_instance() self.this_server = TangoServerHelper.get_instance() self.event_id = None self.csp_master = TangoClient( self.this_server.read_property("CspMasterFQDN")[0]) def start(self): try: self.event_id = self.csp_master.subscribe_attribute( "cspPssHealthState", self.csp_pss_health_state_cb) except tango.DevFailed: self.logger.exception("Exception in attribute subscription") def stop(self): try: self.csp_master.unsubscribe_attribute(self.event_id) except tango.DevFailed: self.logger.exception("Exception in unsubscribing the attribute.") def csp_pss_health_state_cb(self, evt): """ Retrieves the subscribed cspPssHealthState attribute of CSPMaster. :param evt: A TANGO_CHANGE event on cspPssHealthState attribute. :return: None """ log_msg = f"CspPssHealthState Attribute change event is : {evt}" self.logger.debug(log_msg) if not evt.err: self._csp_pss_health = evt.attr_value.value if self._csp_pss_health in (HealthState.OK, HealthState.DEGRADED, HealthState.FAILED): log_message = f"CSP PSS health is {HealthState(self._csp_pss_health).name}." self.logger.debug(log_message) self.device_data._csp_pss_health_state_log = log_message else: log_message = "CSP PSS health is UNKNOWN." self.logger.debug(log_message) self.device_data._csp_pss_health_state_log = log_message else: self.device_data._csp_pss_health_state_log = f"{const.ERR_ON_SUBS_CSP_PSS_HEALTH}{evt.errors}" self.logger.error(const.ERR_ON_SUBS_CSP_PSS_HEALTH)
def restart_leaf_nodes(self, leaf_node_fqdn, info_string): """ set up mccs devices """ # Invoke Restart command on MCCS Subarray Leaf Node. mccs_subarray_client = TangoClient(leaf_node_fqdn) mccs_subarray_client.send_command(const.CMD_RESTART) self.logger.info(info_string) self.logger.info(const.STR_RESTART_SUCCESS)
def subscribe(self): mccs_subarray_ln_fqdn = "" property_val = self.this_server.read_property("MccsSubarrayLNFQDN") mccs_subarray_ln_fqdn = mccs_subarray_ln_fqdn.join(property_val) self.mccs_client = TangoClient(mccs_subarray_ln_fqdn) # Subscribe mccsSubarrayObsState (forwarded attribute) of mccsSubarray mccs_event_id = self.mccs_client.subscribe_attribute( const.EVT_MCCSSA_OBS_STATE, self.observation_state_cb) self.mccs_obs_state_event_id[self.mccs_client] = mccs_event_id log_msg = f"{const.STR_SUB_ATTR_MCCS_SALN_OBSTATE_SUCCESS}{self.mccs_obs_state_event_id}" self.logger.info(log_msg)
def __init__(self, logger=None): if logger == None: self.logger = logging.getLogger(__name__) else: self.logger = logger self.device_data = DeviceData.get_instance() self.this_server = TangoServerHelper.get_instance() self.event_id = None self.csp_master = TangoClient( self.this_server.read_property("CspMasterFQDN")[0])
def _configure_band(self, band): """"Send the ConfigureBand<band-number> command to Dish Master""" command_name = f"ConfigureBand{band}" try: dish_client = TangoClient(self.dish_master_fqdn) cmd_ended_cb = CommandCallBack(self.logger).cmd_ended_cb dish_client.send_command_async(command_name, callback_method=cmd_ended_cb) except DevFailed as dev_failed: raise dev_failed
def abort_mccs(self, mccs_sa_ln_fqdn): """ Create client of MCCS subarray leaf node and invoke abort command on client. :param argin: MCCS SubarrayLeafNode FQDN return: None """ mccs_client = TangoClient(mccs_sa_ln_fqdn) mccs_client.send_command(const.CMD_ABORT) self.logger.info(const.STR_CMD_ABORT_INV_MCCS)
def __init__(self, logger=None): if logger == None: self.logger = logging.getLogger(__name__) else: self.logger = logger self.mccs_ln_asigned_res_event_id = {} self.this_server = TangoServerHelper.get_instance() self.device_data = DeviceData.get_instance() mccs_subarray_ln_fqdn = self.this_server.read_property( "MccsSubarrayLNFQDN")[0] self.mccs_client = TangoClient(mccs_subarray_ln_fqdn)
def validate_obs_state(self): self.this_server = TangoServerHelper.get_instance() sdp_subarray_fqdn = self.this_server.read_property("SdpSubarrayFQDN")[0] sdp_sa_client = TangoClient(sdp_subarray_fqdn) if sdp_sa_client.get_attribute("obsState").value in [ObsState.EMPTY, ObsState.IDLE]: self.logger.info( "SDP subarray is in required obstate,Hence resources to SDP can be assign." ) else: self.logger.error("Subarray is not in EMPTY obstate") log_msg = "Error in device obstate." self.this_server.write_attr("activityMessage", log_msg, False) raise InvalidObsStateError("SDP subarray is not in EMPTY obstate.")
def do(self, argin): """ Method to invoke Scan command on MCCS Subarray. :param argin: JSON string consists of scan id (int) and start_time. Example: {"interface":"https://schema.skatelescope.org/ska-low-mccs-scan/1.0","scan_id":1,"start_time":0.0} Note: Enter the json string without spaces as a input. return: None raises: DevFailed if the command execution is not successful """ this_server = TangoServerHelper.get_instance() device_data = DeviceData.get_instance() try: mccs_subarray_fqdn = "" property_value = this_server.read_property("MccsSubarrayFQDN")[0] mccs_subarray_fqdn = mccs_subarray_fqdn.join(property_value) mccs_subarray_client = TangoClient(mccs_subarray_fqdn) assert mccs_subarray_client.get_attribute( "obsState").value == ObsState.READY mccs_subarray_client.send_command_async(const.CMD_SCAN, argin, self.scan_cmd_ended_cb) this_server.write_attr("activityMessage", const.STR_SCAN_SUCCESS, False) self.logger.info(const.STR_SCAN_SUCCESS) except AssertionError as assertion_error: log_msg = f"{const.ERR_DEVICE_NOT_READY}{assertion_error}" device_data._read_activity_message = log_msg self.logger.exception(log_msg) tango.Except.throw_exception(const.STR_SCAN_EXEC, log_msg, "MccsSubarrayLeafNode.Scan", tango.ErrSeverity.ERR) except DevFailed as dev_failed: log_msg = f"{const.ERR_SCAN_RESOURCES}{dev_failed}" this_server.write_attr("activityMessage", log_msg, False) self.logger.exception(dev_failed) tango.Except.throw_exception( const.STR_SCAN_EXEC, log_msg, "MccsSubarrayLeafNode.Scan", tango.ErrSeverity.ERR, )
def __init__(self, logger=None): if logger == None: self.logger = logging.getLogger(__name__) else: self.logger = logger self.subarray_ln_health_state_map = {} self.mccs_ln_health_event_id = {} self.this_server = TangoServerHelper.get_instance() self.device_data = DeviceData.get_instance() mccs_subarray_ln_fqdn = "" property_val = self.this_server.read_property("MccsSubarrayLNFQDN") mccs_subarray_ln_fqdn = mccs_subarray_ln_fqdn.join(property_val) self.mccs_client = TangoClient(mccs_subarray_ln_fqdn)
def do(self): """ Method to invoke SetOperateMode command on DishMaster. param argin: None return: None raises: DevFailed If error occurs while invoking SetOperateMode command on DishMaster. """ cmd_ended_cb = CommandCallBack(self.logger).cmd_ended_cb attributes_to_subscribe_to = ( "dishMode", "capturing", "achievedPointing", "desiredPointing", ) command_name = "SetOperateMode" cmd_ended_cb = CommandCallBack(self.logger).cmd_ended_cb try: self.this_server = TangoServerHelper.get_instance() self.dish_master_fqdn = "" property_value = self.this_server.read_property("DishMasterFQDN") self.dish_master_fqdn = self.dish_master_fqdn.join(property_value) dish_client = TangoClient(self.dish_master_fqdn) # Subscribe the DishMaster attributes self._subscribe_to_attribute_events(attributes_to_subscribe_to, dish_client) dish_client.send_command_async(command_name, callback_method=cmd_ended_cb) self.logger.info("'%s' command executed successfully.", command_name) except DevFailed as dev_failed: self.logger.exception(dev_failed) log_message = ( f"Exception occured while executing the '{command_name}' command." ) self.this_server.write_attr("activityMessage", log_message, False) tango.Except.re_throw_exception( dev_failed, f"Exception in '{command_name}' command.", log_message, f"DishLeafNode.{command_name}Command", tango.ErrSeverity.ERR, )
def do(self): """ Method to invoke On command on CSP Element. param argin: None return: A tuple containing a return code and a string message indicating status. The message is for information purpose only. rtype: (ResultCode, str) raises: DevFailed on communication failure with CspMaster or CspMaster is in error state. """ device_data = self.target this_device = TangoServerHelper.get_instance() try: csp_mln_client_obj = TangoClient( this_device.read_property("CspMasterFQDN")[0]) csp_mln_client_obj.send_command_async(const.CMD_ON, [], self.on_cmd_ended_cb) self.logger.debug(const.STR_ON_CMD_ISSUED) this_device.write_attr("activityMessage", const.STR_ON_CMD_ISSUED, False) device_data.cbf_health_updator = CbfHealthStateAttributeUpdator() device_data.cbf_health_updator.start() device_data.pss_health_updator = PssHealthStateAttributeUpdator() device_data.pss_health_updator.start() device_data.pst_health_updator = PstHealthStateAttributeUpdator() device_data.pst_health_updator.start() return (ResultCode.OK, const.STR_ON_CMD_ISSUED) except DevFailed as dev_failed: log_msg = f"{const.ERR_EXE_ON_CMD}{dev_failed}" self.logger.exception(dev_failed) this_device.write_attr("activityMessage", const.ERR_EXE_ON_CMD, False) tango.Except.re_throw_exception( dev_failed, const.STR_ON_EXEC, log_msg, "CspMasterLeafNode.OnCommand", tango.ErrSeverity.ERR, )
def test_activity_message_attribute_reports_correct_csp_health_state_callbacks( mock_csp_master_proxy, health_state, mock_tango_server_helper ): ( device_proxy, tango_client_obj, csp_master_fqdn, event_subscription_map, ) = mock_csp_master_proxy with mock.patch.object( TangoClient, "_get_deviceproxy", return_value=Mock() ) as mock_obj: with mock.patch.object( TangoClient, "subscribe_attribute", side_effect=dummy_subscriber ): tango_client_obj = TangoClient("mid_csp/elt/master") device_proxy.On() device_data = DeviceData.get_instance() assert ( device_data._csp_cbf_health_state_log == f"CSP CBF health is {health_state.name}" ) assert ( device_data._csp_pst_health_state_log == f"CSP PST health is {health_state.name}." ) assert ( device_data._csp_pss_health_state_log == f"CSP PSS health is {health_state.name}." )
def _configure_mccs_subarray(self, cmd_name, cmd_data): try: mccs_subarray_ln_fqdn = "" property_val = self.this_server.read_property("MccsSubarrayLNFQDN") mccs_subarray_ln_fqdn = mccs_subarray_ln_fqdn.join(property_val) mccs_subarray_ln_client = TangoClient(mccs_subarray_ln_fqdn) mccs_subarray_ln_client.send_command(cmd_name, cmd_data) log_msg = "%s configured succesfully." % mccs_subarray_ln_fqdn self.logger.debug(log_msg) except DevFailed as df: log_message = df[0].desc self.this_server.write_attr("activityMessage", log_message, False) log_msg = "Failed to configure %s. %s" % ( mccs_subarray_ln_fqdn, df, ) self.logger.error(log_msg)
def validate_obs_state(self): this_server = TangoServerHelper.get_instance() csp_subarray_fqdn = this_server.read_property("CspSubarrayFQDN")[0] csp_sa_client = TangoClient(csp_subarray_fqdn) if csp_sa_client.get_attribute("obsState").value in [ ObsState.EMPTY, ObsState.IDLE, ]: self.logger.info( "CSP Subarray is in required obsState, resources will be assigned" ) else: self.logger.error("CSP Subarray is not in EMPTY/IDLE obsState") this_server.write_attr("activityMessage", "Error in device obsState", False) raise InvalidObsStateError( "CSP Subarray is not in EMPTY/IDLE obsState")
def do(self): """ Method to invoke EndScan command. return: A tuple containing a return code and a string message indicating status. The message is for information purpose only. rtype: (ReturnCode, str) raises: DevFailed if the command execution is not successful. """ device_data = self.target device_data.is_release_resources = False device_data.is_abort_command_executed = False device_data.is_obsreset_command_executed = False device_data.is_restart_command_executed = False this_server = TangoServerHelper.get_instance() try: if device_data.scan_timer_handler.is_scan_running(): device_data.scan_timer_handler.stop_scan_timer() # stop timer when EndScan command is called device_data.isScanRunning = False device_data.is_scan_completed = True mccs_subarray_ln_fqdn = "" property_val = this_server.read_property("MccsSubarrayLNFQDN") mccs_subarray_ln_fqdn = mccs_subarray_ln_fqdn.join(property_val) mccs_subarray_ln_client = TangoClient(mccs_subarray_ln_fqdn) mccs_subarray_ln_client.send_command(const.CMD_END_SCAN) self.logger.debug(const.STR_MCCS_END_SCAN_INIT) this_server.write_attr("activityMessage", const.STR_MCCS_END_SCAN_INIT, False) this_server.write_attr("scanID", "") self.logger.info(const.STR_SCAN_COMPLETE) this_server.write_attr("activityMessage", const.STR_END_SCAN_SUCCESS, False) return (ResultCode.OK, const.STR_END_SCAN_SUCCESS) except DevFailed as dev_failed: log_msg = f"{const.ERR_END_SCAN_CMD_ON_MCCS}{dev_failed}" self.logger.exception(dev_failed) tango.Except.throw_exception( const.STR_END_SCAN_EXEC, log_msg, "SubarrayNode.EndScanCommand", tango.ErrSeverity.ERR, )
def event_subscription(): event_subscription_map = {} with mock.patch.object(TangoClient, "_get_deviceproxy", return_value=Mock()): tango_client_object = TangoClient("low-mccs/subarray/01") tango_client_object.deviceproxy.command_inout_asynch.side_effect = lambda command_name, argument, callback, *args, **kwargs: event_subscription_map.update( {command_name: callback} ) yield event_subscription_map
def create_mccs_client(self, mccs_master_fqdn): """ Create TangoClient for MccsMasterLeafNode node and call standby method. :return: None """ mccs_mln_client = TangoClient(mccs_master_fqdn) self.invoke_stnadby(mccs_mln_client)