WaitForCommand

Waits a command to be finished.

Syntax

KsCommandStatus WaitForCommand(
     double Timeout,
     BOOL AbortOnTimeout,
     KsCommandStatus Status
);

Parameters

Timeout: the time period after which the command will be aborted if it is not finished, or the time period in which the EtherCAT state must be changed to the requested one. The unit of time is second.

AbortOnTimeout: TRUE: the command will be aborted after the time in Timeout has elapsed. FALSE: the command won't be aborted. The program keeps running no matter this command is finished or not.

Status: the command you want to wait. It can be filled with a command whose return type is KsCommandStatus, or a returned KsCommandStatus structure.

Return value

Returns the KsCommandStatus structure.

Remarks

Usable EtherCAT states

ecatOffline, ecatInit, ecatBoot, ecatPreOP, ecatSafeOP, ecatOP

Example

VOID MoveQueue(INT Index) {
   //Add the first move to the queue
   KsCommandStatus move1 = MoveAxisRelative(Index, 360, 3600, 36000, 
	36000, 3600000, mcAborting);
   if (move1.Error) {
      RtPrintf("MoveAxisRelative 1 Failed: %d\n", move1.ErrorId);
      return;
   }

   //Add the second move to the queue
   KsCommandStatus move2 = MoveAxisRelative(Index, 360, 3600, 36000, 
	36000, 3600000, mcBuffered);
   if (move2.Error) {
      RtPrintf("MoveAxisRelative 2 Failed: %d\n", move2.ErrorId);
      return;
   }

   //Wait for both moves to be finished
   move2 = WaitForCommand(60, TRUE, move2);
   if (move2.Error) {
      RtPrintf("MoveAxisRelative 2 Failed: %d\n", move2.ErrorId);
      return;
   }

   //Printf the final position
   double position = 0;
   double setPosition = 0;
   KsError nRet = GetAxisPosition(Index, mcSetValue, &setPosition);
   double actPosition = 0;
   nRet = GetAxisPosition(Index, mcSetValue, &actPosition);
   RtPrintf("Current Position: Target %d, Actual %d\n", (int)setPosition, (int)actPosition);
}

Requirements

  RT Win32
Minimum supported version 4.0 4.0
Header ksapi.h ksapi.h
Library KsApi_Rtss.lib KsApi.lib

See also

AbortCommand