Skip to content

Commit

Permalink
[app, complex] Подписался на изменения состояние шага мельницы
Browse files Browse the repository at this point in the history
И пока что шаг только отображается в статусной строке.
  • Loading branch information
alex13sh committed Oct 22, 2021
1 parent 15b65ef commit e481486
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions meln_logic/src/structs_2/meln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub mod watcher {
}
};
let f_step = async {
self.step.send(self.step.get());
loop {
let next_step = self.step.get()
.check_next_step(self).await;
Expand Down
2 changes: 1 addition & 1 deletion meln_logic/src/structs_2/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub mod values {

pub mod watcher {
use super::*;
pub use meln::watcher::Meln;
pub use meln::watcher::{Meln, MelnStep};
pub use half_meln::watcher::HalfMeln;
pub use dozator::watcher::Dozator;
pub use oil_station::watcher::OilStation;
Expand Down
13 changes: 10 additions & 3 deletions src/app_complex_simple_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub enum MessageMudbusUpdate {
#[derive(Debug, Clone)]
pub enum MelnMessage {
IsStartedChanged(bool),

NextStep(meln_logic::watcher::MelnStep),
}

impl Application for App {
Expand Down Expand Up @@ -153,6 +153,10 @@ impl Application for App {
Subscription::from_recipe(
PropertyAnimation::new("IsStarted", props.is_started.subscribe())
).map(|enb| Message::MelnMessage(MelnMessage::IsStartedChanged(enb))),
Subscription::from_recipe(
PropertyAnimation::new("Steps", props.step.subscribe())
).map(|step| Message::MelnMessage(MelnMessage::NextStep(step))),

self.dozator.subscription(&props.material.dozator).map(Message::DozatorUI),
self.klapans.subscription(&props.klapans).map(Message::KlapansUI),
])
Expand Down Expand Up @@ -232,7 +236,7 @@ impl Application for App {
.style(ui::style::Button::Exit));
// col.into()

let txt_status = Text::new(format!("Status: {}", self.txt_status));
let txt_status = Text::new(format!("Step: {}", self.txt_status));
let row_exit = Row::new()
.push(txt_status)
.push(Space::with_width(Length::Fill))
Expand Down Expand Up @@ -334,6 +338,9 @@ impl App {
self.log_save();
}
}
NextStep(step) => {
self.txt_status = format!("{:?}",step);
}
}
}

Expand All @@ -354,7 +361,7 @@ impl App {
let warn = values.iter().map(|(_,v)| v)
.map(|v| v.is_error())
.any(|err| err);
self.txt_status = if warn {"Ошибка значений"} else {""}.into();
// self.txt_status = if warn {"Ошибка значений"} else {""}.into();
}

fn log_save(&mut self) {
Expand Down

0 comments on commit e481486

Please sign in to comment.