bacnet-services 0.11.0

BACnet service request/response encode/decode per ASHRAE 135-2020
Documentation
use super::property_states::{
    decode_device_obj_prop_ref, decode_property_states, encode_property_states, extract_raw_context,
};
use super::*;

mod decode;
mod decode_helpers;
mod decode_timer;
mod encode;
mod structured;

// ---------------------------------------------------------------------------
// NotificationParameters
// ---------------------------------------------------------------------------

/// Notification parameter variants for eventValues.
#[derive(Debug, Clone, PartialEq)]
pub enum NotificationParameters {
    /// [0] Change of bitstring.
    ChangeOfBitstring {
        referenced_bitstring: (u8, Vec<u8>),
        status_flags: u8,
    },
    /// [1] Change of state.
    ChangeOfState {
        new_state: BACnetPropertyStates,
        status_flags: u8,
    },
    /// [2] Change of value.
    ChangeOfValue {
        new_value: ChangeOfValueChoice,
        status_flags: u8,
    },
    /// [3] Command failure. Value byte vectors contain encoded BACnet TLVs.
    CommandFailure {
        command_value: Vec<u8>,
        status_flags: u8,
        feedback_value: Vec<u8>,
    },
    /// [4] Floating limit.
    FloatingLimit {
        reference_value: f32,
        status_flags: u8,
        setpoint_value: f32,
        error_limit: f32,
    },
    /// [5] Out of range.
    OutOfRange {
        exceeding_value: f32,
        status_flags: u8,
        deadband: f32,
        exceeded_limit: f32,
    },
    /// [6] Complex event type.
    ComplexEventType {
        property_values: Vec<BACnetPropertyValue>,
    },
    /// [8] Change of life safety.
    ChangeOfLifeSafety {
        new_state: u32,
        new_mode: u32,
        status_flags: u8,
        operation_expected: u32,
    },
    /// [9] Extended (vendor-defined). `parameters` contains encoded BACnet TLVs.
    Extended {
        vendor_id: u16,
        extended_event_type: u32,
        parameters: Vec<u8>,
    },
    /// [10] Buffer ready.
    BufferReady {
        buffer_property: BACnetDeviceObjectPropertyReference,
        previous_notification: u32,
        current_notification: u32,
    },
    /// [11] Unsigned range.
    UnsignedRange {
        exceeding_value: u64,
        status_flags: u8,
        exceeded_limit: u64,
    },
    /// [13] Access event. Authentication-factor bytes contain its three inner context fields.
    AccessEvent {
        access_event: u32,
        status_flags: u8,
        access_event_tag: u32,
        access_event_time: (Date, Time),
        access_credential: BACnetDeviceObjectReference,
        authentication_factor: Option<Vec<u8>>,
    },
    /// [14] Double out of range.
    DoubleOutOfRange {
        exceeding_value: f64,
        status_flags: u8,
        deadband: f64,
        exceeded_limit: f64,
    },
    /// [15] Signed out of range.
    SignedOutOfRange {
        exceeding_value: i32,
        status_flags: u8,
        deadband: u64,
        exceeded_limit: i32,
    },
    /// [16] Unsigned out of range.
    UnsignedOutOfRange {
        exceeding_value: u64,
        status_flags: u8,
        deadband: u64,
        exceeded_limit: u64,
    },
    /// [17] Change of characterstring.
    ChangeOfCharacterstring {
        changed_value: String,
        status_flags: u8,
        alarm_value: String,
    },
    /// [18] Change of status flags. `present_value` preserves absent and present-empty context [0].
    ChangeOfStatusFlags {
        present_value: Option<Vec<u8>>,
        referenced_flags: u8,
    },
    /// [19] Change of reliability. `property_values` contains encoded BACnet TLVs.
    ChangeOfReliability {
        reliability: u32,
        status_flags: u8,
        property_values: Vec<u8>,
    },
    /// [21] Change of discrete value. `new_value` contains encoded BACnet TLVs.
    ChangeOfDiscreteValue {
        new_value: Vec<u8>,
        status_flags: u8,
    },
    /// [22] Change of timer.
    ChangeOfTimer {
        new_state: u32,
        status_flags: u8,
        update_time: (Date, Time),
        last_state_change: Option<u32>,
        initial_timeout: Option<u32>,
        expiration_time: Option<(Date, Time)>,
    },
}

/// CHOICE within ChangeOfValue notification parameters.
#[derive(Debug, Clone, PartialEq)]
pub enum ChangeOfValueChoice {
    ChangedBits { unused_bits: u8, data: Vec<u8> },
    ChangedValue(f32),
}