Group#

Group class#

class tango.Group(name)[source]#

Bases: object

A Tango Group represents a hierarchy of tango devices. The hierarchy may have more than one level. The main goal is to group devices with same attribute(s)/command(s) to be able to do parallel requests.

add(self, device: str, timeout_ms: int = -1) None[source]#
add(self, device_list: list[str], timeout_ms: int = -1) None
add(self, subgroup: Group, timeout_ms: int = -1) None

Attaches any device which name matches one of the specified patterns.

This method first asks the Tango database the list of device names matching one the patterns. Devices are then attached to the group in the order in which they are returned by the database.

Any device already present in the hierarchy (i.e. a device belonging to the group or to one of its subgroups), is silently ignored but its client side timeout is set to timeout_ms milliseconds if timeout_ms is different from -1.

Parameters:
  • device (str) – a simple device name or a device name pattern (e.g. domain_*/ family/member_*)

  • device_list (list[str]) – a sequence of these of a simple device names or a device name patterns (e.g. domain_*/ family/member_*)

  • subgroup (Group) – a Group to be attached as subgroup

  • timeout_ms (int) – If timeout_ms is different from -1, the client side timeouts of all devices matching the specified patterns are set to timeout_ms milliseconds

Throws:

TypeError, ArgumentError

command_inout(self, cmd_name: str, forward: bool = True) list[GroupCmdReply][source]#
command_inout(self, cmd_name: str, param: Any, forward: bool = True) list[GroupCmdReply]
command_inout(self, cmd_name: str, param_list: DeviceDataList, forward: bool = True) list[GroupCmdReply]
Just a shortcut to do:

self.command_inout_reply(self.command_inout_asynch(…))

Parameters:
  • cmd_name (str) – Command name

  • param (typing.Any) – Command parameter

  • param_list (DeviceDataList) – Sequence of command parameters

  • forward (bool) – If it is set to true (the default) request is forwarded to subgroups. Otherwise, it is only applied to the local set of devices

command_inout_asynch(cmd_name: str, param: Any = None, forward: bool = True) int[source]#

Executes a Tango command on each device in the group asynchronously. The method sends the request to all devices and returns immediately. Pass the returned request id to Group.command_inout_reply() to obtain the results.

Parameters:
  • cmd_name (str) – command name

  • param (typig.Any) – parameter value

  • forward (bool) – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

Returns:

request id. Pass the returned request id to Group.command_inout_reply() to obtain the results.

Return type:

int

command_inout_reply(self: tango._tango.__Group, req_id: SupportsInt | SupportsIndex, timeout_ms: SupportsInt | SupportsIndex = 0) tango._tango.GroupCmdReplyList#

Returns the results of an asynchronous command.

Parameters:
  • req_id (int) – Is a request identifier previously returned by one of the command_inout_asynch methods

  • timeout_ms (int) – For each device in the hierarchy, if the command result is not yet available, command_inout_reply wait timeout_ms milliseconds before throwing an exception. This exception will be part of the global reply. If timeout_ms is set to 0, command_inout_reply waits “indefinitely”.

Return type:

list[GroupCmdReply]

contains(self: tango._tango.__Group, pattern: str, forward: bool = True) bool#

Returns true if the hierarchy contains groups and/or devices which name matches the specified pattern.

Parameters:
  • pattern (str) – The pattern can be a fully qualified or simple group name, a device name or a device name pattern.

  • forward – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

disable(*args, **kwargs)#

Overloaded function.

  1. disable(self: tango._tango.__Group) -> None

  2. disable(self: tango._tango.__Group, dev_name: str, forward: bool = True) -> None

Disables group element. The element will be excluded from all group operations.

Parameters:
  • dev_name (str) – device_name name of the element, can contain wildcards (*). If more than one device matches the pattern, only the first one will be disabled.

  • forward (bool) – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

enable(*args, **kwargs)#

Overloaded function.

  1. enable(self: tango._tango.__Group) -> None

  2. enable(self: tango._tango.__Group, dev_name: str, forward: bool = True) -> None

Enables group element. The element will participate in all group operations.

Parameters:
  • dev_name (str) – device_name name of the element, can contain wildcards (*). If more than one device matches the pattern, only the first one will be enabled.

  • forward (bool) – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

get_device(name_or_index: str | int) DeviceProxy[source]#

Returns a reference to the specified device or None if there is no device by that name in the group. Or, returns a reference to the “idx-th” device in the hierarchy or NULL if the hierarchy contains less than “idx” devices.

The request is systematically forwarded to subgroups (i.e. if no device named device_name could be found in the local set of devices, the request is forwarded to subgroups).

This method may throw an exception in case the specified device belongs to the group but can’t be reached (not registered, down…).

Parameters:

name_or_index (str | int) – device name of index in group

Return type:

DeviceProxy

Throws:

DevFailed

get_device_list(self: tango._tango.__Group, forward: bool = True) tango._tango.StdStringVector#

Considering the following hierarchy:

g2.add("my/device/04")
g2.add("my/device/05")

g4.add("my/device/08")
g4.add("my/device/09")

g3.add("my/device/06")
g3.add(g4)
g3.add("my/device/07")

g1.add("my/device/01")
g1.add(g2)
g1.add("my/device/03")
g1.add(g3)
g1.add("my/device/02")

The returned vector content depends on the value of the forward option. If set to true, the results will be organized as follows:

    dl = g1.get_device_list(True)

dl[0] contains "my/device/01" which belongs to g1
dl[1] contains "my/device/04" which belongs to g1.g2
dl[2] contains "my/device/05" which belongs to g1.g2
dl[3] contains "my/device/03" which belongs to g1
dl[4] contains "my/device/06" which belongs to g1.g3
dl[5] contains "my/device/08" which belongs to g1.g3.g4
dl[6] contains "my/device/09" which belongs to g1.g3.g4
dl[7] contains "my/device/07" which belongs to g1.g3
dl[8] contains "my/device/02" which belongs to g1

If the forward option is set to false, the results are:

    dl = g1.get_device_list(False);

dl[0] contains "my/device/01" which belongs to g1
dl[1] contains "my/device/03" which belongs to g1
dl[2] contains "my/device/02" which belongs to g1
Parameters:

forward (bool) – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

Returns:

The list of devices currently in the hierarchy.

Return type:

list[str]

get_fully_qualified_name(self: tango._tango.__Group) str#

Get the complete (dpt-separated) name of the group. This takes into consideration the name of the group and its parents

get_group(group_name: str) Group[source]#

Returns a reference to the specified group or None if there is no group by that name. The group_name can be a fully qualified name.

Considering the following group:

-> gauges
    |-> cell-01
    |    |-> penning
    |    |    |-> ...
    |    |-> pirani
    |    |-> ...
    |-> cell-02
    |    |-> penning
    |    |    |-> ...
    |    |-> pirani
    |    |-> ...
    | -> cell-03
    |    |-> ...
    |
    | -> ...

A call to gauges.get_group(“penning”) returns the first group named “penning” in the hierarchy (i.e. gauges.cell-01.penning) while gauges.get_group(“gauges.cell-02.penning’’) returns the specified group.

The request is systematically forwarded to subgroups (i.e. if no group named group_name could be found in the local set of elements, the request is forwarded to subgroups).

Parameters:

group_name (str)

Return type:

Group

Added in version 7.0.0.

get_name(self: tango._tango.__Group) str#

Get the name of the group. Eg: Group(‘name’).get_name() == ‘name’

get_size(self: tango._tango.__Group, forward: bool = True) int#

The number of the devices in the hierarchy

Parameters:

forward (bool) – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

is_enabled(self: tango._tango.__Group, device_name: str, forward: bool = True) bool#

Check if a device is enabled

Parameters:
  • dev_name (str) – device_name name of the element. If more than one device matches the pattern, only the first one will be checked.

  • forward (bool) – flag to perform recursive search for the element in all sub-groups

Added in version 7.0.0.

name_equals(self: tango._tango.__Group, name: str) bool#

Added in version 7.0.0.

name_matches(self: tango._tango.__Group, name: str) bool#

Added in version 7.0.0.

ping(self: tango._tango.__Group, forward: bool = True) bool#

Ping all devices in a group. This method returns true if all devices in the group are alive, false otherwise.

Parameters:

forward (bool) – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

read_attribute(attr_name: str, forward: bool = True) list[GroupAttrReply][source]#
Just a shortcut to do:

self.read_attribute_reply(self.read_attribute_asynch(…))

read_attribute_asynch(self: tango._tango.__Group, attr_name: str, forward: bool = True) int#

Reads an attribute on each device in the group asynchronously. The method sends the request to all devices and returns immediately.

Parameters:
  • attr_name (str) – Name of the attribute to read

  • forward (bool) – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

Returns:

request id. Pass the returned request id to Group.read_attribute_reply() to obtain the results.

read_attribute_reply(self: tango._tango.__Group, req_id: SupportsInt | SupportsIndex, timeout_ms: SupportsInt | SupportsIndex = 0) tango._tango.GroupAttrReplyList#

Returns the results of an asynchronous attribute reading.

Parameters:
  • req_id (int) – Is a request identifier previously returned by one of the read_attribute_asynch methods

  • timeout_ms (int) – For each device in the hierarchy, if the command result is not yet available, command_inout_reply wait timeout_ms milliseconds before throwing an exception. This exception will be part of the global reply. If timeout_ms is set to 0, command_inout_reply waits “indefinitely”.

Return type:

list[GroupAttrReply]

read_attributes(attr_names: list[str], forward: bool = True) list[GroupAttrReply][source]#
Just a shortcut to do:

self.read_attributes_reply(self.read_attributes_asynch(…))

read_attributes_asynch(self: tango._tango.__Group, attr_names: tango._tango.StdStringVector, forward: bool = True) int#

Reads the attributes on each device in the group asynchronously. The method sends the request to all devices and returns immediately.

Parameters:
  • attr_names (list[str]) – Name of the attributes to read.

  • forward (bool) – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

Returns:

request id. Pass the returned request id to Group.read_attributes_reply() to obtain the results.

read_attributes_reply(self: tango._tango.__Group, req_id: SupportsInt | SupportsIndex, timeout_ms: SupportsInt | SupportsIndex = 0) tango._tango.GroupAttrReplyList#

read_attributes_reply (self, req_id, timeout_ms=0 ) -> sequence<GroupAttrReply>

Returns the results of an asynchronous attribute reading.

Parameters:
  • req_id (int) – Is a request identifier previously returned by one of the read_attributes_asynch methods

  • timeout_ms (int) – For each device in the hierarchy, if the command result is not yet available, command_inout_reply wait timeout_ms milliseconds before throwing an exception. This exception will be part of the global reply. If timeout_ms is set to 0, command_inout_reply waits “indefinitely”.

Return type:

list[GroupAttrReply]

remove(patterns: str | list[str], forward: bool = True) None[source]#

Removes any group or device which name matches the specified pattern.

The pattern parameter can be a group name, a device name or a device name pattern (e.g domain_*/family/member_*).

Since we can have groups with the same name in the hierarchy, a group name can be fully qualified to specify which group should be removed. Considering the following group:

-> gauges
| -> cell-01
|     |-> penning
|     |    |-> ...
|     |-> pirani
|          |-> ...
| -> cell-02
|     |-> penning
|     |    |-> ...
|     |-> pirani
|          |-> ...
| -> cell-03
|     |-> ...
|
| -> ...

A call to gauges->remove(“penning”) will remove any group named “penning” in the hierarchy while gauges->remove(“gauges.cell-02.penning”) will only remove the specified group.

Parameters:
  • patterns (str | list[str]) – A string with the pattern or a list of patterns.

  • forward (bool) –

    If fwd is set to true (the default), the remove request is also forwarded to subgroups. Otherwise, it is only applied to the local set of elements. For instance, the following code remove any stepper motor in the hierarchy:

    root_group->remove(”/stepper_motor/”)

remove_all(self: tango._tango.__Group) None#

Removes all elements in the _RealGroup. After such a call, the _RealGroup is empty.

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

Set client side timeout for all devices composing the group in milliseconds. Any method which takes longer than this time to execute will throw an exception.

Parameters:

timeout_ms (int) – timeout in milliseconds

Added in version 7.0.0.

write_attribute(attr_name: str, value: Any, forward: bool = True, multi: bool = False) list[GroupReply][source]#
Just a shortcut to do:

self.write_attribute_reply(self.write_attribute_asynch(…))

write_attribute_asynch(self: tango._tango.__Group, attr_name: object, value: object, forward: bool = True, multi: bool = False) int#

Writes an attribute on each device in the group asynchronously. The method sends the request to all devices and returns immediately.

Parameters:
  • attr_name (str | AttributeInfoEx) – Name or AttributeInfoEx of the attribute to write.

  • value (typing.Any) – Value to write. See DeviceProxy.write_attribute

  • forward (bool) – If it is set to true (the default), the request is forwarded to sub-groups. Otherwise, it is only applied to the local set of devices.

  • multi (bool) – If it is set to false (the default), the same value is applied to all devices in the group. Otherwise the value is interpreted as a sequence of values, and each value is applied to the corresponding device in the group. In this case len(value) must be equal to group.get_size()!

Returns:

request id. Pass the returned request id to Group.write_attribute_reply() to obtain the results.

Changed in version 10.1.0: attr_name parameter was renamed to attr and added support for AttributeInfoEx for attr_values parameter

write_attribute_reply(self: tango._tango.__Group, req_id: SupportsInt | SupportsIndex, timeout_ms: SupportsInt | SupportsIndex = 0) tango._tango.GroupReplyList#

write_attribute_reply (self, req_id, timeout_ms=0 ) -> sequence<GroupReply>

Returns the acknowledgements of an asynchronous attribute writing.

Parameters:
  • req_id (int) – Is a request identifier previously returned by one of the write_attribute_asynch methods

  • timeout_ms (int) – For each device in the hierarchy, if the command result is not yet available, command_inout_reply wait timeout_ms milliseconds before throwing an exception. This exception will be part of the global reply. If timeout_ms is set to 0, command_inout_reply waits “indefinitely”.

Return type:

list[GroupReply]

GroupReply classes#

Group member functions do not return the same as their DeviceProxy counterparts, but objects that contain them. This is:

  • write attribute family returns tango.GroupReplyList

  • read attribute family returns tango.GroupAttrReplyList

  • command inout family returns tango.GroupCmdReplyList

The Group*ReplyList objects are just list-like objects containing GroupReply, GroupAttrReply and GroupCmdReply elements that will be described now.

Note also that GroupReply is the base of GroupCmdReply and GroupAttrReply.

class tango.GroupReply#

This is the base class for the result of an operation on a PyTangoGroup, being it a write attribute, read attribute, or command inout operation.

It has some trivial common operations:

  • has_failed(self) -> bool

  • group_element_enabled(self) ->bool

  • dev_name(self) -> str

  • obj_name(self) -> str

  • get_err_stack(self) -> DevErrorList

dev_name(self: tango._tango.GroupReply) str#

Returns the device name for the group element

get_err_stack(self: tango._tango.GroupReply) list[DevError]#

Get error stack

group_element_enabled(self: tango._tango.GroupReply) bool#

Check if the group element corresponding to this reply is enabled.

has_failed(self: tango._tango.GroupReply) bool#
obj_name(self: tango._tango.GroupReply) str#

The object name

class tango.GroupAttrReply#

Bases: GroupReply

get_data(self: tango._tango.GroupAttrReply, extract_as: tango._tango.ExtractAs = ExtractAs.Numpy) object#

Get the DeviceAttribute.

Parameters:

extract_as

Type:

ExtractAs

Returns:

Whatever is stored there, or None.

Return type:

DeviceAttribute | None

class tango.GroupCmdReply#

Bases: GroupReply

get_data() Any#

Get the actual value stored in the GroupCmdRply, the command output value. It’s the same as self.get_data_raw().extract()

get_data_raw(self: tango._tango.GroupCmdReply) tango._tango.DeviceData#

Get the DeviceData containing the output parameter of the command.

Returns:

Whatever is stored there, or None.

Return type:

DeviceData | None