// Independent worked listings. Load this chapter with vocabulary.sysml, not with other chapters. package Lch10_01 { private import CoffeeVocabulary::*; // ANCHOR: listing-1 package CoffeeMachineRequirements { requirement def <'REQ-TEMP-001'> BrewTempReq { doc /* The brewer extraction temperature shall remain between 90 and 96 degrees Celsius during brewing. */ } } // ANCHOR_END: listing-1 } package Lch10_02 { private import CoffeeVocabulary::*; // ANCHOR: listing-2 package CoffeeMachineRequirements { requirement def <'REQ-TEMP-001'> BrewTempReq { doc /* The brewer extraction temperature shall remain between 90 and 96 degrees Celsius during brewing. */ } requirement def <'REQ-SAFE-001'> SafetyInterlockReq { doc /* The system shall not initiate a brew cycle unless a cup is detected on the drip tray. */ } } // ANCHOR_END: listing-2 } package Lch10_03 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-3 requirement def <'REQ-TEMP-001'> BrewTempReq { doc /* The brewer extraction temperature shall remain between 90 and 96 degrees Celsius during brewing. */ attribute temp : Real; require constraint { temp >= 90.0 and temp <= 96.0 } } // ANCHOR_END: listing-3 } package Lch10_04 { private import CoffeeVocabulary::*; // ANCHOR: listing-4 requirement def <'REQ-TEMP-001'> BrewTempReq { doc /* The brewer extraction temperature shall remain between 90 and 96 degrees Celsius during brewing. */ subject brewer : Brewer; } // ANCHOR_END: listing-4 } package Lch10_05 { private import CoffeeVocabulary::*; // ANCHOR: listing-5 requirement def <'REQ-SAFE-001'> SafetyInterlockReq { doc /* The system shall not initiate a brew cycle unless a cup is detected on the drip tray. */ subject machine : CoffeeMachine; actor user : Operator; } // ANCHOR_END: listing-5 } package Lch10_06 { private import CoffeeVocabulary::*; // ANCHOR: listing-6 part def CoffeeMachine { part brewer : Brewer; satisfy requirement : BrewTempReq; } // ANCHOR_END: listing-6 } package Lch10_07 { private import CoffeeVocabulary::*; // ANCHOR: listing-7 part def CoffeeMachine { part brewer : Brewer; part grinder : Grinder; part waterTank : WaterTank; satisfy requirement : BrewTempReq; satisfy requirement : SafetyInterlockReq; } // ANCHOR_END: listing-7 } package Lch10_08 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-8 part def Brewer { attribute waterTemp : Real; attribute brewPressure : Real; satisfy requirement : BrewTempReq; } // ANCHOR_END: listing-8 } package Lch10_09 { private import CoffeeVocabulary::*; // ANCHOR: listing-9 verification def BrewTempTest { doc /* Measure extraction temperature across 10 consecutive brew cycles and confirm all readings fall within range. */ objective { verify requirement : BrewTempReq; } } // ANCHOR_END: listing-9 } package Lch10_10 { private import CoffeeVocabulary::*; // ANCHOR: listing-10 verification def SafetyInterlockTest { doc /* Attempt to start a brew cycle with no cup present. Confirm the system rejects the command. Then place a cup, retry, and confirm the cycle starts. */ objective { verify requirement : SafetyInterlockReq; } } // ANCHOR_END: listing-10 } package Lch10_11 { private import CoffeeVocabulary::*; // ANCHOR: listing-11 verification def SafetyInterlockTest { doc /* Verify that the brew interlock prevents operation without a cup. */ action removeCup { doc /* Remove any cup from the tray. */ } action attemptBrew { doc /* Press the brew button. */ } action confirmRejection { doc /* Verify the machine refuses to brew. */ } action placeCup { doc /* Place a cup on the tray. */ } action retryBrew { doc /* Press the brew button again. */ } action confirmSuccess { doc /* Verify the brew cycle starts. */ } first removeCup then attemptBrew; first attemptBrew then confirmRejection; first confirmRejection then placeCup; first placeCup then retryBrew; first retryBrew then confirmSuccess; objective { verify requirement : SafetyInterlockReq; } } // ANCHOR_END: listing-11 } package Lch10_12 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-12 package CoffeeMachineRequirements { private import ScalarValues::*; private import CoffeeMachineDomain::*; // --- Requirements --- requirement def <'REQ-TEMP-001'> BrewTempReq { doc /* The brewer extraction temperature shall remain between 90 and 96 degrees Celsius during brewing. */ subject brewer : Brewer; attribute temp : Real; require constraint { temp >= 90.0 and temp <= 96.0 } } requirement def <'REQ-SAFE-001'> SafetyInterlockReq { doc /* The system shall not initiate a brew cycle unless a cup is detected on the drip tray. */ subject machine : CoffeeMachine; } requirement def <'REQ-BREW-001'> BrewTimeReq { doc /* A brew cycle shall complete within 60 seconds from initiation to coffee dispensed. */ subject machine : CoffeeMachine; attribute duration : Real; require constraint { duration <= 60.0 } } // --- Satisfaction (in a usage context) --- part coffeeMachine : CoffeeMachine { satisfy requirement : BrewTempReq; satisfy requirement : SafetyInterlockReq; satisfy requirement : BrewTimeReq; } // The form above is the most common, but the spec also accepts: // // satisfy requirement brewTempReq : BrewTempReq by brewer; // // which gives the satisfaction usage its own name (`brewTempReq`) // and lets you spell out which design element does the satisfying // (`by brewer`) when it is not the enclosing element. // --- Verification --- verification def BrewTempTest { doc /* Measure extraction temperature across 10 consecutive brew cycles. All readings must fall between 90 and 96 degrees Celsius. */ objective { verify requirement : BrewTempReq; } } verification def SafetyInterlockTest { doc /* Attempt brew with no cup: confirm rejection. Place cup, retry: confirm cycle starts. */ objective { verify requirement : SafetyInterlockReq; } } verification def BrewTimeTest { doc /* Time 5 consecutive brew cycles from button press to coffee dispensed. All must complete within 60 seconds. */ objective { verify requirement : BrewTimeReq; } } } // ANCHOR_END: listing-12 } package Lch10_13 { private import CoffeeVocabulary::*; // ANCHOR: listing-13 requirement def <'REQ-PERF-001'> PerformanceReq { doc /* The coffee machine shall deliver acceptable performance across all operating conditions. */ requirement <'REQ-PERF-001a'> startupTimeReq { doc /* The machine shall reach operating temperature within 90 seconds of power-on. */ } requirement <'REQ-PERF-001b'> brewTimeReq { doc /* Each brew cycle shall complete within 60 seconds of initiation. */ } } // ANCHOR_END: listing-13 } package Lch10_14 { private import CoffeeVocabulary::*; // ANCHOR: listing-14 use case def BrewEspresso { doc /* The user selects espresso, the machine grinds beans, heats water, extracts coffee, and dispenses into cup. */ subject machine : CoffeeMachine; objective { doc /* Deliver a single espresso shot to the user. */ } } // ANCHOR_END: listing-14 } package Lch10_15 { private import CoffeeVocabulary::*; // ANCHOR: listing-15 concern def SafetyConcern { doc /* The machine must not create burn hazards or dispense onto the counter without a cup. */ } // ANCHOR_END: listing-15 } package Lch10_16 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-16 analysis def ThermalLossAnalysis { doc /* Estimate the heat lost from the brewer during a 30-second idle period at an ambient temperature of 20 degrees C. */ subject brewer : Brewer; return lossRate : Real; } // ANCHOR_END: listing-16 } package Lch10_17 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-17 case def ThermalLoadProfile { subject brewer : Brewer; out idleLoad : Real; out heatingLoad : Real; } // ANCHOR_END: listing-17 } package Lch10_18 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-18 constraint def BrewTempSafe { in temp : Real; temp >= 90.0 and temp <= 96.0 } // ANCHOR_END: listing-18 } package Lch10_19 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-19 requirement def <'REQ-TEMP-001'> BrewTempReq { doc /* The brewer extraction temperature shall remain between 90 and 96 degrees Celsius during brewing. */ attribute temp : Real; require constraint { temp >= 90.0 and temp <= 96.0 } } // ANCHOR_END: listing-19 }