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 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 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 _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 do(self): """ Method to invoke End command. 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 if the command execution is not successful. """ device_data = self.target this_server = TangoServerHelper.get_instance() device_data.is_end_command = False 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 try: self.logger.info(const.STR_END_CMD_INVOKED_SA_LOW) 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) self.logger.info(const.STR_CMD_END_INV_MCCS) this_server.write_attr("activityMessage", const.STR_END_SUCCESS, False) self.logger.info(const.STR_END_SUCCESS) device_data.is_end_command = True return (ResultCode.OK, const.STR_END_SUCCESS) except DevFailed as dev_failed: log_msg = f"{const.ERR_END_INVOKING_CMD}{dev_failed}" self.logger.exception(log_msg) tango.Except.throw_exception( const.STR_END_EXEC, log_msg, "SubarrayNode.EndCommand", tango.ErrSeverity.ERR, )
def do(self): """ Method to invoke ObsReset command. 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 if error occurs while invoking command on MccsSubarrayLeafNode. """ device_data = self.target device_data.is_abort_command_executed = False this_server = TangoServerHelper.get_instance() try: self.logger.info("ObsReset command invoked on SubarrayNodeLow.") 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_OBSRESET) this_server.write_attr("activityMessage", const.STR_OBSRESET_SUCCESS, False) self.logger.info(const.STR_OBSRESET_SUCCESS) this_server.set_status(const.STR_OBSRESET_SUCCESS) device_data.is_obsreset_command_executed = True return (ResultCode.STARTED, const.STR_OBSRESET_SUCCESS) except DevFailed as dev_failed: log_msg = f"{const.ERR_OBSRESET_INVOKING_CMD}{dev_failed}" self.logger.exception(log_msg) tango.Except.throw_exception( const.STR_OBSRESET_EXEC, log_msg, "SKASubarrayLow.ObsReset", tango.ErrSeverity.ERR, )
def do(self): """ Method to invoke Off command. 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 if the command execution is not successful """ device_data = self.target this_server = TangoServerHelper.get_instance() 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 try: 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_OFF, None) message = "Off command completed OK" self.logger.info(message) this_server.write_attr("activityMessage", message, False) return (ResultCode.OK, message) except DevFailed as dev_failed: log_msg = f"{const.ERR_INVOKING_OFF_CMD}{dev_failed}" self.logger.error(log_msg) this_server.write_attr("activityMessage", log_msg, False) tango.Except.throw_exception( dev_failed[0].desc, "Failed to invoke Off command on SubarrayNode.", "SubarrayNode.Off()", tango.ErrSeverity.ERR, )
def do(self, argin): """ Method to invoke ReleaseResources command on Subarray Node. :param argin: The string in JSON format. The JSON contains following values: subarray_id: DevShort. Mandatory. release_all: Boolean(True or False). Mandatory. True when all the resources to be released from Subarray. Example: {"interface":"https://schema.skatelescope.org/ska-low-tmc-releaseresources/1.0","subarray_id":1, "release_all":true} Note: From Jive, enter input as: {"interface":"https://schema.skatelescope.org/ska-low-tmc-releaseresources/1.0","subarray_id":1, "release_all":true} without any space. return: None raises: ValueError if input argument json string contains invalid value KeyError if input argument json string contains invalid key DevFailed if the command execution or command invocation on SubarrayNode is not successful """ device_data = self.target try: this_server = TangoServerHelper.get_instance() jsonArgument = json.loads(argin) input_mccs_release = json.loads(argin) subarray_id = jsonArgument["subarray_id"] subarray_fqdn = device_data.subarray_FQDN_dict[subarray_id] if jsonArgument["release_all"] == True: # Invoke ReleaseAllResources on SubarrayNode subarray_client = TangoClient(subarray_fqdn) subarray_client.send_command(const.CMD_RELEASE_RESOURCES) # Invoke ReleaseAllResources on MCCS Master Leaf Node # Send updated input string with inteface key to MCCS Master for ReleaseResource Command input_mccs_release[ "interface"] = "https://schema.skatelescope.org/ska-low-mccs-releaseresources/1.0" self.mccs_master_ln_fqdn = "" property_value = this_server.read_property( "MCCSMasterLeafNodeFQDN") self.mccs_master_ln_fqdn = self.mccs_master_ln_fqdn.join( property_value) mccs_mln_client = TangoClient(self.mccs_master_ln_fqdn) mccs_mln_client.send_command(const.CMD_RELEASE_MCCS_RESOURCES, json.dumps(input_mccs_release)) log_msg = const.STR_REL_RESOURCES self.logger.info(log_msg) this_server.write_attr("activityMessage", log_msg, False) else: this_server.write_attr("activityMessage", const.STR_FALSE_TAG, False) self.logger.info(const.STR_FALSE_TAG) except ValueError as value_error: self.logger.error(const.ERR_INVALID_JSON) this_server.write_attr("activityMessage", f"{const.ERR_INVALID_JSON}{value_error}", False) log_msg = f"{const.ERR_INVALID_JSON}{value_error}" self.logger.exception(value_error) tango.Except.throw_exception( const.STR_RELEASE_RES_EXEC, log_msg, "CentralNode.ReleaseResourcesCommand", tango.ErrSeverity.ERR, ) except KeyError as key_error: self.logger.error(const.ERR_JSON_KEY_NOT_FOUND) this_server.write_attr( "activityMessage", f"{const.ERR_JSON_KEY_NOT_FOUND}{key_error}", False) log_msg = f"{const.ERR_JSON_KEY_NOT_FOUND}{key_error}" self.logger.exception(key_error) tango.Except.throw_exception( const.STR_RELEASE_RES_EXEC, log_msg, "CentralNode.ReleaseResourcesCommand", tango.ErrSeverity.ERR, ) except DevFailed as dev_failed: log_msg = f"{const.ERR_RELEASE_RESOURCES}{dev_failed}" this_server.write_attr("activityMessage", const.ERR_RELEASE_RESOURCES, False) self.logger.exception(dev_failed) tango.Except.throw_exception( const.STR_RELEASE_RES_EXEC, log_msg, "CentralNode.ReleaseResourcesCommand", tango.ErrSeverity.ERR, ) message = const.STR_RETURN_MSG_RELEASE_RESOURCES_SUCCESS self.logger.info(message) return message
def do(self, argin): """ Method to invoke Scan command. :param argin: DevString. JSON string containing id. JSON string example as follows: {"interface":"https://schema.skatelescope.org/ska-low-tmc-scan/1.0","scan_id":1} Note: Above JSON string can be used as an input argument while invoking this command from JIVE. 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_scan_completed = False 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: input_to_mccs = self.update_mccs_json(argin) log_msg = f"{const.STR_SCAN_IP_ARG}{argin}" self.logger.info(log_msg) this_server.write_attr("activityMessage", log_msg, False) device_data.isScanRunning = True # Invoke scan command on MCCS Subarray Leaf Node with input argument as scan id mccs_subarray_ln_fqdn = "" property_val = this_server.read_property("MccsSubarrayLNFQDN")[0] 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_SCAN, json.dumps(input_to_mccs)) self.logger.info(const.STR_MCCS_SCAN_INIT) this_server.write_attr("activityMessage", const.STR_MCCS_SCAN_INIT, False) self.logger.info(const.STR_SA_SCANNING) # Once Scan Duration is complete call EndScan Command self.logger.info("Starting Scan Thread") device_data.scan_timer_handler.start_scan_timer( device_data.scan_duration) this_server.write_attr("activityMessage", const.STR_SCAN_SUCCESS, False) self.logger.info("Scan thread started") return (ResultCode.STARTED, const.STR_SCAN_SUCCESS) except json.JSONDecodeError as json_error: log_message = f"{const.ERR_INVALID_JSON}{json_error}" self.logger.error(log_message) this_server.write_attr("activityMessage", log_message, False) tango.Except.throw_exception( const.STR_CMD_FAILED, log_message, const.STR_SCAN_EXEC, tango.ErrSeverity.ERR, ) except KeyError as key_error: self.logger.error(const.ERR_JSON_KEY_NOT_FOUND) this_server.write_attr( "activityMessage", (const.ERR_JSON_KEY_NOT_FOUND + str(key_error)), False) log_message = f"{const.ERR_JSON_KEY_NOT_FOUND}{key_error}" self.logger.exception(key_error) tango.Except.throw_exception( const.STR_CMD_FAILED, log_message, const.STR_SCAN_EXEC, tango.ErrSeverity.ERR, ) except DevFailed as dev_failed: log_msg = f"{const.ERR_SCAN_CMD}{dev_failed}" self.logger.exception(dev_failed) tango.Except.throw_exception( const.STR_SCAN_EXEC, log_msg, "SubarrayNode.ScanCommand", tango.ErrSeverity.ERR, )