采集卡采集程序求 助
下面是买的采集卡带的主要的函数:我的问题是,如何设置采集次数?比如要采集500次。怎么弄。问客服,也没有得到答复。有没有做类似工作的朋友,请指点一下。多谢了
void CDrawWaveView::DrawIt(CDC *pDC,int DataLength, double Data[])
{
RECT Rect;
//CClientDC dc(this);
::GetClientRect(
this->m_hWnd, // handle to window
&Rect // client coordinates
);
double max=0;
for(int i=0;i<DataLength;i++)
{
double temp=fabs(Data[i]);
if(max<temp)
max=temp;
}
CPen *oldpen;
CPen pen(PS_SOLID,3,RGB(0,0,255));
oldpen=pDC->SelectObject(&pen);
///////画坐标
pDC->MoveTo(5,Rect.bottom/2);
pDC->LineTo(Rect.right-5,Rect.bottom/2);
pDC->MoveTo(Rect.right-5,Rect.bottom/2);
pDC->LineTo(Rect.right-15,Rect.bottom/2+4);
pDC->MoveTo(Rect.right-5,Rect.bottom/2);
pDC->LineTo(Rect.right-15,Rect.bottom/2-4);
pDC->MoveTo(20,20);
pDC->LineTo(20,Rect.bottom-20);
pDC->MoveTo(20,20);
pDC->LineTo(16,30);
pDC->MoveTo(20,20);
pDC->LineTo(24,30);
pDC->SelectObject(oldpen);
pDC->MoveTo(20,(int)((Rect.bottom-80)/2.0/max*Data[0]+Rect.bottom/2.0));
for(i=1;i<DataLength;i++)
{
pDC->LineTo((int)((Rect.right-40.0)/DataLength*i+20.0),(int)((Rect.bottom-80)/2.0/max*Data[i]+Rect.bottom/2.0));
pDC->MoveTo((int)((Rect.right-40.0)/DataLength*i+20.0),(int)((Rect.bottom-80)/2.0/max*Data[i]+Rect.bottom/2.0));
}
}
void CDrawWaveView::OnInitiate()
{
// TODO: Add your command handler code here
//打开动态库
/**************************************************************/
// API里面的OpenTopdll函数 //
/**************************************************************/
char buffer[128];
char buffer2[20];
ZeroMemory(buffer,128); //初始化内存,使之为0
ZeroMemory(buffer2,20);
pTopDllEx=new TopDllEx();
SysNum=pTopDllEx->OpenTopDll();//SysNum:使用同一型号的卡应该为1
itoa(SysNum,buffer2,10); //整数转化为10进制数
strcpy(buffer,"系统数目为:"); //拷贝
strcat (buffer,buffer2); //连接buffer,buffer2
AfxMessageBox(buffer); //显示buffer
//初始化数据结构
/**************************************************************/
// API里面的GetCardNum函数 //
/**************************************************************/
int i;
int ReturnVal=0;
for (i=0;i<SysNum;i++)
{
SysBlock[i].CardNum=pTopDllEx->GetCardNum(i);
//获取执行庭卡的数目(这里为1)
//初始化sysinfo
/**************************************************************/
// API里面的SysInit函数 //
/**************************************************************/
for (unsigned int j=0;j<SysBlock[i].CardNum;j++)
{
SysBlock[i].pUserBuffer[j]=NULL;//(unsigned long *)pDataBuf; //pTempUserBuffer; //分配的内存指针
SysBlock[i].UserBufferLength[j]=0;//128*1024*sizeof(int); //256*1024; //分配的内存指针长度(字节)
//参见API手册PAGE.9
}
ReturnVal=pTopDllEx->SysInit(i,&SysBlock[i],1);
//初始化SysBlock
}
}
void CDrawWaveView::OnStartacq()
{
// TODO: Add your command handler code here
//设置硬件
for (int i=0;i<SysNum;i++)
{
for (unsigned int j=0;j<SysBlock[i].CardNum;j++)
{
for (unsigned int k=0;k<SysBlock[i].ChperTB;k++)
{
//控制结构
CtrlBlock[i].rg_idx[j*SysBlock[i].ChperTB+k]=2;
CtrlBlock[i].cpl_idx[j*SysBlock[i].ChperTB+k]=DC;
CtrlBlock[i].filter_idx[j*SysBlock[i].ChperTB+k]=0;
CtrlBlock[i].Kv[j*SysBlock[i].ChperTB+k]=1.0;
CtrlBlock[i].Basev[j*SysBlock[i].ChperTB+k]=0.0;
strcpy(CtrlBlock[i].Unitstr[j*SysBlock[i].ChperTB+k],"V");
CtrlBlock[i].CHACQEn[j*SysBlock[i].ChperTB+k]=1;
//触发结构(通道)
TrgBlock[i].CH_trg[j*SysBlock[i].ChperTB+k].chtrgmode=RISE;
TrgBlock[i].CH_trg[j*SysBlock[i].ChperTB+k].chtrglvl_0=255;
TrgBlock[i].CH_trg[j*SysBlock[i].ChperTB+k].chtrglvl_1=0;
TrgBlock[i].CH_trg[j*SysBlock[i].ChperTB+k].chtrglogic=0;
TrgBlock[i].CH_trg[j*SysBlock[i].ChperTB+k].chtrgen=1;
}
//控制结构
CtrlBlock[i].ADMode[j]=Single_ACQ;
CtrlBlock[i].clkmode[j]=0;
CtrlBlock[i].smpclk_idx[j]=8;
CtrlBlock[i].smplength[j]=DataLen;
CtrlBlock[i].dlylength[j]=0;
CtrlBlock[i].externclk[j]=0;
CtrlBlock[i].TestBlock[j].TestPart=NoCH;
CtrlBlock[i].TestBlock[j].DA8BitL=0;
//触发控制字(时基)
TrgBlock[i].TB_trg[j].trgsource=Local_trg;
TrgBlock[i].TB_trg[j].trgmode=MANUAL;
TrgBlock[i].TB_trg[j].trgout=1;
TrgBlock[i].TB_trg[j].bustrglogic=0;
}
ZeroMemory(CtrlBlock[i].rsvd,24);
//设置硬件
pTopDllEx->HardwareSet(i,&CtrlBlock[i],&TrgBlock[i],1);
}
Sleep(5);
Acqing=true;
//启动采集
for (i=0;i<SysNum;i++)
{
pTopDllEx->Acq(i,0xff); //启动所有卡采集
}
StatusCheck();
Readdata();
}
void CDrawWaveView::OnMultiacq()
{
// TODO: Add your command handler code here
MulAcqFlag=true;
this->SetTimer(1,100,NULL);
}
void CDrawWaveView::Readdata()
{
int ReturnVal,i;
int16 *Buf=new int16[DataLen];
doubler=SysBlock[0].RangeTab[CtrlBlock[0].rg_idx[0]];
//整段pack
ReturnVal=pTopDllEx->Pack(0,0,Buf,0,0,0,DataLen);
for(i=0;i<DataLen;i++)
{
m_dTimeDomain[i]=Buf[i]*(r/32767);
}
delete[] Buf;
Buf=NULL;
ShowLen=DataLen;
this->Invalidate(TRUE);
}
void CDrawWaveView::OnStopacq()
{
// TODO: Add your command handler code here
KillTimer(1);
MulAcqFlag=false;
Acqing=false;
pTopDllEx->StopAcq(0,0xff);
}
void CDrawWaveView::StatusCheck()
{
//采集状态检测
int AcqSts;
for (int i=0;i<SysNum;i++)
{
for (unsigned int j=0;j<SysBlock[i].CardNum;j++)
{
AcqSts=-1;
for(;;)
{
AcqSts=pTopDllEx->StatusCheck(i,j,&CardStatus);
if(AcqSts==0)
break;
}
}
}
Acqing=false;
MulAcqFlag=false;
}
void CDrawWaveView::OnTimer(UINT nIDEvent)
{
if(!Acqing&&MulAcqFlag==true)
{
OnStartacq();
MulAcqFlag=true;
}
CView::OnTimer(nIDEvent);
}
[解决办法]
没人回答,帮顶一下...