22//! and do exactly nothing with it.
33
44use anyhow:: Result ;
5+ use serde:: { Deserialize , Serialize } ;
56
67use crate :: {
7- Control as ControlTrait , GcodeControl as GcodeControlTrait , GcodeTemporaryFile , HardwareConfiguration ,
8- MachineInfo as MachineInfoTrait , MachineMakeModel , MachineState , MachineType ,
8+ Control as ControlTrait , FdmHardwareConfiguration , Filament , GcodeControl as GcodeControlTrait , GcodeTemporaryFile ,
9+ HardwareConfiguration , MachineInfo as MachineInfoTrait , MachineMakeModel , MachineState , MachineType ,
910 SuspendControl as SuspendControlTrait , ThreeMfControl as ThreeMfControlTrait , ThreeMfTemporaryFile , Volume ,
1011} ;
1112
@@ -14,6 +15,26 @@ pub struct Noop {
1415 make_model : MachineMakeModel ,
1516 machine_type : MachineType ,
1617 volume : Option < Volume > ,
18+ config : Config ,
19+ }
20+
21+ /// Configuration information for a Moonraker-based endpoint.
22+ #[ derive( Clone , Debug , Serialize , Deserialize ) ]
23+ pub struct Config {
24+ /// Extrusion hotend nozzle's diameter.
25+ pub nozzle_diameter : f64 ,
26+
27+ /// Available filaments.
28+ pub filaments : Vec < Filament > ,
29+
30+ /// Currently loaded filament, if possible to determine.
31+ pub loaded_filament_idx : Option < usize > ,
32+
33+ /// state that the machine is in
34+ pub state : MachineState ,
35+
36+ /// percentage through a print
37+ pub progress : Option < f64 > ,
1738}
1839
1940/// Nothing to see here!
@@ -38,11 +59,17 @@ impl MachineInfoTrait for MachineInfo {
3859
3960impl Noop {
4061 /// Return a new no-op Machine.
41- pub fn new ( make_model : MachineMakeModel , machine_type : MachineType , volume : Option < Volume > ) -> Self {
62+ pub fn new (
63+ config : Config ,
64+ make_model : MachineMakeModel ,
65+ machine_type : MachineType ,
66+ volume : Option < Volume > ,
67+ ) -> Self {
4268 Self {
4369 make_model,
4470 volume,
4571 machine_type,
72+ config,
4673 }
4774 }
4875}
@@ -72,15 +99,23 @@ impl ControlTrait for Noop {
7299 }
73100
74101 async fn progress ( & self ) -> Result < Option < f64 > > {
75- Ok ( None )
102+ Ok ( self . config . progress )
76103 }
77104
78105 async fn state ( & self ) -> Result < MachineState > {
79- Ok ( MachineState :: Unknown )
106+ Ok ( self . config . state . clone ( ) )
80107 }
81108
82109 async fn hardware_configuration ( & self ) -> Result < HardwareConfiguration > {
83- Ok ( HardwareConfiguration :: None )
110+ let config = & self . config ;
111+
112+ Ok ( HardwareConfiguration :: Fdm {
113+ config : FdmHardwareConfiguration {
114+ filaments : config. filaments . clone ( ) ,
115+ nozzle_diameter : config. nozzle_diameter ,
116+ loaded_filament_idx : config. loaded_filament_idx ,
117+ } ,
118+ } )
84119 }
85120}
86121
0 commit comments