libinco_32
 All Files Functions Enumerations Enumerator Macros Modules Pages
Use case: INCO procedure with asynchronous part returning results

INOS code

The following INCO function (MoveXAxis) "just" puts a message into the tasks message queue. Later, when the message will be 'dispatched' by the task, it'll actually perform an axis Move (iMoveXAxis). The function does finally add the current axis position as a result to the message object or returns the INOS_MCMSG_CODE_MYMODULE_MOVEXAXIS_FAILED application error if the move failed. Therefore, the PC code can get this result and thereby be informed about the current axis position.

CMcResult CMyModule::MoveXAxisReturnTargetPosition(double arAxisPosition)
{
CINOSTaskExMsg* msg = new CINOSTaskExMsg(eMsgCmd, CmdMoveXAxisReturnTargetPosition, apSync);
msg->AddParam(arAxisPosition);
return PutMsg(msg);
}
//------------------------------------------------------------------------------
void CMyModule::iMoveXAxisReturnTargetPosition(CINOSTaskExMsg* apMsg)
{
real64 rAxisPosition = apMsg->GetParam<real64>();
...
// move axis and wait until move finishs
if( pAxis->Move(rAxisPosition, DF_INOS_SYNCHRONOUS) == 0 ) {
// success. Return the current axis position to the caller:
apMsg->AddResult(pAxis->GetActPosition());
// mark the 'async part' as completed:
MsgDone(apMsg);
} else {
MsgDone(apMsg, CINOSTaskEx::eRplError, INOS_MCMSG_CODE_MYMODULE_MOVEXAXISRETURNTARGETPOSITION_FAILED);
}
}

PC code

Correct usage

Strange (but valid) usage

Forbidden/invalid usage


Generated by doxygen 1.8.8