Skip to main content

AveragingObject

Struct AveragingObject 

Source
pub struct AveragingObject { /* private fields */ }
Expand description

BACnet Averaging object (type 18).

Keeps the most recent Window_Samples sample attempts and serves the minimum, maximum and average of the valid ones. Table 12-5 has no Present_Value, Status_Flags, Event_State, Reliability or Out_Of_Service, so the object serves none of them (#1064).

Once the object is in a running server and holds an Object_Property_Reference, the server samples that property every Window_Interval / Window_Samples seconds (Clauses 12.5.14 and 12.5.15), at most every MIN_SAMPLE_PERIOD. A failed read, or a value the object can’t average, is recorded as a missed attempt. Without a reference the application feeds the samples (see add_sample and BACnetServer::add_averaging_sample_local); with one, an application sample is one more attempt in the window and doesn’t move the schedule.

Changing Window_Interval, Window_Samples or Object_Property_Reference, or writing zero to Attempted_Samples, discards the samples: both counts read zero and the statistics read positive infinity, NaN and negative infinity until the next valid sample. The schedule starts over at the same moment, so the next server sample is one spacing later.

Implementations§

Source§

impl AveragingObject

Source

pub fn new(instance: u32, name: impl Into<String>) -> Result<Self, Error>

Create a new Averaging object; fails if instance exceeds the object-identifier range.

The window starts at DEFAULT_WINDOW_SAMPLES samples over DEFAULT_WINDOW_INTERVAL seconds, with no samples taken.

Source

pub fn add_sample(&mut self, value: f32) -> Result<(), Error>

Add a sample value as the newest slot of the window, dropping the oldest once the window is full, and recompute the statistics.

NaN or an infinity fails with PROPERTY / VALUE_OUT_OF_RANGE and leaves the window unchanged. Like other direct setters this bypasses the server’s COV fanout; once the object is in a running server, its application calls BACnetServer::add_averaging_sample_local instead.

Source

pub fn add_missed_sample(&mut self)

Record a sample attempt that produced no value, such as a failed read of the referenced property.

The attempt takes a slot in the window, so it counts toward Attempted_Samples but not Valid_Samples, and the statistics cover the valid slots left.

Source

pub fn window_interval(&self) -> u32

Window_Interval: the period, in seconds, the window is expected to span.

Source

pub fn window_samples(&self) -> u32

Window_Samples: how many sample attempts the window holds.

Source

pub fn set_window_interval(&mut self, seconds: u32) -> Result<(), Error>

Set Window_Interval and discard the samples, as a network write does.

Zero fails with PROPERTY / VALUE_OUT_OF_RANGE and changes nothing.

Source

pub fn set_window_samples(&mut self, samples: u32) -> Result<(), Error>

Set Window_Samples and discard the samples, as a network write does.

Zero, or more than MAX_WINDOW_SAMPLES, fails with PROPERTY / VALUE_OUT_OF_RANGE and changes nothing.

Source

pub fn set_object_property_reference( &mut self, reference: Option<BACnetObjectPropertyReference>, )

Set the object property reference (the property being averaged) and discard the samples taken from the previous one. None, or a reference to the reserved instance 4194303, leaves the object without one (#1417).

Source

pub fn set_description(&mut self, desc: impl Into<String>)

Set the description string.

Trait Implementations§

Source§

impl BACnetObject for AveragingObject

Source§

fn object_identifier(&self) -> ObjectIdentifier

The object’s identifier (type + instance).
Source§

fn object_name(&self) -> &str

The object’s name.
Source§

fn read_property( &self, property: PropertyIdentifier, array_index: Option<u32>, ) -> Result<PropertyValue, Error>

Read a property value.
Source§

fn write_property( &mut self, property: PropertyIdentifier, _array_index: Option<u32>, value: PropertyValue, _priority: Option<u8>, ) -> Result<(), Error>

Write a property value. Read more
Source§

fn property_metadata(&self) -> Cow<'_, [PropertyMetadata]>

Return canonical metadata for this object’s effective property rows. Read more
Source§

fn property_list(&self) -> Cow<'static, [PropertyIdentifier]>

List all properties this object supports in the legacy projection. Read more
Source§

fn supports_subscribe_cov_property(&self) -> bool

Whether SubscribeCOVProperty and SubscribeCOVPropertyMultiple may monitor this object’s properties. Read more
Source§

fn add_averaging_sample_internal( &mut self, sample: Option<PropertyValue>, ) -> Result<(), Error>

Record one sample for an Averaging object. Read more
Source§

fn write_property_from( &mut self, property: PropertyIdentifier, array_index: Option<u32>, value: PropertyValue, priority: Option<u8>, _origin: &CommandOrigin, ) -> Result<(), Error>

Write with explicit actual command provenance. Standalone callers assert the origin; server boundaries additionally validate ingress or membership. Decorators must forward this hook without discarding the origin. The default preserves custom/unaffected object behavior. First-party source-tracked commands require this hook and deny context-free writing.
Source§

fn is_writable_property(&self, property: PropertyIdentifier) -> bool

Whether a property write route can accept property for this object. Read more
Source§

fn is_array_property(&self, property: PropertyIdentifier) -> bool

Whether property accepts an array index on this object. Read more
Source§

fn is_list_property(&self, property: PropertyIdentifier) -> bool

Whether property is a BACnetLIST on this object. Read more
Source§

fn is_createable(&self) -> bool

Whether this object type can be created at runtime via CreateObject. Read more
Source§

fn creation_only_properties(&self) -> &'static [PropertyIdentifier]

The properties whose whole value a CreateObject initial value may set on this object although WriteProperty can’t change it afterwards. Read more
Source§

fn initialize_property( &mut self, _property: PropertyIdentifier, _value: PropertyValue, ) -> Result<(), Error>

Apply a CreateObject initial value to one of Self::creation_only_properties, written whole. Read more
Source§

fn is_deleteable(&self) -> bool

Whether this object type can be deleted at runtime via DeleteObject. Read more
Source§

fn required_properties(&self) -> Cow<'static, [PropertyIdentifier]>

List the REQUIRED properties for this object type. Read more
Source§

fn supports_cov(&self) -> bool

Whether this object type supports COV notifications. Read more
Source§

fn supports_cov_property(&self, property: PropertyIdentifier) -> bool

Whether a readable property supports property-specific COV. Read more
Source§

fn cov_increment(&self) -> Option<f64>

COV increment for this object (objects with a COV_Increment property). Read more
Source§

fn cov_reported_properties(&self) -> &'static [CovReportedProperty]

Properties a whole-object (SubscribeCOV) notification reports after its leading value and Status_Flags, in report order. Read more
Source§

fn set_overridden(&mut self, _overridden: bool)

Set the OVERRIDDEN bit in StatusFlags. Read more
Source§

fn evaluate_intrinsic_reporting(&mut self) -> Option<TransitionOutcome>

Evaluate intrinsic reporting after a present_value change. Read more
Source§

fn tick_intrinsic_reporting(&mut self) -> Option<TransitionOutcome>

Advance the Time_Delay countdown for a pending transition. Read more
Source§

fn tick_schedule( &mut self, _today: SpecificDate, _time: Time, _calendar_active: &dyn Fn(ObjectIdentifier) -> bool, ) -> Option<ScheduleWrite>

Evaluate this object’s schedule at time on today (Clause 12.24.4). Read more
Source§

fn take_owed_schedule_writes(&mut self) -> Vec<ScheduleWrite>

Take the writes this schedule owes its targets apart from its calculation, each once, in order: a NULL to every priority slot a change of List_Of_Object_Property_References or Priority_For_Writing left behind (#1088), then the Present_Value owed out of service, for a client’s write (Clause 12.24.14) or a change of those two properties. Read more
Source§

fn complete_schedule_write( &mut self, _write: &ScheduleWrite, _outcomes: &[ScheduleTargetOutcome], ) -> bool

Report how each target took write, one of this schedule’s writes: outcomes holds one entry per member of write.references, in order. Read more
Source§

fn retry_refusals_naming( &self, _target: ObjectIdentifier, ) -> Option<ScheduleWrite>

The retry of the current value to the references whose last write was refused and that name target, an object just added to the database (#1440), so the refusal can clear without waiting for the next pass. None when no such refusal stands, or when the pass itself would retry nothing: out of service, outside Effective_Period, or with a NULL Present_Value. Only meaningful for Schedule objects; default returns None.
Source§

fn acknowledge_alarm( &mut self, _transition_bit: EventTransitionBits, ) -> Result<(), Error>

Acknowledge an alarm transition. Sets the transition_bit flags in acked_transitions. Returns Ok(()) if the object supports event detection, Err otherwise.
Source§

fn apply_life_safety_operation( &mut self, _operation: LifeSafetyOperation, ) -> Result<LifeSafetyOperationOutcome, Error>

Apply a LifeSafetyOperation atomically to this object. Read more
Source§

fn set_life_safety_operation_expected_internal( &mut self, _operation: LifeSafetyOperation, ) -> Result<(), Error>

Set the next LifeSafetyOperation expected by trusted local logic. Read more
Source§

fn set_event_state_internal(&mut self, _state: EventState) -> Result<(), Error>

Apply an internally-detected Event_State transition. Read more
Source§

fn enrollment_eval_state_internal(&self) -> Option<EventEnrollmentEvalState>

Snapshot this object’s Event Enrollment evaluation state, if it models one. Read more
Source§

fn set_enrollment_eval_state_internal( &mut self, _state: EventEnrollmentEvalState, ) -> Result<(), Error>

Store this object’s Event Enrollment evaluation state. Read more
Source§

fn enrollment_eval_source_internal( &self, ) -> Option<Option<EventEnrollmentMonitoredSource>>

Snapshot the monitored source that owns Event Enrollment private state. Read more
Source§

fn set_enrollment_eval_source_internal( &mut self, _source: Option<EventEnrollmentMonitoredSource>, ) -> Result<(), Error>

Store or clear the monitored source that owns Event Enrollment state.
Source§

fn set_acked_transitions_internal( &mut self, _transition_bit: EventTransitionBits, _acknowledged: bool, ) -> Result<(), Error>

Set or clear one Acked_Transitions bit on a received event-state transition. Read more
Source§

fn evaluate_reliability_internal( &mut self, ) -> Result<ReliabilityEvaluation, Error>

Evaluate and, when necessary, mutate this object’s Reliability. Read more
Source§

fn set_reliability_internal( &mut self, _reliability: Reliability, ) -> Result<(), Error>

Apply an internally-derived Reliability value. Read more
Source§

fn set_present_value_internal( &mut self, _value: PropertyValue, ) -> Result<(), Error>

Apply the logical Present_Value supplied by the local application. Read more
Source§

fn set_present_value_from_internal( &mut self, value: PropertyValue, _origin: &CommandOrigin, ) -> Result<(), Error>

set_present_value_internal on behalf of origin, the local Device the application runs in. Read more
Source§

fn set_tracking_value_internal( &mut self, _value: PropertyValue, ) -> Result<(), Error>

Apply the Tracking_Value the local application derived. Read more
Source§

fn report_access_input_internal( &mut self, _input: AccessControlInput, ) -> Result<(), Error>

Apply an input the application reports for an access-control object the server holds (#1132): an Access Point’s access event, a Credential Data Input’s read or an Access Door’s hardware state, each a record whose values change together. See AccessControlInput. Read more
Source§

fn set_controlled_variable_value_internal( &mut self, _value: PropertyValue, ) -> Result<(), Error>

Apply the Controlled_Variable_Value measured by the local application. Read more
Source§

fn audit_log_storage_internal(&self) -> Option<&dyn AuditLogStorage>

Borrow this object’s Audit Log query storage, if it has any. Read more
Source§

fn audit_log_notification_sink_internal( &mut self, ) -> Option<&mut dyn AuditLogNotificationSink>

Mutably borrow this object’s Audit notification receiver capability. Read more
Source§

fn file_storage_internal(&self) -> Option<&dyn FileStorage>

Borrow this object’s File storage, if it has any. Read more
Source§

fn file_storage_internal_mut(&mut self) -> Option<&mut dyn FileStorage>

Mutably borrow this object’s File storage, if it has any. Read more
Source§

fn log_record_identities_internal(&self) -> Option<Vec<LogRecordIdentity>>

Return stable identities aligned with this object’s resident log records. Read more
Source§

fn log_buffer_internal(&self) -> Option<&dyn LogBufferRecords>

Borrow this object’s Log_Buffer records as ReadRange pages them. Read more
Source§

fn add_trend_record(&mut self, _record: BACnetLogRecord) -> Result<(), Error>

Submit a trend record to an object’s log lifecycle. Read more
Source§

fn add_trend_multiple_record( &mut self, _record: BACnetLogMultipleRecord, ) -> Result<(), Error>

Submit a Trend Log Multiple record, one value per monitored member, to an object’s log lifecycle. Read more
Source§

fn add_event_log_record( &mut self, _record: BACnetEventLogRecord, ) -> Result<(), Error>

Submit an Event Log record to an object’s log lifecycle. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more