elevator_core/components/service_mode.rs
1//! Service mode component for elevator operational modes.
2
3use serde::{Deserialize, Serialize};
4
5/// Operational service mode for an elevator, orthogonal to [`ElevatorPhase`](super::ElevatorPhase).
6///
7/// Normal is the default. Modes modify how simulation phases behave without
8/// replacing `ElevatorPhase` — an elevator in `Independent` mode can still
9/// be `Idle` or `MovingToStop`.
10#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
11#[non_exhaustive]
12pub enum ServiceMode {
13 /// Normal operation: dispatch assigns stops, doors auto-cycle.
14 #[default]
15 Normal,
16 /// Independent mode: elevator is excluded from dispatch and repositioning.
17 /// Consumer controls movement via direct API calls.
18 Independent,
19 /// Inspection mode: reduced speed, doors hold open indefinitely.
20 /// Speed is reduced by [`Elevator::inspection_speed_factor`](super::Elevator::inspection_speed_factor).
21 Inspection,
22}
23
24impl std::fmt::Display for ServiceMode {
25 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
26 match self {
27 Self::Normal => write!(f, "Normal"),
28 Self::Independent => write!(f, "Independent"),
29 Self::Inspection => write!(f, "Inspection"),
30 }
31 }
32}