📄 packinfo.cpp
字号:
// PackInfo.cpp : implementation file
//
#include "stdafx.h"
#include "FakeTolcan.h"
#include "PackInfo.h"
#include <io.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPackInfo dialog
CPackInfo::CPackInfo(CWnd* pParent /*=NULL*/)
: CDialog(CPackInfo::IDD, pParent)
{
//{{AFX_DATA_INIT(CPackInfo)
m_strPackId = _T("");
m_strPackType = _T("");
m_PackInterval = _T("");
m_strPackHeadLen = _T("");
/* m_strBaseValue = _T("");
m_strBound = _T("");
m_strMinValue = _T("");
m_strMaxValue = _T("");
m_strStep = _T("");
m_strFirstValue = _T("");
m_strPumpBound = _T("");
m_strPumpBaseValue = _T("");*/
//}}AFX_DATA_INIT
}
void CPackInfo::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPackInfo)
DDX_Text(pDX, IDC_EDIT_PACK_ID, m_strPackId);
DDX_Text(pDX, IDC_EDIT_PACK_TYPE, m_strPackType);
DDX_Text(pDX, IDC_EDIT_PACK_INTERVAL, m_PackInterval);
DDX_Text(pDX, IDC_EDIT_PACK_HEAD_LEN, m_strPackHeadLen);
/* DDX_Text(pDX, IDC_EDIT_BASE_VALUE, m_strBaseValue);
DDX_Text(pDX, IDC_EDIT_BOUND, m_strBound);
DDX_Text(pDX, IDC_EDIT_MIN_VALUE, m_strMinValue);
DDX_Text(pDX, IDC_EDIT_MAX_VALUE, m_strMaxValue);
DDX_Text(pDX, IDC_EDIT_STEP, m_strStep);
DDX_Text(pDX, IDC_EDIT_FIRST_VALUE, m_strFirstValue);
DDX_Text(pDX, IDC_EDIT_PUMP_BOUND, m_strPumpBound);
DDX_Text(pDX, IDC_EDIT_PUMP_BASE_VALUE, m_strPumpBaseValue);*/
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPackInfo, CDialog)
//{{AFX_MSG_MAP(CPackInfo)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPackInfo message handlers
BOOL CPackInfo::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CString strFileName;
char svPath[MAX_PATH];
::GetModuleFileName(NULL,svPath,sizeof(svPath));
CString ExePath = svPath;
int j = ExePath.ReverseFind('\\');
struct _finddata_t xml_file;
long hFile;
CString strXmlFolderPath;
strXmlFolderPath=ExePath.Left(j);
strXmlFolderPath+="\\Config";
CString strFileName1=strXmlFolderPath;
strFileName1+="\\";
strFileName1+="config.ini";
if( (hFile=_findfirst(strXmlFolderPath.GetBuffer(strXmlFolderPath.GetLength()), &xml_file ))==-1)
{
SECURITY_ATTRIBUTES Attribute;
Attribute.bInheritHandle=FALSE;
Attribute.lpSecurityDescriptor=NULL;
Attribute.nLength=sizeof(SECURITY_ATTRIBUTES);
BOOL bResult=::CreateDirectory(strXmlFolderPath,&Attribute);
}
else
{
CString str;
char temp[MAX_PATH];
GetPrivateProfileString(_T("Package"),_T("PackId"),"",temp,MAX_PATH,strFileName1);
m_strPackId = temp;
GetPrivateProfileString(_T("Package"),_T("PackType"),"",temp,MAX_PATH,strFileName1);
m_strPackType=temp;
GetPrivateProfileString(_T("Package"),_T("PackInterval"),"",temp,MAX_PATH,strFileName1);
m_PackInterval=temp;
GetPrivateProfileString(_T("Package"),_T("PackHeadLen"),"",temp,MAX_PATH,strFileName1);
m_strPackHeadLen=temp;
/* GetPrivateProfileString(_T("Node"),_T("BaseValue"),"",temp,MAX_PATH,strFileName1);
m_strBaseValue=temp;
GetPrivateProfileString(_T("Node"),_T("Bound"),"",temp,MAX_PATH,strFileName1);
m_strBound=temp;
GetPrivateProfileString(_T("Node"),_T("MinValue"),"",temp,MAX_PATH,strFileName1);
m_strMinValue=temp;
GetPrivateProfileString(_T("Node"),_T("MaxValue"),"",temp,MAX_PATH,strFileName1);
m_strMaxValue=temp;
GetPrivateProfileString(_T("Node"),_T("FirstValue"),"",temp,MAX_PATH,strFileName1);
m_strFirstValue=temp;
GetPrivateProfileString(_T("Node"),_T("Step"),"",temp,MAX_PATH,strFileName1);
m_strStep=temp;
GetPrivateProfileString(_T("Node"),_T("PumpBaseValue"),"",temp,MAX_PATH,strFileName1);
m_strPumpBaseValue=temp;
GetPrivateProfileString(_T("Node"),_T("PumpBound"),"",temp,MAX_PATH,strFileName1);
m_strPumpBound=temp;
*/
UpdateData(FALSE);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPackInfo::OnOK()
{
/* m_strBaseValue = _T("");
m_strBound = _T("");
m_strMinValue = _T("");
m_strMaxValue = _T("");
m_strStep = _T("");*/
// TODO: Add extra validation here
UpdateData();
if (m_strPackId.IsEmpty())
{
MessageBox("请输入数据包标识!");
return ;
}
if (m_strPackType.IsEmpty())
{
MessageBox("请输入数据包类型!");
return ;
}
if (m_PackInterval.IsEmpty())
{
MessageBox("请输入数据包间隔!");
return ;
}
if (m_strPackHeadLen.IsEmpty())
{
MessageBox("请输入数据包前缀长度!");
return ;
}
/*
if (m_strBaseValue.IsEmpty())
{
MessageBox("请输入4-20mA节点基值!");
return ;
}
if (m_strBound.IsEmpty())
{
MessageBox("请输入4-20mA节点范围!");
return ;
}
if (m_strMinValue.IsEmpty())
{
MessageBox("请输入绞车节点最小值!");
return ;
}
if (m_strMaxValue.IsEmpty())
{
MessageBox("请输入绞车节点最大值!");
return ;
}
if (m_strFirstValue.IsEmpty())
{
MessageBox("请输入绞车节点初始值!");
return ;
}
if (m_strStep.IsEmpty())
{
MessageBox("请输入绞车节点步长!");
return ;
}
if (m_strPumpBaseValue.IsEmpty())
{
MessageBox("请输入泵冲节点基值!");
return ;
}
if (m_strPumpBound.IsEmpty())
{
MessageBox("请输入泵冲节点基值范围!");
return ;
}
*/
char svPath[MAX_PATH];
::GetModuleFileName(NULL,svPath,sizeof(svPath));
CString ExePath = svPath;
int j = ExePath.ReverseFind('\\');
struct _finddata_t xml_file;
long hFile;
CString strXmlFolderPath;
strXmlFolderPath=ExePath.Left(j);
strXmlFolderPath+="\\Config";
CString strFileName1=strXmlFolderPath;
strFileName1+="\\";
strFileName1+="config.ini";
if( (hFile=_findfirst(strXmlFolderPath.GetBuffer(strXmlFolderPath.GetLength()), &xml_file ))==-1)
{
SECURITY_ATTRIBUTES Attribute;
Attribute.bInheritHandle=FALSE;
Attribute.lpSecurityDescriptor=NULL;
Attribute.nLength=sizeof(SECURITY_ATTRIBUTES);
BOOL bResult=::CreateDirectory(strXmlFolderPath,&Attribute);
}
WritePrivateProfileString(_T("Package"),_T("PackId"),m_strPackId,strFileName1);
WritePrivateProfileString(_T("Package"),_T("PackType"),m_strPackType,strFileName1);
WritePrivateProfileString(_T("Package"),_T("PackInterval"),m_PackInterval,strFileName1);
WritePrivateProfileString(_T("Package"),_T("PackHeadLen"),m_strPackHeadLen,strFileName1);
/* WritePrivateProfileString(_T("Node"),_T("BaseValue"),m_strBaseValue,strFileName1);
WritePrivateProfileString(_T("Node"),_T("Bound"),m_strBound,strFileName1);
WritePrivateProfileString(_T("Node"),_T("MinValue"),m_strMinValue,strFileName1);
WritePrivateProfileString(_T("Node"),_T("MaxValue"),m_strMaxValue,strFileName1);
WritePrivateProfileString(_T("Node"),_T("FirstValue"),m_strFirstValue,strFileName1);
WritePrivateProfileString(_T("Node"),_T("Step"),m_strStep,strFileName1);
WritePrivateProfileString(_T("Node"),_T("PumpBaseValue"),m_strPumpBaseValue,strFileName1);
WritePrivateProfileString(_T("Node"),_T("PumpBound"),m_strPumpBound,strFileName1);
*/
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -