发表于:2003-04-30 21:30:00
楼主
老师好,现在我能实现显示与存储同时进行不发生闪烁了,但有出现了一个怪现象.我设的采样频率为100KHz,显示上正常,但相同时间内存储的点数竟然为正常情况下的2倍,不知道为什么.比如我采样4秒种,应该大约为400000个点,可我用文件转换器查看点数却为800000.我的程序是这样写的.
void CDemo2Dlg::OnStart()
{
if(m_to_file==0)
{
bTofile=FALSE; //不存数据
}
else
{
bTofile=TRUE; //存储数据
}
m_Chart.ClearPlots();
clear_op = FALSE; //清除标志
CWinThread* pThread= AfxBeginThread(CDemo2Dlg::ProcessThread, &m_Chart);//开始采集线程
}
UINT CDemo2Dlg::ProcessThread(LPVOID lpVOID)
{
BOOLEAN HalfReady;
BOOLEAN fstop;
int t =0, ftimeout=0;
U32 count;
F64* buf1=new F64[data_size/2];
F64* buf2=new F64[data_size/2];
CDChart *chart=(CDChart *)lpVOID;
err = AI_ContScanChannelsToFile(card, 0, AdRange,(U8*)LPCTSTR (m_Filename), data_size,(F64) sample_rate, ASYNCH_OP);
if (err!=0) {
printf("AI_ContReadChannel error=%d", err);
exit(1);
}
data_size /= 2;
do {
do {
AI_AsyncDblBufferHalfReady(card, &HalfReady, &fstop);
} while (!HalfReady);
if (bTofile) AI_AsyncDblBufferTransfer(card, NULL); //传向文件
AI_AsyncDblBufferTransfer(card, ai_buf); //传向buffer
AI_ContVScale(0,AdRange,ai_buf,buf1,data_size); //卡号为0 ,数据转化
chart->PlotCharts(&ArrayToVar(buf1, data_size),1, BoolToVar(false));
} while (!clear_op);
AI_AsyncClear(card, &count);
delete[] buf1;
delete[] buf2;
return 0;
}