Holarch

Training · Track 9. SysML v2 Fundamentals

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):

  1. Create the Hybrid Car demo: Manage Projects → Project Files ▾ → New Demo Project → Hybrid Car (SysML v2). Open Model → Editor and the package Vehicles.
  2. Below enum def FuelKind, add enum def CoolingMode { enum passive; enum active; }.
  3. Below part def Body, choose Insert ▾ → Part Definition and complete part def Radiator :> Component with attribute redefines mass = 8 [kg];, attribute coolantVolume : VolumeValue; (type Volu and accept VolumeValue from the completion list with Enter) and attribute mode : CoolingMode;.
  4. Change the mass to 8 [W], point at the underline to read the message, then change it back to 8 [kg].
  5. In part def Powertrain, add part radiator : Radiator;. Then place the cursor on coolantVolume, press F2 and rename it to coolantCapacity.
  6. 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

  1. In part def Battery :> Component { attribute redefines mass = 45 [kg]; }, what do :> and redefines each do?
  2. Why is Component declared abstract part def?
  3. Why does attribute redefines power = 60 [kg]; give an error?
  4. 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):

  1. 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.
  2. Below interface def HighVoltageBus, add interface def ControlLink { end commander : ~ControlPort; end unit : ControlPort; }.
  3. In part def Powertrain, replace connect controller.engineCtl to engine.ecu; with interface engineControl : ControlLink connect controller.engineCtl to engine.ecu;, and add part auxBattery : Battery; after part battery : Battery;.
  4. Open Architecture → Interconnection Views and the view powertrainConnections. Drag from the handle of auxBattery's port powerOut to the motor's port powerIn and choose Interface : HighVoltageBus.
  5. Select the new line and enter auxBus as its Name in the inspector. Then open Model → Editor and find the line Holarch wrote in Powertrain.

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

  1. The engine has port fuelIn : ~FuelPort;. What does the tilde change?
  2. What is the difference between bind output = transmission.output; and interface fuel : FuelLine connect tank.fuelOut to engine.fuelIn;?
  3. Why does the view offer Interface : HighVoltageBus when you drag from a battery's powerOut to the motor's powerIn?

9.3 Actions and Flows

Watch chapter 9.3 (4:31)

Practice

On the Hybrid Car demo project (SysML v2):

  1. 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.
  2. Below action def <'F.3'> DriveWheels, add action def <'F.4'> Refuel { in attribute fuelDemand : Real; out item fuel : Fuel; }.
  3. Open Behavior → FFBD, click + New Diagram, choose Refuel and click Create. In the Add panel, type Open Filler Door and press Enter, then Pump Fuel and Close Filler Door.
  4. Open Model → Editor and find Refuel: the FFBD wrote its three steps and the successions between them.
  5. Open Behavior → Action Flows and the view driveCycleFlow. Find the lane that holds brake, then find the perform line in DrivenCar that puts it there.
  6. 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

  1. In first start then split; fork split; then supply; then produce;, which steps run in parallel, and what brings them back together?
  2. What is the difference between first supply then ready; and flow of Fuel from supply.fuel to produce.fuel;?
  3. 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):

  1. 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.
  2. After attribute def Unplug;, add attribute def FaultDetected;.
  3. Before the closing brace of state def PowertrainStates, add state limpHome { entry action warnDriver; do action driveLimited; } and transition limpStop first limpHome accept StopRequest then off;.
  4. Open Behavior → State Machines, click + New Diagram, choose PowertrainStates under Shows and click Create.
  5. Select electric and drag from its handle to limpHome; drop on Transition. In the transition panel, enter the Name electricFault and the Trigger FaultDetected, 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

  1. What makes off the initial state of PowertrainStates?
  2. After state off; comes accept StartRequest if charge > 20 then electric;. Name its trigger, guard, source and target.
  3. When do a state's entry, do and exit actions run?
  4. What does exhibit state powertrainStates : PowertrainStates; in DrivenCar say?

9.5 Requirements

Watch chapter 9.5 (4:15)

Practice

On the Hybrid Car demo project (SysML v2):

  1. 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.
  2. After attribute minElectricRange, add attribute minTopSpeed : SpeedValue = 180 [km/h];.
  3. Below requirement def <'VR-5'> ChargeTime, choose Insert ▾ → Requirement Definition and write <'VR-8'> TopSpeed with the statement The sports car shall reach at least the minimum top speed., the subject car : SportCar and require constraint { car.topSpeed >= minTopSpeed }.
  4. After the other satisfy lines, add satisfy requirement roadsterSpeed : TopSpeed by fleet.roadster;.
  5. Change minTopSpeed to 220 [km/h]. Point at the mark the Editor puts on the satisfy to read the values it compared, then press ⌘Z / Ctrl+Z.
  6. 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

  1. Why keep limits such as maxCurbMass as named attributes instead of writing the number in each constraint?
  2. In requirement <'VR-1.1'> sedanMass : CurbMass { attribute :>> limit = maxCurbMass; }, what does :>> do?
  3. What does satisfy carSpec by fleet.sedan; let Holarch check?
  4. 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):

  1. 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.
  2. After verification <'VC-1.1'> sedanWeighing, add verification def <'VC-2'> BatteryWeighing { subject battery : Battery; objective { verify batteryMassLimit; } return verdict : Boolean = battery.mass <= 50 [kg]; } and verification <'VC-2.1'> sedanBatteryWeighing : BatteryWeighing { subject battery = fleet.sedan.powertrain.battery; }.
  3. Open Verification → Verification Cases. In the row of the new case, click + Steps, then + Add Step, type Weigh the battery on a bench scale under Action, click Apply, and click Passed in its status buttons.
  4. Open Verification → RVTM and find VR-6 batteryMassLimit with the new case and its status.
  5. Open Verification → Traceability Matrix, show requirements as rows and the class Action as columns, click the cell where sedanAcceleration meets accelerate, and choose satisfied by.
  6. At the end of the package, add requirement <'VR-9'> tankVolume { doc /* The fuel tank shall hold at least 40 L. */ subject tank : FuelTank; } and connection 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

  1. In objective massObjective { verify carSpec.sedanMass; }, what does verify say, and where do you see it?
  2. What is the difference between a verification case's verdict and the status on the Verification Cases page?
  3. When do you use satisfy, and when a Derivation?
  4. 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):

  1. 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.
  2. After constraint def SpeedLimit, add constraint sedanBatteryCheck : MassLimit { in mass = fleet.sedan.powertrain.battery.mass; in limit = 50 [kg]; }.
  3. On the Diagrams page, click + New Diagram, choose Parametric View and VehicleRequirements under Shows, and click Create. The new check passes: 48 kg is within 50 kg.
  4. In the package Vehicles, change the sedan battery's mass to 52 [kg]; the view shows the check failing. Press ⌘Z / Ctrl+Z, then click Solve All to check every constraint again.
  5. In requirement def <'VR-2'> Acceleration, replace attribute zeroToHundred : TimeValue; with attribute 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.
  6. 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

  1. What is the difference between a constraint def and a calc def?
  2. A constraint in the Parametric View shows Needs input. What is missing?
  3. Why mark an open value with #TBD or @TBD { … } instead of writing TBD as the value?
  4. 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):

  1. 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 imports HolarchVariability.
  2. In part def CarLine, after the charger variation, add variation part rims : Wheel { variant part steelRims : Wheel; variant part alloyRims : Wheel { attribute :>> mass = 18 [kg]; } }. The Editor notes that the three configurations have not chosen rims yet.
  3. After wallboxNeedsLargePack, add the rule assert constraint alloyNeedsLargePack { rims == rims::alloyRims implies pack == BatteryPack::largePack }.
  4. Open Model → Browser and select selfChargingHybrid. In the inspector's Configuration section, choose steelRims for rims; choose alloyRims for plugInHybrid and longRangeHybrid. Then try alloyRims on selfChargingHybrid, read the verdict, and press ⌘Z / Ctrl+Z.
  5. Open the row menu (⋯) of CarLine and choose New Configuration…. Name it cityHybrid, choose standardPack, noCharger and steelRims, check that the verdict is Valid, and click Create.
  6. Click View as ▾ in the top bar and choose cityHybrid, then open the view carLineVariants from 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

  1. What is the difference between variation part def BatteryPack { … } and variation part charger : Component { … }?
  2. plugInHybrid chooses BatteryPack::standardPack and charger::wallbox. What happens, and why?
  3. A configuration has not chosen a variant for every point yet. What is its verdict?
  4. What does metadata def <safetyCritical> SafetyCritical let you write, and how do other SysML v2 tools see it?

Answer key

9.1 Definitions and Attributes

  1. :> makes Battery a specialization of Component, so it inherits mass, partNumber and power. redefines replaces the inherited mass in Battery with its own feature, here bound to 45 kg.
  2. 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.
  3. power is typed PowerValue, 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].
  4. A doc comment 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

  1. It conjugates the port: the engine's port has the same features as FuelPort with the directions reversed, so FuelPort's out attribute flowRate arrives at the engine as an input.
  2. 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.
  3. Holarch offers the interface definitions whose ends fit both ports. HighVoltageBus has the ends source : PowerPort and load : ~PowerPort, which match the two ports.

9.3 Actions and Flows

  1. After the fork split, supply and produce start as parallel branches; each then after a fork starts a branch. The join ready waits for both before the next step.
  2. 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.
  3. From perform: each part that performs a step, such as part redefines tank { perform trip.supply; }, gets a lane with the steps it performs.

9.4 States and Transitions

  1. entry; then off;: the entry is followed by a succession to off, so the state machine starts there. The view draws it as the dot.
  2. Trigger: the signal StartRequest. Guard: charge > 20. Target: electric. The short form starts at the state it follows, off.
  3. 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.
  4. 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

  1. Every requirement that uses the name follows one edit, and the limit carries its unit, so the checker compares values with units.
  2. It redefines the limit attribute that sedanMass inherits from CurbMass, giving this usage its own value.
  3. 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.
  4. No. Status, priority and verification method are Holarch data kept next to the model; they never change the text.

9.6 Verification and Traceability

  1. That this verification case verifies the requirement sedanMass. The RVTM lists the case against that requirement.
  2. 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.
  3. satisfy says 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 needs private import RequirementDerivation::*;.
  4. Holarch writes a satisfy into the SysML text, so the trace is part of the model and shows in the Editor.

9.7 Constraints and Calculations

  1. 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 as return ratio = power / mass;.
  2. A parameter has no value yet. Bind every parameter to a value, for example in mass = fleet.sedan.curbMass;.
  3. TBD in place of a value is not valid SysML. The metadata from Holarch's HolarchMetadata package keeps the text valid; TBD and TBR specialize the standard StatusInfo metadata, so other SysML v2 tools read them as status annotations.
  4. 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

  1. 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.
  2. The rule wallboxNeedsLargePack is broken: it says that the wallbox implies the large pack. The verdict names the rule, and the Editor reports the failed assertion.
  3. Incomplete, naming the open point. While a point has no choice, a rule over it is neither met nor broken.
  4. 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