Tango Clients Examples

Basic assumptions for each example are:

  1. the system has been fresh initialized

  2. the only CSP sub-system deployed is the CBF

  3. All TANGO operations (read/write/command_inout) are always successfully. No check on the results is done in the following examples.

To get instruction on how to deploy a working system, please refer to the project’s README.

Be sure that both the charts for ska-low-cbf and ska-low-cbf-proc, as stated in the ‘low-umbrella-chart’ are deployed.

To control CSP with itango, a proxy to CSP Controller and Subarrays has to be created:

csp_ctrl = tango.DeviceProxy('low-csp/control/0')
csp_sub1 = tango.DeviceProxy('low-csp/subarray/01')
csp_sub2 = tango.DeviceProxy('low-csp/subarray/02')
csp_sub3 = tango.DeviceProxy('lowcsp/subarray/03')

It is possible also to create proxies to CBF controller and subarrays, in order to check their states and mode after the command is issued:

cbf_ctrl = tango.DeviceProxy('low-cbf/control/0')
cbf_sub1 = tango.DeviceProxy('low-cbf/subarray/01')
cbf_sub2 = tango.DeviceProxy('low-cbf/subarray/02')
cbf_sub3 = tango.DeviceProxy('low-cbf/subarray/03')

Please check the number of subarrays deployed by Low CBF: f a Low CBF subarray is not deployed, the corresponding Low CSP.LMC subarray state is FAULT and can’t be used for operations.

Also note that all commands on subarray follow the ObsState state model defined in ADR-8. CSP/LMC doesn’t allow commands from obstate other than those specified in this model.

From now on, all the examples refers to these proxy objects. For Subarray commands, the proxy to subarray 1 will be used.

Low CSP.LMC state after deployed

After deployment, Low CSP.LMC Controller and Subarrays are in DISABLE state.

Low CSP.LMC Controller does not currently forward the adminMode value to its Subarrays and subordinated systems devices. This is an issue that will be fixed in a future release.

Low CSP.LMC Controller and Subarrays adminMode have to be set to MAINTENANCE to start the connection with the subordinate Low CBF TANGO Devices.

In the current deployment (see low-csp-umbrella to get the charts versions) Low CBF deploys only one subarray and the state and modes of the Low.CSP Controller and Subarrays after the deployment are:

csp_ctrl.state() = DISABLE
csp_sub1.state() = DISABLE
csp_sub2.state() = DISABLE
csp_sub3.state() = DISABLE
csp_ctrl.healthstate = UNKNOWN
csp_sub1.healthstate = UNKNOWN
csp_sub2.healthstate = UNKNOWN
csp_sub3.healthstate = UNKNOWN
csp_ctrl.adminMode = OFFLINE
csp_sub1.adminMode = OFFLINE
csp_sub2.adminMode = OFFLINE
csp_sub3.adminMode = OFFLINE
csp_sub1.obsstate = EMPTY
csp_sub2.obsstate = EMPTY
csp_sub3.obsstate = EMPTY

Start communication between the Low CSP.LMC Controller and its subordinate sub-systems setting the CSP.LMC devices adminMode equal to MAINTENANCE (2):

csp_ctrl.adminMode = 2
csp_sub1.adminMode = 2
csp_sub2.adminMode = 2
csp_sub3.adminMode = 2
csp_ctr.state() = OFF
csp_ctrl.healthstate = OK
csp_sub1.state() = OFF
csp_sub1.healthstate = OK
csp_sub2.state() = FAULT
csp_sub2.healthstate = FAILED
csp_sub3.state() = FAULT
csp_sub3.healthstate = FAILED

Low CSP.LMC Subarray 2 and 3 are in FAULT because the corresponding Low CBF subarrays are not deployed.

Power-on (off/standby) the Low.CSP

Open a proxy towards the Low.CSP Controller:

csp_ctrl.On([]) # empty list: power on all the available sub-systems (CBF, PSS, PST)


csp_ctrl.On(['low-cbf/control/0', ]) # power-on only the specified sub-systems

cmd_result = csp_ctrl.commandResult

cmd_result is a Tuple of two strings:

  • the first one is the name of last executed CSP task

  • the second one is the result code: allowed values for the result code are defined in SKA Base Classes module ska_tango_base.commands

Possible results for the current example are:

  • (‘on’, ‘0’) # On task completed successfully

  • (‘on’, ‘1’) # On task started

  • (‘on’, ‘3’) # On task completed with failure

Some of the long running command attributes can also be accessed. Long running command result can be read using:

long_running_command_result = csp_ctrl.longRunningCommandResult

long_running_command_result is a Tuple of a string and a list:

  • the first element is a command id assigned when command is invoked

  • the second element is a list of result code (matching the value in command result attribute described above) and result message

Possible results:

  • (‘1684312814.139426_265125881596693_On’, ‘[0, “on completed 1/1”]’) # On task completed successfully on one devices

  • (‘1684312814.139426_265125881596693_Configure’, ‘[0, “configure completed on components 2/2”]’) # Configure task completed successfully on two devices

  • (‘1684312814.139426_265125881596693_Off’, ‘[3, “off completed 1/1”]’) # Off task completed with failure on one device

It is also possible to access long running command status at the various stages of command execution. This attribute can be read using:

long_running_command_status = csp_ctrl.longRunningCommandStatus

long_running_command_status is a Tuple of pairs of strings. In each pair the elements represent the following:

  • the first element is a command id assigned when command is invoked

  • the second element is the task status: allowed values for the task status are defined in SKA Base Classes module ska_tango_base.executor

Possible results:

  • (‘1684312814.139426_265125881596693_On’, ‘QUEUED’)

  • (‘1684312814.139426_265125881596693_On’, ‘IN_PROGRESS’)

  • (‘1684312814.139426_265125881596693_On’, ‘COMPLETED’)

  • (‘1684312814.139426_265125881596693_On’, ‘ABORTED’)

  • (‘1684312814.139426_265125881596693_On’, ‘FAILED’)

  • (‘1684312814.139426_265125881596693_On’, ‘REJECTED’)

Note that there can be more than one pair of command id and task status in the attribute, if there are more commands invoked.

The command On invoked on the Low.CSP Controller is forwarded to the CBF sub-system Controller and to all the Low.CSP Subarrays. This can be checked by the state of all controllers and subarrays:

csp_ctrl.state() -> ON
csp_sub1.state() -> ON
csp_sub1.state() -> ON
csp_sub1.state() -> ON

cbf_ctrl.state() -> ON
cbf_sub1.state() -> ON
cbf_sub1.state() -> ON
cbf_sub1.state() -> ON

The same logic and syntax apply also for Off and Standby command

Assign resources to the Low.CSP Subarray

To assign resources on a subarray both the subarray and controller are needed to be on. To do this please follow the previous example.

A json_string variable needs to be create containing the proper json structure for assignment of resources. A working template can be found here

Invoke the AssignResources command on Low.CSP Subarray 1:


If command is successful, the command result will report:

csp_sub1.commandResult -> ('assignresources', '0')

csp_sub1.commandResultName -> 'assignresources'
csp_sub1.commandResultCode -> '0'

After the assignment of resources the CSP.LMC and CBF Subarray osbstate move from EMPTY to IDLE. It can be checked by:

csp_sub1.obsstate -> IDLE
cbf_sub1.obsstate -> IDLE

Configure, issue and end a Scan

After the Subarray has resources assigned, it is possible to configure and run a scan on the Subarray.

The json_string to be used for configure and scan can be found here. They have to be assigned to a variable and send as a command input as showed above for assignresources.

First of all, Configure command has to be issued:


The obsstate will be in CONFIGURING during the execution. After that, if the command is successful:

csp_sub1.commandResult -> ('configure', '0')
csp_sub1.obsstate -> READY
cbf_sub1.obsstate -> READY

A new configuration can be sent also in READY state, overwriting the old one.

After the subarray is READY, a scan can be issued:


if the command is successful:

csp_sub1.commandResult -> ('scan', '1')
csp_sub1.obsstate -> SCANNING
cbf_sub1.obsstate -> SCANNING

Please note that the resultCode of scan will remain ‘1’ for all the duration of Scanning process. In fact, According to ADR-8 a Scan can be interrupted by the EndScan Command or the Abort Command. The Abort Command has to be intended as an emergency call that interrupts abruptly the Scan process. On the other side, the EndScan first ensure that all the processes are correctly managed.

To end a scan, just issue:


After End Scan is successful, the ObState of subarray is READY, and another Scan can be issued with the same configuration.

On the other side, if the Scan is aborted, the obsstate will go (after a short time in ABORTING) to be ABORTED. To perform a new scanning, the subarray observation should be restarted (via the ObsReset command) and a new configuration need to be sent ( ADR-8)

The sequence of operation is:

csp_sub1.commandResult -> ('abort', '1')
csp_sub1.obsstate -> ABORTING
csp_sub1.commandResult -> ('abort', '0')
csp_sub1.obsstate -> ABORTED
csp_sub1.commandResult -> ('obsreset', '1')
csp_sub1.obsstate -> RESETTING
csp_sub1.commandResult -> ('obsreset', '0')
csp_sub1.obsstate -> IDLE

Go To Idle and Release Resources

The release of the resources of a subarray can be done only in IDLE obsstate. For this reason, if the subarray is in READY firstly must be sent to IDLE with the command:


if the command is successful, the obsstate will be IDLE. After that, the resources can be partially or totally removed. To partially remove some resources, a json string, like the one used for assign resources (see above) should be sent. In this string, please specify the resources to be removed.


On command success:

csp_sub1.commandResult -> ('releaseresources', '0')
csp_sub1.obsstate -> IDLE

Otherwise, if all resources are meant to be removed, this can be done with the ReleaseAllResouces command:


On command success, the subarray will be EMPTY again, and some resouces need to be added to perform a new operation:

csp_sub1.commandResult -> ('releaseallresources', '0')
csp_sub1.obsstate -> EMPTY

csp_sub1.assignedReceptors -> []

Recover from FAULT ObsState: Restart

If something goes wrong in the observation, the ObsState of CSP.LMC could go in FAULT. Please note that this not refers to the case of the Tango Device has an internal error and the DevState goed in FAULT (see next for this case). To recover from this situation, the restart command is issued. This command will release also all the resources, taking the subarray in an EMPTY obstate.

The sequence of operations and responses is:

csp_sub1.obsstate -> FAULT


csp_sub1.commandResult -> ('restart', '1')
csp_sub1.obsstate -> RESTARTING
csp_sub1.commandResult -> ('restart', '0')
csp_sub1.obsstate -> EMPTY

Recover from FAULT DevState: Reset

Both Subarray and Controller, if experience an error internal to TANGO Device, will go in FAULT DevState. To recover from it, the Reset command needs to be issued. This will bring the device in its initial state, i.e. OFF/EMPTY for Subarray and STANDBY for the Controller

Turning OFF the subarray

The Off command disables any signal processing capability of a subarray and all its allocated resources are also released. As for the ADR-8, this command can be issued fron any observing state.

Depending on the current observing state of the Mid CSP.LMC Subarray, the Off command can be replaced by a sequence of commands that properly bring the device in the desired final state. An approach that works for nearly all the observing states is the following one, where the Off command is replaced by the following commands, executed one after the other:

  • Abort: transition the subarray from the current observing state to ABORTED. This command can be issued from all the observing states except: EMPTY

and FAULT. In these cases, this step is skipped and the first command invoked must be Restart. * Restart: transition the subarray from ABORTED to EMPTY/ON * Off: transition the subarray from ON to OFF.