diff --git a/src/ska_tango_base/base/base_device.py b/src/ska_tango_base/base/base_device.py index ef2d9e28a73d2eb1c6d213156b392730a4adacb0..6bbfc93a56c54de9fd33a2516e6bfee69c7b05b0 100644 --- a/src/ska_tango_base/base/base_device.py +++ b/src/ska_tango_base/base/base_device.py @@ -1237,17 +1237,6 @@ class SKABaseDevice(Device): self.logger.info(message) return (ResultCode.OK, message) - def is_Reset_allowed(self): - """ - Whether the ``Reset()`` command is allowed to be run in the current state. - - :returns: whether the ``Reset()`` command is allowed to be run in the - current state - :rtype: boolean - """ - command = self.get_command_object("Reset") - return command.is_allowed(raise_if_disallowed=True) - @command( dtype_out="DevVarLongStringArray", doc_out="(ReturnType, 'informational message')", @@ -1305,18 +1294,6 @@ class SKABaseDevice(Device): self.logger.info(message) return (ResultCode.OK, message) - def is_Standby_allowed(self): - """ - Check if command Standby is allowed in the current device state. - - :raises :py:exc:`CommandError`: if the command is not allowed - - :return: ``True`` if the command is allowed - :rtype: boolean - """ - command = self.get_command_object("Standby") - return command.is_allowed(raise_if_disallowed=True) - @command( dtype_out="DevVarLongStringArray", doc_out="(ReturnType, 'informational message')", @@ -1374,18 +1351,6 @@ class SKABaseDevice(Device): self.logger.info(message) return (ResultCode.OK, message) - def is_Off_allowed(self): - """ - Check if command `Off` is allowed in the current device state. - - :raises :py:exc:`CommandError`: if the command is not allowed - - :return: ``True`` if the command is allowed - :rtype: boolean - """ - command = self.get_command_object("Off") - return command.is_allowed(raise_if_disallowed=True) - @command( dtype_out="DevVarLongStringArray", doc_out="(ReturnType, 'informational message')", @@ -1443,19 +1408,6 @@ class SKABaseDevice(Device): self.logger.info(message) return (ResultCode.OK, message) - def is_On_allowed(self): - """ - Check if command `On` is allowed in the current device state. - - :raises :py:exc:`CommandError`: if the command is not - allowed - - :return: ``True`` if the command is allowed - :rtype: boolean - """ - command = self.get_command_object("On") - return command.is_allowed(raise_if_disallowed=True) - @command( dtype_out="DevVarLongStringArray", doc_out="(ReturnType, 'informational message')", @@ -1537,9 +1489,9 @@ class SKABaseDevice(Device): :param argin: The command ID :type argin: str - :return: The resultcode for this command and the code for the state + :return: The resultcode for this command and the string of the TaskState :rtype: tuple - (ResultCode.OK, TaskState) + (ResultCode.OK, str) """ result = self.target.get_task_state(argin) return (ResultCode.OK, f"{result}") diff --git a/src/ska_tango_base/base/task_queue_manager.py b/src/ska_tango_base/base/task_queue_manager.py index 6ea0d5fbf1ed059fa4ca20bc0305fcca64b09393..5ce0a59e15c8f4999c6357f0ae1cc8f88d63255d 100644 --- a/src/ska_tango_base/base/task_queue_manager.py +++ b/src/ska_tango_base/base/task_queue_manager.py @@ -116,6 +116,7 @@ from uuid import uuid4 from queue import Empty, Queue from datetime import datetime from threading import Event +from inspect import signature from typing import Any, Callable, Dict, Optional, Tuple, Union import tango @@ -380,7 +381,16 @@ class QueueManager: """ try: if hasattr(task, "is_allowed"): +<<<<<<< HEAD:src/ska_tango_base/base/task_queue_manager.py if not task.is_allowed(): +======= + is_allowed_signature = signature(task.is_allowed) + if "raise_if_disallowed" in is_allowed_signature.parameters: + is_task_allowed = task.is_allowed(raise_if_disallowed=True) + else: + is_task_allowed = task.is_allowed() + if not is_task_allowed: +>>>>>>> main:src/ska_tango_base/base/task_queue_component_manager.py return TaskResult( ResultCode.NOT_ALLOWED, "Command not allowed", unique_id ) diff --git a/src/ska_tango_base/utils.py b/src/ska_tango_base/utils.py index c754579e8e62ee1769124227d554ae32775f20b1..c020787c1a8730b820a54b0a65de216107c57f49 100644 --- a/src/ska_tango_base/utils.py +++ b/src/ska_tango_base/utils.py @@ -630,6 +630,10 @@ class LongRunningDeviceInterface: - If so, fire the callback - Clean up """ + if ev.err: + self._logger.error("Event system DevError(s) occured: %s", str(ev.errors)) + return + if ev.attr_value and ev.attr_value.name == "longrunningcommandresult": if ev.attr_value.value: # push change event to new attribute for all tango devices diff --git a/tests/test_base_device.py b/tests/test_base_device.py index deba667dbb90a36a025f82df7391d97552fe68da..c9f217ca618d66e64a9697efff0a895245c5d32f 100644 --- a/tests/test_base_device.py +++ b/tests/test_base_device.py @@ -456,8 +456,12 @@ class TestSKABaseDevice(object): # PROTECTED REGION ID(SKABaseDevice.test_Reset) ENABLED START # # The main test of this command is # TestSKABaseDevice_commands::test_ResetCommand - with pytest.raises(DevFailed): - device_under_test.Reset() + device_under_test.Reset() + assert f"{ResultCode.FAILED}" == device_under_test.longRunningCommandResult[1] + assert ( + "Action reset_invoked is not allowed in op_state OFF" + in device_under_test.longRunningCommandResult[2] + ) # PROTECTED REGION END # // SKABaseDevice.test_Reset def test_On(self, device_under_test, tango_change_event_helper):