How to tune polling by code in a TANGO class¶
Intended audience: advanced developers,
This HowTo explains how it is easily possible to tune attribute or command polling parameters in the code of a Tango class
Since Tango 8, it is possible to configure command or attribute polling within a Tango class code. A new set of polling related methods has been added to the base class Tango::DeviceImpl. These methods are similar to those you find in the Tango::DeviceProxy class when you write a Tango client. With them, you can
- Check if a command or attribute is polled
- Start/Stop polling for a command or a attribute
- Get or update polling period for a polled attribute or command
In C++¶
Programming language: c++
To display some information related to polling of the attribute named TheAtt:
1 2 3 4 5 6 7 | string att_name("TheAtt");
cout << "Attribute " << att_name;
if (is_attribute_polled(att_name) == true)
cout << " is polled with period " << get_attribute_poll_period(att_name) << " mS" << endl;
else
cout << " is not polled" << endl;
|
To poll a command simply type:
1 | poll_command("TheCmd",250);
|
If the command is already polled, this method will update its polling period to 250 mS. Finally, to stop polling the same command, type:
1 | stop_poll_command("TheCmd");
|
All these DeviceImpl polling related methods are documented in the DeviceImpl class documentation page
In Python¶
Programming language: python
To display some information related to polling of the attribute named TheAtt, in a DeviceImpl context type:
1 2 3 4 5 6 | att_name = "TheAtt"
if self.is_attribute_polled(att_name):
print("{0} is polled with period {1} ms".format(att_name, self.get_attribute_poll_period(att_name))
else:
print("{0} is not polled".format(att_name))
|
To poll a command, in a DeviceImpl context, simply type:
1 | self.poll_command("TheCmd", 250)
|
If the command is already polled, this method will update its polling period to 250 mS. Finally, to stop polling the same command, in a DeviceImpl context type:
1 | self.stop_poll_command("TheCmd")
|
All these DeviceImpl polling related methods are documented in the PyTango DeviceImpl class documentation page.
In Java¶
Programming language: java
The polling can be retrieved and modified from the DeviceManager class. Here is an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import org.tango.server.annotation.Device;
import org.tango.server.annotation.DeviceManagement;
import org.tango.server.device.DeviceManager;
import fr.esrf.Tango.DevFailed;
@Device
public class Test {
@DeviceManagement
private DeviceManager deviceManager;
...
final String attName = "TheAttr";
if (deviceManager.isPolled(attName)) {
System.out.println(attName + " is polled with period " + deviceManager.getPollingPeriod(attName) + " mS");
} else {
System.out.println(attName + " is not polled");
}
deviceManager.startPolling("TheCmd", 250);
deviceManager.stopPolling("TheCmd")
...
public void setDeviceManager(final DeviceManager deviceManager) {
this.deviceManager = deviceManager;
}
}
|