Track 9. SysML v2 Fundamentals: exercise sheet
For students and engineers new to SysML v2. One practice task and a few questions per chapter, to work through after each video. Print this page from your browser, or work on screen. The answer key starts on a new page at the end.
Before you start
- Take first
- The in-app tutorial SysML v2: Getting Started (Help → Tutorials).
- Plan
- Free
- Project
- The starter projects of the in-app SysML v2 tutorials; practice on the Hybrid Car demo.
9.1 Definitions and Attributes
Watch chapter 9.1 (4:33)
Practice
On the Hybrid Car demo project (SysML v2):
- Create the Hybrid Car demo: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2). Open Model → Editor and the package
Vehicles. - Below
enum def FuelKind, addenum def CoolingMode { enum passive; enum active; }. - Below
part def Body, choose Insert ▾ → Part Definition and completepart def Radiator :> Componentwithattribute redefines mass = 8 [kg];,attribute coolantVolume : VolumeValue;(typeVoluand acceptVolumeValuefrom the completion list with Enter) andattribute mode : CoolingMode;. - Change the mass to
8 [W], point at the underline to read the message, then change it back to8 [kg]. - In
part def Powertrain, addpart radiator : Radiator;. Then place the cursor oncoolantVolume, press F2 and rename it tocoolantCapacity. - For a checked walk-through, run the SysML v2 tutorial Definitions and Attributes (Help → Tutorials).
You're done when the status under the editor reports no problems and the Browser shows Radiator under Vehicles with coolantCapacity and mode.
Questions
- In
part def Battery :> Component { attribute redefines mass = 45 [kg]; }, what do:>andredefineseach do? - Why is Component declared
abstract part def? - Why does
attribute redefines power = 60 [kg];give an error? - What is the difference between
doc /* … */and a//line?
9.2 Ports and Interfaces
Watch chapter 9.2 (3:44)
Practice
On the Hybrid Car demo project (SysML v2):
- Open your Hybrid Car demo project (create it if needed: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2)), open Model → Editor and the package
Vehicles. - Below
interface def HighVoltageBus, addinterface def ControlLink { end commander : ~ControlPort; end unit : ControlPort; }. - In
part def Powertrain, replaceconnect controller.engineCtl to engine.ecu;withinterface engineControl : ControlLink connect controller.engineCtl to engine.ecu;, and addpart auxBattery : Battery;afterpart battery : Battery;. - Open Architecture → Interconnection Views and the view
powertrainConnections. Drag from the handle ofauxBattery's portpowerOutto the motor's portpowerInand choose Interface : HighVoltageBus. - Select the new line and enter
auxBusas its Name in the inspector. Then open Model → Editor and find the line Holarch wrote inPowertrain.
You're done when Powertrain holds interface engineControl : ControlLink … and the auxBus interface from the view, and the status under the editor reports no problems.
Questions
- The engine has
port fuelIn : ~FuelPort;. What does the tilde change? - What is the difference between
bind output = transmission.output;andinterface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;? - Why does the view offer Interface : HighVoltageBus when you drag from a battery's
powerOutto the motor'spowerIn?
9.3 Actions and Flows
Watch chapter 9.3 (4:31)
Practice
On the Hybrid Car demo project (SysML v2):
- Open your Hybrid Car demo project (create it if needed: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2)), open Model → Editor and the package
VehicleBehavior. - Below
action def <'F.3'> DriveWheels, addaction def <'F.4'> Refuel { in attribute fuelDemand : Real; out item fuel : Fuel; }. - Open Behavior → FFBD, click + New Diagram, choose
Refueland click Create. In the Add panel, typeOpen Filler Doorand press Enter, thenPump FuelandClose Filler Door. - Open Model → Editor and find
Refuel: the FFBD wrote its three steps and the successions between them. - Open Behavior → Action Flows and the view
driveCycleFlow. Find the lane that holdsbrake, then find theperformline inDrivenCarthat puts it there. - Open Behavior → Functional Analysis, click Choose… and pick
DriveCycle. Check that its functions are numbered by their short names.
You're done when Refuel shows its parameters, three steps and their successions in the Editor, and you can name the part whose lane holds brake.
Questions
- In
first start then split; fork split; then supply; then produce;, which steps run in parallel, and what brings them back together? - What is the difference between
first supply then ready;andflow of Fuel from supply.fuel to produce.fuel;? - Where do the swim lanes of an Action Flow View come from?
9.4 States and Transitions
Watch chapter 9.4 (3:51)
Practice
On the Hybrid Car demo project (SysML v2):
- Open your Hybrid Car demo project (create it if needed: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2)), open Model → Editor and the package
VehicleBehavior. - After
attribute def Unplug;, addattribute def FaultDetected;. - Before the closing brace of
state def PowertrainStates, addstate limpHome { entry action warnDriver; do action driveLimited; }andtransition limpStop first limpHome accept StopRequest then off;. - Open Behavior → State Machines, click + New Diagram, choose
PowertrainStatesunder Shows and click Create. - Select
electricand drag from its handle tolimpHome; drop on Transition. In the transition panel, enter the NameelectricFaultand the TriggerFaultDetected, then click Show in Text.
You're done when PowertrainStates holds limpHome, limpStop and the transition electricFault that accepts FaultDetected, and the status under the editor reports no problems.
Questions
- What makes
offthe initial state ofPowertrainStates? - After
state off;comesaccept StartRequest if charge > 20 then electric;. Name its trigger, guard, source and target. - When do a state's entry, do and exit actions run?
- What does
exhibit state powertrainStates : PowertrainStates;inDrivenCarsay?
9.5 Requirements
Watch chapter 9.5 (4:15)
Practice
On the Hybrid Car demo project (SysML v2):
- Open your Hybrid Car demo project (create it if needed: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2)), open Model → Editor and the package
VehicleRequirements. - After
attribute minElectricRange, addattribute minTopSpeed : SpeedValue = 180 [km/h];. - Below
requirement def <'VR-5'> ChargeTime, choose Insert ▾ → Requirement Definition and write<'VR-8'> TopSpeedwith the statementThe sports car shall reach at least the minimum top speed., the subjectcar : SportCarandrequire constraint { car.topSpeed >= minTopSpeed }. - After the other
satisfylines, addsatisfy requirement roadsterSpeed : TopSpeed by fleet.roadster;. - Change
minTopSpeedto220 [km/h]. Point at the mark the Editor puts on the satisfy to read the values it compared, then press ⌘Z / Ctrl+Z. - Open Needs & Requirements → Requirements and find VR-8, then open Needs & Requirements → Quality and click Check Quality.
You're done when VR-8 is in the Requirements table, the satisfy has no mark at 180 km/h, and Check Quality has scored its statement.
Questions
- Why keep limits such as
maxCurbMassas named attributes instead of writing the number in each constraint? - In
requirement <'VR-1.1'> sedanMass : CurbMass { attribute :>> limit = maxCurbMass; }, what does:>>do? - What does
satisfy carSpec by fleet.sedan;let Holarch check? - You set a requirement's Status and Priority on the Requirements page. Does the SysML text change?
9.6 Verification and Traceability
Watch chapter 9.6 (3:32)
Practice
On the Hybrid Car demo project (SysML v2):
- Open your Hybrid Car demo project (create it if needed: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2)), open Model → Editor and the package
VehicleRequirements. - After
verification <'VC-1.1'> sedanWeighing, addverification def <'VC-2'> BatteryWeighing { subject battery : Battery; objective { verify batteryMassLimit; } return verdict : Boolean = battery.mass <= 50 [kg]; }andverification <'VC-2.1'> sedanBatteryWeighing : BatteryWeighing { subject battery = fleet.sedan.powertrain.battery; }. - Open Verification → Verification Cases. In the row of the new case, click + Steps, then + Add Step, type
Weigh the battery on a bench scaleunder Action, click Apply, and click Passed in its status buttons. - Open Verification → RVTM and find VR-6
batteryMassLimitwith the new case and its status. - Open Verification → Traceability Matrix, show requirements as rows and the class Action as columns, click the cell where
sedanAccelerationmeetsaccelerate, and choose satisfied by. - At the end of the package, add
requirement <'VR-9'> tankVolume { doc /* The fuel tank shall hold at least 40 L. */ subject tank : FuelTank; }andconnection tankDerivation : Derivation connect carSpec.sedanRange to tankVolume;. Then open Verification → Model Checks.
You're done when the RVTM lists the new case against VR-6 as passed, the Editor holds the new satisfy and tankDerivation, and the status reports no problems.
Questions
- In
objective massObjective { verify carSpec.sedanMass; }, what doesverifysay, and where do you see it? - What is the difference between a verification case's verdict and the status on the Verification Cases page?
- When do you use
satisfy, and when aDerivation? - What happens when you choose satisfied by in a Traceability Matrix cell?
9.7 Constraints and Calculations
Watch chapter 9.7 (4:26)
Practice
On the Hybrid Car demo project (SysML v2):
- Open your Hybrid Car demo project (create it if needed: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2)), open Model → Editor and the package
VehicleRequirements. - After
constraint def SpeedLimit, addconstraint sedanBatteryCheck : MassLimit { in mass = fleet.sedan.powertrain.battery.mass; in limit = 50 [kg]; }. - On the Diagrams page, click + New Diagram, choose Parametric View and
VehicleRequirementsunder Shows, and click Create. The new check passes: 48 kg is within 50 kg. - In the package
Vehicles, change the sedan battery's mass to52 [kg]; the view shows the check failing. Press ⌘Z / Ctrl+Z, then click Solve All to check every constraint again. - In
requirement def <'VR-2'> Acceleration, replaceattribute zeroToHundred : TimeValue;withattribute zeroToHundred : TimeValue { @TBD { owner = "Test lead"; rationale = "The test track is not booked yet."; } }. Open Needs & Requirements → TBD/TBR and find the requirement with its owner. - Open Architecture → Budgets & TPMs, click Select Root Part… and choose
sedan. Under Quantity, choose Mass and find the battery's 48 kg.
You're done when sedanBatteryCheck shows Pass in the Parametric View and the TBD/TBR register lists the Acceleration requirement with the owner Test lead.
Questions
- What is the difference between a
constraint defand acalc def? - A constraint in the Parametric View shows Needs input. What is missing?
- Why mark an open value with
#TBDor@TBD { … }instead of writing TBD as the value? - What does an analysis case add to a calculation?
9.8 Variants and Configurations
Watch chapter 9.8 (3:42)
Practice
On the Hybrid Car demo project (SysML v2):
- Open your Hybrid Car demo project (create it if needed: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2)), open Model → Editor and the package
Vehicles. It already importsHolarchVariability. - In
part def CarLine, after thechargervariation, addvariation part rims : Wheel { variant part steelRims : Wheel; variant part alloyRims : Wheel { attribute :>> mass = 18 [kg]; } }. The Editor notes that the three configurations have not chosenrimsyet. - After
wallboxNeedsLargePack, add the ruleassert constraint alloyNeedsLargePack { rims == rims::alloyRims implies pack == BatteryPack::largePack }. - Open Model → Browser and select
selfChargingHybrid. In the inspector's Configuration section, choose steelRims for rims; choose alloyRims forplugInHybridandlongRangeHybrid. Then try alloyRims onselfChargingHybrid, read the verdict, and press ⌘Z / Ctrl+Z. - Open the row menu (⋯) of
CarLineand choose New Configuration…. Name itcityHybrid, choose standardPack, noCharger and steelRims, check that the verdict is Valid, and click Create. - Click View as ▾ in the top bar and choose
cityHybrid, then open the viewcarLineVariantsfrom the Diagrams list: the variants it does not choose are hidden.
You're done when the inspector's Product Line section for CarLine lists four configurations, all Valid, and the rule alloyNeedsLargePack.
Questions
- What is the difference between
variation part def BatteryPack { … }andvariation part charger : Component { … }? plugInHybridchoosesBatteryPack::standardPackandcharger::wallbox. What happens, and why?- A configuration has not chosen a variant for every point yet. What is its verdict?
- What does
metadata def <safetyCritical> SafetyCriticallet you write, and how do other SysML v2 tools see it?
Answer key
9.1 Definitions and Attributes
:>makes Battery a specialization of Component, so it inherits mass, partNumber and power.redefinesreplaces the inheritedmassin Battery with its own feature, here bound to 45 kg.- Nothing is a component as such, only kinds of components. An abstract definition collects what every component shares, and only its specializations, such as Battery or Engine, describe real parts.
poweris typedPowerValue, and kilograms are a unit of mass. The checker evaluates units, so it underlines the value until the unit is a power unit such as[W].- A
doccomment is documentation that belongs to the element and is part of the model. A//note stays in the text only and is not part of the model.
9.2 Ports and Interfaces
- It conjugates the port: the engine's port has the same features as FuelPort with the directions reversed, so FuelPort's
out attribute flowRatearrives at the engine as an input. - A binding says the two features are the same: the powertrain's boundary port is the transmission's output. An interface usage connects two different ports, and its interface definition says which ports its ends accept.
- Holarch offers the interface definitions whose ends fit both ports. HighVoltageBus has the ends
source : PowerPortandload : ~PowerPort, which match the two ports.
9.3 Actions and Flows
- After the fork
split,supplyandproducestart as parallel branches; eachthenafter a fork starts a branch. The joinreadywaits for both before the next step. - The first is a succession: it orders the steps in time. The second is a flow: it carries a Fuel item from one step's output parameter to another step's input, and does not order the steps by itself.
- From
perform: each part that performs a step, such aspart redefines tank { perform trip.supply; }, gets a lane with the steps it performs.
9.4 States and Transitions
entry; then off;: the entry is followed by a succession tooff, so the state machine starts there. The view draws it as the dot.- Trigger: the signal StartRequest. Guard:
charge > 20. Target:electric. The short form starts at the state it follows,off. - The entry action runs when the state is entered, the do action while the state is active, and the exit action when the state is left.
- That the car exhibits this state machine: the car owns a usage of PowertrainStates, so its states are the car's states.
9.5 Requirements
- Every requirement that uses the name follows one edit, and the limit carries its unit, so the checker compares values with units.
- It redefines the
limitattribute that sedanMass inherits from CurbMass, giving this usage its own value. - Whether the sedan's values meet the constraints of carSpec. If the sedan's curb mass exceeds the limit, the Editor marks the satisfy and shows the compared values.
- No. Status, priority and verification method are Holarch data kept next to the model; they never change the text.
9.6 Verification and Traceability
- That this verification case verifies the requirement sedanMass. The RVTM lists the case against that requirement.
- The verdict is part of the model: an expression, here whether the curb mass is within the limit. Steps, results and the status of a test run are Holarch data kept next to the model.
satisfysays a design element, such as a part or an action, meets a requirement. A Derivation connects an original requirement to a requirement derived from it; it needsprivate import RequirementDerivation::*;.- Holarch writes a
satisfyinto the SysML text, so the trace is part of the model and shows in the Editor.
9.7 Constraints and Calculations
- A constraint definition states a condition over its parameters that holds or not, such as
mass <= limit. A calculation definition computes and returns a value, such asreturn ratio = power / mass;. - A parameter has no value yet. Bind every parameter to a value, for example
in mass = fleet.sedan.curbMass;. TBDin place of a value is not valid SysML. The metadata from Holarch'sHolarchMetadatapackage keeps the text valid; TBD and TBR specialize the standardStatusInfometadata, so other SysML v2 tools read them as status annotations.- It applies the calculation to a subject, such as the sedan, returns the result, and has an objective whose require constraint Holarch evaluates like any other constraint.
9.8 Variants and Configurations
- The first is a variation definition, a reusable set of choices: a usage typed by it, such as
part pack : BatteryPack;, is a variation point. The second is a variation usage, a point declared inside one design. - The rule
wallboxNeedsLargePackis broken: it says that the wallbox implies the large pack. The verdict names the rule, and the Editor reports the failed assertion. - Incomplete, naming the open point. While a point has no choice, a rule over it is neither met nor broken.
- The short name becomes a keyword, as in
#safetyCritical part controller : Controller;. It is an ordinary metadata usage, so other SysML v2 tools see it as metadata on the part.
Published by Holarch