コード例 #1
0
    def on_cmd_ended_cb(self, event):
        """
        Callback function executes when the command invoked asynchronously returns from the server.

        :param event: A CmdDoneEvent object. This class is used to pass data to the callback method in asynchronous
                        callback model for command execution.

        :type: CmdDoneEvent object

            It has the following members:
                - device     : (DeviceProxy) The DeviceProxy object on which the call was executed.
                - cmd_name   : (str) The command name
                - argout_raw : (DeviceData) The command argout
                - argout     : The command argout
                - err        : (bool) A boolean flag set to true if the command failed. False otherwise
                - errors     : (sequence<DevError>) The error stack
                - ext

        :return: none
        """
        this_server = TangoServerHelper.get_instance()
        sdp_sa_ln_server = TangoServerHelper.get_instance()
        if event.err:
            log = f"{const.ERR_INVOKING_CMD}{event.cmd_name}\n{event.errors}"
            this_server.write_attr("activityMessage", log, False)
            sdp_sa_ln_server.set_status(log)
            self.logger.error(log)
        else:
            log = const.STR_COMMAND + event.cmd_name + const.STR_INVOKE_SUCCESS
            this_server.write_attr("activityMessage", log, False)
            sdp_sa_ln_server.set_status(log)
            self.logger.info(log)
コード例 #2
0
    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
コード例 #3
0
    def do(self):
        """
        Method to invoke Off 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)

        """
        device_data = self.target
        self.logger.debug(const.STR_OFF_CMD_ISSUED)
        this_device = TangoServerHelper.get_instance()
        this_device.write_attr("activityMessage", const.STR_OFF_CMD_ISSUED,
                               False)
        device_data.cbf_health_updator.stop()
        device_data.pss_health_updator.stop()
        device_data.pst_health_updator.stop()

        return (ResultCode.OK, const.STR_OFF_CMD_ISSUED)
コード例 #4
0
    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,
            )
コード例 #5
0
    def check_allowed(self):
        """
        Checks whether this command is allowed to be run in current device state.

        Assigns resources to given SDP subarray.
        This command is provided as a noop placeholder from SDP subarray.
        Eventually this will likely take a JSON string specifying the resource request.

        :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()
        if self.state_model.op_state in [
                DevState.FAULT,
                DevState.UNKNOWN,
                DevState.DISABLE,
        ]:
            tango.Except.throw_exception(
                f"AssignResources() is not allowed in current state {self.state_model.op_state}",
                "Failed to invoke AssignResources command on SdpSubarrayLeafNode.",
                "sdpsubarrayleafnode.AssignResources()",
                tango.ErrSeverity.ERR,
            )

        return True
コード例 #6
0
    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
コード例 #7
0
    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,
            )
コード例 #8
0
    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
コード例 #9
0
    def cmd_ended_cb(self, event):
        """
        Callback function immediately executed when the asynchronous invoked
        command returns. Checks whether the command has been successfully invoked on DishMaster.

        :param event: a CmdDoneEvent object. This object is used to pass data
            to the callback method in asynchronous callback model for command
            execution.
        :type: CmdDoneEvent object
            It has the following members:
            - cmd_name   : (str) The command name
            - argout_raw : (DeviceData) The command argout
            - argout     : The command argout
            - err        : (bool) A boolean flag set to True if the command failed.
                            False otherwise
            - errors     : (sequence<DevError>) The error stack
            - ext
        """
        this_server = TangoServerHelper.get_instance()
        if event.err:
            log_message = f"Error in invoking command: {event.cmd_name}\n{event.errors}"
            self.logger.error(log_message)
            this_server.write_attr("activityMessage", log_message, False)
        else:
            log_message = f"Command :-> {event.cmd_name} invoked successfully."
            self.logger.info(log_message)
            this_server.write_attr("activityMessage", log_message, False)
コード例 #10
0
    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
コード例 #11
0
    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
コード例 #12
0
    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,
            )
コード例 #13
0
        def do(self):
            """
            Initializes the attributes and properties of the CspMasterLeafNode.

            :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 creating the device proxy for CSP Master or
                    subscribing the evennts.
            """
            super().do()
            device = self.target
            device.attr_map = {}

            this_device = TangoServerHelper.get_instance()
            this_device.set_tango_class(device)
            this_device.write_attr("activityMessage",
                                   const.STR_CSP_INIT_LEAF_NODE, False)

            ApiUtil.instance().set_asynch_cb_sub_model(
                tango.cb_sub_model.PUSH_CALLBACK)
            log_msg = f"{const.STR_SETTING_CB_MODEL}{ApiUtil.instance().get_asynch_cb_sub_model()}"
            self.logger.debug(log_msg)

            this_device.write_attr("activityMessage", const.STR_INIT_SUCCESS,
                                   False)
            self.logger.info(const.STR_INIT_SUCCESS)
            return (ResultCode.OK, const.STR_INIT_SUCCESS)
コード例 #14
0
    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,
            )
コード例 #15
0
    def do(self, argin):
        """
        Method to invoke AssignResources command.

        :param argin: DevString in JSON form containing following fields:
            interface: Schema to allocate assign resources.

            mccs:
                subarray_beam_ids: list of integers

                station_ids: list of integers

                channel_blocks: list of integers

        Example:

        {"interface":"https://schema.skatelescope.org/ska-low-tmc-assignedresources/1.0","mccs":{"subarray_beam_ids":[1],"station_ids":[[1,2]],"channel_blocks":[3]}}

        return:
            A tuple containing ResultCode and string.
        """
        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
        # TODO: For now storing resources as station ids
        input_str = json.loads(argin)
        device_data.resource_list = input_str["mccs"]["station_ids"]
        log_msg = f"{const.STR_ASSIGN_RES_EXEC}STARTED"
        self.logger.debug(log_msg)
        this_server.write_attr("activityMessage", log_msg, False)
        return (ResultCode.STARTED, log_msg)
コード例 #16
0
    def releaseallresources_cmd_ended_cb(self, event):
        """
        Callback function immediately executed when the asynchronous invoked
        command returns.

        :param event: a CmdDoneEvent object. This class is used to pass data
            to the callback method in asynchronous callback model for command
            execution.

        :type: CmdDoneEvent object
            It has the following members:
                - device     : (DeviceProxy) The DeviceProxy object on which the call was executed.
                - cmd_name   : (str) The command name
                - argout_raw : (DeviceData) The command argout
                - argout     : The command argout
                - err        : (bool) A boolean flag set to true if the command failed. False otherwise
                - errors     : (sequence<DevError>) The error stack
                - ext

        :return: none
        """
        this_server = TangoServerHelper.get_instance()
        # Update logs and activity message attribute with received event
        if event.err:
            log_msg = (
                f"{const.ERR_INVOKING_CMD}{event.cmd_name}\n{event.errors}")
            self.logger.error(log_msg)
            this_server.write_attr("activityMessage", log_msg, False)
        else:
            log_msg = f"{const.STR_COMMAND}{event.cmd_name}{const.STR_INVOKE_SUCCESS}"
            self.logger.info(log_msg)
            this_server.write_attr("activityMessage", log_msg, False)
コード例 #17
0
    def do(self):
        """
        Method to invoke Off command on CSP Subarray.

        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)

        """
        this_server = TangoServerHelper.get_instance()
        try:
            log_msg = const.CMD_OFF + const.STR_COMMAND + const.STR_INVOKE_SUCCESS
            self.logger.debug(log_msg)
            delay_manager_obj = DelayManager.get_instance()
            delay_manager_obj.stop()
            return (ResultCode.OK, log_msg)
        except DevFailed as dev_failed:
            log_msg = f"{const.ERR_OFF_INVOKING_CMD}{dev_failed}"
            this_server.write_attr("activityMessage", log_msg, False)
            self.logger.exception(log_msg)
            tango.Except.throw_exception(
                const.ERR_OFF_INVOKING_CMD,
                log_msg,
                "CspSubarrayLeafNode.OffCommand",
                tango.ErrSeverity.ERR,
            )
コード例 #18
0
    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
コード例 #19
0
        def do(self):
            """
            Initializes the attributes and properties of the MccsSubarrayLeafNode.

            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 error occurs in creating proxy for MCCSSubarray.

            """
            super().do()
            device = self.target
            this_server = TangoServerHelper.get_instance()
            this_server.set_tango_class(device)
            device.attr_map = {}
            # Initialise Attributes
            device.attr_map["activityMessage"] = ""
            device_data = DeviceData.get_instance()
            device.device_data = device_data
            device._build_state = "{},{},{}".format(
                release.name, release.version, release.description
            )
            device._version_id = release.version
            device._versioninfo = " "
            device.set_status(const.STR_MCCSSALN_INIT_SUCCESS)
            device._mccs_subarray_health_state = HealthState.OK
            self.logger.info(const.STR_MCCSSALN_INIT_SUCCESS)
            this_server.write_attr("activityMessage", const.STR_MCCSSALN_INIT_SUCCESS, False)
            return (ResultCode.OK, const.STR_MCCSSALN_INIT_SUCCESS)
コード例 #20
0
        def do(self):
            """
            Initializes the attributes and properties of the Central Node Low.

            :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 error occurs while initializing the CentralNode device or if error occurs while
                    creating device proxy for any of the devices like SubarrayNodeLow or MccsMasterLeafNode.

            """
            super().do()

            device = self.target
            try:
                self.logger.info("Device initialisating...")
                device_data = DeviceData.get_instance()
                device.device_data = device_data
                # Get Instance of TangoServerHelper class
                this_server = TangoServerHelper.get_instance()
                this_server.set_tango_class(device)
                device.attr_map = {}
                # Initialise Attributes
                device.attr_map["telescopeHealthState"] = HealthState.UNKNOWN
                device.attr_map["subarray1HealthState"] = HealthState.UNKNOWN
                device.attr_map["activityMessage"] = ""

                device._health_state = HealthState.OK
                device._build_state = "{},{},{}".format(
                    release.name, release.version, release.description)
                device._version_id = release.version
                device_data.mccs_controller_fqdn = "low-mccs/control/control"
                self.logger.debug(const.STR_INIT_SUCCESS)

            except DevFailed as dev_failed:
                log_msg = f"{const.ERR_INIT_PROP_ATTR_CN}{dev_failed}"
                self.logger.exception(dev_failed)
                this_server.write_attr("activityMessage",
                                       const.ERR_INIT_PROP_ATTR_CN, False)
                tango.Except.throw_exception(
                    const.STR_CMD_FAILED,
                    log_msg,
                    "CentralNode.InitCommand.do()",
                    tango.ErrSeverity.ERR,
                )

            for subarray in range(0, len(device.TMLowSubarrayNodes)):
                # populate subarray_id-subarray proxy map
                tokens = device.TMLowSubarrayNodes[subarray].split("/")
                subarray_id = int(tokens[2])
                device_data.subarray_FQDN_dict[
                    subarray_id] = device.TMLowSubarrayNodes[subarray]

            this_server.write_attr("activityMessage",
                                   const.STR_CN_INIT_SUCCESS, False)
            self.logger.info(device.attr_map["activityMessage"])
            return (ResultCode.OK, device.attr_map["activityMessage"])
コード例 #21
0
    def do(self):
        """
        Method to invoke StandBy command.

        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:
            AssertionError if Mccs On command is not completed.

        """
        device_data = self.target
        try:
            self.this_server = TangoServerHelper.get_instance()
            # Check if Mccs On command is completed
            cmd_res = json.loads(device_data.cmd_res_evt_val)
            log_msg = "commandresult attribute value in StandByTelescope command", cmd_res
            self.logger.debug(log_msg)

            if cmd_res["result_code"] != 0:
                retry = 0
                while retry < 3:
                    if cmd_res["result_code"] == 0:
                        break
                    retry += 1
                    time.sleep(0.1)

            assert cmd_res["result_code"] == 0, "Startup command completed OK"
            self.mccs_master_ln_fqdn = ""
            property_value = self.this_server.read_property("MCCSMasterLeafNodeFQDN")
            self.mccs_master_ln_fqdn = self.mccs_master_ln_fqdn.join(property_value)

            self.create_mccs_client(self.mccs_master_ln_fqdn)
            subarray_low = self.this_server.read_property("TMLowSubarrayNodes")
            self.create_subarray_client(subarray_low)
            device_data.health_aggreegator.unsubscribe_event()
            log_msg = const.STR_STANDBY_CMD_ISSUED
            self.logger.info(log_msg)
            self.this_server.write_attr("activityMessage", log_msg, False)
            # Unsubscribe commandResult attribute of MccsController
            cmd_res_subscriber_unsubscriber_obj = CommandResultFetcher()
            cmd_res_subscriber_unsubscriber_obj._unsubscribe_cmd_res_attribute_events()

            return (ResultCode.OK, const.STR_STANDBY_CMD_ISSUED)

        except AssertionError:
            log_msg = const.ERR_STARTUP_CMD_INCOMPLETE
            self.logger.exception(log_msg)
            self.this_server.write_attr("activityMessage", const.ERR_STARTUP_CMD_INCOMPLETE, False)
            tango.Except.throw_exception(const.STR_STANDBY_EXEC, log_msg,
                                         "CentralNode.StandByTelescopeCommand",
                                         tango.ErrSeverity.ERR)
コード例 #22
0
    def __init__(self, logger=None):
        if logger is None:
            self.logger = logging.getLogger(__name__)
        else:
            self.logger = logger

        self._mccs_sa_obs_state = None
        self.mccs_obs_state_event_id = {}
        self.this_server = TangoServerHelper.get_instance()
        self.device_data = DeviceData.get_instance()
コード例 #23
0
        def do(self):
            """
            Initializes the attributes and properties of the CspSubarrayLeafNode.

            :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 error occurs in creating proxy for CSPSubarray.
            """
            super().do()
            device = self.target

            this_server = TangoServerHelper.get_instance()
            this_server.set_tango_class(device)
            device.attr_map = {}
            device.attr_map["delayModel"] = " "
            device.attr_map["activityMessage"] = ""

            device._build_state = "{},{},{}".format(release.name,
                                                    release.version,
                                                    release.description)
            device._version_id = release.version
            device._versioninfo = " "

            # The IERS_A file needs to be downloaded each time when the MVP is deployed.
            delay_manager_obj = DelayManager.get_instance()
            try:
                download_iers_thread = threading.Thread(
                    None, delay_manager_obj.download_IERS_file,
                    "CspSubarrayLeafNode")
                download_iers_thread.start()
            except Exception as delay_execption:
                log_msg = f"Exception in DelayCorrection Katpoint API {delay_execption}"
                self.logger.exception(log_msg)
                tango.Except.throw_exception(
                    const.STR_CMD_FAILED,
                    log_msg,
                    "CspSubarrayLeafNode.InitCommand.do()",
                    tango.ErrSeverity.ERR,
                )

            ApiUtil.instance().set_asynch_cb_sub_model(
                tango.cb_sub_model.PUSH_CALLBACK)
            this_server.write_attr(
                "activityMessage",
                f"{const.STR_SETTING_CB_MODEL}{ApiUtil.instance().get_asynch_cb_sub_model()}",
                False,
            )
            this_server.set_status(const.STR_CSPSALN_INIT_SUCCESS)
            this_server.write_attr("activityMessage",
                                   const.STR_CSPSALN_INIT_SUCCESS, False)
            self.logger.info(const.STR_CSPSALN_INIT_SUCCESS)
            return (ResultCode.OK, const.STR_CSPSALN_INIT_SUCCESS)
コード例 #24
0
    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])
コード例 #25
0
    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)
コード例 #26
0
    def do(self, argin):
        """
        Method to invoke Configure command.

        :param argin: DevString.

        JSON string example is:

         {"interface":"https://schema.skatelescope.org/ska-low-tmc-configure/1.0","mccs":{"stations":[{"station_id":1},{"station_id":2}],"subarray_beams":[{"subarray_beam_id":1,"station_ids":[1,2],"update_rate":0.0,"channels":[[0,8,1,1],[8,8,2,1],[24,16,2,1]],"antenna_weights":[1.0,1.0,1.0],"phase_centre":[0.0,0.0],"target":{"system":"HORIZON","name":"DriftScan","az":180.0,"el":45.0}}]},"sdp":{},"tmc":{"scan_duration":10.0}}


        return:
            A tuple containing a return code and a string message indicating status.
            The message is for information purpose only.

        rtype:
            (ReturnCode, str)

        raises:
            JSONDecodeError if input argument json string contains invalid value
            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
        self.logger.info(const.STR_CONFIGURE_CMD_INVOKED_SA_LOW)
        log_msg = f"{const.STR_CONFIGURE_IP_ARG}{argin}"
        self.logger.info(log_msg)
        self.this_server = TangoServerHelper.get_instance()
        self.this_server.write_attr("activityMessage",
                                    const.STR_CONFIGURE_CMD_INVOKED_SA_LOW,
                                    False)
        try:
            scan_configuration = json.loads(argin)
        except json.JSONDecodeError as jerror:
            log_message = f"{const.ERR_INVALID_JSON}{jerror}"
            self.logger.error(log_message)
            self.this_server.write_attr("activityMessage", log_message, False)
            tango.Except.throw_exception(
                const.STR_CMD_FAILED,
                log_message,
                const.STR_CONFIGURE_EXEC,
                tango.ErrSeverity.ERR,
            )
        tmc_configure = scan_configuration["tmc"]
        device_data.scan_duration = int(tmc_configure["scan_duration"])
        self._create_mccs_cmd_data(scan_configuration)
        message = "Configure command invoked"
        self.logger.info(message)
        return (ResultCode.STARTED, message)
コード例 #27
0
        def do(self):
            """
            Initializes the attributes and properties of the Subarray Node.

            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 error while subscribing the tango attribute
            """
            super().do()
            device = self.target
            device.set_status(const.STR_SA_INIT)
            device_data = DeviceData.get_instance()
            device.device_data = device_data

            this_server = TangoServerHelper.get_instance()
            this_server.set_tango_class(device)
            device.attr_map = {}
            device.attr_map["scanID"] = ""
            device.attr_map["assigned_resources"] = ""
            device.attr_map["activityMessage"] = ""
            device._obs_mode = ObsMode.IDLE
            device._resource_list = []
            device.is_end_command = False
            device.is_release_resources = False
            device._build_state = "{},{},{}".format(release.name,
                                                    release.version,
                                                    release.description)
            device._version_id = release.version
            device._health_event_id = []
            device._mccs_sa_obs_state = ObsState.EMPTY
            device.subarray_ln_health_state_map = {}
            device._subarray_health_state = (
                HealthState.OK)  # Aggregated Subarray Health State
            device.device_data.obs_state_aggr = ObsStateAggregator(self.logger)
            device.device_data.obs_state_aggr.subscribe()
            # subscribe to HealthState
            device.device_data.health_state_aggr = HealthStateAggregator(
                self.logger)
            device.device_data.health_state_aggr.subscribe()
            device_data.assigned_resources_maintainer = AssignedResourcesMaintainer(
            )
            device_data.assigned_resources_maintainer.subscribe()
            this_server.write_attr("activityMessage",
                                   const.STR_SA_INIT_SUCCESS, False)
            self.logger.info(const.STR_SA_INIT_SUCCESS)
            return (ResultCode.OK, const.STR_SA_INIT_SUCCESS)
コード例 #28
0
 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.")
コード例 #29
0
    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,
            )
コード例 #30
0
    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)