Equipment & Systems Engineering

Electrical Harness Installation

Browsing an Electrical Network

How to retrieve connected objects
Use Case

Abstract

This article discusses the CAAEhiNetwork use case. This use case explains how to navigate within an electrical network.


What You Will Learn With This Use Case

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]

The CAAEhiNetwork Use Case

CAAEhiNetwork is a use case of the CAAElecHarnessItf.edu framework that illustrates the ElecHarnessItf framework capabilities.

[Top]

What Does CAAEhiNetwork Do

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]

How to Launch CAAEhiNetwork?

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"

[Top]

Where to Find the CAAEhiNetwork Code?

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]

Step-by-Step

There are six logical steps in CAAEhiNetwork:

  1. Prolog
  2. Initializing Electrical Environment
  3. Retrieving; all Electrical Products under Root Product and Select one Bundle Segment to Analyze
  4. Retrieving Connectors linked to Bundle Segment
  5. Retrieving Connectors connected to Bundle Segment Connectors
  6. Epilog

We will now comment each of those sections by looking at the code.

[Top]

Prolog

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]

Initializing Electrical Environment

...
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 Product under Root Product and Select one Bundle Segment to Analyze

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]

Retrieving Electrical Connectors linked to the Bundle Segment

The generic methods to retrieve objects connected to an electrical object are the following :

  1. Get connection points of object using CATIEhiNetwork::ListConnectorPoints method .
  2. For each connection point , get connected connection points using CATIEhiNetworkExtremity::ListConnectedConnectorPoints method .
  3. For each connected connector point found , retrieve associated electrical object using 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]

Retrieving Connectors connected to Bundle Segment Connectors

...
  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]

Epilog

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

Opened documents are removed and session is deleted before exit.

[Top]

 


In Short

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 :

[Top]


References

[1] Browsing a Product Structure
[2] Building and Launching a CAA V5 Use Case
[3] Using Persistent Parameters
[4] About Units
[Top]

History

Version: 1 [Jul 2001] Document created
[Top]

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