diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_01-Constants.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_01-Constants.sysml new file mode 100644 index 00000000..c2a91542 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_01-Constants.sysml @@ -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]; + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_02-Basic Value Properties.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_02-Basic Value Properties.sysml new file mode 100644 index 00000000..64eb2959 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_02-Basic Value Properties.sysml @@ -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; + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_03-Value Expression.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_03-Value Expression.sysml new file mode 100644 index 00000000..0a752a56 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_03-Value Expression.sysml @@ -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]; + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_04-Logical Expressions.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_04-Logical Expressions.sysml new file mode 100644 index 00000000..f4208a76 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_04-Logical Expressions.sysml @@ -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) } + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_05-Unification of Expression and Constraint Definition.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_05-Unification of Expression and Constraint Definition.sysml new file mode 100644 index 00000000..f48f52bb --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_05-Unification of Expression and Constraint Definition.sysml @@ -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]; + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_06-System of Quantities.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_06-System of Quantities.sysml new file mode 100644 index 00000000..622197b6 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_06-System of Quantities.sysml @@ -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 'International System of Quantities': SystemOfQuantities in ISQBase + */ +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_07-System of Units and Scales.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_07-System of Units and Scales.sysml new file mode 100644 index 00000000..3bcd8857 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_07-System of Units and Scales.sysml @@ -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 'ISO/IEC 80000 International System of Units' : SystemOfUnits + * :>> systemOfQuantities = isq; + * :>> baseUnits = (m, kg, s, A, K, mol, cd); + * } + */ +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_08-Range Restriction.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_08-Range Restriction.sysml new file mode 100644 index 00000000..e16e3cc1 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_08-Range Restriction.sysml @@ -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['°'] } + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_10-Primitive Data Types.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_10-Primitive Data Types.sysml new file mode 100644 index 00000000..9679256c --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_10-Primitive Data Types.sysml @@ -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; +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_11-Variable Length Collection Types.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_11-Variable Length Collection Types.sysml new file mode 100644 index 00000000..9b9a4cdb --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_11-Variable Length Collection Types.sysml @@ -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' :> Bag { + ref part :>> elements : SparePart; + } + attribute def 'List' :> List { + ref value :>> elements : Integer; + } + attribute def 'Set' :> Set { + attribute :>> elements : String; + } + attribute def 'OrderedSet' :> OrderedSet { + ref part :>> elements : Person; + } + attribute def 'List>' :> List { + attribute :>> elements : Set { + ref part :>> elements : Person; + } + } + attribute def 'Array[4]' :> Array { + attribute :>> elements : Real; + attribute :>> dimensions = 4; + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_12-Compound Value Type.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_12-Compound Value Type.sysml new file mode 100644 index 00000000..d9ecbb71 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_12-Compound Value Type.sysml @@ -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; + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_13-Discretely Sampled Function Value.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_13-Discretely Sampled Function Value.sysml new file mode 100644 index 00000000..999604e9 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_13-Discretely Sampled Function Value.sysml @@ -0,0 +1,90 @@ +package '15_13-Discretely Sampled Function Value' { + private import SampledFunctions::SampledFunction; + private import SampledFunctions::SamplePair; + private import Collections::Array; + private import ISQ::*; + private import SI::*; + private import MeasurementReferences::*; + private import Time::*; + attribute def MissionElapsedTimeScale :> TimeScale { + :>> unit = s; + attribute :>> definitionalEpoch { + :>> num = 0; + :>> definition = "time instant zero at launch"; + } + attribute definitionalEpochInUTC: Iso8601DateTime; + attribute :>> transformation : CoordinateFramePlacement { + :>> source = UTC; + :>> origin = definitionalEpochInUTC; + :>> basisDirections = 1[UTC]; + } + } + attribute mets: MissionElapsedTimeScale { + doc + /* + * Define mission elapsed time scale starting at given UTC date time (in microsecond resolution) + */ + + :>> definitionalEpochInUTC { + :>> val = "2020-08-23T22:42:32.924534Z"; + } + } + attribute def MissionElapsedTimeValue :> TimeInstantValue { + doc + /* + * Define scalar quantity value type for mission elapsed time + */ + + :>> mRef = mets; + } + attribute spatialCF: CartesianSpatial3dCoordinateFrame[1] { + doc + /* + * Define Cartesian 3D coordinate systems for position and velocity + * Create a velocity coordinate system from the spatial coordinate system through division by second + */ + + :>> mRefs = (m, m, m); + } + attribute velocityCF: CartesianVelocity3dCoordinateFrame[1] = spatialCF / s; + attribute def PositionAndVelocity { + attribute position: CartesianPosition3dVector[1]; + attribute velocity: CartesianVelocity3dVector[1]; + } + attribute def AscentProfile :> SampledFunction { + attribute def AscentSample :> SamplePair { + attribute :>> domainValue : MissionElapsedTimeValue[1]; + attribute :>> rangeValue : PositionAndVelocity[1]; + } + attribute :>> samples : AscentSample[*] ordered; + } + attribute ascentProfile1: AscentProfile { + doc + /* Example ascent profile */ + attribute sample1: AscentSample { + :>> domainValue = 0.0[mets]; + :>> rangeValue = pv1; + attribute pv1: PositionAndVelocity { + :>> position = (0, 0, 0)[spatialCF]; + :>> velocity = (0, 0, 0)[velocityCF]; + } + } + attribute sample2: AscentSample { + :>> domainValue = 2.5[mets]; + :>> rangeValue = pv1; + attribute pv1: PositionAndVelocity { + :>> position = (0.01, 0.03, 8.6)[spatialCF]; + :>> velocity = (0, 0, 5.5)[velocityCF]; + } + } + attribute sample3: AscentSample { + :>> domainValue = 5.1[mets]; + :>> rangeValue = pv1; + attribute pv1: PositionAndVelocity { + :>> position = (0.04, 0.12, 18.6)[spatialCF]; + :>> velocity = (0.05, 0.03, 25.3)[velocityCF]; + } + } + attribute :>> samples = (sample1, sample2, sample3); + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_19-Materials with Properties.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_19-Materials with Properties.sysml new file mode 100644 index 00000000..21b2642b --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_19-Materials with Properties.sysml @@ -0,0 +1,75 @@ +package '15_19-Materials with Properties' { + private import ScalarValues::Real; + private import Quantities::*; + private import MeasurementReferences::*; + private import SI::*; + attribute def AtomicMassValue :> MassValue; + attribute def TensileStrengthUnit :> DerivedUnit { + private attribute lengthPF: QuantityPowerFactor[1] { + :>> quantity = isq.L; + :>> exponent = - 1; + } + private attribute massPF: QuantityPowerFactor[1] { + :>> quantity = isq.M; + :>> exponent = 1; + } + private attribute durationPF: QuantityPowerFactor[1] { + :>> quantity = isq.T; + :>> exponent = - 2; + } + attribute :>> quantityDimension { + :>> quantityPowerFactors = (lengthPF, massPF, durationPF); + } + } + attribute def TensileStrengthValue :> ScalarQuantityValue { + attribute :>> num : Real; + attribute :>> mRef : TensileStrengthUnit; + } + attribute <'N/mm²'> 'newton per square millimetre': TensileStrengthUnit = N / (mm ^ 2); + part def Substance; + part def Material :> Substance; + /* + * The classification of materials into metals and alloys is grossly simplified and not exhaustive. + * A more complete classification would include: ChemicalSubstance, PureMaterial, MixedMaterial, + * Class, Ceramic, OrganicMaterial, AnorganicMaterial, Polymer, HybridMaterial, CompositeMaterial, + * etc. + */ + part def Metal :> Material { + attribute atomicMass: AtomicMassValue[1]; + } + attribute def MaterialFraction { + ref material: Material[1]; + attribute massFraction: MassFractionValue[1]; + } + attribute def MassFractionValue :> DimensionOneValue; + part def Alloy :> Material { + attribute fractions: MaterialFraction[2..*]; + } + individual def Iron :> Metal { + attribute :>> atomicMass = 55.845[Da]; + } + individual def Carbon :> Metal { + attribute atomicMass :>> Metal::atomicMass = 12.011[Da]; + } + individual def Manganese :> Metal { + attribute atomicMass :>> Metal::atomicMass = 54.938[Da]; + } + individual def Steel_980 :> Alloy { + /* + * Particular example of high tensile strength steel. + */ + attribute fraction1 :> fractions { + :>> material : Iron; + attribute :>> massFraction = 0.9862[one]; + } + attribute fraction2 :> fractions { + :>> material : Carbon; + attribute :>> massFraction = 0.9862[one]; + } + attribute fraction3 :> fractions { + :>> material : Manganese; + attribute :>> massFraction = 0.9862[one]; + } + attribute tensileStrength: TensileStrengthValue = 980['N/mm²']; + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_19a-Materials with Properties.sysml b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_19a-Materials with Properties.sysml new file mode 100644 index 00000000..e86e62f6 --- /dev/null +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Expected/15-Properties-Values-Expressions/15_19a-Materials with Properties.sysml @@ -0,0 +1,81 @@ +package '15_19a-Materials with Properties' { + private import ScalarValues::*; + private import Quantities::*; + private import MeasurementReferences::*; + private import SI::*; + attribute def AtomicMassValue :> MassValue; + /* Example declarations of a quantity and unit that are not specified in ISQ and SI */ + attribute def TensileStrengthUnit :> DerivedUnit { + private attribute lengthPF: QuantityPowerFactor[1] { + :>> quantity = isq.L; + :>> exponent = - 1; + } + private attribute massPF: QuantityPowerFactor[1] { + :>> quantity = isq.M; + :>> exponent = 1; + } + private attribute durationPF: QuantityPowerFactor[1] { + :>> quantity = isq.T; + :>> exponent = - 2; + } + attribute :>> quantityDimension { + :>> quantityPowerFactors = (lengthPF, massPF, durationPF); + } + } + attribute def TensileStrengthValue :> ScalarQuantityValue { + attribute :>> num : Real; + attribute :>> mRef : TensileStrengthUnit; + } + attribute <'N/mm²'> 'newton per square millimetre': TensileStrengthUnit = N / (mm ^ 2); + attribute def Substance; + attribute def Material :> Substance; + /* + * The classification of materials into metals and alloys is grossly simplified and not exhaustive. + * A more complete classification would include: ChemicalSubstance, PureMaterial, MixedMaterial, + * Class, Ceramic, OrganicMaterial, AnorganicMaterial, Polymer, HybridMaterial, CompositeMaterial, + * etc. + */ + attribute def Metal :> Material { + attribute atomicMass: AtomicMassValue[1]; + } + attribute def Alloy :> Material { + attribute fractions: MaterialFraction[2..*]; + } + attribute def MaterialFraction { + attribute material: Material[1]; + attribute massFraction: MassFractionValue[1]; + } + attribute def MassFractionValue :> DimensionOneValue; + /* + * Value properties bound to specifically constructed compound values. + */ + attribute Iron: Metal { + :>> atomicMass = 55.845[Da]; + } + attribute Carbon: Metal { + :>> atomicMass = 12.011[Da]; + } + attribute Manganese: Metal { + :>> atomicMass = 54.938[Da]; + } + attribute Steel_980: Alloy { + /* + * Value property with redefined/added sub-properties. + * (Particular example of high tensile strength steel.) + */ + private attribute fraction1: MaterialFraction { + :>> material = Iron; + :>> massFraction = 0.9862[one]; + } + private attribute fraction2: MaterialFraction { + :>> material = Carbon; + :>> massFraction = 0.0018[one]; + } + private attribute fraction3: MaterialFraction { + :>> material = Manganese; + :>> massFraction = 0.012[one]; + } + attribute :>> fractions = (fraction1, fraction2, fraction3); + attribute tensileStrength: TensileStrengthValue = 980['N/mm²']; + } +} diff --git a/SysML2.NET.Serializer.TextualNotation.Tests/Writers/TextualNotationValidationTestFixture.cs b/SysML2.NET.Serializer.TextualNotation.Tests/Writers/TextualNotationValidationTestFixture.cs index 0cd020bb..8153511d 100644 --- a/SysML2.NET.Serializer.TextualNotation.Tests/Writers/TextualNotationValidationTestFixture.cs +++ b/SysML2.NET.Serializer.TextualNotation.Tests/Writers/TextualNotationValidationTestFixture.cs @@ -120,6 +120,20 @@ public void OneTimeTearDown() [TestCase("14-Language Extensions", "14a-Language Extensions.sysmlx")] [TestCase("14-Language Extensions", "14b-Language Extensions.sysmlx")] [TestCase("14-Language Extensions", "14c-Language Extensions.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_01-Constants.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_02-Basic Value Properties.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_03-Value Expression.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_04-Logical Expressions.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_05-Unification of Expression and Constraint Definition.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_06-System of Quantities.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_07-System of Units and Scales.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_08-Range Restriction.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_10-Primitive Data Types.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_11-Variable Length Collection Types.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_12-Compound Value Type.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_13-Discretely Sampled Function Value.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_19-Materials with Properties.sysmlx")] + [TestCase("15-Properties-Values-Expressions", "15_19a-Materials with Properties.sysmlx")] public async Task VerifyValidationTextualNotationXmi(string folderName, string fileName) { var loggerFactory = LoggerFactory.Create(builder =>