Skip to content
Snippets Groups Projects
Commit aab8ea26 authored by Corné Lukken's avatar Corné Lukken
Browse files

Merge branch 'L2SS-1741' into 'master'

L2SS-1741: Prevent bypassing state checks in async devices

Closes L2SS-1741

See merge request !846
parents 5bd0d41f d82b99a7
No related branches found
No related tags found
1 merge request!846L2SS-1741: Prevent bypassing state checks in async devices
......@@ -45,10 +45,7 @@ from tangostationcontrol.common.lofar_logging import (
device_logging_to_python,
)
from tangostationcontrol.common.proxy import create_device_proxy
from tangostationcontrol.common.states import (
DEFAULT_COMMAND_STATES,
INITIALISED_STATES,
)
from tangostationcontrol.common.states import DEFAULT_COMMAND_STATES
from tangostationcontrol.common.type_checking import sequence_not_str
from tangostationcontrol.devices.base_device_classes.control_hierarchy import (
ControlHierarchyDevice,
......@@ -220,7 +217,7 @@ class LOFARDevice(Device):
def is_attribute_access_allowed(self, req_type: AttReqType):
"""Returns whether an attribute wrapped by the AttributeWrapper be accessed."""
return self.get_state() in INITIALISED_STATES
return self.get_state() in DEFAULT_COMMAND_STATES
# TODO(Corne): Actually implement locking in L2SS-940
def atomic_read_modify_write_attribute(
......@@ -405,6 +402,7 @@ class LOFARDevice(Device):
# Commands
# --------
@only_in_states([DevState.OFF])
def _Initialise(self):
"""
Command to ask for initialisation of this device. Can only be called in OFF state.
......@@ -443,11 +441,11 @@ class LOFARDevice(Device):
@command()
@debugit()
@log_exceptions()
@only_in_states([DevState.OFF])
@fault_on_error()
def Initialise(self):
self._Initialise()
@only_in_states(DEFAULT_COMMAND_STATES)
def _On(self):
if self.get_state() == DevState.ON:
# Already on. Don't complain.
......@@ -462,7 +460,6 @@ class LOFARDevice(Device):
@command()
@debugit()
@log_exceptions()
@only_in_states(INITIALISED_STATES)
@fault_on_error()
def On(self):
"""
......@@ -658,7 +655,6 @@ class LOFARDevice(Device):
f"Cannot assign default to attribute {attribute}"
) from _e
@only_in_states(INITIALISED_STATES)
@command()
@debugit()
@log_exceptions()
......@@ -668,7 +664,6 @@ class LOFARDevice(Device):
# This is just the command version of _prepare_hardware().
self._power_hardware_on()
@only_in_states(INITIALISED_STATES)
@command()
@debugit()
@log_exceptions()
......@@ -698,6 +693,7 @@ class LOFARDevice(Device):
restart_python()
logger.error("Failed to restart Device Server")
@only_in_states([DevState.OFF])
def _boot(self):
# setup connections
self._Initialise()
......@@ -708,7 +704,6 @@ class LOFARDevice(Device):
# make device available
self._On()
@only_in_states([DevState.OFF])
@command()
def boot(self):
self._boot()
......@@ -720,6 +715,7 @@ class LOFARDevice(Device):
before configuring the hardware."""
pass
@only_in_states(DEFAULT_COMMAND_STATES)
def _power_hardware_off(self):
"""Override this method to disable any hardware related to the device."""
pass
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment