#![allow(dead_code)]
use super::MachineEnumerable;
use num_enum::{IntoPrimitive, TryFromPrimitive};
macro_rules! hardware_enum {
($comment:literal, $name:ident { $($(# [ doc = $item_comment:literal ])? $x:ident = $v:literal,)* } ) => {
#[doc=$comment]
#[repr(u8)]
#[derive(
Copy,
Clone,
Debug,
PartialEq,
PartialOrd,
Ord,
IntoPrimitive,
TryFromPrimitive,
Eq,
Hash,
)]
pub enum $name { $($(#[doc=$item_comment])? $x = $v),* }
impl $name {
}
impl MachineEnumerable<$name> for $name {
fn all_values() -> &'static[$name] {
&[$(Self::$x),*]
}
fn lookup_by_name_case_insensitive(s: &str) -> Option<$name> {
Self::all().find(|e| format!("{:?}", e).eq_ignore_ascii_case(s))
}
fn lookup_by_name(s: &str) -> Option<$name> {
Self::all().find(|e| format!("{:?}", e) == s)
}
fn to_arg_string(&self) -> String {
match *self {
$(Self::$x => {
stringify!($x).to_ascii_lowercase()
})*
}
}
}
};
}
hardware_enum! {"Ingredients used for brew operations.", EcamIngredients {
Temp = 0, Coffee = 1, Taste = 2, Granulometry = 3, Blend = 4, InfusionSpeed = 5, Preinfusion = 6, Crema = 7, DueXPer = 8, Milk = 9, MilkTemp = 10, MilkFroth = 11, Inversion = 12, TheTemp = 13, TheProfile = 14, HotWater = 15, MixVelocity = 16, MixDuration = 17, DensityMultiBeverage = 18, TempMultiBeverage = 19, DecalcType = 20, TempRisciaquo = 21, WaterRisciaquo = 22, CleanType = 23, Programmable = 24, Visible = 25, VisibleInProgramming = 26, IndexLength = 27, Accessorio = 28, }}
impl EcamIngredients {
pub fn is_wide_encoding(&self) -> Option<bool> {
match self {
EcamIngredients::Temp
| EcamIngredients::Taste
| EcamIngredients::Inversion
| EcamIngredients::DueXPer
| EcamIngredients::IndexLength
| EcamIngredients::Visible
| EcamIngredients::Programmable
| EcamIngredients::Accessorio => Some(false),
EcamIngredients::Coffee | EcamIngredients::Milk | EcamIngredients::HotWater => {
Some(true)
}
_ => None,
}
}
}
hardware_enum! {"Beverage preparation mode.", EcamBeverageTasteType {
Delete = 0,
Save = 1,
Prepare = 2,
PrepareAndSave = 3,
SaveInversion = 5,
PrepareInversion = 6,
PrepareAndSaveInversion = 7,
}}
hardware_enum! {"Operation mode/trigger.", EcamOperationTrigger {
DontCare = 0,
Start = 1,
StartProgramOrStopV2 = 2,
NextStep = 3,
Stop = 4,
StopProgram = 5,
ExitProgramOk = 6,
AdvancedMode = 7,
}}
hardware_enum! {"Identifier determining the type of request and response (also referred to as the 'answer ID').", EcamRequestId {
SetBtMode = 17,
MonitorV0 = 96,
MonitorV1 = 112,
MonitorV2 = 117,
BeverageDispensingMode = 131,
AppControl = 132,
ParameterRead = 149,
ParameterWrite = 144,
ParameterReadExt = 161,
StatisticsRead = 162,
Checksum = 163,
ProfileNameRead = 164,
ProfileNameWrite = 165,
RecipeQuantityRead = 166,
RecipePriorityRead = 168,
ProfileSelection = 169,
RecipeNameRead = 170,
RecipeNameWrite = 171,
SetFavoriteBeverages = 173,
RecipeMinMaxSync = 176,
PinSet = 177,
BeanSystemSelect = 185,
BeanSystemRead = 186,
BeanSystemWrite = 187,
PinRead = 210,
SetTime = 226,
}}
hardware_enum! {"The temperature of the dispensed beverage.", EcamTemperature {
Low = 0,
Mid = 1,
High = 2,
VeryHigh = 3,
}}
hardware_enum! {"The strength of the dispensed beverage.", EcamBeverageTaste {
Preground = 0,
ExtraMild = 1,
Mild = 2,
Normal = 3,
Strong = 4,
ExtraStrong = 5,
}}
hardware_enum! {"The current state of the machine.", EcamMachineState {
StandBy = 0,
TurningOn = 1,
ShuttingDown = 2,
Descaling = 4,
SteamPreparation = 5,
Recovery = 6,
ReadyOrDispensing = 7,
Rinsing = 8,
MilkPreparation = 10,
HotWaterDelivery = 11,
MilkCleaning = 12,
ChocolatePreparation = 16,
}}
hardware_enum! {"The accessory that is connected to the accessory port.", EcamAccessory {
None = 0,
Water = 1,
Milk = 2,
Chocolate = 3,
MilkClean = 4,
}}
hardware_enum! {"The type of beverage to prepare.", EcamBeverageId {
EspressoCoffee = 1,
RegularCoffee = 2,
LongCoffee = 3,
EspressoCoffee2X = 4,
DoppioPlus = 5,
Americano = 6,
Cappuccino = 7,
LatteMacchiato = 8,
CaffeLatte = 9,
FlatWhite = 10,
EspressoMacchiato = 11,
HotMilk = 12,
CappuccinoDoppioPlus = 13,
ColdMilk = 14,
CappuccinoReverse = 15,
HotWater = 16,
Steam = 17,
Ciocco = 18,
Ristretto = 19,
LongEspresso = 20,
CoffeeCream = 21,
Tea = 22,
CoffeePot = 23,
Cortado = 24,
LongBlack = 25,
TravelMug = 26,
BrewOverIce = 27,
Custom01 = 230,
Custom02 = 231,
Custom03 = 232,
Custom04 = 233,
Custom05 = 234,
Custom06 = 235,
Custom07 = 236,
Custom08 = 237,
Custom09 = 238,
Custom10 = 239,
}}
hardware_enum! {"The set of alarms the machine can produce.", EcamMachineAlarm {
EmptyWaterTank = 0,
CoffeeWasteContainerFull = 1,
DescaleAlarm = 2,
ReplaceWaterFilter = 3,
CoffeeGroundTooFine = 4,
CoffeeBeansEmpty = 5,
MachineToService = 6,
CoffeeHeaterProbeFailure = 7,
TooMuchCoffee = 8,
CoffeeInfuserMotorNotWorking = 9,
EmptyDripTray = 11,
SteamerProbeFailure = 10,
TankIsInPosition = 13,
HydraulicCircuitProblem = 12,
CoffeeBeansEmptyTwo = 15,
CleanKnob = 14,
BeanHopperAbsent = 17,
TankTooFull = 16,
InfuserSense = 19,
GridPresence = 18,
ExpansionCommProb = 21,
NotEnoughCoffee = 20,
GrindingUnit1Problem = 23,
ExpansionSubmodulesProb = 22,
CondenseFanProblem = 25,
GrindingUnit2Problem = 24,
SpiCommProblem = 27,
ClockBtCommProblem = 26,
}}
hardware_enum! {"The various switches that the machine reads.", EcamMachineSwitch {
WaterSpout = 0,
MotorUp = 1,
MotorDown = 2,
CoffeeWasteContainer = 3,
WaterTankAbsent = 4,
Knob = 5,
WaterLevelLow = 6,
CoffeeJug = 7,
IfdCaraffe = 8,
CioccoTank = 9,
CleanKnob = 10,
DoorOpened = 13,
PregroundDoorOpened = 14,
}}