Device
DeviceImpl
- class tango.LatestDeviceImpl(*args)
Latest implementation of the TANGO device base class (alias for Device_6Impl).
It inherits from CORBA classes where all the network layer is implemented.
- add_attribute(self, attr, r_meth=None, w_meth=None, is_allo_meth=None) Attr
Add a new attribute to the device attribute list.
Please, note that if you add an attribute to a device at device creation time, this attribute will be added to the device class attribute list. Therefore, all devices belonging to the same class created after this attribute addition will also have this attribute.
If you pass a reference to unbound method for read, write or is_allowed method (e.g. DeviceClass.read_function or self.__class__.read_function), during execution the corresponding bound method (self.read_function) will be used.
Note: Calling the synchronous add_attribute method from a coroutine function in an asyncio server may cause a deadlock. Use
await
async_add_attribute()
instead. However, if overriding the synchronous methodinitialize_dynamic_attributes
, then the synchronous add_attribute method must be used, even in asyncio servers.- Parameters:
attr (server.attribute or Attr or AttrData) – the new attribute to be added to the list.
r_meth (callable) – the read method to be called on a read request (if attr is of type server.attribute, then use the fget field in the attr object instead)
w_meth (callable) – the write method to be called on a write request (if attr is writable) (if attr is of type server.attribute, then use the fset field in the attr object instead)
is_allo_meth (callable) – the method that is called to check if it is possible to access the attribute or not (if attr is of type server.attribute, then use the fisallowed field in the attr object instead)
- Returns:
the newly created attribute.
- Return type:
- Raises:
- add_command(self, cmd, device_level=True) cmd
Add a new command to the device command list.
- Parameters:
cmd – the new command to be added to the list
device_level – Set this flag to true if the command must be added for only this device
- Returns:
The command to add
- Return type:
Command
- Raises:
- add_version_info(self, key, value) dict
Method to add information about the module version a device is using
New in version 10.0.0.
- always_executed_hook(self)
Hook method.
Default method to implement an action necessary on a device before any command is executed. This method can be redefined in sub-classes in case of the default behaviour does not fullfill the needs
- Raises:
DevFailed – This method does not throw exception but a redefined method can.
- append_status(self, status, new_line=False)
Appends a string to the device status.
- async async_add_attribute(self, attr, r_meth=None, w_meth=None, is_allo_meth=None) Attr
Add a new attribute to the device attribute list.
Please, note that if you add an attribute to a device at device creation time, this attribute will be added to the device class attribute list. Therefore, all devices belonging to the same class created after this attribute addition will also have this attribute.
If you pass a reference to unbound method for read, write or is_allowed method (e.g. DeviceClass.read_function or self.__class__.read_function), during execution the corresponding bound method (self.read_function) will be used.
- Parameters:
attr (server.attribute or Attr or AttrData) – the new attribute to be added to the list.
r_meth (callable) – the read method to be called on a read request (if attr is of type server.attribute, then use the fget field in the attr object instead)
w_meth (callable) – the write method to be called on a write request (if attr is writable) (if attr is of type server.attribute, then use the fset field in the attr object instead)
is_allo_meth (callable) – the method that is called to check if it is possible to access the attribute or not (if attr is of type server.attribute, then use the fisallowed field in the attr object instead)
- Returns:
the newly created attribute.
- Return type:
- Raises:
New in version 10.0.0.
- async async_remove_attribute(self, attr_name, free_it=False, clean_db=True)
Remove one attribute from the device attribute list.
- Parameters:
- Raises:
New in version 10.0.0.
- check_command_exists(self)
Check that a command is supported by the device and does not need input value.
The method throws an exception if the command is not defined or needs an input value.
- Parameters:
cmd_name (str) – the command name
- Raises:
API_IncompatibleCmdArgumentType –
API_CommandNotFound –
New in PyTango 7.1.2
- debug_stream(self, msg, *args, source=None)
Sends the given message to the tango debug stream.
Since PyTango 7.1.3, the same can be achieved with:
print(msg, file=self.log_debug)
- Parameters:
msg (str) – the message to be sent to the debug stream
*args – Arguments to format a message string.
source (Callable) – Function that will be inspected for filename and lineno in the log message.
New in version 9.4.2: added source parameter
- delete_device(self)
Delete the device.
- dev_state(self) DevState
Get device state.
Default method to get device state. The behaviour of this method depends on the device state. If the device state is ON or ALARM, it reads the attribute(s) with an alarm level defined, check if the read value is above/below the alarm and eventually change the state to ALARM, return the device state. For all th other device state, this method simply returns the state This method can be redefined in sub-classes in case of the default behaviour does not fullfill the needs.
- dev_status(self) str
Get device status.
Default method to get device status. It returns the contents of the device dev_status field. If the device state is ALARM, alarm messages are added to the device status. This method can be redefined in sub-classes in case of the default behaviour does not fullfill the needs.
- error_stream(self, msg, *args, source=None)
Sends the given message to the tango error stream.
Since PyTango 7.1.3, the same can be achieved with:
print(msg, file=self.log_error)
- Parameters:
msg (str) – the message to be sent to the error stream
*args – Arguments to format a message string.
source (Callable) – Function that will be inspected for filename and lineno in the log message.
New in version 9.4.2: added source parameter
- fatal_stream(self, msg, *args, source=None)
Sends the given message to the tango fatal stream.
Since PyTango 7.1.3, the same can be achieved with:
print(msg, file=self.log_fatal)
- Parameters:
msg (str) – the message to be sent to the fatal stream
*args – Arguments to format a message string.
source (Callable) – Function that will be inspected for filename and lineno in the log message.
New in version 9.4.2: added source parameter
- get_attr_min_poll_period(self) Sequence[str]
Returns the min attribute poll period
- Returns:
the min attribute poll period
- Return type:
Sequence[str]
New in PyTango 7.2.0
- get_attr_poll_ring_depth(self, attr_name) int
Returns the attribute poll ring depth.
- Parameters:
attr_name (str) – the attribute name
- Returns:
the attribute poll ring depth
- Return type:
New in PyTango 7.1.2
- get_attribute_config(self, attr_names) list[DeviceAttributeConfig]
Returns the list of AttributeConfig for the requested names
- Parameters:
attr_names (list[str]) – sequence of str with attribute names
- Returns:
tango.DeviceAttributeConfig
for each requested attribute name- Return type:
- get_attribute_config_2(self, attr_names) list[AttributeConfig_2]
Returns the list of AttributeConfig_2 for the requested names
- get_attribute_config_3(self, attr_name) list[AttributeConfig_3]
Returns the list of AttributeConfig_3 for the requested names
- get_attribute_poll_period(self, attr_name) int
Returns the attribute polling period (ms) or 0 if the attribute is not polled.
- Parameters:
attr_name (str) – attribute name
- Returns:
attribute polling period (ms) or 0 if it is not polled
- Return type:
New in PyTango 8.0.0
- get_cmd_min_poll_period(self) Sequence[str]
Returns the min command poll period.
- Returns:
the min command poll period
- Return type:
Sequence[str]
New in PyTango 7.2.0
- get_cmd_poll_ring_depth(self, cmd_name) int
Returns the command poll ring depth.
New in PyTango 7.1.2
- get_command_poll_period(self, cmd_name) int
Returns the command polling period (ms) or 0 if the command is not polled.
- Parameters:
cmd_name (str) – command name
- Returns:
command polling period (ms) or 0 if it is not polled
- Return type:
New in PyTango 8.0.0
- get_dev_idl_version(self) int
Returns the IDL version.
- Returns:
the IDL version
- Return type:
New in PyTango 7.1.2
- get_device_attr(self) MultiAttribute
Get device multi attribute object.
- Returns:
the device’s MultiAttribute object
- Return type:
- get_device_class(self)
Get device class singleton.
- Returns:
the device class singleton (device_class field)
- Return type:
- get_device_properties(self, ds_class=None)
Utility method that fetches all the device properties from the database and converts them into members of this DeviceImpl.
- Parameters:
ds_class (DeviceClass) – the DeviceClass object. Optional. Default value is None meaning that the corresponding DeviceClass object for this DeviceImpl will be used
- Raises:
- get_exported_flag(self) bool
Returns the state of the exported flag
- Returns:
the state of the exported flag
- Return type:
New in PyTango 7.1.2
- get_logger(self) Logger
Returns the Logger object for this device
- Returns:
the Logger object for this device
- Return type:
Logger
- get_min_poll_period(self) int
Returns the min poll period.
- Returns:
the min poll period
- Return type:
New in PyTango 7.2.0
- get_non_auto_polled_attr(self) Sequence[str]
Returns a COPY of the list of non automatic polled attributes
- Returns:
a COPY of the list of non automatic polled attributes
- Return type:
Sequence[str]
New in PyTango 7.1.2
- get_non_auto_polled_cmd(self) Sequence[str]
Returns a COPY of the list of non automatic polled commands
- Returns:
a COPY of the list of non automatic polled commands
- Return type:
Sequence[str]
New in PyTango 7.1.2
- get_poll_old_factor(self) int
Returns the poll old factor
- Returns:
the poll old factor
- Return type:
New in PyTango 7.1.2
- get_poll_ring_depth(self) int
Returns the poll ring depth
- Returns:
the poll ring depth
- Return type:
New in PyTango 7.1.2
- get_polled_attr(self) Sequence[str]
Returns a COPY of the list of polled attributes
- Returns:
a COPY of the list of polled attributes
- Return type:
Sequence[str]
New in PyTango 7.1.2
- get_polled_cmd(self) Sequence[str]
Returns a COPY of the list of polled commands
- Returns:
a COPY of the list of polled commands
- Return type:
Sequence[str]
New in PyTango 7.1.2
- get_prev_state(self) DevState
Get a COPY of the device’s previous state.
- Returns:
the device’s previous state
- Return type:
- get_state(self) DevState
Get a COPY of the device state.
- Returns:
Current device state
- Return type:
- get_version_info(self) dict
Returns a dict with versioning of different modules related to the pytango device.
- Example:
{ "Build.PyTango.Boost": "1.84.0", "Build.PyTango.NumPy": "1.26.4", "Build.PyTango.Python": "3.12.2", "Build.PyTango.cppTango":"10.0.0", "NumPy": "1.26.4", "PyTango": "10.0.0.dev0", "Python": "3.12.2", "cppTango": "10.0.0", "omniORB": "4.3.2", "zmq": "4.3.5" }
- Returns:
modules version dict
- Return type:
New in version 10.0.0.
- info_stream(self, msg, *args, source=None)
Sends the given message to the tango info stream.
Since PyTango 7.1.3, the same can be achieved with:
print(msg, file=self.log_info)
- Parameters:
msg (str) – the message to be sent to the info stream
*args – Arguments to format a message string.
source (Callable) – Function that will be inspected for filename and lineno in the log message.
New in version 9.4.2: added source parameter
- init_device(self)
Intialize the device.
- is_device_locked(self) bool
Returns if this device is locked by a client.
- Returns:
True if it is locked or False otherwise
- Return type:
New in PyTango 7.1.2
- is_kernel_tracing_enabled(self) bool
Indicates if telemetry tracing of the cppTango kernel API is enabled.
Always False if telemetry support isn’t compiled into cppTango.
- Returns:
if kernel tracing is enabled
- Return type:
New in version 10.0.0.
- is_polled(self) bool
Returns if it is polled
- Returns:
True if it is polled or False otherwise
- Return type:
New in PyTango 7.1.2
- is_telemetry_enabled(self) bool
Indicates if telemetry tracing is enabled for the device.
Always False if telemetry support isn’t compiled into cppTango.
- Returns:
if device telemetry tracing is enabled
- Return type:
New in version 10.0.0.
- is_there_subscriber(self, att_name, event_type) bool
Check if there is subscriber(s) listening for the event.
This method returns a boolean set to true if there are some subscriber(s) listening on the event specified by the two method arguments. Be aware that there is some delay (up to 600 sec) between this method returning false and the last subscriber unsubscription or crash…
The device interface change event is not supported by this method.
- push_alarm_event(attr_name, *args, **kwargs)
- push_alarm_event(self, attr_name, except)
- push_alarm_event(self, attr_name, data, dim_x=1, dim_y=0)
- push_alarm_event(self, attr_name, str_data, data)
- push_alarm_event(self, attr_name, data, time_stamp, quality, dim_x=1, dim_y=0)
- push_alarm_event(self, attr_name, str_data, data, time_stamp, quality)
Push an alarm event for the given attribute name.
- Parameters:
attr_name (str) – attribute name
data – the data to be sent as attribute event data. Data must be compatible with the attribute type and format. for SPECTRUM and IMAGE attributes, data can be any type of sequence of elements compatible with the attribute type
str_data (str) – special variation for DevEncoded data type. In this case ‘data’ must be a str or an object with the buffer interface.
except (DevFailed) – Instead of data, you may want to send an exception.
dim_x (int) – the attribute x length. Default value is 1
dim_y (int) – the attribute y length. Default value is 0
time_stamp (double) – the time stamp
quality (AttrQuality) – the attribute quality factor
- Raises:
DevFailed – If the attribute data type is not coherent.
- push_archive_event(attr_name, *args, **kwargs)
- push_archive_event(self, attr_name, except)
- push_archive_event(self, attr_name, data, dim_x=1, dim_y=0)
- push_archive_event(self, attr_name, str_data, data)
- push_archive_event(self, attr_name, data, time_stamp, quality, dim_x=1, dim_y=0)
- push_archive_event(self, attr_name, str_data, data, time_stamp, quality)
Push an archive event for the given attribute name.
- Parameters:
attr_name (str) – attribute name
data – the data to be sent as attribute event data. Data must be compatible with the attribute type and format. for SPECTRUM and IMAGE attributes, data can be any type of sequence of elements compatible with the attribute type
str_data (str) – special variation for DevEncoded data type. In this case ‘data’ must be a str or an object with the buffer interface.
except (DevFailed) – Instead of data, you may want to send an exception.
dim_x (int) – the attribute x length. Default value is 1
dim_y (int) – the attribute y length. Default value is 0
time_stamp (double) – the time stamp
quality (AttrQuality) – the attribute quality factor
- Raises:
DevFailed – If the attribute data type is not coherent.
- push_att_conf_event(self, attr)
Push an attribute configuration event.
- Parameters:
attr (Attribute) – the attribute for which the configuration event will be sent.
New in PyTango 7.2.1
- push_change_event(attr_name, *args, **kwargs)
- push_change_event(self, attr_name, except)
- push_change_event(self, attr_name, data, dim_x=1, dim_y=0)
- push_change_event(self, attr_name, str_data, data)
- push_change_event(self, attr_name, data, time_stamp, quality, dim_x=1, dim_y=0)
- push_change_event(self, attr_name, str_data, data, time_stamp, quality)
Push a change event for the given attribute name.
- Parameters:
attr_name (str) – attribute name
data – the data to be sent as attribute event data. Data must be compatible with the attribute type and format. for SPECTRUM and IMAGE attributes, data can be any type of sequence of elements compatible with the attribute type
str_data (str) – special variation for DevEncoded data type. In this case ‘data’ must be a str or an object with the buffer interface.
except (DevFailed) – Instead of data, you may want to send an exception.
dim_x (int) – the attribute x length. Default value is 1
dim_y (int) – the attribute y length. Default value is 0
time_stamp (double) – the time stamp
quality (AttrQuality) – the attribute quality factor
- Raises:
DevFailed – If the attribute data type is not coherent.
- push_data_ready_event(self, attr_name, counter)
Push a data ready event for the given attribute name.
The method needs the attribute name and a “counter” which will be passed within the event
- push_event(attr_name, filt_names, filt_vals, *args, **kwargs)
- push_event(self, attr_name, filt_names, filt_vals, except)
- push_event(self, attr_name, filt_names, filt_vals, data, dim_x=1, dim_y=0)
- push_event(self, attr_name, filt_names, filt_vals, str_data, data)
- push_event(self, attr_name, filt_names, filt_vals, data, time_stamp, quality, dim_x=1, dim_y=0)
- push_event(self, attr_name, filt_names, filt_vals, str_data, data, time_stamp, quality)
Push a user event for the given attribute name.
- Parameters:
attr_name (str) – attribute name
filt_names (Sequence[str]) – unused (kept for backwards compatibility) - pass an empty list.
filt_vals (Sequence[double]) – unused (kept for backwards compatibility) - pass an empty list.
data – the data to be sent as attribute event data. Data must be compatible with the attribute type and format. for SPECTRUM and IMAGE attributes, data can be any type of sequence of elements compatible with the attribute type
str_data (str) – special variation for DevEncoded data type. In this case ‘data’ must be a str or an object with the buffer interface.
dim_x (int) – the attribute x length. Default value is 1
dim_y (int) – the attribute y length. Default value is 0
time_stamp (double) – the time stamp
quality (AttrQuality) – the attribute quality factor
- Raises:
DevFailed – If the attribute data type is not coherent.
- push_pipe_event(self, blob)
Push an pipe event.
- Parameters:
blob – the blob which pipe event will be send.
New in PyTango 9.2.2
- read_attr_hardware(self, attr_list)
Read the hardware to return attribute value(s).
Default method to implement an action necessary on a device to read the hardware involved in a read attribute CORBA call. This method must be redefined in sub-classes in order to support attribute reading
- register_signal(self, signo)
Register a signal.
Register this device as device to be informed when signal signo is sent to to the device server process
- Parameters:
signo (int) – signal identifier
- remove_attribute(self, attr_name)
Remove one attribute from the device attribute list.
Note: Call of synchronous remove_attribute method from a coroutine function in an asyncio server may cause a deadlock. Use
await
async_remove_attribute()
instead. However, if overriding the synchronous methodinitialize_dynamic_attributes
, then the synchronous remove_attribute method must be used, even in asyncio servers.- Parameters:
- Raises:
New in version 9.5.0: free_it parameter. clean_db parameter.
- remove_command(self, cmd_name, free_it=False, clean_db=True)
Remove one command from the device command list.
- server_init_hook(self)
Hook method.
This method is called once the device server admin device is exported. This allows for instance for the different devices to subscribe to events at server startup on attributes from other devices of the same device server with stateless parameter set to false.
This method can be redefined in sub-classes in case of the default behaviour does not fullfill the needs
New in version 9.4.2.
- set_archive_event(self, attr_name, implemented, detect=True)
Set an implemented flag for the attribute to indicate that the server fires archive events manually, without the polling to be started.
If the detect parameter is set to true, the criteria specified for the archive event are verified and the event is only pushed if they are fullfilled. If detect is set to false the event is fired without any value checking!
- set_attribute_config(self, new_conf) None
Sets attribute configuration locally and in the Tango database
- Parameters:
new_conf (list[
tango.AttributeConfig
]) – The new attribute(s) configuration. One AttributeConfig structure is needed for each attribute to update- Returns:
None
- Return type:
None
New in version 10.0.0.
- set_attribute_config_3(self, new_conf) None
Sets attribute configuration locally and in the Tango database
- Parameters:
new_conf (list[
tango.AttributeConfig_3
]) – The new attribute(s) configuration. One AttributeConfig structure is needed for each attribute to update- Returns:
None
- Return type:
None
- set_change_event(self, attr_name, implemented, detect=True)
Set an implemented flag for the attribute to indicate that the server fires change events manually, without the polling to be started.
If the detect parameter is set to true, the criteria specified for the change event are verified and the event is only pushed if they are fullfilled. If detect is set to false the event is fired without any value checking!
- set_data_ready_event(self, attr_name, implemented)
Set an implemented flag for the attribute to indicate that the server fires data ready events manually.
- set_kernel_tracing_enabled(self, enabled) None
Enable or disable telemetry tracing of cppTango kernel methods, and for high-level PyTango devices, tracing of the PyTango kernel (BaseDevice) methods.
This is a no-op if telemetry support isn’t compiled into cppTango.
- Parameters:
enabled (bool) – True to enable kernel tracing
New in version 10.0.0.
- set_state(self, new_state)
Set device state.
- Parameters:
new_state (DevState) – the new device state
- set_status(self, new_status)
Set device status.
- Parameters:
new_status (str) – the new device status
- set_telemetry_enabled(self, enabled) None
Enable or disable the device’s telemetry interface.
This is a no-op if telemetry support isn’t compiled into cppTango.
- Parameters:
enabled (bool) – True to enable telemetry tracing
New in version 10.0.0.
- signal_handler(self, signo)
Signal handler.
The method executed when the signal arrived in the device server process. This method is defined as virtual and then, can be redefined following device needs.
- stop_poll_attribute(self, attr_name) None
Remove an attribute from the list of polled attributes.
- Parameters:
attr_name (str) – attribute name
- Returns:
None
- Return type:
None
- stop_poll_command(self, cmd_name) None
Remove a command from the list of polled commands.
- Parameters:
cmd_name (str) – cmd_name name
- Returns:
None
- Return type:
None
- stop_polling(self)
- stop_polling(self, with_db_upd)
Stop all polling for a device. if the device is polled, call this method before deleting it.
- Parameters:
with_db_upd (bool) – Is it necessary to update db?
New in PyTango 7.1.2
- unregister_signal(self, signo)
Unregister a signal.
Unregister this device as device to be informed when signal signo is sent to to the device server process
- Parameters:
signo (int) – signal identifier
- warn_stream(self, msg, *args, source=None)
Sends the given message to the tango warn stream.
Since PyTango 7.1.3, the same can be achieved with:
print(msg, file=self.log_warn)
- Parameters:
msg (str) – the message to be sent to the warn stream
*args – Arguments to format a message string.
source (Callable) – Function that will be inspected for filename and lineno in the log message.
New in version 9.4.2: added source parameter
- write_attr_hardware(self)
Write the hardware for attributes.
Default method to implement an action necessary on a device to write the hardware involved in a write attribute. This method must be redefined in sub-classes in order to support writable attribute