Equipment & Systems |
Distributive Systems |
Accessing Network Connectivity and Connector Flow DataHow to access network connectivity data |
Use Case |
AbstractThis article discusses the CAAPspConnectivity 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]
CAAPspConnectivity is a use case of the CAAPlantShipInterfaces.edu framework that illustrates CATPlantShipInterfaces framework capabilities.
[Top]
The goal of CAAPspConnectivity is to show you how to use the CATPlantShipInterfaces methods to query and obtain part connector and connection information.
[Top]
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]
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]
There are eight logical steps in CAAPspConnectivity:
[Top]
In this use case, we open an input document containing some Equipment and Piping Design objects.
[Top]
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]
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]
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]
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]
The CATIPspConnector interface pointer is obtained from one of the connectors and is used to get the following information:
// Get the owner of this connector i.e Associated Connectable if( SUCCEEDED( piPspConnector->GetAssociatedConnectable ( &piPspConnectable )) && ( NULL != piPspConnectable) ) { cout << "Succeeded in getting associated connectable" << endl; } if ( NULL != piPspConnectable ) { piPspConnectable->Release(); piPspConnectable = NULL; } // Is connector connected CATBoolean oBYes = FALSE; if( SUCCEEDED( piPspConnector->IsCntrConnected (&oBYes) ) ) { if( oBYes) { cout << "Connector is connected " << endl; } else { cout << "Connector is not connected " << endl; } } // Getting name of the connector CATUnicodeString uConnectorName; if( SUCCEEDED( piPspConnector->GetName (uConnectorName) )) { cout << "Name of the connector is " << uConnectorName.ConvertToChar() << endl; } // Setting name of the connector uConnectorName = "Connector1"; if( SUCCEEDED( piPspConnector->SetName (uConnectorName) )) { cout << "Succeeded in modifying the connector's name" << endl; } // Getting connector number int iCtrNumber; if( SUCCEEDED( piPspConnector->GetConnectorNumber(iCtrNumber) )) { cout << "Number of the connector is " << iCtrNumber << endl; } //----------------------------------------------------------------------- // Disconnect and connect connectors //----------------------------------------------------------------------- if ( SUCCEEDED(piCntr1->Disconnect(piCntr2)) ) { cout << "Succeeded in disconnecting two connectors" << endl; // Get a valid connection type for 2 connectors if ( SUCCEEDED(piCntr1->GetValidConnection(piCntr2,ConnectionType)) ) cout << "Succeeded in getting a valid connection type" << endl; if ( SUCCEEDED(piCntr1->Connect(ConnectionType,piCntr2,&piConnection)) && (NULL != piConnection) ) { cout << "Succeeded in connecting two connectors" << endl; piConnection->Release(); piConnection = NULL; } } |
[Top]
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]
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]
This use case has demonstrated how to use the Psp interfaces to obtain network connectivity information. Specifically, it has illustrated:
[Top]
[1] | Building and Launching a CAA V5 Use Case |
Version: 1 [March 2003] | Document created |
[Top] |
Copyright © 2003, Dassault Systèmes. All rights reserved.