24小时热门版块排行榜    

查看: 404  |  回复: 0

suyanxia

铁虫 (初入文坛)

[求助] 用c++编写程序

软件输入信号有采集好的数据,我发给你,数据格式参见下面程序读写方式

void CTestPCIDlg::OnButtonOpen()
{
CString str;
// 弹出文件对话框
CString strOpenFileType = "pci文件 (*.PCI)|*.pci|All Files (*.*)|*.*||";
CFileDialog FileDlg(TRUE, "*.pci", NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, strOpenFileType);
CFileException fe;
CString strPathName;
CFile File;
if (FileDlg.DoModal() == IDOK)
{
strPathName = FileDlg.GetPathName();

if( !File.Open(strPathName, CFile::modeRead | CFile::shareDenyWrite, &fe))
{
strNewFileName=strNewFileName+" 不存在!";
AfxMessageBox(strNewFileName,MB_ICONSTOP, 0);
return;
}
strNewFileName=strPathName;
        File.Close();
File.Open(strPathName, PCI8514_modeRead);
int FileLength=File.GetLength();
File.Seek(0,CFile::begin);
File.Read((WORD*)&m_Header,sizeof(m_Header));
File.Close();

long VoltTopRange, VoltBottomRange;
VoltTopRange = m_Header.VoltTopRange;       // 电压的最大值
VoltBottomRange = m_Header.VoltBottomRange; // 电压的最小值
m_PerLsbVolt = (float)((VoltTopRange - VoltBottomRange) / LSB_COUNT);
///////////////////////////////写文件/////////////////////////////////////
FILE * fp;
char FileName[32];
strcpy(FileName,"PCIFileHead.log";
fp=fopen(FileName,"ab";

str.Format(_T("DeviceNum:%x",m_Header.DeviceNum );
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);
str.Format(_T("HeadSizeBytes:%d",m_Header.HeadSizeBytes );
str=str+"\r\n";
str.Format(_T("分辨率:%x位", m_Header.DataWidth);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);
str.Format(_T("电压量程:%d~%dmV",m_Header.VoltBottomRange,m_Header.VoltTopRange);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);

     str.Format(_T("采样频率:%d", m_Header.ADPara.Frequency);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);

str.Format(_T("触发源:%d",m_Header.ADPara.TriggerSource);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);
str.Format(_T("触发方向:%d",m_Header.ADPara.TriggerDir);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);
str.Format(_T("M_Length:%d", m_Header.ADPara.M_Length);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);
str.Format(_T("触发事件提前:%d", m_Header.ADStatus.bAheadTrig);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);

str.Format(_T("电压的最大值:%dmv", m_Header.VoltTopRange);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);

str.Format(_T("电压的最小值:%dmv", m_Header.VoltBottomRange);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);

str.Format(_T("文件长度:%d", FileLength);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);

int DataNUM=(FileLength-sizeof(m_Header))/2;

str.Format(_T("数据个数:%d", DataNUM);
str=str+"\r\n";
fwrite(str,str.GetLength(),1,fp);

fclose(fp);

}
//AfxMessageBox("存储完成!";
MessageBox("存储PCI文件信息完成!","提示",MB_OK) ;
回复此楼
believemyself
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

智能机器人

Robot (super robot)

我们都爱小木虫

相关版块跳转 我要订阅楼主 suyanxia 的主题更新
信息提示
请填处理意见