3D PLM PPR Hub Open Gateway |
Knowledge Modeler |
Creating and Managing RelationsHow to manipulate formulas, rules and checks |
Use Case |
AbstractThis article explains how to create relations such as formulas, rules and checks. |
In these use cases, you will learn how to:
[Top]
There are three types of relations: the formulas, the rules and the checks. Relations as well as parameters are created by the appropriate services of the CATICkeParmFactory object. A relation is described by the CATICkeRelation interface which allows you to manage the relation activity, hide or make a relation reappear in the specification tree, add, remove or replace a parameter in the relation expression. The expression, i.e. the body of a relation is described by the CATICkeRelationExp interface. This article illustrates how to use very simply the most common services provided by CATICkeRelation and CATICkeRelationExp interfaces.
[Top]
CAALifRuleCheck is a use case of the CAALiteralFeatures.edu framework that illustrates KnowledgeInterfaces framework capabilities.
[Top]
This use case creates a rule and a check and retrieves the expression or body of a relation.
[Top]
To launch CAALifRuleCheck, you will need to set up the build time environment, then compile CAALifRuleCheck along with its prerequisites, set up the run time environment, and then execute the use case which main program is CAALifRelationMain. This program encompasses two use cases [1].
[Top]
The CAALifRuleCheck use case is made of the CAALifRuleCheck.cpp file located in the CAALifRelations.m module of the CAALiteralFeatures.edu framework:
Windows | InstallRootDirectory\CAALiteralFeatures.edu\CAALifRelations.m\ |
Unix | InstallRootDirectory/CAALiteralFeatures.edu/CAALifRelations.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
The main program related to this file is CAALifRelationMain.
[Top]
The CAALifRuleCheck is divided into four steps:
[Top]
// Create a rule CATICkeRelation_var spRule1 = spFact->CreateProgram ("rel1", "", "", &list, "if (a1 > 9 m) \n {a4 = a1*a2*a3} \n else {a4 = 100*a5*a2}", NULL_var, CATCke::False); |
The whole string passed in the argument 5 should be declared as one statement line (you cannot break the string between quotes in your C++ code). To specify a new line in the rule body, use the \n character.
If the syntax of your rule/check is wrong, the CreateProgram/Check method returns NULL_var, but this only applies to expressions declared with the 'ai' notation.
The rule which would be displayed as:
If (Width > 9 m) {v=Width*Length*Height} else {v=100*surface*Length}
in the rule editor, is specified as "if (a1>9m)\n
{a4=a1*a2*a3}\n else {a4 = 100*a5*a2}"
in the CreateProgram
method.
[Top]
The CATICkeRelationExp::Body allows you to display the expression making up the rule body. You must specify '1' as the first argument value, if you want to re-calculate the expression. In an application, it is recommended to recalculate the expression since parameter names and values are subject to changes.
[Top]
The "Width" parameter is modified by using the CATICkeParm::Valuate method. The first part of the rule is no longer valid and the else statement is applied.
[Top]
The 'Ch1' check is created. The check which would be displayed as: Length
> Width
in the check editor is specified as a2 > a3
in
the CreateCheck method. Replacing the check body with a2 - a3
results in a syntax error. If you are using the ai notation, NULL_var is
returned by the CreateCheck method and the following message is displayed in the
standard output:
"The check cannot be created"
// Create a check CATICkeRelation_var check1 = fact->CreateCheck ("rel2","","",&list,"a2 > a3",NULL_var,CATCke::False); |
If need be, to manage the rule and check activity after an expression has been modified, you can proceed exactly as explained in the formula sample.
[Top]
The following programming steps are typically required when writing relations:
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Jan 2000] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.