// Independent worked listings. Load this chapter with vocabulary.sysml, not with other chapters. package Lch12_01 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-1 package CoffeeMachineVariants { private import CoffeeMachineDomain::*; part def EspressoMachine :> CoffeeMachine { attribute pumpPressure : Real; } } // ANCHOR_END: listing-1 } package Lch12_02 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-2 part def HeatedGrinder :> Grinder, HeatedComponent { attribute grindTemp : Real; } // ANCHOR_END: listing-2 } package Lch12_03 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-3 part def CoffeeMachine { attribute targetTemp : Real; } // ANCHOR_END: listing-3 } package Lch12_04 { private import CoffeeVocabulary::*; // ANCHOR: listing-4 part def EspressoMachine :> CoffeeMachine { attribute brewTemp :>> targetTemp = 94.0; } // ANCHOR_END: listing-4 } package Lch12_05 { private import CoffeeVocabulary::*; // ANCHOR: listing-5 part def CoffeeMachine { part brewer : Brewer; } part def EspressoMachine :> CoffeeMachine { part espressoBrewer :>> brewer : PressurizedBrewer; } // ANCHOR_END: listing-5 } package Lch12_06 { private import CoffeeVocabulary::*; // ANCHOR: listing-6 part def CoffeeMachine { part sensors : Sensor[1..*]; } part def EspressoMachine :> CoffeeMachine { part tempSensors :> sensors : TemperatureSensor[1..2]; part pressureSensors :> sensors : PressureSensor[1]; } // ANCHOR_END: listing-6 } package Lch12_07 { private import CoffeeVocabulary::*; // ANCHOR: listing-7 port def WaterSupplyPort { out item water : Water; } // ANCHOR_END: listing-7 } package Lch12_08 { private import CoffeeVocabulary::*; // ANCHOR: listing-8 part def WaterTank { port waterOut : WaterSupplyPort; } part def Brewer { port waterInlet : ~WaterSupplyPort; } // ANCHOR_END: listing-8 } package Lch12_09 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-9 package CoffeeMachineVariants { private import ScalarValues::*; private import CoffeeMachineDomain::*; part def PressurizedBrewer :> Brewer { attribute boilerPressure : Real; } part def EspressoMachine :> CoffeeMachine { // Redefine the brewer to a pressurized variant, and pin the // water temperature it inherits from Brewer part espressoBrewer :>> brewer : PressurizedBrewer { attribute :>> waterTemp = 94.0; } // Add espresso-specific features attribute shotVolume : Real; } } // ANCHOR_END: listing-9 } package Lch12_10 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-10 part def BrewProfile { attribute targetTemp : Real; } part def StandardBrew :> BrewProfile; part def IntenseBrew :> BrewProfile; variation part def BrewProfileChoice :> BrewProfile { variant part standardProfile : StandardBrew; variant part intense : IntenseBrew; } part def CoffeeMachine { part brewProfile : BrewProfileChoice; } // ANCHOR_END: listing-10 } package Lch12_11 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-11 part def Grinder { attribute rpm : Real; } // ANCHOR_END: listing-11 } package Lch12_12 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-12 part def HeatedGrinder :> Grinder { attribute heatLevel : Real; } // ANCHOR_END: listing-12 } package Lch12_13 { private import CoffeeVocabulary::*; // ANCHOR: listing-13 // Unnecessary specialization: part def LargeCoffeeMachine :> CoffeeMachine { part bigTank :>> waterTank : LargeWaterTank; } // Often sufficient: just a configured usage part largeMachine : CoffeeMachine { part bigTank :>> waterTank : LargeWaterTank; } // ANCHOR_END: listing-13 }