pub struct Attr<M: Model> { /* private fields */ }Expand description
An attribute of a single device, together with the last value written to it, which
Tango keeps aside from the model, and its configuration on that device. Its definition
is shared the way that of a Command is.
Implementations§
Source§impl<M: Model> Attr<M>
impl<M: Model> Attr<M>
Sourcepub fn config(&self) -> AttrConfig
pub fn config(&self) -> AttrConfig
The configuration of that attribute on its device.
Sourcepub fn is_memorized(&self) -> bool
pub fn is_memorized(&self) -> bool
Whether that attribute is memorized, see AttrMemorized.
Sourcepub fn info(&self) -> Result<AttrInfo>
pub fn info(&self) -> Result<AttrInfo>
What a client is told of that attribute: what it may read and change of its configuration, and what its definition advertises of its data.
A definition advertising neither a kind nor a format, which only one built out of a raw handler and given neither can be, has nothing to tell a client of its data and is answered with an error rather than with a guess.
An attribute whose configuration could not be applied is described all the same, with what could be, so that a client can still see what it is configured with.
TODO: AttrMode::ReadWithWrite cannot be derived from the handlers, the write
attribute it is paired with having to be named; it needs its own definition.
Sourcepub fn push_history(
&self,
read: Result<AttrRead<Value>>,
valid_for: Option<Duration>,
) -> Result<()>
pub fn push_history( &self, read: Result<AttrRead<Value>>, valid_for: Option<Duration>, ) -> Result<()>
Record that reading in the history of that attribute, the oldest one being dropped
when the history is full, see Self::set_history_depth. A reading that failed
is recorded as well, as the error it failed with.
The latest reading is what a read from the cache is answered with, for that long when given a validity, after which the device is read again, or a read from the cache alone fails as outdated; without one, it answers until the next is recorded.
The reading must have a read value, so an attribute that cannot be read records none,
and be of a valid quality for the State and the Status, their commands answering
with the value alone. The write value is merged into it as for an event, see
Dev::push_attr_event.
Sourcepub fn history(&self, max: usize) -> Vec<RecordedResult<AttrRead<Value>>> ⓘ
pub fn history(&self, max: usize) -> Vec<RecordedResult<AttrRead<Value>>> ⓘ
The latest readings recorded in the history of that attribute, oldest first and at
most max of them, see Self::push_history.
Sourcepub fn clear_history(&self)
pub fn clear_history(&self)
Forget every reading recorded in the history of that attribute, so that a read from the cache finds none.
Sourcepub fn history_depth(&self) -> usize
pub fn history_depth(&self) -> usize
How many readings the history of that attribute keeps at most.
Sourcepub fn set_history_depth(&self, depth: usize)
pub fn set_history_depth(&self, depth: usize)
Set how many readings the history of that attribute keeps at most, the oldest ones beyond that being dropped now. A depth of zero records nothing.