AbstractThis article discusses the CAAPsnUseCase4 use case. This use case explains how to create a CATProduct Black Box (Publication Exposed) from a Structure Exposed assembly already existing in the ENOVIA VPM V4 database and how to attach the CATProduct Black Box to the Root part of the assembly. The Black Box creation is performed in batch from Windows platform. This use case makes reference to the CAAPsnUECreate use case which explains how implement the CATIPDMUECreate user exit required to set the attributes for the parts and documents that will be created in ENOVIA vpm V4. It also contains an implementation of the CATIPDMUECreate and CATIPDMUnixNTMapping interfaces that are not explained in detail in this use case. |
This use case is an example of how to use the SetPDMProperties, CATOpenConfiguredAssemblyInVPM, CATCreateVPMSession, CATLoadChildrenFromVPM, CATCompleteSessionFromVPM, CATSaveInVPMFromCATIA, CATCloseAssemblyInVPM and SaveAsInVPM methods.
[Top]
CAAPsnUseCase4 is a use case of the CAAPSNInteroperability.edu framework that illustrates the PSNInteroperability framework capabilities.
[Top]
The goal of CAAPsnUseCase4 is to create a CATProduct Black Box reflecting the complete structure of an Exploded mode assembly existing in ENOVIA vpm V4. The CATProduct is attached on the Root part of this assembly. The Root part is identified by its COID. The COID can be retrieved by executing the following Select statement against the VPM database. If you have previously executed CAAPsnUseCase1 which imports a file base assembly in ENOVIA vpm, You can use "Root assembly" as the Root part:
select "$COID", s_part_number from VPMENV.PART_LIST where s_part_number = 'Root assembly' |
As a result of the execution of the use case, the following product structure is created in ENOVIA vpm V4
NoteRunning this use case creates new data in ENOVIA vpm V4. Prior to running it, we advise you to check if similar document already exist in ENOVIA vpm as shown in the following panel:
[Top]
To launch CAAPsnUseCase4, you will need to set up the build time environment, then compile CAAPsnUseCase4 along with its prerequisites, set up the run time environment, and then execute the use case [1]. To launch it, execute the following command:
mkrun -c "CAAPsnUseCase4 Coid hostName user pwd role server "
where
Coid
is the Coid of the Root part of the Structure Exploded assembly. hostName
is the name of the Unix host on which the communication server will be launched.user
is the user name used for the database connection.pwd
is the password used for the database connection.role
is the ENOVIA vpm role used to access the database.server
is the name of the server in the option settings.[Top]
CAAPsnUseCase4 code is located in the CAAPsnUseCase4.m use case module of the CAAPSNInteroperability.edu framework:
Windows | InstallRootDirectory/CAAPSNInteroperability.edu/CAAPsnUseCase4.m |
Unix | InstallRootDirectory\CAAPSNInteroperability.edu\CAAPsnUseCase4.m |
where InstallRoot
is the root directory of your CAA V5
installation. It is made of a unique source file named CAAPsnUseCase4.cpp.
[Top]
There are ten logical steps in CAAPsnUseCase4:
We will now comment each of those sections by looking at the code.
[Top]
... CATUnicodeString Coid = argv[1] ; CATUnicodeString hostName = argv[2] ; char * pHostName = argv[2] ; CATUnicodeString user = argv[3] ; CATUnicodeString pwd = argv[4] ; CATUnicodeString role = argv[5] ; CATUnicodeString server = argv[6] ; ... |
CAAPsnUseCase4 begins by retrieving the arguments from the command line. Arguments are extracted in sequence: the full path of the root assembly document, the name of the Unix host, the ENOVIA vpm user and password used for database authentication, the role of this user and the option settings server name.
... char* pCAAPathToShell; CATLibStatus result = ::CATGetEnvValue("CV5VpmStart", &pCAAPathToShell); if ( (CATLibError == result) || ( NULL == pCAAPathToShell) ) { cout << "CV5VpmStart environment variable is not set" << endl << flush; return 1; } cout << " The unix shell script is " << pCAAPathToShell << " on host " << hostName.ConvertToChar() << endl; ... |
Then the CV5VpmStart
environment variable is checked. It contains the name of the Unix
directory where the StartVPMBatchFromV5Batch.sh
shell script is located.
... char *sessionName = "CAA2_Sample_Session"; CATSession *pSession = NULL; HRESULT rc = ::Create_Session(sessionName, pSession); if ((FAILED(rc)) || (NULL == pSession)) { cout << "ERROR in creating session" << endl << flush; return 1; } ... |
Since this is a batch program, it is first necessary to open a new
session before beginning to work with documents. Do not forget that this
session needs to be deleted at the end of the program.
To open a new session, use the Create_Session
global function.
[Top]
... rc = ::CATInitBatchOnHost( pHostName ); if (SUCCEEDED(rc)) cout << "Communication with ENOVIA vpm is set" << endl << flush; else { cout << "ERROR establishing communication with ENOVIA vpm" << endl << flush; //Always deleting session before exiting ::Delete_Session(pSessionName); return 1; } ... |
Now that the session is opened, you can establish the communication channel with ENOVIA vpm using
the CATInitBatchOnHost
global method. This method establishes the connection with ENOVIA VPM V4
running on indicated Unix host.
If there is no server running to which the application can connect to,
a new ENOVIA VPM V4 server is launched on the dedicated Unix host.
[Top]
rc = ::CATConnectToVPM(server, user, pwd, role ); if (FAILED(rc)) { cout << "ERROR in server authentication" << endl << flush; //Always deleting session before exiting ::Delete_Session(pSessionName); return 1; } |
Now that the connection to ENOVIA vpm is established, you can connect to the database
using the CATConnectToVPM
global method. This method establishes the database connection
using user and password for authentication.
[Top]
... //You are using the default VPM environment CATUnicodeString CompId = "3030303030303030"; CATUnicodeString Env = "VPMENV "; CATUnicodeString Table = "PART_LIST "; CATLISTV(CATUnicodeString)* lvConfiguration = NULL; CATDocument * pDocRoot = NULL; //First, you must perform the assembly expand in VPM server memory rc = ::CATOpenConfiguredAssemblyInVPM ( lvConfiguration, Coid, CompId, Env, Table, server); if (SUCCEEDED(rc)) { ... |
Now that the session is opened, you can open the root part of the Structure Exploded assembly using
the CATOpenConfiguredAssemblyInVPM
global method.
This method requires, as a first parameter, a list of Configuration Handler.
In this use case, we do not use a configured assembly so the list is a NULL pointer.
The second parameter is the Coid
of the root part passed in argument of the use case.
The Compid
is set to "3030303030303030"
which is the expected hexadecimal value
for PART_LIST table rows.
... // New CATProduct Document to receive Root part rc = ::CATCreateVPMSession ( pDocRoot, Coid, CompId, Env, Table, server ); if (SUCCEEDED(rc) && (NULL != pDocRoot)) { ... |
Now that the Structure Exploded is opened in the VPM server memory,
you use the CATCreateVPMSession
global method to attach this Structure Exploded
to a new CATProduct type document. You reuse the same Coid
, CompId
, Env
, Table
.
... int nbLevel = 0; rc = ::CATLoadChildrenFromVPM ( pDocRoot, nbLevel ); if (SUCCEEDED(rc)) { ... |
You then request to create in this new CATProduct document all the product structure children
of the Structure Exploded assembly by using the CATLoadChildrenFromVPM
global method.
You set the nbLevel
argument to zero to retrieve all the children.
... rc = ::CATCompleteSessionFromVPM ( pDocRoot ); if (SUCCEEDED(rc)) { ... |
Finaly, you complete the CATProduct structure with all applicative data associated to the whole product struture
by using the CATCompleteSessionFromVPM
global method.
[Top]
... CATLISTP(CATDocument)* ToResetDocuments = NULL; CATLISTP(CATDocument)* ResetDocuments = NULL; ToResetDocuments = new CATLISTP(CATDocument); ToResetDocuments->Append( pDocRoot ); rc = CATPDMServices::ResetPDMDocuments ( ToResetDocuments, ResetDocuments ); ... |
You use the ResetPDMDocuments
statis method of CATPDMServices to reset PDM properties
of the CATProduct prior to set new properties.
... rc = CATVPMServices::SetPDMProperties ( pDocRoot, CATVPMServices::VPM1, CATVPMServices::PermanentBlackBox ); ... |
The CATProduct document must be stored in Publication Exposed mode to become a CATProduct Black Box.
You use the SetPDMProperties
static method of CATVPMServices to set
the CATVPMServices::PermanentBlackBox
mode.
[Top]
... CATBoolean UnloadAfterSave = FALSE; rc = ::CATSaveInVPMFromCATIA( pDocRoot, UnloadAfterSave ); if (FAILED(rc)) { cout << "ERROR in Saving document in Enovia vpm" << endl << flush; } rc = ::CATCommitVPM(); ... |
You use the CATSaveInVPMFromCATIA
global method to save the CATProduct Black Box document.
You use the CATCommitVPM
global method to commit the Save transaction in ENOVIA vpm.
[Top]
... rc = ::CATCloseAssemblyInVPM(); ... |
You use the CATCloseAssemblyInVPM
global method to close the Structure Exploded assembly
opened previously by using CATOpenConfiguredAssemblyInVPM
.
[Top]
... CATUnicodeString printableId; CATBaseUnknown * pDocUnknown = pDocRoot ; rc = CATPDMServices::GetPrintableId ( pDocUnknown, printableId ); CATUnicodeString UpdateCoid = printableId.SubString(0,16); CATUnicodeString UpdateCompid = printableId.SubString(16,16); CATUnicodeString UpdateEnv = printableId.SubString(32,8); CATUnicodeString UpdateTable = printableId.SubString(40,18); ... |
You use the GetPrintableId
static method of CATPDMServices to retrieve the PDM identifier of the document
comming from ENOVIA vpm V4.
... CATVPMServices::SaveAsMode iMod = CATVPMServices::KeepModified; rc= CATVPMServices::SaveAsInVPM ( pDocRoot, UpdateCoid, UpdateCompid, UpdateEnv, UpdateTable, server, iMod); if (SUCCEEDED(rc)) { cout << "Commit transaction in ENOVIA vpm" << endl << flush; rc = ::CATCommitVPM(); if (FAILED(rc)) { ... |
The CATProduct Black Box initialy created in ENOVIA VPM V4 is updated
by using the SaveAsInVPM
static method of CATVPMServices.
You use the CATCommitVPM
global method to commit the Save transaction in ENOVIA vpm.
[Top]
... rc = ::CATDisconnectFromVPM(); ... |
You use the CATDisconnectFromVPM
global method to disconnect from ENOVIA VPM V4 .
rc = ::CATTerminateBatch(); |
You use the CATTerminateBatch
global method to terminate the V5 session.
[Top]
rc = ::Delete_Session(sessionName); |
Do not forget to delete the session at the end of the program using the Delete_Session
global function!
[Top]
This use case has demonstrated how to create a CATProduct Black Box in ENOVIA vpm V4.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[Top] |
Version: 1 [Oct 2005] | Document created |
[Top] |
Copyright © 2003, Dassault Systèmes. All rights reserved.