Professional Documents
Culture Documents
Intro To The SysML v2 Language-Textual Notation
Intro To The SysML v2 Language-Textual Notation
Intro To The SysML v2 Language-Textual Notation
Release: 2022-12
2 Release 2022-12
SysML v2 Language Architecture SST
Declarative semantic base
Systems Modeling Language elements and domain-
(SysML) specific libraries modeled
using SysML
Documentation is a special
kind of comment that is
directly owned by the
element it documents. package 'Documentation Example' {
doc /* This is documentation of the owning
* package.
*/
// Definitions
part def Vehicle {
part eng : Engine;
}
part def Engine {
Parts can be specified part cyl : Cylinder[4..6];
outside the context of a }
specific part definition. The defined by relationship is a
part def Cylinder;
kind of generalization.
// Usages
part smallVehicle : Vehicle {
part redefines eng {
part redefines cyl[4];
}
} Parts inherit properties from
part bigVehicle : Vehicle { their definitions and can
part redefines eng { redefine them, to any level of
part redefines cyl[6]; nesting.
}
}
An interface definition is a
connection definition
whose ends are ports. interface def FuelInterface {
end supplierPort : FuelOutPort;
end consumerPort : FuelInPort;
}
«interface def»
WaterDelivery
suppliedBy : deliveredTo :
SpigotBank[1] hot hot Faucet[1..*]
cold cold
fuelTankPort engineFuelPort
tankAssy :
eng :
FuelTank Fuel Engine
Assembly
fuelSupply fuelSupply
flow of Fuel
Specifying the item type (e.g.,
from eng.engineFuelPort.fuelReturn
“of Fuel”) is optional.
to tankAssy.fuelTankPort.fuelReturn;
}
33 Last changed: 2022-07 (parameter declaration; removed ”flow from”) Release 2022-12
Action Decomposition SST
34 Last changed: 2022-07 (parameter declaration; removed ”flow from”) Release 2022-12
Conditional Succession (1) SST
then done;
References the end of the action
} as the target of a succession.
join joinNode;
then done; A join node waits for all its predecessors
} to happen before continuing.
for i in 1..powerProfile->size() {
An action may also be perform action dynamics : StraightLineDynamics {
performed by another in power = powerProfile[i];
This evaluates to the i'th
in mass = vehicleMass;
action (similar to a "call"). value of the powerProfile.
in delta_t = deltaT;
in x_in = position; in v_in = speed;
An assignment action sets out x_out; out v_out;
the value of a feature to the }
result of an expression at then assign position := dynamics.x_out;
the time of performance of then assign speed := dynamics.v_out;
then assign positions := The functions size and
the assignment. including come from the
positions->including(position);
} SequenceFunctions
} library package.
«accept»
action takePicture : TakePicture {
trigger action trigger accept scene : Scene;
Scene via viewPort
scene
= then action focus : Focus {
scene
in item scene = trigger.scene;
focus out item image;
image }
flow from focus.image to shoot.image;
image then action shoot : Shoot {
shoot in item image;
out item picture; This is an expression evaluating
picture
= } to the value to be sent.
picture
«send»
Show(picture) then send Show(shoot.picture) to screen;
to screen
}
The notation “Show(…)” means
A send action is an to create an instance of the This is also an expression,
outgoing transfer of values definition Show with the given evaluating to the target (in this
to a specific target. value for its nested attribute. case just a feature reference).
state on;
VehicleOnSignal accept VehicleOffSignal
then off;
}
on
VehicleOffSignal
state operationalStates {
entry; then off;
off
state off;
accept VehicleStartSignal
VehicleStartSignal then starting;
state starting;
accept VehicleOnSignal
starting
then on;
state on;
VehicleOnSignal accept VehicleOffSignal
then off;
} ! Transitions are not allowed
on
VehicleOffSignal between concurrent states.
state healthStates {
…
healthStates }
… }
state starting;
starting accept VehicleOnSignal A state entry, do or exit
then on; can reference an action
VehicleOnSignal defined elsewhere…
state on {
entry performSelfTest
{ in vehicle = operatingVehicle; }
on do action providePower { … }
exit action applyParkingBrake { … }
entry performSelfTest }
do action providePower accept VehicleOffSignal
exit action applyParkingBrake then off; … or the action can be
} defined within the state.
snapshot delivery;
A snapshot represents an
occurrence at a specific first delivery then ownership;
point in time (a time slice
with zero duration). timeslice ownership[0..*] ordered;
done is the name of the
snapshot junked = done;
} end-of-life snapshot of
Timeslices and snapshots any occurrence.
are suboccurrences.
«occurrence def»
! Sequence diagram CruiseControlInteraction
graphical notation is
purely illustrative. «part»
vehicle
Succession must be
message setSpeedMessage
event occurrence event occurrence specified explicitly for
of SetSpeed
setSpeedSent setSpeedReceived
events in different lifelines.
Succession is implicit between then
«occurrence»
cruiseControlInteraction_a : CruiseControlInteraction
«part»
vehicle_a
SetSpeed
send setSpeed() accept setSpeed This succession from the
then interaction may not actually
be satisfied by the realization.
SensedSpeed
accept SensedSpeed send SensedSpeed()
FuelCommand accept
send FuelCommand() FuelCommand
«occurrence»
cruiseControlInteraction_b : CruiseControlInteraction
«part»
vehicle_b
// Example usage
The totalMass default is not
import SI::kg; overridden for the nested carParts.
part c :> car {
attribute :>> simpleMass = 1000[kg];
part :>> engine {
attribute :>> simpleMass = 100[kg];
}
part attribute transmission {
attribute :>> simpleMass = 50[kg];
}
}
When computing the totalMass
of c, c.engine and c.transmission,
// c.totalMass --> 1150.0[kg] the relevant defaults are used.
attribute drag = Cd * v;
The calculation can include the
computation of intermediate values.
attribute friction = Cf * tm * v;
! There is no semicolon
whlpwr - drag - friction The calculation result expression must at the end of a result
} conform to the return type. expression.
calc def Acceleration { in tp: PowerValue; in tm : MassValue; in v: SpeedValue;
return : AccelerationValue = tp / (tm * v); The result expression can also be bound
}
directly to the return parameter.
calc def Velocity { in dt : TimeValue; in v0 : SpeedValue; in a : AccelValue;
return : SpeedValue = v0 + a * dt;
}
action straightLineDynamics {
in delta_t : TimeValue;
Values are bound to the in v_in : SpeedValue; in x_in : LengthValue;
parameters of calculation usages out v_out : SpeedValue; out x_out : LengthValue;
(similar to action parameters). calc acc : Acceleration {
in tp = Power(wheelPower, C_d, C_f, mass, v_in);
in tm = mass;
in v = v_in;
return a;
A calculation definition can also be
} invoked as an expression, with input
calc vel : Velocity { values given as arguments, evaluating
in dt = delta_t; to the result of the calculation.
in v0 = v_in;
in a = acc.a;
return v = v_out;
}
calc pos : Position { Calculation results can be
in dt = delta_t;
in x0 = x_in; referenced by name and/or bound
in v = vel.v; (like action output parameters).
return x = x_out; }
}
}
75 Last changed: 2022-07 (parameter declaration) Release 2022-12
Calculation Usages (2) SST
attribute def DynamicState {
attribute v: SpeedValue;
attribute x: LengthValue;
}
a == Acceleration(p, m, v_avg) and Note the use of the An action definition is inherently
v_f == Velocity(dt, v_i, a) and calculation definitions "causal" in the sense that outputs
x_f == Position(dt, x_i, v_avg) defined earlier. are determined in terms of inputs.
}
state maintenance {
assert constraint { TimeOf(maintenance) > vehicle.maintenanceTime }
assert constraint { TimeOf(maintenance) - TimeOf(normal.done) < 2 [s]
}
entry assign vehicle.maintenanceTime :=
vehicle.maintenanceTime + vehicle.maintenanceInterval;
}
accept MaintenanceDone
then normal;
assume constraint {
doc /* Fuel tank is empty. */
vehicle.fuelMass == 0[kg]
}
}
requirement vehicleSpecification {
doc /* Overall vehicle requirements group */
subject vehicle : Vehicle;
By default, the subject of grouped
require fullVehicleMassLimit; requirements is assumed to be the
require emptyVehicleMassLimit; same as that of the group.
}
Requirements can be
grouped by reference… part def Engine {
port clutchPort: ClutchPort;
perform action generateTorque: GenerateTorque;
}
The subject of a grouped
requirement engineSpecification { requirement can also be
…or by composition. doc /* Engine power requirements group */ bound explicitly.
subject engine : Engine;
assume constraint {
The analysis objective is specified as a
vehicle.wheelDiameter == 33['in’] and
vehicle.driveTrainEfficiency == 0.4 requirement, allowing both assumed
} and required constraints.
require constraint {
fuelEconomyResult > 30[mi / gallon]
}
}
…
The objective is a requirement on
} the result of the analysis case.
objective vehicleMassVerificationObjective {
verify vehicleMassRequirement; The requirements to be verified are declared in
} the verification case objective. The subject of
the verification case is automatically bound to
return verdict : VerdictKind;
} the subject of the verified requirements.
action collectData {
in part testVehicle : Vehicle = VehicleMassTest::testVehicle;
out massMeasured :> ISQ::mass;
}
action processData {
in massMeasured :> ISQ::mass = collectData.massMeasured;
PassIf is a utility function that out massProcessed :> ISQ::mass;
returns a pass or fail verdict }
depending on whether its action evaluateData {
argument is true or false. in massProcessed :> ISQ::mass = processData.massProcessed;
out verdict : VerdictKind =
PassIf(vehicleMassRequirement(
The use of named vehicle = testVehicle, This is a check of whether the
argument notation massActual = massProcessed)); requirement is satisfied for
here is optional. } the given parameter values.
return verdict : VerdictKind = evaluateData.verdict;
}
timeslice test1 {
! perform action :>> vehicleMassTest {
The keyword action is individual :>> testVehicle : TestVehicle1 {
required here to permit :>> mass = 2500[SI::kg];
the local redefinition. }
} The test on the individual
} TestVehicle1 should pass.
then timeslice test2 {
perform action :>> vehicleMassTest {
individual :>> testVehicle : TestVehicle2 {
:>> mass = 3000[SI::kg];
}
} The test on the individual
} TestVehicle2 should fail.
}
Actors may also be specified for use case def 'Enter Vehicle’ {
other kinds of cases and for subject vehicle : Vehicle;
requirements. actor driver : Person;
actor passengers : Person[0..4];
}
// Variability model
assert constraint {
(engine == engine::'4cylEngine’ and
transmission == transmission::manualTransmission) xor
A constraint can be used to (engine == engine::'6cylEngine’ and
model restrictions across the transmission == transmission::automaticTransmission)
choices that can be made. }
The operator xor means "exclusive or". So, this constraint
}
means "choose either a 4cylEngine and a manualTransmission,
or a 6cylEngine and an automaticTransmission".
dependency Schemata
from 'System Assembly'::'Storage Subsystem'
to 'Software Design'::MessageSchema, 'Software Design'::DataSchema;
}
metadata ToolExecution {
toolName = "ModelCenter"; The @ symbol is equivalent
uri = "aserv://localhost/Vehicle/Equation1";
}
to the metadata keyword.
A metadata annotation
contained in the body of in dt : ISQ::TimeValue {@ToolVariable {name = "deltaT";}}
a namespace (package, in a : ISQ:: AccelerationValue {@ToolVariable {name = "mass";}}
definition or usage) is, in v_in : ISQ:: VelocityValue {@ToolVariable {name = "v0";}}
by default, about that in x_in : ISQ:: LengthValue {@ToolVariable {name = "x0";}}
namespace.
out v_out : ISQ:: VelocityValue {@ToolVariable {name = "v";}}
out x_out : ISQ:: LengthValue {@ToolVariable {name = "x";}}
}
The view rendering can also be given A view usage specifies how the view is
in the view definition, in which case it to be rendered as a physical artifact.
will be the same for all usages of that
definition. But only view usages can
expose elements to be viewed.
datatype KeyValuePair {
feature key: Anything[0..*] ordered nonunique;
feature val: Anything[0..*] ordered nonunique;
}
feature pi : Real;
inv piPrecision {
RealFunctions::round(pi * 1E20) == 314159265358979323846.0
}
function includes {in seq1: Anything[0..*] ordered nonunique; in seq2: Anything[0..*] nonunique;
return : Boolean[1];
}
function excludes {in seq1: Anything[0..*] ordered nonunique; in seq2: Anything[0..*] nonunique;
return : Boolean[1];
}
function including {in seq: Anything[0..*] ordered nonunique; in values: Anything[0..*] ordered nonunique;
return : Anything[0..*] ordered nonunique;
}
function includingAt{in seq: Anything[0..*] ordered nonunique; in values: Anything[0..*] ordered nonunique;
in index: Positive[1]; return : Anything[0..*] ordered nonunique;
}
function excluding {in seq: Anything[0..*] ordered nonunique; in values: Anything[0..*] ordered nonunique;
return : Anything[0..*] ordered nonunique;
}
function excludingAt{in seq: Anything[0..*] ordered nonunique; in values: Anything[0..*] ordered nonunique;
in index: Positive[1]; return : Anything[0..*] ordered nonunique;
}
…
135 Last changed: 2022-09 (standard library package, additional functions) Release 2022-12
Sequence Functions (2) SST
standard library package SequenceFunctions {
…
behavior add {
inout seq: Anything[0..*] ordered nonunique; in values: Anything[0..*] ordered nonunique;
}
behavior addAt {
inout seq: Anything[0..*] ordered nonunique; in values: Anything[0..*] ordered nonunique;
in index: Positive[1];
}
behavior remove{
inout seq: Anything[0..*] ordered nonunique; in values: Anything[0..*];
}
behavior removeAt{
inout seq: Anything[0..*] ordered nonunique;
in startIndex: Positive[1]; in endIndex: Positive[1] default startIndex;
}
}
136 Last changed: 2022-09 (standard library package, additional functions) Release 2022-12
Collection Functions SST
import VectorValues::*;
…
}
function CartesianVectorOf
{in components: NumericalValue[1..*] ordered nonunique; return : CartesianVectorValue;}
function CartesianThreeVectorOf specializes CartesianVectorOf
{in components: Real[3] ordered nonunique; return : CartesianVectorValue;}
function 'and’
{in firstValue: Anything[0..*]; in expr secondValue[0..1]; {return : Boolean[1];} return : Boolean[1];}
function 'or’
{in firstValue: Anything[0..*]; in expr secondValue[0..1]; {return : Boolean[1];} return : Boolean[1];}
function 'implies’
{in firstValue: Anything[0..*]; in expr secondValue[0..1]; {return : Boolean[1];} return : Boolean[1];}
147 Last changed: 2022-09 (replaced "as" with "meta") Release 2022-12
Image Metadata SST
…
}
…
}
assert constraint {
( semiAxis1 == semiAxis2 ) &
( semiAxis2 == semiAxis3 ) }
}
}
…
}
…
}