⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 computesave.cpp

📁 一个根据热敏电阻的电阻值计算出AD转换值的程序(源码) 采用列表控件,可同时计算出0到159度的电阻值所对应的AD值,AD转换精度8到12位 计算结果可保存可打开(文档操作)
💻 CPP
字号:

// computesave.cpp : implementation of the CWzdInfo class
//


#include "stdafx.h"
#include "computesave.h"

/////////////////////////////////////////////////////////////////////////////
// computesave

IMPLEMENT_SERIAL( computesave, CObject, 0 )


 computesave::computesave()
{  BYTE BB;

    conver_bit="8";
     GNDORVCC=0;
	 resister_vol="47";

for(BB=0;BB<160;BB++)
{    ADC_VOL[BB]="";
     ADC_VOL[BB]="";
}
}

computesave::~computesave()
{
	
}

void computesave::Serialize( CArchive& ar )
{  BYTE BB;
    CObject::Serialize( ar );
    if( ar.IsStoring() )
	{ UINT dd=54445;
	   	ar<<dd;

		ar<<GNDORVCC;
        ar<<conver_bit;
		ar<<resister_vol;
	   for(BB=0;BB<160;BB++)
	   {ar<<TEMP_VOL[BB];
	    ar<<ADC_VOL[BB];
	   }
	}
    else
	{UINT dd=0;;
	 ar>>dd;
	 if(dd!=54445){::MessageBox(AfxGetMainWnd()->m_hWnd,"file error!",NULL,MB_ICONERROR);return;}
	    ar>>GNDORVCC;
	    ar>>conver_bit;
		ar>>resister_vol;
	   for(BB=0;BB<160;BB++)
	   {ar>>TEMP_VOL[BB];
	    ar>>ADC_VOL[BB];
	   }
	}
	
}

void computesave::save()
{   CString path;
	path=Getpath(0);
	CFile file;
	if(path!="0")
 if (file.Open(path, CFile::modeCreate|CFile::modeWrite ) )
	{
        CArchive ar(&file, CArchive::store);
        Serialize( ar );
        ar.Close();
        file.Close() ;
	}
}

bool computesave::open()
{	CFile file;
     CString path;
	path=Getpath(1);
    if(path!="0")
 if (file.Open(path,CFile::modeRead))
  {
      CArchive ar(&file, CArchive::load);
     Serialize( ar );
      ar.Close();
      file.Close();
	  return TRUE;
  }	
 else {return FALSE;}

}
CString computesave::Getpath(bool openorsave)
{ 
  CFileDialog filedig( openorsave,  NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL,  NULL );
	CString path;//=filepath+"ico\\";
          // filedig.m_ofn.lpstrInitialDir=path;
		   if(openorsave)filedig.m_ofn.lpstrTitle   =  _T("用户卡信息输入");
		    else filedig.m_ofn.lpstrTitle   =  _T("用户卡信息输出");
		   filedig.m_ofn.lpstrFilter = _T(".tdt\0*.tdt\0 ");
         int nStructSize = 0;
	DWORD dwVersion, dwWindowsMajorVersion, dwWindwosMinorVersion;
	dwVersion = GetVersion();
	dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
	dwWindwosMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
	if(dwVersion < 0x80000000)
	{
		nStructSize = 88;   //2k,xp下显示新的版本
	}
	else
	{
		nStructSize = 76;  //98下显示老版本,如图1
	}
	filedig.m_ofn.lStructSize = nStructSize;  //------用来检测目前的操作系统的版本信息

     if(filedig.DoModal()==IDOK)
	 {
	 
	 path=filedig.GetPathName();
	 return path;
	 }
	 else return "0";

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -