sardanaattribute

This module is part of the Python Sardana libray. It defines the base classes for Sardana attributes

Classes

SardanaAttribute

Inheritance diagram of SardanaAttribute
class SardanaAttribute(obj, name=None, initial_value=None, **kwargs)[source]

Class representing an atomic attribute like position of a motor or a counter value

has_value()[source]

Determines if the attribute’s read value has been read at least once in the lifetime of the attribute.

Returns:

True if the attribute has a read value stored or False otherwise

Return type:

bool

has_write_value()[source]

Determines if the attribute’s write value has been read at least once in the lifetime of the attribute.

Returns:

True if the attribute has a write value stored or False otherwise

Return type:

bool

get_obj()[source]

Returns the object which owns this attribute

Returns:

the object which owns this attribute

Return type:

object

in_error()[source]

Determines if this attribute is in error state.

Returns:

True if the attribute is in error state or False otherwise

Return type:

bool

set_value(value, exc_info=None, timestamp=None, propagate=1)[source]

Sets the current read value and propagates the event (if propagate > 0).

Parameters:
  • value (object or SardanaValue) – the new read value for this attribute. If a SardanaValue is given, exc_info and timestamp are ignored (if given)

  • exc_info (tuple<3> or None) – exception information as returned by sys.exc_info() [default: None, meaning no exception]

  • timestamp (float or None) – timestamp of attribute readout [default: None, meaning create a ‘now’ timestamp]

  • propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

get_value()[source]

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

object

Raises:

Exception if no read value has been set yet

get_value_obj()[source]

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

SardanaValue

Raises:

Exception if no read value has been set yet

set_write_value(w_value, timestamp=None, propagate=1)[source]

Sets the current write value.

Parameters:
  • value (obj or SardanaValue) – the new write value for this attribute. If a SardanaValue is given, timestamp is ignored (if given)

  • timestamp (float or None) – timestamp of attribute write [default: None, meaning create a ‘now’ timestamp]

  • propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

get_write_value()[source]

Returns the last write value for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

object

get_write_value_obj()[source]

Returns the last write value object for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

SardanaValue

get_quality()[source]
set_quality(quality)[source]
get_exc_info()[source]

Returns the exception information (like sys.exc_info()) about last attribute readout or None if last read did not generate an exception.

Returns:

exception information or None

Return type:

tuple<3> or None

accepts(propagate)[source]
get_timestamp()[source]

Returns the timestamp of the last readout or None if the attribute has never been read before

Returns:

timestamp of the last readout or None

Return type:

float or None

get_write_timestamp()[source]

Returns the timestamp of the last write or None if the attribute has never been written before

Returns:

timestamp of the last write or None

Return type:

float or None

fire_write_event(propagate=1)[source]

Fires an event to the listeners of the object which owns this attribute.

Parameters:

propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

fire_read_event(propagate=1)[source]

Fires an event to the listeners of the object which owns this attribute.

Parameters:

propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

property obj

Returns the object which owns this attribute

Returns:

the object which owns this attribute

Return type:

object

property value_obj

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

SardanaValue

Raises:

Exception if no read value has been set yet

property write_value_obj

Returns the last write value object for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

SardanaValue

property value

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

object

Raises:

Exception if no read value has been set yet

property w_value

Returns the last write value for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

object

property quality
property timestamp

the read timestamp

property w_timestamp

the write timestamp

property error

Determines if this attribute is in error state.

Returns:

True if the attribute is in error state or False otherwise

Return type:

bool

property exc_info

Returns the exception information (like sys.exc_info()) about last attribute readout or None if last read did not generate an exception.

Returns:

exception information or None

Return type:

tuple<3> or None

add_listener(listener)

Adds a new listener for this object.

Parameters:

listener – a listener

fire_event(event_type, event_value, listeners=None)
flush_queue()
get_listeners()
has_listeners()

Returns True if anybody is listening to events from this object

Returns:

True is at least one listener is listening or False otherwise

queue_event(event_type, event_value, listeners=None)
remove_listener(listener)

Removes an existing listener for this object.

Parameters:

listener – the listener to be removed

Returns:

True is succeeded or False otherwise

SardanaSoftwareAttribute

Inheritance diagram of SardanaSoftwareAttribute
class SardanaSoftwareAttribute(obj, name=None, initial_value=None, **kwargs)[source]

Class representing a software attribute. The difference between this and SardanaAttribute is that, because it is a pure software attribute, there is no difference ever between the read and write values.

get_value()

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

object

Raises:

Exception if no read value has been set yet

set_value(value, exc_info=None, timestamp=None, propagate=1)[source]

Sets the current read value and propagates the event (if propagate > 0).

Parameters:
  • value (object) – the new read value for this attribute

  • exc_info (tuple<3> or None) – exception information as returned by sys.exc_info() [default: None, meaning no exception]

  • timestamp (float or None) – timestamp of attribute readout [default: None, meaning create a ‘now’ timestamp]

  • propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

property value

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

object

Raises:

Exception if no read value has been set yet

accepts(propagate)
add_listener(listener)

Adds a new listener for this object.

Parameters:

listener – a listener

property error

Determines if this attribute is in error state.

Returns:

True if the attribute is in error state or False otherwise

Return type:

bool

property exc_info

Returns the exception information (like sys.exc_info()) about last attribute readout or None if last read did not generate an exception.

Returns:

exception information or None

Return type:

tuple<3> or None

fire_event(event_type, event_value, listeners=None)
fire_read_event(propagate=1)

Fires an event to the listeners of the object which owns this attribute.

Parameters:

propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

fire_write_event(propagate=1)

Fires an event to the listeners of the object which owns this attribute.

Parameters:

propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

flush_queue()
get_exc_info()

Returns the exception information (like sys.exc_info()) about last attribute readout or None if last read did not generate an exception.

Returns:

exception information or None

Return type:

tuple<3> or None

get_listeners()
get_obj()

Returns the object which owns this attribute

Returns:

the object which owns this attribute

Return type:

object

get_quality()
get_timestamp()

Returns the timestamp of the last readout or None if the attribute has never been read before

Returns:

timestamp of the last readout or None

Return type:

float or None

get_value_obj()

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

SardanaValue

Raises:

Exception if no read value has been set yet

get_write_timestamp()

Returns the timestamp of the last write or None if the attribute has never been written before

Returns:

timestamp of the last write or None

Return type:

float or None

get_write_value()

Returns the last write value for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

object

get_write_value_obj()

Returns the last write value object for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

SardanaValue

has_listeners()

Returns True if anybody is listening to events from this object

Returns:

True is at least one listener is listening or False otherwise

has_value()

Determines if the attribute’s read value has been read at least once in the lifetime of the attribute.

Returns:

True if the attribute has a read value stored or False otherwise

Return type:

bool

has_write_value()

Determines if the attribute’s write value has been read at least once in the lifetime of the attribute.

Returns:

True if the attribute has a write value stored or False otherwise

Return type:

bool

in_error()

Determines if this attribute is in error state.

Returns:

True if the attribute is in error state or False otherwise

Return type:

bool

property obj

Returns the object which owns this attribute

Returns:

the object which owns this attribute

Return type:

object

property quality
queue_event(event_type, event_value, listeners=None)
remove_listener(listener)

Removes an existing listener for this object.

Parameters:

listener – the listener to be removed

Returns:

True is succeeded or False otherwise

set_quality(quality)
set_write_value(w_value, timestamp=None, propagate=1)

Sets the current write value.

Parameters:
  • value (obj or SardanaValue) – the new write value for this attribute. If a SardanaValue is given, timestamp is ignored (if given)

  • timestamp (float or None) – timestamp of attribute write [default: None, meaning create a ‘now’ timestamp]

  • propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

property timestamp

the read timestamp

property value_obj

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

SardanaValue

Raises:

Exception if no read value has been set yet

property w_timestamp

the write timestamp

property w_value

Returns the last write value for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

object

property write_value_obj

Returns the last write value object for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

SardanaValue

ScalarNumberAttribute

Inheritance diagram of ScalarNumberAttribute
class ScalarNumberAttribute(*args, **kwargs)[source]

A SardanaAttribute specialized for numbers

accepts(propagate)
add_listener(listener)

Adds a new listener for this object.

Parameters:

listener – a listener

property error

Determines if this attribute is in error state.

Returns:

True if the attribute is in error state or False otherwise

Return type:

bool

property exc_info

Returns the exception information (like sys.exc_info()) about last attribute readout or None if last read did not generate an exception.

Returns:

exception information or None

Return type:

tuple<3> or None

fire_event(event_type, event_value, listeners=None)
fire_read_event(propagate=1)

Fires an event to the listeners of the object which owns this attribute.

Parameters:

propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

fire_write_event(propagate=1)

Fires an event to the listeners of the object which owns this attribute.

Parameters:

propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

flush_queue()
get_exc_info()

Returns the exception information (like sys.exc_info()) about last attribute readout or None if last read did not generate an exception.

Returns:

exception information or None

Return type:

tuple<3> or None

get_listeners()
get_obj()

Returns the object which owns this attribute

Returns:

the object which owns this attribute

Return type:

object

get_quality()
get_timestamp()

Returns the timestamp of the last readout or None if the attribute has never been read before

Returns:

timestamp of the last readout or None

Return type:

float or None

get_value()

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

object

Raises:

Exception if no read value has been set yet

get_value_obj()

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

SardanaValue

Raises:

Exception if no read value has been set yet

get_write_timestamp()

Returns the timestamp of the last write or None if the attribute has never been written before

Returns:

timestamp of the last write or None

Return type:

float or None

get_write_value()

Returns the last write value for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

object

get_write_value_obj()

Returns the last write value object for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

SardanaValue

has_listeners()

Returns True if anybody is listening to events from this object

Returns:

True is at least one listener is listening or False otherwise

has_value()

Determines if the attribute’s read value has been read at least once in the lifetime of the attribute.

Returns:

True if the attribute has a read value stored or False otherwise

Return type:

bool

has_write_value()

Determines if the attribute’s write value has been read at least once in the lifetime of the attribute.

Returns:

True if the attribute has a write value stored or False otherwise

Return type:

bool

in_error()

Determines if this attribute is in error state.

Returns:

True if the attribute is in error state or False otherwise

Return type:

bool

property obj

Returns the object which owns this attribute

Returns:

the object which owns this attribute

Return type:

object

property quality
queue_event(event_type, event_value, listeners=None)
remove_listener(listener)

Removes an existing listener for this object.

Parameters:

listener – the listener to be removed

Returns:

True is succeeded or False otherwise

set_quality(quality)
set_value(value, exc_info=None, timestamp=None, propagate=1)

Sets the current read value and propagates the event (if propagate > 0).

Parameters:
  • value (object or SardanaValue) – the new read value for this attribute. If a SardanaValue is given, exc_info and timestamp are ignored (if given)

  • exc_info (tuple<3> or None) – exception information as returned by sys.exc_info() [default: None, meaning no exception]

  • timestamp (float or None) – timestamp of attribute readout [default: None, meaning create a ‘now’ timestamp]

  • propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

set_write_value(w_value, timestamp=None, propagate=1)

Sets the current write value.

Parameters:
  • value (obj or SardanaValue) – the new write value for this attribute. If a SardanaValue is given, timestamp is ignored (if given)

  • timestamp (float or None) – timestamp of attribute write [default: None, meaning create a ‘now’ timestamp]

  • propagate (int) – 0 for not propagating, 1 to propagate, 2 propagate with priority

property timestamp

the read timestamp

property value

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

object

Raises:

Exception if no read value has been set yet

property value_obj

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Return type:

SardanaValue

Raises:

Exception if no read value has been set yet

property w_timestamp

the write timestamp

property w_value

Returns the last write value for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

object

property write_value_obj

Returns the last write value object for this attribute.

Returns:

the last write value for this attribute or None if value has not been written yet

Return type:

SardanaValue

SardanaAttributeConfiguration

Inheritance diagram of SardanaAttributeConfiguration
class SardanaAttributeConfiguration[source]

Storage class for SardanaAttribute information (like ranges)

NoRange = (-inf, inf)