Commit 16e72889 authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

AT5-262: Change to command progress counter: now it work properly.

Removed availableCapabilities from CSP.LMC Common interface
(to overload in MID/LOW instances).
parent 3ca96847
Loading
Loading
Loading
Loading
+25 −43
Original line number Diff line number Diff line
@@ -405,8 +405,6 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):

        Check if a TANGO device is exported in the TANGO DB (i.e its TANGO 
        device server is running).
        If the device is not in the list of proxies a DeviceProxy on
        the device is performed.
        
        :param: device_fqdn : the FQDN of the sub-element
        :type: `DevString`
@@ -415,23 +413,19 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
        :return: True if the connection with the subarray is established,
                False otherwise
        """
        print(proxy_list)
        if proxy_list:
        if not proxy_list:
            return False
        try:
            proxy = proxy_list[device_fqdn]
                # execute a ping to detect if the device is actually running
            # ping the device to control if is alive
            proxy.ping()
                return True
        except KeyError as key_err:
            # Raised when a mapping (dictionary) key is not found in the set
            # of existing keys.
            # no proxy registered for the subelement device
            msg = "Can't retrieve the information of key {}".format(key_err)
            self.dev_logging(msg, tango.LogLevel.LOG_ERROR)
        try: 
            proxy = tango.DeviceProxy(device_fqdn)
            proxy.ping()
            proxy_list[device_fqdn] = proxy
            return False
        except tango.DevFailed:
            return False
        return True
@@ -487,6 +481,7 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
            # set the sub-element command execution flag
            self._se_cmd_execution_state[device][cmd_name] = CmdExecState.RUNNING
            se_cmd_duration_measured[device][cmd_name] = 0
            self._se_cmd_progress[device][cmd_name] = 0
            self._alarm_message[cmd_name] = ''
            try:
                device_proxy = self._se_proxies[device] 
@@ -507,6 +502,7 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
                self._se_cmd_starting_time[device] = time.time() 
                # loop on the device until the State changes to ON or a timeout occurred
                print("Device {} State {} expected value {}".format(device, self._se_state[device], dev_successful_state))
                command_progress = self._cmd_progress[cmd_name]
                while True:
                    if self._se_state[device] == dev_successful_state:
                        print("Command {} ended with success on device {}.".format(cmd_name, 
@@ -587,10 +583,10 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
                    time.sleep(1)
                    # update the progress counter inside the loop taking into account the number of devices
                    # executing the command
                    self._cmd_progress[cmd_name] += self._se_cmd_progress[device][cmd_name]/len(device_list)
                    self._cmd_progress[cmd_name] = command_progress + self._se_cmd_progress[device][cmd_name]/len(device_list)
                # end of the while loop
                # update the progress counter at the end of the loop 
                self._cmd_progress[cmd_name] += self._se_cmd_progress[device][cmd_name]/len(device_list)
                self._cmd_progress[cmd_name] = command_progress + (self._se_cmd_progress[device][cmd_name]/len(device_list))
                if len(device_list) ==  self._num_dev_completed_task[cmd_name] + num_of_failed_device:
                    print("All devices have been handled!")
                    # end of the command: the command has been issued on all the sub-element devices
@@ -655,10 +651,10 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
        """
        """
        # build the list with the Capability monitor devices
        capability_monitor_device = [self.SearchBeamsMonitor,
        self._capability_fqdn = [self.SearchBeamsMonitor,
                                 self.TimingBeamsMonitor,
                                 self.VlbiBeamsMonitor]
        for fqdn in capability_monitor_device:
        for fqdn in self._capability_fqdn:
            self._capability_proxy[fqdn] = tango.DeviceProxy(fqdn)               
                
# PROTECTED REGION END #    //  CspMaster.class_protected_methods
@@ -992,13 +988,6 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
        doc="Alarm message when the Standby command fails with error(s).",
    )

    availableCapabilities = attribute(
        dtype=('DevString',),
        max_dim_x=20,
        doc=("A list of available number of instances of each capability type, e.g."
             " `CORRELATOR:512`, `PSS-BEAMS:4`."),
    )

    reportSearchBeamState = attribute(
        dtype=('DevState',),
        max_dim_x=1500,
@@ -1430,9 +1419,6 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
        # clear any list and dict
        self._se_fqdn.clear()
        self._se_proxies.clear()
        self._search_beam_membership.clear()
        self._timing_beam_membership.clear()
        self._vlbi_beam_membership.clear()
        # PROTECTED REGION END #    //  CspMaster.delete_device
    # ------------------
    # Attributes methods
@@ -1713,12 +1699,6 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
        return self._alarm_message['standby']
        # PROTECTED REGION END #    //  CspMaster.standbyAlarmMessage_read

    def read_availableCapabilities(self):
        # PROTECTED REGION ID(CspMaster.availableCapabilities_read) ENABLED START #
        """Return the availableCapabilities attribute."""
        return ('',)
        # PROTECTED REGION END #    //  CspMaster.availableCapabilities_read

    def read_cspSubarrayAddresses(self):
        # PROTECTED REGION ID(CspMaster.cspSubarrayAddresses_read) ENABLED START #
        """Return the cspSubarrayAddresses attribute."""
@@ -1801,6 +1781,7 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
        # are passed as arguments of the function
        # args: the list of sub-element FQDNS
        # args_dict: dictionary with the specific command information
        print("Send command to device", device_list)
        args_dict = {'cmd_name':'On', 'attr_name': 'onCommandProgress', 'dev_state': tango.DevState.ON}
        self._command_thread['on'] = threading.Thread(target=self._issue_power_command, name="Thread-On",
                                               args=(device_list,),
@@ -1808,6 +1789,7 @@ class CspMaster(with_metaclass(DeviceMeta, SKAMaster)):
        # set the  CSP command execution running flag
        self._cmd_execution_state['on'] = CmdExecState.RUNNING
        # start the thread
        print("starting thread")
        self._command_thread['on'].start()
        # sleep for a while to let the thread start
        time.sleep(0.2)
+3 −2
Original line number Diff line number Diff line
@@ -544,11 +544,12 @@
      <status abstract="false" inherited="true" concrete="true"/>
      <properties description="Maximum number of instances of each capability type, e.g. 'CORRELATOR:512', 'PSS-BEAMS:4'." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
    </attributes>
    <attributes name="availableCapabilities" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="20" maxY="" allocReadMember="true">
    <attributes name="availableCapabilities" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="20" maxY="" allocReadMember="true" isDynamic="false">
      <dataType xsi:type="pogoDsl:StringType"/>
      <changeEvent fire="false" libCheckCriteria="false"/>
      <archiveEvent fire="false" libCheckCriteria="false"/>
      <status abstract="false" inherited="true" concrete="true" concreteHere="true"/>
      <dataReadyEvent fire="false" libCheckCriteria="true"/>
      <status abstract="false" inherited="true" concrete="true" concreteHere="false"/>
      <properties description="A list of available number of instances of each capability type, e.g. `CORRELATOR:512`, `PSS-BEAMS:4`." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
    </attributes>
    <attributes name="cspSubarrayAddresses" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="16" maxY="" allocReadMember="true" isDynamic="false">