Implementation of a CtrlExtension

The CtrlExtension consists of a class derived from BaseExternHdl and a function called newExternHdl.

ADO interface implementation

class ADOExternHdl : public BaseExternHdl

{

public:

ADOExternHdl(BaseExternHdl *nextHdl,

PVSSulong funcCount,

FunctionListRec fnList[])

: BaseExternHdl(nextHdl, funcCount, fnList) {}

virtual const Variable *execute(ExecuteParamRec &param);

protected:

private:

};

CTRL_EXTENSION(ADOExternHdl, fnList)

The newExternHdl function has a fixed interface and must be exported so that it can be called by the WinCC OA Manager. A macro sets the keyword '_declspec(dllexport)' and exports the function. The macro also implements an ADO example.

The newExternHdl function must allocate a class object and return the pointer to it.

Complete implementation of newExternHdl for the ADO example

BaseExternHdl *newExternHdl(BaseExternHdl *nextHdl)

{

// simply fill this list with the prototype of each

//function you want to implement

static FunctionListRec fnList[] =

{

//Return-Value function name parameter list true ==

//thread-save

//----------------------------------------------------

{INTEGER_VAR, "dbOpenConnection", "(string conn, dbConnect& conn)", true},

{INTEGER_VAR, "dbCloseConnection", "(dbConnect conn)", true},

{INTEGER_VAR, "dbBeginTransaction", "(dbConnect conn)", true},

{INTEGER_VAR, "dbCommitTransaction", "(dbConnect conn)", true},

{INTEGER_VAR, "dbRollbackTransaction","(dbConnect conn)", true},

{INTEGER_VAR, "dbFinishCommand", "(dbCommand cmd)", true},

{INTEGER_VAR, "dbExecuteCommand", "(dbCommand cmd)", true},

{INTEGER_VAR, "dbCloseRecordset", "(dbRecordset rs)", true},

{BIT_VAR, "dbEOF", "(dbRecordset rs)", true},

{INTEGER_VAR, "dbMoveFirst", "(dbRecordset rs)", true},

{INTEGER_VAR, "dbMovePrevious", "(dbRecordset rs)", true},

{INTEGER_VAR, "dbMoveNext", "(dbRecordset rs)", true},

{INTEGER_VAR, "dbMoveLast", "(dbRecordset rs)", true},

{INTEGER_VAR, "dbMove", "(dbRecordset rs, long index)", true},

{INTEGER_VAR, "dbRequery", "(dbRecordset rs)", true},

{INTEGER_VAR, "dbAddNew", "(dbRecordset rs)", true},

{INTEGER_VAR, "dbDelete", "(dbRecordset rs)", true},

{INTEGER_VAR, "dbUpdate", "(dbRecordset rs)", true},

};

CTRL_EXTENSION(ADOExternHdl, fnList)

/* The macro also counts the number of the functions, you want to implement */

}