3D PLM PPR Hub Open Gateway

Knowledge Modeler

Using Volatile Parameters

How to create and modify volatile parameters

Use Case

Abstract

This article explains how to create volatile parameters, retrieve and modify their values. Volatile parameters are literals that are not saved in any form. Unlike persistent parameters, they cannot be retrieved when a document is unloaded. Volatile parameters are created, read and modified like persistent parameters but the way to create them is a bit different.


What You Will Learn With This Use Case

This article explains how to do most of the usual operations on volatile parameters.

[Top]

The CAALifParametersVolatile Use Case

CAALifParametersVolatile is a use case of the CAALiteralFeatures.edu framework that illustrates KnowledgeInterfaces framework capabilities.

[Top]

What Does CAALifParametersVolatile Do

The CAALifParametersVolatile use case is divided into five parts:

  1. Retrieving the volatile factory
  2. Creating and managing simple type parameters
    1. creates two simple type parameters:
      • intParam - which is an integer with an initial value of 2
      • booleanParam - which is a boolean with an initial value of true (CATCke::True).
    2. displays the name and the value of each simple type parameter.
    3. modifies each simple type parameter
  3. Creating and managing length and angle parameters
    1. creates two dimension type parameters:
    2. displays the name and value of each dimension type parameter.
  4. Creating and managing magnitude type parameters
    1. creates one magnitude type parameter
    2. displays the name and the value of volumeParam
  5. Creating and managing literal type parameter
    1. creates a literal of integer type and assigns it a value
    2. creates a literal of boolean type and assigns it a value.

[Top]

How to Launch CAALifParametersVolatile

To launch CAALifParametersVolatile, you will need to set up the build time environment, then compile CAALifParametersVolatile along with its prerequisites, set up the run time environment, and then execute the use case which main program is CAALifParametersMain. This program encompasses several use cases [1].

[Top]

Where to Find the CAALifParametersVolatile Code

The CAALifParametersVolatile use case is made of the  CAALifParametersVolatile.cpp file located in the CAALifParameters.m module of the CAALiteralFeatures.edu framework:

Windows InstallRootDirectory\CAALiteralFeatures.edu\CAALifParameters.m\
Unix InstallRootDirectory/CAALiteralFeatures.edu/CAALifParameters.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

The main program related to this use case is CAALifParametersMain.

[Top]

Step-by-Step

CAALifParametersVolatile is divided into five steps:

  1. Retrieving the Volatile Factory
  2. Creating and Managing Simple Type Parameters
  3. Creating and Managing Dimension Type Parameters
  4. Creating and Managing Magnitude Type Parameters
  5. Creating and Managing Literal Type Parameters

[Top]

Retrieving the Volatile Factory

...
// -----------------------------------
// 1 - Retrieving the volatile factory
// -----------------------------------
CATICkeParmFactory_var spVolFactory = CATCkeGlobalFunctions::GetVolatileFactory();

You can only create volatile parameters from the volatile factory. The CATCkeGlobalFunctions::GetVolatileFactory method allows you to create a volatile factory.

[Top]

Creating and Managing Simple Type Parameters

Simple type parameters are integers, reals, strings or booleans.

  1. Creating simple type parameters

    To create a simple type parameter, you should use one of the methods below:

    1. CATICkeParmFactory::CreateInteger
    2. CATICkeParmFactory::CreateReal
    3. CATICkeParmFactory::CreateString
    4. or CATICkeParmFactory CreateBoolean.

    Each method takes the parameter name as its first argument, the parameter value as its second argument.

    ...
    // -----------------------------------
    // 2 - Simple type volatile parameters
    // -----------------------------------
    
       // Create a real
       // Parameter name is "realParam", parameter value is 2.3
       CATICkeParm_var spPp1 = spVolFactory->CreateInteger ("intParam",2);
       ...
       // Create a boolean
       // Parameter name is "booleanParam", parameter value is CATCke::True
       CATICkeParm_var spPp4 = spVolFactory->CreateBoolean ("booleanParam",
                                                              CATCke::True);

    If the second argument of CATICkeParmFactory::CreateInteger is passed as a real, its is converted to an integer. Likewise, if the second argument of CATICkeParmFactory::CreateReal is passed as an integer, the method converts it to a real.

    The value of a boolean is either CATCke::True or CATCke::False.

  2. Modifying a parameter
  3. The CATICkeParm::Valuate method is used to modify the value of a volatile parameter.

    ...
    // Modify the intParam value (initial value = 2)
    spPp1->Valuate (6);
  4. Retrieving and displaying parameter values
  5. Like persistent parameter values, volatile parameter values can be retrieved and displayed in three ways:

    1. CATICkeInst::Show which displays the end user view of the parameter value (i.e the parameter value with the units and settings specified in the Tools->Options...->General Units tab).
    2. CATICkeInst::AsType which:
      • either returns the parameter value when the parameter is of the appropriate type
      • or converts the parameter value to a value with the type expected.
        • CATICkeInst::AsInteger converts:
          • a real to an integer
          • a boolean to 0 or 1
          • an enum to its rank
        • CATICkeInst::AsReal converts
          • an integer to a real
          • a boolean to 0 or 1
          • an enum to its rank
    3. CATIParmAsStored::ValueStored which returns the value in model units [2].

    Here is a code extract illustrating how to use these methods.

    ...
    // Display the name and value of booleanParam
    cout << spPp4->Name().CastToCharPtr() << " value is: " << endl;
    cout << spPp4->Show ().CastToCharPtr() << " (with CATICkeParm::Show)" << endl ;
    
    cout << spPp4->Value()->AsBoolean () ;
    cout << " (with CATICkeInst::AsBoolean)" << endl;
    cout << spPp4->Value()->AsInteger () 
    cout << " (with CATICkeInst::AsInteger)" << endl;
    cout << spPp4->Value()->AsString ().CastToCharPtr() ;
    cout << " (with CATICkeInst::AsString)" << endl;

[Top]

Creating and Managing Dimension Type Parameters

  1. Creating length and angle type parameters

    These parameters are created by the:

    1. CATICkeParmFactory::CreateLength
    2. and CATICkeParmFactory ::CreateAngle methods.

    The value passed as the second argument should be specified in MKS units, i.e, in meters for a length type parameter and in radians for an angle type parameters.

    ...
    // ------------------------------------------------
    // 3 - Dimension type parameters (Length and Angle) 
    // ------------------------------------------------
     
      // Create and display a Length type parameter
      // Parameter name is "lengthParam", parameter value is 2
      CATICkeParm_var spPp5 = spVolFactory->CreateLength ("lengthParam",2);
      ...
      
      // Create and display an Angle type parameter
      // Parameter name is "angleParam", parameter value is 3.1416
      CATICkeParm_var spPp6 = spVolFactory->CreateAngle ("angleParam",3.1416);
      ...
    
  2. Retrieving Parameter Values

    The portion of code below

    ...
    // Display the name and value of lengthParam
    cout << spPp5->Name().CastToCharPtr() << " value is: " << endl;
    cout << spPp5->Show ().CastToCharPtr() << " (with CATICkeParm::Show)" << endl ;

    displays in the standard output:

    lengthParam value is:
    2 (with CATICkeParm::Show)

[Top]

Creating and Managing Magnitude Type Parameters

Dimension other than lengths and angles are created by using the CATICkeParmFactory::CreateDimension method.

To create a magnitude type parameter:

...
// ------------------------------
// 4 - Magnitude type parameters
// ------------------------------

CATICkeParm_var
  spPp7 = spFact->CreateDimension(
CATCkeGlobalFunctions::GetParmDictionary()->FindMagnitude("VOLUME"),
                                                 "volumeParam",20.5);

[Top]

Creating and Managing Literal Type Parameters

Parameters of a given type can be created by using the CATICkeParmFactory::CreateLiteral method and specify the parameter type in the first argument. To retrieve this parameter type, you must use the CATIParmDictionary::GetxxxType method. The CATCkeGlobalFunctions::GetParmDictionary allows to retrieve the CATIParmDictionary.

...
//  6 - Create literals of a given type
//      Create a literal of integer type
CATICkeParm_var 
  spLast = spVolFactory->CreateLiteral(
              CATCkeGlobalFunctions::GetParmDictionary()->GetIntegerType(),"int0");
spLast->Valuate(5);
...
//       Create a literal of boolean type
spLast = spVolFactory->CreateLiteral(
             CATCkeGlobalFunctions::GetParmDictionary()->GetBooleanType(),"bool0");
spLast->Valuate(CATCke::True);

Note that when you create a literal that way, you can't specify a value at creation. The parameter must be valuated later on.

[Top]


In Short

A volatile factory allows you to create the same types of parameters as a persistent factory. To retrieve a volatile factory, you must use the CATCkeGlobalFunctions::GetVolatileFactory method.

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[2] About Units
[Top]

History

Version: 1 [Mar 2000] Document created
[Top]

Copyright © 2000, Dassault Systèmes. All rights reserved.