Machining |
NC Review |
Customizing User Tool Database AccessImplementing the CATIMfgResourceQueryUserDatabase interface |
Use Case |
AbstractThis article discusses the CAAMaiUserToolDatabaseCustomization use case and explains how to implement the CATIMfgResourceQueryUserDatabase manufacturing interface. |
This use case is intended to help you customize the tool database access by implementing the CATIMfgResourceQueryUserDatabase manufacturing interface. This involves the following:
[Top]
CAAMaiUserToolDatabaseCustomization is a use case of the CAAManufacturingItf.edu framework that illustrates ManufacturingInterfaces framework capabilities.
[Top]
CAAMaiUserToolDatabaseCustomization runs with the Part document "CAAMaiUserToolDatabaseCustomization.CATPart". After selecting the PrismaticMachining workbench, access to the Import Tools command and access the "My_Tool_Database" in the combo "Look in", in order to make query in this customized Database.
![]() |
[Top]
To launch CAAMaiUserToolDatabaseCustomization, you will need to:
Windows | InstallRootDirectory\CAADoc\CAAManufacturingItf.edu\CNext\code\dictionary\ |
Unix | InstallRootDirectory/CAADoc/CAAManufacturingItf.edu/CNext/code/dictionary/ |
where InstallRootDirectory
is the directory where the CAA
CD-ROM is installed, and decomment the following line by removing the '#'
character:
CATMfgResourceQuery CATIMfgResourceQueryUserDatabase libCAAMaiUserToolDatabaseCustomization
Windows | InstallRootDirectory\CAADoc\CAAManufacturingItf.edu\CNext\resources\graphic\ |
Unix | InstallRootDirectory/CAADoc/CAAManufacturingItf.edu/CNext/resources/graphic/ |
This displays the PPR document:
Note: at this step, there is no result as Tool query as there is no tool in the CATProcess document (default selection is made on current document).
Then select the "My_Tool_Database" in the "Look in" combo to invoke the query with no specific constraint on the Drilling tools
[Top]
The CAAMaiUserToolDatabaseCustomization use case is made of a class named CAAEMaiUserToolDatabaseCustomization located in the CAAMaiUserToolDatabaseCustomization.m module of the CAAManufacturingItf.edu framework:
Windows | InstallRootDirectory\CAADoc\CAAManufacturingItf.edu\CAAMaiUserToolDatabaseCustomization.m |
Unix | InstallRootDirectory/CAADoc/CAAManufacturingItf.edu/CAAMaiUserToolDatabaseCustomization.m |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
There are several steps in CAAMaiUserToolDatabaseCustomization:
We now comment each of those sections by looking at the code.
[Top]
The extension class that will implement CATIMfgResourceQueryUserDatabase is named CAAEMaiUserToolDatabaseCustomization. Creating this class is done is three sub steps:
#include "CATBaseUnknown.h" #include "CATListOfInt.h" #include "CATListOfDouble.h" #include "CATListOfCATUnicodeString.h" class CAAEMaiUserToolDatabaseCustomization : public CATBaseUnknown { CATDeclareClass; public: CAAEMaiUserToolDatabaseCustomization(); virtual ~CAAEMaiUserToolDatabaseCustomization(); virtual HRESULT InitConnection (); virtual HRESULT ResetConnection (); virtual HRESULT GetNamesToDisplay (CATListOfCATUnicodeString &oListNames); virtual HRESULT Initialize (const CATUnicodeString &iName, const CATUnicodeString &iType); virtual HRESULT AddNameLikeConstraint (const CATUnicodeString &iValue); virtual HRESULT AddDiameterBetweenConstraint (const double &iMinValue, const double &iMaxValue, const CATUnicodeString &iUnit); virtual HRESULT AddConstraint (const CATUnicodeString &iAttribute, const int &iOperator, const int &iValue); virtual HRESULT AddConstraint (const CATUnicodeString &iAttribute, const int &iOperator, const double &iValue, const CATUnicodeString &iUnit); virtual HRESULT AddConstraint (const CATUnicodeString &iAttribute, const int &iOperator, const CATUnicodeString &iValue); virtual HRESULT AddConstraints (const CATUnicodeString &iAttribute, const CATUnicodeString &iUnit, const int &iTypeValue, const CATListOfInt &iOperators, const CATListOfInt &iIntValues, const CATListOfDouble &iDblValues, const CATListOfCATUnicodeString &iStrValues, const CATListOfInt &iLogLinks); virtual HRESULT Execute(); virtual HRESULT GetResultSize(int &NbElem); virtual HRESULT GetDescription (const int &iElem, CATListOfCATUnicodeString &oAttributes, CATListOfInt &oTypeValues, CATListOfInt &oNbValues, CATListOfInt &oIntValues, CATListOfDouble &DblValues, CATListOfCATUnicodeString &StrValues); virtual HRESULT GetRepresentation (const int &iElem, CATUnicodeString &oPathName); private: CAAEMaiUserToolDatabaseCustomization(const CAAEMaiUserToolDatabaseCustomization &iObjectToCopy); }; |
The CAAEMaiUserToolDatabaseCustomization class C++-derives from CATBaseUnknown.
The CATDeclareClass
macro declares that the class CAAEMaiUserToolDatabaseCustomization
belongs to a component. The class has a constructor, a destructor, all the
methods for the editor customization, and a copy constructor. Note that the
copy constructor is set as private. This is very important for extensions.
Since extensions must never be directly instantiated by client applications,
this prevents the compiler from creating the copy constructor as public
without you know. This copy constructor is not implemented in the source
file.
... #include "TIE_CATIMfgResourceQueryUserDatabase.h" TIE_CATIMfgResourceQueryUserDatabase(CAAEMaiUserToolDatabaseCustomization); CATImplementClass(CAAEMaiUserToolDatabaseCustomization, DataExtension, CATBaseUnknown, CATMfgResourceQuery); ... HRESULT CAAEMaiUserToolDatabaseCustomization::InitConnection() { ... |
The CAAEMaiUserToolDatabaseCustomization class states that it
implements the CATIMfgResourceQueryUserDatabase interface thanks to
the TIE_CATIMfgResourceQueryUserDatabase
macro. The CATImplementClass
macro declares that the CAAEMaiUserToolDatabaseCustomization class is
data extension class, thanks to the DataExtension
keyword, and
that it extends the feature whose type is Drilling. The third
parameter must always be set to CATBaseUnknown, makes no sense, and
is unused for extensions.
Extending the CATMfgResourceQuery feature using the CAAEMaiUserToolDatabaseCustomization class that implements CATIMfgResourceQueryUserDatabase means fitting this feature with your customized behavior for drill tool editor which will replace the default one. Some implementations method are shown in the next steps. It has a smart pointer to the Process document manufacturing container as input parameter, and a smart pointer to the created Resource Query as output parameter.
Update the interface dictionary, that is a file named, for example in this case, CAAManufacturingItf.edu.dico, whose directory's pathname is concatenated at run time in the CATDictionaryPath environment variable, and containing the following declaration to state that the Drilling feature implements the CATIMfgResourceQueryUserDatabase interface, and whose code is located in the libCAAMaiUserToolDatabaseCustomization shared library or DLL. Pay attention to remove the comment (#) in the supplied dictionary.
CATMfgResourceQuery CATIMfgResourceQueryUserDatabase libCAAMaiUserToolDatabaseCustomization
The CAAManufacturingItf.edu.dico file is located in:
Windows | InstallRootDirectory\CAADoc\CAAManufacturingItf.edu\CNext\code\dictionary\ |
Unix | InstallRootDirectory/CAADoc/CAAManufacturingItf.edu/Cnext/code/dictionary/ |
[Top]
This method will allow the user to specify what will be the text displayed in the combo "Look in" for this user database access.
HRESULT CAAEMaiUserToolDatabaseCustomization::GetNamesToDisplay (CATListOfATUnicodeString &oListNames) { ... oListNames.Append ("My_Tool_Database"); ... } |
[Top]
In the sample, the implementation of these methods is not complete due to the fact that in our example we are not trying to connect to any database but only display an hard-coded result.
HRESULT CAAEMaiUserToolDatabaseCustomization::InitConnection() { // Database Connection (call to Database connection Service) ... } HRESULT CAAEMaiUserToolDatabaseCustomization::ResetConnection() { // Reset Database Connection (call to Database reset connection Service) ... |
[Top]
In the use case, the implementation of these methods is not complete due to the fact that we are not trying to connect to any database but only display an hard-coded result.
The first method is dedicated to initialize query. For example to check that searched object type is stored in the current database.
HRESULT CAAEMaiUserToolDatabaseCustomization::Initialize() { ... } |
The next method is dedicated to manage constraints definition in the query. For example, if the user defines through the tool selection panel a query like "search the tool with Nominal Diameter greater than 10.00mm", that means the constraints will be defined with this method.
In such a case the iAttribute argument will be MFG_NOMINAL_DIAM (see CATMfgToolConstant.h header file), then the iunit argument will be "mm", iTypeValue will be 2 (for double), iOperators list will contain an interger with value 3, iIntValkues list will be empty (double value), iDblValues will contains double value 10.0, iStrValues will be empty and iLogLinks list will contains integrer value 0.
For more information about legal values to define the input, please refer to CATIMfgResourceQuery interface.
HRESULT CAAEMaiUserToolDatabaseCustomization::AddConstraints (const CATUnicodeString &iAttribute, const CATUnicodeString &iUnit, const int &iTypeValue, const CATListOfInt &iOperators, const CATListOfInt &iIntValues, const CATListOfDouble &iDblValues, const CATListOfCATUnicodeString &iStrValues, const CATListOfInt &iLogLinks) { ... } |
[Top]
In the sample, the implementation of these methods is not complete due to the fact that in our example we are not trying to connect to any database but only display an hard-coded result.
HRESULT CAAEMaiUserToolDatabaseCustomization::Execute() { // Database query execution (call to Database query Service) ... } |
[Top]
The first method to implement provides the number of description found in the database for the defined query.
HRESULT CAAEMaiUserToolDatabaseCustomization::GetResultSize( int &oNbElements ) { ... } |
The second method to implement provides the output definition for the executed query, that means the result to be displayed
HRESULT CAAEMaiUserToolDatabaseCustomization::GetDescription (const int &iNumber, CATListOfCATUnicodeString &oAttributes, CATListOfInt &oTypeValues, CATListOfInt &oNbValues, CATListOfInt &oIntValues, CATListOfDouble &oDblValues, CATListOfCATUnicodeString &oStrValues) { ... // Read the description of elements in database // For this example the output is hard-coded for Drill Tool // Length values should be given in mm unit switch (iNumber) { case 1: oAttributes.Append(MfgName); oTypeValues.Append(3); oNbValues.Append(1); oStrValues.Append("My_Tool_01"); oAttributes.Append(MfgNominalDiameter); oTypeValues.Append(2); oNbValues.Append(1); oDblValues.Append(10.0); oAttributes.Append(MfgCuttingAngle); oTypeValues.Append(2); oNbValues.Append(1); oDblValues.Append(120.0); oAttributes.Append(MfgCuttingLength); oTypeValues.Append(2); oNbValues.Append(1); oDblValues.Append(30.0); oAttributes.Append(MfgLength); oTypeValues.Append(2); oNbValues.Append(1); oDblValues.Append(50.0); oAttributes.Append(MfgOverallLength); oTypeValues.Append(2); oNbValues.Append(1); oDblValues.Append(100.0); oAttributes.Append(MfgBodyDiameter); oTypeValues.Append(2); oNbValues.Append(1); oDblValues.Append(11.0); break; ... } |
[Top]
This article provides an example on how to use the manufacturing interface classes, and has illustrated them on the customization of Tool Database query. It shows how to implement the CATIMfgResourceQueryUserDatabase interface to customize query on Tools objects in a User Database.
The CATMfgResourceQuery feature behavior is modified by implementing CATIMfgResourceQueryUserDatabase in a data extension class. This class allows the end user to make its own query in an external database.
[Top]
[1] | Building and Launching a CAA V5 Use Case |
[2] | Process Modeler Home Page |
[Top] |
Version: 1 [January 2001] | Document created |
[Top] |
Copyright © 2000, Dassault Systèmes. All rights reserved.