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

Removed a bug in power command execution.

Removed some typos.
Updated history and release files.
parent e2a535cf
Loading
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
0.5.6

- set the exec flag before the thread start
- re-enable the cmd_ended_cb callback registration with
  the asynchronous commands
- configure thread lock to access commad execution flag
- removed some typos
- more logs

0.5.5

- reduced the sleep time inside monitoring threads in CspMaster.py and CspSubarray.py
+1 −1
Original line number Diff line number Diff line
@@ -276,7 +276,7 @@ class CspCapabilityMonitor(SKABaseDevice):
                    self._event_id.pop(fqdn)
            except KeyError as key_err:
                msg = " Can't retrieve the information of key {}".format(key_err)
                self.loggerr.error(msg)
                self.logger.error(msg)
            
        self._capability_fqdn.clear()
        self._capability_state.clear()
+30 −20
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ from tango import AttrWriteType, DeviceProxy
#
from ska.base import SKAMaster
from ska.base import utils
from ska.base.control_model import HealthState, AdminMode, ObsState
from ska.base.control_model import HealthState, AdminMode, ObsState, LoggingLevel
from .utils.decorators import AdminModeCheck, CmdInputArgsCheck
from .utils.cspcommons import CmdExecState
from . import release
@@ -289,11 +289,11 @@ class CspMaster(SKAMaster):
        """
        self._update_csp_health_state()
        if all(value == CmdExecState.IDLE for value in self._cmd_execution_state.values()) or (not any(self._cmd_execution_state)):
            self.logger.debug("_update_csp_state: _cmd_execution_state:{}".format(self._cmd_execution_state))
            self.logger.debug("_cmd_execution_state:{}".format(self._cmd_execution_state.items()))
            self.set_state(self._se_state[self.CspCbf])
        if self._admin_mode in [AdminMode.OFFLINE, AdminMode.NOT_FITTED, AdminMode.RESERVED]:
            self.set_state(tango.DevState.DISABLE)
        self.logger.debug("_update_csp_state: CspState: {}".format(self.get_state()))
        self.logger.debug("CspState: {}".format(self.get_state()))

    def _update_csp_health_state(self):
        """
@@ -488,8 +488,7 @@ class CspMaster(SKAMaster):
                # IDLE and the thread exit. After it is received the callback message with the
                # error message generated by the CbfMaster but the 
                # self._cmd_execution_state results RUNNING and the device stucks 
                #device_proxy.command_inout_asynch(tango_cmd_name, self._cmd_ended_cb)
                device_proxy.command_inout_asynch(tango_cmd_name)
                device_proxy.command_inout_asynch(tango_cmd_name, self._cmd_ended_cb)
            except tango.DevFailed as df:
                # It should not happen! Verify
                msg = "Failure reason: {} Desc: {}".format(str(df.args[0].reason), str(df.args[0].desc))
@@ -565,8 +564,8 @@ class CspMaster(SKAMaster):
                                          "execution!!! Exit".format(cmd_name))
                        self._timeout_expired[cmd_name] = True
                        self._se_cmd_execution_state[device][cmd_name] = CmdExecState.IDLE
                        with self._cmd_exec_state_lock:
                            self._cmd_execution_state[cmd_name] = CmdExecState.IDLE
                        self.logger.info("self._cmd_execution_state:{}".format(self._cmd_execution_state))
                        return
                    # timeout on the sub-element, skip to the next device
                    break
@@ -602,11 +601,10 @@ class CspMaster(SKAMaster):
            # reset the CSP sub-element command execution flag
            self._se_cmd_execution_state[device][cmd_name] = CmdExecState.IDLE
        # reset the CSP command execution flag

        with self._cmd_exec_state_lock:
            self._cmd_execution_state[cmd_name] = CmdExecState.IDLE
        self.logger.debug("__issue_power command end _cmd_execution_state:{}".format(self._cmd_execution_state))
        self._update_csp_state()
    
        self.logger.info("CSP State:{}".format(self.get_state()))
    def _se_write_adminMode(self, value, device_fqdn):
        """
        *Class method.*
@@ -1276,6 +1274,10 @@ class CspMaster(SKAMaster):
        # values: thread instance
        self._command_thread = {}

        # _cmd_exec_state_lock: lock to share the _cmd_execution_state
        # attribute among thread in a safe way
        self._cmd_exec_state_lock = threading.Lock()

        # _se_cmd_progress: for each sub-element report the execution progress 
        # of a long-running command
        # implemented as a default nested dictionary:
@@ -1784,15 +1786,18 @@ class CspMaster(SKAMaster):
                                               kwargs=args_dict)
        try:
            # start the thread
            self._command_thread['on'].start()
            # set the  CSP command execution running flag
            self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items()))
            with self._cmd_exec_state_lock:
                self._cmd_execution_state['on'] = CmdExecState.RUNNING
            self._command_thread['on'].start()
            self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items()))
            # sleep for a while to let the thread start
            time.sleep(0.2)
            #time.sleep(0.1)
        except Exception:
            # reset the sub-element command exec state
            self._se_cmd_execution_state.clear()
            self._cmd_execution_state['on'] = CmdExecState.IDLe
            self._cmd_execution_state['on'] = CmdExecState.IDLE
            tango.Except.throw_exception("Command failed",
                                         "Thread non started while executing On command",
                                         "On",
@@ -1867,12 +1872,13 @@ class CspMaster(SKAMaster):
                                                args=(device_list,),
                                                kwargs=args_dict)
        try:
            # start the thread
            self._command_thread['off'].start()
            # set the  CSP command execution running flag
            with self._cmd_exec_state_lock:
                self._cmd_execution_state['off'] = CmdExecState.RUNNING
            # start the thread
            self._command_thread['off'].start()
            # sleep for a while to let the thread start
            time.sleep(0.2)
            #time.sleep(0.1)
        except Exception:
            # reset the sub-element command exec state
            self._se_cmd_execution_state.clear()
@@ -1948,11 +1954,15 @@ class CspMaster(SKAMaster):
                                                           args=(device_list,),
                                                           kwargs=args_dict)
        try:
            # set the  CSP command execution running flag
            self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items()))
            with self._cmd_exec_state_lock:
                self._cmd_execution_state['standby'] = CmdExecState.RUNNING
            # start the thread
            self._command_thread['standby'].start()
            self._cmd_execution_state['standby'] = CmdExecState.RUNNING
            self.logger.debug("self._cmd_execution_state: {}".format(self._cmd_execution_state.items()))
            # sleep for a while to let the thread start
            time.sleep(0.2)
            #time.sleep(0.1)
        except Exception:
            # reset the sub-element command exec state
            self._se_cmd_execution_state.clear()
+7 −2
Original line number Diff line number Diff line
@@ -367,6 +367,7 @@ class CspSubarray(SKASubarray):
                self._obs_state = self._sc_subarray_obs_state[self.CbfSubarray]
                self.logger.info("All sub-array sub-component are IDLE."
                                  "Subarray obsState:{}".format( self._obs_state))
        self.logger.info("Subarray ObsState:{}".format( self._obs_state))
                
    def _connect_to_subarray_subcomponent(self, fqdn):
        """
@@ -603,9 +604,10 @@ class CspSubarray(SKASubarray):
        # flag to signal when configuration ends on a sub-array sub-component
        device_done = defaultdict(lambda:False)
        # inside the end-less lop check the obsState of each sub-component
        self.logger.info("device_list:{}".format(device_list))
        while True:
            for device in device_list:
                self.logger.debug("Command {} obs_state: {}".format(cmd_name,
                self.logger.info("Command {} obs_state: {}".format(cmd_name,
                                                                 self._sc_subarray_obs_state[device]))
                if device_done[device] == True:
                    continue
@@ -652,10 +654,12 @@ class CspSubarray(SKASubarray):
                # update the progress counter inside the loop taking into account the number of devices
                # executing the command
                self._cmd_progress[cmd_name] = command_progress+ self._sc_subarray_cmd_progress[device][cmd_name]/len(device_list)
                self.logger.debug("Command {} on device {} obsState {}:".format(cmd_name,device,
                self.logger.info("Command {} on device {} exec_state {}:".format(cmd_name,device,
                                                                   self._sc_subarray_cmd_exec_state[device][cmd_name]))
            self.logger.info("self._sc_subarray_obs_state {}".format(self._sc_subarray_obs_state))
            if all(self._sc_subarray_obs_state[device] == ObsState.CONFIGURING for device in device_list):
                self._obs_state = ObsState.CONFIGURING
                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!")
                #if (all(self._sc_subarray_obs_state[device] == ObsState.READY for device in device_list)):
@@ -680,6 +684,7 @@ class CspSubarray(SKASubarray):
        self._last_executed_command = cmd_name
        # reset the CSP Subarray command execution flag
        self._cmd_execution_state[cmd_name] = CmdExecState.IDLE
        self.logger.info("CspSubarray ObsState:{}".format(self._obs_state))

    def __gotoidle(self, device_list, **args_dict):
        """
+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.5"
version = "0.5.6"
version_info = version.split(".")
description = """SKA CSP.LMC Common Software"""
author = "INAF-OAA"
Loading