// Independent worked listings. Load this chapter with vocabulary.sysml, not with other chapters. package Lch13_01 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-1 part def Brewer { doc /* Heats water and forces it through ground coffee under controlled pressure and temperature. */ attribute waterTemp : Real; attribute brewPressure : Real; } // ANCHOR_END: listing-1 } package Lch13_02 { private import CoffeeVocabulary::*; private import ScalarValues::String; // ANCHOR: listing-2 package CoffeeMachineGovernance { private import ScalarValues::*; metadata def ReviewStatus { attribute status : String; attribute reviewer : String; } metadata def SafetyClass { attribute level : String; } } // ANCHOR_END: listing-2 } package Lch13_03 { private import CoffeeVocabulary::*; private import ScalarValues::String; // ANCHOR: listing-3 package CoffeeMachineStructure { private import ScalarValues::*; private import CoffeeMachineGovernance::*; @ReviewStatus about CoffeeMachine { :>> status = "approved"; :>> reviewer = "Systems Team"; } part def CoffeeMachine { doc /* Top-level system definition for the Smart Coffee Machine. */ part grinder : Grinder; part brewer : Brewer; part waterTank : WaterTank; attribute serialNumber : String; } } // ANCHOR_END: listing-3 } package Lch13_04 { private import CoffeeVocabulary::*; // ANCHOR: listing-4 @SafetyClass about SafetyInterlockReq { :>> level = "SIL-2"; } requirement def SafetyInterlockReq { doc /* The machine shall disable the heater if water temperature exceeds 100 degrees Celsius. */ } // ANCHOR_END: listing-4 } package Lch13_05 { private import CoffeeVocabulary::*; private import ScalarValues::Real; // ANCHOR: listing-5 @ReviewStatus about Brewer { :>> status = "in-review"; :>> reviewer = "Safety Board"; } @SafetyClass about Brewer { :>> level = "SIL-2"; } part def Brewer { doc /* Heating subsystem. Under safety review. */ attribute waterTemp : Real; attribute brewPressure : Real; } // ANCHOR_END: listing-5 } package Lch13_06 { private import CoffeeVocabulary::*; private import ScalarValues::String; // ANCHOR: listing-6 package CoffeeMachineGovernance { private import ScalarValues::*; metadata def ReviewStatus { attribute status : String; attribute reviewer : String; } metadata def SafetyClass { attribute level : String; } metadata def MaturityLevel { attribute level : String; } } // ANCHOR_END: listing-6 } package Lch13_07 { private import CoffeeVocabulary::*; // ANCHOR: listing-7 @MaturityLevel about BrewCycle { :>> level = "preliminary"; } action def BrewCycle; @MaturityLevel about WaterTank { :>> level = "baselined"; } part def WaterTank; @MaturityLevel about BrewTempReq { :>> level = "verified"; } requirement def BrewTempReq; // ANCHOR_END: listing-7 } package Lch13_08 { private import CoffeeVocabulary::*; // ANCHOR: listing-8 package CoffeeMachineViews { viewpoint def SafetyViewpoint { doc /* Concerns: hazard mitigations, safety interlocks, and safety-classified requirements. */ } viewpoint def ArchitectureViewpoint { doc /* Concerns: structural decomposition, subsystem interfaces, and key part definitions. */ } } // ANCHOR_END: listing-8 } package Lch13_09 { private import CoffeeVocabulary::*; // ANCHOR: listing-9 viewpoint def VerificationViewpoint { doc /* Requirement-to-test traceability for verification closure. */ } // ANCHOR_END: listing-9 } package Lch13_10 { private import CoffeeVocabulary::*; // ANCHOR: listing-10 package CoffeeMachineViews { private import CoffeeMachineStructure::*; view def CoffeeOverview; view overview : CoffeeOverview { expose CoffeeMachine; } } // ANCHOR_END: listing-10 } package Lch13_11 { private import CoffeeVocabulary::*; // ANCHOR: listing-11 package CoffeeMachineViews { private import CoffeeMachineStructure::*; private import CoffeeMachineRequirements::*; viewpoint def SafetyViewpoint { doc /* Concerns: hazard mitigations and safety interlocks. */ } viewpoint def ArchitectureViewpoint { doc /* Concerns: structural decomposition and interfaces. */ } view def SafetyReviewView; view def ArchitectureReviewView; view safetyReview : SafetyReviewView { viewpoint perspective : SafetyViewpoint; expose CoffeeMachineRequirements::SafetyInterlockReq; expose CoffeeMachineRequirements::BrewTempReq; } view architectureReview : ArchitectureReviewView { viewpoint perspective : ArchitectureViewpoint; expose CoffeeMachineStructure::CoffeeMachine; expose CoffeeMachineStructure::Brewer; expose CoffeeMachineStructure::Grinder; expose CoffeeMachineStructure::WaterTank; } } // ANCHOR_END: listing-11 } package Lch13_12 { private import CoffeeVocabulary::*; // ANCHOR: listing-12 view interfaceReview : ArchitectureReviewView { expose CoffeeMachineStructure::Brewer; // member expose expose CoffeeMachineStructure::*; // namespace expose } // ANCHOR_END: listing-12 } package Lch13_13 { private import CoffeeVocabulary::*; // ANCHOR: listing-13 view scratch { expose CoffeeMachine; } // ANCHOR_END: listing-13 } package Lch13_14 { private import CoffeeVocabulary::*; // ANCHOR: listing-14 package CoffeeMachineReview { private import ScalarValues::*; private import CoffeeMachineGovernance::*; private import CoffeeMachineStructure::*; private import CoffeeMachineRequirements::*; viewpoint def SafetyViewpoint { doc /* All elements classified SIL-2 or above, plus their associated requirements. */ } view def SafetyReviewView; // The safety review exposes only safety-relevant elements view safetyReview : SafetyReviewView { viewpoint perspective : SafetyViewpoint; expose CoffeeMachineRequirements::SafetyInterlockReq; expose CoffeeMachineRequirements::BrewTempReq; expose CoffeeMachineStructure::Brewer; } viewpoint def ArchitectureViewpoint { doc /* System decomposition for architecture board review. */ } view def ArchitectureReviewView; // The architecture review exposes structural elements view architectureReview : ArchitectureReviewView { viewpoint perspective : ArchitectureViewpoint; expose CoffeeMachineStructure::CoffeeMachine; expose CoffeeMachineStructure::Grinder; expose CoffeeMachineStructure::Brewer; expose CoffeeMachineStructure::WaterTank; } } // ANCHOR_END: listing-14 } package Lch13_15 { private import CoffeeVocabulary::*; // ANCHOR: listing-15 view def PartsOnlyPortable { filter @SysML::PartUsage; // metaclass test } view partsOnly : PartsOnlyPortable { expose CoffeeMachineStructure::*; } view def MandatorySafety { filter @SIL2; } view mandatorySafety : MandatorySafety { expose CoffeeMachineStructure::*; } // ANCHOR_END: listing-15 } package Lch13_16 { private import CoffeeVocabulary::*; // ANCHOR: listing-16 view def AllOfIt { filter true; } // accept everything view def NoneOfIt { filter false; } // accept nothing // ANCHOR_END: listing-16 } package Lch13_17 { private import CoffeeVocabulary::*; // ANCHOR: listing-17 view def PartsOnly { filter @SysML::PartUsage; } view structureParts : PartsOnly { expose CoffeeMachineStructure::**; } view brewerOnly { expose CoffeeMachineStructure::Brewer; } // ANCHOR_END: listing-17 } package Lch13_18 { private import CoffeeVocabulary::*; // ANCHOR: listing-18 view def SafetyParts { filter @SysML::PartUsage; filter @SafetyClassification; } view safetyParts : SafetyParts { expose CoffeeMachineStructure::**; } // ANCHOR_END: listing-18 } package Lch13_19 { private import CoffeeVocabulary::*; // ANCHOR: listing-19 package CoffeeMachineViews { private import CoffeeMachineStructure::*; private import CoffeeMachineRequirements::*; rendering def StandardRendering; view def SafetyReviewView { render rendering presentation : StandardRendering; } view safetyReview : SafetyReviewView { viewpoint perspective : SafetyViewpoint; expose CoffeeMachineRequirements::SafetyInterlockReq; expose CoffeeMachineRequirements::BrewTempReq; } } // ANCHOR_END: listing-19 } package Lch13_20 { private import CoffeeVocabulary::*; private import StandardViewDefinitions::GeneralView; // ANCHOR: listing-20 view def RequirementOverview :> GeneralView { filter @SysML::RequirementDefinition or @SysML::RequirementUsage or @SysML::SatisfyRequirementUsage; } // ANCHOR_END: listing-20 } package Lch13_21 { private import CoffeeVocabulary::*; private import StandardViewDefinitions::ActionFlowView; private import StandardViewDefinitions::InterconnectionView; private import StandardViewDefinitions::StateTransitionView; // ANCHOR: listing-21 view def CoffeeStructure :> InterconnectionView; view def BrewSequence :> ActionFlowView; view def HeaterStateMachine :> StateTransitionView { filter @SysML::StateUsage or @SysML::TransitionUsage; } view structure : CoffeeStructure { expose CoffeeMachine; } view brewOrder : BrewSequence { expose BrewCycle; } view heaterStates : HeaterStateMachine { expose Brewer; } // ANCHOR_END: listing-21 } package Lch13_22 { private import CoffeeVocabulary::*; private import StandardViewDefinitions::InterconnectionView; // ANCHOR: listing-22 package SafetyReview { private import CoffeeMachineStructure::*; // Stakeholder — a role part def SafetyEngineer; // Viewpoint — the concern, expressed as a requirement viewpoint def SafetyConcernViewpoint { subject selectedView : Views::View; stakeholder reviewer : SafetyEngineer; doc /* Reviewers must see all SIL-2-classified parts. */ } // Rendering — the style rendering def DarkInterconnection; // View Definition — the recipe view def SafetySIL2View :> InterconnectionView { render rendering dark : DarkInterconnection; filter @SIL2; } // View Usage — the concrete instance view sil2Diagram : SafetySIL2View { viewpoint perspective : SafetyConcernViewpoint; expose CoffeeMachine; } } // ANCHOR_END: listing-22 }