Add relay state history proto
This commit is contained in:
		| @@ -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; | ||||||
|   | |||||||
							
								
								
									
										44
									
								
								central_backend/src/energy/relay_state_history.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								central_backend/src/energy/relay_state_history.rs
									
									
									
									
									
										Normal 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!() | ||||||
|  |     } | ||||||
|  | } | ||||||
		Reference in New Issue
	
	Block a user