Your Complete System Model
What evidence would show that an espresso machine meets its extraction-temperature requirement? This chapter follows one measurement from the brewer, through a design claim, to a verification verdict. It uses the structure and behavior from earlier lessons, but does not require their files.
The Model So Far
Here is what each chapter contributed:
- Chapter 2 defined the core types:
Grinder,Brewer,WaterTank,CoffeeMachine, plus item definitions forWater,CoffeeBeans, andBrewedCoffee. - Chapter 5 added typed ports to each component:
beanInputandgroundOutputon the grinder;waterInlet,groundInput, andbrewOutputon the brewer;waterOuton the water tank. - Chapter 6 wired the components together with connections and typed item flows.
- Chapter 7 defined
BrewCycleas a sequence of actions with parallel branches. - Chapter 8 defined
MachineStateswith guarded transitions between operating modes. - Chapter 9 added
BrewTempTarget(calculation) andSafetyInterlock(constraint). - Chapter 10 added requirements with
satisfyandverifylinks.
Package Organization
The next six listings form one self-contained model. Paste them, in order, into an empty .sysml file or download the combined file. It uses only the standard library. Do not load vocabulary.sysml or the larger coffee-machine project alongside it: those are separate teaching models.
Start with the materials and grind settings. No part owns them yet.
package CoffeeMachineDomain {
// Domain vocabulary
item def Water;
item def CoffeeBeans;
item def GroundCoffee;
item def BrewedCoffee;
enum def GrindSetting {
fine;
medium;
coarse;
}
}
The assembly supplies the context: brewer.waterTemp is a measurement on this machine’s brewer. Ground coffee and water each have a directed pair of ports: the receiving or supplying side uses the conjugate type.
package CoffeeMachineStructure {
private import ScalarValues::*;
private import CoffeeMachineDomain::*;
port def BeanInputPort {
in item beans : CoffeeBeans;
}
port def GroundCoffeePort {
out item grounds : GroundCoffee;
}
port def WaterPort {
in item water : Water;
}
port def BrewOutputPort {
out item coffee : BrewedCoffee;
}
part def Grinder {
attribute grindSize : GrindSetting;
port beanInput : BeanInputPort;
port groundOutput : GroundCoffeePort;
}
part def Brewer {
attribute waterTemp : Real; // measured extraction temperature in degrees Celsius
attribute brewPressure : Real;
port waterInlet : WaterPort;
port groundInput : ~GroundCoffeePort;
port brewOutput : BrewOutputPort;
}
part def WaterTank {
attribute currentLevel : Real;
attribute maxCapacity : Real;
port waterOut : ~WaterPort;
}
part def CoffeeMachine {
part grinder : Grinder;
part brewer : Brewer;
part waterTank : WaterTank;
attribute serialNumber : String;
connect waterTank.waterOut to brewer.waterInlet;
connect grinder.groundOutput to brewer.groundInput;
flow of Water from waterTank.waterOut.water to brewer.waterInlet.water;
flow of GroundCoffee from grinder.groundOutput.grounds to brewer.groundInput.grounds;
}
}
Grinding and heating can proceed in parallel. Extraction waits for both. The controlled machine exhibits a state machine: a brew command can leave idle only if a cup is present.
package CoffeeMachineBehavior {
private import CoffeeMachineDomain::*;
private import CoffeeMachineStructure::CoffeeMachine;
private import ScalarValues::Boolean;
action def GrindBeans { in item beans : CoffeeBeans; out item grounds : GroundCoffee; }
action def HeatWater { in item water : Water; out item hotWater : Water; }
action def ExtractCoffee {
in item water : Water; in item grounds : GroundCoffee; out item coffee : BrewedCoffee;
}
action def DispenseCoffee { in item coffee : BrewedCoffee; }
action def BrewCycle {
action grind : GrindBeans; action heat : HeatWater;
action extract : ExtractCoffee; action dispense : DispenseCoffee;
fork prepare; join prepared;
first start then prepare;
first prepare then grind; first prepare then heat;
first grind then prepared; first heat then prepared;
first prepared then extract; first extract then dispense; first dispense then done;
flow from grind.grounds to extract.grounds;
flow from heat.hotWater to extract.water;
flow from extract.coffee to dispense.coffee;
}
attribute def BrewCommand; attribute def ShotPoured;
attribute def CleanCommand; attribute def Cleaned;
attribute def Fault; attribute def Reset;
part def ControlledMachine :> CoffeeMachine {
attribute cupPresent : Boolean;
exhibit state machineStates {
entry; then idle;
state idle;
state brewing { do action cycle : BrewCycle; }
state cleaning; state error;
transition first idle accept BrewCommand if cupPresent then brewing;
transition first brewing accept ShotPoured then idle;
transition first idle accept CleanCommand then cleaning;
transition first cleaning accept Cleaned then idle;
transition first brewing accept Fault then error;
transition first error accept Reset then idle;
}
}
}
Write the acceptance rules once. The target temperature is a setpoint; the temperature-band constraint evaluates a measurement. Both the requirement and its test reuse the latter rule.
package CoffeeMachineAnalysis {
private import ScalarValues::*;
calc def BrewTempTarget {
in ambient : Real;
return target : Real = if ambient < 18.0 ? 94.0 else 93.0;
}
constraint def BrewTempSafe {
in celsius : Real;
celsius >= 90.0 and celsius <= 96.0
}
constraint def SafetyInterlock {
in started : Boolean; in cupPresent : Boolean;
started implies cupPresent
}
constraint def WithinBrewTime {
in seconds : Real;
seconds < 60.0
}
}
Declare the requirement usages and identify the design that claims to satisfy them. benchMachine and hotShot differ only in measured temperature. Only benchMachine makes satisfaction claims.
package CoffeeMachineRequirements {
private import CoffeeMachineBehavior::ControlledMachine;
private import CoffeeMachineAnalysis::*;
private import ScalarValues::*;
part def TestMachine :> ControlledMachine {
attribute brewStarted : Boolean;
attribute elapsedSeconds : Real;
}
requirement def <'REQ-TEMP-001'> BrewTempReq {
doc /* The measured extraction temperature shall be in the range 90–96 °C inclusive. */
subject machine : TestMachine;
require constraint { BrewTempSafe(machine.brewer.waterTemp) }
}
requirement def <'REQ-SAFE-001'> SafetyInterlockReq {
doc /* Brewing shall not start without a cup. */
subject machine : TestMachine;
require constraint { SafetyInterlock(machine.brewStarted, machine.cupPresent) }
}
requirement def <'REQ-TIME-001'> BrewTimeReq {
doc /* A brew cycle shall take less than 60 seconds. */
subject machine : TestMachine;
require constraint { WithinBrewTime(machine.elapsedSeconds) }
}
requirement brewTemperature : BrewTempReq;
requirement interlock : SafetyInterlockReq;
requirement brewTime : BrewTimeReq;
part benchMachine : TestMachine {
part :>> brewer { :>> waterTemp = 96.0; }
:>> cupPresent = true; :>> brewStarted = true; :>> elapsedSeconds = 45.0;
}
satisfy brewTemperature by benchMachine;
satisfy interlock by benchMachine;
satisfy brewTime by benchMachine;
// A second observation for testing the temperature limit, not a design claim.
part hotShot : TestMachine {
part :>> brewer { :>> waterTemp = 97.0; }
:>> cupPresent = true; :>> brewStarted = true; :>> elapsedSeconds = 45.0;
}
}
Each verification objective names the same requirement usage as the design claim. Run a case on a particular subject to obtain a verdict.
package CoffeeMachineVerification {
private import CoffeeMachineRequirements::*;
private import CoffeeMachineAnalysis::*;
private import VerificationCases::VerdictKind;
verification def BrewTempTest {
subject machine : TestMachine;
objective { verify brewTemperature; }
return verdict : VerdictKind = if BrewTempSafe(machine.brewer.waterTemp)
? VerdictKind::pass else VerdictKind::fail;
}
verification def SafetyInterlockTest {
subject machine : TestMachine;
objective { verify interlock; }
return verdict : VerdictKind = if SafetyInterlock(machine.brewStarted, machine.cupPresent)
? VerdictKind::pass else VerdictKind::fail;
}
verification def BrewTimeTest {
subject machine : TestMachine;
objective { verify brewTime; }
return verdict : VerdictKind = if WithinBrewTime(machine.elapsedSeconds)
? VerdictKind::pass else VerdictKind::fail;
}
}
How the Packages Connect
CoffeeMachineDomain supplies the material types used by structure and behavior. ControlledMachine specializes the structural CoffeeMachine, so the subject of a test can have both a brewer and operating modes. CoffeeMachineAnalysis depends only on the standard library. Requirements bring the machine and the rules together; verification imports the named requirements and the same rules.
Cross-Concern Traceability
Follow the temperature measurement in either direction:
benchMachine.brewer.waterTempsupplies 96 °C. This is a recorded observation, not the calculated temperature target.brewTemperatureis aBrewTempRequsage. Its required constraint evaluatesBrewTempSafeon the subject’s brewer.satisfy brewTemperature by benchMachine;identifies the design making the claim.BrewTempTesthasobjective { verify brewTemperature; }. Its return expression applies the same inclusive band to the specified test subject. The objective records which requirement the test verifies; it does not compute the verdict for us.
Run the chapter from the edition root. The checks below need only the six packages shown above:
model=src/examples/lessons/ch11.sysml
req=CoffeeMachineRequirements
ver=CoffeeMachineVerification
sysml -strict -validate "$model"
sysml -satisfy "$model"
sysml -instantiate "$req::benchMachine" -analysis "$ver::BrewTempTest $req::benchMachine" "$model"
sysml -instantiate "$req::hotShot" -analysis "$ver::BrewTempTest $req::hotShot" "$model"
What Makes This Model Review-Ready
The three satisfaction assertions are about benchMachine: temperature at the included upper boundary, a cup present when brewing started, and 45 seconds elapsed. The temperature case passes for that machine. It fails for hotShot at 97 °C; the last command is an intentional negative test. A structural check succeeds in both cases. Finding an unacceptable observation is the test doing its job, not a syntax error.
These checks do not establish how an actual machine acquired the readings, or that all future shots stay in range. For that conclusion a reviewer would need a sampling plan and test results from the hardware.
The model on disk
For the chapter exercise, use the single six-package model. The larger companion project below is independent: it develops the same system in more detail, with different package names and its own measured inputs. From the edition root, load the directory as one model:
sysml -strict -validate src/examples/coffee-machine
sysml -list views src/examples/coffee-machine
File in src/examples/coffee-machine/ | Question it answers |
|---|---|
definitions.sysml, typing-and-specialization.sysml | What is a brewer, and what is different about an espresso brewer? |
ports-and-interfaces.sysml, connections.sysml, flows.sysml | Where can water pass between the tank and the brewer? |
actions.sysml, brew-cycle-flow.sysml | Which steps must wait for grinding and heating? |
states.sysml, orchestration.sysml | Which modes exist? Which timed transitions does the example run exercise? |
calculations.sysml, demo-analysis.sysml | How do time and power depend on operating conditions? |
requirements.sysml | What is required, which machine claims compliance, and what does the verification case measure? |
metadata.sysml, views.sysml, book-views.sysml, package-structure.sysml | How can each reviewer find the relevant elements without copying the model? |
Exploring the Model
These four figures were rendered from the larger companion project, not from the six-package exercise. Each selects a different aspect of that project:
Structure
Actions
States
Requirements
Extending the Model
This model is a foundation, not a finished product. Real projects extend it in several directions:
- More requirements. Add power consumption, noise level, maintenance interval requirements.
- More states. Add
Steaming,Descaling,Standbymodes with guarded transitions. - More actions. Add
SteamMilk,RunDescaleactions with their own control flow. - Variants. Use specialization (Chapter 12) to create
EspressoMachineandDripMachinevariants. - Governance. Use metadata and views (Chapter 13) to add review status and stakeholder-specific model slices.
- Physical units. Use library quantities (Chapter 14) to replace
RealwithTemperatureValueandPressureValue.
The structure is ready for all of these. Each extension adds to the model without rewriting what exists.