Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

If you did not find a suitable Using Units in the standard libraries (ISO-80000), you can:

Table of Contents

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


  1. Select a package in the Containment tree where you want to create a new Value Type.
  2. Right-click it and select Create Element.
  3. In the opened dialog, search for a Value Type and select it.
  4. Type its name. Following syntax is recommended: quantity name[unit name]. (e.g. volume[liter]).
  5. Press Enter.
  6. Double-click the newly created Value Type to open its Specification window.
  7. 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
    titleWarning

    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).

  8. 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


  1. From the Block Definition Diagram palette, expand the Value Type button and select the Unit button.

    Note

    If you do not see the Unit button, make sure the Expert Mode is turned on.


  2. Click the mouse pointer on the diagram pane. The Select Classifier dialog opens automatically.
  3. In the Select Classifier dialog, find the Unit Block, double-click it to select and click OK. The new Unit is created.
  4. Type its name (e.g. mile).

  5. Double-click the Unit shape to open its Specification window.
  6. 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
      titleWarning

      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.

Note

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


  1. Create a new Instance Specification.
  2. Set its classifier to UnitFactor.
  3. Fill in the values of Unit and Exponent slots.


An example of a derived unit(acceleration).
Info

To learn more about derived units, refer to OMG SysML Specification.