3D PLM PPR Hub Open Gateway

Feature Modeler

Introduction to the OSM Language

Using OSM and CATfctEditorAssistant
Technical Article

Abstract

This article explain how to create an update a catalog with osm language and the CATfctEditorAssistant compiler .



 

Introduction

The CATfctEditorAssistant is a batch tool that need a proper environment set up, please see the article Building and Launching a CAA V5 Use Case [1]

[Top]

Getting started

The osm modeling language in short

Osm modeling language is an easy and compact way to define a feature data structure.

The following use case is based on #CAAOsmCatalogSU use case[2].

CAAOsmBook.gif

In this article we use an executable: the CATfctEditorAssistant to compile .CATfct file

$ CATfctEditorAssistant -h
usage: CATfctEditorAssistant -client-id id [-generate-osm|-upgrade-catalog|-new-catalog] files...
where:
generate osm file according to feat file
-client-id id set your client id to set catalog ownership
-generate-osm xxx.CATfct xxx.osm
upgrading a feat file by adding xxx.osm
-upgrade-catalog xxx.CATfct xxx.osm
create a catalog file and is xxx.osm
-new-catalog xxx.CATfct xxx.osm

Lets start by creating an empty catalog and an empty osm file using CATfctEditorAssistant

$ CATfctEditorAssistant -client-id MyUserId -new-catalog CAAOsmCatalogSU.CATfct CAAOsmCatalogSU.osm

Once it is created, you have to move the CAAosmCatalogSU.CATfct from the current directory to the run-time directory:

Windows InstallRootDirectory\intel_a\resources\graphic\
AIX InstallRootDirectory/aix_a/resources/graphic/
HP-UX InstallRootDirectory/hpux_b/resources/graphic/
Solaris InstallRootDirectory/solaris_a/resources/graphic/

You can do this using the mkCreateRuntimeView command.

To modify this empty catalog you are going to upgrade it with a osm file.

Here is an example of one of the simplest catalog you can define.
We create one startup CATOsmBook.

 /*
* The bookshop catalog
*/
document `CAAOsmCatalogSU.CATfct` [1]
{
container RootCont #root [2]
{
feature CATOsmBook #startup [3]
{
string Title [4] [5]
specobject BookPublisher
}
}
}
An osm source file is an enumeration of hierarchical block delimited by curly braces like C++. The language supports C++ comments but they cannot be regenerated when using source CATfctEditorAssistant compiler generation option.
  1. define a document scope, named "catalog.CATfct".
  2. define a container scope, named and typed RootCont.
  3. define a feature scope, named and typed CATOsmBook. The "#startup" facet means that the feature is not an instance but a startup

Now compile !

$ CATfctEditorAssistant -client-id id -upgrade-catalog CAAOsmCatalogSU.osm CAAOsmCatalogSU.CATfct 

In current directory we have now a CAAOsmCatalogSU.CATfct file.
Remember:  Dont forget to move the new generated catalog from the current directory to the run-time directory.

[Top]

The CATfctEditorAssistant compiler

  1. The CATfctEditorAssistant compiler enables you to check that your osm source file is syntaxically correct.
  2. It embed your source file in the catalog file.
  3. It can generate the osm source of an existing catalog.



Catalogs contains the data definition of all feature and are very similar to dynamic linked library (DLL).
Like DLL are located thru the PATH environment, a catalog is located thru a V5 official environment variable CATGraphicPath.

Keep in mind that CATGraphicPath environment variable is used to search existing catalog. CATfctEditorAssistant tool always load the first catalog found in your CATGraphicPath. 

When specified the directory path is used to save at the specified directory. If unspecified it save in current directory.


[Top]

CATfctEditorAssistant compiler usage

Here follow the three most usefull options to handle catalog files.

$ CATfctEditorAssistant -client-id id -generate-osm catalog.CATfct catalog.osm [1]
$ CATfctEditorAssistant -client-id id -upgrade-catalog catalog.CATfct catalog.osm [2]
$ CATfctEditorAssistant -client-id id -new-catalog catalog.osm catalog.CATfct [3]
  1. Generate the osm source code from catalog file.
  2. Upgrade the catalog by applying osm file. You can :
  3. Create a catalog from scratch.

Image:Warning.gif/ BE CAREFULL WHEN USING THIS OPTION


read the next section


[Top]

How to manage document and containers


How to create a new catalog and the root container

Before creating a new catalog, verify that you have a clear understanding of how you want to create your container structure.

Remember: after creation there is no way to remove a container.

Suppose that you want create a catalog named CAAOsmCatalogSU.CATfct with a root container named RootCont.

document `CAAOsmCatalogSU.CATfct`
{
container RootCont #root [1]
{
}
}
  1. Always define the root container.

An existing root container is requested to create the document

Run the CATfctEditorAssistant compiler :

$ CATfctEditorAssistant -client-id id -new-catalog CAAOsmCatalogSU.osm CAAOsmCatalogSU.CATfct [1]
  1. Notice that you have to specify the full target path.

The latest command produces a file that much more look like that :

document `CAAOsmCatalogSU.CATfct` {
container RootCont #root {
...
[Top] 

How to create a new feature?

There are several ways to create features

document `CAAOsmCatalogSU.CATfct` 
{
container RootCont #root
{
feature CATOsmBook #startup {} [1]
feature CATOsmNovel CATOsmBook #startup {} [2]
feature `Book.1` CATOsmBook {} [3]
  1. Create CATOsmBook startup. Note the #startup facet. the late type is CATOsmBook.
  2. This statement creates a sub startup of CATOsmBook named CATOsmNovel.
  3. This creates an instance of CATOsmBook named Book.1 in the current container scope.

You may have to create instance to initialize your startup. Or if you have to define predefined reference feature.

After upgrading and re-generating the source code look like

document `CAAOsmCatalogSU.CATfct` {
container RootCont #root {
feature CATOsmBook#1 #startup { [1]
}
feature CATOsmNovel#2 CATOsmBook#1 #startup {
}
feature `Book.1`#4 CATOsmBook#1 {
}
  1. The generator adds #nn tag after the declaration.

This insure stability of persistant tag. This tag is required for an efficient feature lookup.


Image:Warning.gif/ THE TAG IS A REQUIREMENT FOR CATALOG COMPATIBILITY.-new-catalog



Image:Warning.gif/ The tag is required when you want to create two instances with the same name.


[Top]

How to define the instance reference or the startup super type ?

In previous section we have seen how to create a startup super class or reference in the same container. But suppose that we have to create the CATOsmDictionary startup in another catalog. We need also to create an instance of Book.1 and an instance of CATOsmBook :

document `AnotherSU.CATfct` {
container RootCont #root {
catalog_manager `CAAOsmCatalogSU.CATfct` [1]
feature CATOsmDictionary CATOsmBook@`CAAOsmCatalogSU.CATfct` #startup {} [2]
feature `Book.1` CATOsmBook@`CAAOsmCatalogSU.CATfct` {} [3]
feature `Book.2` `Book.1`@`CAAOsmCatalogSU.CATfct` {} [4]
  1. This statement registers a catalog_manager.
  2. Create CATOsmDictionary as a startup using CATOsmBook startup in CAAOsmCatalogSU.CATfct.
  3. Create a first instance named Book.1 using CATOsmBook startup in CAAOsmCatalogSU.CATfct.
  4. Create Book.2 an instance of Book.1 of CAAOsmCatalogSU.CATfct.
 Note that there is two Book.1 instances one in CAAOsmCatalogSU and one in AnotherSU.

Notice that defining a reference and subclassing use the same syntactical construction, the #startup facet change the behavior.

Some way to reference an existing feature

Here follows several way to specify an existing feature.

 
MyFeature [1]
MyFeature@SubCont [2]
MyFeature@`Other.CATfct` [3]
MyFeature@SubCont@`Other.CATfct` [4]
  1. locating by name
  2. locating in the sub container SubCont in the same document
  3. locating in the root container in another document
  4. locating a sub container in another document

[Top] 

How to add an attribute on a startup?

Suppose that we want create a catalog to describe book content.

/*
* a naive book content modeling
*/
document `CATOsmBookContent.CATfct`
{
container RootCont #root
{
feature CATOsmBook #startup {
component style #list // list of style [1]
}
feature CATOsmStyle #startup {
string font_name [2]
double font_size [3]
boolean underline [4] ; int background; int foreground
}

feature CATOsmItem #startup {}
feature CATOsmText CATOsmItem #startup {
specobject style [5]
string text
}
feature CATOsmImage CATOsmItem #startup {
external image_link
}
}
}

Create an attribute typed as:

  1. component list
  2. string named font_name
  3. double named font_size
  4. boolean named underline and two int named background and foreground
  5. specobject name private access


CATAttrKind osm type
tk_any any
tk_boolean boolean
tk_component component
tk_double double
tk_external external
tk_integer int
tk_list #list facet
tk_octet octet
tk_specobject specobject
tk_string string

How to define quality ?

 The #in_external can also be set on external attribute to propagate update on pointed object.


[Top]

How to modify an attribute?

You should never modify attribute definition.
Removing or modifiying an attribute type or quality can leads to data upward compatibility or memory capacity issues.
As an unset attribute cost nothing, the solution is to create a new attribute.

[Top]

How to set a value?

You may have to set value after defining all feature.</br> You can do that by assigning the value to an attribute.
Values are always constants, and must be set after all feature creation
Here is an example of an attribute we want to set to 5

document `catalog.CATfct` {
container RootCont #root {
catalog_manager `ObjectSpecsModeler.feat`
feature MyStartup#2 #startup {[1]
double X
X = 5. [2]
}
}
}
  1. The with construction is used for feature lookup.
  2. set X to 5. See How to format a value ?

[Top]

How to format a value ?


type value
double a real number containing a dot or an exponent
-2. 2.424e-5 3300041.e+40
int an integer value in range -2**31, +2**31-1.

Like C++, you can use octal (prefix 0), hexadecimal (prefix 0x).

-2, 0x3f 63 in hexadecimal, 0377 255 in octal.
octet like int but constrained in 0, 255 range
boolean true or false keyword
string single (') or double quoted (") delimited string.

Like C++ some character can be escaped, strings may contain UTF8 character. String can be prefixed by a u letter (u) to specify that the string is an UTF8 string,

"string1"
'5"1/4' a string containing a double quote
"I'm" a string containing a single quote
'I\'m' another way of previous one
"\n" a string containing a &lt.CR&gt.
'\\' a string containing a backslash
"\t" a string containing a tab
"\"" a string containing double quote
u"pupil at school" an utf-8 string containing pupil at school
u"élève à l'école" the same in french
specobject

component
external

You can reference by feature name.

You have to specify the container path or document if you reference a feature outside the current container (or document). See #Some way to reference an existing feature for more details. Use the null keyword to set to null.

MyFeature

null

list Enumeration are delimited by brackets ('[' and ']'), values are separated by comas (',').

[ 1, 2, 3 ] list of 3 integer [ ] an empty list [ "str1" , "str2" ] list of 2 strings

octet list octet list can be initialized as an hexadecimal binary string.

the number of hexadecimal digits must be odd. Dash character ('-') can be added in source file for clarity

b'0fabced000555555' undelimited binary
 b'0fabced0-00-555555' delimited binary

[ 0xf, 0xab, 0xce, 0xd0, 0x00, 0x55, 0x55, 0x55 ]

[Top]

How to define an extension feature

An extension feature is an extension that inherit from FeatExt. FeatExt is a virtual type defined by the feature modeler.

document `CAAOsmCatalogSU.CATfct` 
{
container RootCont #root
{
feature CAAOsmHistoricalNovel FeatExt@`ObjectSpecsModeler.feat` #startup {} [1]
    1. super type is located in ObjectSpecsModeler.feat

[Top]

What to do when something goes wrong?

Error format, source and severity

Here is a typical CATfctEditorAssistant error message

[E][1] OSM-CVT[2] : created catalog is not the first in CATGraphicPath[3]  : { doc='catalog .feat', found='...\intel_a\resources\graphic\.' }[4]
1.
 The error severity begin any message there is three level of severity : 

    [E] the error level class: an error is never revorable and the process will abort
    [W] the warning level class: the CATfctEditorAssistant detect an anomaly adopt a default behavior, in most of case it ignore the statement
    [I] the informational level: notify what the CATfctEditorAssistant is doing.


2.
 This is the error source. It indicates which OSM components emites the error. 
Most of the errors source from CATfctEditorAssistant are :

    OSM-PAR parser and runtime engine error
    OSM-CVT CATfctEditorAssistant tools command line.

3. an human explaination of the error

4. some usefull data that help to understand the context


Omsfeat is a two pass compiler :

parse pass this pass build a syntactical tree. During this pass compilation errors are emited, most of then are lexical or syntactical.
evaluation pass

When the previous pass is successful an evaluation can be done. During this pass the syntactical tree is scanned and evaluated. Some runtime errors may occurs.

Compilation error

Now suppose that we have wrote the following catalog source:

 document `catalog.CATfct` 
{
catalog_manager `catalog.CATfct`
container RootCont #root
{
feature MyStartup #startup
{
double X :
}
feature MyStartup2 MyStarup #starup
{
double y
}
}
}
$ CATfctEditorAssistant -client-id id -create-feat ...\intel_a\resources\graphic\catalog.CATfct catalog.osm
[E] OSM-PAR: catalog.osm:3:[1] parse error, unexpected `OSMKCatalogManager', expect
ing `OSMKContainer' or `OSMKEnd' or `OSMKMetaDataDef' near 'catalog_manager'[2]
catalog_manager `catalog.CATfct` [3]
[E] OSM-PAR: catalog.osm: 1 error(s) found during parse[4]
  1. Compilation errors indicate the source filename and the line number where the errors are detected
  2. Parse errors occur during the first pass.
  3. It prints the current line. This feature is disable when the source file is not available
  4. Summary of errors and warnings.

Ho, yes! the catalog_manager have to be in a container scope. corrected file :

 document `catalog.CATfct` 
{
container RootCont #root
{
catalog_manager `catalog.CATfct`
feature MyStartup #startup
{
double X :
}
feature MyStartup2 MyStarup #starup
{
double y
}
}
}
[E] OSM-PAR: catalog.osm:8: parse error, unexpected `$undefined.', expecting `OS
MKEnd' or `OSMKFacet' or `'='' near ':'
double X :[1]
[E] OSM-PAR: catalog.osm:10: invalid facet name[2]
feature MyStartup2 MyStarup #starup
[E] OSM-PAR: catalog.osm: 2 error(s) found during parse[3]
  1. Here there is an extraneous ':'
  2. Here startup is mistyped
  3. Summary of errors and warnings.

Runtime errors

Run again CATfctEditorAssistant compiler.

[E] OSM-PAR: catalog.osm:10: cannot find reference : { feature='MyStartup2',
reference='MyStarup', container='RootCont', document='catalog.CATfct' }
feature MyStartup2 MyStarup #startup [1]
[E] OSM-PAR: catalog.osm: 1 error(s) found during evaluation[2]
[W] OSM-PAR: catalog.osm: 1 warning(s) found during evaluation

Here, the error occurs at line 5, with catalog.CATfct in container RootCont in document catalog.CATfct.

  1. The message tell you that the reference is not found. MyStarup is mistyped
  2. note that now we have evaluation error not parse error!

[Top] 

References

[1] CAADocRunSample use case
[2] CAAOsmCatalogSU use case
[Top]


History

Version Date Comment
1 2006-04-04 Document created
2 2006-05-31 Document review
3 2006-06-20 Document review

[Top]

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