DeviceProxy

Contents

DeviceProxy#

class tango.DeviceProxy(*args, green_mode=None, executor=None, threadpool=None, asyncio_executor=None)#

Bases: Connection

DeviceProxy is the high level Tango object which provides the client with an easy-to-use interface to TANGO devices. DeviceProxy provides interfaces to all TANGO Device interfaces.The DeviceProxy manages timeouts, stateless connections and reconnection if the device server is restarted. To create a DeviceProxy, a Tango Device name must be set in the object constructor.

Example :

dev = tango.DeviceProxy(“sys/tg_test/1”)

Creates a new DeviceProxy.

Parameters:
  • dev_name (str) – the device name or alias

  • need_check_acc (bool) – (optional, default is True) Determines if at creation time of DeviceProxy it should check for channel access (rarely used).

  • green_mode (GreenMode) – determines the mode of execution of the device (including. the way it is created). Defaults to the current global green_mode (check get_green_mode() and set_green_mode())

  • wait (bool) – whether or not to wait for result. If green_mode Ignored when green_mode is Synchronous (always waits).

  • timeout (float) – The number of seconds to wait for the result. If None, then there is no limit on the wait time. Ignored when green_mode is Synchronous or wait is False.

Returns:

if green_mode is Synchronous or wait is True:

DeviceProxy

elif green_mode is Futures:

concurrent.futures.Future

elif green_mode is Gevent:

gevent.event.AsynchResult

elif green_mode is Asyncio:

asyncio.Future

Throws:
DevFailed if green_mode is Synchronous or wait is True

and there is an error creating the device.

concurrent.futures.TimeoutError if green_mode is Futures,

wait is False, timeout is not None and the time to create the device has expired.

gevent.timeout.Timeout if green_mode is Gevent, wait is False,

timeout is not None and the time to create the device has expired.

asyncio.TimeoutError if green_mode is Asyncio,

wait is False, timeout is not None and the time to create the device has expired.

Added in version 8.1.0: green_mode parameter. n wait parameter. n timeout parameter.

add_logging_target(self: tango._tango.DeviceProxy, target_type_target_name: str) None#

Adds a new logging target to the device.

The target_type_target_name input parameter must follow the format: target_type::target_name. Supported target types are: console, file and device. For a device target, the target_name part of the target_type_target_name parameter must contain the name of a log consumer device (as defined in A.8). For a file target, target_name is the full path to the file to log to. If omitted, the device’s name is used to build the file name (which is something like domain_family_member.log). Finally, the target_name part of the target_type_target_name input parameter is ignored in case of a console target and can be omitted.

Parameters:

target_type_target_name (str) – logging target

Throws:

DevFailed from device

Added in version 7.0.0.

add_telemetry_logging_endpoint(endpoint: TelemetryEndpoint, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Add a telemetry logging endpoint for the device.

Parameters:
  • endpoint (TelemetryEndpoint) – Telemetry logging endpoint to add.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

add_telemetry_tracing_endpoint(endpoint: TelemetryEndpoint, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Add a telemetry tracing endpoint for the device.

Parameters:
  • endpoint (TelemetryEndpoint) – Telemetry tracing endpoint to add.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

adm_name(self: tango._tango.DeviceProxy) str#

Return the name of the corresponding administrator device. This is useful if you need to send an administration command to the device server, e.g restart it

Added in version 3.0.4.

alias(self: tango._tango.DeviceProxy) str#

Return the device alias if one is defined. Otherwise, throws exception.

attribute_history(self: tango._tango.DeviceProxy, attr_name: str, depth: SupportsInt | SupportsIndex, extract_as: tango._tango.ExtractAs = ExtractAs.Numpy) list[tango._tango.DeviceAttributeHistory]#

Retrieve attribute history from the attribute polling buffer. See chapter on Advanced Feature for all details regarding polling

Parameters:
  • attr_name (str) – attribute name

  • depth (int) – the wanted history depth

  • extract_as (ExtractAs) – to which format extract data

Return type:

list[DeviceAttributeHistory]

Throws:

NonSupportedFeature, ConnectionFailed, CommunicationFailed, DevFailed from device

attribute_list_query(self: tango._tango.DeviceProxy) tango._tango.AttributeInfoList#

Query the device for info on all attributes. This method returns a sequence of tango.AttributeInfo.

Return type:

list[AttributeInfo]

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

attribute_list_query_ex(self: tango._tango.DeviceProxy) tango._tango.AttributeInfoListEx#

Query the device for info on all attributes. This method returns a sequence of tango.AttributeInfoEx.

Return type:

list[AttributeInfoEx]

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

attribute_query(self: tango._tango.DeviceProxy, attr_name: str) tango._tango.AttributeInfoEx#

Query the device for information about a single attribute.

Parameters:

attr_name (str) – the attribute name

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

black_box(self: tango._tango.DeviceProxy, n: SupportsInt | SupportsIndex) tango._tango.StdStringVector#

Get the last commands executed on the device server

Parameters:

n (int) – number of commands to get

Returns:

sequence of strings containing the date, time, command and from which client computer the command was executed

Return type:

list[str]

cancel_all_polling_asynch_request(self: tango._tango.Connection) None#

Cancel all running asynchronous request

This is a client side call. Obviously, the calls cannot be aborted while it is running in the device.

Added in version 7.0.0.

cancel_asynch_request(self: tango._tango.Connection, id: SupportsInt | SupportsIndex) None#

Cancel a running asynchronous request

This is a client side call. Obviously, the call cannot be aborted while it is running in the device.

Parameters:

id (int) – The asynchronous call identifier

Added in version 7.0.0.

command_history(self: tango._tango.DeviceProxy, cmd_name: str, depth: SupportsInt | SupportsIndex) tango._tango.DeviceDataHistoryList#

Retrieve command history from the command polling buffer. See chapter on Advanced Feature for all details regarding polling

Parameters:
  • cmd_name (str) – command name

  • depth (int) – the wanted history depth

Return type:

list[DeviceDataHistory]

Throws:

NonSupportedFeature, ConnectionFailed, CommunicationFailed, DevFailed from device

command_inout(name: str, cmd_param: Any = None, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) Any#

Execute a command on a device.

Parameters:
  • cmd_name – Command name

  • cmd_param (typing.Any) – It should be a value of the type expected by the command or a DeviceData object with this value inserted. It can be omitted if the command should not get any argument.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

The result of the command. The type depends on the command. It may be None

Return type:

typing.Any

Throws:

TypeError: if cmd_param’s type is not compatible with the command

ConnectionFailed: Raised in case of a connection failure

CommunicationFailed: Raised in case of a communication failure

DevFailed: Raised in case of a device failure

DeviceUnlocked: Raised in case of a device failure.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 8.1.0: green_mode parameter. wait parameter. timeout parameter.

Changed in version 10.0.0: TypeError’s for invalid command input arguments are now more detailed. For commands with a DEV_STRING input argument, invalid data will now raise TypeError instead of SystemError.

command_inout_asynch(self, cmd_name: str) int#
command_inout_asynch(self, cmd_name: str, cmd_param: Any) int
command_inout_asynch(self, cmd_name: str, cmd_param: Any, forget: bool) int
command_inout_asynch(self, cmd_name: str, callback: Callable) None
command_inout_asynch(self, cmd_name: str, cmd_param: Any, callback: Callable) None

Execute asynchronously (polling model) a command on a device

Parameters:
  • cmd_name – Command name

  • cmd_param (typing.Any) – It should be a value of the type expected by the command or a DeviceData object with this value inserted. It can be omitted if the command should not get any argument. If the command should get no argument and you want to set the ‘forget’ param, use None for cmd_param.

  • callback (typing.Callable) – Any callable object (function, lambda…) or any oject with a method named “cmd_ended”.

  • forget (bool) – If this flag is set to true, this means that the client does not care at all about the server answer and will even not try to get it. Default value is False. Please, note that device re-connection will not take place (in case it is needed) if the fire and forget mode is used. Therefore, an application using only fire and forget requests is not able to automatically re-connnect to device.

Returns:

This call returns an asynchronous call identifier which is needed to get the command result (see command_inout_reply)

Throws:

TypeError: if cmd_param’s type is not compatible with the command

ConnectionFailed: Raised in case of a connection failure.

Important

by default, TANGO is initialized with the polling model. If you want to use the push model (the one with the callback parameter), you need to change the global TANGO model to PUSH_CALLBACK. You can do this with the tango.ApiUtil.set_asynch_cb_sub_model()

Important

Multiple asynchronous calls are not guaranteed to be executed by the device server in the same order they are invoked by the client. E.g., a call to command_inout_asynch("A") followed immediately with a call to command_inout_asynch("B") could result in the device invoking command B before command A.

Changed in version 10.0.0: TypeError’s for invalid command input arguments are now more detailed. For commands with a DEV_STRING input argument, invalid data will now raise TypeError instead of SystemError.

command_inout_raw(cmd_name: str, cmd_param: Any = None) DeviceData#

Execute a command on a device. Does not convert result.

Parameters:
  • cmd_name – Command name

  • cmd_param (typing.Any) – It should be a value of the type expected by the command or a DeviceData object with this value inserted. It can be omitted if the command should not get any argument.

Returns:

The result of the command

Return type:

tango.DeviceData

Throws:

TypeError: if cmd_param’s type is not compatible with the command

ConnectionFailed: Raised in case of a connection failure

CommunicationFailed: Raised in case of a communication failure

DevFailed: Raised in case of a device failuren

DeviceUnlocked: Raised in case of a device failure.

Changed in version 10.0.0: TypeError’s for invalid command input arguments are now more detailed. For commands with a DEV_STRING input argument, invalid data will now raise TypeError instead of SystemError.

command_inout_reply(idx: int, timeout: int | None = None) Any#

Check if the answer of an asynchronous command_inout is arrived (polling model). If the reply is arrived and if it is a valid reply, it is returned to the caller in a DeviceData object. If the reply is an exception, it is re-thrown by this call. If optional timeout parameter is not provided an exception is also thrown in case of the reply is not yet arrived. If timeout is provided, the call will wait (blocking the process) for the time specified in timeout. If after timeout milliseconds, the reply is still not there, an exception is thrown. If timeout is set to 0, the call waits until the reply arrived.

Parameters:
  • idx (int) – Asynchronous call identifier

  • timeout (int) – (optional) Milliseconds to wait for the reply.

Throws:

AsynCall, AsynReplyNotArrived, CommunicationFailed, DevFailed,

command_inout_reply_raw(*args, **kwargs)#

Overloaded function.

  1. command_inout_reply_raw(self: tango._tango.Connection, id: typing.SupportsInt | typing.SupportsIndex) -> tango._tango.DeviceData

Check if the answer of an asynchronous command_inout is arrived (polling model). If the reply is arrived and if it is a valid reply, it is returned to the caller in a DeviceData object. If the reply is an exception, it is re-thrown by this call. An exception is also thrown in case of the reply is not yet arrived.

Parameters:

id (int) – Asynchronous call identifier

Throws:

AsynCall, AsynReplyNotArrived, CommunicationFailed, DevFailed from device

  1. command_inout_reply_raw(self: tango._tango.Connection, id: typing.SupportsInt | typing.SupportsIndex, timeout_ms: typing.SupportsInt | typing.SupportsIndex) -> tango._tango.DeviceData

Check if the answer of an asynchronous command_inout is arrived (polling model). id is the asynchronous call identifier. If the reply is arrived and if it is a valid reply, it is returned to the caller in a DeviceData object. If the reply is an exception, it is re-thrown by this call. If the reply is not yet arrived, the call will wait (blocking the process) for the time specified in timeout. If after timeout milliseconds, the reply is still not there, an exception is thrown. If timeout is set to 0, the call waits until the reply arrived.

Parameters:
  • id (int) – Asynchronous call identifier

  • timeout_ms (int) – timeout

Return type:

DeviceData

Throws:

AsynCall, AsynReplyNotArrived, CommunicationFailed, DevFailed from device

command_list_query(self: tango._tango.DeviceProxy) tango._tango.CommandInfoList#

Query the device for information on all commands.

Returns:

list of CommandInfo objects

Return type:

list[CommandInfo]

command_query(self: tango._tango.DeviceProxy, command: str) tango._tango.CommandInfo#

Query the device for information about a single command.

Example:
com_info = dev.command_query("DevString")
print(com_info.cmd_name)
print(com_info.cmd_tag)
print(com_info.in_type)
print(com_info.out_type)
print(com_info.in_type_desc)
print(com_info.out_type_desc)
print(com_info.disp_level)

See CommandInfo documentation string for more detail

Parameters:

command (str) – command name

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

connect(self: tango._tango.Connection, corba_name: str) None#

Creates a connection to a TANGO device using it’s stringified CORBA reference i.e. IOR or corbaloc.

Parameters:

corba_name (str) – Name of the CORBA object

Added in version 7.0.0.

defaultCommandExtractAs = 0#
delete_property(value: str | DbDatum | DbData | list[str | bytes | DbDatum] | dict[str, DbDatum] | dict[str, list[str]] | dict[str, object], *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Delete the given properties for this attribute.

Parameters:
  • value

    Can be one of the following:

    1. str [in] - Single property data to be deleted.

    2. DbDatum [in] - Single property data to be deleted.

    3. DbData [in] - Several property data to be deleted.

    4. list[str] [in] - Several property data to be deleted.

    5. list[tango.DbDatum] [in] - Several property data to be deleted.

    6. dict[str, object] [in] - Keys are property names to be deleted (values are ignored).

    7. dict[str, tango.DbDatum] [in] - Several DbDatum.name are property names to be deleted (keys are ignored).

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

TypeError: Raised in case of value has the wrong type.

tango.NonDbDevice: Raised in case of a non-database device error.

tango.ConnectionFailed: Raised on connection failure with the database.

tango.CommunicationFailed: Raised on communication failure with the database.

tango.DevFailed: Raised on a device failure from the database device.`

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

description(self: tango._tango.DeviceProxy) str#
Returns:

device description

dev_name(self: tango._tango.DeviceProxy) str#
event_queue_size(self: tango._tango.DeviceProxy, event_id: SupportsInt | SupportsIndex) int#

Returns the number of stored events in the event reception buffer. After every call to DeviceProxy.get_events(), the event queue size is 0. During event subscription the client must have chosen the ‘pull model’ for this event. event_id is the event identifier returned by the DeviceProxy.subscribe_event() method.

Parameters:

event_id (int) – event identifier

Throws:

EventSystemFailed

Added in version 7.0.0.

freeze_dynamic_interface()#

Prevent unknown attributes to be set on this DeviceProxy instance.

An exception will be raised if the Python attribute set on this DeviceProxy instance does not already exist. This prevents accidentally writing to a non-existent Tango attribute when using the high-level API.

This is the default behaviour since PyTango 9.3.4.

See also tango.DeviceProxy.unfreeze_dynamic_interface().

Added in version 9.4.0.

get_access_control(self: tango._tango.Connection) tango._tango.AccessControlType#

Returns the current access control type

Added in version 7.0.0.

get_access_right(self: tango._tango.Connection) tango._tango.AccessControlType#

Returns the current access control right

Added in version 8.0.0.

get_asynch_replies(*args, **kwargs)#

Overloaded function.

  1. get_asynch_replies(self: tango._tango.Connection) -> None

Try to obtain data returned by a command asynchronously requested. This method does not block if the reply has not yet arrived. It fires callback for already arrived replies.

Added in version 7.0.0.

  1. get_asynch_replies(self: tango._tango.Connection, call_timeout: typing.SupportsInt | typing.SupportsIndex) -> None

Try to obtain data returned by a command asynchronously requested. This method blocks for the specified timeout if the reply is not yet arrived. This method fires callback when the reply arrived. If the timeout is set to 0, the call waits undefinitely for the reply

Parameters:

call_timeout (int) – timeout in miliseconds

Added in version 7.0.0.

get_attribute_config(self, name: str, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) AttributeInfoEx#
get_attribute_config(self, names: list[str], green_mode: GreenMode = None, wait: bool = True, timeout: float = None) AttributeInfoList

Return the attribute configuration for a single or a list of attribute(s). To get all the attributes pass a sequence containing the constant tango.constants.AllAttr

Deprecated since version use: get_attribute_config_ex instead

Parameters:
  • name (str) – Attribute name.

  • names (list[str]) – Attribute names.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

An AttributeInfoEx or AttributeInfoList object containing the attribute(s) information.

Return type:

tango.AttributeInfoEx | tango.AttributeInfoList

Throws:

tango.ConnectionFailed: Raised in case of a connection failure.

tango.CommunicationFailed: Raised in case of a communication failure.

tango.DevFailed: Raised in case of a device failure.

TypeError: Raised in case of an incorrect type of input arguments.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

get_attribute_config_ex(names: str | list[str], *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) AttributeInfoListEx#

Return the extended attribute configuration for a single attribute or for the list of specified attributes. To get all the attributes pass a sequence containing the constant tango.constants.AllAttr.

Parameters:
  • names (str | list[str]) – Attribute name or attribute names. Can be a single string (for one attribute) or a sequence of strings (for multiple attributes).

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

An AttributeInfoListEx object containing the attribute information.

Return type:

AttributeInfoListEx

Throws:

ConnectionFailed: Raised in case of a connection failure.

CommunicationFailed: Raised in case of a communication failure.

DevFailed: Raised in case of a device failure.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

get_attribute_list(self: tango._tango.DeviceProxy) tango._tango.StdStringVector#

Return the names of all attributes implemented for this device.

Return type:

list[str]

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

get_attribute_poll_period(self: tango._tango.DeviceProxy, attr_name: str) int#

Return the attribute polling period in milliseconds

Parameters:

attr_name (str) – attribute name

get_command_config(self, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) CommandInfoList#
get_command_config(self, name: str, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) CommandInfo
get_command_config(self, names: Sequence[str], green_mode: GreenMode = None, wait: bool = True, timeout: float = None) CommandInfoList

Return the command configuration for single/list/all command(s).

Parameters:
  • name (str, optional) – Command name. Used when querying information for a single command.

  • names (typing.Sequence[str], optional) – Command names. Used when querying information for multiple commands. This parameter should not be used simultaneously with ‘name’.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

A CommandInfoList object containing the commands information if multiple command names are provided, or a CommandInfo object if a single command name is provided.

Return type:

CommandInfoList | CommandInfo

Throws:

tango.ConnectionFailed: Raised in case of a connection failure.

tango.CommunicationFailed: Raised in case of a communication failure.

tango.DevFailed: Raised in case of a device failure.

TypeError: Raised in case of an incorrect type of input arguments.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

get_command_list(self: tango._tango.DeviceProxy) tango._tango.StdStringVector#

Return the names of all commands implemented for this device.

Return type:

list[str]

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

get_command_poll_period(self: tango._tango.DeviceProxy, cmd_name: str) int#

Return the command polling period in milliseconds

Parameters:

cmd_name (str) – command name

get_db_host(self: tango._tango.Connection) str#

Returns the database host.

Added in version 7.0.0.

get_db_port(self: tango._tango.Connection) str#

Returns the database port.

Added in version 7.0.0.

get_db_port_num(self: tango._tango.Connection) int#

Returns the database port.

Added in version 7.0.0.

get_dev_host(self: tango._tango.Connection) str#

Returns the current host

Added in version 7.2.0.

get_dev_port(self: tango._tango.Connection) str#

Returns the current port

Added in version 7.2.0.

get_device_db(self: tango._tango.DeviceProxy) tango._tango.Database#

Returns the internal database reference

Added in version 7.0.0.

get_events(event_id: int, callback: Callable | None = None, extract_as: ExtractAs = ExtractAs.Numpy) None#

The method extracts all waiting events from the event reception buffer.

If callback is not None, it is executed for every event. During event subscription the client must have chosen the pull model for this event. The callback will receive a parameter of type EventData, AttrConfEventData or DataReadyEventData depending on the type of the event (event_type parameter of subscribe_event).

If callback is None, the method extracts all waiting events from the event reception buffer. The returned event_list is a vector of EventData, AttrConfEventData or DataReadyEventData pointers, just the same data the callback would have received.

Parameters:
  • event_id (int) – The event identifier returned by the DeviceProxy.subscribe_event() method.

  • callback (typing.Callable) – Any callable object or any object with a “push_event” method.

  • extract_as (ExtractAs) – (Description Needed)

Throws:

tango.EventSystemFailed: Raised in case of a failure in the event system.

TypeError: Raised in case of an incorrect type of input arguments.

ValueError: Raised in case of an invalid value.

See also:

subscribe_event()

static get_fqdn() str#

Returns the fully qualified domain name

Added in version 7.2.0.

get_from_env_var(self: tango._tango.Connection) bool#

Returns True if determined by environment variable or False otherwise

Added in version 7.0.0.

get_green_mode()#

Returns the green mode in use by this DeviceProxy.

Returns:

the green mode in use by this DeviceProxy.

Return type:

GreenMode

Added in version 8.1.0.

get_idl_version(self: tango._tango.Connection) int#

Get the version of the Tango Device interface implemented by the device

get_last_event_date(self: tango._tango.DeviceProxy, event_id: SupportsInt | SupportsIndex) tango._tango.TimeVal#

Returns the arrival time of the last event stored in the event reception buffer. After every call to DeviceProxy:get_events(), the event reception buffer is empty. In this case an exception will be returned. During event subscription the client must have chosen the ‘pull model’ for this event. event_id is the event identifier returned by the DeviceProxy.subscribe_event() method.

Parameters:

event_id (int) – event identifier

Throws:

EventSystemFailed

Added in version 7.0.0.

get_locker(self: tango._tango.DeviceProxy, lockinfo: tango._tango.LockerInfo) bool#

If the device is locked, this method returns True an set some locker process informations in the structure passed as argument. If the device is not locked, the method returns False.

Parameters:

lockinfo (LockInfo) – object that will be filled with lock information

Added in version 7.0.0.

get_logging_level(self: tango._tango.DeviceProxy) int#
Returns the current device’s logging level, where:
  • 0=OFF

  • 1=FATAL

  • 2=ERROR

  • 3=WARNING

  • 4=INFO

  • 5=DEBUG

Added in version 7.0.0.

get_logging_target(self: tango._tango.DeviceProxy) tango._tango.StdStringVector#

Returns a sequence of string containing the current device’s logging targets. Each vector element has the following format: target_type::target_name. An empty sequence is returned is the device has no logging targets.

Added in version 7.0.0.

get_property(propname: str | DbDatum | DbData | list[str | bytes | DbDatum] | dict[str, DbDatum] | dict[str, list[str]] | dict[str, object], value=None, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) dict[str, list[str]]#

Get a (list) property(ies) for an attribute.

Parameters:
  • propname

    Can be one of the following:

    1. str [in] - Single property data to be fetched.

    2. DbDatum [in] - Single property data to be fetched.

    3. DbData [in] - Several property data to be fetched.

    4. list[str | bytes ] [in] - Several property data to be fetched.

    5. list[tango.DbDatum] [in] - Several property data to be fetched.

    6. dict[str, object] [in] - Keys are property names to be fetched (values are ignored).

    7. dict[str, tango.DbDatum] [in] - Several DbDatum.name are property names to be fetched (keys are ignored).

  • value (tango.DbData, optional) – Optional. For propname overloads with str and list[str] will be filed with the property values, if provided.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

A dict object, which keys are the property names the value associated with each key being a sequence of strings being the property value.

Throws:

TypeError: Raised in case of propname has the wrong type.

tango.NonDbDevice: Raised in case of a non-database device error.

tango.ConnectionFailed: Raised on connection failure with the database.

tango.CommunicationFailed: Raised on communication failure with the database.

tango.DevFailed: Raised on a device failure from the database device.`

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.1.0:: overloads with dict as propname parameter

Changed in version 10.1.0:: raises if propname has an invalid type instead of returning None

get_property_list(self, filter, array=None, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) obj#

Get the list of property names for the device. The parameter filter allows the user to filter the returned name list. The wildcard character is ‘*’. Only one wildcard character is allowed in the filter parameter.

Parameters:
  • filter (str) – The filter wildcard.

  • array (list[object]) – Optional. An array to be filled with the property names. If None, a new list will be created internally with the values. Defaults to None.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

The given array filled with the property names, or a new list if array is None.

Return type:

sequence obj

Throws:

tango.NonDbDevice: Raised in case of a non-database device error.

tango.WrongNameSyntax: Raised in case of incorrect syntax in the name.

tango.ConnectionFailed: Raised in case of a connection failure with the database.

tango.CommunicationFailed: Raised in case of a communication failure with the database.

tango.DevFailed: Raised in case of a device failure from the database device.

TypeError: Raised in case of an incorrect type of input arguments.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Versionadded::

7.0.0

get_source(self: tango._tango.Connection) tango._tango.DevSource#

Get the data source(device, polling buffer, polling buffer then device) used by command_inout or read_attribute methods

Example:
source = dev.get_source()
if source == DevSource.CACHE_DEV : ...
get_tango_lib_version(self: tango._tango.DeviceProxy) int#

Returns the Tango lib version number used by the remote device Otherwise, throws exception.

Returns:

3 or 4 digits number. Possible return value are: 100,200,500,520,700,800,810,…

Added in version 8.1.0.

get_telemetry_logging(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) bool#

Get the enabled state of telemetry logging for the device.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

The enabled state of telemetry logging.

Return type:

bool

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

get_telemetry_logging_endpoints(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) tuple[TelemetryEndpoint, ...]#

Get the telemetry logging endpoints configured for the device.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

The configured telemetry logging endpoints.

Return type:

tuple of TelemetryEndpoint

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

get_telemetry_topics(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) tuple[str, ...]#

Get the telemetry topics configured for the device.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

The configured telemetry topics.

Return type:

tuple[str, …]

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

get_telemetry_tracing(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) bool#

Get the enabled state of telemetry tracing for the device.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

The enabled state of telemetry tracing.

Return type:

bool

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

get_telemetry_tracing_endpoints(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) tuple[TelemetryEndpoint, ...]#

Get the telemetry tracing endpoints configured for the device.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

The configured telemetry tracing endpoints.

Return type:

tuple of TelemetryEndpoint

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

get_timeout_millis(self: tango._tango.Connection) int#

Get the client side timeout in milliseconds

get_transparency_reconnection(self: tango._tango.Connection) bool#

Returns the device transparency reconnection flag.

import_info(self: tango._tango.DeviceProxy) tango._tango.DbDevImportInfo#

Query the device for import info from the database.

Example:
dev_import = dev.import_info()
print(dev_import.name)
print(dev_import.exported)
print(dev_ior.ior)
print(dev_version.version)

All DbDevImportInfo fields are strings except for exported which is an integer

info(self: tango._tango.DeviceProxy) tango._tango.DeviceInfo#

A method which returns information on the device

Example:
dev_info = dev.info()
print(dev_info.dev_class)
print(dev_info.server_id)
print(dev_info.server_host)
print(dev_info.server_version)
print(dev_info.doc_url)
print(dev_info.dev_type)
print(dev_info.version_info)
invalidate_attribute_config_cache() None#

Invalidates attribute configuration cache

For more details, see Attribute configuration caching.

See also tango.DeviceProxy.enable_attribute_config_cache() and tango.DeviceProxy.is_attribute_config_cache_enabled().

Added in version 10.3.0.

is_attribute_config_cache_enabled() bool#

Returns whether the attribute configuration is cached or not.

For more details, see Attribute configuration caching.

See also tango.DeviceProxy.enable_attribute_config_cache() and tango.DeviceProxy.invalidate_attribute_config_cache().

Added in version 10.3.0.

is_attribute_polled(self: tango._tango.DeviceProxy, attr_name: str) bool#

True if the attribute is polled.

Parameters:

attr_name (str) – attribute name

is_command_polled(self: tango._tango.DeviceProxy, cmd_name: str) bool#

True if the command is polled.

Parameters:

cmd_name (str) – command name

is_dbase_used(self: tango._tango.Connection) bool#

Returns True if the database is being used

Added in version 7.2.0.

is_dynamic_interface_frozen()#

Indicates if the dynamic interface for this DeviceProxy instance is frozen.

See also tango.DeviceProxy.freeze_dynamic_interface() and tango.DeviceProxy.unfreeze_dynamic_interface().

Returns:

True if the dynamic interface this DeviceProxy is frozen.

Return type:

bool

Added in version 9.4.0.

is_event_queue_empty(self: tango._tango.DeviceProxy, event_id: SupportsInt | SupportsIndex) bool#

Returns true when the event reception buffer is empty. During event subscription the client must have chosen the ‘pull model’ for this event. event_id is the event identifier returned by the DeviceProxy.subscribe_event() method.

Parameters:

event_id (int) – event identifier

Throws:

EventSystemFailed

Added in version 7.0.0.

is_locked(self: tango._tango.DeviceProxy) bool#

Returns True if the device is locked. Otherwise, returns False.

Added in version 7.0.0.

is_locked_by_me(self: tango._tango.DeviceProxy) bool#

Returns True if the device is locked by the caller. Otherwise, returns False (device not locked or locked by someone else)

Added in version 7.0.0.

is_telemetry_enabled(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) bool#

Get the enabled state of the telemetry service for the device.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

The enabled state of device telemetry.

Return type:

bool

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

lock(self: tango._tango.DeviceProxy, lock_validity: SupportsInt | SupportsIndex = 10) None#

Lock a device. The lock_validity is the time (in seconds) the lock is kept valid after the previous lock call. A default value of 10 seconds is provided and should be fine in most cases. In case it is necessary to change the lock validity, it’s not possible to ask for a validity less than a minimum value set to 2 seconds. The library provided an automatic system to periodically re lock the device until an unlock call. No code is needed to start/stop this automatic re-locking system. The locking system is re-entrant. It is then allowed to call this method on a device already locked by the same process. The locking system has the following features:

  • It is impossible to lock the database device or any device server process admin device

  • Destroying a locked DeviceProxy unlocks the device

  • Restarting a locked device keeps the lock

  • It is impossible to restart a device locked by someone else

  • Restarting a server breaks the lock

A locked device is protected against the following calls when executed by another client:

  • command_inout call except for device state and status requested via command and for the set of commands defined as allowed following the definition of allowed command in the Tango control access schema.

  • write_attribute call

  • write_read_attribute call

  • set_attribute_config call

Parameters:

lock_validity (int) – lock validity time in seconds

Added in version 7.0.0.

locking_status(self: tango._tango.DeviceProxy) str#

This method returns a plain string describing the device locking status. This string can be:

  • “Device <device name> is not locked” in case the device is not locked

  • “Device <device name> is locked by CPP or Python client with PID <pid> from host <host name>” in case the device is locked by a CPP client

  • “Device <device name> is locked by JAVA client class <main class> from host <host name>” in case the device is locked by a JAVA client

Added in version 7.0.0.

name(self: tango._tango.DeviceProxy) str#

Returns the device name from the device itself

pending_asynch_call(self: tango._tango.DeviceProxy, arg0: tango._tango.asyn_req_type) int#

Return number of device asynchronous pending requests”

Added in version 7.0.0.

ping(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) int#

A method which sends a ping to the device

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

time elapsed in microseconds

Return type:

int

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

poll_attribute(self: tango._tango.DeviceProxy, attr_name: str, period_ms: SupportsInt | SupportsIndex) None#

Add an attribute to the list of polled attributes.

Parameters:
  • attr_name (str) – attribute name

  • period_ms (int)) – polling period in milliseconds

poll_command(self: tango._tango.DeviceProxy, cmd_name: str, period_ms: SupportsInt | SupportsIndex) None#

Add a command to the list of polled commands.

Parameters:
  • cmd_name (str) – command name

  • period_ms (int) – polling period in milliseconds

polling_status(self: tango._tango.DeviceProxy) tango._tango.StdStringVector#

Return the device polling status.

Returns:

One string for each polled command/attribute. Each string is multi-line string with:

  • attribute/command name

  • attribute/command polling period in milliseconds

  • attribute/command polling ring buffer

  • time needed for last attribute/command execution in milliseconds

  • time since data in the ring buffer has not been updated

  • delta time between the last records in the ring buffer

  • exception parameters in case of the last execution failed

Return type:

list[str]

put_property(value: str | DbDatum | DbData | list[str | bytes | DbDatum] | dict[str, DbDatum] | dict[str, list[str]] | dict[str, object], *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Insert or update a list of properties for this attribute.

Parameters:
  • value

    Can be one of the following:

    1. str - Single property data to be inserted.

    2. DbDatum - Single property data to be inserted.

    3. DbData - Several property data to be inserted.

    4. list[str | bytes | DbDatum] - Several property data to be inserted.

    5. dict[str, DbDatum] - DbDatum is property to be inserted (keys are ignored).

    6. dict[str, list[str]] - Keys are property names, and value has data to be inserted.

    7. dict[str, object] - Keys are property names, and str(obj) is property value.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

TypeError: Raised in case of value has the wrong type.

tango.NonDbDevice: Raised in case of a non-database device error.

tango.ConnectionFailed: Raised on connection failure with the database.

tango.CommunicationFailed: Raised on communication failure with the database.

tango.DevFailed: Raised on a device failure from the database device.`

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

read_attribute(attr_name: str, extract_as: ExtractAs = ExtractAs.Numpy, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) DeviceAttribute#

Read a single attribute.

Parameters:
  • attr_name (str) – The name of the attribute to read.

  • extract_as (ExtractAs) – Defaults to numpy.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

DeviceAttribute object with read attribute value.

Return type:

DeviceAttribute

Throws:

ConnectionFailed: Raised in case of a connection failure

CommunicationFailed: Raised in case of a communication failure.

DevFailed: Raised in case of a device failure

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Changed in version 7.1.4: For DevEncoded attributes, before it was returning a DeviceAttribute.value as a tuple (format<str>, data<str>) no matter what was the extract_as value was. Since 7.1.4, it returns a (format<str>, data<buffer>) unless extract_as is String, in which case it returns (format<str>, data<str>).

Changed in version 8.0.0: For DevEncoded attributes, now returns a DeviceAttribute.value as a tuple (format<str>, data<bytes>) unless extract_as is String, in which case it returns (format<str>, data<str>). Careful, if using python >= 3 data<str> is decoded using default python utf-8 encoding. This means that PyTango assumes tango DS was written encapsulating string into utf-8 which is the default python encoding.

Added in version 8.1.0: green_mode parameter. wait parameter. timeout parameter.

Changed in version 9.4.0: For spectrum and image attributes with an empty sequence, no longer returns DeviceAttribute.value and DeviceAttribute.w_value as None. Instead, DevString and DevEnum types get an empty tuple, while other types get an empty numpy.ndarray. Using extract_as can change the sequence type, but it still won’t be None.

read_attribute_asynch(self, attr_name: str, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) int#
read_attribute_asynch(self, attr_name: str, cb: Callable, extract_as: ExtractAs = Numpy, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) None

Read asynchronously the specified attributes.

Important

by default, TANGO is initialized with the polling model. If you want to use the push model (the one with the callback parameter), you need to change the global TANGO model to PUSH_CALLBACK. You can do this with the tango.ApiUtil.set_asynch_cb_sub_model()

Parameters:
  • attr_name (str) – an attribute to read

  • cb (typing.Optional[typing.Callable]) – push model: as soon as attributes read, core calls cb with read results. This callback object should be an instance of a user class with an attr_read() method. It can also be any callable object.

  • extract_as (ExtractAs) – Defaults to ExtractAs.Numpy

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

an asynchronous call identifier which is needed to get attribute value if poll model, None if push model

Return type:

int | None

Throws:

ConnectionFailed

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Important

Multiple asynchronous calls are not guaranteed to be executed by the device server in the same order they are invoked by the client. E.g., a call to the method write_attribute_asynch("a", 1) followed immediately with a call to read_attribute_asynch("a") could result in the device reading the attribute a before writing to it.

Added in version 7.0.0.

read_attribute_reply(self, id: int, extract_as: ExtractAs = ExtractAs.Numpy, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) DeviceAttribute#
read_attribute_reply(self, id: int, poll_timeout: int, extract_as: ExtractAs = ExtractAs.Numpy, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) DeviceAttribute

Get the answer of an asynchronous read_attribute call, if it has arrived (polling model).

If the reply is ready, but the attribute raised an exception while reading, an exception will be raised by this function (DevFailed, with reason API_AttrValueNotSet).

Changed in version 10.0.0: To eliminate confusion between different timeout parameters, the core (cppTango) timeout (previously the optional second positional argument) has been renamed to “poll_timeout”. Conversely, the pyTango executor timeout remains as the keyword argument “timeout”. These parameters have distinct meanings and units:

  • The cppTango “poll_timeout” is measured in milliseconds and blocks the call until a reply is received. If the reply is not received within the specified poll_timeout duration, an exception is thrown. Setting poll_timeout to 0 causes the call to wait indefinitely until a reply is received.

  • The pyTango “timeout” is measured in seconds and is applicable only in asynchronous GreenModes (Asyncio, Futures, Gevent), and only when “wait” is set to True. The specific behavior when a reply is not received within the specified timeout period varies depending on the GreenMode.

Parameters:
  • id (int) – the asynchronous call identifier

  • poll_timeout (int, optional) –

    cppTango core timeout in ms:

    • If the reply has not yet arrived, the call will wait for the time specified (in ms).

    • If after timeout, the reply is still not there, an exception is thrown.

    • If timeout set to 0, the call waits until the reply arrives.

    • If the argument is not provided, then there is no timeout check, and an exception is raised immediately if the reply is not ready.

  • extract_as (ExtractAs) – Defaults to numpy.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

Could be:

  • If the reply is arrived and if it is a valid reply, it is returned to the caller in a DeviceAttribute.

  • If the reply is an exception, it is re-thrown by this call.

  • If the reply is not yet arrived, the call will wait (blocking the process) for the time specified in timeout. If after timeout milliseconds, the reply is still not there, an exception is thrown. If timeout is set to 0, the call waits until the reply arrived.

Return type:

tango.DeviceAttribute

Throws:

tango.AsynCall, tango.AsynReplyNotArrived, tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed

Added in version 7.0.0.

read_attributes(attr_names: Sequence[str], extract_as: ExtractAs = ExtractAs.Numpy, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) list[DeviceAttribute]#

Read the list of specified attributes.

Parameters:
  • attr_names (typing.Sequence[str]) – A list of attributes to read.

  • extract_as (ExtractAs) – In which format to return the attribute values.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

A list of DeviceAttribute objects.

Return type:

list[tango.DeviceAttribute]

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DeviceUnlocked, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 8.1.0: green_mode parameter. wait parameter. timeout parameter.

read_attributes_asynch(self, attr_names: Sequence[str], green_mode: GreenMode = None, wait: bool = True, timeout: float = None) int#
read_attributes_asynch(self, attr_names: Sequence[str], cb: Callable, extract_as: ExtractAs = Numpy, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) None

Read asynchronously an attribute list.

Important

by default, TANGO is initialized with the polling model. If you want to use the push model (the one with the callback parameter), you need to change the global TANGO model to PUSH_CALLBACK. You can do this with the tango.ApiUtil.set_asynch_cb_sub_model()

Parameters:
  • attr_names (typing.Sequence[str]) – A list of attributes to read. See read_attributes.

  • cb (typing.Optional[typing.Callable]) – push model: as soon as attributes read, core calls cb with read results. This callback object should be an instance of a user class with an attr_read() method. It can also be any callable object.

  • extract_as (ExtractAs) – Defaults to numpy.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

an asynchronous call identifier which is needed to get attributes value if poll model, None if push model

Return type:

int | None

Throws:

ConnectionFailed

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Important

Multiple asynchronous calls are not guaranteed to be executed by the device server in the same order they are invoked by the client. E.g., a call to write_attributes_asynch([("a", 1)]) followed immediately with a call to read_attributes_asynch(["a"]) could result in the device reading the attribute a before writing to it.

Added in version 7.0.0.

read_attributes_reply(self, id: int, extract_as: ExtractAs = ExtractAs.Numpy, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) list[DeviceAttribute]#
read_attributes_reply(self, id: int, poll_timeout: int, extract_as: ExtractAs = ExtractAs.Numpy, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) list[DeviceAttribute]

Get the answer of an asynchronous read_attributes call, if it has arrived (polling model).

If the reply is ready, but an attribute raised an exception while reading, it will still be included in the returned list. However, the has_error field for that item will be set to True.

Changed in version 10.0.0: To eliminate confusion between different timeout parameters, the core (cppTango) timeout (previously the optional second positional argument) has been renamed to “poll_timeout”. Conversely, the pyTango executor timeout remains as the keyword argument “timeout”. These parameters have distinct meanings and units:

  • The cppTango “poll_timeout” is measured in milliseconds and blocks the call until a reply is received. If the reply is not received within the specified poll_timeout duration, an exception is thrown. Setting poll_timeout to 0 causes the call to wait indefinitely until a reply is received.

  • The pyTango “timeout” is measured in seconds and is applicable only in asynchronous GreenModes (Asyncio, Futures, Gevent), and only when “wait” is set to True. The specific behavior when a reply is not received within the specified timeout period varies depending on the GreenMode.

Parameters:
  • id (int) – the asynchronous call identifier

  • poll_timeout (int, optional) –

    cppTango core timeout in ms:

    • If the reply has not yet arrived, the call will wait for the time specified (in ms).

    • If after timeout, the reply is still not there, an exception is thrown.

    • If timeout set to 0, the call waits until the reply arrives.

    • If the argument is not provided, then there is no timeout check, and an exception is raised immediately if the reply is not ready.

  • extract_as (ExtractAs) – Defaults to numpy.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

Could be:

  • If the reply is arrived and if it is a valid reply, it is returned to the caller in a list of DeviceAttribute.

  • If the reply is an exception, it is re-thrown by this call.

  • If the reply is not yet arrived, the call will wait (blocking the process) for the time specified in timeout. If after timeout milliseconds, the reply is still not there, an exception is thrown. If timeout is set to 0, the call waits until the reply arrived.

Return type:

list[DeviceAttribute]

Throws:

AsynCall, AsynReplyNotArrived, ConnectionFailed, CommunicationFailed, DevFailed

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 7.0.0.

reconnect(self: tango._tango.Connection, db_used: bool) None#

Reconnect to to a CORBA object.

Parameters:

db_used (bool) – Use database

Added in version 7.0.0.

remove_logging_target(self: tango._tango.DeviceProxy, target_type_target_name: str) None#

Removes a logging target from the device’s target list.

The target_type_target_name input parameter must follow the format: target_type::target_name. Supported target types are: console, file and device. For a device target, the target_name part of the target_type_target_name parameter must contain the name of a log consumer device (as defined in ). For a file target, target_name is the full path to the file to remove. If omitted, the default log file is removed. Finally, the target_name part of the target_type_target_name input parameter is ignored in case of a console target and can be omitted. If target_name is set to ‘*’, all targets of the specified target_type are removed.

Parameters:

target_type_target_name (str) – logging target

Added in version 7.0.0.

remove_telemetry_logging_endpoint(endpoint: TelemetryEndpoint, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Remove a telemetry logging endpoint from the device.

Parameters:
  • endpoint (TelemetryEndpoint) – Telemetry logging endpoint to remove.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

remove_telemetry_tracing_endpoint(endpoint: TelemetryEndpoint, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Remove a telemetry tracing endpoint from the device.

Parameters:
  • endpoint (TelemetryEndpoint) – Telemetry tracing endpoint to remove.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

set_access_control(self: tango._tango.Connection, acc: tango._tango.AccessControlType) None#

Sets the current access control type

Parameters:

acc (AccessControlType) – the type of access control to set

Added in version 7.0.0.

set_attribute_config(self, attr_info: AttributeInfo | Sequence[AttributeInfo], green_mode: GreenMode = None, wait: bool = True, timeout: float = None) None#
set_attribute_config(self, attr_info_ex: AttributeInfoEx | Sequence[AttributeInfoEx], green_mode: GreenMode = None, wait: bool = True, timeout: float = None) None

Change the attribute configuration/extended attribute configuration for the specified attribute(s)

Parameters:
  • attr_info (tango.AttributeInfo | typing.Sequence[AttributeInfo]]) – Attribute information. This parameter is used when providing basic attribute(s) information.

  • attr_info_ex (AttributeInfoEx | typing.Sequence[AttributeInfoEx]]) – Extended attribute information. This parameter is used when providing extended attribute information. It should not be used simultaneously with ‘attr_info’.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

None

Throws:

tango.ConnectionFailed: Raised in case of a connection failure.

tango.CommunicationFailed: Raised in case of a communication failure.

tango.DevFailed: Raised in case of a device failure.

TypeError: Raised in case of an incorrect type of input arguments.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

set_attribute_config_cache(enabled: bool) None#

Enable or disable the attribute configuration caching.

For more details, see Attribute configuration caching.

See also tango.DeviceProxy.is_attribute_config_cache_enabled() and tango.DeviceProxy.invalidate_attribute_config_cache().

Added in version 10.3.0.

set_green_mode(green_mode=None)#

Sets the green mode to be used by this DeviceProxy Setting it to None means use the global PyTango green mode (see tango.get_green_mode()).

Parameters:

green_mode (GreenMode) – the new green mode

Added in version 8.1.0.

set_logging_level(self: tango._tango.DeviceProxy, level: SupportsInt | SupportsIndex) None#
Changes the device’s logging level, where:
  • 0=OFF

  • 1=FATAL

  • 2=ERROR

  • 3=WARNING

  • 4=INFO

  • 5=DEBUG

Parameters:

level (int) – logging level

Added in version 7.0.0.

set_source(self: tango._tango.Connection, source: tango._tango.DevSource) None#

Set the data source(device, polling buffer, polling buffer then device) for command_inout and read_attribute methods.

Parameters:

source (DevSource) – data source

set_telemetry_logging(enabled: bool, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Set the enabled state of telemetry logging for the device.

Parameters:
  • enabled (bool) – True to enable telemetry logging, False to disable it.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

set_telemetry_logging_endpoints(endpoints: Sequence[TelemetryEndpoint], *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Set the telemetry logging endpoints for the device.

Replaces all existing telemetry logging endpoints with the provided endpoints.

Parameters:
  • endpoints (Sequence of TelemetryEndpoint) – Telemetry logging endpoints to configure.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

set_telemetry_topics(topics: Sequence[str], *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Set the telemetry topics configured for the device.

Parameters:
  • topics (typing.Sequence[str]) – Telemetry topics to configure.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

set_telemetry_tracing(enabled: bool, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Set the enabled state of telemetry tracing for the device.

Parameters:
  • enabled (bool) – True to enable telemetry tracing, False to disable it.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

set_telemetry_tracing_endpoints(endpoints: Sequence[TelemetryEndpoint], *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Set the telemetry tracing endpoints for the device.

Replaces all existing telemetry tracing endpoints with the provided endpoints.

Parameters:
  • endpoints (Sequence of TelemetryEndpoint) – Telemetry tracing endpoints to configure.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

ConnectionFailed: Raised in case of a connection failure

CommunicationFailed: Raised in case of a communication failure.

DevFailed: Raised in case of a device failure

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

set_timeout_millis(self: tango._tango.Connection, timeout_ms: SupportsInt | SupportsIndex) None#

Set client side timeout for device in milliseconds. Any method which takes longer than this time to execute will throw an exception

Example:
dev.set_timeout_millis(1000)
Parameters:

timeout_ms (int) – integer value of timeout in milliseconds

set_transparency_reconnection(self: tango._tango.Connection, yesno: bool) None#

Set the device transparency reconnection flag

Parameters:

yesno (bool) – True to set transparency reconnection or False otherwise

start_telemetry(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Start the telemetry service for the device.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

state(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) DevState#

A method which returns the state of the device.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

A DevState constant.

Return type:

DevState

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

status(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) str#

A method which returns the status of the device as a string.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

string describing the device status

Return type:

str

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

stop_poll_attribute(self: tango._tango.DeviceProxy, attr_name: str) None#

Remove an attribute from the list of polled attributes.

Parameters:

attr_name (str) – attribute name

stop_poll_command(self: tango._tango.DeviceProxy, cmd_name: str) None#

Remove a command from the list of polled commands.

Parameters:

cmd_name (str) – command name

stop_telemetry(*, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Stop the telemetry service for the device.

Parameters:
  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 10.3.0.

subscribe_event(self, attr_name: str, event_type: EventType, cb: Callable, sub_mode: EventSubMode = EventSubMode.SyncRead, extract_as: ExtractAs = ExtractAs.Numpy, *, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) int#
subscribe_event(self, attr_name: str, event_type: EventType, queuesize: int, sub_mode: EventSubMode = EventSubMode.SyncRead, extract_as: ExtractAs = ExtractAs.Numpy, *, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) int
subscribe_event(self, event_type: EventType, cb: Callable, sub_mode: EventSubMode = EventSubMode.SyncRead, *, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) int

Note

This function is heavily overloaded, and includes three additional signatures that have been deprecated (see warning below).

The client call to subscribe for event reception. There are two main categories:

  • Subscribe to events for a specific attribute, like change events, providing either:

    • a callback function for immediate notification (push callback model), or

    • a queue length, allowing events to be processed later (pull callback model).

  • Subscribe to device-level events (not linked to a specific attribute), like interface-changed events. These require a callback function (push callback model).

More details of the push and pull callback models are provided in the cppTango Events API docs.

A common example, subscribing to change events on the “voltage” attribute with a callback, is shown below.

from tango import DeviceProxy, EventData, EventType

def on_change_event(evt: EventData):
    if evt.err:
        e = evt.errors[0]
        print(f"Event error: [{e.reason}] {e.desc}")
    else:
        print(f"Event received: [{evt.attr_value.quality}] {evt.attr_value.value}")

# subscribe
dp = DeviceProxy("my/power_supply/1")
eid = dp.subscribe_event("voltage", EventType.CHANGE_EVENT, on_change_event)
...
# when done with subscription
dp.unsubscribe_event(eid)
Parameters:
  • attr_name (str) – The device attribute name which will be sent as an event, e.g., “current”.

  • event_type (EventType) –

    The event reason, which must be one of the enumerated values in EventType. This includes:

    • EventType.CHANGE_EVENT

    • EventType.ALARM_EVENT

    • EventType.PERIODIC_EVENT

    • EventType.ARCHIVE_EVENT

    • EventType.USER_EVENT

    • EventType.DATA_READY_EVENT

    • EventType.ATTR_CONF_EVENT

    • EventType.INTERFACE_CHANGE_EVENT

  • cb (typing.Callable) – Any callable object or an object with a callable push_event method (i.e., use the push callback model). The callable has the signature def cb(event) (or async def cb(event) for asyncio green mode DeviceProxy objects). The event parameter’s data type depends on the type of event subscribed to. In most cases it is tango.EventData. Special cases are EventType.DATA_READY, EventType.ATTR_CONF_EVENT, and EventType.INTERFACE_CHANGE_EVENT - see Event arrived structures.

  • queuesize (int) –

    The size of the event reception buffer (i.e., use the pull callback model). The event reception buffer is implemented as a round-robin buffer. This way the client can set up different ways to receive events:

    • Event reception buffer size = 1 : The client is interested only in the value of the last event received. All other events that have been received since the last reading are discarded.

    • Event reception buffer size > 1 : The client has chosen to keep an event history of a given size. When more events arrive since the last reading, older events will be discarded.

    • Event reception buffer size = tango.constants.ALL_EVENTS : The client buffers all received events. The buffer size is unlimited and only restricted by the available memory for the client.

  • sub_mode (EventSubMode) – The event subscription mode.

  • extract_as (ExtractAs) – In which format to return the attribute values. Default: ExtractAs.NumPy

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

An event id which has to be specified when unsubscribing from this event.

Return type:

int

Throws:

tango.EventSystemFailed: Raised in case of a failure in the event system.

tango.DevFailed: Raised in case of general communication failures.

TypeError: Raised in case of an incorrect type of input arguments.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Deprecated since version PyTango: 10.1.0

The following signatures, which use the filters and/or stateless parameters, are deprecated. The version for removal has not been decided, but the earliest is version 11.0.0.

  • subscribe_event(self, attr_name, event_type, cb, filters=[], stateless=False, extract_as=ExtractAs.Numpy, green_mode: GreenMode=None, wait: bool=True, timeout: float=None) -> int

  • subscribe_event(self, attr_name, event_type, queuesize, filters=[], stateless=False, extract_as=ExtractAs.Numpy, green_mode: GreenMode=None, wait: bool=True, timeout: float=None) -> int

  • subscribe_event(self, event_type, cb, stateless=False, *, green_mode: GreenMode=None, wait: bool=True, timeout: float=None) -> int

filters (sequence<str>)

The filters apply to the original Notifd-based event system, not the current ZeroMQ-based event system (added in Tango 8). Notifd support is scheduled for removal in Tango 11.

A variable length list of name-value pairs which define additional filters for events. Provide an empty list, if this feature is not needed (typically, for all Tango servers from version 8).

Filters cannot be used with the sub_mode parameter.

stateless (bool)

Instead of setting stateless=True use sub_mode=EventSubMode.Stateless.

When this flag is set to false, an exception will be thrown if the event subscription encounters a problem. With the stateless flag set to true, the event subscription will not raise an exception, even if the corresponding device is not running, or the attribute doesn’t exist. A keep-alive thread will attempt to subscribe for the specified event every 10 seconds, executing a callback with the corresponding exception at every retry.

The stateless flag cannot be used with the sub_mode parameter.

Added in version 10.1.0: Three new signatures using the sub_mode parameter.

Changed in version 10.1.0: All parameters can now be passed as keyword arguments.

unfreeze_dynamic_interface()#

Allow new attributes to be set on this DeviceProxy instance.

An exception will not be raised if the Python attribute set on this DeviceProxy instance does not exist. Instead, the new Python attribute will be added to the DeviceProxy instance’s dictionary of attributes. This may be useful, but a user will not get an error if they accidentally write to a non-existent Tango attribute when using the high-level API.

See also tango.DeviceProxy.freeze_dynamic_interface().

Added in version 9.4.0.

unlock(self: tango._tango.DeviceProxy, force: bool = False) None#

Unlock a device. If used, the method argument provides a back door on the locking system. If this argument is set to true, the device will be unlocked even if the caller is not the locker. This feature is provided for administration purpose and should be used very carefully. If this feature is used, the locker will receive a DeviceUnlocked during the next call which is normally protected by the locking Tango system.

Parameters:

force (bool) – force unlocking even if we are not the locker

Added in version 7.0.0.

unsubscribe_event(event_id: int, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Unsubscribes a client from receiving the event specified by event_id.

Parameters:
  • event_id (int) – The event identifier returned by DeviceProxy::subscribe_event(). Unlike in TangoC++, this implementation checks that the event_id has been subscribed to in this DeviceProxy.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

None

Throws:

tango.EventSystemFailed: Raised in case of a failure in the event system.

KeyError: Raised if the specified event_id is not found or not subscribed in

this DeviceProxy.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

write_attribute(self, attr, value, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) None#

Write a single attribute.

Parameters:
  • attr (str | tango.AttributeInfoEx) – The name or AttributeInfoEx structure of the attribute to write.

  • value (typing.Any) – The value to write to the attribute.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DeviceUnlocked, tango.DevFailed: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 8.1.0: green_mode parameter. wait parameter. timeout parameter.

Changed in version 10.1.0: attr_name parameter was renamed to attr

write_attribute_asynch(attr: str | AttributeInfoEx, value: Any, cb: Callable | None = None, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) int | None#

Write asynchronously the specified attribute.

Important

by default, TANGO is initialized with the polling model. If you want to use the push model (the one with the callback parameter), you need to change the global TANGO model to PUSH_CALLBACK. You can do this with the tango.ApiUtil.set_asynch_cb_sub_model()

Parameters:
  • attr (str | AttributeInfoEx) – an attribute name to write or AttributeInfoEx object (see Note below)

  • value (typing.Any) – value to write

  • cb (typing.Optional[typing.Callable]) – push model: as soon as attribute written, core calls cb with write results. This callback object should be an instance of a user class with an attr_written() method. It can also be any callable object.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

an asynchronous call identifier which is needed to get the server reply if poll model, None if push model

Return type:

int | None

Throws:

tango.ConnectionFailed

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Important

Multiple asynchronous calls are not guaranteed to be executed by the device server in the same order they are invoked by the client. E.g., a call to the method write_attribute_asynch("a", 1) followed immediately with a call to read_attribute_asynch("a") could result in the device reading the attribute a before writing to it.

Note

There are two possibilities for the attr parameter: if you give attribute name, then PyTango will do additional synchronous(!) IO to fetch AttributeInfoEx object from device server, since we must know to which c++ data type cast python value. If you would like to avoid this IO you can give AttributeInfoEx instead of attribute name.

Changed in version 10.1.0:

  • attr_name parameter was renamed to attr

  • added support for AttributeInfoEx for attr parameter

write_attribute_reply(self, id: int, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) None#
write_attribute_reply(self, id: int, poll_timeout: int, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) None

Check if the answer of an asynchronous write_attributes is arrived (polling model). If the reply is arrived and if it is a valid reply, the call returned. If the reply is an exception, it is re-thrown by this call. An exception is also thrown in case of the reply is not yet arrived.

Changed in version 10.0.0: To eliminate confusion between different timeout parameters, the core (cppTango) timeout (previously the optional second positional argument) has been renamed to “poll_timeout”. Conversely, the pyTango executor timeout remains as the keyword argument “timeout”. These parameters have distinct meanings and units:

  • The cppTango “poll_timeout” is measured in milliseconds and blocks the call until a reply is received. If the reply is not received within the specified poll_timeout duration, an exception is thrown. Setting poll_timeout to 0 causes the call to wait indefinitely until a reply is received.

  • The pyTango “timeout” is measured in seconds and is applicable only in asynchronous GreenModes (Asyncio, Futures, Gevent), and only when “wait” is set to True. The specific behavior when a reply is not received within the specified timeout period varies depending on the GreenMode.

Parameters:
  • id (int) – the asynchronous call identifier

  • poll_timeout (int, optional) –

    cppTango core timeout in ms:

    • If the reply has not yet arrived, the call will wait for the time specified (in ms).

    • If after timeout, the reply is still not there, an exception is thrown.

    • If timeout set to 0, the call waits until the reply arrives.

    • If the argument is not provided, then there is no timeout check, and an exception is raised immediately if the reply is not ready.

  • extract_as (ExtractAs) – Defaults to numpy.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

None

Return type:

None

Throws:

tango.AsynCall, tango.AsynReplyNotArrived, tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed

Added in version 7.0.0.

write_attributes(attr_values: Sequence[tuple[str | AttributeInfoEx, Any]], *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) None#

Write the specified attributes.

Parameters:
  • attr_values (typing.Sequence[tuple[str | AttributeInfoEx, typing.Any]]) – A list of pairs (attr, value). See write_attribute

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.ConnectionFailed, tango.CommunicationFailed, tango.DeviceUnlocked, tango.DevFailed, tango.NamedDevFailedList: from device

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 8.1.0: green_mode parameter. wait parameter. timeout parameter.

Changed in version 10.1.0:

  • name_val parameter was renamed to attr_values

  • added support for AttributeInfoEx for attr_values parameter

write_attributes_asynch(attr_values: Sequence[tuple[str | AttributeInfoEx, Any]], cb: Callable | None = None, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) int | None#

Write asynchronously the specified attributes.

Important

by default, TANGO is initialized with the polling model. If you want to use the push model (the one with the callback parameter), you need to change the global TANGO model to PUSH_CALLBACK. You can do this with the tango.ApiUtil.set_asynch_cb_sub_model()

Parameters:
  • values (typing.Sequence[tuple[str | AttributeInfoEx, typing.Any]]) – pairs of (attr_name, value) to write (see Note below)

  • cb (typing.Optional`[:py:obj:`typing.Callable]) – push model: as soon as attributes written, core calls cb with write results. This callback object should be an instance of a user class with an attr_written() method. It can also be any callable object.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

an asynchronous call identifier which is needed to get the server reply if poll model, None if push model

Return type:

int | None

Throws:

ConnectionFailed

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Important

Multiple asynchronous calls are not guaranteed to be executed by the device server in the same order they are invoked by the client. E.g., a call to write_attributes_asynch([("a", 1)]) followed immediately with a call to read_attributes_asynch(["a"]) could result in the device reading the attribute a before writing to it.

Note

For each pair of values there are two possibilities for the attr parameter: if you give attribute name, then PyTango must fetch attribute info for this attribute from server by additional synchronous(!) IO, since we must know to which c++ data type cast each python value. If you would like to avoid this IO you must give AttributeInfoEx instead of attribute name for each(!) pair of values.

Changed in version 10.1.0: Added support for AttributeInfoEx for attr_values parameter.

write_attributes_reply(self, id: int, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) None#
write_attributes_reply(self, id: int, poll_timeout: int, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) None

Check if the answer of an asynchronous write_attributes is arrived (polling model). If the reply is arrived and if it is a valid reply, the call returned. If the reply is an exception, it is re-thrown by this call. An exception is also thrown in case of the reply is not yet arrived.

Changed in version 10.0.0: To eliminate confusion between different timeout parameters, the core (cppTango) timeout (previously the optional second positional argument) has been renamed to “poll_timeout”. Conversely, the pyTango executor timeout remains as the keyword argument “timeout”. These parameters have distinct meanings and units:

  • The cppTango “poll_timeout” is measured in milliseconds and blocks the call until a reply is received. If the reply is not received within the specified poll_timeout duration, an exception is thrown. Setting poll_timeout to 0 causes the call to wait indefinitely until a reply is received.

  • The pyTango “timeout” is measured in seconds and is applicable only in asynchronous GreenModes (Asyncio, Futures, Gevent), and only when “wait” is set to True. The specific behavior when a reply is not received within the specified timeout period varies depending on the GreenMode.

Parameters:
  • id (int) – the asynchronous call identifier

  • poll_timeout (int, optional) –

    cppTango core timeout in ms:

    • If the reply has not yet arrived, the call will wait for the time specified (in ms).

    • If after timeout, the reply is still not there, an exception is thrown.

    • If timeout set to 0, the call waits until the reply arrives.

    • If the argument is not provided, then there is no timeout check, and an exception is raised immediately if the reply is not ready.

  • extract_as (ExtractAs) – Defaults to numpy.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Throws:

tango.AsynCall, tango.AsynReplyNotArrived, tango.ConnectionFailed, tango.CommunicationFailed, tango.DevFailed

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 7.0.0.

write_read_attribute(attr: str | AttributeInfoEx, value: Any, extract_as: ExtractAs = ExtractAs.Numpy, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) DeviceAttribute#

Write then read a single attribute in a single network call. By default (serialisation by device), the execution of this call in the server can’t be interrupted by other clients.

Parameters:
  • attr (str | AttributeInfoEx) – The name or AttributeInfoEx structure of the attribute to write.

  • value (typing.Any) – The value to write to the attribute.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

A DeviceAttribute object with readout value.

Return type:

tango.DeviceAttribute

Throws:

tango.ConnectionFailed: Raised in case of a connection failure.

tango.CommunicationFailed: Raised in case of a communication failure.

tango.DeviceUnlocked: Raised in case of an unlocked device.

tango.WrongData: Raised in case of a wrong data format.

tango.DevFailed: Raised in case of a device failure.

TypeError: Raised in case of an incorrect type of input arguments.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Note

There are two possibilities for the attr parameter: if you give attribute name, then PyTango will do additional IO to fetch AttributeInfoEx object from device server, since we must know to which c++ data type cast python value. If you would like to avoid this IO you can give AttributeInfoEx instead of attribute name.

Added in version 7.0.0.

Added in version 8.1.0: green_mode parameter. wait parameter. timeout parameter.

Changed in version 10.1.0:

  • attr_name parameter was renamed to attr

  • added support for AttributeInfoEx for attr parameter

write_read_attributes(attr_values: Sequence[tuple[str | AttributeInfoEx, Any]], attr_read_names: Sequence[str], extract_as: ExtractAs = ExtractAs.Numpy, *, green_mode: GreenMode = None, wait: bool = None, timeout: int = None) DeviceAttribute#

Write then read attribute(s) in a single network call. By default (serialisation by device), the execution of this call in the server can’t be interrupted by other clients. On the server side, attribute(s) are first written and if no exception has been thrown during the write phase, attributes will be read.

Parameters:
  • attr_values (typing.Sequence[tuple[str | AttributeInfoEx, typing.Any]]) – A list of pairs (attr, value). See write_attribute

  • attr_read_names (typing.Sequence[str]) – A list of attributes to read.

  • extract_as (ExtractAs) – Defaults to numpy.

  • green_mode (GreenMode, optional) – Defaults to the current tango GreenMode. Refer to get_green_mode() and set_green_mode() for more details.

  • wait (bool, optional) – Specifies whether to wait for the result. If green_mode is Synchronous, this parameter is ignored as the operation always waits for the result. This parameter is also ignored when green_mode is Synchronous.

  • timeout (float, optional) – The number of seconds to wait for the result. If set to None, there is no limit on the wait time. This parameter is ignored when green_mode is Synchronous or when wait is False.

Returns:

A sequence DeviceAttribute object with readout values.

Return type:

list[tango.DeviceAttribute]

Throws:

tango.ConnectionFailed: Raised in case of a connection failure.

tango.CommunicationFailed: Raised in case of a communication failure.

tango.DeviceUnlocked: Raised in case of an unlocked device.

tango.WrongData: Raised in case of a wrong data format.

tango.DevFailed: Raised in case of a device failure.

TypeError: Raised in case of an incorrect type of input arguments.

Throws:

TimeoutError: (green_mode == Futures) If the future didn’t finish executing before the given timeout

gevent.Timeout: (green_mode == Gevent) If the async result

didn’t finish executing before the given timeout.

Added in version 9.2.0.

Note

For each pair of values there are two possibilities for the attr parameter: if you give attribute name, then PyTango must fetch attribute info for this attribute from server by additional synchronous(!) IO, since we must know to which c++ data type cast each python value. If you would like to avoid this IO you must give AttributeInfoEx instead of attribute name for each(!) pair of values.

Changed in version 10.1.0:

  • name_val parameter was renamed to attr_values

  • added support for AttributeInfoEx for attr_values parameter.

tango.get_device_proxy(self, dev_name: str, green_mode: GreenMode = None, wait: bool = True, timeout: float = True) DeviceProxy[source]#
tango.get_device_proxy(self, dev_name: str, need_check_acc: bool, green_mode: GreenMode = None, wait: bool = True, timeout: float = None) DeviceProxy

Returns a new DeviceProxy. There is no difference between using this function and the direct DeviceProxy constructor if you use the default kwargs.

The added value of this function becomes evident when you choose a green_mode to be Futures or Gevent or Asyncio. The DeviceProxy constructor internally makes some network calls which makes it slow. By using one of the green modes as green_mode you are allowing other python code to be executed in a cooperative way.

Note

The timeout parameter has no relation with the tango device client side timeout (gettable by get_timeout_millis() and settable through set_timeout_millis())

Parameters:
  • dev_name (str) – the device name or alias

  • need_check_acc (bool) – (optional, default is True) Determines if at creation time of DeviceProxy it should check for channel access (rarely used)

  • green_mode (GreenMode) – determines the mode of execution of the device (including the way it is created). Defaults to the current global green_mode (check get_green_mode() and set_green_mode())

  • wait (bool) – whether or not to wait for result. If green_mode Ignored when green_mode is Synchronous (always waits).

  • timeout (float) – The number of seconds to wait for the result. If None, then there is no limit on the wait time. Ignored when green_mode is Synchronous or wait is False.

Returns:

if green_mode is Synchronous or wait is True:

DeviceProxy

elif green_mode is Futures:

concurrent.futures.Future

elif green_mode is Gevent:

gevent.event.AsynchResult

elif green_mode is Asyncio:

asyncio.Future

Throws:
DevFailed if green_mode is Synchronous or wait is True

and there is an error creating the device.

concurrent.futures.TimeoutError if green_mode is Futures,

wait is False, timeout is not None and the time to create the device has expired.

gevent.timeout.Timeout if green_mode is Gevent, wait is False,

timeout is not None and the time to create the device has expired.

asyncio.TimeoutError if green_mode is Asyncio,

wait is False, timeout is not None and the time to create the device has expired.

Added in version 8.1.0.