Equipment & Systems Engineering |
Electrical Harness Installation |
Browsing an Electrical NetworkHow to retrieve connected objects |
Use Case |
AbstractThis article discusses the CAAEhiNetwork use case. This use case explains how to navigate within an electrical network. |
This use case is intended to show you how to browse electrical objects within product structure and analyze electrical connectivities between objects.
Following operations are detailed is this use case :
[Top]
CAAEhiNetwork is a use case of the CAAElecHarnessItf.edu framework that illustrates the ElecHarnessItf framework capabilities.
[Top]
The goal of CAAEhiNetwork is to navigate within an electrical network and to analyse electrical connectivities. The existing product structure is found under the pathname of the document passed as an argument to this program.
Above is a CATIA image of a product structure we will use as an example.
[Top]
To launch CAAEhiNetwork, you will need to set up the build time environment, then compile CAAEhiNetwork.cpp along with its prerequisites, set up the run time environment, and then execute the use case. This is fully described in the referenced article [2].
To launch the use case, execute the following command:
mkrun -c "CAAEhiNetwork input.CATProduct"
InstallRootDirectory\OS\resources\graphic
where InstallRootDirectory is the root directory of your CAA V5 installation, and OS is a directory the name of which depends on the operating system. Refer to [2] to get the list of the currently supported operating systems and their associated directory names.
[Top]
CAAEhiNetwork code is located in the CAAEhiNetwork.m use case module of the CAAElecHarnessItf.edu framework:
Windows | InstallRootDirectory/CAAElecHarnessItf.edu/CAAEhiNetwork.m |
Unix | InstallRootDirectory\CAAElecHarnessItf.edu\CAAEhiNetwork.m |
where InstallRootDirectory
is the root directory of your CAA V5
installation. It is made of a unique source file named CAAEhiNetwork.cpp.
[Top]
There are six logical steps in CAAEhiNetwork:
We will now comment each of those sections by looking at the code.
[Top]
Once the current session has been created, the CATProduct document can be loaded into the session . pDoc is a pointer to this document.
The root product of the document is retrieved . pRootProduct is a CATIProduct handle to the root product.
Methodology describing how to load a CATProduct document and how to retrieve the root product is described in [1].
[Top]
... 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]
We use generic method CATIProduct::GetAllChildren to retrieve all products under root product.
... CATListValCATBaseUnknown_var* pListProduct = NULL; pListProduct = piRootProduct->GetAllChildren(CATIProduct::ClassName()); piRootProduct -> Release(); piRootProduct = NULL ; int NumberOfProduct = 0; if ( (NULL!=pListProduct) && pListProduct->Size() ) { NumberOfProduct = pListProduct->Size(); cout << "> number of products found : "<< NumberOfProduct << endl << flush; } ... |
We extract the list of electrical object from list of products by using CATIEhiNetwork interfaces.
... CATListValCATBaseUnknown_var* pListNetworkObject = new CATLISTV(CATBaseUnknown_var); int NumberOfNetworkObject = 0; CATIEhiNetwork * piNetworkObject = NULL; int i=0; for ( i=1; i<= NumberOfProduct; i++ ) { if ( SUCCEEDED( (*pListProduct)[i]->QueryInterface(IID_CATIEhiNetwork,(void**) &piNetworkObject))) { pListNetworkObject->Append((*pListProduct)[i]); piNetworkObject->Release(); piNetworkObject=NULL; } } ... |
First bundle segment found in list is selected to be analyzed ( CATIEhiBundleSegment interface is used to extract bundle segment from list of electrical objects ).
... CATIEhiBundleSegment * piBundleSegment = NULL; int rank = 1; while ( rank<=NumberOfNetworkObject && FAILED((*pListNetworkObject)[rank]->QueryInterface(IID_CATIEhiBundleSegment,(void**) &piBundleSegment)) ) rank++; ... |
[Top]
The generic methods to retrieve objects connected to an electrical object are the following :
CATIEhiNetwork::ListConnectorPoints
method .CATIEhiNetworkExtremity::ListConnectedConnectorPoints
method .CATIEhiNetworkExtremity::GetElectricalObject
method .
... CATListValCATBaseUnknown_var* pListConnector = new CATLISTV(CATBaseUnknown_var); if ( SUCCEEDED(piBundleSegment->QueryInterface(IID_CATIEhiNetwork,(void**) &piNetworkObject)) ) { CATListValCATBaseUnknown_var* pListConnectorPoint = NULL; piNetworkObject->ListConnectorPoints(&pListConnectorPoint); if ( NULL!=pListConnectorPoint ) { int NumberOfConnectorPoint = pListConnectorPoint->Size(); CATIEhiNetworkExtremity * piNetworkExtremity = NULL; for ( i=1; i<=NumberOfConnectorPoint; i++ ) { CATListValCATBaseUnknown_var* pListConnected = NULL; (*pListConnectorPoint)[i]->QueryInterface(IID_CATIEhiNetworkExtremity,(void**) &piNetworkExtremity); if ( NULL != piNetworkExtremity ) { piNetworkExtremity->ListConnectedConnectorPoints(&pListConnected); if ( NULL != pListConnected ) { int NumberOfConnected = pListConnected->Size(); CATBaseUnknown * piConnectedObject=NULL; CATIEhiNetworkExtremity * piConnectedExtremity = NULL; for ( int j=1; j<=NumberOfConnected; j++ ) { (*pListConnected)[j]->QueryInterface(IID_CATIEhiNetworkExtremity,(void**) &piConnectedExtremity); if ( NULL != piConnectedExtremity ) { piConnectedExtremity->GetElectricalObject(&piConnectedObject); piConnectedExtremity->Release(); piConnectedExtremity=NULL; if ( NULL != piConnectedObject ) { CATBaseUnknown_var spObject = piConnectedObject; if ( NULL_var != spObject ) pListConnector->Append(spObject); ... |
This first example illustrates method to retrieve electrical connectors linked to bundle segment (pListConnector).
[Top]
... CATListValCATBaseUnknown_var* pListConnectedConnector = new CATLISTV(CATBaseUnknown_var); int NumberOfConnectedConnector = 0; int NumberOfConnector = pListConnector->Size(); cout << "> number of connected connector ? "<< endl << flush; for ( i=1; i<=NumberOfConnector; i++ ) { cout << " process connector number "<< i <<endl << flush; if ( SUCCEEDED((*pListConnector)[i]->QueryInterface(IID_CATIEhiNetwork,(void**) &piNetworkObject)) ) { // -- retrieving connector points of electrical connector CATListValCATBaseUnknown_var* pListConnectorPoint = NULL; piNetworkObject->ListConnectorPoints(&pListConnectorPoint); if ( NULL!=pListConnectorPoint ) { int NumberOfConnectorPoint = pListConnectorPoint->Size(); CATIEhiNetworkExtremity * piNetworkExtremity = NULL; cout << " number of connector point = "<< NumberOfConnectorPoint <<endl << flush; for ( int j=1; j<=NumberOfConnectorPoint; j++ ) { cout << " process connector point "<< j <<endl << flush; CATListValCATBaseUnknown_var* pListConnected = NULL; (*pListConnectorPoint)[j]->QueryInterface(IID_CATIEhiNetworkExtremity,(void**) &piNetworkExtremity); if ( NULL != piNetworkExtremity ) { piNetworkExtremity->ListConnectedConnectorPoints(&pListConnected); if ( NULL != pListConnected ) { int NumberOfConnected = pListConnected->Size(); cout << " number of connected connector point "<< NumberOfConnected <<endl << flush; CATBaseUnknown * piConnectedObject=NULL; CATIEhiNetworkExtremity * piConnectedExtremity = NULL; for ( int k=1; k<=NumberOfConnected; k++ ) { (*pListConnected)[k]->QueryInterface(IID_CATIEhiNetworkExtremity,(void**) &piConnectedExtremity); if ( NULL != piConnectedExtremity ) { piConnectedExtremity->GetElectricalObject(&piConnectedObject); piConnectedExtremity->Release(); piConnectedExtremity=NULL; if ( NULL != piConnectedObject ) { CATIElecAttrAccess * piElecAttribute = NULL; CATUnicodeString ElecType = "unknown"; CATUnicodeString BundleSegmentType = "ElecBundleSegment"; if ( SUCCEEDED( piConnectedObject->QueryInterface(IID_CATIElecAttrAccess,(void**) &piElecAttribute) )) { piElecAttribute->GetElecType(ElecType); if ( ElecType != BundleSegmentType ) { CATBaseUnknown_var spObject = piConnectedObject; if ( NULL_var != spObject ) pListConnectedConnector->Append(spObject); ... |
Second example illustrates the way to retrieve connectors connected bundle segment connectors ( pListConnectedConnector ).
[Top]
... rc = CATDocumentServices::Remove(*pDoc); ... rc = ::Delete_Session(sessionName); ... |
Opened documents are removed and session is deleted before exit.
[Top]
This use case is has demonstrated how to browse electrical objects within product structure and analyze electrical connectivity between objects.
Following operations have been detailed is this use case :
Initialize
method
of CATIEleDocServices.ListConnectorPoints
method of CATIEhiNetwork.ListConnectedConnectorPoints
of CATIEhiNetworkExtremity.GetElectricalObject
of CATIElecAttrAccess.[Top]
[1] | Browsing a Product Structure |
[2] | Building and Launching a CAA V5 Use Case |
[3] | Using Persistent Parameters |
[4] | About Units |
[Top] |
Version: 1 [Jul 2001] | Document created |
[Top] |
Copyright © 2001, Dassault Systèmes. All rights reserved.