From f51ec8019aa0d567b04bceb7da1b919f124b36e8 Mon Sep 17 00:00:00 2001 From: Aditya Dange <adityadange.ska@gmail.com> Date: Mon, 10 Dec 2018 19:24:08 +0530 Subject: [PATCH] Removed unwanted methods (GetMetrics and ToJson) from SKABase class. Changed data types of attributes centralLoggingLevel, elementLoggingLevel and storageLoggingLevel to DevUShort to align with CS_Guidelines --- skabase/SKABaseDevice/SKABaseDevice.xmi | 31 +++----------- .../SKABaseDevice/SKABaseDevice.py | 42 +------------------ .../SKABaseDevice/test/SKABaseDevice_test.py | 21 ++-------- 3 files changed, 11 insertions(+), 83 deletions(-) diff --git a/skabase/SKABaseDevice/SKABaseDevice.xmi b/skabase/SKABaseDevice/SKABaseDevice.xmi index 185f8571..bf0c9812 100644 --- a/skabase/SKABaseDevice/SKABaseDevice.xmi +++ b/skabase/SKABaseDevice/SKABaseDevice.xmi @@ -10,13 +10,6 @@ <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <DefaultPropValue>4</DefaultPropValue> </deviceProperties> - <deviceProperties name="MetricList" description="A subset of attributes we want to expose as metrics for this device."> - <type xsi:type="pogoDsl:StringVectorType"/> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - <DefaultPropValue>healthState</DefaultPropValue> - <DefaultPropValue>adminMode</DefaultPropValue> - <DefaultPropValue>controlMode</DefaultPropValue> - </deviceProperties> <deviceProperties name="GroupDefinitions" description="Each string in the list is a JSON serialised dict defining the ``group_name``,
``devices`` and ``subgroups`` in the group. A TANGO Group object is created
for each item in the list, according to the hierarchy defined. This provides
easy access to the managed devices in bulk, or individually.

The general format of the list is as follows, with optional ``devices`` and
``subgroups`` keys:
 [ {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ...]},
 {``group_name``: ``<name>``,
 ``devices``: [``<dev name>``, ``<dev name>``, ...],
 ``subgroups`` : [{<nested group>},
 {<nested group>}, ...]},
 ...
 ]

For example, a hierarchy of racks, servers and switches:
 [ {``group_name``: ``servers``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/server/3``, ``elt/server/4``]},
 {``group_name``: ``switches``,
 ``devices``: [``elt/switch/A``, ``elt/switch/B``]},
 {``group_name``: ``pdus``,
 ``devices``: [``elt/pdu/rackA``, ``elt/pdu/rackB``]},
 {``group_name``: ``racks``,
 ``subgroups``: [
 {``group_name``: ``rackA``,
 ``devices``: [``elt/server/1``, ``elt/server/2``,
 ``elt/switch/A``, ``elt/pdu/rackA``]},
 {``group_name``: ``rackB``,
 ``devices``: [``elt/server/3``, ``elt/server/4``,
 ``elt/switch/B``, ``elt/pdu/rackB``],
 ``subgroups``: []}
 ]} ]"> <type xsi:type="pogoDsl:StringVectorType"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> @@ -52,24 +45,6 @@ </argout> <status abstract="true" inherited="true" concrete="true" concreteHere="false"/> </commands> - <commands name="GetMetrics" description="Gets list of attributes marked as metrics, with their values, 
for device" execMethod="get_metrics" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> - <argin description=""> - <type xsi:type="pogoDsl:VoidType"/> - </argin> - <argout description=""> - <type xsi:type="pogoDsl:StringType"/> - </argout> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - </commands> - <commands name="ToJson" description="Returns a JSON translation of this device.
Defaults for empty string argin gives commands and metris:
with_value:false, 
with_commands:true, 
with_metrics:true, 
with_attributes:false" execMethod="to_json" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> - <argin description="Requests the JSON string representing this device, can be filtered 
by with_commands, with_metrics, with_attributes and 
with_value. Defaults for empty string argin are:
{`with_value`:false, `with_commands`:true,
 `with_metrics`:true, `with_attributes`:false}"> - <type xsi:type="pogoDsl:StringType"/> - </argin> - <argout description="The JSON string representing this device, 
filtered as per the input argument flags"> - <type xsi:type="pogoDsl:StringType"/> - </argout> - <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> - </commands> <commands name="GetVersionInfo" description="Array of version strings of all entities modelled by this device. 
(One level down only)
Each string in the array lists the version info for one entity
managed by this device. 
The first entry is version info for this TANGO Device itself.
The entities may be TANGO devices, or hardware LRUs or 
anything else this devices manages/models.
The intention with this command is that it can provide more 
detailed information than can be captured in the versionId 
and buildState attributes, if necessary.
In the minimal case the GetVersionInfo will contain only the 
versionId and buildState attributes of the next lower level
entities." execMethod="get_version_info" displayLevel="OPERATOR" polledPeriod="0" isDynamic="false"> <argin description=""> <type xsi:type="pogoDsl:VoidType"/> @@ -102,18 +77,24 @@ </attributes> <attributes name="centralLoggingLevel" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:UShortType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="Current logging level to Central logging target for this device - 
initialises to CentralLoggingLevelDefault on startup" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="elementLoggingLevel" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:UShortType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="Current logging level to Element logging target for this device - 
initialises to ElementLoggingLevelDefault on startup" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> </attributes> <attributes name="storageLoggingLevel" attType="Scalar" rwType="READ_WRITE" displayLevel="OPERATOR" polledPeriod="1000" maxX="" maxY="" memorized="true" allocReadMember="true" isDynamic="false"> <dataType xsi:type="pogoDsl:UShortType"/> + <changeEvent fire="false" libCheckCriteria="false"/> + <archiveEvent fire="false" libCheckCriteria="false"/> <dataReadyEvent fire="false" libCheckCriteria="true"/> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> <properties description="Current logging level to Syslog for this device - 
initialises from StorageLoggingLevelDefault on first execution of device.
Needs to be READ_WRITE To make it memorized - but writing this attribute should 
do the same as command SetStorageLoggingLevel to ensure the targets and adjustments
are made correctly" label="" unit="" standardUnit="" displayUnit="" format="" maxValue="" minValue="" maxAlarm="" minAlarm="" maxWarning="" minWarning="" deltaTime="" deltaValue=""/> diff --git a/skabase/SKABaseDevice/SKABaseDevice/SKABaseDevice.py b/skabase/SKABaseDevice/SKABaseDevice/SKABaseDevice.py index 278d9102..f2ff5a99 100644 --- a/skabase/SKABaseDevice/SKABaseDevice/SKABaseDevice.py +++ b/skabase/SKABaseDevice/SKABaseDevice/SKABaseDevice.py @@ -4,6 +4,8 @@ # # # +# Distributed under the terms of the none license. +# See LICENSE.txt for more info. """ SKABASE @@ -186,10 +188,6 @@ class SKABaseDevice(Device): dtype='int16', default_value=4 ) - MetricList = device_property( - dtype=('str',), default_value=["healthState", "adminMode", "controlMode"] - ) - GroupDefinitions = device_property( dtype=('str',), ) @@ -412,42 +410,6 @@ class SKABaseDevice(Device): # Commands # -------- - @command( - dtype_out='str', - ) - @DebugIt() - # def GetMetrics(self): - # # PROTECTED REGION ID(SKABaseDevice.GetMetrics) ENABLED START # - # ### TBD - read the value of each of the attributes in the MetricList - # with exception_manager(self): - # args_dict = {'with_value': True, 'with_commands': False, - # 'with_metrics': True, 'with_attributes': False} - # device_dict = self._get_device_json(args_dict) - # argout = json.dumps(device_dict) - - # return argout - # # PROTECTED REGION END # // SKABaseDevice.GetMetrics - - @command( - dtype_in='str', - doc_in="Requests the JSON string representing this device, can be filtered \nby with_commands, with_metrics, with_attributes and \nwith_value. Defaults for empty string argin are:\n{`with_value`:false, `with_commands`:true,\n `with_metrics`:true, `with_attributes`:false}", - dtype_out='str', - doc_out="The JSON string representing this device, \nfiltered as per the input argument flags", - ) - @DebugIt() - # def ToJson(self, argin): - # # PROTECTED REGION ID(SKABaseDevice.ToJson) ENABLED START # - - # TBD - see how to use fandango's export_device_to_dict - # with exception_manager(self): - # defaults = {'with_value': False, 'with_commands': True, - # 'with_metrics': True, 'with_attributes': False} - # args_dict = self._parse_argin(argin, defaults=defaults) - # device_dict = self._get_device_json(args_dict) - # argout = json.dumps(device_dict) - # return argout - # # PROTECTED REGION END # // SKABaseDevice.ToJson - @command( dtype_out=('str',), doc_out="[ name: EltTelState ]", diff --git a/skabase/SKABaseDevice/test/SKABaseDevice_test.py b/skabase/SKABaseDevice/test/SKABaseDevice_test.py index 0c0c0831..beb56747 100644 --- a/skabase/SKABaseDevice/test/SKABaseDevice_test.py +++ b/skabase/SKABaseDevice/test/SKABaseDevice_test.py @@ -5,6 +5,8 @@ # # # +# Distributed under the terms of the none license. +# See LICENSE.txt for more info. ######################################################################################### """Contain the tests for the SKABASE.""" @@ -34,7 +36,6 @@ class TestSKABaseDevice(object): properties = { 'SkaLevel': '4', - 'MetricList': 'healthState', 'GroupDefinitions': '', 'CentralLoggingTarget': '', 'ElementLoggingTarget': '', @@ -45,7 +46,7 @@ class TestSKABaseDevice(object): def mocking(cls): """Mock external libraries.""" # Example : Mock numpy - #cls.numpy = SKABaseDevice.numpy = MagicMock() + # cls.numpy = SKABaseDevice.numpy = MagicMock() # PROTECTED REGION ID(SKABaseDevice.test_mocking) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_mocking @@ -71,22 +72,6 @@ class TestSKABaseDevice(object): assert tango_context.device.Status() == "The device is in UNKNOWN state." # PROTECTED REGION END # // SKABaseDevice.test_Status - # PROTECTED REGION ID(SKABaseDevice.test_GetMetrics_decorators) ENABLED START # - # PROTECTED REGION END # // SKABaseDevice.test_GetMetrics_decorators - # def test_GetMetrics(self, tango_context): - # """Test for GetMetrics""" - # # PROTECTED REGION ID(SKABaseDevice.test_GetMetrics) ENABLED START # - # assert tango_context.device.GetMetrics() == "" - # # PROTECTED REGION END # // SKABaseDevice.test_GetMetrics - - # PROTECTED REGION ID(SKABaseDevice.test_ToJson_decorators) ENABLED START # - # PROTECTED REGION END # // SKABaseDevice.test_ToJson_decorators - # def test_ToJson(self, tango_context): - # """Test for ToJson""" - # # PROTECTED REGION ID(SKABaseDevice.test_ToJson) ENABLED START # - # assert tango_context.device.ToJson("") == "" - # # PROTECTED REGION END # // SKABaseDevice.test_ToJson - # PROTECTED REGION ID(SKABaseDevice.test_GetVersionInfo_decorators) ENABLED START # # PROTECTED REGION END # // SKABaseDevice.test_GetVersionInfo_decorators def test_GetVersionInfo(self, tango_context): -- GitLab