Add handler for relay states
This commit is contained in:
parent
82f2d49dc6
commit
55617dbd7c
8 changed files with 53 additions and 20 deletions
emgauwa-controller/src
|
@ -5,6 +5,7 @@ use chrono::Local;
|
|||
use emgauwa_lib::constants::RELAYS_RETRY_TIMEOUT;
|
||||
use emgauwa_lib::errors::EmgauwaError;
|
||||
use emgauwa_lib::models::Controller;
|
||||
use emgauwa_lib::types::RelayStates;
|
||||
use futures::pin_mut;
|
||||
use tokio::time;
|
||||
use tokio::time::timeout;
|
||||
|
@ -30,7 +31,7 @@ async fn run_relays(app_state: &Addr<AppState>) -> Result<(), EmgauwaError> {
|
|||
|
||||
let mut last_weekday = emgauwa_lib::utils::get_weekday();
|
||||
let mut this = utils::app_state_get_this(app_state).await?;
|
||||
let mut relay_states: Vec<Option<bool>> = Vec::new();
|
||||
let mut relay_states: RelayStates = Vec::new();
|
||||
init_relay_states(&mut relay_states, &this);
|
||||
|
||||
loop {
|
||||
|
@ -80,7 +81,7 @@ async fn run_relays(app_state: &Addr<AppState>) -> Result<(), EmgauwaError> {
|
|||
}
|
||||
}
|
||||
|
||||
fn init_relay_states(relay_states: &mut Vec<Option<bool>>, this: &Controller) {
|
||||
fn init_relay_states(relay_states: &mut RelayStates, this: &Controller) {
|
||||
relay_states.clear();
|
||||
for _ in 0..this.c.relay_count {
|
||||
relay_states.push(None);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue