Commit 0f78a01e authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

AT5-262: renamed device proeprty and attributes for inherent capabilities.

Implemented ConfigureScan method and obsState update.
Implemented decorator to reject configuring during add/remove resources operations.
Implemented is_XXX_allowed methods for all TANGO methods.
parent dea603fc
Loading
Loading
Loading
Loading
+376 −247

File changed.

Preview size limit exceeded, changes collapsed.

+61 −15
Original line number Diff line number Diff line
@@ -47,10 +47,10 @@ VALID_OBS_STATE = {'abort' : [ObsState.CONFIGURING, ObsState.SCANNING],
                   'scan'       : [ObsState.READY],
                   'endscan'    : [ObsState.SCANNING],
                   'endsb'      : [ObsState.READY, ObsState.IDLE],
                   'addbeam'    : [ObsState.IDLE],
                   'removebeam' : [ObsState.IDLE]
                   'addresources'    : [ObsState.IDLE],
                   'removeresources' : [ObsState.IDLE]
                   }
class StateAndObsStateCheck(object):
class ObsStateCheck(object):
    """
    Class designed to be a decorator for the CspMaster methods.
    It checks the obsMode attribute value
@@ -63,20 +63,12 @@ class StateAndObsStateCheck(object):
        def obs_state_check(*args, **kwargs):
            # get the  device instance
            dev_instance = args[0]
            cmd_to_execute = self._args
            # check if the sub-array State is On, otherwise throws an exception
            if dev_instance.get_state() != tango.DevState.ON:
                msg_args = (cmd_to_execute, dev_instance.get_state())
                err_msg = ("{} command can't be issued when the"
                       " State is {} ".format(*msg_args))
                tango.Except.throw_exception("Command not executable",
                                         err_msg,
                                         "StateAndObsStateCheck decorator",
                                         tango.ErrSeverity.ERR)
            cmd_type = self._args
            
            # Check the obsState attribute value: valid values for the command to
            # execute are defined by VALID_OBS_STATE dictionary
            if dev_instance._obs_state in VALID_OBS_STATE[cmd_to_execute.lower()]:
                msg_args = (cmd_to_execute, ObsState(dev_instance._obs_state).name)
            if dev_instance._obs_state not in VALID_OBS_STATE[cmd_type]:
                msg_args = (f.__name__, ObsState(dev_instance._obs_state).name)
                err_msg = ("{} command can't be issued when the"
                       " obsState is {} ".format(*msg_args))
            
@@ -249,3 +241,57 @@ class CmdInputArgsCheck(object):
            return f(*args, **kwargs)
        return input_args_check
            
class SubarrayRejectCmd(object):
    """
    Class designed to be a decorator for the CspSubarray methods.
    The *decorator function* control if the execution of a sub-array
    command to assign/remove resources conflicts with a command already
    running.
    The *decorator function* accepts some parameters as input to customize
    its functionality
    """
    def __init__(self, *args, **kwargs):
        # store the decorators parameters:
        # args: the list of command to reject
        #                      
        self._args = args
        self._kwargs = kwargs
        print(args)
    def __call__(self, f):
        @functools.wraps(f)
        def input_args_check(*args, **kwargs):
            # the CspSubarray device instance
            dev_instance = args[0]
            cmd_to_exec = f.__name__
            commands_to_reject = self._args
            dev_instance.logger.debug("SubarrayRejectCmd: function {}".format(f.__name__))
            # If a sub-array is executing an AddXXX (RemoveXX) command, an exception is
            # thown only when the requested command is RemoveXXX (AddXXX)remove/add resources or ConfigureScan.
            # If the requested command is already running, the decorator returns.
            
            list_of_running_cmd = [cmd_name for cmd_name, cmd_state in  dev_instance._cmd_execution_state.items()
                                   if cmd_state == CmdExecState.RUNNING]
            print(list_of_running_cmd)
            if cmd_to_exec.lower() in list_of_running_cmd:
                # the requested command is already running
                # return with no exception (see SKA Guidelines)
                msg = ("Command {} is already running".format(cmd_to_exec))
                dev_instance.logger.info(msg)
                return
            if any (cmd_name in commands_to_reject for cmd_name in list_of_running_cmd):
                err_msg = ("Can't execute command {}:"
                               " command {} is already running".format(cmd_to_exec, list_of_running_cmd))
                tango.Except.throw_exception("Command failure",
                                                err_msg,
                                                 "SubarrayRejectCmd decorator",
                                                 tango.ErrSeverity.ERR)
            # reset alarm/timeout condition
            if dev_instance._alarm_raised:
                dev_instance.logger.info("A previous alarm condition is present")
                dev_instance._alarm_raised = False
            if dev_instance._timeout_expired:   
                dev_instance.logger.info("A previous timeout condition is present")
                dev_instance._timeout_expired = False
            # TODO: how check if the alarm condition has been reset by AlarmHandler?
            return f(*args, **kwargs)
        return input_args_check
+15 −16
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="CspSubarray" pogoRevision="9.6">
    <description description="CSP subarray functionality is modeled via a TANGCSP.LMC Common Class for the CSPSubarray TANGO Device." title="CSP.LMC Common CspSubarray" sourcePath="/home/softir/src/ska-git/csp-lmc/csp-lmc-common/pogo" language="PythonHL" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="INAF - SKA Telescope" hasMandatoryProperty="false" hasConcreteProperty="true" hasAbstractCommand="false" hasAbstractAttribute="false">
    <description description="CSP subarray functionality is modeled via a TANGO CSP.LMC Common Class for the CSPSubarray TANGO Device." title="CSP.LMC Common CspSubarray" sourcePath="/home/softir/src/ska-git/csp-lmc/csp-lmc-common/pogo" language="PythonHL" filestogenerate="XMI   file,Code files,Protected Regions" license="GPL" copyright="INAF - SKA Telescope" hasMandatoryProperty="false" hasConcreteProperty="true" 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"/>
@@ -28,11 +28,6 @@
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="true" concrete="true"/>
    </deviceProperties>
    <deviceProperties name="CspMaster" description="The TANGO address of the CspMaster.">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
      <DefaultPropValue>mid_csp/elt/master</DefaultPropValue>
    </deviceProperties>
    <deviceProperties name="CbfSubarray" description="CBF sub-element sub-array TANGO device FQDN">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
@@ -41,19 +36,19 @@
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="CorrelationCapability" description="CSP Subarray *Correlation Inherent Capability*&#xA;TANGO device FQDN">
    <deviceProperties name="SubarrayProcModeCorrelation" description="CSP Subarray *Correlation Inherent Capability*&#xA;TANGO device FQDN">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="PssCapability" description="CSP Subarray *Pss Inherent Capability*&#xA;TANGO device FQDN">
    <deviceProperties name="SubarrayProcModePss" description="CSP Subarray *Pss Inherent Capability*&#xA;TANGO device FQDN">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="PstCapability" description="CSP Subarray *PST Inherent Capability*&#xA;TANGO device FQDN">
    <deviceProperties name="SubarrayProcModePst" description="CSP Subarray *PST Inherent Capability*&#xA;TANGO device FQDN">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <deviceProperties name="VlbiCapability" description="CSP Subarray *VLBI Inherent Capability*&#xA;TANGO device FQDN">
    <deviceProperties name="SubarrayProcModeVlbiCapability" description="CSP Subarray *VLBI Inherent Capability*&#xA;TANGO device FQDN">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
@@ -67,6 +62,10 @@
      <status abstract="false" inherited="true" concrete="true"/>
      <DefaultPropValue>console::cout</DefaultPropValue>
    </deviceProperties>
    <deviceProperties name="CspMaster" description="The TANGO address of the CspMaster.">
      <type xsi:type="pogoDsl:StringType"/>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </deviceProperties>
    <commands name="Abort" description="Change obsState to ABORTED." execMethod="abort" displayLevel="OPERATOR" polledPeriod="0">
      <argin description="">
        <type xsi:type="pogoDsl:VoidType"/>
@@ -247,7 +246,7 @@
      </argout>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </commands>
    <commands name="AddSearchBeamsID" description="Add the specified SeachBeam Capability IDs o the CSP &#xA;sub-array." execMethod="add_search_beams_id" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
    <commands name="AddSearchBeams" description="Add the specified SeachBeam Capability IDs o the CSP &#xA;sub-array." execMethod="add_search_beams" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
      <argin description="The list of SearchBeam Capability IDs to assign to the CSP sub-array.">
        <type xsi:type="pogoDsl:UShortArrayType"/>
      </argin>
@@ -256,7 +255,7 @@
      </argout>
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
    </commands>
    <commands name="RemoveSearchBeamsID" description="Remove the specified Search Beam Capability IDs from the&#xA;CSP sub-array." execMethod="remove_search_beams_id" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
    <commands name="RemoveSearchBeams" description="Remove the specified Search Beam Capability IDs from the&#xA;CSP sub-array." execMethod="remove_search_beams" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false">
      <argin description="The list of SearchBeam Capability IDs to remove from the CSP sub-array.">
        <type xsi:type="pogoDsl:UShortArrayType"/>
      </argin>
@@ -372,7 +371,7 @@
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
      <properties description="" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
    </attributes>
    <attributes name="corrInherentCapAddr" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
    <attributes name="procModeCorrelationAddr" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
      <dataType xsi:type="pogoDsl:StringType"/>
      <changeEvent fire="false" libCheckCriteria="false"/>
      <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -380,7 +379,7 @@
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
      <properties description="The CSP sub-array Correlation Inherent Capability FQDN." label="Correlation Inherent Capability Address" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
    </attributes>
    <attributes name="pssInherentCapAddr" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
    <attributes name="procModePssAddr" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
      <dataType xsi:type="pogoDsl:StringType"/>
      <changeEvent fire="false" libCheckCriteria="false"/>
      <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -388,7 +387,7 @@
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
      <properties description="The CSP sub-array PSS Inherent Capability FQDN." label="PSS Inherent Capability address" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
    </attributes>
    <attributes name="pstInherentCap" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
    <attributes name="procModePstAddr" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
      <dataType xsi:type="pogoDsl:StringType"/>
      <changeEvent fire="false" libCheckCriteria="false"/>
      <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -396,7 +395,7 @@
      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
      <properties description="The CSP sub-array PST Inherent Capability FQDN." label="PST Inherent Capability address" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
    </attributes>
    <attributes name="vlbiInherentCap" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
    <attributes name="procModeVlbiAddr" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
      <dataType xsi:type="pogoDsl:StringType"/>
      <changeEvent fire="false" libCheckCriteria="false"/>
      <archiveEvent fire="false" libCheckCriteria="false"/>