If you did not find a suitable Using Units in the standard libraries (ISO-80000), you can:
Creating a custom Value Type
If you want to use a different Value Type than our library provides, you can create a custom Value Type and specify a desired unit for it from the ISO-80000 package.
To create a custom Value Type
- Select a package in the Containment tree where you want to create a new Value Type.
- Right-click it and select Create Element.
- In the opened dialog, search for a Value Type and select it.
- Type its name. Following syntax is recommended: quantity name[unit name]. (e.g. volume[liter]).
- Press Enter.
- Double-click the newly created Value Type to open its Specification window.
In the Specification window, specify the Unit property value:
a. Click .
b. In the Select Instance Specification dialog, clear the Apply Filter box.
c. Make sure the ISO-80000 library is loaded in your project.Warning
If the ISO-80000 library is not uploaded in your project, you can load it directly in the Select Instance Specification dialog by clicking the Load button.
d. Select the required Unit from the ISO-80000 package (e.g.litre).
- Click Close.
The new Value Type is defined in your project and can be used as a type for a Value Property.
Creating custom Unit
If you can't find a desired unit you can create a custom Unit. A unit is recommended to be related to a Quantity Kind. Often equations can be expressed in terms of quantities that include Quantity Kinds without specifying Units.
To create a custom Unit
From the Block Definition Diagram palette, expand the Value Type button and select the Unit button.
If you do not see the Unit button, make sure the Expert Mode is turned on.
- Click the mouse pointer on the diagram pane. The Select Classifier dialog opens automatically.
- In the Select Classifier dialog, find the Unit Block, double-click it to select and click OK. The new Unit is created.
Type its name (e.g. mile).
- Double-click the Unit shape to open its Specification window.
- In the Specification window specify:
The Quantity Kind property value:
a. Click .
b. In the Select Quantity Kind dialog, clear the Apply Filter box.
c. Make sure the ISO-80000 library is loaded in your project.Warning
If the ISO-80000 library is not uploaded in your project, you can load it directly in the Select Quantity Kind dialog by clicking the Load button.
d. Select the required quantity from the ISO-80000 package (e.g. distance).
- The symbol of Unit:
a. In the Property group list, select Slots.
b. Select the symbol slot and click the Create Value button.
c. Type the unit symbol in the Value area (e.g. mi).
d. Click Close.
The new Unit is created and can now be specified for the Value Type and then used in your project as a type of Value Property.
Following are the QUDV library Classifiers that support Unit Conversion.
- SimpleUnit – Base unit that other units can convert to.
- PrefixedUnit – Unit that converts to other units via prefix (for example kilo, mega and etc).
- LinearConversionUnit – Unit that converts using predefined factor. Formula: ReferenceUnit=value*factor.
- AffineConversionUnit – Unit that converts using predefined factor and offset. Formula: ReferenceUnit=value*factor+offset.
- DerivedUnit – Combination of several units.
After the classifier is defined, the slot window is available. Slot window is used to define a properties. Following are the properties that support Unit Conversion:
- referenceUnit – A unit to convert to. Can be a SimpleUnit or another ConversionUnit.
- prefix – Selecting a prefix suitable for the unit (only for PrefixedUnit).
- factor – Conversion factor (for LinearConversion and AffineConversion Units).
- offset – Static part for AffineConversionUnits.
Derived Unit
Derived units are a combination of several pre-defined units. Creating a Derived Unit follows a different logic than other types of units. Derived Units do not have a referenceUnit slot.
The factor slot is filled with UnitFactors. A UnitFactor is an instance that has a Unit and an Exponent. For example, a DerivedUnit of m/s^2 (acceleration) would have a factor of m^1 (meter with exponent 1) and s^-2 (second with exponent -2).
If required UnitFactor is not found, then you need to create a new UnitFactor and use it to create new derived units.
To create a UnitFactor
- Create a new Instance Specification.
- Set its classifier to UnitFactor.
- Fill in the values of Unit and Exponent slots.
An example of a derived unit(acceleration).
To learn more about derived units, refer to OMG SysML Specification.