16.2. Requirements
A requirement definition is a kind of constraint definition that specifies a stakeholder-imposed constraint on a design element called subject. A design solution must satisfy the constraint to be a valid solution. Requirements may be specified informally using text statements (commonly known as "shall" statements) or formally using constraint expressions. The subject of a requirement is specified as the first parameter of a requirement definition.
requirement def HeatingSufficiency {
subject room : Room;
attribute ambientTemp : Real; // outside temperature [°C]
attribute targetTemp : Real; // desired int. temp. [°C]
doc /* The heat loss of a room shall not exceed the
power of its heater. */
require constraint {
room.heater.power > HeatLoss( room.areaOfExtWalls,
ambientTemp, targetTemp)
}
}A requirement definition is used for typing requirement properties, which may bind its attributes to attributes of a context type and possibly define preconditions for the requirement in the form of assume constraints.
This requirement definition is used for typing the Home requirement property heatSuff5, which defines a precondition (ambientTemp > 5) for the requirement in the form of an assume constraint:
part def Home {
attribute ambientTemp : Real; // [°C]
attribute targetTemp : Real; // [°C]
...
requirement heatSuff5: HeatingSufficiency {
attribute :>> ambientTemp = Home::ambientTemp;
attribute :>> targetTemp = Home::targetTemp;
assume constraint { ambientTemp > 5 }
}
...
}A requirement satisfaction assertion states that a given requirement is satisfied by a subject. For instance, the satisfaction assertion satisfy heatSuff5 can be added for the livingRoom as the requirement's subject:
part def Home {
attribute ambientTemp : Real; // [°C]
attribute targetTemp : Real; // [°C]
part livingRoom : Room {
attribute areaOfExtWalls : Real = 10.0; // [m²]
part heater : Device {
attribute redefines ratedCurrent = 20 [A];
attribute redefines power = 2000.0; // [W]
}
satisfy heatSuff5;
}
requirement heatSuff5: HeatingSufficiency {
attribute :>> ambientTemp = Home::ambientTemp;
attribute :>> targetTemp = Home::targetTemp;
assume constraint { ambientTemp > 5 }
}
...
}