Method ITcPostCyclicCaller:AddPostModule
Logs the ITcPostCyclic interface of a module to a cyclic caller, e.g. a TwinCAT task.
Syntax
virtual HRESULT TCOMAPI
AddPostModule(STcPostCyclicEntry* pEntry, ITcPostCyclic* ipMod, ULONG_PTR
context=0, ULONG sortOrder=0)=0;
Return value
If successful, S_OK ("0") or another positive value will be returned, cf. Return values. Extended messages refer in particular to the column HRESULT in ADS Return Codes.
The error ADSERR_DEVICE_INVALIDSTATE is returned if the cyclic caller, i.e. the TwinCAT task is not in the OP state.
Parameter
Name | Type | Description |
|---|---|---|
pEntry | STcPostCyclicEntry | [in] Pointer to a list item that is inserted into the internal list of the cyclic caller; see also description. |
ipMod | ITcPostCyclic | [in] Interface pointer used by the cyclic caller. |
context | ULONG_PTR | [optional] A context value that is transferred to the ITcPostCyclic::PostCyclicUpdate() method with each call. |
sortOrder | ULONG | [optional] The sort order can be used for controlling the order of execution if various module instances are executed by the same cyclic caller. |
Description
A TwinCAT module class uses a Smart Pointer to refer to the cyclic caller of type ITcPostCyclicCallerPtr. The object ID of the task is stored in this Smart Pointer and a reference to the task can be obtained via the TwinCAT object server. In addition, the Smart Pointer class already contains a list item. Therefore the Smart Pointer can be used as the first parameter for the AddPostModule method.
The following code sample illustrates the login of the ITcPostCyclicCaller interface.
RESULT hr =
S_OK;
if ( m_spPostCyclicCaller.HasOID() ) {
if ( SUCCEEDED_DBG(hr =
m_spSrv->TcQuerySmartObjectInterface(m_spPostCyclicCaller)) )
{
if ( FAILED(hr =
m_spPostCyclicCaller->AddPostModule(m_spPostCyclicCaller,
THIS_CAST(ITcPostCyclic))) ) {
m_spPostCyclicCaller = NULL;
}
}
}