Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package '15_01-Constants' {
private import MeasurementReferences::*;
private import SI::*;
private import RealFunctions::*;
/*
* Note: Value properties that are bound to specific values are constants and have the specified
* values in all contexts. It is not legal to redefine them.
*/
package 'Mathematical Constants' {
doc
/*
* Standard mathematical constants
*
* Irrational constants cannot be represented exactly with finite precision.
* However, they can be required to be implemented with a attribute that is accurate
* to at least a certain precision.
*
* (The decimal literals here should be interpreted as being fixed point and exact.)
*/

attribute e: Real {
assert constraint { round(e * 1E+20) == 2.7182818284590452E+20}
}
attribute pi: Real {
assert constraint { round(pi * 1E+20) == 3.1415926535897933E+20}
}
}
package 'Fundamental Physical Constants' {
doc
/*
* Standard fundamental physical constants
*
* Physical constants have a standard measured attribute to a finite precision.
*
* The reference source is:
* CODATA - Task Group on Fundamental Physical Constants (TGFC) - 2018 CODATA recommended values
* See https://codata.org/initiatives/strategic-programme/fundamental-physical-constants/
* For the actual values see https://pml.nist.gov/cuu/Constants/
*/

attribute 'fine structure constant': DimensionOneValue = 0.0072973525693[one];
attribute 'electron to proton mass ratio': DimensionOneValue = 0.000544617021487[one];
attribute 'speed of light in vacuum': SpeedValue = 299792458[m / s];
}
package 'Global Context' {
attribute 'nominal earth gravitational acceleration': AccelerationValue = 9.80665['m⋅s⁻²'];
}
package 'Model X Context' {
attribute 'amplifier gain': DimensionOneValue = 3.5[one];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package '15_02-Basic Value Properties' {
private import ScalarValues::*;
attribute def LengthValue :> Real {
doc
/*
* Real world user models would use a quantity type
* from the library model. A attribute def is defined
* here to show that it is possible.
*/

}
part def Tire {
attribute manufacturer: String;
attribute hubDiameter: LengthValue;
attribute width: Integer;
}
part frenchTire: Tire {
attribute :>> manufacturer = "Michelin";
attribute :>> hubDiameter = 18.0;
attribute :>> width = 245;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package '15_03-Value Expression' {
private import SI::*;
private import USCU::*;
part def Vehicle_1 {
attribute mass: MassValue = 1200[kg];
attribute length: LengthValue = 4.82[m];
part leftFrontWheel: Wheel;
part rightFrontWheel: Wheel;
}
part def Wheel {
attribute hubDiameter: LengthValue = 18['in'];
attribute width: LengthValue = 245[mm];
attribute outerDiameter: LengthValue = (hubDiameter + (2* tire.height))[mm] {
doc
/*
* This binds 'outDiameter' to the result of a computed attribute.
* There is no need to mark it as "derived".
*/

}
part tire: Tire[1];
}
part def Tire {
attribute profileDepth: LengthValue default = 6.0[mm];
constraint hasLegalProfileDepth { profileDepth >= 3.5[mm] }
attribute height: LengthValue = 45[mm];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package '15_04-Logical Expressions' {
private import ScalarValues::*;
part def Engine;
part def '4CylEngine' :> Engine;
part def '6CylEngine' :> Engine;
part def Transmission;
part def ManualTransmission :> Transmission;
part def AutomaticTransmission :> Transmission;
part def Vehicle {
attribute isHighPerformance: Boolean;
part engine: Engine[1];
part transmission: Transmission[1];
assert constraint { if isHighPerformance ? engine istype '6CylEngine' else engine istype '4CylEngine' }
assert constraint { (engine istype '4CylEngine' and transmission istype ManualTransmission) xor (engine istype '6CylEngine' and transmission istype AutomaticTransmission) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package '15_05-Unification of Expression and Constraint Definition' {
private import '15_03-Value Expression'::*;
private import ControlFunctions::forAll;
private import SI::*;
constraint def DiscBrakeConstraint { in wheelAssy: WheelAssy[4]; wheelAssy->forAll { in w : WheelAssy; 2* w.discBrakeAssy.radius < w.wheel.outerDiameter } }
constraint def DiscBrakeFitConstraint_Alt { in discBrakeAssy: DiscBrakeAssy[1]; in wheel: Wheel[1]; 2* discBrakeAssy.radius < wheel.outerDiameter }
part def Vehicle_2 {
attribute mass: MassValue[1] = 1200[kg];
attribute length: LengthValue[1] = 4.82[m];
part wheelAssy: WheelAssy[4];
constraint discBrakeConstraint: DiscBrakeConstraint { doc /*
* This constraint is computed, but not asserted. This means a tool can identify
* when it is violated without the model being inconsistent.
*/
in wheelAssy = Vehicle_2::wheelAssy; }
}
part def WheelAssy {
part wheel: Wheel[1];
part discBrakeAssy: DiscBrakeAssy[1];
assert constraint discBrakeFitConstraint_Alt: DiscBrakeFitConstraint_Alt { doc /*
* This constraint is asserted to be true, which means that the model
* is inconsistent if it the constraint is violated.
*/
in discBrakeAssy = WheelAssy::discBrakeAssy; in wheel = WheelAssy::wheel; }
}
part def DiscBrakeAssy {
attribute radius: LengthValue[1] = 95[mm];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package '15_06-System of Quantities' {
private import ISQ::*;
/*
* A System of Quantities is represented by a model library package.
*
* Its structure is modeled after the International System of Quantities (ISQ):
* - Quantity dimension is defined as the product of powers of a selected set of base quantities.
* - A system of quantities is multi-dimensional space spanned by the powers of its base quantities.
* - Any base quantity is modeled as a specialization of a SimpleUnit. Such a specialized SimpleUnit defines one base unit vector
* (with power one by definition), e.g. MassUnit with symbol M, that establishes a base quantity dimension for the system of quantities,
* without committing yet to a particular choice of measurement unit.
* - To complete the system of quantities any number of derived quantities can be added.
* - A derived quantity is modeled as a specialization of a DerivedUnit. A DerivedUnit is defined in terms of so-called UnitPowerFactors.
* Each UnitPowerFactor is a combination of a base (or other derived) quantity and an exponent.
* - As an example the AccelerationUnit (specialization of DerivedUnit) can be defined as the combination of LengthUnit (symbol L)
* to the power 1 and TimeUnit (symbol T) to the power -2, so having quantity dimension L¹⋅T⁻².
* - A quantity of dimension one is defined as a derived quantity for which the effective exponent for each
* of its base quantity power factors is zero. Historically a quantity of dimension one was also called a dimensionless quantity.
* - A quantity of dimension one may be defined by adding all quantity power factors that cancel out by having positive and negative
* exponents. Doing so enables distinction between different 'kinds of' quantities of dimension one, e.g:
* angle (L¹⋅L⁻¹), mass ratio (L¹⋅L⁻¹), power ratio (L²⋅M⋅T⁻³⋅L⁻²⋅M⁻¹⋅T³), Mach number (L¹⋅T⁻¹⋅L⁻¹⋅T¹).
*
* The International System of Quantities (ISQ) as defined in ISO/IEC 80000 is added as a predefined model library to SysML v2.
* However, this does not prevent to model any other system of quantities in another model library and use it.
*/
/*
* Above capabilities were implemented in:
* - standard library Quantities:
* TensorQuantityValue, VectorQuantityValue, ScalarQuantityValue,
* tensorQuantities, vectorQuantities, scalarQuantities,
* SystemOfQuantities
* - standard library MeasurementReferences:
* TensorMeasurementReference, VectorMeasurementReference, ScalarMeasurementReference,
* SystemOfUnits
* - standard library ISQBase:
* attribute <isq> 'International System of Quantities': SystemOfQuantities in ISQBase
*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package '15_07-System of Units and Scales' {
private import ISQ::*;
private import USCU::*;
/*
* A System of Units and Scales is represented by a model library package.
*
* Its structure is modeled after the International System of Units -- Système Internationale d'Unités, abbreviated to SI -- as defined in ISO/IEC 80000:
* - Measurement units and scales are generalized to a common super type MeasurementReference.
* - A particular quantity is modeled as the tuple of a numerical value (i.e. a mathematical number) and a MeasurementReference.
* - An actual measurement unit is modeled as a usage of a specialization of either SimpleUnit or DerivedUnit, e.g. TimeUnit or ForceUnit,
* see the SI package.
* - The quantity dimension of the actual unit usage must match the quantity dimension of the generic quantity unit definition that it is a usage of.
* - A system of units and scales must define exactly one selected base unit for each base quantity in the associated system of quantities. The collection of
* base units forms the foundation for automated quantity value conversion between any pair of compatible units and/or scales.
* - If only a measurement unit is used on a quantity value, it implies expression on a ratio scale, in other words only the ratio between the actual quantity value,
* and the defined unit value is of importance. On ratio scales for one kind of quantity that only differ in their unit (e.g. metre and inch)
* zero is zero no matter what unit is selected.
* - A unit may carry a conversion factor definition w.r.t. to another reference unit. It can be a conversion by convention (e.g. between metre and foot) or
* via an ISO/IEC 80000 prefix symbol that indicates a decimal or binary multiple or sub-multiple (e.g. kilo, nano, mega, kibi, mebi, ...). See package SIPrefixes.
* - In addition to measurement units / ratio scales also other types of measurement scales are supported. The additional scales are:
* - ordinal scales (e.g. Beaufort wind force, Richter Scale, Rockwell C hardness scale),
* - interval scales (e.g. absolute temperature in deg C or F),
* - cyclic ratio scales (e.g. rotation angle with modulus 360 degree),
* - logarithmic scales (e.g. dB(A) or dBA sound pressure level w.r.t. a reference ambient pressure, dB(m) or dBm power ratio w.r.t. 1 mW).
* - Any base unit quantity is modeled as a specialization of a SimpleUnit. This specialized SimpleUnit (e.g. MassUnit) defines one base unit vector (with power one by definition)
* that establishes a base quantity dimension for the system of quantities, without committing yet to a particular choice of measurement unit.
*
* The International System of Units (SI) as defined in ISO/IEC 80000 as well as the US Customary System of Units as defined by NIST SP 811
* are added as predefined model libraries to SysML v2.
* However, this does not prevent to model any other system of units and scales in another model library and use it.
*/
/*
* Above capabilities were implemented in:
* - standard library MeasurementReferences:
* TensorMeasurementReference, VectorMeasurementReference, ScalarMeasurementReference,
* MeasurementUnit, OrdinalScale, IntervalScale, CyclicRatioScale, LogarithmicScale,
* SystemOfUnits
* - standard library SI:
* attribute <si> 'ISO/IEC 80000 International System of Units' : SystemOfUnits
* :>> systemOfQuantities = isq;
* :>> baseUnits = (m, kg, s, A, K, mol, cd);
* }
*/
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package '15_08-Range Restriction' {
private import ISQ::*;
private import SI::*;
private import '15_01-Constants'::'Mathematical Constants'::pi;
part def HeadLightsTiltKnob {
attribute headLightsTile: LightBeamTiltAngleValue[1];
}
attribute def LightBeamTiltAngleValue :> AngularMeasureValue {
attribute angle: LightBeamTiltAngleValue :>> self {
doc
/*
* Tilt angle shall be limited to the range between 50 and 80 degrees (inclusive).
*/

}
assert constraint { angle >= 50['°'] and angle <= 80['°'] }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package '15.10-Primitive Data Types' {
/*
* Primitive data types are defined in normative model libraries.
* Any more specialized data types can be declared in user-defined
* model libraries or models as needed.
*/
private import ScalarValues::Integer {
doc
/*
* The unqualified Integer is signed, in line with integer numbers in mathematics.
*/

}
private import ScalarValues::Natural;
attribute def UnsignedInteger :> Natural {
doc
/* Mathematically, unsigned integers are just natural numbers (non-negative integers). */
}
private import ScalarValues::Real {
doc
/*
* The unqualified Real is signed, in line with real numbers in mathematics.
*/

}
attribute def UnsignedReal :> Real {
doc
/*
* Example of restriction of the base Real datatype.
*/

attribute x: Real :>> self;
assert constraint { x >= 0.0}
}
private import ScalarValues::String {
doc
/*
* String attributes are sequences of characters.
*/

}
private import ScalarValues::Boolean {
doc
/*
* Boolean type has two legal attributes: true, false.
*/

}
private import Time::DateTime;
enum def ConditionColor {
doc
/*
* Enumerations are defined as an implicit restriction of the extent of the
* enumeration type to the listed enumeration values.
* Note: Enumerations are currently limited to attributes.
*/

enum red;
enum yellow;
enum green;
}
attribute def ConditionLevel {
attribute associatedColor: ConditionColor;
}
enum def SeverityEnum :> ConditionLevel {
enum danger {
:>> associatedColor = ConditionColor::red;
}
enum warning {
:>> associatedColor = ConditionColor::yellow;
}
enum normal {
:>> associatedColor = ConditionColor::green;
}
}
attribute def Diameter :> ISQ::LengthValue;
enum def DiameterChoice :> Diameter {
enum small = 60[SI::mm];
enum medium = 70[SI::mm];
enum large = 80[SI::mm];
}
attribute aperatureDiameter: DiameterChoice = DiameterChoice::small;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package '15_11-Variable Length Collection Types' {
private import ScalarValues::*;
private import Collections::*;
part def SparePart;
part def Person;
/* Examples of declaring syntactic sugar-like names for instantiating collection types. */
attribute def 'Bag<SparePart>' :> Bag {
ref part :>> elements : SparePart;
}
attribute def 'List<Integer>' :> List {
ref value :>> elements : Integer;
}
attribute def 'Set<String>' :> Set {
attribute :>> elements : String;
}
attribute def 'OrderedSet<Person>' :> OrderedSet {
ref part :>> elements : Person;
}
attribute def 'List<Set<Person>>' :> List {
attribute :>> elements : Set {
ref part :>> elements : Person;
}
}
attribute def 'Array<Real>[4]' :> Array {
attribute :>> elements : Real;
attribute :>> dimensions = 4;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package '15_12-Compound Value Type' {
private import ScalarValues::*;
private import USCU::'in';
/*
* Real world user models would use quantity and vector types
* from library models. They are included here for the purpose
* of showing how such attribute defs can be defined.
*/
attribute def PositionVector {
attribute x: Real[1];
attribute y: Real[1];
attribute z: Real[1];
}
attribute def LengthValue :> Real;
attribute def TireInfo {
attribute manufacturer: String;
attribute hubDiameter: LengthValue;
attribute width: Integer;
attribute placement: PositionVector[0..1];
}
attribute frenchTireInfo: TireInfo {
attribute :>> manufacturer = "Michelin";
attribute :>> hubDiameter = 18.0['in'];
attribute :>> width = 245;
}
}
Loading
Loading