// Independent worked listings. Load this chapter with vocabulary.sysml, not with other chapters. package Lch05_01 { private import CoffeeVocabulary::*; private import ScalarValues::String; // ANCHOR: listing-1 part def CoffeeMachine { part grinder : Grinder; part brewer : Brewer; part waterTank : WaterTank; attribute serialNumber : String; } // ANCHOR_END: listing-1 } package Lch05_02 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-2 part def Brewer { attribute waterTemp : Real; attribute brewPressure : Real; port waterInlet; } // ANCHOR_END: listing-2 } package Lch05_03 { private import CoffeeVocabulary::*; // ANCHOR: listing-3 port def WaterPort { in item water : Water; } // ANCHOR_END: listing-3 } package Lch05_04 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-4 part def Brewer { attribute waterTemp : Real; attribute brewPressure : Real; port waterInlet : WaterPort; } // ANCHOR_END: listing-4 } package Lch05_05 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-5 port def WaterPort { in item water : Water; } port def GroundCoffeePort { out item grounds : CoffeeBeans; } port def StatusPort { inout attribute level : Real; } // ANCHOR_END: listing-5 } package Lch05_06 { private import CoffeeVocabulary::*; // ANCHOR: listing-6 port def BrewInputPort { in item water : Water; in item grounds : CoffeeBeans; } // ANCHOR_END: listing-6 } package Lch05_07 { private import CoffeeVocabulary::*; // ANCHOR: listing-7 port def BeanInputPort { in item beans : CoffeeBeans; } port def GroundCoffeePort { out item grounds : CoffeeBeans; } // ANCHOR_END: listing-7 } package Lch05_08 { private import CoffeeVocabulary::*; // ANCHOR: listing-8 port def WaterPort { in item water : Water; } port def BrewOutputPort { out item coffee : BrewedCoffee; } // ANCHOR_END: listing-8 } package Lch05_09 { private import CoffeeVocabulary::*; // ANCHOR: listing-9 port def WaterSupplyPort { out item water : Water; } // ANCHOR_END: listing-9 } package Lch05_10 { private import CoffeeVocabulary::*; private import ScalarValues::Real; private import ScalarValues::String; // ANCHOR: listing-10 package CoffeeMachineDomain { private import ScalarValues::*; // Items item def Water; item def CoffeeBeans; item def BrewedCoffee; // Enumerations enum def GrindSetting { fine; medium; coarse; } // Port definitions port def BeanInputPort { in item beans : CoffeeBeans; } port def GroundCoffeePort { out item grounds : CoffeeBeans; } port def WaterPort { in item water : Water; } port def WaterSupplyPort { out item water : Water; } port def BrewOutputPort { out item coffee : BrewedCoffee; } // Parts with ports part def Grinder { attribute grindSize : GrindSetting; port beanInput : BeanInputPort; port groundOutput : GroundCoffeePort; } part def Brewer { attribute waterTemp : Real; attribute brewPressure : Real; port waterInlet : WaterPort; port groundInput : BeanInputPort; port brewOutput : BrewOutputPort; } part def WaterTank { attribute currentLevel : Real; attribute maxCapacity : Real; port waterOut : WaterSupplyPort; } part def CoffeeMachine { part grinder : Grinder; part brewer : Brewer; part waterTank : WaterTank; attribute serialNumber : String; } } // ANCHOR_END: listing-10 } package Lch05_11 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-11 attribute def BrewRatio { attribute ratio : Real; } enum def BrewStrength :> BrewRatio { enum light { :>> ratio = 15.0; } enum medium { :>> ratio = 12.0; } enum strong { :>> ratio = 10.0; } } // ANCHOR_END: listing-11 } package Lch05_12 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-12 part def Brewer { attribute waterTemp : Real; attribute brewPressure : Real; part heatingElement : HeatingElement [2]; port waterInlet : WaterPort; port groundInput : BeanInputPort; port brewOutput : BrewOutputPort; } // ANCHOR_END: listing-12 } package Lch05_13 { private import CoffeeVocabulary::*; // ANCHOR: listing-13 part def CoffeeMachine { part grinder : Grinder [1]; part brewer : Brewer [1]; part waterTank : WaterTank [1]; } // ANCHOR_END: listing-13 } package Lch05_14 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-14 part def SensorArray { attribute readings : Real [0..*]; port outlets : PowerOutlet [6]; } // ANCHOR_END: listing-14 } package Lch05_15 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-15 attribute def TemperatureRange { attribute min : Real; attribute max : Real; } // ANCHOR_END: listing-15 } package Lch05_16 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-16 part def WaterTank { attribute currentLevel : Real := 0.0; attribute maxCapacity : Real default = 1500.0; attribute nominalPressure : Real = 1.0; port waterOut : WaterSupplyPort; } // ANCHOR_END: listing-16 } package Lch05_17 { private import CoffeeVocabulary::*; private import ScalarValues::Real; private import ScalarValues::String; // ANCHOR: listing-17 package CoffeeMachineDomain { private import ScalarValues::*; // Items: things that flow through the system item def Water; item def CoffeeBeans; item def BrewedCoffee; // Enumerations enum def GrindSetting { fine; medium; coarse; } // Port definitions: typed interaction boundaries port def BeanInputPort { in item beans : CoffeeBeans; } port def GroundCoffeePort { out item grounds : CoffeeBeans; } port def WaterPort { in item water : Water; } port def WaterSupplyPort { out item water : Water; } port def BrewOutputPort { out item coffee : BrewedCoffee; } // Structural definitions with ports part def Grinder { attribute grindSize : GrindSetting; port beanInput : BeanInputPort; port groundOutput : GroundCoffeePort; } part def Brewer { attribute waterTemp : Real; attribute brewPressure : Real; port waterInlet : WaterPort; port groundInput : BeanInputPort; port brewOutput : BrewOutputPort; } part def WaterTank { attribute currentLevel : Real := 0.0; attribute maxCapacity : Real default = 1500.0; port waterOut : WaterSupplyPort; } part def CoffeeMachine { part grinder : Grinder [1]; part brewer : Brewer [1]; part waterTank : WaterTank [1]; attribute serialNumber : String; } } // ANCHOR_END: listing-17 } package Lch05_18 { private import CoffeeVocabulary::*; // ANCHOR: listing-18 port def WaterPort { ref item water : Water; } // ANCHOR_END: listing-18 }