研华数据采集卡应用时,官方提供Navigator展示C++应用示例,模拟量瞬时读值应用如下:
#include "BDaqCtrl.h"
using namespace Automation::BDaq;
...
// Read profile to configure device
ret = instantAiCtrl1->LoadProfile(filePath);
// Read AI samples
ret = instantAiCtrl1->Read(startChannel, channelCount, dataScaled);
数字量静态读值应用如下:
#include "BDaqCL.h"
using namespace Automation::BDaq;
...
ErrorCode ret = Success;
InstantDiCtrl * instantDiCtrl = AdxInstantDoCtrlCreate();
DeviceInformation devInfo(deviceDescription);
ret = instantDiCtrl -> setSelectedDevice(devInfo);
// Read profile to configure device
ret = instantDiCtrl->LoadProfile(filePath);
ICollection<PortDirection>* portDirection = instantDiCtrl -> getPortDirection();
if (portDirection != NULL)
{
//Set the first two port to output
DioPortDir dir = Iutput ;
portDirection -> getItem(0).setDirection(dir);
portDirection -> getItem(1).setDirection(dir);
//get port direction and print the direction information
DioPortDir currentDir = portDirection -> getItem(0).getDirection();
printf(" Current Direction of Port[%ld]=%ld \n",0, currentDir);
currentDir = portDirection -> getItem(1).getDirection();
printf(" Current Direction of Port[%ld]=%ld \n",1, currentDir);
}
else
{