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"])
    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)
Esempio n. 3
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()
        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)
Esempio n. 5
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])
Esempio n. 6
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)
Esempio n. 7
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)
        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)
Esempio n. 9
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.")
Esempio n. 10
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,
            )
    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)
Esempio n. 12
0
    def do(self, argin):
        """
        Method to invoke Configure command on dish.

        :param argin:
            A String in a JSON format that includes pointing parameters of Dish- Azimuth and
            Elevation Angle.

                Example:
                {"pointing":{"target":{"system":"ICRS","name":"Polaris Australis","RA":"21:08:47.92","dec":"-88:57:22.9"}},
                "dish":{"receiverBand":"1"}}

        return:
            None

        raises:
            DevFailed If error occurs while invoking ConfigureBand<> command on DishMaster or
            if the json string contains invalid data.

        """

        device_data = self.target
        command_name = "Configure"

        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)
            json_argument = device_data._load_config_string(argin)
            receiver_band = json_argument["dish"]["receiverBand"]
            self._configure_band(receiver_band)
        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,
                f"DishLeafNode.{command_name}Command",
                tango.ErrSeverity.ERR,
            )
        except KeyError as key_error:
            raise Exception(
                f"JSON key not found.'{key_error}'in Configure.do().")
        self.logger.info("'%s' command executed successfully.", command_name)
Esempio n. 13
0
    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):
            """
            Initializes the attributes and properties of the DishLeafNode.

            :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 in creating a DeviceProxy instance for DishMaster
            """

            super().do()
            device = self.target
            self.logger.info("Initializing DishLeafNode...")
            # Create DeviceData class instance
            device_data = DeviceData.get_instance()
            device.device_data = device_data
            # Get Instance of TangoServerHelper class
            this_server = TangoServerHelper.get_instance()
            this_server.device = device
            device.attr_map = {}
            # Initialise Attributes
            device.attr_map["activityMessage"] = ""
            device._build_state = (
                f"{release.name},{release.version},{release.description}")
            device._version_id = release.version
            device_data.set_dish_name_number(device.DishMasterFQDN)
            azel_converter = AzElConverter(self.logger)
            azel_converter.create_antenna_obj()
            log_message = f"DishMasterFQDN :-> {device.DishMasterFQDN}"
            self.logger.debug(log_message)
            this_server.write_attr("activityMessage", log_message, False)
            device._health_state = HealthState.OK
            device._simulation_mode = SimulationMode.FALSE
            ApiUtil.instance().set_asynch_cb_sub_model(
                tango.cb_sub_model.PUSH_CALLBACK)
            log_message = f"Setting CallBack Model as :-> {ApiUtil.instance().get_asynch_cb_sub_model()}"
            self.logger.debug(log_message)
            this_server.write_attr("activityMessage", log_message, False)

            # Download IERS file from internet
            self.download_iers_thread = threading.Thread(
                None, azel_converter.download_IERS_file, "DishLeafNode")
            self.download_iers_thread.start()

            log_message = "Dish Leaf Node initialized successfully."
            device.set_status(log_message)
            this_server.write_attr("activityMessage", log_message, False)
            self.logger.info(log_message)
            return (ResultCode.OK, log_message)
Esempio n. 15
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.subarray_health_state_map = {}
     self.this_server = TangoServerHelper.get_instance()
     #self.mccs_master_ln_fqdn = self.this_server.read_property("MCCSMasterLeafNodeFQDN")[0]
     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.health_state_event_map = {}
Esempio n. 16
0
        def do(self):
            """
            Initializes the attributes and properties of the MccsMasterLeafNode.

            :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 Mccs Master or
                    subscribing the evennts.
            """
            super().do()
            device = self.target
            device._health_state = HealthState.OK  # Setting healthState to "OK"
            device._simulation_mode = (SimulationMode.FALSE
                                       )  # Enabling the simulation mode
            device._test_mode = TestMode.NONE
            device._build_state = "{},{},{}".format(release.name,
                                                    release.version,
                                                    release.description)
            device._version_id = release.version

            self.this_server = TangoServerHelper.get_instance()
            self.this_server.set_tango_class(device)
            device.attr_map = {}
            # Initialise Attributes
            device.attr_map["activityMessage"] = ""
            # Create DeviceData class instance
            device_data = DeviceData.get_instance()
            device.device_data = device_data
            self.this_server.write_attr("activityMessage",
                                        const.STR_MCCS_INIT_LEAF_NODE, False)
            self.this_server.write_attr(
                "activityMessage",
                f"{const.STR_MCCSMASTER_FQDN}{device.MccsMasterFQDN}", False)
            # Creating proxy to the CSPMaster
            log_msg = f"MCCS Master name: {device.MccsMasterFQDN}"
            self.logger.debug(log_msg)

            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)
            self.this_server.write_attr("activityMessage",
                                        const.STR_INIT_SUCCESS, False)
            self.logger.info(const.STR_INIT_SUCCESS)
            return (ResultCode.OK, const.STR_INIT_SUCCESS)
Esempio n. 17
0
    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 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 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")
Esempio n. 20
0
    def do(self):
        """
        Method to invoke End command on MCCS Subarray.

        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_END, None,
                                                    self.end_cmd_ended_cb)
            this_server.write_attr("activityMessage", const.STR_END_SUCCESS,
                                   False)
            self.logger.info(const.STR_END_SUCCESS)

        except AssertionError:
            log_msg = const.STR_OBS_STATE
            device_data._read_activity_message = const.ERR_DEVICE_NOT_READY
            self.logger.error(log_msg)
            tango.Except.throw_exception(const.STR_END_EXEC,
                                         const.ERR_DEVICE_NOT_READY,
                                         "MCCSSubarrayLeafNode.End",
                                         tango.ErrSeverity.ERR)

        except DevFailed as dev_failed:
            log_msg = f"{const.ERR_END_INVOKING_CMD}{dev_failed}"
            this_server.write_attr("activityMessage", log_msg, False)
            self.logger.exception(dev_failed)
            tango.Except.throw_exception(
                const.ERR_END_INVOKING_CMD,
                log_msg,
                "MccsSubarrayLeafNode.End()",
                tango.ErrSeverity.ERR,
            )
        def do(self):
            """
            Initializes the attributes and properties of the SdpMasterLeafNode.

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

            rtype:
                (ReturnCode, str)
            """

            super().do()
            device = self.target
            device_data = DeviceData.get_instance()
            device.device_data = device_data
            # Creating Instance of TangoServerHelper class
            self.this_server = TangoServerHelper.get_instance()
            self.this_server.device = device

            device.attr_map = {}
            # Initialising Attributes 
            device.attr_map["versionInfo"]=""
            device.attr_map["activityMessage"]=""
            device.attr_map["ProcessingBlockList"]= "test"


            device._health_state = HealthState.OK  # Setting healthState to "OK"
            device._simulation_mode = (
                SimulationMode.FALSE
            )  # Enabling the simulation mode
            device._test_mode = TestMode.NONE
            device.set_status(const.STR_INIT_SUCCESS)
            device._build_state = "{},{},{}".format(
                release.name, release.version, release.description
            )
            device._version_id = release.version
            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)

            self.this_server.write_attr("activityMessage", const.STR_INIT_SUCCESS, False)
            self.logger.info(const.STR_INIT_SUCCESS)
            return (ResultCode.OK, const.STR_INIT_SUCCESS)
Esempio n. 22
0
    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,
            )
Esempio n. 23
0
    def do(self):
        """
        Invokes TrackStop command on the DishMaster.

        param argin:
            None

        return:
            None

        raises:
            DevFailed If error occurs while invoking TrackStop command on DishMaster.

        """
        device_data = self.target
        command_name = "Abort"
        device_data.event_track_time.set()
        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_pointing_state = dish_client.get_attribute("pointingState")
            if (dish_pointing_state.value is not PointingState.READY):
                dish_client.send_command_async("TrackStop",
                                               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,
                "Abort.do()",
                tango.ErrSeverity.ERR,
            )
    def assign_resources_ended(self, event):
        """
        Callback function immediately executed when the asynchronous invoked
        command returns.

        :param: 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

        :raises: DevFailed if this command is not allowed to be run
        in current device state

        """
        self.logger.info("Executing callback assign_resources_ended_cb")
        this_server = TangoServerHelper.get_instance()
        try:
            if event.err:
                this_server.write_attr("activityMessage", f"{const.ERR_INVOKING_CMD}{event.cmd_name}\n{event.errors}", False)
                log = const.ERR_INVOKING_CMD + event.cmd_name
                self.logger.error(log)
            else:
                log = const.STR_COMMAND + event.cmd_name + const.STR_INVOKE_SUCCESS
                this_server.write_attr("activityMessage", log, False)
                self.logger.info(log)

        except tango.DevFailed as df:
            self.logger.exception(df)
            tango.Except.re_throw_exception(
                df,
                "CSP subarray gave an error response",
                "CSP subarray threw error in AddReceptors CSP LMC_CommandFailed",
                "AddReceptors",
                tango.ErrSeverity.ERR,
            )
Esempio n. 25
0
    def __init__(self):
        """Private constructor of the class"""
        if DeviceData.__instance != None:
            raise Exception("This is singletone class")
        else:
            DeviceData.__instance = self

        self.this_server = TangoServerHelper.get_instance()

        self.el = 30.0
        self.az = 0.0
        self.ele_max_lim = 90
        self.ele_min_lim = 17.5
        self.el_limit = False
        self.radec_value = ""
        self.dish_name = ""
        self.dish_number = ""
        self.event_track_time = threading.Event()
        self.attr_event_map = {}
        self.observer = None
Esempio n. 26
0
    def __init__(self, logger=None):
        """Private constructor of the class"""
        if DelayManager.__instance is not None:
            raise Exception("This is singletone class")
        else:
            DelayManager.__instance = self

        if logger is None:
            self.logger = logging.getLogger(__name__)
        else:
            self.logger = logger

        self.fsids_list = []
        self.delay_model_json = {}
        self.device_data = DeviceData.get_instance()
        self._DELAY_UPDATE_INTERVAL = 10
        # _delay_in_advance variable (in seconds) is added to current timestamp and is used to calculate advance
        # delay coefficients.
        self._delay_in_advance = 60
        self.this_server = TangoServerHelper.get_instance()
    def do(self):
        """
        Method to invoke ReleaseAllResources command on CSP Subarray.

        return:
            None

        raises:
            DevFailed if the command execution is not successful

        """
        device_data = self.target
        try:
            # Invoke RemoveAllResources command on CspSubarray
            device_data.receptorIDList_str = []
            device_data.fsids_list = []
            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_RELEASE_ALL_RESOURCES,
                None,
                self.releaseallresources_cmd_ended_cb,
            )
            this_server.write_attr("activityMessage",
                                   const.STR_RELEASE_ALL_RESOURCES_SUCCESS,
                                   False)
            self.logger.info(const.STR_RELEASE_ALL_RESOURCES_SUCCESS)

        except DevFailed as dev_failed:
            log_msg = f"{const.ERR_RELEASE_ALL_RESOURCES}{dev_failed}"
            this_server.write_attr("activityMessage", log_msg, False)
            self.logger.exception(dev_failed)
            tango.Except.throw_exception(
                const.STR_RELEASE_RES_EXEC,
                log_msg,
                "CspSubarrayLeafNode.ReleaseAllResourcesCommand",
                tango.ErrSeverity.ERR,
            )
Esempio n. 28
0
    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,
            )
Esempio n. 29
0
    def do(self):
        """
        Method to invoke Abort 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 in invoking command on MCCS Subarrayleaf node.

        """
        device_data = self.target
        device_data.is_release_resources = False
        device_data.is_end_command = 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()
            mccs_subarray_ln_fqdn = ""
            property_val = this_server.read_property("MccsSubarrayLNFQDN")
            mccs_subarray_ln_fqdn = mccs_subarray_ln_fqdn.join(property_val)
            self.abort_mccs(mccs_subarray_ln_fqdn)
            device_data.is_abort_command_executed = True
            return (ResultCode.STARTED, const.STR_ABORT_SUCCESS)

        except DevFailed as dev_failed:
            log_msg = f"{const.ERR_ABORT_INVOKING_CMD}{dev_failed}"
            self.logger.exception(dev_failed)
            tango.Except.throw_exception(
                const.ERR_ABORT_INVOKING_CMD,
                log_msg,
                "SubarrayNode.Abort",
                tango.ErrSeverity.ERR,
            )
Esempio n. 30
0
    def do(self, argin):
        """
        Method to invoke Slew command on Dish Master.

        :param argin: list
            [0] = Azimuth, in degrees
            [1] = Elevation, in degrees

        return:
            None

        raises:
            DevFailed If error occurs while invoking Slew command on DishMaster.

        """
        command_name = "Slew"
        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(command_name,
                                           command_data=argin,
                                           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,
                "Slew.do()",
                tango.ErrSeverity.ERR,
            )