#[cfg(not(feature = "std"))]
use alloc::vec::Vec;
use super::EventNotificationRequest;
use crate::bitstring::LogStatus;
use crate::primitives::{Date, StatusFlags, Time};
#[derive(Debug, Clone, PartialEq)]
pub enum LogDatum {
LogStatus(LogStatus),
BooleanValue(bool),
RealValue(f32),
EnumValue(u64),
UnsignedValue(u64),
SignedValue(i64),
BitstringValue {
unused_bits: u8,
data: Vec<u8>,
},
NullValue,
Failure {
error_class: u32,
error_code: u32,
},
TimeChange(f32),
AnyValue(Vec<u8>),
}
impl From<LogValue> for LogDatum {
fn from(value: LogValue) -> Self {
match value {
LogValue::BooleanValue(value) => Self::BooleanValue(value),
LogValue::RealValue(value) => Self::RealValue(value),
LogValue::EnumValue(value) => Self::EnumValue(value),
LogValue::UnsignedValue(value) => Self::UnsignedValue(value),
LogValue::SignedValue(value) => Self::SignedValue(value),
LogValue::BitstringValue { unused_bits, data } => {
Self::BitstringValue { unused_bits, data }
}
LogValue::NullValue => Self::NullValue,
LogValue::Failure {
error_class,
error_code,
} => Self::Failure {
error_class,
error_code,
},
LogValue::AnyValue(bytes) => Self::AnyValue(bytes),
}
}
}
#[derive(Debug, Clone, PartialEq)]
pub struct BACnetLogRecord {
pub date: Date,
pub time: Time,
pub log_datum: LogDatum,
pub status_flags: Option<StatusFlags>,
}
#[derive(Debug, Clone, PartialEq)]
pub enum EventLogDatum {
LogStatus(LogStatus),
Notification(EventNotificationRequest),
TimeChange(f32),
}
#[derive(Debug, Clone, PartialEq)]
pub struct BACnetEventLogRecord {
pub date: Date,
pub time: Time,
pub log_datum: EventLogDatum,
}
#[derive(Debug, Clone, PartialEq)]
pub enum LogValue {
BooleanValue(bool),
RealValue(f32),
EnumValue(u64),
UnsignedValue(u64),
SignedValue(i64),
BitstringValue {
unused_bits: u8,
data: Vec<u8>,
},
NullValue,
Failure {
error_class: u32,
error_code: u32,
},
AnyValue(Vec<u8>),
}
#[derive(Debug, Clone, PartialEq)]
pub enum LogData {
LogStatus(LogStatus),
Values(Vec<LogValue>),
TimeChange(f32),
}
#[derive(Debug, Clone, PartialEq)]
pub struct BACnetLogMultipleRecord {
pub date: Date,
pub time: Time,
pub log_data: LogData,
}