invariant-robotics-core 0.0.2

Core types, physics checks, authority validation, and cryptography for Invariant.
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
// CNC tending cycle state machine (Step 67).
//
// Models the complete load/unload cycle from CNC cell specification Section 5.
// The coordinator manages:
// - Cycle state transitions (IDLE → PICK_APPROACH → ... → CYCLE_COMPLETE)
// - Conditional zone overrides (haas_spindle_zone active/inactive per phase)
// - I/O signal tracking (HAAS_READY, HAAS_CYCLE_COMPLETE, VISE_CLAMP, etc.)
// - Gripper state
//
// This is a pure state machine — no I/O, no hardware access. The caller
// (CLI `tend` command, Isaac Lab bridge, or real edge PC controller) maps
// external signals to `HaasSignal` and calls `advance()`.

use std::collections::HashMap;

use serde::{Deserialize, Serialize};

// ---------------------------------------------------------------------------
// Cycle states
// ---------------------------------------------------------------------------

/// States of the CNC tending cycle from Section 5.1.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum CycleState {
    /// Robot at home position, waiting for start signal.
    Idle,
    /// Moving to above raw stock pallet (W0→W1).
    PickApproach,
    /// Lowering into pallet to grip billet (W1→W2).
    PickBillet,
    /// Lifting billet clear of pallet (W2→W3).
    PickLift,
    /// Checking if Haas is ready (idle + door open).
    CheckHaasReady,
    /// Waiting for Haas to finish current cycle.
    WaitHaasReady,
    /// Moving to in front of Haas door opening (W3→W4).
    DoorApproach,
    /// Moving to above vise inside enclosure (W4→W5).
    ViseApproach,
    /// Lowering billet into vise jaws (W5→W6).
    VisePlace,
    /// Commanding vise to clamp.
    ViseClamp,
    /// Retracting from enclosure after loading (W6→W7).
    ViseRetreat,
    /// Signaling Haas to start machining cycle.
    SignalHaasStart,
    /// Waiting for machining to complete (~40 min per workpiece).
    WaitMachining,
    /// Commanding vise to unclamp after machining.
    ViseUnclamp,
    /// Gripping finished part from vise (W8).
    PickFinished,
    /// Moving to above finished parts pallet (W7→W9).
    FinishedApproach,
    /// Placing finished part on pallet (W9→W10).
    PlaceDone,
    /// Checking if raw stock remains.
    CheckStock,
    /// All stock processed; cycle complete.
    CycleComplete,
}

// ---------------------------------------------------------------------------
// I/O signals
// ---------------------------------------------------------------------------

/// External signals that can cause state transitions.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum HaasSignal {
    /// Haas is idle, door open, safe to enter.
    HaasReady,
    /// Haas is still busy (cutting).
    HaasBusy,
    /// Machining complete, door opening.
    HaasCycleComplete,
}

/// Commands to actuators.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum ActuatorCommand {
    GripperClose,
    GripperOpen,
    ViseClamp,
    ViseUnclamp,
    HaasCycleStart,
}

// ---------------------------------------------------------------------------
// Transition result
// ---------------------------------------------------------------------------

/// The result of a state transition.
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct TransitionResult {
    /// Previous state.
    pub from: CycleState,
    /// New state.
    pub to: CycleState,
    /// Actuator commands to issue (may be empty).
    pub commands: Vec<ActuatorCommand>,
    /// Whether the spindle exclusion zone state changed.
    pub zone_changed: bool,
}

// ---------------------------------------------------------------------------
// Cycle coordinator
// ---------------------------------------------------------------------------

/// The name of the conditional exclusion zone managed by this coordinator.
const SPINDLE_ZONE_NAME: &str = "haas_spindle_zone";

/// CNC tending cycle coordinator.
///
/// Pure state machine. Call `advance()` to move to the next state. The
/// coordinator determines whether the spindle exclusion zone should be
/// active or inactive at each point in the cycle.
#[derive(Debug, Clone)]
pub struct CycleCoordinator {
    state: CycleState,
    /// Whether the spindle exclusion zone is currently active.
    spindle_zone_active: bool,
    /// Number of billets remaining in the stock pallet.
    billets_remaining: u32,
    /// Total parts machined in this session.
    parts_completed: u32,
}

impl CycleCoordinator {
    /// Create a new coordinator with the robot in IDLE state.
    ///
    /// `billets` is the number of raw billets loaded on the stock pallet.
    /// The spindle exclusion zone starts ACTIVE (safe default).
    pub fn new(billets: u32) -> Self {
        Self {
            state: CycleState::Idle,
            spindle_zone_active: true,
            billets_remaining: billets,
            parts_completed: 0,
        }
    }

    /// Current cycle state.
    pub fn state(&self) -> CycleState {
        self.state
    }

    /// Whether the spindle exclusion zone is currently active.
    pub fn spindle_zone_active(&self) -> bool {
        self.spindle_zone_active
    }

    /// Number of billets remaining.
    pub fn billets_remaining(&self) -> u32 {
        self.billets_remaining
    }

    /// Total parts completed.
    pub fn parts_completed(&self) -> u32 {
        self.parts_completed
    }

    /// Generate the `zone_overrides` map for the current cycle state.
    ///
    /// This is the map that should be set on `Command.zone_overrides` for
    /// every command issued in the current state. The edge PC controller
    /// calls this before constructing each command.
    pub fn zone_overrides(&self) -> HashMap<String, bool> {
        let mut overrides = HashMap::new();
        overrides.insert(SPINDLE_ZONE_NAME.to_string(), self.spindle_zone_active);
        overrides
    }

    /// Advance to the next state.
    ///
    /// `haas_signal` is required for states that wait on Haas I/O
    /// (`CheckHaasReady`, `WaitHaasReady`, `WaitMachining`). For all other
    /// states, pass `None`.
    ///
    /// Returns `Ok(TransitionResult)` on success, or `Err(message)` if
    /// the transition is invalid (wrong signal, already complete, etc.).
    pub fn advance(&mut self, haas_signal: Option<HaasSignal>) -> Result<TransitionResult, String> {
        let from = self.state;

        let (next, commands, zone_changed) = match self.state {
            CycleState::Idle => {
                if self.billets_remaining == 0 {
                    return Err("no billets remaining; cannot start cycle".into());
                }
                (CycleState::PickApproach, vec![], false)
            }

            CycleState::PickApproach => (CycleState::PickBillet, vec![], false),

            CycleState::PickBillet => {
                self.billets_remaining = self.billets_remaining.saturating_sub(1);
                (
                    CycleState::PickLift,
                    vec![ActuatorCommand::GripperClose],
                    false,
                )
            }

            CycleState::PickLift => (CycleState::CheckHaasReady, vec![], false),

            CycleState::CheckHaasReady => match haas_signal {
                Some(HaasSignal::HaasReady) => (CycleState::DoorApproach, vec![], false),
                Some(HaasSignal::HaasBusy) => (CycleState::WaitHaasReady, vec![], false),
                _ => return Err("CheckHaasReady requires HaasReady or HaasBusy signal".into()),
            },

            CycleState::WaitHaasReady => match haas_signal {
                Some(HaasSignal::HaasReady) => (CycleState::DoorApproach, vec![], false),
                Some(HaasSignal::HaasBusy) => (CycleState::WaitHaasReady, vec![], false),
                _ => return Err("WaitHaasReady requires HaasReady or HaasBusy signal".into()),
            },

            CycleState::DoorApproach => {
                // Disable spindle exclusion zone so robot can enter enclosure.
                self.spindle_zone_active = false;
                (CycleState::ViseApproach, vec![], true)
            }

            CycleState::ViseApproach => (CycleState::VisePlace, vec![], false),

            CycleState::VisePlace => (
                CycleState::ViseClamp,
                vec![ActuatorCommand::GripperOpen, ActuatorCommand::ViseClamp],
                false,
            ),

            CycleState::ViseClamp => (CycleState::ViseRetreat, vec![], false),

            CycleState::ViseRetreat => {
                // Re-enable spindle exclusion zone after exiting enclosure.
                self.spindle_zone_active = true;
                (CycleState::SignalHaasStart, vec![], true)
            }

            CycleState::SignalHaasStart => (
                CycleState::WaitMachining,
                vec![ActuatorCommand::HaasCycleStart],
                false,
            ),

            CycleState::WaitMachining => match haas_signal {
                Some(HaasSignal::HaasCycleComplete) => {
                    // Disable spindle exclusion zone for unloading.
                    self.spindle_zone_active = false;
                    (CycleState::ViseUnclamp, vec![], true)
                }
                Some(HaasSignal::HaasBusy) => (CycleState::WaitMachining, vec![], false),
                _ => {
                    return Err(
                        "WaitMachining requires HaasCycleComplete or HaasBusy signal".into(),
                    )
                }
            },

            CycleState::ViseUnclamp => (
                CycleState::PickFinished,
                vec![ActuatorCommand::ViseUnclamp, ActuatorCommand::GripperClose],
                false,
            ),

            CycleState::PickFinished => {
                // Re-enable spindle exclusion zone after picking finished part.
                self.spindle_zone_active = true;
                (CycleState::FinishedApproach, vec![], true)
            }

            CycleState::FinishedApproach => (CycleState::PlaceDone, vec![], false),

            CycleState::PlaceDone => {
                self.parts_completed += 1;
                (
                    CycleState::CheckStock,
                    vec![ActuatorCommand::GripperOpen],
                    false,
                )
            }

            CycleState::CheckStock => {
                if self.billets_remaining > 0 {
                    (CycleState::PickApproach, vec![], false)
                } else {
                    (CycleState::CycleComplete, vec![], false)
                }
            }

            CycleState::CycleComplete => {
                return Err("cycle already complete; reset to start a new cycle".into());
            }
        };

        self.state = next;

        Ok(TransitionResult {
            from,
            to: next,
            commands,
            zone_changed,
        })
    }

    /// Reset the coordinator for a new cycle.
    ///
    /// Can only be called from `CycleComplete` or `Idle`. Sets state back to
    /// `Idle` with the spindle exclusion zone active.
    pub fn reset(&mut self, billets: u32) -> Result<(), String> {
        match self.state {
            CycleState::CycleComplete | CycleState::Idle => {
                self.state = CycleState::Idle;
                self.spindle_zone_active = true;
                self.billets_remaining = billets;
                Ok(())
            }
            _ => Err(format!(
                "cannot reset from state {:?}; must be Idle or CycleComplete",
                self.state
            )),
        }
    }
}

// ---------------------------------------------------------------------------
// Tests
// ---------------------------------------------------------------------------

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn new_coordinator_starts_idle_with_active_spindle_zone() {
        let coord = CycleCoordinator::new(10);
        assert_eq!(coord.state(), CycleState::Idle);
        assert!(coord.spindle_zone_active());
        assert_eq!(coord.billets_remaining(), 10);
        assert_eq!(coord.parts_completed(), 0);
    }

    #[test]
    fn zone_overrides_reflect_spindle_state() {
        let coord = CycleCoordinator::new(1);
        let overrides = coord.zone_overrides();
        assert_eq!(overrides.get(SPINDLE_ZONE_NAME), Some(&true));
    }

    #[test]
    fn full_single_billet_cycle() {
        let mut coord = CycleCoordinator::new(1);

        // IDLE → PICK_APPROACH
        let r = coord.advance(None).unwrap();
        assert_eq!(r.from, CycleState::Idle);
        assert_eq!(r.to, CycleState::PickApproach);
        assert!(!r.zone_changed);

        // PICK_APPROACH → PICK_BILLET
        coord.advance(None).unwrap();
        assert_eq!(coord.state(), CycleState::PickBillet);

        // PICK_BILLET → PICK_LIFT (gripper closes, billet count decremented)
        let r = coord.advance(None).unwrap();
        assert_eq!(r.to, CycleState::PickLift);
        assert!(r.commands.contains(&ActuatorCommand::GripperClose));
        assert_eq!(coord.billets_remaining(), 0);

        // PICK_LIFT → CHECK_HAAS_READY
        coord.advance(None).unwrap();
        assert_eq!(coord.state(), CycleState::CheckHaasReady);

        // CHECK_HAAS_READY + HaasReady → DOOR_APPROACH
        coord.advance(Some(HaasSignal::HaasReady)).unwrap();
        assert_eq!(coord.state(), CycleState::DoorApproach);

        // DOOR_APPROACH → VISE_APPROACH (spindle zone disabled)
        let r = coord.advance(None).unwrap();
        assert_eq!(r.to, CycleState::ViseApproach);
        assert!(r.zone_changed);
        assert!(!coord.spindle_zone_active());

        // VISE_APPROACH → VISE_PLACE
        coord.advance(None).unwrap();

        // VISE_PLACE → VISE_CLAMP (gripper opens, vise clamps)
        let r = coord.advance(None).unwrap();
        assert_eq!(r.to, CycleState::ViseClamp);
        assert!(r.commands.contains(&ActuatorCommand::GripperOpen));
        assert!(r.commands.contains(&ActuatorCommand::ViseClamp));

        // VISE_CLAMP → VISE_RETREAT
        coord.advance(None).unwrap();

        // VISE_RETREAT → SIGNAL_HAAS_START (spindle zone re-enabled)
        let r = coord.advance(None).unwrap();
        assert_eq!(r.to, CycleState::SignalHaasStart);
        assert!(r.zone_changed);
        assert!(coord.spindle_zone_active());

        // SIGNAL_HAAS_START → WAIT_MACHINING (sends HaasCycleStart)
        let r = coord.advance(None).unwrap();
        assert_eq!(r.to, CycleState::WaitMachining);
        assert!(r.commands.contains(&ActuatorCommand::HaasCycleStart));

        // WAIT_MACHINING + HaasCycleComplete → VISE_UNCLAMP (spindle zone disabled)
        let r = coord.advance(Some(HaasSignal::HaasCycleComplete)).unwrap();
        assert_eq!(r.to, CycleState::ViseUnclamp);
        assert!(r.zone_changed);
        assert!(!coord.spindle_zone_active());

        // VISE_UNCLAMP → PICK_FINISHED
        let r = coord.advance(None).unwrap();
        assert_eq!(r.to, CycleState::PickFinished);
        assert!(r.commands.contains(&ActuatorCommand::ViseUnclamp));
        assert!(r.commands.contains(&ActuatorCommand::GripperClose));

        // PICK_FINISHED → FINISHED_APPROACH (spindle zone re-enabled)
        let r = coord.advance(None).unwrap();
        assert_eq!(r.to, CycleState::FinishedApproach);
        assert!(r.zone_changed);
        assert!(coord.spindle_zone_active());

        // FINISHED_APPROACH → PLACE_DONE
        coord.advance(None).unwrap();

        // PLACE_DONE → CHECK_STOCK (parts completed incremented)
        let r = coord.advance(None).unwrap();
        assert_eq!(r.to, CycleState::CheckStock);
        assert!(r.commands.contains(&ActuatorCommand::GripperOpen));
        assert_eq!(coord.parts_completed(), 1);

        // CHECK_STOCK → CYCLE_COMPLETE (no billets left)
        coord.advance(None).unwrap();
        assert_eq!(coord.state(), CycleState::CycleComplete);
    }

    #[test]
    fn haas_busy_causes_wait() {
        let mut coord = CycleCoordinator::new(1);
        // Advance to CHECK_HAAS_READY.
        coord.advance(None).unwrap(); // → PickApproach
        coord.advance(None).unwrap(); // → PickBillet
        coord.advance(None).unwrap(); // → PickLift
        coord.advance(None).unwrap(); // → CheckHaasReady

        // Haas busy → WAIT.
        coord.advance(Some(HaasSignal::HaasBusy)).unwrap();
        assert_eq!(coord.state(), CycleState::WaitHaasReady);

        // Still busy → stay in WAIT.
        coord.advance(Some(HaasSignal::HaasBusy)).unwrap();
        assert_eq!(coord.state(), CycleState::WaitHaasReady);

        // Ready → DOOR_APPROACH.
        coord.advance(Some(HaasSignal::HaasReady)).unwrap();
        assert_eq!(coord.state(), CycleState::DoorApproach);
    }

    #[test]
    fn wait_machining_stays_while_busy() {
        let mut coord = CycleCoordinator::new(1);
        // Fast-forward to WAIT_MACHINING.
        coord.advance(None).unwrap(); // → PickApproach
        coord.advance(None).unwrap(); // → PickBillet
        coord.advance(None).unwrap(); // → PickLift
        coord.advance(None).unwrap(); // → CheckHaasReady
        coord.advance(Some(HaasSignal::HaasReady)).unwrap(); // → DoorApproach
        coord.advance(None).unwrap(); // → ViseApproach
        coord.advance(None).unwrap(); // → VisePlace
        coord.advance(None).unwrap(); // → ViseClamp
        coord.advance(None).unwrap(); // → ViseRetreat
        coord.advance(None).unwrap(); // → SignalHaasStart
        coord.advance(None).unwrap(); // → WaitMachining

        // Busy → stay in WAIT_MACHINING.
        coord.advance(Some(HaasSignal::HaasBusy)).unwrap();
        assert_eq!(coord.state(), CycleState::WaitMachining);
        assert!(coord.spindle_zone_active()); // still active during machining
    }

    #[test]
    fn multi_billet_cycle_loops() {
        let mut coord = CycleCoordinator::new(2);

        // Complete first billet (fast-forward through all states).
        for signal in full_cycle_signals() {
            coord.advance(signal).unwrap();
        }
        assert_eq!(coord.state(), CycleState::CheckStock);
        assert_eq!(coord.billets_remaining(), 1);
        assert_eq!(coord.parts_completed(), 1);

        // CHECK_STOCK → PICK_APPROACH (more stock).
        coord.advance(None).unwrap();
        assert_eq!(coord.state(), CycleState::PickApproach);
    }

    #[test]
    fn cannot_start_with_zero_billets() {
        let mut coord = CycleCoordinator::new(0);
        let result = coord.advance(None);
        assert!(result.is_err());
        assert!(result.unwrap_err().contains("no billets"));
    }

    #[test]
    fn cannot_advance_past_cycle_complete() {
        let mut coord = CycleCoordinator::new(1);
        // Complete the full cycle.
        for signal in full_cycle_signals() {
            coord.advance(signal).unwrap();
        }
        coord.advance(None).unwrap(); // CHECK_STOCK → CYCLE_COMPLETE

        let result = coord.advance(None);
        assert!(result.is_err());
        assert!(result.unwrap_err().contains("already complete"));
    }

    #[test]
    fn reset_from_cycle_complete() {
        let mut coord = CycleCoordinator::new(1);
        for signal in full_cycle_signals() {
            coord.advance(signal).unwrap();
        }
        coord.advance(None).unwrap(); // → CYCLE_COMPLETE

        coord.reset(5).unwrap();
        assert_eq!(coord.state(), CycleState::Idle);
        assert!(coord.spindle_zone_active());
        assert_eq!(coord.billets_remaining(), 5);
    }

    #[test]
    fn cannot_reset_mid_cycle() {
        let mut coord = CycleCoordinator::new(1);
        coord.advance(None).unwrap(); // → PickApproach
        let result = coord.reset(5);
        assert!(result.is_err());
    }

    #[test]
    fn spindle_zone_disabled_during_load_and_unload() {
        let mut coord = CycleCoordinator::new(1);

        // Advance to DOOR_APPROACH.
        coord.advance(None).unwrap(); // → PickApproach
        coord.advance(None).unwrap(); // → PickBillet
        coord.advance(None).unwrap(); // → PickLift
        coord.advance(None).unwrap(); // → CheckHaasReady
        coord.advance(Some(HaasSignal::HaasReady)).unwrap(); // → DoorApproach
        assert!(coord.spindle_zone_active()); // still active before entry

        // DOOR_APPROACH → ViseApproach: zone disabled.
        coord.advance(None).unwrap();
        assert!(!coord.spindle_zone_active());
        let overrides = coord.zone_overrides();
        assert_eq!(overrides.get(SPINDLE_ZONE_NAME), Some(&false));

        // Continue through loading...
        coord.advance(None).unwrap(); // → VisePlace
        coord.advance(None).unwrap(); // → ViseClamp
        coord.advance(None).unwrap(); // → ViseRetreat
        assert!(!coord.spindle_zone_active()); // still disabled during retreat

        // VISE_RETREAT → SignalHaasStart: zone re-enabled.
        coord.advance(None).unwrap();
        assert!(coord.spindle_zone_active());
    }

    #[test]
    fn check_haas_ready_requires_signal() {
        let mut coord = CycleCoordinator::new(1);
        coord.advance(None).unwrap(); // → PickApproach
        coord.advance(None).unwrap(); // → PickBillet
        coord.advance(None).unwrap(); // → PickLift
        coord.advance(None).unwrap(); // → CheckHaasReady

        let result = coord.advance(None);
        assert!(result.is_err());
        assert!(result.unwrap_err().contains("requires"));
    }

    #[test]
    fn serde_round_trip_cycle_state() {
        let state = CycleState::WaitMachining;
        let json = serde_json::to_string(&state).unwrap();
        let back: CycleState = serde_json::from_str(&json).unwrap();
        assert_eq!(state, back);
    }

    /// Helper: signals needed to advance one full billet from IDLE to CHECK_STOCK.
    fn full_cycle_signals() -> Vec<Option<HaasSignal>> {
        vec![
            None,                                // IDLE → PickApproach
            None,                                // → PickBillet
            None,                                // → PickLift
            None,                                // → CheckHaasReady
            Some(HaasSignal::HaasReady),         // → DoorApproach
            None,                                // → ViseApproach
            None,                                // → VisePlace
            None,                                // → ViseClamp
            None,                                // → ViseRetreat
            None,                                // → SignalHaasStart
            None,                                // → WaitMachining
            Some(HaasSignal::HaasCycleComplete), // → ViseUnclamp
            None,                                // → PickFinished
            None,                                // → FinishedApproach
            None,                                // → PlaceDone
            None,                                // → CheckStock
        ]
    }
}