+
+
+
+
+ Warning
+
+
+
+
+
+
+ Laser diameter is out of tolerance.
+ Please check the filament immediately.
+
+
,
+ {
+ id: toastId,
+ duration: Infinity,
+ position: "top-center",
+ style: {
+ background: "transparent",
+ padding: 0,
+ boxShadow: "none",
+ border: "none",
+ },
+ },
+ );
+ }
+ if (inTolerance) {
+ lastToastTs.current = null;
+ }
+ }, [state]);
+
+ return null;
+}
diff --git a/machines/src/laser/act.rs b/machines/src/laser/act.rs
index ea71160b..501dafc2 100644
--- a/machines/src/laser/act.rs
+++ b/machines/src/laser/act.rs
@@ -29,6 +29,10 @@ impl MachineAct for LaserMachine {
};
self.update();
+ if self.did_change_state {
+ self.emit_state();
+ }
+
// more than 33ms have passed since last emit (30 "fps" target)
if now.duration_since(self.last_measurement_emit) > Duration::from_secs_f64(1.0 / 30.0) {
self.emit_live_values();
diff --git a/machines/src/laser/api.rs b/machines/src/laser/api.rs
index 2cc9abc1..923c8b32 100644
--- a/machines/src/laser/api.rs
+++ b/machines/src/laser/api.rs
@@ -49,6 +49,8 @@ pub struct LaserState {
pub lower_tolerance: f64,
/// target diameter in mm
pub target_diameter: f64,
+ /// tolerance bool
+ pub in_tolerance: bool,
}
pub enum LaserEvents {
diff --git a/machines/src/laser/mod.rs b/machines/src/laser/mod.rs
index a7c27a5b..26ffc0a0 100644
--- a/machines/src/laser/mod.rs
+++ b/machines/src/laser/mod.rs
@@ -11,10 +11,10 @@ use smol::{
lock::RwLock,
};
use socketioxide::extract::SocketRef;
+use units::Length;
use crate::AsyncThreadMessage;
use std::{sync::Arc, time::Instant};
-use units::f64::*;
use units::length::millimeter;
pub mod act;
@@ -41,12 +41,18 @@ pub struct LaserMachine {
y_diameter: Option