From ceb44c89abf806105c4bdc1cf37f101a682ef810 Mon Sep 17 00:00:00 2001
From: softir <elisabetta.giani@inaf.it>
Date: Fri, 3 Apr 2020 16:05:04 +0200
Subject: [PATCH] AT5-370: Removed default polling value set for some
 attributes and polling configuration from dsconfig file: if polling is
 enabled for the attributes, the test on attribute reading is not performed
 because the value is read from the cache and not from the device. Polling has
 to be enabled into the dsconfig file when the real devices are instantiated)

---
 cspse/lmc/subelement_master.py     | 18 +++++-----
 docker/config/csplmc_dsconfig.json | 54 ++----------------------------
 pogo/CspSubElementMaster.xmi       | 28 ++++++++++------
 setup.cfg                          |  6 +++-
 tests/test_se_master.py            | 12 +++++++
 5 files changed, 44 insertions(+), 74 deletions(-)

diff --git a/cspse/lmc/subelement_master.py b/cspse/lmc/subelement_master.py
index f20a0c0..b27c0dd 100644
--- a/cspse/lmc/subelement_master.py
+++ b/cspse/lmc/subelement_master.py
@@ -42,6 +42,9 @@ class CspSubElementMaster(SKAMaster):
     **Properties:**
 
     - Device Property
+        Racks
+            - The list with the FQDNs of the sub-element racks devices.
+            - Type:'DevVarStringArray'
     """
     # PROTECTED REGION ID(CspSubElementMaster.class_variable) ENABLED START #
     # PROTECTED REGION END #    //  CspSubElementMaster.class_variable
@@ -50,6 +53,10 @@ class CspSubElementMaster(SKAMaster):
     # Device Properties
     # -----------------
 
+    Racks = device_property(
+        dtype='DevVarStringArray',
+    )
+
     # ----------
     # Attributes
     # ----------
@@ -63,7 +70,7 @@ class CspSubElementMaster(SKAMaster):
     onCmdFailure = attribute(
         dtype='DevBoolean',
         label="CBF command failure flag",
-        polling_period=1000,
+        #polling_period=1000,
         doc="Failure flag set when the On command fails with error(s).",
     )
 
@@ -76,7 +83,6 @@ class CspSubElementMaster(SKAMaster):
     offCmdFailure = attribute(
         dtype='DevBoolean',
         label="Off execution failure flag",
-        polling_period=1000,
         doc="Failure flag set when the Off command fails with error(s).",
     )
 
@@ -89,7 +95,6 @@ class CspSubElementMaster(SKAMaster):
     standbyCmdFailure = attribute(
         dtype='DevBoolean',
         label="Standby execution failure message",
-        polling_period=1000,
         doc="Failure flag set when the Standby command fails with error(s).",
     )
 
@@ -102,7 +107,6 @@ class CspSubElementMaster(SKAMaster):
     adminMode = attribute(
         dtype=AdminMode,
         access=AttrWriteType.READ_WRITE,
-        polling_period=1000,
         memorized=True,
         doc="The admin mode reported for this device. It may interpret the current device condition \nand condition of all managed devices to set this. Most possibly an aggregate attribute.",
     )
@@ -110,7 +114,6 @@ class CspSubElementMaster(SKAMaster):
     onCommandProgress = attribute(
         dtype='DevUShort',
         label="Progress percentage for the On command",
-        polling_period=3000,
         abs_change=10,
         max_value=100,
         min_value=0,
@@ -120,7 +123,6 @@ class CspSubElementMaster(SKAMaster):
     offCommandProgress = attribute(
         dtype='DevUShort',
         label="Progress percentage for the Off command",
-        polling_period=3000,
         abs_change=10,
         max_value=100,
         min_value=0,
@@ -130,7 +132,6 @@ class CspSubElementMaster(SKAMaster):
     standbyCommandProgress = attribute(
         dtype='DevUShort',
         label="Progress percentage for the Standby command",
-        polling_period=3000,
         abs_change=10,
         max_value=100,
         min_value=0,
@@ -200,21 +201,18 @@ class CspSubElementMaster(SKAMaster):
     onCmdTimeoutExpired = attribute(
         dtype='DevBoolean',
         label="On execution timeout flag",
-        polling_period=2000,
         doc="Signal the occurence of a timeout during the execution of the on command.",
     )
 
     offCmdTimeoutExpired = attribute(
         dtype='DevBoolean',
         label="Off execution timeout flag",
-        polling_period=2000,
         doc="Signal the occurence of a timeout during the execution of the Off command.",
     )
 
     standbyCmdTimeoutExpired = attribute(
         dtype='DevBoolean',
         label="Standby execution timeout flag.",
-        polling_period=2000,
         doc="Signal the occurence of a timeout during the execution of the Standby command.",
     )
 
diff --git a/docker/config/csplmc_dsconfig.json b/docker/config/csplmc_dsconfig.json
index 83dbae6..29d976d 100644
--- a/docker/config/csplmc_dsconfig.json
+++ b/docker/config/csplmc_dsconfig.json
@@ -27,32 +27,6 @@
 				"subelement/rack/02",
 				"subelement/rack/03",
 				"subelement/rack/04"
-			    ],
-                            "polled_attr": [
-                                "healthstate", 
-                                "1000", 
-                                "adminmode", 
-                                "1000", 
-                                "state", 
-				"1000",
-                                "oncommandprogress", 
-                                "2000", 
-                                "offcommandprogress", 
-                                "2000", 
-                                "standbycommandprogress", 
-                                "2000", 
-                                "oncmdtimeoutexpired", 
-                                "1000", 
-                                "offcmdtimeoutexpired", 
-                                "1000", 
-                                "standbycmdtimeoutexpired", 
-                                "1000", 
-                                "oncmdfailure", 
-                                "1000", 
-                                "offcmdfailure", 
-                                "1000", 
-                                "standbycmdfailure", 
-                                "1000" 
                             ]
                         }
                     }
@@ -151,19 +125,7 @@
                         "properties": {
                             "SubID": [
                                 "1"
-                            ], 
-                            "polled_attr": [
-                                "state", 
-                                "1000", 
-                                "healthstate", 
-                                "1000", 
-                                "adminmode", 
-                                "1000", 
-                                "obsstate", 
-                                "1000",
-                                "obsmode", 
-                                "1000"
-                            ]
+                            ] 
                         }
                     }
                 }
@@ -197,19 +159,7 @@
                         "properties": {
                             "SubID": [
                                 "2"
-                            ], 
-                            "polled_attr": [
-                                "state", 
-                                "1000", 
-                                "healthstate", 
-                                "1000", 
-                                "adminmode", 
-                                "1000", 
-                                "obsstate", 
-                                "1000",
-                                "obsmode", 
-                                "1000"
-                            ]
+                            ] 
                         }
                     }
                 }
diff --git a/pogo/CspSubElementMaster.xmi b/pogo/CspSubElementMaster.xmi
index 567b8c2..0abe206 100644
--- a/pogo/CspSubElementMaster.xmi
+++ b/pogo/CspSubElementMaster.xmi
@@ -1,7 +1,7 @@
 <?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="CspSubElementMaster" pogoRevision="9.6">
-    <description description="A base class for the Master of a SKA Sub-element." title="CSP.LMC Sub-element Master" sourcePath="/home/softir/src/ska-git/csp-lmc-subelement/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="A base class for the Master of a SKA Sub-element." title="CSP.LMC Sub-element Master" sourcePath="/home/softir/src/ska-git/csp-lmc-subelement/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="SKABaseDevice" sourcePath="../../lmc-base-classes/pogo"/>
       <inheritances classname="SKAMaster" sourcePath="/home/softir/src/ska-git/lmc-base-classes/pogo"/>
@@ -38,6 +38,10 @@
       <type xsi:type="pogoDsl:StringVectorType"/>
       <status abstract="false" inherited="true" concrete="true"/>
     </deviceProperties>
+    <deviceProperties name="Racks" description="The list with the FQDNs of the sub-element racks devices.">
+      <type xsi:type="pogoDsl:StringVectorType"/>
+      <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
+    </deviceProperties>
     <commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR" polledPeriod="0">
       <argin description="none">
         <type xsi:type="pogoDsl:VoidType"/>
@@ -169,7 +173,7 @@
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
       <properties description="Number of devices that completed the task" label="Number of devices that completed the task" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
-    <attributes name="onCmdFailure" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false">
+    <attributes name="onCmdFailure" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:BooleanType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -185,7 +189,7 @@
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
       <properties description="Failure message when the On command fails with error(s)." label="On execution failure message" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
-    <attributes name="offCmdFailure" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false">
+    <attributes name="offCmdFailure" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:BooleanType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -201,7 +205,7 @@
       <status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
       <properties description="Failure message when the Off command fails with error(s)." label="Off execution failure message" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
-    <attributes name="standbyCmdFailure" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false">
+    <attributes name="standbyCmdFailure" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:BooleanType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -231,7 +235,7 @@
       <status abstract="false" inherited="true" concrete="true"/>
       <properties description="The health state reported for this device. It interprets the current device condition &#xA;and condition of all managed devices to set this. Most possibly an aggregate attribute." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
-    <attributes name="adminMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" memorized="true" allocReadMember="true">
+    <attributes name="adminMode" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" memorized="true" allocReadMember="true">
       <dataType xsi:type="pogoDsl:EnumType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -259,7 +263,7 @@
       <status abstract="false" inherited="true" concrete="true"/>
       <properties description="The test mode of the device. &#xA;Either no test mode (empty string) or an indication of the test mode." label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
     </attributes>
-    <attributes name="onCommandProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="3000" maxX="" maxY="" allocReadMember="false" isDynamic="false">
+    <attributes name="onCommandProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
       <dataType xsi:type="pogoDsl:UShortType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -268,7 +272,7 @@
       <properties description="Percentage progress implemented for commands that  result in state/mode transitions for a large &#xA;number of components and/or are executed in stages (e.g power up, power down)" label="Progress percentage for the On command" unit="" standardUnit="" displayUnit="" format="" maxValue="100" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
       <eventCriteria relChange="" absChange="10" period=""/>
     </attributes>
-    <attributes name="offCommandProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="3000" maxX="" maxY="" allocReadMember="false" isDynamic="false">
+    <attributes name="offCommandProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
       <dataType xsi:type="pogoDsl:UShortType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -277,7 +281,7 @@
       <properties description="Percentage progress implemented for commands that  result in state/mode transitions for a large &#xA;number of components and/or are executed in stages (e.g power up, power down)" label="Progress percentage for the Off command" unit="" standardUnit="" displayUnit="" format="" maxValue="100" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
       <eventCriteria relChange="" absChange="10" period=""/>
     </attributes>
-    <attributes name="standbyCommandProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="3000" maxX="" maxY="" allocReadMember="false" isDynamic="false">
+    <attributes name="standbyCommandProgress" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="false" isDynamic="false">
       <dataType xsi:type="pogoDsl:UShortType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -340,7 +344,7 @@
       <properties description="Report the measured duration of the Standby command" label="Measured duration (sec) of the Standby command" unit="" standardUnit="" displayUnit="" format="" maxValue="100" minValue="0" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
       <eventCriteria relChange="" absChange="0" period=""/>
     </attributes>
-    <attributes name="onCmdTimeoutExpired" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="2000" maxX="" maxY="" allocReadMember="true" isDynamic="false">
+    <attributes name="onCmdTimeoutExpired" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:BooleanType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -349,7 +353,7 @@
       <properties description="Signal the occurence of a timeout during the execution of the on command." label="On execution timeout flag" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
       <eventCriteria relChange="" absChange="1" period=""/>
     </attributes>
-    <attributes name="offCmdTimeoutExpired" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="2000" maxX="" maxY="" allocReadMember="true" isDynamic="false">
+    <attributes name="offCmdTimeoutExpired" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:BooleanType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -358,7 +362,7 @@
       <properties description="Signal the occurence of a timeout during the execution of the Off command." label="Off execution timeout flag" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/>
       <eventCriteria relChange="" absChange="1" period=""/>
     </attributes>
-    <attributes name="standbyCmdTimeoutExpired" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="2000" maxX="" maxY="" allocReadMember="true" isDynamic="false">
+    <attributes name="standbyCmdTimeoutExpired" attType="Scalar" rwType="READ" displayLevel="OPERATOR" polledPeriod="0" maxX="" maxY="" allocReadMember="true" isDynamic="false">
       <dataType xsi:type="pogoDsl:BooleanType"/>
       <changeEvent fire="false" libCheckCriteria="false"/>
       <archiveEvent fire="false" libCheckCriteria="false"/>
@@ -429,5 +433,7 @@
       <status abstract="false" inherited="true" concrete="true"/>
     </states>
     <preferences docHome="./doc_html" makefileHome="/usr/local/share/pogo/preferences"/>
+    <overlodedPollPeriodObject name="adminMode" type="attribute" pollPeriod="0"/>
+    <overlodedPollPeriodObject name="adminMode" type="attribute" pollPeriod="0"/>
   </classes>
 </pogoDsl:PogoSystem>
diff --git a/setup.cfg b/setup.cfg
index 90ecf57..ed35f2e 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -11,7 +11,8 @@ source = cspse
 
 [tool:pytest]
 testpaths = tests
-addopts = --cov=cspse 
+addopts = --verbose
+          --cov=cspse 
           --json-report 
           --json-report-file=htmlcov/report.json 
           --cov-report=term 
@@ -21,6 +22,9 @@ addopts = --cov=cspse
 
 junit_family=legacy
 console_output_style = progress
+
+[coverage:report]
+show_missing = True
 # Define `python setup.py build_sphinx`
 [build_sphinx]
 source-dir = docs
diff --git a/tests/test_se_master.py b/tests/test_se_master.py
index 94d9e4b..a598ec3 100644
--- a/tests/test_se_master.py
+++ b/tests/test_se_master.py
@@ -273,3 +273,15 @@ class TestCspSubElementMaster(object):
         assert tango_context.device.offCmdDurationExpected == 30
         assert tango_context.device.standbyCmdDurationExpected == 30
 
+    def test_set_command_duration_expected(self, tango_context):
+        """Test xxxCmdDurationExpected attributes"""
+        tango_context.device.onCmdDurationExpected = 20
+        tango_context.device.offCmdDurationExpected = 20
+        tango_context.device.standbyCmdDurationExpected = 20
+        # wait to let the polling thread update the attrs value
+        time.sleep(3)
+        assert tango_context.device.onCmdDurationExpected == 20
+        assert tango_context.device.offCmdDurationExpected == 20
+        assert tango_context.device.standbyCmdDurationExpected == 20
+
+
-- 
GitLab