123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142 |
- // AddDevice.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "Editor.h"
- #include "AddDevice.h"
- #include "IniReader.h"
- // CAddDevice 对话框
- IMPLEMENT_DYNAMIC(CAddDevice, CDialog)
- CAddDevice::CAddDevice(CWnd* pParent /*=NULL*/)
- : CDialog(CAddDevice::IDD, pParent)
- , m_strDeviceName(_T(""))
- , m_strDeviceID(_T(""))
- , m_strResponseTime(_T(""))
- , m_strLineType(_T(""))
- , m_strComType(_T(""))
- , m_strPindef(_T(""))
- , m_strFactory(_T(""))
- , m_strClassType(_T(""))
- , m_strDeviceName2(_T(""))
- , m_strModelNum(_T(""))
- , m_strSeries(_T(""))
- , m_strProtocol(_T(""))
- {
- }
- CAddDevice::~CAddDevice()
- {
- }
- void CAddDevice::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Text(pDX, ET_DEVICENAME, m_strDeviceName);
- DDX_Text(pDX, ET_DEVICEID, m_strDeviceID);
- DDX_Control(pDX, CB_RATE, m_cobRate);
- DDX_Control(pDX, CB_DATABIT, m_cobDatabit);
- DDX_Control(pDX, CB_STOPBIT, m_cobStopbit);
- DDX_Control(pDX, CB_PARITY, m_cobParity);
- DDX_Text(pDX, ET_RESPONSETIME, m_strResponseTime);
- DDX_Text(pDX, ET_FREQUENCY, m_strFrequency);
- DDX_Text(pDX, ET_LINETYPE, m_strLineType);
- DDX_Text(pDX, ET_COMTYPE, m_strComType);
- DDX_Text(pDX, ET_PINDEF, m_strPindef);
- //DDX_Control(pDX, CB_STORERECV, m_cobStore);
- DDX_Text(pDX, ET_FACTORY, m_strFactory);
- DDX_Text(pDX, ET_CLASSTYPE, m_strClassType);
- DDX_Text(pDX, ET_NAME, m_strDeviceName2);
- DDX_Text(pDX, ET_MODELNUM, m_strModelNum);
- DDX_Text(pDX, ET_SERIES, m_strSeries);
- DDX_Text(pDX, ET_PROTOCOL, m_strProtocol);
- }
- BEGIN_MESSAGE_MAP(CAddDevice, CDialog)
- ON_BN_CLICKED(IDOK, &CAddDevice::OnBnClickedOk)
- ON_BN_CLICKED(Btn_Exist, &CAddDevice::OnBnClickedExist)
- END_MESSAGE_MAP()
- // CAddDevice 消息处理程序
- BOOL CAddDevice::OnInitDialog()
- {
- CDialog::OnInitDialog();
- // TODO: 在此添加额外的初始化
- //////////////////
- CString strPath;
- TCHAR szFull[_MAX_PATH];
- TCHAR szDrive[_MAX_DRIVE];
- TCHAR szDir[_MAX_DIR];
- ::GetModuleFileName(NULL, szFull, sizeof(szFull)/sizeof(TCHAR));
- _tsplitpath(szFull, szDrive, szDir, NULL, NULL);
- _tcscpy(szFull, szDrive);
- _tcscat(szFull, szDir);
- strPath = CString(szFull);
- CString strIni;
- strIni.Format("%s\\config.ini",strPath);
- CIniReader IniReader(strIni);
- m_strDepotPath = IniReader.GetKeyValueText("name","DeviceLibrary");
- m_strRutDepotPath = IniReader.GetKeyValueText("name","RunUnitLibrary");
- UpdateData(FALSE);
- return TRUE; // return TRUE unless you set the focus to a control
- // 异常: OCX 属性页应返回 FALSE
- }
- // 初始化数据视图界面 [4/3/2013 Zero.t]
- void CAddDevice::InitDataView()
- {
-
- }
- void CAddDevice::OnBnClickedOk()
- {
- UpdateData();
- CObjectdepot tObjectdepot;
- tObjectdepot.SetDevicesDepotPath(m_strDepotPath);
- tObjectdepot.SetRuntimeDevicesDepotPath(m_strRutDepotPath);
- STDepotPhysical tDevicePhysical;
- STDeviceDocument tDeviceDocument;
- tDevicePhysical.iRate = GetDlgItemInt(CB_RATE);
- tDevicePhysical.iDBit = GetDlgItemInt(CB_DATABIT);
- tDevicePhysical.iSBit = m_cobStopbit.GetCurSel();
- tDevicePhysical.iPaty = m_cobParity.GetCurSel();
- tDevicePhysical.iRsTm = GetDlgItemInt(ET_RESPONSETIME);
- tDevicePhysical.iIntl = GetDlgItemInt(ET_FREQUENCY);
- sprintf(tDevicePhysical.szLineType,"%s",m_strLineType);
- sprintf(tDevicePhysical.szComType,"%s",m_strComType);
- sprintf(tDevicePhysical.szPinDef,"%s",m_strLineType);
- sprintf(tDeviceDocument.szdeviceClass,"%s",m_strSeries);
- sprintf(tDeviceDocument.szdeviceName,"%s",m_strDeviceName2);
- sprintf(tDeviceDocument.szdeviceType,"%s",m_strClassType);
- sprintf(tDeviceDocument.szFactory,"%s",m_strFactory);
- sprintf(tDeviceDocument.szProtocol,"%s",m_strProtocol);
- sprintf(tDeviceDocument.szUnitType,"%s",m_strModelNum);
- tObjectdepot.InsertElementNode(m_strDeviceName,m_strDeviceID,tDevicePhysical,tDeviceDocument);
- OnOK();
- }
- void CAddDevice::OnBnClickedExist()
- {
- // TODO: 在此添加控件通知处理程序代码
- CDialog::OnCancel();
- }
|