1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
use crate::models::file::GcodeFile;
use crate::models::temperature::Temperature;
use serde::{Deserialize, Serialize};
use strum::Display;
/// Main struct to communicate with the lib
#[derive(Clone, Serialize, Deserialize)]
pub enum Action {
/// telemetry data from the lib
Telemetry(TelemetryData),
/// The state of the printer changed (eg. idle or active)
StateChange(PrinterStatus),
/// a action from the printer (eg. cancel or pause)
PrinterAction(PrinterAction),
/// send a command to the lib
Command(Command),
}
#[derive(Clone, Serialize, Deserialize, PartialEq, Eq, Display)]
pub enum PrinterStatus {
Disconnected,
Active,
Idle,
Errored,
}
/// Action sent by printer
#[derive(Clone, Serialize, Deserialize, Display)]
pub enum PrinterAction {
Cancel,
Pause,
Resume,
}
#[derive(Clone, Serialize, Deserialize)]
pub enum TelemetryData {
/// Hotend and Bed Temperature telemtry
Temps(Temperature),
/// commands left in Que
Progress(u32),
/// Currently only used by sd-card prints (percentage completed)
PercentDone(u32),
/// Currently only used by sd-card prints (Minutes left to print)
MinsRemaining(u32),
/// total number of commands of active print
TotalCommandCount(u32),
/// target extruder temp changed
TargetExtruderTemp(u32),
/// target bed temp changed
TargetBedTemp(u32),
/// zHeight changed
ZHeight(f32),
/// Maximum ZHeight of the current print
MaxZHeight(f32),
/// Fan speed changed
FanSpeed(f32),
/// Active print file changed
ActiveFile(Option<GcodeFile>),
/// Last print file changed
LastFileActive(GcodeFile),
}
/// Send an Action command to the lib
#[derive(Clone, Serialize, Deserialize)]
pub enum Command {
/// Set target temps (bed, extruder)
SetTemps(u16, u16),
/// Start printing a file given by path
StartPrint(String),
/// stop currently active print
StopPrint,
}