Antilatency Hardware Extension Interface Library

Antilatency Hardware Extension Interface Library

用于使用支持Antilatency Hardware Extension Interface(Antilatency硬件扩展接口)的设备的库。

使用库

  1. 加载库;
  2. 获取ILibrary
  3. 通过startTask启动Task(任务);
  4. 使用以下命令声明所需引脚(pin)的工作模式:
  5. 使用run(运行)方法将Task置于Run模式;
  6. 使用以前收到的接口(IInputPinIOutputPin等)。

IInputPin

}

IOutputPin

}

IAnalogPin

}

IPulseCounterPin

}

IPwmPin

interface IPwmPin : InterfaceContract.IInterface {
void setDuty(​float value);
float getDuty(​);
uint getFrequency(​);
}
对于更高的频率,duty将有更多的分级。但某些频率的值设置得不太准确。推荐频率列表:
您可以分别使用getFrequencygetDuty找出实际频率和占空比。
在Task转换到Run状态之前,这些接口的所有方法都将返回默认值。

ICotask

interface ICotask : DeviceNetwork.ICotask {
IAnalogPin createAnalogPin(​Interop.Pins pin, uint refreshIntervalMs);
IPulseCounterPin createPulseCounterPin(​Interop.Pins pin, uint refreshIntervalMs);
IPwmPin createPwmPin(​Interop.Pins pin, uint frequency, float initialDuty);
void run(​);
}
创建引脚的方法仅形成初始化表,该表将在run方法中发送到设备。
启动后,Task立即处于Init(初始化)状态。只有在这种状态下,创建引脚的方法才起作用。

Run

run方法将生成的初始化表发送到设备并等待确认。Task切换到Run模式。退出该方法后,将获得输入和模拟输入模式下所有引脚的实际状态,以及设置输出模式下所有引脚的初始状态。
切换到Run模式后,可以使用之前获得的接口(IInputPinIOutputPin等)中的必要方法。
Task完成后,所有引脚都将取消初始化并进入高阻抗(Hi-Z)状态。

创建引脚方法异常的原因

  1. 已调用run方法。
  2. 指定的引脚已在使用中。
  3. 指定的引脚不支持所需的模式。
  4. Refresh interval/frequency不包括在允许间隔中(请参见Constants)。
  5. 已创建此类型的最大引脚数。
  6. 为脉冲计数器模式下的引脚指定了不同的refresh interval,或为PWM引脚指定了不同的frequency。