Equipment & Systems |
Distributive Systems |
Using CATPspservices and CATPspListServicesHow to use CATPspservices and CATPspListServices |
Use Case |
AbstractThis article discusses the CAAPspServices use case. |
This use case is intended to show you how to activate a Plant Ship application and make use of CATPspServices and CATPspListServices functions.
[Top]
CAAPspServices is a use case of the CAAPlantShipInterfaces.edu framework that illustrates CATPlantShipInterfaces framework capabilities.
[Top]
The goal of CAAPspServices is to show you how to use the CATPlantShipInterfaces methods to query and obtain application and domain related information from the objects in a design document.
[Top]
To launch CAAPspServices, you will need to set up the build time environment, then compile CAAPspServices along with its prerequisites, set up the run time environment, and then execute the sample. This is fully described in the referenced article [1]. When launching the use case, you must pass the following arguments:
[Top]
CAAPspServices code is located in the CAAPspServices.m use case module of the CAAPlantShipInterfaces.edu framework:
Windows | InstallRootDirectory\CAAPlantShipInterfaces.edu\CAAPspServices.m |
Unix | InstallRootDirectory/CAAPlantShipInterfaces.edu/CAAPspServices.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of two unique source files named CAAPspServicesMain.cpp and
CAAPspServices.cpp.
Additional prerequisite code is located in the CAAPspUtilities.m directory of the same framework.
[Top]
There are seven logical steps in CAAPspServices:
[Top]
In this use case, we open an input document containing some Equipment and Piping Design objects.
[Top]
The CAAPspServices code is derived from the CAAPspBaseEnv base class. The base class contains functionality common to the other CAAPsp samples. Initializing the environment involves the following method:
CAAPspBaseEnv::CreateCATProductEnv |
This method performs the following functions:
[Top]
First get a physical object from the input document and then create CATIUnknownList interface implementation object by calling CATPspListServices::CreateCATIUnknownList() and then add a IUnknown pointer got from a physical object. In order to locate physical object just added to CATIUnknownList object, use CATPspListServices::Locate() as illustrated in the following code.
rc = CATPspListServices::CreateCATIUnknownList(&piUnkList); // Create a list of unknowns if( SUCCEEDED (rc) ) { cout << "CAAPspServices: " << "Succeeded in creating a CATIUnknownList interface implementation object" << endl; } if ( NULL != piPhysical ) rc = piPhysical->QueryInterface (IID_IUnknown, (void **)&piUnknown); if (SUCCEEDED(rc) && (NULL != piUnknown) && (NULL != piUnkList)) { rc = piUnkList->Add(0,piUnknown); if( SUCCEEDED( rc) ) { int iLocation = 0; iLocation = CATPspListServices::Locate(piUnkList, piUnknown); if( iLocation >= 0) { cout << "Found Physical object in the list at index" << iLocation<< endl; } else { cout << "Could not find the physical object" << endl; } } } |
[Top]
First create CATICStringList interface implementation object by calling CATPspListServices::CreateCATICStringList() and then add a couple of c- strings to the CreateCATICStringList object. In order to locate character string just added to CATICStringList object, use CATPspListServices::Locate() as illustrated in the following code.
if( SUCCEEDED(CATPspListServices::CreateCATICStringList(&pLCStrNames)) && pLCStrNames ) { const char* cStrPiping = "Piping"; const char* cStrTubing = "Tubing"; // Adding strings to the list pLCStrNames->Add(0,cStrPiping); pLCStrNames->Add(0,cStrTubing); // // Calling CATPspListServices::Locate() function to locate "Piping" // int iLocation = 0; iLocation = CATPspListServices::Locate( pLCStrNames, cStrPiping); cout << "Location index =" << iLocation << endl; if( iLocation >= 0) { cout << "Found the string" << endl; } else { cout << "Could not find the string" << endl; } |
First create CATIStringList interface implementation object by calling CATPspListServices::CreateCATIStringList() and then add a couple of wide character strings to the CreateCATIStringList object. In order to locate one of the wide character string just added to CATIStringList object, use CATPspListServices::Locate() as illustrated in the following code.
if ( SUCCEEDED(CATPspListServices::CreateCATICStringList(&pLCStrNames)) && pLCStrNames ) { const char* cStrPiping = "Piping"; const char* cStrTubing = "Tubing"; // Adding strings to the list pLCStrNames->Add(0,cStrPiping); pLCStrNames->Add(0,cStrTubing); // // Calling CATPspListServices::Locate() function to locate "Piping" // int iLocation = 0; iLocation = CATPspListServices::Locate( pLCStrNames, cStrPiping); cout << "Location index =" << iLocation << endl; if( iLocation >= 0) { cout << "Found the string" << endl; } else { cout << "Could not find the string" << endl; } |
Use CATPspServices::ListAllApplicationNames to get a list of application names
if( SUCCEEDED( CATPspServices::ListAllApplicationNames( &pLApplNames) ) ) { unsigned int LCStrSize = 0; int NumOfCStr = 0; if (pLApplNames) HRESULT rc = pLApplNames->Count (&LCStrSize); NumOfCStr = LCStrSize; if (NumOfCStr) { cout << "Number of Applications = " << NumOfCStr <<endl; |
Use CATPspServices::ListAllDomainNamesto get a list of domain names
if( SUCCEEDED( CATPspServices::ListAllDomainNames( &pLDomainNames) )) { unsigned int LCStrSize = 0; int NumOfCStr = 0; if (pLDomainNames) HRESULT rc = pLDomainNames->Count (&LCStrSize); NumOfCStr = LCStrSize; if (NumOfCStr) { cout << "Number of Domains =" << NumOfCStr <<endl; |
[Top]
This use case has demonstrated how to use the CATPspServices and CATPspListServices functions. Specifically, it has illustrated:
[Top]
[1] | Building and Launching a CAA V5 Use Case |
Version: 1 [March 2003] | Document created |
[Top] |
Copyright © 2003, Dassault Systèmes. All rights reserved.