Commit 363ef97f authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

CT-69: Check the inprogress command attribute after issuing a long-running command

to check for command failure.
Added some debug printing.
Validation of json confiuration ID done in subarray common class.
parent a9ae8f69
Loading
Loading
Loading
Loading
+32 −14
Original line number Diff line number Diff line
@@ -66,7 +66,22 @@ class MidCspSubarrayBase(CspSubarray):
    # PROTECTED REGION ID(MidCspSubarrayBase.class_variable) ENABLED START #
    # PROTECTED REGION END #    //  MidCspSubarrayBase.class_variable
    # PROTECTED REGION ID(MidCspSubarrayBase.private_methods) ENABLED START #
    def __monitor_add_receptors(self, receptor_list, args_dict=None):
    def _get_cbfsubarray_assigned_receptors(self, device_proxy):
        """

        :param device_proxy: DeviceProxy of the CBF Sub-element subarray
        :return: the list of receptors Id on success, otherwise []
        """
        receptors = []
        try:
            # Note: with numpy support in PyTango, receptors is a
            # numpy array
            receptors = device_proxy.receptors
        except tango.DevFailed as tango_err:
            self.logger.warning("__monitor_add_receptors:{}".format(tango_err.args[0].desc))
        return receptors

    def __monitor_add_receptors(self, receptors_to_be_added, args_dict=None):
        cmd_name = 'addreceptors'
        device = self.CbfSubarray
        self._num_dev_completed_task[cmd_name] = 0
@@ -77,21 +92,16 @@ class MidCspSubarrayBase(CspSubarray):
        self._sc_subarray_cmd_progress[device][cmd_name] = 0
        self._failure_message[cmd_name] = ''
        device_proxy = self._sc_subarray_proxies[device]
        self.logger.info("Going to assign receptors {}".format(receptor_list))
        self.logger.info("Going to assign receptors {}".format(receptors_to_be_added))

        while True:
            # read the list of receptor IDs assigned to the CbfSubarray
            try:
                # Note: with numpy support in PyTango, receptors is a
                # numpy array
                receptors = device_proxy.receptors
            except tango.DevFailed as tango_err:
                self.logger.warning("__monitor_add_receptors:{}".format(tango_err.args[0].desc))
            receptors = self._get_cbfsubarray_assigned_receptors(device_proxy)
            if len(receptors):
                # get the ids in receptor_list that are also in receptor
                receptors_assigned = [value for value in receptor_list if value in receptors]
                receptors_assigned = [value for value in receptors_to_be_added if value in receptors]
                self._num_dev_completed_task[cmd_name] = len(receptors_assigned)
                if (len(receptors_assigned) == len(receptor_list)) and (self.get_state() == tango.DevState.ON):
                if (len(receptors_assigned) == len(receptors_to_be_added)) and (self.get_state() == tango.DevState.ON):
                    self.logger.info("All required receptors assigned!!")
                    self._sc_subarray_cmd_progress[device][cmd_name] = 100
                    # calculate the real execution time for the command
@@ -128,9 +138,12 @@ class MidCspSubarrayBase(CspSubarray):
            self.logger.warning(msg)
        if self._sc_subarray_cmd_exec_state[device][cmd_name] == CmdExecState.TIMEOUT:
            self._timeout_expired = True
        self.logger.info("CspSubarray failure flag:{}".format(self._failure_raised))
        self.logger.info("CspSubarray timeout flag:{}".format(self._timeout_expired))
        # reset the command execution state
        self._sc_subarray_cmd_exec_state[device][cmd_name] = CmdExecState.IDLE
        self._cmd_execution_state[cmd_name] = CmdExecState.IDLE

     # PROTECTED REGION END #    //  MidCspSubarrayBase.private_methods

    def __monitor_remove_receptors(self, receptor_list, args_dict=None):
@@ -200,11 +213,13 @@ class MidCspSubarrayBase(CspSubarray):
            self._failure_raised = True
        if self._sc_subarray_cmd_exec_state[device][cmd_name] == CmdExecState.TIMEOUT:
            self._timeout_expired = True
        self.logger.info("CspSubarray failure flag:{}".format(self._failure_raised))
        self.logger.info("CspSubarray timeout flag:{}".format(self._timeout_expired))
        # reset the command exeuction state
        self._sc_subarray_cmd_exec_state[device][cmd_name] = CmdExecState.IDLE
        self._cmd_execution_state[cmd_name] = CmdExecState.IDLE

    def _validate_scan_configuration(self, argin):
    def validate_scan_configuration(self, argin):
        """
        Overwritten method.
        Validate the MID scan configuration file.
@@ -255,6 +270,7 @@ class MidCspSubarrayBase(CspSubarray):
        self._sc_subarray_assigned_fqdn.clear()
        json_dict = {}
        try:
            CspSubarray.validate_scan_configuration(self, argin)
            json_dict = json.loads(argin)
        except json.JSONDecodeError as e:  # argument not a valid JSON object
            # this is a fatal error
@@ -600,6 +616,7 @@ class MidCspSubarrayBase(CspSubarray):
                                                                    name="Thread-AddReceptors",
                                                                    args=(receptor_to_assign,))
            self._sc_subarray_cmd_starting_time[self.CbfSubarray] = time.time()
            if self._cmd_execution_state['addreceptors'] != CmdExecState.FAILED:
                self._cmd_execution_state['addreceptors'] = CmdExecState.RUNNING
            self._command_thread['addreceptors'].start()
        except tango.DevFailed as tango_err:
@@ -683,6 +700,7 @@ class MidCspSubarrayBase(CspSubarray):
                            self.logger.info(tango_err.args[0].desc)
                    # forward the command to CbfSubarray
                    proxy.command_inout_asynch("RemoveReceptors", receptors_to_remove, self._cmd_ended_cb)
                    if self._cmd_execution_state['removereceptors'] != CmdExecState.FAILED:
                        self._cmd_execution_state['removereceptors'] = CmdExecState.RUNNING
                    self._sc_subarray_cmd_starting_time[self.CbfSubarray] = time.time()
                    # Note: rembember to put the comma in args=(receptors_to_remove,) otherwise
+26 −4
Original line number Diff line number Diff line
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
  <classes name="MidCspSubarrayBase" pogoRevision="9.6">
    <description description="The base class for MID CspSubarray.&#xA;Fuctionality to monitor assigned CSP.LMC Capabilities,&#xA;as well as inherent Capabilities, are implemented in &#xA;separate TANGO Devices." title="MidCspSubarrayBase" sourcePath="/home/softir/src/ska-git/csp-lmc/csp-lmc-mid/pogo" language="PythonHL" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="INAF, SKA Telescope" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false">
    <description description="The base class for MID CspSubarray.&#xA;Fuctionality to monitor assigned CSP.LMC Capabilities,&#xA;as well as inherent Capabilities, are implemented in &#xA;separate TANGO Devices." title="MidCspSubarrayBase" sourcePath="/home/softir/ska-git/csp-lmc/csp-lmc-mid/pogo" language="PythonHL" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="INAF, SKA Telescope" hasMandatoryProperty="false" hasConcreteProperty="false" hasAbstractCommand="false" hasAbstractAttribute="false">
      <inheritances classname="Device_Impl" sourcePath=""/>
      <inheritances classname="SKAObsDevice" sourcePath="../../../lmc-base-classes/skabase/SKAObsDevice"/>
      <inheritances classname="SKASubarray" sourcePath="/home/softir/src/ska-git/lmc-base-classes/skabase/SKASubarray"/>
      <inheritances classname="CspSubarray" sourcePath="/home/softir/src/ska-git/csp-lmc/csp-lmc-common/pogo"/>
      <inheritances classname="SKAObsDevice" sourcePath="../../../lmc-base-classes/pogo"/>
      <inheritances classname="SKASubarray" sourcePath="/home/softir/ska-git/lmc-base-classes/pogo"/>
      <inheritances classname="CspSubarray" sourcePath="/home/softir/ska-git/csp-lmc/csp-lmc-common/pogo"/>
      <identification contact="at inaf.it - elisabetta.giani" author="elisabetta.giani" emailDomain="inaf.it" classFamily="SKA CSP" siteSpecific="" platform="All Platforms" bus="Not Applicable" manufacturer="INAF" reference=""/>
    </description>
    <classProperties name="PSTBeams" description="PST sub-element PSTBeams TANGO devices FQDNs">
@@ -715,6 +715,28 @@
      <status abstract="false" inherited="true" concrete="true"/>
      <properties description="The failure message on command execution" label="The failure message" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
    </attributes>
    <attributes name="goToIdleCmdProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1500" maxX="" maxY="" allocReadMember="true">
      <dataType xsi:type="pogoDsl:UShortType"/>
      <changeEvent fire="false" libCheckCriteria="false"/>
      <archiveEvent fire="false" libCheckCriteria="false"/>
      <status abstract="false" inherited="true" concrete="true"/>
      <properties description="The progress percentage for the EndSB command." label="EndSB command progress percentage" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
      <eventCriteria relChange="" absChange="5" period=""/>
    </attributes>
    <attributes name="isCmdInProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true">
      <dataType xsi:type="pogoDsl:EnumType"/>
      <changeEvent fire="false" libCheckCriteria="false"/>
      <archiveEvent fire="false" libCheckCriteria="false"/>
      <status abstract="false" inherited="true" concrete="true"/>
      <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
    </attributes>
    <attributes name="configurationID" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true">
      <dataType xsi:type="pogoDsl:StringType"/>
      <changeEvent fire="false" libCheckCriteria="false"/>
      <archiveEvent fire="false" libCheckCriteria="false"/>
      <status abstract="false" inherited="true" concrete="true"/>
      <properties description="The configuration identifier (string)" label="Configuration ID" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
    </attributes>
    <attributes name="assignedResources" attType="Spectrum" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="100" maxY="" allocReadMember="true">
      <dataType xsi:type="pogoDsl:StringType"/>
      <changeEvent fire="false" libCheckCriteria="false"/>