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
- The value given as Status to WaitForCommand should not be empty, but be the return value of another command such as Start.
- When you use WaitForCommand to wait a command, if the command is done before the specified time period has elapsed, the next command will be run. For example, if you set
WaitForCommand(30, TRUE, Start())
and Start is done in 20 seconds, WaitForCommand will be ended and the next command will be run. It won't wait 30 seconds.
Usable EtherCAT states
ecatOffline, ecatInit, ecatBoot, ecatPreOP, ecatSafeOP, ecatOP
Example
// Case 1: Directly pass the KsCommandStatus
KsCommandStatus resultStart = WaitForCommand(30, TRUE, Start());
// Case 2: Save the returned KsCommandStatus and then pass to WaitForCommand
KsCommandStatus commandStart = Start();
// Some operation in your application
commandStart = WaitForCommand(30, TRUE, commandStart);
Requirements
RT | Win32 | |
---|---|---|
Minimum supported version | 4.0 | 4.0 |
Header | ksapi.h | ksapi.h |
Library | KsApi_Rtss.lib | KsApi.lib |
See also