sardanaattribute
¶
This module is part of the Python Sardana libray. It defines the base classes for Sardana attributes
Classes
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: obj
-
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 (obj 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: obj 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: obj
-
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_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
-
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
-
obj
¶ Returns the object which owns this attribute
Returns: the object which owns this attribute Return type: obj
-
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
-
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
-
value
¶ Returns the last read value for this attribute.
Returns: the last read value for this attribute Return type: obj Raises: Exception
if no read value has been set yet
-
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: obj
-
timestamp
¶ the read timestamp
-
w_timestamp
¶ the write timestamp
-
error
¶ Determines if this attribute is in error state.
Returns: True if the attribute is in error state or False otherwise Return type: bool
-
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
()¶
-
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¶
-
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: obj 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 (obj) – 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
-
value
¶ Returns the last read value for this attribute.
Returns: the last read value for this attribute Return type: obj 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
-
error
¶ Determines if this attribute is in error state.
Returns: True if the attribute is in error state or False otherwise Return type: bool
-
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_obj
()¶ Returns the object which owns this attribute
Returns: the object which owns this attribute Return type: obj
-
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: obj
-
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
-
obj
¶ Returns the object which owns this attribute
Returns: the object which owns this attribute Return type: obj
-
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_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
-
timestamp
¶ the read timestamp
-
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
-
w_timestamp
¶ the write timestamp
-
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: obj
-
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¶
-
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
-
error
¶ Determines if this attribute is in error state.
Returns: True if the attribute is in error state or False otherwise Return type: bool
-
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_obj
()¶ Returns the object which owns this attribute
Returns: the object which owns this attribute Return type: obj
-
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: obj 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: obj
-
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
-
obj
¶ Returns the object which owns this attribute
Returns: the object which owns this attribute Return type: obj
-
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_value
(value, exc_info=None, timestamp=None, propagate=1)¶ Sets the current read value and propagates the event (if propagate > 0).
Parameters: - value (obj 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
-
timestamp
¶ the read timestamp
-
value
¶ Returns the last read value for this attribute.
Returns: the last read value for this attribute Return type: obj Raises: Exception
if no read value has been set yet
-
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
-
w_timestamp
¶ the write timestamp
-
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: obj
-
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¶
-
class
SardanaAttributeConfiguration
[source]¶ Storage class for
SardanaAttribute
information (like ranges)-
NoRange
= (-inf, inf)¶
-