Add relay state history proto

This commit is contained in:
Pierre HUBERT 2024-09-16 22:41:20 +02:00
parent 20bc71851d
commit 368eb13089
2 changed files with 45 additions and 0 deletions

View File

@ -1,3 +1,4 @@
pub mod consumption; pub mod consumption;
pub mod energy_actor; pub mod energy_actor;
pub mod engine; pub mod engine;
pub mod relay_state_history;

View File

@ -0,0 +1,44 @@
use crate::devices::device::DeviceRelayID;
/// # RelayStateHistory
///
/// This structures handles the manipulation of relay state history files
///
/// These file are binary file optimizing used space.
pub struct RelayStateHistory {
id: DeviceRelayID,
day: usize,
buff: Vec<u8>,
}
impl RelayStateHistory {
/// Open relay state history file, if it exist, or create an empty one
pub fn open(id: DeviceRelayID, day: usize) -> anyhow::Result<Self> {
todo!()
}
/// Create a new in memory dev relay state history
fn new_memory(id: DeviceRelayID, day: usize) -> Self {
todo!()
}
/// Resolve time offset of a given time in buffer
fn resolve_offset(&self, time: i64) -> anyhow::Result<(usize, u8)> {
todo!()
}
/// Set new state of relay
fn set_state(&mut self, time: i64, on: bool) -> anyhow::Result<()> {
todo!()
}
/// Get the state of relay at a given time
fn get_state(&self, time: i64) -> anyhow::Result<bool> {
todo!()
}
/// Persist device relay state history
pub fn save(&self) -> anyhow::Result<()> {
todo!()
}
}