This patch refactors the state management for the Extruder v2 on both the frontend and backend to use a more centralized and robust model.
- **Backend (Rust):**
- Replaced numerous individual events with two primary events: `StateEvent` for configuration and less frequent state, and `LiveValuesEvent` for high-frequency telemetry.
- State-mutating API calls now emit the entire updated `StateEvent`.
- **Frontend (TypeScript):**
- Replaced multiple specialized hooks (`useInverter`, `useMode`, `useMotor`, etc.) with a single, comprehensive `useExtruder2` hook.
- Centralized all client-side state, including optimistic updates, into the new `useExtruder2` hook.
- UI components are updated to consume all data and actions from the single hook, simplifying data flow.
- Renamed action functions to a consistent verb-first convention (e.g., `extruderSetMode` -> `setExtruderMode`).
This commit refactors the state management and event handling for the laser machine on both the frontend and backend. The changes clarify the distinction between infrequently changing state and frequently updated live values.
- **State and Event Consolidation:**
- Renamed `DiameterEvent` to `LiveValuesEvent` and `LaserStateEvent` to `StateEvent` for better clarity.
- The `StateEvent` now nests laser properties under a `laser_state` object.
- Frontend hook `useLaser1` now manages a single, consolidated state object with optimistic updates using `immer`.
- **API and Naming Simplification:**
- Simplified mutation names by removing the "Target" prefix (e.g., `TargetSetTargetDiameter` is now `SetTargetDiameter`).
- Renamed variables and functions in the frontend for better readability (e.g., `laserDiameter` to `diameter`, `laserSet...` to `set...`).
- **Improved Backend Efficiency:**
- The backend now emits the full state only when it changes, rather than on every tick.
- Live values (diameter) are still emitted at 60 FPS.
This change refactors the EtherCAT initialization process to be non-blocking by moving it into its own dedicated thread.
- The `init_ethercat` function now spawns a named thread ("init_ethercat") to handle interface discovery and the setup loop.
- This prevents the main application from blocking during startup while searching for a valid EtherCAT interface.
- The initialization order in `main.rs` has been slightly adjusted.
- A minor optimization was made to the laser machine actor to avoid redundant `Instant::now()` calls.