1use async_trait::async_trait;
18use chrono::{DateTime, Utc};
19use std::error::Error;
20
21#[derive(Clone, PartialEq, Debug)]
22pub struct SocUpdate {
23 pub time: DateTime<Utc>,
24 pub target_soc_low: f64,
25 pub target_soc_high: f64,
26 pub alarm_soc: f64,
27 pub target_soc_export_low: f64,
28 pub target_soc_export_high: f64,
29 pub current_soc: f64,
30 pub predicted_pv: f64, pub is_loadshedding: bool,
32 pub next_change: Option<DateTime<Utc>>,
33}
34
35#[derive(Clone, PartialEq, Debug)]
36pub struct CoilUpdate {
37 pub time: DateTime<Utc>,
38 pub active: bool,
39 pub target: Option<f64>, pub setting: Option<f64>, }
42
43#[async_trait]
44pub trait Monitor: Send {
45 async fn soc_update(&mut self, update: SocUpdate) -> Result<(), Box<dyn Error>>;
46 async fn coil_update(&mut self, update: CoilUpdate) -> Result<(), Box<dyn Error>>;
47}
48
49pub struct NullMonitor;
50
51#[async_trait]
52impl Monitor for NullMonitor {
53 async fn soc_update(&mut self, _: SocUpdate) -> Result<(), Box<dyn Error>> {
54 Ok(())
55 }
56
57 async fn coil_update(&mut self, _: CoilUpdate) -> Result<(), Box<dyn Error>> {
58 Ok(())
59 }
60}