DeviceProxy

class tango.DeviceProxy(*args, **kwargs)

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”)

DeviceProxy(dev_name, green_mode=None, wait=True, timeout=True) -> DeviceProxy DeviceProxy(self, dev_name, need_check_acc, green_mode=None, wait=True, timeout=True) -> DeviceProxy

Creates a new DeviceProxy.

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

  • need_check_acc (bool) – in first version of the function it defaults to 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

Throws:
  • : class:~tango.DevFailed if green_mode is Synchronous or wait is True and there is an error creating the device.

  • : class:concurrent.futures.TimeoutError if green_mode is Futures, wait is False, timeout is not None and the time to create the device has expired.

  • : class:gevent.timeout.Timeout if green_mode is Gevent, wait is False, timeout is not None and the time to create the device has expired.

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

add_logging_target(self, target_type_target_name) 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

Return:

None

Throws:

DevFailed from device

New in PyTango 7.0.0

adm_name(self) 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

New in PyTango 3.0.4

alias(self) str

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

Return:

(str) device alias

attribute_history(self, attr_name, depth, extract_as=ExtractAs.Numpy) sequence<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)

Return:

This method returns a vector of DeviceAttributeHistory types.

Throws:

NonSupportedFeature, ConnectionFailed, CommunicationFailed, DevFailed from device

attribute_list_query(self) sequence<AttributeInfo>

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

Parameters:

None

Return:

(sequence<AttributeInfo>) containing the attributes configuration

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

attribute_list_query_ex(self) sequence<AttributeInfoEx>

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

Parameters:

None

Return:

(sequence<AttributeInfoEx>) containing the attributes configuration

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

attribute_query(self, attr_name) AttributeInfoEx

Query the device for information about a single attribute.

Parameters:
attr_name:

(str) the attribute name

Return:

(AttributeInfoEx) containing the attribute configuration

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

black_box(self, n) sequence<str>

Get the last commands executed on the device server

Parameters:
n:

n number of commands to get

Return:

(sequence<str>) sequence of strings containing the date, time, command and from which client computer the command was executed

Example:
print(black_box(4))
cancel_all_polling_asynch_request(self) 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.

Parameters:

None

Return:

None

New in PyTango 7.0.0

cancel_asynch_request(self, id) 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:

The asynchronous call identifier

Return:

None

New in PyTango 7.0.0

command_history(self, cmd_name, depth) sequence<DeviceDataHistory>

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:

This method returns a vector of DeviceDataHistory types.

Throws:

NonSupportedFeature, ConnectionFailed, CommunicationFailed, DevFailed from device

command_inout(self, cmd_name, cmd_param=None, green_mode=None, wait=True, timeout=None) any

Execute a command on a device.

Parameters:
cmd_name:

(str) Command name.

cmd_param:

(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) Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

wait:

(bool) whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. 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.

Return:

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

Throws:

ConnectionFailed, CommunicationFailed, DeviceUnlocked, DevFailed from device TimeoutError (green_mode == Futures) If the future didn’t finish executing before the given timeout. Timeout (green_mode == Gevent) If the async result didn’t finish executing before the given timeout. TypeError if cmd_param’s type is not compatible with the command.

New 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) id
command_inout_asynch(self, cmd_name, cmd_param) id
command_inout_asynch(self, cmd_name, cmd_param, forget) id

Execute asynchronously (polling model) a command on a device

Parameters:
cmd_name:

(str) Command name.

cmd_param:

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

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.

Return:

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

Throws:

ConnectionFailed, TypeError, anything thrown by command_query

command_inout_asynch( self, cmd_name, callback) -> None

command_inout_asynch( self, cmd_name, cmd_param, callback) -> None

Execute asynchronously (callback model) a command on a device.

Parameters:
cmd_name:

(str) Command name.

cmd_param:

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

callback:

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

Return:

None

Throws:

ConnectionFailed, TypeError, anything thrown by command_query

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.:class:`ApiUtil().set_asynch_cb_sub_model`

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(self, cmd_name, cmd_param=None) DeviceData

Execute a command on a device.

Parameters:
cmd_name:

(str) Command name.

cmd_param:

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

Return:

A DeviceData object.

Throws:

ConnectionFailed, CommunicationFailed, DeviceUnlocked, DevFailed from device. TypeError if cmd_param’s type is not compatible with the command.

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(self, idx, timeout=None) 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. 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.

Return:

(DeviceData)

Throws:

AsynCall, AsynReplyNotArrived, CommunicationFailed, DevFailed from device

command_inout_reply_raw(self, id, timeout) 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:

(int)

Return:

(DeviceData)

Throws:

AsynCall, AsynReplyNotArrived, CommunicationFailed, DevFailed from device

command_list_query(self) sequence<CommandInfo>

Query the device for information on all commands.

Parameters:

None

Return:

(CommandInfoList) Sequence of CommandInfo objects

command_query(self, command) CommandInfo

Query the device for information about a single command.

Parameters:
command:

(str) command name

Return:

(CommandInfo) object

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

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 form more detail

connect(self, corba_name) 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

Return:

None

New in PyTango 7.0.0

delete_property(self, value, green_mode=None, wait=True, timeout=None)

Delete a the given of properties for this device. This method accepts the following types as value parameter:

  1. string [in] - single property to be deleted

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

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

  4. sequence<string> [in]- several property data to be deleted

  5. sequence<DbDatum> [in] - several property data to be deleted

  6. dict<str, obj> [in] - keys are property names to be deleted (values are ignored)

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

Parameters:
  • value (string, tango.DbDatum, tango.DbData, sequence<string>, sequence<DbDatum>, dict<str, obj>, dict<str, DbDatum>) – Can be one of the following: 1. string [in] - Single property data to be deleted. 2. tango.DbDatum [in] - Single property data to be deleted. 3. tango.DbData [in] - Several property data to be deleted. 4. sequence<string> [in] - Several property data to be deleted. 5. sequence<DbDatum> [in] - Several property data to be deleted. 6. dict<str, obj> [in] - Keys are property names to be deleted (values are ignored). 7. dict<str, DbDatum> [in] - Several DbDatum.name are property names to be deleted (keys are ignored).

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

  • wait (bool) – 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

Raises:
  • ConnectionFailed – Raised in case of a connection failure.

  • CommunicationFailed – Raised in case of a communication failure.

  • DevFailed – Raised in case of a device failure, specifically DB_SQLError.

  • TypeError – Raised in case of an incorrect type of input arguments.

description(self) str

Get device description.

Parameters:

None

Return:

(str) describing the device

dev_name(self) str

Return the device name as it is stored locally

Parameters:

None

Return:

(str)

event_queue_size(self, event_id) 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

Return:

an integer with the queue size

Throws:

EventSystemFailed

New in PyTango 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().

New in version 9.4.0.

get_access_control(self) AccessControlType

Returns the current access control type

Parameters:

None

Return:

(AccessControlType) The current access control type

New in PyTango 7.0.0

get_access_right(self) AccessControlType

Returns the current access control type

Parameters:

None

Return:

(AccessControlType) The current access control type

New in PyTango 8.0.0

get_asynch_replies(self, call_timeout) 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

Return:

None

New in PyTango 7.0.0

get_attribute_config(self, name, green_mode=None, wait=True, timeout=None) AttributeInfoEx
get_attribute_config(self, names, green_mode=None, wait=True, timeout=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: use get_attribute_config_ex instead

Parameters:
  • name (str) – Attribute name.

  • names (sequence(str)) – Attribute names.

  • green_mode (GreenMode) – Defaults to the current DeviceProxy GreenMode. See tango.DeviceProxy.get_green_mode and tango.DeviceProxy.set_green_mode for more details.

  • wait (bool) – 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:

Union[AttributeInfoEx, AttributeInfoList]

Raises:
get_attribute_config_ex(self, name or sequence(names), green_mode=None, wait=True, timeout=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:
  • name (str or sequence(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) – Defaults to the current DeviceProxy GreenMode. Refer to tango.DeviceProxy.get_green_mode and tango.DeviceProxy.set_green_mode for more details.

  • wait (bool) – 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

Raises:
get_attribute_list(self) sequence<str>

Return the names of all attributes implemented for this device.

Parameters:

None

Return:

sequence<str>

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

get_attribute_poll_period(self, attr_name) int

Return the attribute polling period.

Parameters:
attr_name:

(str) attribute name

Return:

polling period in milliseconds

get_command_config(self, green_mode=None, wait=True, timeout=None) CommandInfoList
get_command_config(self, name, green_mode=None, wait=True, timeout=None) CommandInfo
get_command_config(self, names) 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 (sequence<str>, optional) – Command names. Used when querying information for multiple commands. This parameter should not be used simultaneously with ‘name’.

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

  • wait (bool) – 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 or CommandInfo

Raises:
get_command_list(self) sequence<str>

Return the names of all commands implemented for this device.

Parameters:

None

Return:

sequence<str>

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device

get_command_poll_period(self, cmd_name) int

Return the command polling period.

Parameters:
cmd_name:

(str) command name

Return:

polling period in milliseconds

get_db_host(self) str

Returns a string with the database host.

Parameters:

None

Return:

(str)

New in PyTango 7.0.0

get_db_port(self) str

Returns a string with the database port.

Parameters:

None

Return:

(str)

New in PyTango 7.0.0

get_db_port_num(self) int

Returns an integer with the database port.

Parameters:

None

Return:

(int)

New in PyTango 7.0.0

get_dev_host(self) str

Returns the current host

Parameters:

None

Return:

(str) the current host

New in PyTango 7.2.0

get_dev_port(self) str

Returns the current port

Parameters:

None

Return:

(str) the current port

New in PyTango 7.2.0

get_device_db(self) Database

Returns the internal database reference

Parameters:

None

Return:

(Database) object

New in PyTango 7.0.0

get_events(self, event_id, callback=None, extract_as=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 (callable) – Any callable object or any object with a “push_event” method.

  • extract_as (ExtractAs) – (Description Needed)

Returns:

None

Raises:
  • 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()

get_fqdn(self) str

Returns the fully qualified domain name

Parameters:

None

Return:

(str) the fully qualified domain name

New in PyTango 7.2.0

get_from_env_var(self) bool

Returns True if determined by environment variable or False otherwise

Parameters:

None

Return:

(bool)

New in PyTango 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

New in PyTango 8.1.0

get_idl_version(self) int

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

Parameters:

None

Return:

(int)

get_last_event_date(self, event_id) 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

Return:

(tango.TimeVal) representing the arrival time

Throws:

EventSystemFailed

New in PyTango 7.0.0

get_locker(self, lockinfo) 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 [out]:

(tango.LockInfo) object that will be filled with lock informantion

Return:

(bool) True if the device is locked by us. Otherwise, False

New in PyTango 7.0.0

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

  • 1=FATAL

  • 2=ERROR

  • 3=WARNING

  • 4=INFO

  • 5=DEBUG

:Parameters:None :Return: (int) representing the current logging level

New in PyTango 7.0.0

get_logging_target(self) sequence<str>

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.

Parameters:

None

Return:

a squence<str> with the logging targets

New in PyTango 7.0.0

get_pipe_config(self, green_mode=None, wait=True, timeout=None) PipeInfoList
get_pipe_config(self, name, green_mode=None, wait=True, timeout=None) PipeInfo
get_pipe_config(self, names) PipeInfoList

Return the pipe configuration for single/list/all pipes.

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

  • names (sequence<str>, optional) – Pipe names. Used when querying information for multiple pipes. This parameter should not be used simultaneously with ‘name’.

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

  • wait (bool) – 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 or CommandInfo

Raises:
  • ConnectionFailed – Raised in case of a connection failure.

  • CommunicationFailed – Raised in case of a communication failure.

  • DevFailed – Raised in case of a device failure.

  • TypeError

    Raised in case of an incorrect type of input arguments.

    New in PyTango 9.2.0

get_property(self, propname, value=None, green_mode=None, wait=True, timeout=None) tango.DbData

Get a (list) property(ies) for a device.

This method accepts the following types as propname parameter: 1. string [in] - single property data to be fetched 2. sequence<string> [in] - several property data to be fetched 3. tango.DbDatum [in] - single property data to be fetched 4. tango.DbData [in,out] - several property data to be fetched. 5. sequence<DbDatum> - several property data to be feteched

Note: for cases 3, 4 and 5 the ‘value’ parameter if given, is IGNORED.

If value is given it must be a tango.DbData that will be filled with the property values

Parameters:
  • propname (any) – Property(ies) name(s).

  • value (DbData, optional) – Optional. The default is None, meaning that the method will create internally a tango.DbData and return it filled with the property values.

  • green_mode (GreenMode) – Defaults to the current DeviceProxy GreenMode. See tango.DeviceProxy.get_green_mode and tango.DeviceProxy.set_green_mode.

  • wait (bool) – Whether to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. Ignored when green_mode is Synchronous (always waits).

  • timeout (float, optional) – 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:

A DbData object containing the property(ies) value(s). If a tango.DbData is given as a parameter, it returns the same object; otherwise, a new tango.DbData is returned.

Return type:

DbData

Raises:
  • NonDbDevice – Raised in case of a non-database device error.

  • ConnectionFailed – Raised on connection failure with the database.

  • CommunicationFailed – Raised on communication failure with the database.

  • DevFailed – Raised on a device failure from the database device.`

get_property_list(self, filter, array=None, green_mode=None, wait=True, timeout=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 (sequence obj or None, optional) – 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) – Defaults to the current DeviceProxy GreenMode. Refer to tango.DeviceProxy.get_green_mode and tango.DeviceProxy.set_green_mode for more details.

  • wait (bool) – 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

Raises:
  • NonDbDevice – Raised in case of a non-database device error.

  • WrongNameSyntax – Raised in case of incorrect syntax in the name.

  • ConnectionFailed – Raised in case of a connection failure with the database.

  • CommunicationFailed – Raised in case of a communication failure with the database.

  • DevFailed – Raised in case of a device failure from the database device.

  • TypeError

    Raised in case of an incorrect type of input arguments.

    New in PyTango 7.0.0

get_source(self) DevSource

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

Parameters:

None

Return:

(DevSource)

Example:
source = dev.get_source()
if source == DevSource.CACHE_DEV : ...
get_tango_lib_version(self) int

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

Return:

(int) The device Tango lib version as a 3 or 4 digits number. Possible return value are: 100,200,500,520,700,800,810,…

New in PyTango 8.1.0

get_timeout_millis(self) int

Get the client side timeout in milliseconds

Parameters:

None

Return:

(int)

get_transparency_reconnection(self) bool

Returns the device transparency reconnection flag.

Parameters:

None

Return:

(bool) True if transparency reconnection is set or False otherwise

import_info(self) DbDevImportInfo

Query the device for import info from the database.

Parameters:

None

Return:

(DbDevImportInfo)

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) DeviceInfo

A method which returns information on the device

Parameters:

None

Return:

(DeviceInfo) object

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)

All DeviceInfo fields are strings except for the server_version
which is an integer"
is_attribute_polled(self, attr_name) bool

True if the attribute is polled.

Parameters:

attr_name (str) – attribute name

Returns:

boolean value

Return type:

bool

is_command_polled(self, cmd_name) bool

True if the command is polled.

Parameters:

cmd_name (str) – command name

Returns:

boolean value

Return type:

bool

is_dbase_used(self) bool

Returns if the database is being used

Parameters:

None

Return:

(bool) True if the database is being used

New in PyTango 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.

rtype:

bool

New in version 9.4.0.

is_event_queue_empty(self, event_id) 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

Return:

(bool) True if queue is empty or False otherwise

Throws:

EventSystemFailed

New in PyTango 7.0.0

is_locked(self) bool

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

Parameters:

None

Return:

(bool) True if the device is locked. Otherwise, False

New in PyTango 7.0.0

is_locked_by_me(self) bool

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

Parameters:

None

Return:

(bool) True if the device is locked by us. Otherwise, False

New in PyTango 7.0.0

lock(self, (int)lock_validity) 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 (optional, default value is tango.constants.DEFAULT_LOCK_VALIDITY)

Return:

None

New in PyTango 7.0.0

locking_status(self) 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

Parameters:

None

Return:

a string representing the current locking status

New in PyTango 7.0.0”

name(self) str

Return the device name from the device itself.

pending_asynch_call(self) int

Return number of device asynchronous pending requests”

New in PyTango 7.0.0

ping(self, green_mode=None, wait=True, timeout=True) int

A method which sends a ping to the device

Parameters:
green_mode:

(GreenMode) Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

wait:

(bool) whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. 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.

Return:

(int) time elapsed in microseconds

Throws:

exception if device is not alive

poll_attribute(self, attr_name, period) None

Add an attribute to the list of polled attributes.

Parameters:
attr_name:

(str) attribute name

period:

(int) polling period in milliseconds

Return:

None

poll_command(self, cmd_name, period) None

Add a command to the list of polled commands.

Parameters:
cmd_name:

(str) command name

period:

(int) polling period in milliseconds

Return:

None

polling_status(self) sequence<str>

Return the device polling status.

Parameters:

None

Return:

(sequence<str>) 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

put_property(self, value, green_mode=None, wait=True, timeout=None) None

Insert or update a list of properties for this device. This method accepts the following types as value parameter: 1. tango.DbDatum - single property data to be inserted 2. tango.DbData - several property data to be inserted 3. sequence<DbDatum> - several property data to be inserted 4. dict<str, DbDatum> - keys are property names and value has data to be inserted 5. dict<str, seq<str>> - keys are property names and value has data to be inserted 6. dict<str, obj> - keys are property names and str(obj) is property value

Parameters:
  • value (tango.DbDatum, tango.DbData, sequence<DbDatum>, dict<str, DbDatum>, dict<str, seq<str>>, dict<str, obj>) – Can be one of the following: 1. tango.DbDatum - Single property data to be inserted. 2. tango.DbData - Several property data to be inserted. 3. sequence<DbDatum> - Several property data to be inserted. 4. dict<str, DbDatum> - Keys are property names, and value has data to be inserted. 5. dict<str, seq<str>> - Keys are property names, and value has data to be inserted. 6. dict<str, obj> - Keys are property names, and str(obj) is property value.

  • green_mode (GreenMode) – Defaults to the current DeviceProxy GreenMode. See tango.DeviceProxy.get_green_mode and tango.DeviceProxy.set_green_mode.

  • wait (bool) – Whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. Ignored when green_mode is Synchronous (always waits).

  • timeout (float, optional) – 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:

None

Raises:
read_attribute(self, attr_name, extract_as=ExtractAs.Numpy, green_mode=None, wait=True, timeout=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) Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

wait:

(bool) whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. 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.

Return:

(DeviceAttribute)

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device TimeoutError (green_mode == Futures) If the future didn’t finish executing before the given timeout. 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.

New 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, green_mode=None, wait=True, timeout=None) int
read_attribute_asynch(self, attr_name, cb, extract_as=Numpy, green_mode=None, wait=True, timeout=None) None

Read asynchronously the specified attributes.

New in PyTango 7.0.0

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 (Optional[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) – Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

  • wait (bool) – whether to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result.

  • 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:

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

Return type:

Union[int, None]

Throws:

ConnectionFailed

read_attribute_reply(self, id, extract_as=ExtractAs.Numpy, green_mode=None, wait=True) DeviceAttribute
read_attribute_reply(self, id, poll_timeout, extract_as=ExtractAs.Numpy, green_mode=None, wait=True) DeviceAttribute

Check if the answer of an asynchronous read_attribute is arrived (polling model).

Changed in version 7.0.0: New in PyTango

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 (Optional[int]) – 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) – Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

  • wait (bool) – whether to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result.

  • timeout (float) – pytango green executor timout. 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 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:

DeviceAttribute

Throws:

Union[AsynCall, AsynReplyNotArrived, ConnectionFailed, CommunicationFailed, DevFailed]

read_attributes(self, attr_names, extract_as=ExtractAs.Numpy, green_mode=None, wait=True, timeout=None) sequence<DeviceAttribute>

Read the list of specified attributes.

Parameters:
attr_names:

(sequence<str>) A list of attributes to read.

extract_as:

(ExtractAs) Defaults to numpy.

green_mode:

(GreenMode) Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

wait:

(bool) whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. 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.

Return:

(sequence<DeviceAttribute>)

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device TimeoutError (green_mode == Futures) If the future didn’t finish executing before the given timeout. Timeout (green_mode == Gevent) If the async result didn’t finish executing before the given timeout.

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

read_attributes_asynch(self, attr_names, green_mode=None, wait=True, timeout=None) int
read_attributes_asynch(self, attr_names, cb, extract_as=Numpy, green_mode=None, wait=True, timeout=None) None

Read asynchronously an attribute list.

New in PyTango 7.0.0

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 (Sequence[str]) – A list of attributes to read. See read_attributes.

  • cb (Optional[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) – Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

  • wait (bool) – whether to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result.

  • 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:

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

Return type:

Union[int, None]

Throws:

ConnectionFailed

read_attributes_reply(self, id, extract_as=ExtractAs.Numpy, green_mode=None, wait=True) [DeviceAttribute]
read_attributes_reply(self, id, poll_timeout, extract_as=ExtractAs.Numpy, green_mode=None, wait=True) [DeviceAttribute]

Check if the answer of an asynchronous read_attributes is arrived (polling model).

Changed in version 7.0.0: New in PyTango

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 (Optional[int]) – 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) – Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

  • wait (bool) – whether to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result.

  • timeout (float) – pytango green executor timout. 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 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:

Sequence[DeviceAttribute]

Throws:

Union[AsynCall, AsynReplyNotArrived, ConnectionFailed, CommunicationFailed, DevFailed]

read_pipe(self, pipe_name, extract_as=ExtractAs.Numpy, green_mode=None, wait=True, timeout=None) tuple

Read a single pipe. The result is a blob: a tuple with two elements: blob name (string) and blob data (sequence). The blob data consists of a sequence where each element is a dictionary with the following keys:

  • name: blob element name

  • dtype: tango data type

  • value: blob element data (str for DevString, etc)

In case dtype is DevPipeBlob, value is again a blob.

Parameters:
pipe_name:

(str) The name of the pipe to read.

extract_as:

(ExtractAs) Defaults to numpy.

green_mode:

(GreenMode) Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

wait:

(bool) whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. 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.

Return:

tuple<str, sequence>

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device TimeoutError (green_mode == Futures) If the future didn’t finish executing before the given timeout. Timeout (green_mode == Gevent) If the async result didn’t finish executing before the given timeout.

New in PyTango 9.2.0

reconnect(self, db_used) None

Reconnecto to a CORBA object.

Parameters:
db_used:

(bool) Use thatabase

Return:

None

New in PyTango 7.0.0

remove_logging_target(self, target_type_target_name) 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

Return:

None

New in PyTango 7.0.0

set_access_control(self, acc) None

Sets the current access control type

Parameters:
acc:

(AccessControlType) the type of access control to set

Return:

None

New in PyTango 7.0.0

set_attribute_config(self, attr_info, green_mode=None, wait=True, timeout=None) None
set_attribute_config(self, attr_info_ex, green_mode=None, wait=True, timeout=None) None

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

Parameters:
  • attr_info (Union[AttributeInfo, Sequence[AttributeInfo]], optional) – Attribute information. This parameter is used when providing basic attribute(s) information.

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

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

  • wait (bool) – 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

Raises:
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

New in PyTango 8.1.0

set_logging_level(self, (int)level) 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

Return:

None

New in PyTango 7.0.0

set_pipe_config(self, pipe_info, green_mode=None, wait=True, timeout=None) None
set_pipe_config(self, pipe_info, green_mode=None, wait=True, timeout=None) None

Change the pipe configuration for the specified pipe

Parameters:
  • pipe_info (PipeInfo, optional) – Pipe information for a single pipe.

  • pipes_info (sequence<PipeInfo>, optional) – Pipes information for multiple pipes.

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

  • wait (bool) – 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

Raises:
set_source(self, source) None

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

Parameters:
source:

(DevSource) constant.

Return:

None

Example:
dev.set_source(DevSource.CACHE_DEV)
set_timeout_millis(self, timeout) None

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

Parameters:
timeout:

integer value of timeout in milliseconds

Return:

None

Example:
dev.set_timeout_millis(1000)
set_transparency_reconnection(self, yesno) None

Set the device transparency reconnection flag

Parameters:

” - val : (bool) True to set transparency reconnection ” or False otherwise

Return:

None

state(self, green_mode=None, wait=True, timeout=None) DevState

A method which returns the state of the device.

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

  • wait (bool) – 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

status(self, green_mode=None, wait=True, timeout=None) str

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

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

  • wait (bool) – 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

stop_poll_attribute(self, attr_name) None

Remove an attribute from the list of polled attributes.

Parameters:
attr_name:

(str) attribute name

Return:

None

stop_poll_command(self, cmd_name) None

Remove a command from the list of polled commands.

Parameters:
cmd_name:

(str) command name

Return:

None

subscribe_event(self, event_type, cb, stateless=False, green_mode=None, wait=True, timeout=None) int
subscribe_event(self, attr_name, event, cb, filters=[], stateless=False, extract_as=Numpy, green_mode=None, wait=True, timeout=None) int
subscribe_event(self, attr_name, event, queuesize, filters=[], stateless=False, green_mode=None, wait=True, timeout=None) int

The client call to subscribe for event reception. In the push model the client implements a callback method which is triggered when the event is received. Filtering is done based on the reason specified and the event type. For example when reading the state and the reason specified is “change” the event will be fired only when the state changes. Events consist of an attribute name and the event reason. A standard set of reasons are implemented by the system, additional device specific reasons can be implemented by device servers programmers.

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.PERIODIC_EVENT * EventType.ARCHIVE_EVENT * EventType.ATTR_CONF_EVENT * EventType.DATA_READY_EVENT * EventType.USER_EVENT

  • cb (callable) – Any callable object or an object with a callable “push_event” method.

  • filters (sequence<str>, optional) – A variable list of name, value pairs which define additional filters for events.

  • stateless (bool) – 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 always succeed, even if the corresponding device server is not running. 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.

  • queuesize (float, optional) – the size of the event reception buffer. 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 = ALL_EVENTS : The client buffers all received events. The buffer size is unlimited and only restricted by the available memory for the client.

  • extract_as (ExtractAs) – (Description Needed)

  • green_mode (GreenMode) – Defaults to the current DeviceProxy GreenMode. See tango.DeviceProxy.get_green_mode and tango.DeviceProxy.set_green_mode for more details.

  • wait (bool) – 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

Raises:
  • EventSystemFailed – Raised in case of a failure in the event system.

  • TypeError – Raised in case of an incorrect type of input 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().

New in version 9.4.0.

unlock(self, (bool)force) 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 purpopse 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 (optional, default value is False)

Return:

None

New in PyTango 7.0.0

unsubscribe_event(self, event_id, green_mode=None, wait=True, timeout=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) – Defaults to the current DeviceProxy GreenMode. Refer to tango.DeviceProxy.get_green_mode and tango.DeviceProxy.set_green_mode for more details.

  • wait (bool) – 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

Raises:
  • 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.

write_attribute(self, attr_name, value, green_mode=None, wait=True, timeout=None) None
write_attribute(self, attr_info, value, green_mode=None, wait=True, timeout=None) None

Write a single attribute.

Parameters:
attr_name:

(str) The name of the attribute to write.

attr_info:

(AttributeInfo)

value:

The value. For non SCALAR attributes it may be any sequence of sequences.

green_mode:

(GreenMode) Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

wait:

(bool) whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. 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.

Throws:

ConnectionFailed, CommunicationFailed, DeviceUnlocked, DevFailed from device TimeoutError (green_mode == Futures) If the future didn’t finish executing before the given timeout. Timeout (green_mode == Gevent) If the async result didn’t finish executing before the given timeout.

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

write_attribute_asynch(attr_name, value, cb=None, **kwargs)

write_attributes_asynch(self, attr_name, value, green_mode=None, wait=True, timeout=None) -> int write_attributes_asynch(self, attr_name, value, cb, green_mode=None, wait=True, timeout=None) -> 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_name (str) – an attribute to write

  • value (Any) – value to write

  • cb (Optional[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) – Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

  • wait (bool) – whether to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result.

  • 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:

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

Return type:

Union[int, None]

Throws:

ConnectionFailed

write_attribute_reply(self, id, green_mode=None, wait=True) None
write_attribute_reply(self, id, poll_timeout, green_mode=None, wait=True) 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 7.0.0: New in PyTango

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 (Optional[int]) – 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) – Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

  • wait (bool) – whether to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result.

  • timeout (float) – pytango green executor timout. 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:

None

Return type:

None

Throws:

Union[AsynCall, AsynReplyNotArrived, ConnectionFailed, CommunicationFailed, DevFailed]

write_attributes(self, name_val, green_mode=None, wait=True, timeout=None) None

Write the specified attributes.

Parameters:
name_val:

A list of pairs (attr_name, value). See write_attribute

green_mode:

(GreenMode) Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

wait:

(bool) whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. 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.

Throws:

ConnectionFailed, CommunicationFailed, DeviceUnlocked, DevFailed or NamedDevFailedList from device TimeoutError (green_mode == Futures) If the future didn’t finish executing before the given timeout. Timeout (green_mode == Gevent) If the async result didn’t finish executing before the given timeout.

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

write_attributes_asynch(self, values, green_mode=None, wait=True, timeout=None) int
write_attributes_asynch(self, values, cb, green_mode=None, wait=True, timeout=None) 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 (Sequence[Sequence[str, Any]]) – attributes to write

  • cb (Optional[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) – Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

  • wait (bool) – whether to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result.

  • 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:

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

Return type:

Union[int, None]

Throws:

ConnectionFailed

write_attributes_reply(self, id, green_mode=None, wait=True) None
write_attributes_reply(self, id, poll_timeout, green_mode=None, wait=True) 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 7.0.0: New in PyTango

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 (Optional[int]) – 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) – Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

  • wait (bool) – whether to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result.

  • timeout (float) – pytango green executor timout. 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:

None

Return type:

None

Throws:

Union[AsynCall, AsynReplyNotArrived, ConnectionFailed, CommunicationFailed, DevFailed]

write_pipe(self, blob, green_mode=None, wait=True, timeout=None)

Write a blob to a single pipe. The blob comprises: a tuple with two elements: blob name (string) and blob data (sequence). The blob data consists of a sequence where each element is a dictionary with the following keys:

  • name: blob element name

  • dtype: tango data type

  • value: blob element data (str for DevString, etc)

In case dtype is DevPipeBlob, value is also a blob.

Parameters:
blob:

a tuple with two elements: blob name (string) and blob data (sequence).

green_mode:

(GreenMode) Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

wait:

(bool) whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. 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.

Throws:

ConnectionFailed, CommunicationFailed, DevFailed from device TimeoutError (green_mode == Futures) If the future didn’t finish executing before the given timeout. Timeout (green_mode == Gevent) If the async result didn’t finish executing before the given timeout.

New in PyTango 9.2.1

write_read_attribute(self, attr_name, value, extract_as=ExtractAs.Numpy, green_mode=None, wait=True, timeout=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:

see write_attribute(attr_name, value)

Return:

A tango.DeviceAttribute object.

Throws:

ConnectionFailed, CommunicationFailed, DeviceUnlocked, DevFailed from device, WrongData TimeoutError (green_mode == Futures) If the future didn’t finish executing before the given timeout. Timeout (green_mode == Gevent) If the async result didn’t finish executing before the given timeout.

New in PyTango 7.0.0

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

write_read_attributes(self, name_val, attr_names, extract_as=ExtractAs.Numpy, green_mode=None, wait=True, timeout=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:
name_val:

A list of pairs (attr_name, value). See write_attribute

attr_names:

(sequence<str>) A list of attributes to read.

extract_as:

(ExtractAs) Defaults to numpy.

green_mode:

(GreenMode) Defaults to the current DeviceProxy GreenMode. (see get_green_mode() and set_green_mode()).

wait:

(bool) whether or not to wait for result. If green_mode is Synchronous, this parameter is ignored as it always waits for the result. 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.

Return:

(sequence<DeviceAttribute>)

Throws:

ConnectionFailed, CommunicationFailed, DeviceUnlocked, DevFailed from device, WrongData TimeoutError (green_mode == Futures) If the future didn’t finish executing before the given timeout. Timeout (green_mode == Gevent) If the async result didn’t finish executing before the given timeout.

New in PyTango 9.2.0

tango.get_device_proxy(self, dev_name, green_mode=None, wait=True, timeout=True) DeviceProxy
tango.get_device_proxy(self, dev_name, need_check_acc, green_mode=None, wait=True, timeout=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) – in first version of the function it defaults to 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

else if green_mode is Futures:

concurrent.futures.Future

else if green_mode is Gevent:

gevent.event.AsynchResult

else if green_mode is Asyncio:

asyncio.Future

Throws:
  • a DevFailed if green_mode is Synchronous or wait is True and there is an error creating the device.

  • a concurrent.futures.TimeoutError if green_mode is Futures, wait is False, timeout is not None and the time to create the device has expired.

  • a gevent.timeout.Timeout if green_mode is Gevent, wait is False, timeout is not None and the time to create the device has expired.

  • a asyncio.TimeoutError if green_mode is Asyncio, wait is False, timeout is not None and the time to create the device has expired.

New in PyTango 8.1.0