Refactor models names
This commit is contained in:
parent
76b14ce75b
commit
be7f31906c
24 changed files with 461 additions and 340 deletions
emgauwa-controller/src
|
@ -1,5 +1,6 @@
|
|||
use emgauwa_lib::{constants, utils};
|
||||
use serde_derive::Deserialize;
|
||||
|
||||
use crate::driver::Driver;
|
||||
|
||||
#[derive(Clone, Debug, Deserialize)]
|
||||
|
@ -23,6 +24,8 @@ pub struct Logging {
|
|||
#[allow(unused)]
|
||||
pub struct Relay {
|
||||
pub driver: Driver,
|
||||
pub name: String,
|
||||
pub number: Option<i64>,
|
||||
pub pin: u8,
|
||||
pub inverted: bool,
|
||||
}
|
||||
|
@ -54,6 +57,8 @@ impl Default for Relay {
|
|||
fn default() -> Self {
|
||||
Relay {
|
||||
driver: Driver::Gpio,
|
||||
number: None,
|
||||
name: String::from("Relay"),
|
||||
pin: 0,
|
||||
inverted: false,
|
||||
}
|
||||
|
@ -79,5 +84,13 @@ impl Default for Logging {
|
|||
}
|
||||
|
||||
pub fn init() -> Settings {
|
||||
utils::load_settings("controller", "CONTROLLER")
|
||||
let mut settings: Settings = utils::load_settings("controller", "CONTROLLER");
|
||||
|
||||
for (num, relay) in settings.relays.iter_mut().enumerate() {
|
||||
if relay.number.is_none() {
|
||||
relay.number = Some(num as i64);
|
||||
}
|
||||
}
|
||||
|
||||
settings
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue