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.

Return type:

bool

Returns:

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

has_write_value()[source]

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

Return type:

bool

Returns:

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

get_obj()[source]

Returns the object which owns this attribute

Return type:

Any

Returns:

the object which owns this attribute

in_error()[source]

Determines if this attribute is in error state.

Return type:

bool

Returns:

True if the attribute is in error state or False otherwise

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 (Union[Any, SardanaValue]) – the new read value for this attribute. If a SardanaValue is given, exc_info and timestamp are ignored (if given)

  • exc_info (Optional[Tuple]) – exception information as returned by sys.exc_info() [default: None, meaning no exception]

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

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

Return type:

None

get_value()[source]

Returns the last read value for this attribute.

Return type:

Any

Returns:

the last read value for this attribute

Raises:

Exception if no read value has been set yet

get_value_obj()[source]

Returns the last read value for this attribute.

Return type:

SardanaValue

Returns:

the last read value for this attribute

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 – the new write value for this attribute. If a SardanaValue is given, timestamp is ignored (if given)

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

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

Return type:

None

get_write_value()[source]

Returns the last write value for this attribute.

Return type:

object

Returns:

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

get_write_value_obj()[source]

Returns the last write value object for this attribute.

Return type:

SardanaValue

Returns:

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

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.

Return type:

Optional[Tuple]

Returns:

exception information 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

Return type:

Optional[float]

Returns:

timestamp of the last readout or None

get_write_timestamp()[source]

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

Return type:

Optional[float]

Returns:

timestamp of the last write 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

Return type:

None

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

Return type:

None

property obj: Any

Returns the object which owns this attribute

Returns:

the object which owns this attribute

property value_obj: SardanaValue

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Raises:

Exception if no read value has been set yet

property write_value_obj: SardanaValue

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

property value: Any

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Raises:

Exception if no read value has been set yet

property w_value: object

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

property quality
property timestamp: float | None

the read timestamp

property w_timestamp: float | None

the write timestamp

property error: bool

Determines if this attribute is in error state.

Returns:

True if the attribute is in error state or False otherwise

property exc_info: Tuple | None

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

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.

Return type:

Any

Returns:

the last read value for this attribute

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 (Any) – the new read value for this attribute

  • exc_info (Optional[Tuple]) – exception information as returned by sys.exc_info() [default: None, meaning no exception]

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

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

Return type:

None

property value: Any

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

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

Determines if this attribute is in error state.

Returns:

True if the attribute is in error state or False otherwise

property exc_info: Tuple | None

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

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

Return type:

None

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

Return type:

None

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.

Return type:

Optional[Tuple]

Returns:

exception information or None

get_listeners()
get_obj()

Returns the object which owns this attribute

Return type:

Any

Returns:

the object which owns this attribute

get_quality()
get_timestamp()

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

Return type:

Optional[float]

Returns:

timestamp of the last readout or None

get_value_obj()

Returns the last read value for this attribute.

Return type:

SardanaValue

Returns:

the last read value for this attribute

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

Return type:

Optional[float]

Returns:

timestamp of the last write or None

get_write_value()

Returns the last write value for this attribute.

Return type:

object

Returns:

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

get_write_value_obj()

Returns the last write value object for this attribute.

Return type:

SardanaValue

Returns:

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

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.

Return type:

bool

Returns:

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

has_write_value()

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

Return type:

bool

Returns:

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

in_error()

Determines if this attribute is in error state.

Return type:

bool

Returns:

True if the attribute is in error state or False otherwise

property obj: Any

Returns the object which owns this attribute

Returns:

the object which owns this attribute

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 – the new write value for this attribute. If a SardanaValue is given, timestamp is ignored (if given)

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

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

Return type:

None

property timestamp: float | None

the read timestamp

property value_obj: SardanaValue

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Raises:

Exception if no read value has been set yet

property w_timestamp: float | None

the write timestamp

property w_value: object

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

property write_value_obj: SardanaValue

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

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

Determines if this attribute is in error state.

Returns:

True if the attribute is in error state or False otherwise

property exc_info: Tuple | None

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

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

Return type:

None

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

Return type:

None

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.

Return type:

Optional[Tuple]

Returns:

exception information or None

get_listeners()
get_obj()

Returns the object which owns this attribute

Return type:

Any

Returns:

the object which owns this attribute

get_quality()
get_timestamp()

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

Return type:

Optional[float]

Returns:

timestamp of the last readout or None

get_value()

Returns the last read value for this attribute.

Return type:

Any

Returns:

the last read value for this attribute

Raises:

Exception if no read value has been set yet

get_value_obj()

Returns the last read value for this attribute.

Return type:

SardanaValue

Returns:

the last read value for this attribute

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

Return type:

Optional[float]

Returns:

timestamp of the last write or None

get_write_value()

Returns the last write value for this attribute.

Return type:

object

Returns:

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

get_write_value_obj()

Returns the last write value object for this attribute.

Return type:

SardanaValue

Returns:

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

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.

Return type:

bool

Returns:

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

has_write_value()

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

Return type:

bool

Returns:

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

in_error()

Determines if this attribute is in error state.

Return type:

bool

Returns:

True if the attribute is in error state or False otherwise

property obj: Any

Returns the object which owns this attribute

Returns:

the object which owns this attribute

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 (Union[Any, SardanaValue]) – the new read value for this attribute. If a SardanaValue is given, exc_info and timestamp are ignored (if given)

  • exc_info (Optional[Tuple]) – exception information as returned by sys.exc_info() [default: None, meaning no exception]

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

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

Return type:

None

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

Sets the current write value.

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

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

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

Return type:

None

property timestamp: float | None

the read timestamp

property value: Any

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Raises:

Exception if no read value has been set yet

property value_obj: SardanaValue

Returns the last read value for this attribute.

Returns:

the last read value for this attribute

Raises:

Exception if no read value has been set yet

property w_timestamp: float | None

the write timestamp

property w_value: object

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

property write_value_obj: SardanaValue

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

SardanaAttributeConfiguration

Inheritance diagram of SardanaAttributeConfiguration
class SardanaAttributeConfiguration[source]

Storage class for SardanaAttribute information (like ranges)

NoRange = (-inf, inf)