Equipment & Systems Engineering

Systems Diagrams

Managing Electrical Objects in a Schematics Environment

How to use schematics with electrical objects
Use Case

Abstract

This article discusses the CAAEDIInterfaces use case. This use case explains how to manage electrical objects in a Schematic environment.


What You Will Learn With This Use Case

This use case is intended to help you make your first steps in programming with CATIA EDI Interfaces. Its main intent is to allow you to manage electrical objects in a document. Before creating the electrical objects, you will have to navigate through the feature model of CATIA V5 to find the objects that will enable you to do this under the document.

[Top]

The CAAEDIInterfaces Use Case

CAAEDIInterfaces is a use case of the CAAElecSchematicItf.edu framework that illustrates the CATIA EDI Interfaces framework capabilities.

[Top]

What Does CAAEdiSchematic Do?

The goal of CAAEdiSchematic use case is to show how to manage Electrical objects, which is the first common step before creating the entire electrical system. We enrich the sample code CAAEDIInterfacesSample.cpp(.h) and illustrates some backbone concepts that are shared by an Electrical Application.

[Top]

How to Launch CAAEdiSchematic?

To launch CAAEdiSchematic, you will need to set up the build time environment, then compile CAAEDIInterfacesSample.cpp along with its prerequisites, set up the run time environment, and then execute the sample. This is fully described in the referenced article [1].

To launch the use case, execute the following command:

mkrun -c "CAAEdiSchematic CAAEdiSchematic_InstIn.CATProduct output_Inst.CATProduct output_CompRef.CATProduct output_CableRef.CATProduct"

[Top]

Where to Find the CAAEdiSchematic Code

The CAAEdiSchematic sample is made of a single class named CAAEDIInterfacesSample.cpp located in the CAAEDISchematic.m module of the CAAElecSchematicItf.edu framework:

Windows InstallRootDirectory\CAAElecSchematicItf.edu\CAAEDISchematic.m\
Unix InstallRootDirectory/CAAElecSchematicItf.edu/CAAEDISchematic.m/

where InstallRootDirectory is the directory where the CAA CD-ROM is installed.

This sample deals with the following classes:

CATSession Class for the session
CATDocument Class for the document base class
CATObject Class for the schematic
CATIEdiApplicatin Class for the schematic environment
CATEdiInstanceFactory Class for the Instance Factory
CATIEdiReference Factory Class for the Reference factory
IUnknown Base Class for the References and Instances
CATIEdiCable Class for the electrical Cable
CATIEdiCableExtremity Class for the electrical extremity
CATIEdiConnector Class for the electrical Connector
CATIEdiEquipment Class for the electrical Equipment
CATIEdiWidePin Class for the electrical WidePin

[Top]

Step-by-Step

We will now first comment the Electrical environment and it’s components creation by looking at the code of the CAAEDIInterfacesSample.cpp. There are 31 logical steps in CAAEDIInterfacesSample:

# Step
1 Creating an Object Modeler Session
2 Opening an Existing Document and Creating a New Document
3 Creating the Electrical Schematic Object
4 Creating the Electrical Schematic Environment
5 Creating the Reference Factory
6 Creating the Reference Equipment
7 Creating the Reference Cables
8 Retrieving the Instance Factory
9 Instantiating the Equipments
10 Retrieving the Equipment Instance Factory
11 Instantiating the Cable
12 Retrieving the Cable Extremities
13 Retrieving the Attribute Name on the Cable
14 Retrieving the Cable from the Extremity
15 Adding WidePins on the Equipment
16 Listing the WidePins on Equipment 1
17 Retrieving the Equipment from the WidePin
18 Connecting CABLE/Ext1 on EQT1/Pin1
19 Retrieving the WidePin from the Connection CABLE/Ext1 to EQT1/Pin1
20 Retrieving the Extremity from the Connection EQT1/Pin1 to CABLE/Ext1
21 Removing EQT1/Pin1
22 Retrieving the WidePin from the Connection CABLE/Ext1 to EQT1/Pin1 after Remove
23 Connecting CABLE/Ext1 on EQT1/Pin2
24 Disconnecting CABLE/Ext1 on EQT1/Pin2
25 Connecting CABLE/Ext1 on EQT1/Pin2 after Disconnection
26 Connecting CABLE/Ext2 on EQT2/Pin1
27 Listing Associated Equipments of the Cable
28 Listing Associated Cables of the Equipments
29 Saving the Document

The electrical system is displayed when the CAAEDIInterfacesSample application is launched. The system creation and display is performed in the Electrical Factory constructor that calls the CreateEfdSystem method. This is described below.

[Top]

Creating an Object Modeler Session

We need a CATSession pointer to create the Session.

...
char* psessionIdent = "Working Session";
CATSession* psession = NULL;
::Create_Session(psessionIdent, psession);
...

[Top]

Opening an Existing Document and Creating a New Document

We need a CATDocument pointers to open the existing and create the new Document.

CATDocument *pCATDocument1 = NULL;
CATDocumentServices::OpenDocument (PATHInstIN, pCATDocument1);
CATDocument *pCATDocumentEqt = NULL;
CATDocumentServices::New (ELECTYPE, pCATDocumentEqt);
CATDocument *pCATDocumentCable = NULL;
CATDocumentServices::New (ELECTYPE, pCATDocumentCable);

We open the existing Document with two arguments: input PATH (path of the document) and output POINTER to the opened Document.

We create the new Document with two arguments: input TYPE (type of the Document) and output POINTER to the new Document.

[Top]

Creating the Electrical Schematic Object

We need a CATObject pointer to be able to create the Electrical Schematic Object.

...
CATObject * pSchematicApplication = new CATObject (SCHELEName_Application); 
...

[Top]

Creating the Electrical Schematic Environment

We need a CATIEdiApplication interface pointer to be able to create the Electrical Schematic Environment.

...
CATIEdiApplication * piApplication = NULL;
RC = pSchematicApplication->QueryInterface(IID_CATIEdiApplication, 
                                           (void**)& piApplication);
RC = piApplication->Init();
... 

We create the Electrical Schematic Environment and initialize it by using the method Init.

[Top]

Creating the Reference Factory

We need a CATIEdiReferenceFactory interface pointer to be able to create the Reference Factory..

...
CATIEdiReferenceFactory * piReferenceFactory = NULL;
RC = pSchematicApplication->QueryInterface(IID_CATIEdiReferenceFactory, 
                                           (void**)& piReferenceFactory);
...

We create the Reference Factory by using the QueryInterface method on the Electrical Schematic Object.

[Top]

Creating the Reference Equipment

We need a IUnknown pointer to be able to create the Reference Equipment..

IUnknown* pEdiEquipmentReference = NULL;
const wchar_t* wchar_EquipmentPartNumber = L"EQT_PartNumber";
RC = piReferenceFactory->CreateEdiComponentReference (SCHELEClass_Eqt, 
                                                      wchar_EquipmentPartNumber,
                                                      &pEdiEquipmentReference);

By using the method CreateEdiComponentReference on the Reference Factory pointer we create the Equipment.

[Top]

Creating the Reference Cables

We need a IUnknown pointer to be able to create the Reference Cable.

IUnknown* pEdiBidon = NULL;
const wchar_t* wchar_CablePartNumber = L"CABLE_PartNumber";
RC = piReferenceFactory->CreateEdiComponentReference (SCHELEClass_Cable, 
                                                      wchar_CablePartNumber,
                                                      &pEdiBidon); 

We create the Reference Cable by using the method CreateEdiComponentReference on the Reference Factory.

[Top]

Retrieving the Instance Factory

We need a CATIEdiInstanceFactory interface pointer to be able to create (later) the electrical Equipments.

CATIEdiInstanceFactory * piEquipmentInstanceFactory = NULL;
RC = pEdiEquipmentReference->QueryInterface(IID_CATIEdiInstanceFactory, 
                                            (void**)& piEquipmentInstanceFactory); 

We use QueryInterface method on the Reference Equipment to obtain an Instance Factory pointer .

[Top]

Instantiating the Equipments

We need a IUnknown pointer to be able to create the electrical Equipments.

const wchar_t* wchar_EquipmentInstanceName1 = L"EQT_InstanceName_1";
IUnknown * pEdiEquipmentInstance1 = NULL;
RC = piEquipmentInstanceFactory->Instanciate(wchar_EquipmentInstanceName1, 
                                             &pEdiEquipmentInstance1); 

We use Instanciate method on the Instance Factory pointer to obtain the Equipment .

[Top]

Retrieving the Equipment Instance Factory

We need a CATIEdiInstanceFactory interface pointer to be able to create (later) the electrical Cable..

CATIEdiInstanceFactory * piCableInstanceFactory = NULL;
RC = pEdiCableReference->QueryInterface(IID_CATIEdiInstanceFactory, 
                                        (void**)& piCableInstanceFactory); 

We use QueryInterface method on the Reference Cable to obtain an Instance Factory pointer .

[Top]

Instantiating the Cable

We need a IUnknown pointer to create the electrical Cable..

const wchar_t* wchar_CableInstanceName = L"CABLE_InstanceName";
IUnknown * pEdiCableInstance = NULL;
RC = piCableInstanceFactory->Instanciate(wchar_CableInstanceName, 
                                         &pEdiCableInstance);

We use the Instanciate method on the Instance Factory pointer to obtain a Cable. .

[Top]

Retrieving the Cable Extremities

We need a CATIEdiCable interface pointer and two CATIEdiCableExtremity interface pointers to retrieves Cable extremities.

CATIEdiCable * piEdiCable = NULL;
RC = pEdiCableInstance->QueryInterface(IID_CATIEdiCable, (void**)& piEdiCable);

  if( FAILED(RC) || NULL == piEdiCable   ) return 14;
  
CATIEdiCableExtremity * piEdiCableExt1 = NULL;
CATIEdiCableExtremity * piEdiCableExt2 = NULL;
RC = piEdiCable->GetCableExtremities(&piEdiCableExt1, &piEdiCableExt2); 

We use GetCableExtremities method on the interface pointer CATIEdiCable with the two CATIEdiCableExtremity interface pointers as arguments.

[Top]

Retrieving the Attribute Name on the Cable

We need a CATIEdiConnector interface pointer to retrieves the Attribute Name.

CATIEdiConnector * piCableConnector1 = NULL;
RC = piEdiCableExt1->QueryInterface(IID_CATIEdiConnector, 
                                    (void**)& piCableConnector1);
...

CATUnicodeString UStgNameExt1;
RC = piCableConnector1->GetName(&UStgNameExt1);

We use GetName method on the interface pointer CATIEdiConnector .

[Top]

Retrieving the Cable from the Extremity

We need a CATIEdiCable interface pointer to retrieves the Cable from the extremity..

CATIEdiCable * piEdiRetCable = NULL;
RC = piEdiCableExt1->GetCable(&piEdiRetCable);

We use GetCable method on the interface pointer CATIEdiCable .

[Top]

Adds WidePin on the Equipment

We need a CATIEdiEquipment interface pointer to add a WidePin on it.

CATIEdiEquipment * piEdiEquipment1 = NULL;
RC = pEdiEquipmentInstance1->QueryInterface(IID_CATIEdiEquipment, 
                                            (void**)& piEdiEquipment1);
...
const wchar_t* wchar_NUM1 = L"NUM-1"; 
const wchar_t* wcharId_WidePin1 = L"Wide Pin 1";
  
CATIEdiWidePin *piWidePinCntr1Eqt1 = NULL;
RC = piEdiEquipment1->AddWidePin (wcharId_WidePin1, 
                                  wchar_NUM1,
                                  &piWidePinCntr1Eqt1);

We use AddWidePin method to add a WidePin (CATIEdiWidePin interface pointer) on the Equipment.

[Top]

Listing the WidePins on Equipment 1

We need a CATIUnknownList interface pointer to list the WidePins.

CATIUnknownList* pLUKWidePins = NULL;
RC = piEdiEquipment1->ListWidePins (&pLUKWidePins);
...
unsigned uSizeCntrs = 0;
pLUKWidePins->Count(&uSizeCntrs); 

We use the method ListWidePins on the Equipment and we can also see the number of elements by using Count method on the list created.

[Top]

Retrieving the Equipment from the WidePin

We need a CATIEdiEquipment interface pointer.

CATIEdiEquipment *piEdiRetEquipment = NULL;
RC = piWidePinCntr2Eqt1->GetEquipment(&piEdiRetEquipment);

We use the method GetEquipment on the WidePin to retrieve the Equipment.

[Top]

Connecting CABLE/Ext1 on EQT1/Pin1

RC = piEdiCableExt1->Connect (piWidePinCntr1Eqt1);

We use the method Connect on the Cable to connect Cable extremity to an Equipment's pin .

[Top]

Retrieving the WidePin from the Connection CABLE/Ext1 to EQT1/Pin1

We need a CATIEdiWidePin interface pointer.

CATIEdiWidePin *piFromToWidePin = NULL;
RC = piEdiCableExt1->GetConnectedWidePin (&piFromToWidePin);

We use the method GetConnectedWidePin on the Cable to retrieve the WidePin .

[Top]

Retrieving the Extremity from the Connection EQT1/Pin1 to CABLE/Ext1

We need a CATIEdiCableExtremity interface pointer.

CATIEdiCableExtremity *piFromToCableExtremity = NULL;
RC = piWidePinCntr1Eqt1->GetConnectedCableExtremity (&piFromToCableExtremity);

We use the method GetConnectedCableExtremity on the WidePin to retrieve the extremity .

[Top]

Removing EQT1/Pin1

RC = piFromToWidePin->Remove();

We use the method Remove on the WidePin to remove it .

[Top]

Retrieving the WidePin from the Connection CABLE/Ext1 to EQT1/Pin1 after Remove

We need a CATIEdiWidePin interface pointer.

CATIEdiWidePin *piWidePinBid = NULL;
RC = piEdiCableExt1->GetConnectedWidePin (&piWidePinBid);

We use the method GetConnectedWidePin on the Cable to retrieve the WidePin, the method returns a null pointer beacause the WidePin has been removed before .

[Top]

Connecting CABLE/Ext1 on EQT1/Pin2

RC = piEdiCableExt1->Connect (piWidePinCntr2Eqt1);

We use the method Connect on the Cable to connect the Cable extremity to the WidePin(2) of the Equipment 1.

[Top]

Disconnecting CABLE/Ext1 on EQT1/Pin2

RC = piEdiCableExt1->Disconnect ();

We use the method Disconnect on the Cable to disconnect the extremity of the Cable from the WidePin of the Equipment .

[Top]

Connecting CABLE/Ext1 on EQT1/Pin2 after Disconnection

RC = piEdiCableExt1->Connect (piWidePinCntr2Eqt1);

We use the method Connect on the Cable to connect the WidePin with the Cable's extremity after disconnection .

[Top]

Connecting CABLE/Ext2 on EQT2/Pin1

RC = piEdiCableExt2->Connect (piWidePinCntr1Eqt2);

We use the method Connect on the Cable to connect the WidePin with the Cable's extremity.

[Top]

Listing the Associated Equipments of the Cable

We need a CATIUnknownList pointer to build the list

CATIUnknownList* pLUKEquipments = NULL;
RC = piEdiCable->ListAssociatedEquipments (&pLUKEquipments);

We use the method ListAssociatedEquipments on the Cable to get the list of the associated Equipments.

[Top]

Listing the Associated Cables of the Equipments

We need a CATIUnknownList pointer to build the list

CATIUnknownList* pLUKCables = NULL;
RC = piEdiEquipment1->ListAssociatedCables (&pLUKCables);

We use the method ListAssociatedEquipments on the Equipment to get the list of the associated Cables.

[Top]

Saving the Document

We need a CATIPersistent interface pointer builded from the Document

CATIPersistent_var hPers (pCATDocument);
...
hPers->Save(); 

Then we use the method Save .

[Top]


In Short

This use case has demonstrated the way to manage electrical entities in a document. We illustrate how some management interfaces on the system feature can be used like CATIEdiEquipment, CATIEdiConnector, CATIEdiCable. We also illustrate the way to connect or disconnect electrical objects.

[Top]


References

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

History

Version: 1 [Sep 2000] Document created
[Top]

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