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 结构。

备注

可用的 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

参见

AbortCommand

GetCommandStatus