PRISM
All lessonsLesson 8 of 9 · about 25 minutes

Requirements

Learn how SysML v2 describes what a system has to achieve: requirement def with doc, subject and require constraint, using a requirement with an identifier, and assigning it with satisfy to the part that satisfies it. With exercises, for beginners and SysML v1 users.

After this lesson you can

  • Define a requirement with text, subject and condition using requirement def
  • Use a requirement with an identifier and set its value
  • State with satisfy which part satisfies a requirement
  • Say what satisfy asserts and what it does not check

The machine is described: its parts, its connections, its process and its states. What is still open is what it has to achieve. For that SysML v2 has requirements. The example is a requirement on the boiler of the invented coffee machine: the water reaches 92 °C within 60 seconds.

Defining a requirement: requirement def

A requirement def defines a kind of requirement. It has three components:

  • doc is the text for people.
  • subject names the thing the requirement is about, here a Boiler.
  • require constraint is the condition that has to hold. It stands in curly braces and is an expression: the heat-up time of the boiler is at most the allowed time.

The allowed time is an attribute of the requirement, maxHeatUpTime. Only the usage sets the value. That way the definition applies to any limit.

// Excerpt of the coffee machine model
requirement def HeatUpRequirement {
    doc /* The boiler reaches its brewing temperature within the allowed time. */
    subject boiler : Boiler;
    attribute maxHeatUpTime : DurationValue;
    require constraint { boiler.heatUpTime <= maxHeatUpTime }
}

Using a requirement: identifier and value

A usage starts with requirement, names the definition and sets the value. In angle brackets in front stands the identifier, here <'REQ-1'>. That is the short name of the element: it stays even when the name changes, and tools show it in lists and diagrams.

The text of the usage describes this one case. It may write °C because it is only text. In the model itself the temperature is in kelvin, as explained in lesson 2: the boiler in the download has brewTemp = 365.15 [K], which is 92 °C. The attribute heatUpTime is the time until the water reaches that temperature.

// Excerpt of the coffee machine model
requirement <'REQ-1'> heatUp : HeatUpRequirement {
    doc /* Water reaches 92 °C within 60 s. */
    attribute :>> maxHeatUpTime = 60 [s];
}

Who satisfies it: satisfy

satisfy heatUp by machine.boiler; says that the boiler of the machine is meant to satisfy the requirement heatUp. The by names the satisfier and thereby binds the subject of the requirement: machine.boiler is a Boiler, so it fits the subject. The machine itself is a part, a usage of the definition: part machine : CoffeeMachine;.

A satisfy is an assertion in the model, not evidence. Whether the boiler really manages the time is shown only by a test or a calculation. A tool can, however, see which requirements already have a satisfier and which do not.

// Excerpt of the coffee machine model
part machine : CoffeeMachine;

satisfy heatUp by machine.boiler;

Our model so far

The machine with one requirement on the boiler. A second requirement is still missing: the coffee should be ready after at most 30 seconds. The brew unit has an attribute brewTime for that. Writing the requirement is your task below.

// The coffee machine model of this lesson
package CoffeeMachine {
    private import ISQ::*;
    private import SI::*;

    part def Boiler {
        attribute brewTemp : TemperatureValue = 365.15 [K];
        attribute heatUpTime : DurationValue;
    }

    part def BrewUnit {
        attribute brewTime : DurationValue = 25 [s];
    }

    part def CoffeeMachine {
        part boiler : Boiler;
        part brewUnit : BrewUnit;
    }

    part machine : CoffeeMachine;

    requirement def HeatUpRequirement {
        doc /* The boiler reaches its brewing temperature within the allowed time. */
        subject boiler : Boiler;
        attribute maxHeatUpTime : DurationValue;
        require constraint { boiler.heatUpTime <= maxHeatUpTime }
    }

    requirement <'REQ-1'> heatUp : HeatUpRequirement {
        doc /* Water reaches 92 °C within 60 s. */
        attribute :>> maxHeatUpTime = 60 [s];
    }

    satisfy heatUp by machine.boiler;
}

Source

Statements follow the OMG SysML v2 specification, Part 1 (Language Specification), in the clause on requirements (requirement definitions and usages, subject, require constraint, satisfy requirement, short names). PRISM reads these constructs and draws the satisfy in the diagram. PRISM does not evaluate the condition in require constraint, nor the quantities and units from the standard library (lesson 2).

Try it

This is the coffee machine model of the lesson with its first requirement. The diagram is a traceability view: the requirement REQ-1 is on the left, the part that satisfies it on the right, and the dashed line is the satisfy. Edit the text; the diagram redraws while you type. Everything runs in your browser, nothing is sent anywhere. At the end of the page you can download the file and open it in any tool that reads SysML v2 textual notation.

The editor loads when you scroll here.

The editor contains open-source components. Third-party notices · Source offer

Exercises

10 short exercises. Every answer gets feedback right away. Exercises you get wrong come back at the end. Your progress stays in this browser.

Exercise 1 of 10

What sets doc apart from require constraint in a requirement?

requirement def HeatUpRequirement {
    doc /* The boiler reaches its brewing temperature within the allowed time. */
    subject boiler : Boiler;
    attribute maxHeatUpTime : DurationValue;
    require constraint { boiler.heatUpTime <= maxHeatUpTime }
}

Exercise 2 of 10

Match each SysML v1 term with its counterpart in SysML v2.

SysML v1SysML v2

Requirement
Property text
Property id
Dependency «satisfy»

Exercise 3 of 10

Which keyword assigns the requirement to the boiler?

part machine : CoffeeMachine;

___ heatUp by machine.boiler;

Exercise 4 of 10

Tap the line that is not valid SysML v2.

package CoffeeMachine {
    requirement def HeatUpRequirement;
    requirement <REQ-1> heatUp : HeatUpRequirement {
        doc /* Water reaches 92 °C within 60 s. */
    }
}

Tap a line, or move to it with the Tab key and press Enter.

Exercise 5 of 10

Put the pieces in the order of the line that assigns the requirement heatUp to the boiler of the machine.

Drag the pieces, or use the arrow buttons.

  • machine.boiler
  • ;
  • heatUp
  • by
  • satisfy

Exercise 6 of 10

What does satisfy heatUp by machine.boiler; mean?

Exercise 7 of 10

Which line sets the limit to 30 seconds for this usage?

requirement <'REQ-2'> brewTime : BrewTimeRequirement {
    doc /* Coffee is ready within 30 s. */
}

Exercise 8 of 10

What does subject boiler : Boiler; say in a requirement?

requirement def HeatUpRequirement {
    subject boiler : Boiler;
}

Exercise 9 of 10

Type the keyword that introduces the formal condition of a requirement.

requirement def HeatUpRequirement {
    subject boiler : Boiler;
    attribute maxHeatUpTime : DurationValue;
    require ___ { boiler.heatUpTime <= maxHeatUpTime }
}

Exercise 10 of 10

The doc text says 92 °C, but the boiler has 365.15 [K]. Why?

Take the model with you

The coffee machine model as a SysML v2 text file.

Download coffee-machine.sysml

See it as a diagram

PRISM turns SysML v2 text like this into diagrams and views. Try it on the sample model.

Try it now
Next lesson

Allocation and views

Which part takes over which action, and how to cut targeted views out of a model.