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

INOS code

In addition to the use cases presented in Use case: INCO procedure with asynchronous part returning results, this page shows how to return 'named results'. 'Named results' is a feature that allows INOS code to return values to a caller (e.g. an HMI) by adding a string/name to it. Especially in case that a function returns multiple results, this feature offers some useful possibilities:

This page focus on the named results, therefore it assumes the reader has already studied the use cases here: Use case: INCO procedure with asynchronous part returning results.

The examples below assume the following code running on the target:

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 ) {
// increase move counter
++m_MoveCounter;
// Success. Return various results to the caller. For the sake of
// demonstration we mix named and unnamed results:
apMsg->AddResult(m_MoveCounter); // unnamed
apMsg->AddResult(pAxis->GetState(), "AxisState"); // named
apMsg->AddResult(pAxis->GetType());
apMsg->AddResult(pAxis->GetError(), "AxisError");
apMsg->AddResult(pAxis->GetActPosition());
// mark the 'async part' as completed:
MsgDone(apMsg);
} else {
MsgDone(apMsg, CINOSTaskEx::eRplError, INOS_MCMSG_CODE_MYMODULE_MOVEXAXISRETURNTARGETPOSITION_FAILED);
}
}

The function does not return any results (except application errors of course).

PC code

Correct usage

Forbidden/invalid usage


Generated by doxygen 1.8.8