SardanaDevice

Generic Sardana Tango device module

Classes

SardanaDevice

Inheritance diagram of SardanaDevice
class SardanaDevice(dclass, name)[source]

Bases: LatestDeviceImpl, Logger

SardanaDevice represents the base class for all Sardana PyTango.DeviceImpl classes

init(name)[source]

initialize the device once in the object lifetime. Override when necessary but always call the method from your super class

:param str name: device name

get_alias()[source]

Returns this device alias name

Returns:

this device alias

Return type:

str

property alias

the device alias name

get_full_name()[source]

Compose full name from the TANGO_HOST information and device name.

Full name is of format “tango://dbhost:dbport/<domain>/<family>/<member>” where dbhost is always FQDN.

Returns:

this device full name

Return type:

str

init_device()[source]

Initialize the device. Called during startup after init() and every time the tango Init command is executed. Override when necessary but always call the method from your super class

sardana_init_hook()[source]

Hook that is called before the server event loop.

The idea behind this hook is to be equivalent to server_init_hook from Tango. Similar behaviour can be archived using post_init_callback.

init_device_nodb()[source]

Internal method. Initialize the device when tango database is not being used (example: in demos)

delete_device()[source]

Clean the device. Called during shutdown and every time the tango Init command is executed. Override when necessary but always call the method from your super class

set_change_events(evts_checked, evts_not_checked)[source]

Helper method to set change events on attributes

Parameters:
  • evts_checked (seq<str>) – list of attribute names to activate change events programatically with tango filter active

  • evts_not_checked (seq<str>) – list of attribute names to activate change events programatically with tango filter inactive. Use this with care! Attributes configured with no change event filter may potentially generated a lot of events!

initialize_dynamic_attributes()[source]

Initialize dynamic attributes. Default implementation does nothing. Override when necessary.

initialize_attribute_values()[source]

Initialize attributes values. Default implementation does nothing. Override when necessary.

get_memorized_values()[source]

Get memorized values from database

Returns:

map with attribute names and memorized values

Return type:

dict {str: obj}

get_event_thread_pool()[source]

Return the ThreadPool used by sardana to send tango events.

Returns:

the sardana ThreadPool

Return type:

ThreadPool

get_attribute_by_name(attr_name)[source]

Gets the attribute for the given name.

Parameters:

attr_name (str) – attribute name

Returns:

the attribute object

Return type:

Attribute

get_wattribute_by_name(attr_name)[source]

Gets the writable attribute for the given name.

Parameters:

attr_name (str) – attribute name

Returns:

the attribute object

Return type:

WAttribute

get_database()[source]

Helper method to return a reference to the current tango database

Returns:

the Tango database

Return type:

Database

set_write_attribute(attr, w_value)[source]
set_attribute(attr, value=None, w_value=None, timestamp=None, quality=None, error=None, priority=1, synch=True)[source]

Sets the given attribute value. If timestamp is not given, now is used as timestamp. If quality is not given VALID is assigned. If error is given an error event is sent (with no value and quality INVALID). If priority is > 1, the event filter is temporarily disabled so the event is sent for sure. If synch is set to True, wait for fire event to finish

Parameters:
  • attr (PyTango.Attribute) – the tango attribute

  • value (object) – the value to be set (not mandatory if setting an error) [default: None]

  • w_value – the write value to be set (not mandatory) [default: None, meaning maintain current write value]

  • timestamp (float or PyTango.TimeVal) – the timestamp associated with the operation [default: None, meaning use now as timestamp]

  • quality (PyTango.AttrQuality) – attribute quality [default: None, meaning VALID]

  • error (PyTango.DevFailed) – a tango DevFailed error or None if not an error [default: None]

  • priority (int) – event priority [default: 1, meaning normal priority]. If priority is > 1, the event filter is temporarily disabled so the event is sent for sure. The event filter is restored to the previous value

  • synch – If synch is set to True, wait for fire event to finish. If False, a job is sent to the sardana thread pool and the method returns immediately [default: True]

set_attribute_push(attr, value=None, w_value=None, timestamp=None, quality=None, error=None, priority=1, synch=True)[source]

Synchronous internal implementation of set_attribute() (synch is passed to this method because it might need to know if it is being executed in a synchronous or asynchronous context).

calculate_tango_state(ctrl_state, update=False)[source]

Calculate tango state based on the controller state.

Parameters:
  • ctrl_state (State) – the state returned by the controller

  • update (bool) – if True, set the state of this device with the calculated tango state [default: False:

Returns:

the corresponding tango state

Return type:

PyTango.DevState

calculate_tango_status(ctrl_status, update=False)[source]

Calculate tango status based on the controller status.

Parameters:
  • ctrl_status (str) – the status returned by the controller

  • update (bool) – if True, set the state of this device with the calculated tango state (by default is False)

Returns:

the corresponding tango state

Return type:

str

SardanaDeviceClass

Inheritance diagram of SardanaDeviceClass
class SardanaDeviceClass(name)[source]

Bases: DeviceClass

SardanaDeviceClass represents the base class for all Sardana PyTango.DeviceClass classes

class_property_list = {}

Sardana device class properties definition

device_property_list = {}

Sardana device properties definition

cmd_list = {}

Sardana device command definition

attr_list = {}

Sardana device attribute definition

write_class_property()[source]

Write class properties ProjectTitle, Description, doc_url, InheritedFrom and __icon

dyn_attr(dev_list)[source]

Invoked to create dynamic attributes for the given devices. Default implementation calls SardanaDevice.initialize_dynamic_attributes() for each device

Parameters:

dev_list (PyTango.DeviceImpl) – list of devices

device_name_factory(dev_name_list)[source]

Builds list of device names to use when no Database is being used

Parameters:

dev_name_list (seq<obj:list>) – list to be filled with device names