WaitForCommand
等待命令完成。
语法
KsCommandStatus WaitForCommand(
double Timeout,
BOOL AbortOnTimeout,
KsCommandStatus Status
);
参数
Timeout:若未完成命令将被中止的时间段,或必须将 EtherCAT 状态更改为请求状态的时间段。其时间单位为秒。
AbortOnTimeout: TRUE: the command will be aborted after the time in Timeout has elapsed.FALSE:命令不会被中止。不管此命令结束与否程式皆继续运作。
Status:欲等待的命令。可用返回类型为 KsCommandStatus 的命令或返回的 KsCommandStatus 结构来输入。
回传值
返回 KsCommandStatus 结构。
备注
- 给 WaitForCommand 的 Status 值不应为空值, 而是另一个如 Start 的命令值。
- 使用 WaitForCommand 等待命令时,若该命令在指定时间段过去前即完成,下一个命令将执行。例如:设定
WaitForCommand(30, TRUE, Start())
而 Start 在 20 秒内完成, WaitForCommand 将会结束而下一个命令将执行。不会等到 30 秒。
可用的 EtherCAT 状态
ecatOffline, ecatInit, ecatBoot, ecatPreOP, ecatSafeOP, ecatOP
范例
复制
// 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);
使用需求
RT | Win32 | |
---|---|---|
最低支援版本 | 4.0 | 4.0 |
标头档 | ksapi.h | ksapi.h |
程式库 | KsApi_Rtss.lib | KsApi.lib |
参见