Record relays state
This commit is contained in:
central_backend
@ -1,4 +1,4 @@
|
||||
use crate::devices::device::DeviceId;
|
||||
use crate::devices::device::{DeviceId, DeviceRelayID};
|
||||
use clap::{Parser, Subcommand};
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
@ -81,7 +81,7 @@ pub struct AppConfig {
|
||||
pub production_margin: i32,
|
||||
|
||||
/// Energy refresh operations interval, in seconds
|
||||
#[arg(short('i'), long, env, default_value_t = 30)]
|
||||
#[arg(short('i'), long, env, default_value_t = 20)]
|
||||
pub refresh_interval: u64,
|
||||
|
||||
/// Consumption backend provider
|
||||
@ -235,6 +235,18 @@ impl AppConfig {
|
||||
pub fn device_csr_path(&self, id: &DeviceId) -> PathBuf {
|
||||
self.devices_config_path().join(format!("{}.csr", id.0))
|
||||
}
|
||||
|
||||
/// Get relays runtime storage path
|
||||
pub fn relays_runtime_stats_storage_path(&self) -> PathBuf {
|
||||
self.storage_path().join("relays_runtime")
|
||||
}
|
||||
|
||||
/// Get relay runtime stats path for a given day
|
||||
pub fn relay_runtime_file_path(&self, relay_id: DeviceRelayID, day: u64) -> PathBuf {
|
||||
self.relays_runtime_stats_storage_path()
|
||||
.join(relay_id.0.to_string())
|
||||
.join(day.to_string())
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
Reference in New Issue
Block a user