求高手帮忙解释程序 VC++ 30

voidmain(){DWORDdwErrCde;ULONGlDevNum;longlDriverHandle;inti,iSamples;//USHORTusChan;... void main()
{
DWORD dwErrCde;
ULONG lDevNum;
long lDriverHandle;
int i, iSamples;
//USHORT usChan;
UINT usChan;
char chFifo;

USHORT *pusINTBuf; //INT internal transfer buffer
float *pfUserBuf; //User buffer for retrieve data
USHORT usActiveBuf; //for PT_FAICheck to return data
USHORT usStopped;
ULONG ulRetrieved;
USHORT usOverrun;
USHORT usHalfReady;
ULONG ulPreRetrieved;
//USHORT usFifoSize; //Fifo size
UINT usFifoSize;
//USHORT usNumChans;
UINT usNumChans;
USHORT gwGainCde[32];

float fOutValue;

PT_FAIIntScanStart tFAIIntScanStart;
PT_FAICheck tFAICheck;
PT_FAITransfer tFAITransfer;

PT_AOVoltageOut tAOVoltageOut;
}
else
{
usFifoSize = 1;
}

printf("Input Conversion Number: ");
scanf("%d", &iSamples);

printf("Input Start Channel: ");
scanf("%d", &usChan);
printf("Input Channel Number: ");
scanf("%d", &usNumChans);

//Step 3: Open device
dwErrCde = DRV_DeviceOpen(lDevNum, &lDriverHandle);
if (dwErrCde != SUCCESS)
{
ErrorHandler(dwErrCde);
printf("Program terminated!\n");

printf("Press any key to exit....");
getch();
return ;
}

//Step 4: Allocate INT & data buffer for interrupt transfer
if( AllocateDataBuffer(
lDriverHandle, // driver handle
iSamples, // data count
sizeof(float), // size of one data
&pusINTBuf, // INT buffer allocated
(void**)&pfUserBuf)==false) // user buffer allocated
{
printf("Program terminated\n");
DRV_DeviceClose(&lDriverHandle);

printf("Press any key to exit....");
getch();
return;
}

for( i=0; i<32; i++ )
gwGainCde[i] = 4;
展开
 我来答
孤松独海
2011-05-23 · TA获得超过1513个赞
知道大有可为答主
回答量:1220
采纳率:0%
帮助的人:488万
展开全部
void main()
{
DWORD dwErrCde; //定义错误代码变量
ULONG lDevNum; //定义设备数目
long lDriverHandle; //定义驱动句柄
int i, iSamples; //iSamples 为转换数
//USHORT usChan;
UINT usChan; //定义 通道变量
char chFifo;

USHORT *pusINTBuf; //INT internal transfer buffer
float *pfUserBuf; //User buffer for retrieve data 定义了获取数据的用户缓冲区
USHORT usActiveBuf; //for PT_FAICheck to return data 定义数据返回的变量
USHORT usStopped;
ULONG ulRetrieved;
USHORT usOverrun;
USHORT usHalfReady;
ULONG ulPreRetrieved;
//USHORT usFifoSize; //Fifo size
UINT usFifoSize;
//USHORT usNumChans;
UINT usNumChans;
USHORT gwGainCde[32];

float fOutValue;

PT_FAIIntScanStart tFAIIntScanStart;
PT_FAICheck tFAICheck;
PT_FAITransfer tFAITransfer;

上面定义了一些基本变量

PT_AOVoltageOut tAOVoltageOut;
} // 这里少东西 if 哪里去了
else
{
usFifoSize = 1;
}

printf("Input Conversion Number: ");
scanf("%d", &iSamples);// 获得转换数

printf("Input Start Channel: ");
scanf("%d", &usChan);//获得开始通道
printf("Input Channel Number: ");
scanf("%d", &usNumChans);//获得通道数目

//Step 3: Open device
dwErrCde = DRV_DeviceOpen(lDevNum, &lDriverHandle); //打开设备
if (dwErrCde != SUCCESS)//如果没有打开失败的话
{
ErrorHandler(dwErrCde);//输出错误代码
printf("Program terminated!\n");

printf("Press any key to exit....");
getch();
return ; //程序返回
}

//Step 4: Allocate INT & data buffer for interrupt transfer 为转换中断分配缓冲区
if( AllocateDataBuffer(
lDriverHandle, // driver handle 驱动句柄
iSamples, // data count 数据数目
sizeof(float), // size of one data 一条数据的大小
&pusINTBuf, // INT buffer allocated 分配的 INT缓冲区
(void**)&pfUserBuf)==false) // user buffer allocated 分配的用户缓冲区
{
printf("Program terminated\n"); //如果分配失败的话
DRV_DeviceClose(&lDriverHandle); //关闭设备

printf("Press any key to exit....");
getch();
return; //返回
}

for( i=0; i<32; i++ )
gwGainCde[i] = 4; //循环赋值
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式