Skip to content
Snippets Groups Projects
Unverified Commit 0e2bab95 authored by SKAJohanVenter's avatar SKAJohanVenter
Browse files

Merge branch 'main' into sar-288-async-controller

parents e8085b21 98ae63bd
No related branches found
No related tags found
No related merge requests found
......@@ -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}")
......
......@@ -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
)
......
......@@ -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
......
......@@ -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()
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):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment