Commit 33263462 authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

fix_subarray_on_command: Fix CspMaster On command:on success it invokes the On

command an all the deployed CspSubarrays.
EndScan and GoToIdle are now implemented as synchronous commands.
parent 5f6e12a1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
0.6.4
- CSP Subarrays are enabled when the  On command is invoked on the CspMaster
- fix EndScan: command invoked synchronously
- GoToIdle now invoked synchronously

0.6.3
- use ska-python-buildenv and runtime 9.3.2
- use lmcbaseclasses ver 0.6.3
+67 −38
Original line number Diff line number Diff line
@@ -380,11 +380,11 @@ class CspSubarray(SKASubarray):
                # for the received configuration content
                if target_device._valid_scan_configuration:
                    try:
                        stored_configuration = json.dumps(self._valid_scan_configuration, sort_keys=True)
                        stored_configuration = json.dumps(target_device._valid_scan_configuration, sort_keys=True)
                        received_configuration = json.dumps(argin, sort_keys=True)
                        # if the received configuration is equal to the last valid configuration and the
                        # state of the subarray is READY than subarray is not re-configured.
                        if (stored_configuration == received_configuration) and (target_device._obs_state == ObsState.READY):
                        if (stored_configuration == received_configuration) and (target_device.state_model._obs_state == ObsState.READY):
                            self.logger.info("Subarray is going to use the same configuration")
                            return (ResultCode.OK, "Configure command OK")
                    except Exception as e:
@@ -742,8 +742,6 @@ class CspSubarray(SKASubarray):
                    # if the sub-component execution flag is no more RUNNING, the command has
                    # ended with or without success. Go to check next device state.
                    if target_device._sc_subarray_obs_state[device] == dev_successful_state:
                        self.logger.info("end scan set: {}".format(format(target_device._end_scan_event.is_set())))
                        if target_device._end_scan_event.is_set():
                        self.logger.info("Command {} ended with success on device {}.".format(cmd_name,
                                                                                            device))
                        # update the list and number of device that completed the task
@@ -766,6 +764,7 @@ class CspSubarray(SKASubarray):
                    # TODO: handle connection problems
                    #if target_device._sc_subarray_state[device] == DevState.UNKNOWN:
                    #    self.logger.warning("Connection with device {} temporaly down".format(device))
                if target_device._end_scan_event.is_set():
                    if any(device_done.values()) and all(value == True for value in device_done.values()):
                        self.logger.info("All devices have been handled!")
                        break
@@ -784,31 +783,38 @@ class CspSubarray(SKASubarray):
                elapsed_time = time.time() - starting_time 
                self.logger.info("Scan elapsed time:{}".format(elapsed_time))
                target_device._last_executed_command = cmd_name
                return target_device.scan_cmd_obj.succeeded()
                return

    class EndScanCommand(SKASubarray.EndScanCommand):

        def do(self):
            target_device = self.target
            device_list = target_device._sc_subarray_assigned_fqdn
            self.logger.info("EndScan assigned_fqdn: {}".format(device_list))
            if not any(target_device._sc_subarray_assigned_fqdn):
                # need to add a check also on PSTBeams belonging to subarray
                device_list = target_device._sc_subarray_fqdn
            for device in device_list:
            try:
                    proxy = target_device._sc_subarray_proxies[device]
                    #proxy.command_inout_asynch("EndScan", target_device._cmd_ended_cb)
                    # Note: at the moment EndScan does not support STARTED code so can't start
                    # asynchrnously
                    proxy.command_inout("EndScan")
                except KeyError as key_err:
                    self.logger.warning("No key {} found".format(key_err))
                except tango.DevFailed as tango_err:
                    self.logger.warning(tango_err.args[0].desc)
                    # TODO: address this case!
                    # signal the failure raising the failure flag?
            # set the threading endScan event 
                sc_group = tango.Group("EndScanGroup")
                self.logger.info("Create group!!")
                for device in device_list:
                    sc_group.add(device)
            except (TypeError, ArgumentError) as ex:
                self.logger.error("TANGO Group command failed")
                return (ResultCode.FAILED, "EndScan Command FAILED")
            self.logger.info("Issue EndScan")
            answers = sc_group.command_inout("EndScan")
            target_device._end_scan_event.set()
            self.logger.info("end scan set: {}".format(format(target_device._end_scan_event.is_set())))
            for reply in answers: 
                if reply.has_failed(): 
                    for err in reply.get_err_stack(): 
                        self.logger.error("device {}: {}-{}".format(reply.dev_name(), err.desc, err.reason))
                else:
                    (result_code,msg) = reply.get_data()
                    self.logger.error("device {}: {}".format(reply.dev_name(), msg))
            if any(target_device._sc_subarray_obs_state[device]== ObsState.FAULT for device in  device_list):
                return (ResultCode.FAILED, "EndScan Command FAILED")
            return (ResultCode.OK, "EndScan command executed OK")

    class ObsResetCommand(SKASubarray.ObsResetCommand):
@@ -917,8 +923,6 @@ class CspSubarray(SKASubarray):
            self.logger.info(message)
            return (ResultCode.OK, message)
    
    
    '''
    class GoToIdleCommand(ActionCommand):
        """
        A class for the CSPSubarray's GoToIdle() command.
@@ -1119,6 +1123,34 @@ class CspSubarray(SKASubarray):
            #                                 msg,
            #                                 "GoToIdle",
            #                                 tango.ErrSeverity.ERR)
    '''
    class GoToIdleCommand(SKASubarray.EndCommand):
        def do(self):
            target_device = self.target
            device_list = target_device._sc_subarray_assigned_fqdn
            if not any(target_device._sc_subarray_assigned_fqdn):
                # need to add a check also on PSTBeams belonging to subarray
                device_list = target_device._sc_subarray_fqdn
            try:
                self.logger.info("Creating group for GoToIdle {}".format(device_list))
                sc_group = tango.Group("GoToIdleGroup")
                for device in device_list:
                    sc_group.add(device)
            except (TypeError, ArgumentError) as ex:
                self.logger.error("TANGO Group command failed")
                return (ResultCode.FAILED, "GoToIDle Command FAILED")
            self.logger.info("Issue GoToIdle")
            answers = sc_group.command_inout("GoToIdle")
            for reply in answers:
                if reply.has_failed():
                    for err in reply.get_err_stack():
                        self.logger.error("device {}: {}-{}".format(reply.dev_name(), err.desc, err.reason))
                else:
                    (result_code,msg) = reply.get_data()
                    self.logger.error("device {}: {}".format(reply.dev_name(), msg))
            if any(target_device._sc_subarray_obs_state[device]== ObsState.FAULT for device in  device_list):
                return (ResultCode.FAILED, "GoToIdle Command FAILED")
            return (ResultCode.OK, "GoToIdle command executed OK")

    # PROTECTED REGION ID(CspSubarray.class_variable) ENABLED START #
    # PROTECTED REGION END #    //  CspSubarray.class_variable
@@ -1297,9 +1329,7 @@ class CspSubarray(SKASubarray):
                    msg += " Desc: {}".format(evt.errors[0].desc)
                    self.logger.info(msg)
                    self._sc_subarray_cmd_exec_state[evt.device.dev_name()][evt.cmd_name.lower()] = CmdExecState.FAILED
                    self.logger.info("2")
                    self._failure_message[evt.cmd_name.lower()] += msg
                    self.logger.info("3")
                    # obsState and obsMode values take on the CbfSubarray's values via
                    # the subscribe/publish mechanism
            else:
@@ -1339,7 +1369,6 @@ class CspSubarray(SKASubarray):
        if self._sc_subarray_state[self.CbfSubarray] == DevState.OFF:
            if self._sc_subarray_obs_state[self.CbfSubarray] == ObsState.EMPTY:
                self.off_cmd_obj.succeeded()
                self.logger.info("state: {} status {}".format(self.get_state(), self.get_status()))
        if self._sc_subarray_state[self.CbfSubarray] == DevState.ON:
            if self._sc_subarray_obs_state[self.CbfSubarray] == ObsState.EMPTY:
                self.on_cmd_obj.succeeded()
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
"""Release information for Python Package"""

name = """csp-lmc-common"""
version = "0.6.3"
version = "0.6.4"
version_info = version.split(".")
description = """SKA CSP.LMC Common Software"""
author = "INAF-OAA"
+3 −3
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
"""Release information for Python Package"""

name = """csplmc-common"""
version = "0.6.3"
version = "0.6.4"
version_info = version.split(".")
description = """SKA CSP.LMC Common Classe"""
author = "E.G"
@@ -18,5 +18,5 @@ license = """BSD-3-Clause"""
url = """www.tango-controls.org"""
copyright = """"""

release=0.6.3
tag=csp-lmc-common-0.6.3
release=0.6.4
tag=csp-lmc-common-0.6.4
+6 −0
Original line number Diff line number Diff line
0.6.4:
- use csp-lmc-common version 0.6.4
- Receptor class uses the assignedReceptors attribute (exported by the MidCspSubarray) 
  to get the number of assigned receptors. No more use of receptorMembership: this value sometimes
  has some delays due to the use of events to build it

0.6.3
- use ska-python-buildenv and runtime 9.3.2
- use csp-lmc-common version 0.6.3
Loading