Equipment & Systems Engineering

Electrical Library

Retrieving and Analyzing Electrical Objects

How to retrieve electrical devices and navigate in the product tree
Use Case

Abstract

This article discusses the ElecDeviceItf use case. This use case explains how to manage electrical objects in the tree of product


What You Will Learn With This Use Case

This use case is intended to help you make your first steps in programming with CATIA ELB Interfaces. Its main intent is to allow you to manage electrical objects and to show you how to retrieve electrical object under the root product and how to navigate through the electrical model of CATIA V5.

[Top]

The CAAElecDevice Use Case

CAAElecDevice is a use case of the CAAElecDeviceItf.edu framework that illustrates the CATIA ELB Interfaces framework capabilities.

[Top]

What Does CAAElecDevice Do?

The goal of CAAElecDevice use case is to show how to manage Electrical objects and how to use the services of infrastructure of the interfaces which define the behavior of electric objects as CATIElbEquipment, CATIElbSingleConnector or CATIElbConnectorShell for example.

Above is a CATIA image of a electrical model we will use for our study. [Top]

How to Launch CAAElecDevice ?

To launch CAAElecDevice, you will need to set up the build time environment, then compile CAAElecDevice along with its prerequisites, set up the run time environment, and then execute the sample.

To launch the use case, execute the following command:

mkrun -c "CAAElecDevice input.CATProduct" 

[Top]

Where to Find the CAAElecDevice Code

The CAAElecDevice sample is made of a single class named CAAElecDevice located in the CAAElecDevice.m module of the CAAElecDeviceItf.edu framework:

Windows InstallRootDirectory\CAAElecDeviceItf.edu\CAAElecDevice.m\
Unix InstallRootDirectory/CAAElecDeviceItf.edu/CAAElecDevice.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

This sample deals with the following classes:

IUnknown Base Class for the References and Instances
CATSessionServices Class for managing the session
CATDocument Class for the document base class
CATDocumentServices Class for managing document in the session
CATIDocRoots Class for browsing root object in document
CATIGSMSpline Interface allows to access data of the spline feature
CATICkeInst Interface dedicated to parameters value management
CATIEleDocServices Interface dedicated electrical environment initialization
CATIElecAttrAccess Interface dedicated to manage electrical attribute
CATIElbEquipment Interface for defining electrical equipment behavior
CATIElbSingleConnector Interface for defining single connector behavior
CATIElbCavity Interface for defining electrical cavity behavior
CATIElbConnectorShell Interface for defining electrical connector shell behavior
CATIElbTermination Interface for defining electrical termination behavior
CATIElbBundleCnctPt Interface for defining electrical bundle connection point behavior

[Top]

Step-by-Step

We will now first comment the Electrical environment and it’s components creation by looking at the code of the CAAElecDevice. There are 16 logical steps in CAAElecDevice:

# Step
1 Creating the session and opening an existing CATProduct
2 Retrieving the root product of the CATProduct document
3 Initializing Electrical Environment
4 Retrieving all electrical equipment under the root product
5 Selecting the first equipment of model and to analyze it.
6 Retrieving the list of cavity of the first equipment.
7 Retrieving the parent of each cavity of the list.
8 Retrieving the Device plugged in the cavity
9 If the device plugged in the cavity is a single connector, retrieving its list of cavity.
10 Retrieving the list of bundle connection point of single connector.
11 Retrieving the list of contact aggregate in the single connector.
12 If the device plugged in cavity of first equipment is a connector shell retrieving its list of cavity.
13 Retrieving the cavity of the father equipment used by the connector shell.
14 Selecting the second equipment of model and to analyse it.
15 Retrieving the list of bundle connection point defined on the second equipment.
16 Epilog

[Top]

Creating the session and opening an existing CATProduct

We need a CATSession pointer to create the Session.

...
CATSession *pSession = NULL;
char *sessionName = "CAA_ElbDevice_Session";
HRESULT rc = ::Create_Session(sessionName,pSession);
...

We need a CATDocument pointer to opening the document.

...
CATDocument *pDoc = NULL;
rc = CATDocumentServices::OpenDocument(argv[1], pDoc);
...

Once the current session has been created, the CATProduct document can be loaded into the session. pDoc is a pointer to this document.

[Top]

Retrieving the root product of the CATProduct document

We need a CATProduct pointer to retrieve the root product.

....
  CATIProduct* piRootProduct = NULL;  
  CATIDocRoots * pDocRoots = NULL;
  rc = pDoc->QueryInterface(IID_CATIDocRoots,(void**) &pDocRoots);
  ...
  CATListValCATBaseUnknown_var* pListRootProduct = pDocRoots->GiveDocRoots();
  ...
  
  if ( pListRootProduct && pListRootProduct->Size() )
  {  
    rc = (*pListRootProduct)[1]->QueryInterface(IID_CATIProduct,(void**) &piRootProduct );
  }
...

[Top]

Initializing Electrical Environment

We initialize the Document by using CATIEleDocServices interface pointer and the method Initialize() on it.

....
  CATIEleDocServices * piElecDocServices = NULL;  
  rc = pDoc->QueryInterface(IID_CATIEleDocServices,(void**) &piElecDocServices );
  if ( SUCCEEDED(rc) && piElecDocServices )
  {
    rc = piElecDocServices->Initialize();
  }
...

Initializing the electrical environment is mandatory to enable access to electrical object or electrical attributes.

[Top]

Retrieving all electrical equipment under the root product

We need a generic method GetAllChildren() of interface CATIProduct to retrieve all equipment defined under the root product.

...
CATListValCATBaseUnknown_var* pListElectricalEquipment = NULL;
pListElectricalEquipment = piRootProduct->GetAllChildren(CATIElbEquipment::ClassName());
piRootProduct -> Release();
piRootProduct = NULL ;
  
int NumberOfEquipment = 0;
if ( (NULL!=pListElectricalEquipment) && pListElectricalEquipment->Size() ) 
      NumberOfEquipment = pListElectricalEquipment->Size();	
...

[Top]

Selecting the first equipment of model and to analyse it

We need a CATIElbEquipment interface pointer to be able to selecting the first equipment defined under the root poduct..

...
CATIElbEquipment * piFirstElecEquipment = NULL;
rc = (*pListElectricalEquipment)[1]->QueryInterface(IID_CATIElbEquipment,(void**) &piFirstElecEquipment);
...

[Top]

Retrieving the list of cavity of the first equipment

We use method ListCavities() of CATIElbEquipment interface to find the list of cavities defined on the first equipment. Every element of the list adheres to the CATIElbCavity interface.

...
 CATListValCATBaseUnknown_var* pListOfCavity = NULL;
rc = piFirstElecEquipment ->ListCavities(pListOfCavity);
int nNumberOfCavity = pListOfCavity? pListOfCavity->Size() : 0;
...

Above is a CATIA image of connectivity of first equipment.

Above is a CATIA image of the tree of connectivity of first equipment. We can see the list of cavity defined on the first equipment

[Top]

Retrieving the parent of each cavity of the list

We need the method GetParent() of the interface CATIElbCavity to find where the cavity is aggregate.

...
  for(int i=1;i<=nNumberOfCavity;i++)
  {
    CATIElbCavity * pElecCavity =NULL;
    if(SUCCEEDED((*pListOfCavity)[i]->QueryInterface(IID_CATIElbCavity,(void**)& pElecCavity)) && pElecCavity)
    {      
      CATBaseUnknown * pParentOfCavity = NULL;
      rc = pElecCavity->GetParent(pParentOfCavity);
    }
  }
... 

[Top]

Retrieving the Device plugged in the cavity

We need the method GetPluggedInDevice () of the interface CATIElbCavity to find the device connected with the cavity.

...
      
CATBaseUnknown * pDevicePluggedInCavity = NULL;
rc = pElecCavity->GetPluggedInDevice(pDevicePluggedInCavity);
...

[Top]

If the device plugged in the cavity is a single connector, retrieving its list of cavity

The device plugged in the cavity is a single connector if it adheres to the interface CATIElbsingleConnector. The method ListCavities() of CATIElbSingleConnector interface allows to find the list of cavity defined on the single connector.

...
CATIElbSingleConnector * pElecSingleConnector = NULL;
if(SUCCEEDED(pDevicePluggedInCavity->QueryInterface(IID_CATIElbSingleConnector,(void**)& pElecSingleConnector)) &&pElecSingleConnector )
{
  CATListValCATBaseUnknown_var * pListCavityOfSic = NULL;
  rc = pElecSingleConnector->ListCavities(pListCavityOfSic);
  int NumberOfCavity = pListCavityOfSic?pListCavityOfSic->Size():0;
} ...

		

Above is a CATIA image of general view of single connector.

Above is a CATIA image of connectivity of the single connector

Above is a CATIA image of the tree of connectivity of single connector. We can see the list of cavity defined on the single connector

[Top]

Retrieving the list of bundle connection point of single connector

We need the method ListBundleCnctPts() of CATIElbSingleConnector interface to find the list of bundle connection point defined on the single connector.

...
CATListValCATBaseUnknown_var * pListBundleCnctPtOfSic = NULL;
rc = pElecSingleConnector->ListBundleCnctPts(pListBundleCnctPtOfSic);
int NumberOfBCP = pListBundleCnctPtOfSic?pListBundleCnctPtOfSic->Size():0;
...

[Top]

Retrieving the list of contact aggregate in the single connector

We need the method ListDeviceComposition() of CATIElbSingleConnector interface to find the list of contact (or filler plug) defined on the single connector.

...
CATListValCATBaseUnknown_var * pListDeviceComposition = NULL;
rc = pElecSingleConnector->ListDeviceComposition(pListDeviceComposition);
int NumberOfContact = pListDeviceComposition?pListDeviceComposition->Size():0;
...

[Top]

If the device plugged in cavity of first equipment is a connector shell retrieving its list of cavity

The device plugged in the cavity is a connector if it adheres to the interface CATIElbConnectorShell. The method ListCavities() of CATIElbConnectorShell interface allows to find the list of cavity defined on the connector shell.

...
CATIElbConnectorShell * pElecConnectorShell = NULL;
if(SUCCEEDED(pDevicePluggedInCavity->QueryInterface(IID_CATIElbConnectorShell,(void**)& pElecConnectorShell)) && pElecConnectorShell )
{
  CATListValCATBaseUnknown_var * pListCavityInConnectorShell = NULL;
  rc = pElecConnectorShell->ListCavities(pListCavityInConnectorShell); 
  int NumberOfShellCavity = pListCavityInConnectorShell?pListCavityInConnectorShell->Size():0;
}
...

Above is a CATIA image of connectivity of the connector shell

Above is a CATIA image of the tree of connectivity of connector shell. We can see its list of cavity.

[Top]

Retrieving the cavity of the father equipment used by the connector shell

We need the method GetEquipmentCavity of CATIElbConnectorShell interface to find the cavity where the connector shell is inserted.

...
CATIElbCavity * pElecCavityOfFatherEquipment = NULL;
rc =pElecConnectorShell->GetEquipmentCavity(pElecCavityOfFatherEquipment);

[Top]

Selecting the second equipment of model and analyze it

CATIElbEquipment * piSecondElecEquipment = NULL;
rc = (*pListElectricalEquipment)[2]->QueryInterface(IID_CATIElbEquipment,(void**) &piSecondElecEquipment);

Retrieving the list of bundle connection point defined on the second equipment

We need the method ListBundleCnctPts() of CATIElbEquipment interface to find the bundle connection point defined on the equipment.

...
CATListValCATBaseUnknown_var * pListBCPinEquipment = NULL;
rc = piSecondElecEquipment->ListBundleCnctPts(pListBCPinEquipment);
if(piSecondElecEquipment) piSecondElecEquipment->Release();
piSecondElecEquipment = NULL;
int tailleListBCP = pListBCPinEquipment ? pListBCPinEquipment->Size() : 0;
...

Above is a CATIA image of the second equipment.

[Top]

Epilog

Removing document from session and closing the session.

rc = CATDocumentServices::Remove(*pDoc);
rc = ::Delete_Session(sessionName);

[Top]


In Short

This use case has demonstrated the way to navigate electrical entities in a document and how use electrical services to manage electrical model.

[Top]


References

[1] Building and Launching a CAA V5 Use Case
[Top]

History

Version: 1 [August 2002] Document created
[Top]

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