Skip to content
Snippets Groups Projects
Commit 6f5ac04f authored by toor's avatar toor
Browse files

CT-166: Removed reject command.

Updated tests and documentation.
parent a14e3cc9
Branches
No related tags found
No related merge requests found
......@@ -3,6 +3,10 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. |br| raw:: html
<br />
SKA CSP Sub-element ObsDevice
============================================
......@@ -13,3 +17,48 @@ SKA CSP Sub-element ObsDevice
.. autoclass:: ska.base.CspSubElementObsDevice
:members:
:undoc-members:
Instance attributes
-------------------
Here it is reported the list of the *instance attributes*. |br|
* ``scan_id``: the identification number of the scan. |br|
The scan ID is passed as argument of the *Scan* command. |br|
The attribute value is reported via TANGO attribute *scanID*.
* ``_sdp_addresses``: a python dictionary with the SDP destination addresses for the output
products. |br|
Depending on the sub-element (CBF, PSS, PST) this attribute can specify more than one destination address,
as for example in CBF sub-element. |br|
The SDP destination addresses are specified at configuration.
An SDP address specifies the MAC address, IP address and port of the endpoint. |br|
Below an example of how SDP addresses are specified in a Mid CBF configuration::
{
...
"outputHost": [[0, "192.168.0.1"], [8184, "192.168.0.2"]],
"outputMac": [[0, "06-00-00-00-00-01"]],
"outputPort": [[0, 9000, 1], [8184, 9000, 1]]
...
}
The value of this attribute is reported via the TANGO *sdpDestionationAddresses* attribute.
.. note:: Not all the Sub-element observing devices are connected to the SDP (for example Mid VCCs).
* ``_sdp_links_active``: a python list of boolean. Each list element reports the network connectivity of the
corresponding link to SDP.
* ``_sdp_links_capacity``: this attribute records the capacity in GB/s of the SDP link.
* ``_config_id``: it stores the unique identificator associated to a JSON scan configuration. |br|
The value of this attribute is reported via the TANGO attriute *configID*.
* ``_last_scan_configuration``: this attribute stores the last configuration successully programmed. |br|
The value is reported via the TANGO attribute *lastScanConfiguration*.
* ``_health_failure_msg``:
The value is reported via the TANGO attribute *healthFailureMesssage*.
docs/source/images/CspSubElementObsDeviceStateMachine_autogenerated.png

160 KiB | W: | H:

docs/source/images/CspSubElementObsDeviceStateMachine_autogenerated.png

153 KiB | W: | H:

docs/source/images/CspSubElementObsDeviceStateMachine_autogenerated.png
docs/source/images/CspSubElementObsDeviceStateMachine_autogenerated.png
docs/source/images/CspSubElementObsDeviceStateMachine_autogenerated.png
docs/source/images/CspSubElementObsDeviceStateMachine_autogenerated.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -22,7 +22,6 @@ from tango.server import run, attribute, command, device_property
# SKA specific imports
from ska.base import SKAObsDevice, ObsDeviceStateModel
from ska.base.commands import ResultCode, ActionCommand
from ska.base.csp_commands import InputValidatedCommand
from ska.base.control_model import ObsState
from ska.base.faults import CommandError
from ska.base.csp_subelement_state_machine import CspSubElementObsDeviceStateMachine
......@@ -63,11 +62,8 @@ class CspSubElementObsDeviceStateModel(ObsDeviceStateModel):
"configure_started": ("configure_started", None),
"configure_succeeded": ("configure_succeeded", None),
"configure_failed": ("configure_failed", None),
"configure_rejected_to_idle": ("configure_rejected_to_idle", None),
"configure_rejected": ("configure_rejected", None),
"scan_started": ("scan_started", None),
"scan_succeeded": ("scan_succeeded", None),
"scan_rejected": ("scan_rejected", None),
"scan_failed": ("scan_failed", None),
"end_scan_succeeded": ("end_scan_succeeded", None),
"end_scan_failed": ("end_scan_failed", None),
......@@ -314,7 +310,7 @@ class CspSubElementObsDevice(SKAObsDevice):
# --------
class ConfigureScanCommand(InputValidatedCommand):
class ConfigureScanCommand(ActionCommand):
"""
A class for the CspSubElementObsDevices's ConfigureScan command.
"""
......@@ -353,25 +349,22 @@ class CspSubElementObsDevice(SKAObsDevice):
:raises: ``CommandError`` if the configuration data validation fails.
"""
device = self.target
# validate the input args
(result_code, msg) = self.validate_input(argin)
if result_code == ResultCode.OK:
# store the configuration on command success
device._last_scan_configuration = argin
return (ResultCode.OK, "Configure command completed OK")
msg = "Configure command completed OK"
return(result_code, msg)
def validate_input(self, argin):
"""
Validate the configuration parameters against allowed values, as needed.
The developer is free to return a FAULT code or raise an exception taking into
account that in the first case the observing state of the device transits
to FAULT while in the second case it is restored the observing state of the device
as it was before the command was invoked.
:param argin: The JSON formatted string with configuration for the device.
:type argin: 'DevString'
:return: A tuple containing a return code and a string message.
:rtype: (ResultCode, str)
:raises: ``CommandError`` exception when wrong type or range values are specified for
the configuration data. In this case the device restores the observing
state before command was invoked.
"""
device = self.target
try:
......@@ -385,9 +378,9 @@ class CspSubElementObsDevice(SKAObsDevice):
except Exception as other_errs:
msg = "Validate configuration failed with unknown error:{}".format(other_errs)
self.logger.error(msg)
raise CommandError(msg)
return (ResultCode.FAILED, msg)
class ScanCommand(InputValidatedCommand):
class ScanCommand(ActionCommand):
"""
A class for the CspSubElementObsDevices's Scan command.
"""
......@@ -425,8 +418,12 @@ class CspSubElementObsDevice(SKAObsDevice):
:rtype: (ResultCode, str)
"""
device = self.target
(result_code, msg) = self.validate_input(argin)
if result_code == ResultCode.OK:
# store the configuration on command success
device._scan_id = int(argin)
return (ResultCode.STARTED, "Scan command started")
return(result_code, msg)
def validate_input(self, argin):
"""
......@@ -438,13 +435,11 @@ class CspSubElementObsDevice(SKAObsDevice):
message indicating status. The message is for
information purpose only.
:rtype: (ResultCode, str)
:raises: ``CommandError`` exception when wrong type or value arguments
are specified.
"""
if not argin.isdigit():
msg = f"Input argument '{argin}' is not an integer"
self.logger.error(msg)
raise CommandError(msg)
return (ResultCode.FAILED, msg)
return (ResultCode.OK, "Scan arguments validation successfull")
class EndScanCommand(ActionCommand):
......
......@@ -54,16 +54,6 @@ class CspSubElementObsDeviceStateMachine(Machine):
"trigger": "configure_failed",
"dest": "FAULT",
},
{
"source": "CONFIGURING",
"trigger": "configure_rejected",
"dest": "READY",
},
{
"source": "CONFIGURING",
"trigger": "configure_rejected_to_idle",
"dest": "IDLE",
},
{
"source": "READY",
"trigger": "end_succeeded",
......@@ -89,11 +79,6 @@ class CspSubElementObsDeviceStateMachine(Machine):
"trigger": "scan_succeeded",
"dest": "READY",
},
{
"source": "SCANNING",
"trigger": "scan_rejected",
"dest": "READY",
},
{
"source": "SCANNING",
"trigger": "scan_failed",
......
......@@ -29,16 +29,6 @@
"to": "IDLE",
"trigger": "end_succeeded"
},
{
"from": "CONFIGURING",
"to": "IDLE",
"trigger": "configure_rejected_to_idle"
},
{
"from": "CONFIGURING",
"to": "READY",
"trigger": "configure_rejected"
},
{
"from": "CONFIGURING",
"to": "READY",
......@@ -94,11 +84,6 @@
"to": "READY",
"trigger": "scan_succeeded"
},
{
"from": "SCANNING",
"to": "READY",
"trigger": "scan_rejected"
},
{
"from": "SCANNING",
"to": "FAULT",
......
......@@ -997,16 +997,6 @@
"to": "READY_ONLINE",
"trigger": "configure_succeeded"
},
{
"from": "CONFIGURING_ONLINE",
"to": "READY_ONLINE",
"trigger": "configure_rejected"
},
{
"from": "CONFIGURING_ONLINE",
"to": "IDLE_ONLINE",
"trigger": "configure_rejected_to_idle"
},
{
"from": "CONFIGURING_ONLINE",
"to": "OBSFAULT_ONLINE",
......@@ -1047,16 +1037,6 @@
"to": "READY_MAINTENANCE",
"trigger": "configure_succeeded"
},
{
"from": "CONFIGURING_MAINTENANCE",
"to": "READY_MAINTENANCE",
"trigger": "configure_rejected"
},
{
"from": "CONFIGURING_MAINTENANCE",
"to": "IDLE_MAINTENANCE",
"trigger": "configure_rejected_to_idle"
},
{
"from": "CONFIGURING_MAINTENANCE",
"to": "OBSFAULT_MAINTENANCE",
......
......@@ -39,7 +39,6 @@ def csp_subelement_obsdevice_state_model():
"""
yield CspSubElementObsDeviceStateModel(logging.getLogger())
@pytest.mark.state_machine_tester(load_state_machine_spec("csp_subelement_obsdevice_state_machine"))
class TestCspSubElementObsDeviceStateModel(ModelStateMachineTester):
"""
......@@ -244,39 +243,19 @@ class TestCspSubElementObsDevice(object):
assert "Error executing command ConfigureScanCommand" in str(df.value.args[0].desc)
# PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_when_in_wrong_state
# PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_when_idle_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_when_idle_decorators
def test_ConfigureScan_with_wrong_input_args_when_idle(self, tango_context):
# PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_decorators
def test_ConfigureScan_with_wrong_input_args(self, tango_context):
"""Test for ConfigureScan when input argument specifies a wrong json configuration
and the device is in IDLE state.
"""
# PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_when_idle) ENABLED START #
tango_context.device.On()
init_obs_state = tango_context.device.obsState
# wrong configurationID key
wrong_configuration = '{"subid":"sbi-mvp01-20200325-00002"}'
with pytest.raises(DevFailed) as df:
tango_context.device.ConfigureScan(wrong_configuration)
assert tango_context.device.obsState == init_obs_state
# PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_when_idle
# PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_when_ready_decorators) ENABLED START #
# PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_wrong_configId_key_decorators
def test_ConfigureScan_with_wrong_input_args_when_ready(self, tango_context):
"""Test for ConfigureScan when json configuration specifies a wrong data and the device is
in ON/READY state.
"""
# PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_when_ready) ENABLED START #
tango_context.device.On()
# wrong configurationID key
valid_configuration = '{"id":"sbi-mvp01-20200325-00002"}'
tango_context.device.ConfigureScan(valid_configuration)
current_obs_state = tango_context.device.obsState
wrong_configuration = '{"subid":"sbi-mvp01-20200325-00002"}'
with pytest.raises(DevFailed) as df:
tango_context.device.ConfigureScan(wrong_configuration)
assert tango_context.device.obsState == current_obs_state
# PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args_when_ready
assert tango_context.device.obsState == ObsState.FAULT
# PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_wrong_input_args
# PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_json_syntax_error) ENABLED START #
# PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_json_syntax_error_decorators
......@@ -284,11 +263,8 @@ class TestCspSubElementObsDevice(object):
"""Test for ConfigureScan when syntax error in json configuration """
# PROTECTED REGION ID(CspSubelementObsDevice.test_ConfigureScan_with_json_syntax_error) ENABLED START #
tango_context.device.On()
init_obs_state = tango_context.device.obsState
with pytest.raises(DevFailed) as df:
tango_context.device.ConfigureScan('{"foo": 1,}')
assert tango_context.device.obsState == init_obs_state
assert tango_context.device.obsState != ObsState.FAULT
assert tango_context.device.obsState == ObsState.FAULT
# PROTECTED REGION END # // CspSubelementObsDevice.test_ConfigureScan_with_json_syntax_error
# PROTECTED REGION ID(CspSubelementObsDevice.test_GoToIdle_decorators) ENABLED START #
......@@ -350,10 +326,8 @@ class TestCspSubElementObsDevice(object):
# Set the device in ON/IDLE state
tango_context.device.On()
tango_context.device.ConfigureScan('{"id":"sbi-mvp01-20200325-00002"}')
current_obs_state = tango_context.device.obsState
with pytest.raises(DevFailed) as df:
tango_context.device.Scan('abc')
assert tango_context.device.obsState == current_obs_state
assert tango_context.device.obsState == ObsState.FAULT
# PROTECTED REGION END # // CspSubelementObsDevice.test_Scan_with_wrong_argument
# PROTECTED REGION ID(CspSubelementObsDevice.test_EndScan_decorators) ENABLED START #
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment