dcs2 0.1.0

An extensible distributed control system framework made in rust with no-std support.
Documentation
//! # DCS Properties
//! Here lives a number of properties relevant to the system.
use serde::{Deserialize, Serialize};

use crate::rules::measurements::Measurement;

/// Number of max nodes allowed in a cluster
pub const CLUSTER_NODE_COUNT: usize = 7;
/// Number of max nodes allowed in the system.
pub const MAX_NODE_COUNT: usize = 100;
/// Max buffer size to be used when encoding and decoding messages.
pub const MESSAGE_BUFFER_MAX_SIZE: usize = 1024;
/// Max buffer size for errors being logged.
pub const DESCRIPTIVE_LOG_ERROR_MAX_SIZE: usize = 512;
/// Max ammount of measurements per each node to be hold in the [`crate::rules::measurements::SystemState`]
pub const MEASUREMENTS_MAX_COUNT: usize = 15;
/// Max metadata to be exchanged by the [`crate::communication::messages::ControlMessage`]
pub const METADATA_MAX_SIZE: usize = 64;
/// Max length in bytes of the serialized addresses. Used mainly in the [`crate::membership::client::MembershipMessage`]
pub const ADDRESSES_MAX_SIZE: usize = 256;
/// Max ammount of messages to be saved by the [`crate::communication::service::GenericCommunicationService`].
pub const MAX_QUEUED_MESSAGES: usize = 64;
/// Max ammount of rules to be stored in the [`crate::rules::manager::RulesPool`].
pub const RULES_AMOUNT: usize = 4;
/// Number of max clusters where a translator can be.
pub const CLUSTERS_PER_TRANSLATOR: usize = 4;

pub type SystemBufferVec = heapless::Vec<u8, MESSAGE_BUFFER_MAX_SIZE>;
pub type MeasurementsVec = heapless::Vec<Measurement, CLUSTER_NODE_COUNT>;
pub type AddressesBytesVec = heapless::Vec<u8, ADDRESSES_MAX_SIZE>;
pub type EncodedMetadataVec = heapless::Vec<u8, METADATA_MAX_SIZE>;

#[derive(Debug, Eq, PartialEq, Serialize, Deserialize, Clone)]
pub struct EncodedMetadata {
    pub node: EncodedMetadataVec,
    pub coordination: Option<EncodedMetadataVec>,
}

pub fn init_buffer() -> [u8; MESSAGE_BUFFER_MAX_SIZE] {
    [0_u8; MESSAGE_BUFFER_MAX_SIZE]
}
pub fn init_system_vec() -> SystemBufferVec {
    SystemBufferVec::new()
}

pub enum SystemError {
    NotValidStrategyError,
}