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('low-csp/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 note that the Low CBF is currently deploying 4 subarrays. If 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

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

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

To start the communication use the following command:

csp_ctrl.adminMode = 2  #set to MAINTENANCE

or

csp_ctrl.adminMode = 0  #set to ONLINE

Low CSP.LMC Controller forwards the adminMode value to its Subarrays and subordinated systems devices. The new states are the following for all the devices:

csp_ctrl.state() = ON
csp_ctrl.healthstate = UNKNOWN (It will be fixed to OK in one of the next releases)
csp_sub1.state() = ON
csp_sub1.healthstate = UNKNOWN (It will be fixed to OK in one of the next releases)
csp_sub2.state() = DISABLE (It will be fixed to FAULT in one of the next releases)
csp_sub2.healthstate = UNKNOWN (It will be fixed to FAILED in one of the next releases)
csp_sub3.state() = DISABLE (It will be fixed to FAULT in one of the next releases)
csp_sub3.healthstate = UNKNOWN (It will be fixed to FAILED in one of the next releases)
cbf_ctrl.state() = ON
cbf_sub1.state() = ON

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

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

Note

CBF Devices start in ON state and so CSP. Anyway the command ON can be still meaningful for turning on other subsystems. If only cbf is present, this section can be dropped

To power-on all the device, send the ON command towards the Low.CSP Controller. The sub-systems already in ON state will be skipped by the command.

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

or

csp_ctrl.On(['low-pst/beam/01', ]) # power-on only the specified sub-systems

The command returns immediately the following list:

[array([2], dtype=int32), ['1679401117.9451234_224758016395799_On']]
Where:
  • 2 is the command status (2 means QUEUED)

  • ‘1679401117.9451234_224758016395799_On’ is a unique id assigned to the command. It can be used to track the execution status of the command

It is possible to read the command result state using:

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:

csp_sub1.assignresources(json_string)

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. When CBF is in simulation mode (i.e. all the deployment except th PSI-LOW) some preliminar operation are needed before configuring the subarray. In particular, a serial number has to be assigned to the low-cbf processor device and this one subscribed by the low-cbf allocator. To do this:

processor1 = tango.DeviceProxy("low-cbf/processor/0.0.0")
processor1.serialnumber = "XFL14SLO1LIF"
processor1.subscribetoallocator("low-cbf/allocator/0")
processor1.register()

If this is not performed, the configure command will fail.

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:

csp_sub1.configure(json_string_configure)

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:

csp_sub1.scan(json_string_scan)

if the command is successful:

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

It as been decided that the command ‘scan’ has to be considered as a normal command that return the status 0 when all the subsystems are moved to SCANNING status. The scan behavior is documented in Scan handling . 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:

csp_sub1.endscan()

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.abort()
csp_sub1.commandResult -> ('abort', '1')
csp_sub1.obsstate -> ABORTING
csp_sub1.commandResult -> ('abort', '0')
csp_sub1.obsstate -> ABORTED
csp_sub1.obsreset()
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:

csp_sub1.gotoidle()

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.

csp_sub1.releaseresources(json_string)

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:

csp_sub1.releaseallresources()

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.restart()

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.