1use std::collections::BTreeMap;
10
11use printobserver_printer_api::{Adjustable, PrinterState};
12use printobserver_types::contract::Sample;
13use printobserver_types::{EventId, FileName, ImageId, PrintId, Range, Timestamp};
14
15use super::action::{
16 AcknowledgementDisposition, ActionKind, ActionRecord, ActionRequest, Actor, ActorClass,
17 ExecutionOutcome, PrintAction,
18};
19use super::charge::{
20 ChargeKey, ChargeMethod, ChargedFilament, FilePosition, PendingCharge, PendingTaken,
21 PrintOutcome, PrintSegmentKey,
22};
23use super::ids::{ActionId, InterventionId, SpoolId};
24use super::image::ImageRecord;
25use super::intervention::{Intervention, InterventionOutcome};
26use super::manifest::JobManifest;
27use super::policy::{
28 EffectiveBounds, PolicyDecision, RejectionReason, SafetyEnvelope, SpoolField, SpoolRefusalCause,
29};
30use super::preflight::{
31 DoubtedSpool, Preflight, PreflightNeed, PreflightObjection, PreflightSpool, PreflightTool,
32 PreflightToolResult, PreflightVerdict, ShortSpool, UnanalysedSpool,
33};
34use super::print::{ManifestNarrowing, PrintRecord};
35use super::spool::{
36 ClearedMark, LoadedSpool, SpoolLifecycle, SpoolRecord, SpoolTrust, UnverifiedMark,
37 UnverifiedMarks, UnverifiedReason,
38};
39use super::spool_command::SpoolCommand;
40
41fn later_instant() -> Timestamp {
43 "2026-03-01T12:30:00Z"
44 .parse()
45 .expect("a fixed RFC 3339 instant")
46}
47
48fn action_id() -> ActionId {
50 "0191f0a0-0000-7000-8000-000000000004"
51 .parse()
52 .expect("a fixed version 7 identifier")
53}
54
55fn intervention_id() -> InterventionId {
57 "0191f0a0-0000-7000-8000-000000000005"
58 .parse()
59 .expect("a fixed version 7 identifier")
60}
61
62fn spool_id() -> SpoolId {
64 "0191f0a0-0000-7000-8000-000000000006"
65 .parse()
66 .expect("a fixed version 7 identifier")
67}
68
69fn replaced_spool_id() -> SpoolId {
71 "0191f0a0-0000-7000-8000-000000000007"
72 .parse()
73 .expect("a fixed version 7 identifier")
74}
75
76impl Sample for SpoolId {
77 fn sample_full() -> Self {
78 spool_id()
79 }
80}
81
82impl Sample for ActionId {
83 fn sample_full() -> Self {
84 action_id()
85 }
86}
87
88impl Sample for InterventionId {
89 fn sample_full() -> Self {
90 intervention_id()
91 }
92}
93
94impl Sample for ManifestNarrowing {
95 fn sample_full() -> Self {
96 Self {
97 adjustable: Adjustable::Feedrate,
98 requested: Range::new(0.2, 4.0),
99 applied: Range::new(0.5, 1.5),
100 }
101 }
102}
103
104impl Sample for PrintRecord {
105 fn sample_full() -> Self {
106 Self {
107 id: PrintId::sample_full(),
108 provider_print_id: Some(4211),
109 file_name: Some("benchy.gcode".to_owned()),
110 state: PrinterState::Printing,
111 opened_at: Timestamp::sample_full(),
112 job_started_at: Some(Timestamp::sample_full()),
113 job_print_time_s: Some(3024),
114 ended_at: Some(later_instant()),
115 end_reason: Some("finished".to_owned()),
116 narrowings: vec![ManifestNarrowing::sample_full()],
117 }
118 }
119
120 fn sample_minimal() -> Self {
121 Self {
122 id: PrintId::sample_full(),
123 provider_print_id: None,
124 file_name: None,
125 state: PrinterState::Printing,
126 opened_at: Timestamp::sample_full(),
127 job_started_at: None,
128 job_print_time_s: None,
129 ended_at: None,
130 end_reason: None,
131 narrowings: vec![],
132 }
133 }
134}
135
136impl Sample for ImageRecord {
137 fn sample_full() -> Self {
138 Self {
139 id: ImageId::sample_full(),
140 print_id: Some(PrintId::sample_full()),
141 event_id: EventId::sample_full(),
142 source_url: Some("https://detector.example/snapshots/1.jpg".to_owned()),
143 fetched_at: Timestamp::sample_full(),
144 content_type: "image/jpeg".to_owned(),
145 byte_len: 51_200,
146 sha256: "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855".to_owned(),
147 relative_path: "images/0191f0a0/1.jpg".to_owned(),
148 }
149 }
150
151 fn sample_minimal() -> Self {
152 Self {
153 print_id: None,
154 source_url: None,
155 ..Self::sample_full()
156 }
157 }
158}
159
160impl Sample for Actor {
161 fn sample_full() -> Self {
162 Self::Agent {
163 session_name: "print-0191f0a0".to_owned(),
164 }
165 }
166}
167
168impl Sample for ActorClass {
169 fn sample_full() -> Self {
170 Self::Agent
171 }
172}
173
174impl Sample for ActionKind {
175 fn sample_full() -> Self {
176 Self::SetFeedrateFactor
177 }
178}
179
180impl Sample for AcknowledgementDisposition {
181 fn sample_full() -> Self {
182 Self::Watch
183 }
184}
185
186impl Sample for ExecutionOutcome {
187 fn sample_full() -> Self {
188 Self::Failed {
189 reason: "the printer refused the command".to_owned(),
190 }
191 }
192}
193
194impl Sample for PrintAction {
195 fn sample_full() -> Self {
196 Self::SetFeedrateFactor {
197 factor: 0.8,
198 duration_s: Some(600),
199 reason: "the first layer is going down fast".to_owned(),
200 actor: Actor::sample_full(),
201 }
202 }
203
204 fn sample_minimal() -> Self {
205 Self::SetFeedrateFactor {
206 factor: 0.8,
207 duration_s: None,
208 reason: "the first layer is going down fast".to_owned(),
209 actor: Actor::sample_full(),
210 }
211 }
212
213 fn sample_alternates() -> Vec<Self> {
214 let reason = || "the print needs it".to_owned();
215 vec![
216 Self::Pause {
217 reason: reason(),
218 actor: Actor::sample_full(),
219 },
220 Self::Resume {
221 reason: reason(),
222 actor: Actor::sample_full(),
223 },
224 Self::Cancel {
225 reason: reason(),
226 actor: Actor::sample_full(),
227 },
228 Self::StartPrint {
229 file_name: FileName::sample_full(),
230 manifest: JobManifest::sample_full(),
231 override_filament_check: true,
232 reason: reason(),
233 actor: Actor::sample_full(),
234 },
235 Self::SetFlowrateFactor {
236 factor: 1.05,
237 duration_s: Some(300),
238 reason: reason(),
239 actor: Actor::sample_full(),
240 },
241 Self::SetToolTargetC {
242 tool: 0,
243 target_c: 215.0,
244 duration_s: Some(300),
245 reason: reason(),
246 actor: Actor::sample_full(),
247 },
248 Self::SetBedTargetC {
249 target_c: 60.0,
250 duration_s: Some(300),
251 reason: reason(),
252 actor: Actor::sample_full(),
253 },
254 Self::SetFanPercent {
255 percent: 80.0,
256 duration_s: Some(300),
257 reason: reason(),
258 actor: Actor::sample_full(),
259 },
260 Self::AcknowledgeFailure {
261 event_id: EventId::sample_full(),
262 disposition: AcknowledgementDisposition::Watch,
263 reason: reason(),
264 actor: Actor::Operator,
265 },
266 Self::ClosePrint {
267 outcome: PrintOutcome::Interrupted,
268 reason: "the printer was switched off mid-print".to_owned(),
269 actor: Actor::Operator,
270 },
271 ]
272 }
273}
274
275impl Sample for ActionRequest {
276 fn sample_full() -> Self {
277 Self {
278 action: PrintAction::sample_full(),
279 actor: Actor::sample_full(),
280 requested_at: Timestamp::sample_full(),
281 }
282 }
283
284 fn sample_minimal() -> Self {
285 Self {
286 action: PrintAction::sample_minimal(),
287 ..Self::sample_full()
288 }
289 }
290}
291
292impl Sample for ActionRecord {
293 fn sample_full() -> Self {
294 Self {
295 id: action_id(),
296 print_id: PrintId::sample_full(),
297 request: ActionRequest::sample_full(),
298 decision: PolicyDecision::Accepted,
299 executed_at: Some(later_instant()),
300 outcome: Some(ExecutionOutcome::Succeeded),
301 }
302 }
303
304 fn sample_minimal() -> Self {
305 Self {
306 request: ActionRequest::sample_minimal(),
307 executed_at: None,
308 outcome: None,
309 ..Self::sample_full()
310 }
311 }
312}
313
314fn allowed_ranges() -> BTreeMap<Adjustable, Range> {
316 BTreeMap::from([
317 (Adjustable::Feedrate, Range::new(0.5, 1.5)),
318 (Adjustable::ToolTarget { tool: 0 }, Range::new(190.0, 230.0)),
319 ])
320}
321
322impl Sample for JobManifest {
323 fn sample_full() -> Self {
324 Self {
325 file_name: "benchy.gcode".to_owned(),
326 material: "PLA".to_owned(),
327 nozzle_diameter_mm: 0.4,
328 slicer_profile: "0.2mm standard".to_owned(),
329 allowed: allowed_ranges(),
330 metadata: BTreeMap::from([("layer_height_mm".to_owned(), "0.2".to_owned())]),
331 }
332 }
333}
334
335impl Sample for SafetyEnvelope {
336 fn sample_full() -> Self {
337 Self {
338 allowed: allowed_ranges(),
339 actions: BTreeMap::from([(
340 ActorClass::Agent,
341 vec![ActionKind::Pause, ActionKind::SetFeedrateFactor],
342 )]),
343 agent_min_interval_s: 60,
344 }
345 }
346}
347
348impl Sample for EffectiveBounds {
349 fn sample_full() -> Self {
350 Self {
351 allowed: allowed_ranges(),
352 }
353 }
354}
355
356impl Sample for RejectionReason {
357 fn sample_full() -> Self {
358 Self::OutOfBounds {
359 adjustable: Adjustable::Feedrate,
360 requested: 4.0,
361 allowed: Range::new(0.5, 1.5),
362 }
363 }
364
365 fn sample_alternates() -> Vec<Self> {
366 vec![
367 Self::InsufficientFilament {
368 tool: 0,
369 spool_id: spool_id(),
370 spool_name: "Galaxy black".to_owned(),
371 required_g: 120.0,
372 buffer_g: 12.0,
373 remaining_g: 80.0,
374 unverified: Some(UnverifiedReason::sample_full()),
375 },
376 Self::InsufficientFilament {
377 tool: 0,
378 spool_id: spool_id(),
379 spool_name: "Galaxy black".to_owned(),
380 required_g: 120.0,
381 buffer_g: 12.0,
382 remaining_g: 80.0,
383 unverified: None,
384 },
385 Self::UnverifiedSpool {
386 tool: 0,
387 spool_id: spool_id(),
388 spool_name: "Galaxy black".to_owned(),
389 reason: UnverifiedReason::sample_full(),
390 },
391 Self::AnalysisUnavailable {
392 file_name: "benchy.gcode".to_owned(),
393 waited_s: 300,
394 },
395 Self::SpoolRefused {
396 cause: SpoolRefusalCause::sample_full(),
397 message: "spool Galaxy black is retired, so it takes no command".to_owned(),
398 },
399 Self::PrintAlreadyEnded,
400 Self::PrintStillActive {
401 state: PrinterState::Paused,
402 },
403 Self::InterventionStillActive {
404 intervention_id: InterventionId::sample_full(),
405 },
406 ]
407 }
408}
409
410impl Sample for SpoolField {
411 fn sample_full() -> Self {
412 Self::GrossG
413 }
414}
415
416impl Sample for SpoolRefusalCause {
417 fn sample_full() -> Self {
418 Self::RetiredSpool {
419 spool_id: spool_id(),
420 }
421 }
422
423 fn sample_minimal() -> Self {
424 Self::DensityRequired {
425 spool_id: None,
426 material: "PEEK".to_owned(),
427 }
428 }
429
430 fn sample_alternates() -> Vec<Self> {
431 vec![
432 Self::UnknownSpool {
433 spool_id: replaced_spool_id(),
434 },
435 Self::NothingToConfirm { tool: 0 },
436 Self::InvalidAdjustmentFigure {
437 field: SpoolField::GrossG,
438 value: -5.0,
439 },
440 Self::TareRequired {
441 spool_id: spool_id(),
442 },
443 Self::DensityRequired {
444 spool_id: Some(spool_id()),
445 material: "PEEK".to_owned(),
446 },
447 Self::MissingField {
448 field: SpoolField::Name,
449 },
450 Self::ConflictingFields {
451 fields: vec![SpoolField::RemainingG, SpoolField::GrossG],
452 },
453 Self::UnknownTool { tool: -1 },
454 Self::NotLoaded {
455 spool_id: spool_id(),
456 },
457 Self::LedgerRefused,
458 ]
459 }
460}
461
462impl Sample for PolicyDecision {
463 fn sample_full() -> Self {
464 Self::Rejected(RejectionReason::sample_full())
465 }
466}
467
468impl Sample for InterventionOutcome {
469 fn sample_full() -> Self {
470 Self::Superseded {
471 by: intervention_id(),
472 }
473 }
474}
475
476impl Sample for Intervention {
477 fn sample_full() -> Self {
478 Self {
479 id: intervention_id(),
480 print_id: PrintId::sample_full(),
481 action_id: action_id(),
482 adjustable: Adjustable::Feedrate,
483 prior_value: Some(1.0),
484 applied_value: 0.8,
485 applied_at: Timestamp::sample_full(),
486 expires_at: later_instant(),
487 restored_at: Some(later_instant()),
488 outcome: InterventionOutcome::Restored,
489 }
490 }
491
492 fn sample_minimal() -> Self {
493 Self {
494 prior_value: None,
495 restored_at: None,
496 outcome: InterventionOutcome::StillActive,
497 ..Self::sample_full()
498 }
499 }
500}
501
502impl Sample for UnverifiedReason {
503 fn sample_full() -> Self {
504 Self::UnchargedPrint {
505 print_id: PrintId::sample_full(),
506 }
507 }
508
509 fn sample_alternates() -> Vec<Self> {
510 vec![
511 Self::UnaccountedPrint {
512 file_name: "benchy.gcode".to_owned(),
513 printed_at: Timestamp::sample_full(),
514 },
515 Self::FilamentChangeUnconfirmed {
516 print_id: PrintId::sample_full(),
517 },
518 Self::FilamentChangeUnconfirmedPosition {
519 print_id: PrintId::sample_full(),
520 },
521 Self::TallyReset {
522 file_name: "benchy.gcode".to_owned(),
523 origin: "local".to_owned(),
524 },
525 ]
526 }
527}
528
529impl Sample for UnverifiedMark {
530 fn sample_full() -> Self {
531 Self {
532 reason: UnverifiedReason::sample_full(),
533 since: Timestamp::sample_full(),
534 }
535 }
536}
537
538impl Sample for UnverifiedMarks {
539 fn sample_full() -> Self {
540 Self::new(vec![
541 UnverifiedMark::sample_full(),
542 UnverifiedMark {
543 reason: UnverifiedReason::FilamentChangeUnconfirmed {
544 print_id: PrintId::sample_full(),
545 },
546 since: later_instant(),
547 },
548 ])
549 .expect("two marks")
550 }
551}
552
553impl Sample for SpoolTrust {
554 fn sample_full() -> Self {
555 Self::Unverified {
556 marks: UnverifiedMarks::sample_full(),
557 }
558 }
559
560 fn sample_alternates() -> Vec<Self> {
561 vec![Self::Verified]
562 }
563}
564
565impl Sample for SpoolRecord {
566 fn sample_full() -> Self {
567 Self {
568 id: spool_id(),
569 name: "Galaxy black".to_owned(),
570 material: "PLA".to_owned(),
571 color: Some("black".to_owned()),
572 diameter_mm: 1.75,
573 density_g_cm3: 1.24,
574 initial_g: 1_000.0,
575 remaining_g: 742.5,
576 tare_g: Some(250.0),
577 lifecycle: SpoolLifecycle::sample_full(),
578 trust: SpoolTrust::sample_full(),
579 registered_at: Timestamp::sample_full(),
580 updated_at: later_instant(),
581 }
582 }
583
584 fn sample_minimal() -> Self {
585 Self {
586 color: None,
587 tare_g: None,
588 lifecycle: SpoolLifecycle::Shelved,
589 trust: SpoolTrust::Verified,
590 ..Self::sample_full()
591 }
592 }
593
594 fn sample_alternates() -> Vec<Self> {
595 vec![Self {
596 remaining_g: 12.5,
597 lifecycle: SpoolLifecycle::Retired {
598 at: later_instant(),
599 },
600 ..Self::sample_full()
601 }]
602 }
603}
604
605impl Sample for SpoolLifecycle {
606 fn sample_full() -> Self {
607 Self::Loaded { tool: 0 }
608 }
609
610 fn sample_alternates() -> Vec<Self> {
611 vec![
612 Self::Shelved,
613 Self::Retired {
614 at: later_instant(),
615 },
616 ]
617 }
618}
619
620impl Sample for ClearedMark {
621 fn sample_full() -> Self {
622 Self {
623 spool_id: replaced_spool_id(),
624 reason: UnverifiedReason::FilamentChangeUnconfirmed {
625 print_id: PrintId::sample_full(),
626 },
627 }
628 }
629}
630
631impl Sample for LoadedSpool {
632 fn sample_full() -> Self {
633 Self {
634 tool: 0,
635 spool_id: spool_id(),
636 }
637 }
638}
639
640impl Sample for PrintOutcome {
641 fn sample_full() -> Self {
642 Self::Completed
643 }
644
645 fn sample_alternates() -> Vec<Self> {
646 vec![Self::Cancelled, Self::Failed, Self::Interrupted]
647 }
648}
649
650impl Sample for ChargeMethod {
651 fn sample_full() -> Self {
652 Self::GcodeExtrusion
653 }
654}
655
656impl Sample for ChargeKey {
657 fn sample_full() -> Self {
658 Self::Print {
659 print_id: PrintId::sample_full(),
660 tool: 0,
661 segment: 1,
662 }
663 }
664
665 fn sample_alternates() -> Vec<Self> {
666 vec![Self::Unobserved {
667 origin: "local".to_owned(),
668 file_name: "benchy.gcode".to_owned(),
669 generation: 2,
670 print_number: 7,
671 tool: 0,
672 }]
673 }
674}
675
676impl Sample for FilePosition {
677 fn sample_full() -> Self {
678 Self {
679 bytes: 1_761_607,
680 size_bytes: Some(4_194_304),
681 observed_at: Timestamp::sample_full(),
682 }
683 }
684
685 fn sample_minimal() -> Self {
686 Self {
687 size_bytes: None,
688 ..Self::sample_full()
689 }
690 }
691}
692
693impl Sample for PrintSegmentKey {
694 fn sample_full() -> Self {
695 Self {
696 print_id: PrintId::sample_full(),
697 tool: 0,
698 segment: 1,
699 }
700 }
701}
702
703impl Sample for ChargedFilament {
704 fn sample_full() -> Self {
705 Self {
706 spool_id: spool_id(),
707 grams: 2.98,
708 diameter_mm: 1.75,
709 density_g_cm3: 1.24,
710 remaining_before_g: 745.48,
711 remaining_after_g: 742.5,
712 }
713 }
714}
715
716impl Sample for PendingCharge {
717 fn sample_full() -> Self {
718 Self {
719 charge_key: PrintSegmentKey::sample_full(),
720 length_mm: 1_204.5,
721 method: ChargeMethod::GcodeExtrusion,
722 analysed_length_mm: Some(5_120.0),
723 position: Some(FilePosition::sample_full()),
724 note: Some("fed after the filament change at layer 12".to_owned()),
725 pended_at: later_instant(),
726 }
727 }
728
729 fn sample_minimal() -> Self {
730 Self {
731 method: ChargeMethod::FileFraction,
732 analysed_length_mm: None,
733 position: None,
734 note: None,
735 ..Self::sample_full()
736 }
737 }
738}
739
740impl Sample for PendingTaken {
741 fn sample_full() -> Self {
742 Self {
743 charge_key: ChargeKey::sample_full(),
744 print_id: PrintId::sample_full(),
745 }
746 }
747}
748
749impl Sample for PreflightVerdict {
750 fn sample_full() -> Self {
751 Self::Insufficient
752 }
753}
754
755impl Sample for PreflightSpool {
756 fn sample_full() -> Self {
757 Self {
758 id: spool_id(),
759 name: "Galaxy black".to_owned(),
760 }
761 }
762}
763
764impl Sample for PreflightNeed {
765 fn sample_full() -> Self {
766 Self {
767 required_g: 120.0,
768 buffer_g: 12.0,
769 }
770 }
771}
772
773impl Sample for ShortSpool {
774 fn sample_full() -> Self {
775 Self {
776 spool: PreflightSpool::sample_full(),
777 remaining_g: 80.0,
778 need: PreflightNeed::sample_full(),
779 marks: vec![UnverifiedMark::sample_full()],
780 }
781 }
782
783 fn sample_minimal() -> Self {
784 Self {
785 marks: Vec::new(),
786 ..Self::sample_full()
787 }
788 }
789}
790
791impl Sample for DoubtedSpool {
792 fn sample_full() -> Self {
793 Self {
794 spool: PreflightSpool::sample_full(),
795 remaining_g: 742.5,
796 need: Some(PreflightNeed::sample_full()),
797 marks: UnverifiedMarks::sample_full(),
798 }
799 }
800
801 fn sample_minimal() -> Self {
802 Self {
803 need: None,
804 ..Self::sample_full()
805 }
806 }
807}
808
809impl Sample for UnanalysedSpool {
810 fn sample_full() -> Self {
811 Self {
812 spool: PreflightSpool::sample_full(),
813 remaining_g: 742.5,
814 }
815 }
816}
817
818impl Sample for PreflightObjection {
819 fn sample_full() -> Self {
820 Self::Insufficient(ShortSpool::sample_full())
821 }
822
823 fn sample_minimal() -> Self {
824 Self::NoAnalysis(UnanalysedSpool::sample_full())
825 }
826
827 fn sample_alternates() -> Vec<Self> {
828 vec![
829 Self::Insufficient(ShortSpool::sample_minimal()),
830 Self::UnverifiedSpool(DoubtedSpool::sample_full()),
831 ]
832 }
833}
834
835impl Sample for PreflightToolResult {
836 fn sample_full() -> Self {
837 Self::Insufficient(ShortSpool::sample_full())
838 }
839
840 fn sample_minimal() -> Self {
841 Self::Unchecked
842 }
843
844 fn sample_alternates() -> Vec<Self> {
845 vec![
846 Self::Passed {
847 spool: PreflightSpool::sample_full(),
848 remaining_g: 742.5,
849 need: PreflightNeed::sample_full(),
850 },
851 Self::UnverifiedSpool(DoubtedSpool::sample_minimal()),
852 Self::NoAnalysis(UnanalysedSpool::sample_full()),
853 Self::Overridden {
854 objection: PreflightObjection::sample_full(),
855 },
856 Self::Warned {
857 objection: PreflightObjection::NoAnalysis(UnanalysedSpool::sample_full()),
858 },
859 ]
860 }
861}
862
863impl Sample for PreflightTool {
864 fn sample_full() -> Self {
865 Self {
866 tool: 0,
867 result: PreflightToolResult::sample_full(),
868 }
869 }
870
871 fn sample_minimal() -> Self {
872 Self {
873 tool: 1,
874 result: PreflightToolResult::Unchecked,
875 }
876 }
877}
878
879impl Sample for Preflight {
880 fn sample_full() -> Self {
881 Self {
882 file_name: "benchy.gcode".to_owned(),
883 tools: vec![
884 PreflightTool::sample_full(),
885 PreflightTool::sample_minimal(),
886 ],
887 verdict: PreflightVerdict::Insufficient,
888 checked_at: Timestamp::sample_full(),
889 }
890 }
891}
892
893impl Sample for SpoolCommand {
894 fn sample_full() -> Self {
895 Self::RegisterSpool {
896 name: "Galaxy black".to_owned(),
897 material: "PLA".to_owned(),
898 color: Some("black".to_owned()),
899 diameter_mm: Some(1.75),
900 density_g_cm3: Some(1.24),
901 initial_g: 1_000.0,
902 remaining_g: Some(742.5),
903 tare_g: Some(250.0),
904 reason: "a new spool went on the shelf".to_owned(),
905 actor: Actor::Operator,
906 }
907 }
908
909 fn sample_minimal() -> Self {
910 Self::RegisterSpool {
911 name: "Galaxy black".to_owned(),
912 material: "PLA".to_owned(),
913 color: None,
914 diameter_mm: None,
915 density_g_cm3: None,
916 initial_g: 1_000.0,
917 remaining_g: None,
918 tare_g: None,
919 reason: "a new spool went on the shelf".to_owned(),
920 actor: Actor::Operator,
921 }
922 }
923
924 fn sample_alternates() -> Vec<Self> {
925 let reason = || "the spool on the shelf changed".to_owned();
926 vec![
927 Self::LoadSpool {
928 spool_id: spool_id(),
929 tool: 0,
930 reason: reason(),
931 actor: Actor::Operator,
932 },
933 Self::UnloadSpool {
934 spool_id: spool_id(),
935 reason: reason(),
936 actor: Actor::Operator,
937 },
938 Self::AdjustSpool {
939 spool_id: spool_id(),
940 remaining_g: Some(700.0),
941 gross_g: None,
942 reason: reason(),
943 actor: Actor::Operator,
944 },
945 Self::AdjustSpool {
946 spool_id: spool_id(),
947 remaining_g: None,
948 gross_g: Some(950.0),
949 reason: reason(),
950 actor: Actor::sample_full(),
951 },
952 Self::RetireSpool {
953 spool_id: spool_id(),
954 reason: reason(),
955 actor: Actor::Operator,
956 },
957 ]
958 }
959}