mirror of
https://github.com/LastExceed/spacermake.git
synced 2025-03-12 15:01:44 +01:00
update display update messages to account for protocol change
This commit is contained in:
parent
608c192805
commit
3c4213265d
@ -8,7 +8,7 @@ use tap::Pipe;
|
|||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
||||||
use crate::MACHINE_IDS;
|
use crate::MACHINE_IDS;
|
||||||
use crate::utils::{create_display_update_message, minute_mark};
|
use crate::utils::{create_display_time_string, minute_mark};
|
||||||
use crate::{Announcer, State};
|
use crate::{Announcer, State};
|
||||||
|
|
||||||
impl State<Announcer> {
|
impl State<Announcer> {
|
||||||
@ -48,17 +48,24 @@ impl State<Announcer> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn update_runtime_display(&self, machine_id: &str, runtime: Duration) {
|
async fn update_runtime_display(&self, machine_id: &str, runtime: Duration) {
|
||||||
self.client
|
let client = self.client.read().await;
|
||||||
.read()
|
|
||||||
.await
|
let messages = [
|
||||||
.publish(
|
("title", "Dauer".into()),
|
||||||
format!("/cmnd/reader/{machine_id}"),
|
("info", create_display_time_string(runtime)),
|
||||||
QoS::AtMostOnce,
|
];
|
||||||
false,
|
|
||||||
create_display_update_message(runtime)
|
for (route, payload) in messages {
|
||||||
)
|
client
|
||||||
.await
|
.publish(
|
||||||
.expect("failed to publish display update");
|
format!("fabreader/{machine_id}/display/{route}"),
|
||||||
|
QoS::AtMostOnce,
|
||||||
|
false,
|
||||||
|
payload
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.expect("failed to publish display update");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn perform_scheduled_shutdowns(&self) {
|
async fn perform_scheduled_shutdowns(&self) {
|
||||||
|
@ -34,14 +34,11 @@ pub fn minute_mark(duration: Duration) -> bool {
|
|||||||
duration.as_secs() % 60 == 0
|
duration.as_secs() % 60 == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create_display_update_message(runtime: Duration) -> String {
|
pub fn create_display_time_string(runtime: Duration) -> String {
|
||||||
let hours = runtime.as_secs() / 3600;
|
let hours = runtime.as_secs() / 3600;
|
||||||
let minutes = runtime.as_secs() / 60 % 60;
|
let minutes = runtime.as_secs() / 60 % 60;
|
||||||
|
|
||||||
json::object! {
|
json::object! {
|
||||||
Cmd: "message",
|
|
||||||
MssgID: 12,
|
|
||||||
ClrTxt: "Nutzungsdauer",
|
|
||||||
AddnTxt: format!("{hours:.0}:{minutes:0>2.0}")
|
AddnTxt: format!("{hours:.0}:{minutes:0>2.0}")
|
||||||
}.to_string()
|
}.to_string()
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user