Commit 3f01bac0 authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

Set Subarray state to CONFIGURING as soon as the Configure command is

in execution.
Modified __configure_scan thread to catch the CbfSubarray CONFIGURING
obsState.
Update csp-lmc-common release number and HISTORY.
Updated Mid CspSubarray tests and configuration file.
parent d8fe602a
Loading
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
0.5.12

- push event on obsState
- set subarray to CONFIGURING at Configure command reception
- modified __configure_scan thread to catch the CbfSubarray CONFIGURING
  obsState 

0.5.11
- call to DeviceProxy instead of tango.DeviceProxy to have the deviceemocking works
  properly
+34 −35
Original line number Diff line number Diff line
@@ -492,6 +492,10 @@ class CspSubarray(SKASubarray):
            return True
        return False
    
    def _push_event_on_obs_state(self,value):
        self._obs_state = value
        self.push_change_event("obsState", self._obs_state)
    
    # ----------------
    # Class private methods
    # ----------------
@@ -604,7 +608,6 @@ class CspSubarray(SKASubarray):
        device_done = defaultdict(lambda:False)
        # inside the end-less lop check the obsState of each sub-component
        device_list = input_arg[0]
        self.logger.info("device_list:{}".format(device_list))
        while True:
            command_progress = 0
            for device in device_list:
@@ -615,22 +618,8 @@ 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 self._sc_subarray_obs_state[device] == dev_successful_state:
                    # !!! bad hack:
                    # if the sub-element subarray state is already READY, sleep for a while to wait
                    # sub-element moves  to CONFIGURING.
                    # TODO:
                    # - wait for all sub-elements subarrays move to CONFIGURING, handling possible
                    #   error/timeout conditions
                    # - when in CONFIGURING, wait for sub-elements subarrays to move to READY
                    #   handling error conditions

                    # check the time elapsed from the command start, if less then 0.1 sleep for a while
                    elapsed_time = time.time() - self._sc_subarray_cmd_starting_time[device]
                    if elapsed_time < 0.1:
                        self.logger.info("Device {} already in READY state after {} sec".format(device,
                                         elapsed_time))
                        time.sleep(0.3)
                        continue
                    self.logger.info("Reconfiguring is:{}".format(self._reconfiguring))
                    if not self._reconfiguring:
                        self.logger.info("Command {} ended with success on device {}.".format(cmd_name,
                                                                                                  device))
                        # update the list and number of device that completed the task
@@ -672,8 +661,10 @@ class CspSubarray(SKASubarray):
                self.logger.debug("Command {} on device {} exec_state {}:".format(cmd_name,device,
                                                                   self._sc_subarray_cmd_exec_state[device][cmd_name]))
            self._cmd_progress[cmd_name] = command_progress
            if all(self._sc_subarray_obs_state[device] == ObsState.CONFIGURING for device in device_list):
                self._obs_state = ObsState.CONFIGURING
            if any(self._sc_subarray_obs_state[device] == ObsState.CONFIGURING for device in device_list):
                #self._obs_state = ObsState.CONFIGURING
                self._reconfiguring = False
                self.logger.info("Reconfiguring is:{}".format(self._reconfiguring))
                self.logger.info("Current CspSubarray ObsState:{}".format(self._obs_state))
            if all(value == True for value in device_done.values()):
                self.logger.info("All devices have been handled!")
@@ -690,7 +681,7 @@ class CspSubarray(SKASubarray):
                break
            # TODO:
            # check for abort request.
            time.sleep(0.2)
            time.sleep(0.1)
        # end of the while loop
        # check for timeout/failure conditions on each sub-component
        for device in device_list:
@@ -704,18 +695,18 @@ class CspSubarray(SKASubarray):
        if self._timeout_expired or self._failure_raised:
            # if failure/timeout found check if the CBF subarray is configured. In
            # this case the CSP.LMC Subarray obsState is set to READY.
            if self._sc_subarray_obs_state[self.CbfSubarray] == ObsState.READY:
                self._obs_state = ObsState.READY
            self._push_event_on_obs_state(self._sc_subarray_obs_state[self.CbfSubarray])
            #TODO:
            # else:...
            # self.set_state(tango.DevState.FAULT)
            # 

        if all(self._sc_subarray_obs_state[fqdn] == dev_successful_state for fqdn in device_list):
            self._obs_state = dev_successful_state
            self._push_event_on_obs_state(ObsState.READY)
            self._valid_scan_configuration = input_arg[1]
            self._cmd_duration_measured[cmd_name] = time.time() - command_start_time
            self._cmd_progress[cmd_name] = 100
        else:
            self._push_event_on_obs_state(ObsState.IDLE)
        self._last_executed_command = cmd_name
        self.logger.info("CspSubarray failure flag:{}".format(self._failure_raised))
        self.logger.info("CspSubarray timeout flag:{}".format(self._timeout_expired))
@@ -1283,6 +1274,8 @@ class CspSubarray(SKASubarray):
        self._config_delay_expected = 10
        self._scan_id = 0
        self._configuration_id = ''
        # flag to signal if we have a recofniguraiton
        self._reconfiguring = False
        # connect to TANGO DB
        
        # use defaultdict to initialize the sub-element State,healthState
@@ -2073,6 +2066,9 @@ class CspSubarray(SKASubarray):
                                         msg,
                                         "Configure",
                                         tango.ErrSeverity.ERR)
        self._reconfiguring = False
        if self._obs_state == ObsState.READY:
            self._reconfiguring = True
        # Forward the Configure command to the sub-elements
        # components (subarrays, pst beams)
        for device in self._sc_subarray_assigned_fqdn:
@@ -2126,10 +2122,13 @@ class CspSubarray(SKASubarray):
                # Note: check if callaback executed...
                if self._sc_subarray_cmd_exec_state[device]['configurescan'] != CmdExecState.FAILED:
                    self._sc_subarray_cmd_exec_state[device]['configurescan'] = CmdExecState.RUNNING
                    self._push_event_on_obs_state(ObsState.CONFIGURING)
            except tango.DevFailed as tango_err:
                if device == self.CbfSubarray:
                    msg = "Failure in configuring CBF: {}".format(tango_err.args[0].desc)
                    # throw the exception, configuration can't proceed
                    self._obs_state = ObsState.IDLE
                    self.push_change_event("obsState", self._obs_state)
                    tango.Except.throw_exception("Command failed",
                                                 msg,
                                                 "Configure",
+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.5.11"
version = "0.5.12"
version_info = version.split(".")
description = """SKA CSP.LMC Common Software"""
author = "INAF-OAA"
+2 −2
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@
"""Release information for Python Package"""

name = """csplmc-common"""
version = "0.5.11"
version = "0.5.12"
version_info = version.split(".")
description = """SKA CSP.LMC Common Classe"""
author = "E.G"
@@ -19,4 +19,4 @@ url = """www.tango-controls.org"""
copyright = """"""

release=0.5.11
tag=csp-lmc-common-0.5.11
tag=csp-lmc-common-0.5.12
+9 −9
Original line number Diff line number Diff line
@@ -288,7 +288,7 @@
                                "mid_csp_cbf/pssconfig/02"
                            ],
                            "CorrConfigAddress": [
                                "mid_csp_cbf/corrconfig/01"
                                "mid_csp_cbf/corrconfig/02"
                            ],
                            "SubID": [
                                "2"
@@ -435,7 +435,7 @@
                                "state",
                                "1000",
                                "subarraymembership",
                                "1000"
                                "200"
                            ]
                        }
                    }
@@ -600,7 +600,7 @@
                                "state",
                                "1000",
                                "subarraymembership",
                                "1000"
                                "200"
                            ]
                        }
                    }
@@ -765,7 +765,7 @@
                                "state",
                                "1000",
                                "subarraymembership",
                                "1000"
                                "200"
                            ]
                        }
                    }
@@ -930,7 +930,7 @@
                                "state",
                                "1000",
                                "subarraymembership",
                                "1000"
                                "200"
                            ]
                        }
                    }
@@ -1109,7 +1109,7 @@
                                "adminmode",
                                "1000",
                                "subarraymembership",
                                "1000"
                                "200"
                            ]
                        }
                    }
@@ -1184,7 +1184,7 @@
                                "adminmode",
                                "1000",
                                "subarraymembership",
                                "1000"
                                "200"
                            ]
                        }
                    }
@@ -1259,7 +1259,7 @@
                                "adminmode",
                                "1000",
                                "subarraymembership",
                                "1000"
                                "200"
                            ]
                        }
                    }
@@ -1334,7 +1334,7 @@
                                "adminmode",
                                "1000",
                                "subarraymembership",
                                "1000"
                                "200"
                            ]
                        }
                    }
Loading