内容发布更新时间 : 2024/11/1 7:30:32星期一 下面是文章的全部内容请认真阅读。
{ if(*(base_data+i)!=*(demod_data+i)) num_of_err++; } } else { for (i=0;i return num_of_err/(1.0*num_of_base); } (三) 输入输出模块 ◆数据输入模块 void CCommSys0713Dlg::OnBnClickedStart() { // TODO: 在此添加控件通知处理程序代码 //调制解调 CBPSK bpsk; int i; CString s1,s2,s3,s4; UpdateData(true); s1 = m_value11.GetString(); s2 = m_value12.GetString(); s3 = m_value13.GetString(); s4 = m_value14.GetString(); int a1 = _tstoi(s1); int a2 = _tstoi(s2); int a3 = _tstoi(s3); int a4 = _tstoi(s4); i = bpsk.BPSK_ModDemod(a1, a2, a3, a4); MessageBox(\仿真完成\温馨提示\ //OnOK(); } ◆数据读取模块 float* CTools::getDataf(CString sFilename,long length) { float* fpointer; CFile inf(sFilename,CFile::modeRead); if (!inf) return NULL; if (length<=0)//判断长度正确与否 return NULL; fpointer=(float *) malloc(length*sizeof(float)); if (!fpointer) return NULL; inf.Read(fpointer,length*sizeof(float)); inf.Close(); return fpointer; } ◆数据输出模块 void CTools::putData(float *outdata, CString out_put_filename, { if (!outdata) { return; } CFile outf(out_put_filename, CFile::modeCreate|CFile::modeWrite); if (!outf) { return; } outf.Write(outdata, length*sizeof(float)); long length) outf.Close(); } ◆绘图模块: OnPaint(); void ModeData::OnPaint() { CPaintDC dc(this); // device context for painting int i; int* iModData;//基带数据 long nPointlength = 0;//绘制点长度 CTools tTool;//工具类 /************************** 读取文件长度 ******************/ CFile inf(FILE_BASE_DATAPUT, CFile::modeRead); nPointlength=inf.GetLength()/sizeof(float);//获取文件长度 inf.Close(); if (nPointlength > 1000) { nPointlength =1000; } /**********************************************************/ //读取文件数据 iModData=tTool.getData(FILE_BASE_DATAPUT,nPointlength); //求出最大值 float fmaxModData = 0; for (i = 1; i < nPointlength ; i++ ) { if (fmaxModData < *(iModData+i)) fmaxModData = *(iModData+i); } // // for (i = 1; i < nPointlength ; i++ ) // { // // *(iModData+i) = *(iModData+i)-500; // } // //CClientDC dc(this); CRect rect; int m_Low=0; int m_High=nPointlength; if(m_High>10000)m_High=10000; // int m_Low1=-1; // int m_High1=1; int m_High1=fmaxModData; int m_Low1=-m_High1; CString str; int m_left,m_top,m_right,m_bottom; int m_Interval=(m_High - m_Low)/10; //int m_Interval1=(m_High1 - m_Low1)/10; int m_Interval1=(m_High1 - m_Low1)/2;//修改 if (m_Interval < 1) m_Interval = 1; if (m_Interval1 < 1) m_Interval1 = 1; GetClientRect(&rect); dc.Rectangle(&rect); /*m_left = rect.Width()/8; m_top = rect.top+10; m_right = rect.right-50; m_bottom = rect.bottom-30;*/ m_left = rect.Width()/8; m_top = rect.top+20; m_right = rect.right-50;// m_bottom = rect.bottom/2;//修改 int m_IntervalPan = (m_right - m_left)/10; if (m_IntervalPan < 1 ) m_IntervalPan =1; int m_IntervalPan1 = ( m_bottom-m_top)/2; if (m_IntervalPan < 1 ) m_IntervalPan1 =1; //绘制数据,使用蓝色画笔 CPen myPen; myPen.CreatePen(PS_SOLID,0,RGB(0,0,255)); dc.SelectObject(&myPen); dc.MoveTo(m_left+m_IntervalPan/ m_Interval,m_bottom-iModData[1]*m_IntervalPan1/m_Interval1);//起点 for(i=2;i m_Interval,m_bottom-iModData[i]*m_IntervalPan1/m_Interval1); } myPen.DeleteObject(); free(iModData); //将画笔颜色改为黑色 myPen.CreatePen(PS_SOLID,0,RGB(0,0,0)); dc.SelectObject(&myPen); //绘制坐标轴 /*dc.MoveTo(m_left,m_top); dc.LineTo(m_left,m_bottom); dc.LineTo(m_right+20,m_bottom); dc.MoveTo(m_left,m_bottom); dc.LineTo(m_left,m_bottom+150);*/ //dc.MoveTo(m_left,m_top+70); //dc.LineTo(m_left,m_bottom); //dc.LineTo(m_right+40,m_bottom); dc.MoveTo(m_left,m_top+20); dc.LineTo(m_left,m_bottom); dc.LineTo(m_right+20,m_bottom); dc.MoveTo(m_left,m_bottom); dc.LineTo(m_left,m_bottom+100); //绘制X轴 for(i=1;i<=10;i++) {