Equipment & Systems Engineering

Electrical Library

Connecting Electrical Objects

How to connect an electrical single connector with another electrical single connector, a back shell or a mounting equipment
Use Case

Abstract

This article discusses the ElecDeviceItf use case. This use case explains how to connect an electrical single connector with another electrical single connector or back shell or mounting equipment, or how to connect an electrical mounting equipment with an electrical equipment.


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 connect an electrical single connector with another electrical single connector or back shell or mounting equipment, or how to connect an electrical mounting equipment with an electrical equipment.

[Top]

The CAAElecConnectDevices Use Case

CAAElecConnectDevices is a use case of the CAAElecDeviceItf.edu framework that illustrates the CATIA ELB interfaces framework capabilities.

[Top]

What Does CAAElecConnectDevice Do

The goal of CAAElecConnectDevice use case is to show how to connect electrical single connector with a back shell or with another single connector or with a mounting equipment, or how to connect an equipment with a mounting equipment. To do that, the methods of the interfaces which define the behaviour of electrical devices are used, such as CATIElbSingleConnector for example.

Above is a CATIA image of the electrical model which is used in our sample.

[Top]

How to Launch CAAElecConnectDevices

To launch CAAElecConnectDevices, you will need to set up the build time environment, then compile CAAElecConnectDevices 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 "CAAElecConnectDevices input.CATProduct output.CATProduct"

[Top]

Where to Find the CAAElecConnectDevices Code

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

Windows InstallRootDirectory\CAAElecDeviceItf.edu\CAAElecConnectDevices.m\
Unix InstallRootDirectory/CAAElecDeviceItf.edu/CAAElecConnectDevices.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
CATIProduct Interface dedicated to define product behaviour
CATIEleDocServices Interface dedicated electrical environment initialisation
CATIElbSingleConnector Interface for defining single connector behaviour
CATIElbConnectorCnctPt Interface for defining electrical connector connection point behaviour
CATIElbBackShell Interface for defining electrical back shell behaviour
CATIElbBackShellCnctPt Interface for defining electrical back shell connection point behaviour
CATIElbEquipment Interface for defining electrical equipment behaviour
CATIElbMountingEquipment Interface for defining electrical mounting equipment behaviour
CATIElbCavity Interface for defining electrical cavity behaviour

[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 17 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 single connector and back shell under the root product
5 Selecting the single connector which part number is "First_Single_Connector".
6 Retrieving the list of back shell connector point defined on the first single connector.
7 Connecting the first single connector with the back shell which part number is "Second_Back_Shell".
8 Selecting the single connector which part number is "Second_Single_Connector".
9 Retrieving the list of back shell connection point defined on the second single connector.
10 Connecting the second single connector with the back shell which part number is "First_Back_Shell".
11 Retrieving the list of connector connection point defined on the first single connector.
12 Connecting the first single connector with the second single connector.
13 Retrieving all equipments under the root product
14 Retrieving all mounting equipments under the root product
15 Connecting the third single connector with the mounting equipment which part number is "First_Mounting_Equipment".
16 Connecting the second mounting equipment with the first equipment
17 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_ElbConnectDevice_Session";
HRESULT rc = ::Create_Session(sessionName,pSession);
...

We need a CATDocument pointer to open 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 single connector and back shell under the root product

We need a generic method GetAllChildren() of interface CATIProduct to retrieve all single connector and back shell defined under the root product.

...
  CATListValCATBaseUnknown_var* pListElbSingleConnector = NULL;
  pListElbSingleConnector = piRootProduct->GetAllChildren(CATIElbSingleConnector::ClassName());
    
  int NumberOfSingleConnector = 0;
  if ( (NULL!=pListElbSingleConnector) && pListElbSingleConnector->Size() ) 
  {NumberOfSingleConnector = pListElbSingleConnector->Size();
... 
  CATListValCATBaseUnknown_var* pListElbBackShell = NULL;
  pListElbBackShell = piRootProduct->GetAllChildren(CATIElbBackShell::ClassName());
  piRootProduct -> Release();
  piRootProduct = NULL ;
  
  int NumberOfBackShell = 0;
  if ( (NULL!=pListElbBackShell) && pListElbBackShell->Size() ) 
  {
    NumberOfBackShell = pListElbBackShell->Size();
  }
...	

[Top]

Selecting the single connector which part number is "First_Single_Connector"

We select the first single connector defined under the root product using the CATIElbSingleConnector interface pointer.

...
CATIElbSingleConnector * pFirst_SingleConnector = NULL;
rc = (*pListElbSingleConnector)[2]->QueryInterface(IID_CATIElbSingleConnector,(void**) &pFirst_SingleConnector);
...

[Top]

Retrieving the list of back shell connection point defined on the first single connector

We use method ListBackShellCnctPt() of CATIElbSingleConnector interface to find the list of back shell defined on the first single connector.

...
CATListValCATBaseUnknown_var * pListBackShellCnctPt = NULL;
rc = pFirst_SingleConnector->ListBackShellCnctPts(pListBackShellCnctPt);

int SizeBackShellCnctPt = pListBackShellCnctPt ? pListBackShellCnctPt->Size() :0;
...

Above is a CATIA image of connectors defined on the first single connector

Above is a CATIA image of the second back shell.

[Top]

Connecting the first single connector with the back shell which part number is "Second_Back_Shell"

We need the method ConnectBackShell() of the interface CATIElbSingleConnector to connect the back shell with the first single connector using a back shell connection point.

...
  CATIElbBackShellCnctPt_var hElbBackShellCnctPt(pElbBackShellCnctPt);
  pElbBackShellCnctPt->Release();
  pElbBackShellCnctPt = NULL;
  int  StatusOfGeometricalConstraint= 0;
  rc = pFirst_SingleConnector->ConnectBackShell(hElbBackShellCnctPt,hSecond_BackShell,  StatusOfGeometricalConstraint);
... 

[Top]

Selecting the single connector which part number is "Second_Single_Connector"

We select the second single connector defined under the root product using the CATIElbSingleConnector interface pointer.

...
CATIElbSingleConnector * pSecond_SingleConnector = NULL;
rc = (*pListElbSingleConnector)[1]->QueryInterface(IID_CATIElbSingleConnector,(void**) &pSecond_SingleConnector);
...

[Top]

Retrieving the list of back shell connection point defined on the second single connector

The list of back shell connection point of the second single connector is found using the same method used for the first single connector..

...
rc = pSecond_SingleConnector->ListBackShellCnctPts(pListBackShellCnctPt);
SizeBackShellCnctPt = pListBackShellCnctPt ? pListBackShellCnctPt->Size() :0;
...
rc = (*pListBackShellCnctPt)[1] -> QueryInterface(IID_CATIElbBackShellCnctPt ,(void**) & pElbBackShellCnctPt);
...

Above is a CATIA image of second single connector.

Above is a CATIA image of the first back shell.

[Top]

Connecting the second single connector with the back shell which part number is "First_Back_Shell"

We need the method ConnectBackShell() of CATIElbSingleConnector interface to connect the first single connector with the back shell.

...
CATIElbBackShell_var hFirst_BackShell ( (*pListElbBackShell)[1]) ;
rc = pSecond_SingleConnector->ConnectBackShell(hElbBackShellCnctPt ,hFirst_BackShell,  StatusOfGeometricalConstraint);
...

[Top]

Retrieving the list of connector connection point defined on the first single connector

We need the method ListConnectorsCnctPts of CATIElbSingleConnector interface to find the list of connectors connection point defined on the single connector.

...
CATListValCATBaseUnknown_var * pListConnectorCnctPt = NULL;
rc = pFirst_SingleConnector->ListConnectorCnctPts(pListConnectorCnctPt);
int SizeListConnectorCnctPt = pListConnectorCnctPt  ? pListConnectorCnctPt ->Size() : 0;
...

[Top]

Connecting the first single connector with the second single connector

We need the method ConnectSingleConnector() of CATIElbSingleConnector interface to connect the first single connector with the second single connector.

...
CATIElbSingleConnector_var hSecond_SingleConnector(pSecond_SingleConnector);
rc = pFirst_SingleConnector->ConnectSingleConnector(hElecConnectorCnctPt,hSecond_SingleConnector,StatusOfGeometricalConstraint);
...

Above is a CATIA image of the connection between first and second single connector

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

[Top]

Retrieving all equipments under the root product

We use the generic method GetAllChildren() of interface CATIProduct to retrieve all equipments defined under the root product. pFirst_Equipment is a pointer on the equipment called "First_Equipment".

...
  CATListValCATBaseUnknown_var* pListElbEquipment = NULL;
  pListElbEquipment = piRootProduct->GetAllChildren(CATIElbEquipment::ClassName());

  // selecting the first equipment : "First_Equipment"
  // ------------------------------------------------------------
  CATIElbEquipment * pFirst_Equipment= NULL;
  rc = (*pListElbEquipment)[1]->QueryInterface(IID_CATIElbEquipment,(void**) &pFirst_Equipment);
...

Above is a CATIA image of the equipment "First_Equipment".

Retrieving all mounting equipments under the root product

We use the generic method GetAllChildren() of interface CATIProduct to retrieve all mounting equipments defined under the root product.

pFirst_MountingEquipment is a pointer on the mounting equipment called "First_Mounting_Equipment".

pSecond_MountingEquipment is a pointer on the mounting equipment called "Second_Mounting_Equipment".

...
  CATListValCATBaseUnknown_var* pListElbMountingEquipment = NULL;
  pListElbMountingEquipment = piRootProduct->GetAllChildren(CATIElbMountingEquipment::ClassName());

  // selecting the first equipment : "First_Mounting_Equipment"
  // ------------------------------------------------------------
  CATIElbEquipment * pFirst_MountingEquipment= NULL;
  rc = (*pListElbMountingEquipment)[1]->QueryInterface(IID_CATIElbMountingEquipment,(void**) &pFirst_MountingEquipment);

  // selecting the mounting equipment : "Second_Mounting_Equipment"
  // -------------------------------------------------------------
  CATIElbMountingEquipment * pSecond_MountingEquipment= NULL;
  rc = (*pListElbMountingEquipment)[2]->QueryInterface(IID_CATIElbMountingEquipment,(void**) &pSecond_MountingEquipment);
...

Above is a CATIA image of the mounting equipment "Second_Mounting_Equipment" .

[Top]

Connecting the third single connector with the first mounting equipment

The method AddDevice of CATIElbMountingEquipment is used to link the third single connector with the first mounting equipment :

...
   // search a cavity on the mounting equipment :
   CATListValCATBaseUnknown_var * pListCavities = NULL;
   rc = pFirst_MountingEquipment->ListCavities(pListCavities);

   CATIElbCavity * pElecCavity = NULL;
   rc = (*pListCavities)[1]->QueryInterface(IID_CATIElbCavity,(void **) & pElecCavity) ;

   // search a CATBaseUnknown on the single connector :

   CATBaseUnknown * pUnkOfConnector = NULL;
   rc = pThird_SingleConnector->QueryInterface(IID_CATBaseUnknown,(void**) &pUnkOfConnector);

   //
   // connecting the first mounting equipment and the third single connector

   rc = pFirst_MountingEquipment->AddDevice(pElecCavity,pUnkOfConnector,StatusOfGeometricalConstraint);
...

Above is a CATIA image showing the link between the third single connector and the first mounting equipment

[Top]

Connecting the second mounting equipment and the first equipment

The method AddDevice of CATIElbMountingEquipment is used to link the second mounting equipment with the first equipment :

...
   // search a cavity on the mounting equipment :
   CATListValCATBaseUnknown_var * pListCavities = NULL;
   rc = pSecond_MountingEquipment->ListCavities(pListCavities);

   rc = (*pListCavities)[1]->QueryInterface(IID_CATIElbCavity,(void **) & pElecCavity) ;

   // search a CATBaseUnknown on the single connector :

   CATBaseUnknown * pUnkOfEquipment = NULL;
   rc = pFirst_Equipment->QueryInterface(IID_CATBaseUnknown,(void**) &pUnkOfEquipment);

   //
   // connecting the second mounting equipment and the first equipment :

   rc = pSecond_MountingEquipment->AddDevice(pElecCavity,pUnkOfConnector,StatusOfGeometricalConstraint);
...

Above is a CATIA image showing the link between the second mounting equipment and the first equipment.

[Top]

Epilog

Removing document from session and closing the session.

  CATBoolean iSavePointedIfNecessary = TRUE; 
  rc = CATDocumentServices::SaveAs ( *pDoc,argv[2],".CATProduct",iSavePointedIfNecessary );
...
rc = CATDocumentServices::Remove(*pDoc);
rc = ::Delete_Session(sessionName);
...

[Top]


In Short

This use case has demonstrated the way to connect electrical devices such as single connector with a single connector, a back shell or mounting equipment, and also the way to connect an equipment with a mounting equipment.

[Top]


References

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

History

Version: 1 [March 2003] Document created
[Top]

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