24小时热门版块排行榜    

北京石油化工学院2026年研究生招生接收调剂公告
查看: 410  |  回复: 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 的主题更新
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 26考研调剂0710 0860 +9 补补不补 2026-04-03 14/700 2026-04-04 23:32 by 果冻大王
[考研] 081200-11408-276学硕求调剂 +5 崔wj 2026-03-31 5/250 2026-04-04 19:45 by 1753564080
[考研] 求调剂 +6 朔朔话 2026-04-02 7/350 2026-04-04 19:16 by 蓝云思雨
[考研] 考研调剂 +4 美丽的youth_ 2026-04-04 5/250 2026-04-04 17:16 by imissbao
[考研] 293分求调剂,外语为俄语 +6 加一一九 2026-03-31 6/300 2026-04-04 14:57 by 聪明的大松鼠
[考研] 考研调剂 +3 15615482637 2026-04-03 3/150 2026-04-03 22:50 by ms629
[考研] 322求调剂 +4 FZAC123 2026-04-03 4/200 2026-04-03 20:55 by zhq0425
[考研] 考研调剂 +3 Draa 2026-04-03 3/150 2026-04-03 17:37 by hgwz7468
[考研] 机械专硕297 +3 Afksy 2026-04-03 3/150 2026-04-03 14:24 by 1753564080
[考研] 266求调剂 +3 08电气工程 2026-04-03 3/150 2026-04-03 14:05 by 1753564080
[考研] 一志愿安徽大学0817化学工程与技术,求调剂 +14 我不是只因 2026-04-02 15/750 2026-04-03 09:49 by 蓝云思雨
[考研] 一志愿大工学硕,求调剂 +4 yub0811 2026-04-02 4/200 2026-04-02 21:36 by 百灵童888
[考研] 279求调剂 +5 傅文秋 2026-04-02 5/250 2026-04-02 18:10 by 笔落锦州
[考研] 初试301,代码085701环境工程,本硕一致,四六级已过,有二区一作,共发表5篇论文 +6 axibli 2026-04-01 6/300 2026-04-02 13:42 by Ecowxq666!
[考研] 材料工程322分 +8 哈哈哈吼吼吼哈 2026-04-01 8/400 2026-04-02 11:53 by 3041
[考研] 261求B区调剂 +5 明仔· 2026-04-01 7/350 2026-04-02 11:17 by 邹尉尉
[考研] 食品学硕362求调剂 +3 xuanxianxian 2026-04-01 3/150 2026-04-01 21:05 by 啊李999
[考研] 085600 一志愿9 总分351 求调剂学校 +7 czhcz 2026-03-31 9/450 2026-04-01 19:24 by 无际的草原
[考研] 材料调剂 +10 Eujd1 2026-03-31 11/550 2026-04-01 11:23 by ivanqyq
[考研] 生物考研337分求调剂 +4 cgxin 2026-03-30 6/300 2026-03-31 14:18 by 记事本2026
信息提示
请填处理意见