Equipment & Systems

Distributive Systems

Accessing Network Connectivity and Connector Flow Data

How to access network connectivity data
Use Case

Abstract

This article discusses the CAAPspConnectivity use case.


What You Will Learn With This Use Case

This use case is intended to show you how to obtain a part's connectors and get connectivity and connector flow data.

[Top]

The CAAPspConnectivity Use Case

CAAPspConnectivity  is a use case of the CAAPlantShipInterfaces.edu framework that illustrates CATPlantShipInterfaces framework capabilities.

[Top]

What Does CAAPspConnectivity Do

The goal of  CAAPspConnectivity  is to show you how to use the CATPlantShipInterfaces methods to query and obtain part connector and connection information. 

                                                                                                                                                                                                                                  [Top]

How to Launch CAAPspConnectivity

To launch CAAPspConnectivity, you will need to set up the build time environment, then compile CAAPspConnectivity  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]

Where to Find the CAAPspConnectivity Code

CAAPspConnectivity code is located in the CAAPspConnectivity.m use case module of the CAAPlantShipInterfaces.edu framework:

Windows InstallRootDirectory\CAAPlantShipInterfaces.edu\CAAPspConnectivity.m
Unix InstallRootDirectory/CAAPlantShipInterfaces.edu/CAAPspConnectivity.m

where InstallRootDirectory is the root directory of your CAA V5 installation. It is made of  two unique source files named CAAPspConnectivityMain.cpp and CAAPspConnectivity.cpp.

Additional prerequisite code is located in the CAAPspUtilities.m directory of the same framework.

[Top]

Step-by-Step

There are eight logical steps in CAAPspConnectivity:

  1. Prolog
  2. Initializing the Environment
  3. Retrieving a List of Connectors
  4. Retrieving Connectable Data 
  5. Retrieving Connector Flow information
  6. Retrieving Connector Data
  7. Retrieving a List of Connections
  8. Retrieving Connection Data

[Top]

Prolog

In this use case, we open an input document containing some Equipment and Piping Design objects. 

[Top]

Initializing the Environment

The CAAPspConnectivity 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 methods:

CAAPspBaseEnv::CreateCATProductEnv
CAAPspBaseEnv::ApplicationInit

This method performs the following functions:

[Top]

Retrieving a List of  Connectors

The CATIPspConnectable interface is used to get the number of connectors belonging to a part and to retrieve a list of its connectors.   In this sample, the CATIPspConnectable interface pointer is obtained from a physical part in the document. 

if ( SUCCEEDED(piPspConnectable->ListConnectors (NULL,&piUnkListCtnr ))
         && (NULL!= piUnkListCtnr )) 
{
   cout << "Succeeded in  getting a list of connectors" << endl;
 

[Top]

Retrieving Connectable Data

The  CATIPspConnectable interface pointer is used to get the following information:

    //----------------------------------------------------------------------
    //  List valid connector types
    //----------------------------------------------------------------------    
    if ( SUCCEEDED(piPspConnectable->ListValidCntrTypes(&pLTypes)) && pLTypes )
    {
      unsigned int LCStrSize = 0;
      int NumOfCStr = 0;
      if (pLTypes) 
      HRESULT rc = pLTypes->Count (&LCStrSize);
      NumOfCStr = LCStrSize;
      if (NumOfCStr)
      {
        cout << "Number of valid connector types = " << NumOfCStr <<endl;
        char *piCStrMember = NULL;
        for (int iCStr=1; iCStr <= NumOfCStr; iCStr++)
        {
          if ( SUCCEEDED(pLTypes->Item(iCStr-1,&piCStrMember)) &&
               (NULL != piCStrMember) )
          {
            cout <<  iCStr << ") " << piCStrMember << endl;
            delete [] piCStrMember; piCStrMember = NULL;
          }
        }
      }
      if ( NULL != pLTypes )
      {
        pLTypes->Release();
        pLTypes = NULL;
      }
    }
    //----------------------------------------------------------------------
    // Find all the objects connected to this object and the corresponding
    // connectors involved in the connection.
    //----------------------------------------------------------------------
    if ( SUCCEEDED(piPspConnectable->ListConnectables(NULL,&pIUListOfOtherCtbl,&pIUListOfCtr,&pIUListOfOtherCtr)) && 
            pIUListOfOtherCtr && pIUListOfCtr && pIUListOfOtherCtbl )
    {
      unsigned int uiListSizeOtherCtbl = 0;
      unsigned int uiListSizeCtr = 0;
      unsigned int uiListSizeOtherCtr = 0;
      pIUListOfOtherCtbl -> Count(&uiListSizeOtherCtbl);
      pIUListOfCtr -> Count(&uiListSizeCtr);
      pIUListOfOtherCtr -> Count(&uiListSizeOtherCtr);
      cout << "Number of connected objects = " << uiListSizeOtherCtbl << endl;
      cout << "Number of connected connectors on this object = " << uiListSizeCtr << endl;
    }
    // Get the connector with given name
    CATIPspConnector *piCntr = NULL;
    if ( SUCCEEDED(piPspConnectable->GetConnector(CntrName,&piCntr)) )
    {
       cout << "Succeeded in getting a connector pointer" << endl;
       piCntr->Release();
       piCntr = NULL;
    }

[Top]

Retrieving Connector Flow information

In this sample, the CATIPspCntrFlow interface pointer is obtained from a connector object ( CATIPspConnector pointer) and is used to get and set the following flow connector information

    // Query the connector flow capability
    CATPspCntrFlowCapability CntrFlowCapability = CatPspCntrFlowCapability_Undefined;
    if ( SUCCEEDED(piPspCntrFlow->GetFlowCapability(CntrFlowCapability)) )
    {
      switch( CntrFlowCapability )
      {
        case  CatPspCntrFlowCapability_Undefined :
            cout << "Flow Capability is undefined" << endl;
            break;
        case  CatPspCntrFlowCapability_InDirection :
            cout << "Flow Capability is inward direction" << endl;
            break;
        case  CatPspCntrFlowCapability_OutDirection :
            cout << "Flow Capability is Outward Direction" << endl;
            break;
        case  CatPspCntrFlowCapability_InOutDirection :
            cout << "Flow Capability is bi-directional" << endl;
            break;
      }
    }

    // Set the connector flow capability
    CntrFlowCapability = CatPspCntrFlowCapability_InDirection;
    if ( SUCCEEDED(piPspCntrFlow->SetFlowCapability(CntrFlowCapability)) )
       cout << "Succeeded in setting the connector flow capability" << endl;

    // Query the connector flow reality
    CATPspCntrFlowReality CntrFlowReality = CatPspCntrFlowReality_Undefined;
    if ( SUCCEEDED(piPspCntrFlow->GetFlowReality(CntrFlowReality)) )
    {
      switch( CntrFlowCapability )
      {
        case  CatPspCntrFlowReality_Undefined :
          cout << "Flow Reality is undefined" << endl;
          break;
        case  CatPspCntrFlowReality_InDirection :
          cout << "Flow is in inward direction" << endl;
          break;
        case  CatPspCntrFlowReality_OutDirection :
          cout << "Flow is in Outward Direction" << endl;
          break;
        case  CatPspCntrFlowReality_InOutDirection :
          cout << "Flow is bi-directional" << endl;
          break;
      }
    }

    // Set the connector flow reality
    CntrFlowReality = CatPspCntrFlowReality_InDirection;
    if ( SUCCEEDED(piPspCntrFlow->SetFlowReality(CntrFlowReality)) )
       cout << "Succeeded in setting the connector flow reality" << endl;
  

[Top]

Retrieving Connector Data

The CATIPspConnector interface pointer is obtained from one of the connectors and is used to get the following information:

[Top]

Retrieving a List of  Connections

The CATIPspConnector interface pointer is also used to get a list of  connections.   

      if ( SUCCEEDED( piPspConnector->ListConnections (NULL, &piUnkListConnections )) &&
           (NULL != piUnkListConnections) )          
      {
        // Get a connection 
        unsigned int ListSize = 0;
        if ( SUCCEEDED(piUnkListConnections->Count(&ListSize)) ) NumOfCntns = ListSize;
        if ( NumOfCntns > 0 )
        {
          for ( int i = 0; i < NumOfCntns; i++ )
          {
            if ( SUCCEEDED(piUnkListConnections->Item(i,&piUnknown)) && (NULL != piUnknown) )
            {
              rc = piUnknown->QueryInterface(IID_CATIPspConnection,(void**)&piPspConnection);
              piUnknown->Release();
              piUnknown = NULL; 
              if ( NULL != piPspConnection ) break;
            }
          }
        }
        piUnkListConnections->Release();  piUnkListConnections = NULL;
      }
	

[Top]

Retrieving Connection Data

The CATIPspConnection interface pointer is obtained from one of the connections and is used to get the following information:

    //-------------------------------------------------------------------------
    // Find all connected objects in this connection
    //-------------------------------------------------------------------------
    if ( SUCCEEDED(piPspConnection->ListConnectables(NULL,&pIUListOfConnectables, &pIUListOfConnectors))
                && pIUListOfConnectables  && pIUListOfConnectors)
    {
      unsigned int uiListSizeCtbl = 0;                
      pIUListOfConnectables -> Count(&uiListSizeCtbl);                
      cout << "Number of connected objects in this connection is " << uiListSizeCtbl << endl;

      if ( NULL != pIUListOfConnectables )
      {
        pIUListOfConnectables->Release();
        pIUListOfConnectables = NULL;
      }

      unsigned int uiListSizeCntr = 0;
      pIUListOfConnectors -> Count(&uiListSizeCntr);
      cout << "Number of connectors included in this connection is " << uiListSizeCntr << endl;

      if ( NULL != pIUListOfConnectors )
      {
        pIUListOfConnectors->Release();
        pIUListOfConnectors = NULL;
      }
    }

    //-------------------------------------------------------------------------
    // Find all the connectors included in this connection
    //-------------------------------------------------------------------------   
    if ( SUCCEEDED(piPspConnection->ListConnectors(NULL,&pIUListOfConnectors))
         && pIUListOfConnectors )
    {
      cout << "Succeded in getting a list of connectors in the connection" << endl;

      unsigned int uiListSizeCntr = 0;                
      pIUListOfConnectors->Count(&uiListSizeCntr);
      if ( uiListSizeCntr == 2 )
      {
         if ( SUCCEEDED(pIUListOfConnectors->Item(0,&piUnknown)) )
         {
            piUnknown->QueryInterface(IID_CATIPspConnector,(void**)&piCntr1);
            piUnknown->Release();
            piUnknown = NULL;
         }
         if ( SUCCEEDED(pIUListOfConnectors->Item(1,&piUnknown)) )
         {
            piUnknown->QueryInterface(IID_CATIPspConnector,(void**)&piCntr2);
            piUnknown->Release();
            piUnknown = NULL;
         }
      }

[Top]


In Short

This use case has demonstrated how to use the Psp interfaces to obtain network connectivity information.  Specifically, it has illustrated:

[Top]


References

[1] Building and Launching a CAA V5 Use Case

History

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

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