3D PLM PPR Hub Open Gateway |
Knowledge Modeler |
Using Volatile ParametersHow to create and modify volatile parameters |
Use Case |
AbstractThis 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. |
This article explains how to do most of the usual operations on volatile parameters.
[Top]
CAALifParametersVolatile is a use case of the CAALiteralFeatures.edu framework that illustrates KnowledgeInterfaces framework capabilities.
[Top]
The CAALifParametersVolatile use case is divided into five parts:
[Top]
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]
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]
CAALifParametersVolatile is divided into five steps:
[Top]
... // ----------------------------------- // 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]
Simple type parameters are integers, reals, strings or booleans.
To create a simple type parameter, you should use one of the methods below:
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.
The CATICkeParm::Valuate method is used to modify the value of a volatile parameter.
... // Modify the intParam value (initial value = 2) spPp1->Valuate (6); |
Like persistent parameter values, volatile parameter values can be retrieved and displayed in three ways:
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]
These parameters are created by the:
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); ... |
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)
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]
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]
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]
[1] | Building and Launching a CAA V5 Use Case |
[2] | About Units |
[Top] |
Version: 1 [Mar 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.