From c0550cde1ce995d0cc9be2f36ef195f19727a5f1 Mon Sep 17 00:00:00 2001 From: Johan Venter <aventer@ska.ac.za> Date: Wed, 27 Oct 2021 06:48:04 +0000 Subject: [PATCH] SAR-288 Change GetVersionInfo and isCapabilityAchievable to long running --- pogo/CspSubElementController.xmi | 2 +- pogo/CspSubElementObsDevice.xmi | 2 +- pogo/CspSubElementSubarray.xmi | 2 +- pogo/SKAAlarmHandler.xmi | 2 +- pogo/SKABaseDevice.xmi | 2 +- pogo/SKACapability.xmi | 2 +- pogo/SKAController.xmi | 4 ++-- pogo/SKALogger.xmi | 2 +- pogo/SKAObsDevice.xmi | 2 +- pogo/SKASubarray.xmi | 2 +- pogo/SKATelState.xmi | 2 +- src/ska_tango_base/base/base_device.py | 9 +++++---- src/ska_tango_base/controller_device.py | 10 ++++++---- tests/test_alarm_handler_device.py | 9 +++++---- tests/test_base_device.py | 9 +++++---- tests/test_controller_device.py | 18 ++++++++++++------ tests/test_csp_controller.py | 9 +++++---- tests/test_csp_obs_device.py | 9 +++++---- tests/test_csp_subarray.py | 9 +++++---- tests/test_logger_device.py | 9 +++++---- tests/test_obs_device.py | 9 +++++---- tests/test_subarray_device.py | 9 +++++---- tests/test_tel_state_device.py | 9 +++++---- 23 files changed, 80 insertions(+), 62 deletions(-) diff --git a/pogo/CspSubElementController.xmi b/pogo/CspSubElementController.xmi index c861cbdb..a130f84c 100644 --- a/pogo/CspSubElementController.xmi +++ b/pogo/CspSubElementController.xmi @@ -71,7 +71,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> diff --git a/pogo/CspSubElementObsDevice.xmi b/pogo/CspSubElementObsDevice.xmi index 7befab6d..af8d7f2f 100644 --- a/pogo/CspSubElementObsDevice.xmi +++ b/pogo/CspSubElementObsDevice.xmi @@ -53,7 +53,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> diff --git a/pogo/CspSubElementSubarray.xmi b/pogo/CspSubElementSubarray.xmi index 489b6908..1ca79a91 100644 --- a/pogo/CspSubElementSubarray.xmi +++ b/pogo/CspSubElementSubarray.xmi @@ -56,7 +56,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> diff --git a/pogo/SKAAlarmHandler.xmi b/pogo/SKAAlarmHandler.xmi index db01bd18..3f8f1945 100644 --- a/pogo/SKAAlarmHandler.xmi +++ b/pogo/SKAAlarmHandler.xmi @@ -118,7 +118,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState ]"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> diff --git a/pogo/SKABaseDevice.xmi b/pogo/SKABaseDevice.xmi index a7f7ed3d..42261f49 100644 --- a/pogo/SKABaseDevice.xmi +++ b/pogo/SKABaseDevice.xmi @@ -46,7 +46,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="Version strings"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> diff --git a/pogo/SKACapability.xmi b/pogo/SKACapability.xmi index b71acefe..524562f9 100644 --- a/pogo/SKACapability.xmi +++ b/pogo/SKACapability.xmi @@ -59,7 +59,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> diff --git a/pogo/SKAController.xmi b/pogo/SKAController.xmi index 46679e7d..ba8e0367 100644 --- a/pogo/SKAController.xmi +++ b/pogo/SKAController.xmi @@ -60,7 +60,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> @@ -69,7 +69,7 @@ <type xsi:type="pogoDsl:LongStringArrayType"/> </argin> <argout description=""> - <type xsi:type="pogoDsl:BooleanType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="false" concrete="true" concreteHere="true"/> </commands> diff --git a/pogo/SKALogger.xmi b/pogo/SKALogger.xmi index 267dbfb0..3616550b 100644 --- a/pogo/SKALogger.xmi +++ b/pogo/SKALogger.xmi @@ -56,7 +56,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState ]"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> diff --git a/pogo/SKAObsDevice.xmi b/pogo/SKAObsDevice.xmi index 3512f147..6caa6332 100644 --- a/pogo/SKAObsDevice.xmi +++ b/pogo/SKAObsDevice.xmi @@ -47,7 +47,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> diff --git a/pogo/SKASubarray.xmi b/pogo/SKASubarray.xmi index f13224cf..280d53a2 100644 --- a/pogo/SKASubarray.xmi +++ b/pogo/SKASubarray.xmi @@ -55,7 +55,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> diff --git a/pogo/SKATelState.xmi b/pogo/SKATelState.xmi index 009fed6b..210d8fee 100644 --- a/pogo/SKATelState.xmi +++ b/pogo/SKATelState.xmi @@ -51,7 +51,7 @@ <type xsi:type="pogoDsl:VoidType"/> </argin> <argout description="[ name: EltTelState ]"> - <type xsi:type="pogoDsl:StringArrayType"/> + <type xsi:type="pogoDsl:DevVarLongStringArray"/> </argout> <status abstract="false" inherited="true" concrete="true"/> </commands> diff --git a/src/ska_tango_base/base/base_device.py b/src/ska_tango_base/base/base_device.py index 093a7ecd..6bbfc93a 100644 --- a/src/ska_tango_base/base/base_device.py +++ b/src/ska_tango_base/base/base_device.py @@ -1183,8 +1183,8 @@ class SKABaseDevice(Device): return [f"{device.__class__.__name__}, {device.read_buildState()}"] @command( - dtype_out=("str",), - doc_out="Version strings", + dtype_out="DevVarLongStringArray", + doc_out="(ResultCode, 'Command unique ID')", ) @DebugIt() def GetVersionInfo(self): @@ -1195,10 +1195,11 @@ class SKABaseDevice(Device): To modify behaviour for this command, modify the do() method of the command class. - :return: Version details of the device. + :return: The result code and the command unique ID """ command = self.get_command_object("GetVersionInfo") - return command() + unique_id, result_code = self.component_manager.enqueue(command) + return [[result_code], [unique_id]] # PROTECTED REGION END # // SKABaseDevice.GetVersionInfo class ResetCommand(StateModelCommand, ResponseCommand): diff --git a/src/ska_tango_base/controller_device.py b/src/ska_tango_base/controller_device.py index a4401208..a390d9a1 100644 --- a/src/ska_tango_base/controller_device.py +++ b/src/ska_tango_base/controller_device.py @@ -240,7 +240,8 @@ class SKAController(SKABaseDevice): @command( dtype_in="DevVarLongStringArray", doc_in="[nrInstances][Capability types]", - dtype_out="bool", + dtype_out="DevVarLongStringArray", + doc_out="(ResultCode, 'Command unique ID')", ) @DebugIt() def isCapabilityAchievable(self, argin): @@ -258,11 +259,12 @@ class SKAController(SKABaseDevice): :type argin: :py:class:`tango.DevVarLongStringArray`. - :return: True if capability can be achieved, False if cannot - :rtype: DevBoolean + :return: result_code, unique_id + :rtype: DevVarLongStringArray """ command = self.get_command_object("IsCapabilityAchievable") - return command(argin) + unique_id, result_code = self.component_manager.enqueue(command, argin) + return [[result_code], [unique_id]] # PROTECTED REGION END # // SKAController.isCapabilityAchievable diff --git a/tests/test_alarm_handler_device.py b/tests/test_alarm_handler_device.py index 3e6c5bf6..f93a5a5f 100644 --- a/tests/test_alarm_handler_device.py +++ b/tests/test_alarm_handler_device.py @@ -97,11 +97,12 @@ class TestSKAAlarmHandler(object): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKAAlarmHandler.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // SKAAlarmHandler.test_GetVersionInfo # PROTECTED REGION ID(SKAAlarmHandler.test_statsNrAlerts_decorators) ENABLED START # diff --git a/tests/test_base_device.py b/tests/test_base_device.py index 9a328bd5..c9f217ca 100644 --- a/tests/test_base_device.py +++ b/tests/test_base_device.py @@ -441,11 +441,12 @@ class TestSKABaseDevice(object): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKABaseDevice.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // SKABaseDevice.test_GetVersionInfo # PROTECTED REGION ID(SKABaseDevice.test_Reset_decorators) ENABLED START # diff --git a/tests/test_controller_device.py b/tests/test_controller_device.py index 6999b808..981a1d03 100644 --- a/tests/test_controller_device.py +++ b/tests/test_controller_device.py @@ -95,11 +95,12 @@ class TestSKAController(object): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKAController.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // SKAController.test_GetVersionInfo # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_failure_decorators) ENABLED START # @@ -107,7 +108,10 @@ class TestSKAController(object): def test_isCapabilityAchievable_failure(self, device_under_test): """Test for isCapabilityAchievable to test failure condition.""" # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_failure) ENABLED START # - assert device_under_test.isCapabilityAchievable([[2], ["BAND1"]]) is False + device_under_test.isCapabilityAchievable([[2], ["BAND1"]]) + capability_achievalble = device_under_test.longRunningCommandResult[2] + assert capability_achievalble == "False" + # assert device_under_test.isCapabilityAchievable([[2], ["BAND1"]]) is False # PROTECTED REGION END # // SKAController.test_isCapabilityAchievable_failure # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_success_decorators) ENABLED START # @@ -116,7 +120,9 @@ class TestSKAController(object): def test_isCapabilityAchievable_success(self, device_under_test): """Test for isCapabilityAchievable to test success condition.""" # PROTECTED REGION ID(SKAController.test_isCapabilityAchievable_success) ENABLED START # - assert device_under_test.isCapabilityAchievable([[1], ["BAND1"]]) is True + device_under_test.isCapabilityAchievable([[1], ["BAND1"]]) + capability_achievalble = device_under_test.longRunningCommandResult[2] + assert capability_achievalble == "True" # PROTECTED REGION END # // SKAController.test_isCapabilityAchievable_success # PROTECTED REGION ID(SKAController.test_elementLoggerAddress_decorators) ENABLED START # diff --git a/tests/test_csp_controller.py b/tests/test_csp_controller.py index 55aab228..eadcf3d0 100644 --- a/tests/test_csp_controller.py +++ b/tests/test_csp_controller.py @@ -88,11 +88,12 @@ class TestCspSubElementController(object): """Test for GetVersionInfo.""" # PROTECTED REGION ID(CspSubelementController.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // CspSubelementController.test_GetVersionInfo # PROTECTED REGION ID(CspSubelementController.test_configurationProgress_decorators) ENABLED START # diff --git a/tests/test_csp_obs_device.py b/tests/test_csp_obs_device.py index 3aa5d0e6..a505efb4 100644 --- a/tests/test_csp_obs_device.py +++ b/tests/test_csp_obs_device.py @@ -97,11 +97,12 @@ class TestCspSubElementObsDevice(object): """Test for GetVersionInfo.""" # PROTECTED REGION ID(CspSubelementObsDevice.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // CspSubelementObsDevice.test_GetVersionInfo # PROTECTED REGION ID(CspSubelementObsDevice.test_buildState_decorators) ENABLED START # diff --git a/tests/test_csp_subarray.py b/tests/test_csp_subarray.py index 37a4d0b4..6d36bde9 100644 --- a/tests/test_csp_subarray.py +++ b/tests/test_csp_subarray.py @@ -98,11 +98,12 @@ class TestCspSubElementSubarray(object): """Test for GetVersionInfo.""" # PROTECTED REGION ID(CspSubelementSubarray.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // CspSubelementSubarray.test_GetVersionInfo # PROTECTED REGION ID(CspSubelementSubarray.test_configurationProgress_decorators) ENABLED START # diff --git a/tests/test_logger_device.py b/tests/test_logger_device.py index 2bdf46bb..f3a65923 100644 --- a/tests/test_logger_device.py +++ b/tests/test_logger_device.py @@ -81,11 +81,12 @@ class TestSKALogger(object): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKALogger.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // SKALogger.test_GetVersionInfo # PROTECTED REGION ID(SKALogger.test_buildState_decorators) ENABLED START # diff --git a/tests/test_obs_device.py b/tests/test_obs_device.py index daceac14..6114ff50 100644 --- a/tests/test_obs_device.py +++ b/tests/test_obs_device.py @@ -84,11 +84,12 @@ class TestSKAObsDevice(object): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKAObsDevice.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // SKAObsDevice.test_GetVersionInfo # PROTECTED REGION ID(SKAObsDevice.test_obsState_decorators) ENABLED START # diff --git a/tests/test_subarray_device.py b/tests/test_subarray_device.py index cceb1bdf..420e4608 100644 --- a/tests/test_subarray_device.py +++ b/tests/test_subarray_device.py @@ -122,11 +122,12 @@ class TestSKASubarray: """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKASubarray.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // SKASubarray.test_GetVersionInfo # PROTECTED REGION ID(SKASubarray.test_Status_decorators) ENABLED START # diff --git a/tests/test_tel_state_device.py b/tests/test_tel_state_device.py index e771eb82..a6b14891 100644 --- a/tests/test_tel_state_device.py +++ b/tests/test_tel_state_device.py @@ -77,11 +77,12 @@ class TestSKATelState(object): """Test for GetVersionInfo.""" # PROTECTED REGION ID(SKATelState.test_GetVersionInfo) ENABLED START # versionPattern = re.compile( - f"{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " - "A set of generic base devices for SKA Telescope." + f"['{device_under_test.info().dev_class}, ska_tango_base, [0-9]+.[0-9]+.[0-9]+, " + "A set of generic base devices for SKA Telescope.']" ) - versionInfo = device_under_test.GetVersionInfo() - assert (re.match(versionPattern, versionInfo[0])) is not None + device_under_test.GetVersionInfo() + versionInfo = device_under_test.longRunningCommandResult[2] + assert (re.match(versionPattern, versionInfo)) is not None # PROTECTED REGION END # // SKATelState.test_GetVersionInfo # PROTECTED REGION ID(SKATelState.test_buildState_decorators) ENABLED START # -- GitLab