提交 | 用户 | age
|
418cb3
|
1 |
|
Q |
2 |
// ConfigToolView.cpp: CConfigToolView 类的实现
|
|
3 |
//
|
|
4 |
|
|
5 |
#include "pch.h"
|
|
6 |
#include "framework.h"
|
|
7 |
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
|
|
8 |
// ATL 项目中进行定义,并允许与该项目共享文档代码。
|
|
9 |
#ifndef SHARED_HANDLERS
|
|
10 |
#include "ConfigTool.h"
|
|
11 |
#endif
|
|
12 |
|
|
13 |
#include "ConfigToolDoc.h"
|
|
14 |
#include "ConfigToolView.h"
|
|
15 |
#include "../MyLib/Functions.hpp"
|
|
16 |
|
|
17 |
#ifdef _DEBUG
|
|
18 |
#define new DEBUG_NEW
|
|
19 |
#endif
|
|
20 |
|
|
21 |
CConfigToolDoc::stCtrls myCtrls[] =
|
|
22 |
{
|
|
23 |
25001,CConfigToolDoc::typeText,_T("文本输入框1"),_T("默认文本1"),_T("DT200"),
|
|
24 |
25002,CConfigToolDoc::typeText,_T("文本输入框2"),_T("默认文本2"),_T("DT202"),
|
|
25 |
25003,CConfigToolDoc::typeInt,_T("整数输入框1"),_T("123"),_T("默认地址"),
|
|
26 |
25004,CConfigToolDoc::typeInt,_T("整数输入框2"),_T("4562"),_T("默认地址"),
|
|
27 |
25005,CConfigToolDoc::typeFloat,_T("浮点输入框1"),_T("123.6"),_T("默认地址"),
|
|
28 |
25006,CConfigToolDoc::typeFloat,_T("浮点输入框2"),_T("234.5"),_T("默认地址"),
|
|
29 |
25007,CConfigToolDoc::typeSelect,_T("选择框1"),_T("选择1|选项2|选项3|选项4|选项5"),_T("默认地址"),
|
|
30 |
25008,CConfigToolDoc::typeSelect,_T("选择甜点"),_T("苹果|西瓜|香蕉|沙拉|火龙果"),_T("默认地址"),
|
|
31 |
25009,CConfigToolDoc::typeCheck,_T("复选框1"),_T("默认选择1"),_T("默认地址"),
|
|
32 |
25010,CConfigToolDoc::typeCheck,_T("复选框2"),_T("默认选择2"),_T("默认地址"),
|
|
33 |
25011,CConfigToolDoc::typeButton,_T("按钮1"),_T("默认1"),_T("默认地址"),
|
|
34 |
25012,CConfigToolDoc::typeButton,_T("按钮2"),_T("默认2"),_T("默认地址"),
|
|
35 |
25013,CConfigToolDoc::typeButton,_T("按钮3"),_T("默认3"),_T("默认地址"),
|
|
36 |
25014,CConfigToolDoc::typeButton,_T("按钮4"),_T("默认4"),_T("默认地址"),
|
|
37 |
25015,CConfigToolDoc::typeButton,_T("按钮5"),_T("默认5"),_T("默认地址"),
|
|
38 |
25016,CConfigToolDoc::typeButton,_T("按钮6"),_T("默认6"),_T("默认地址"),
|
|
39 |
25017,CConfigToolDoc::typeButton,_T("按钮7"),_T("默认7"),_T("默认地址"),
|
|
40 |
|
|
41 |
};
|
|
42 |
CStatic * pCStatics[100] = { 0 };
|
|
43 |
CWnd * pCWnds[100] = { 0 };
|
|
44 |
|
|
45 |
int nCtrls = sizeof(myCtrls) / sizeof(CConfigToolDoc::stCtrls);
|
|
46 |
|
|
47 |
// CConfigToolView
|
|
48 |
|
|
49 |
IMPLEMENT_DYNCREATE(CConfigToolView, CFormView)
|
|
50 |
|
|
51 |
BEGIN_MESSAGE_MAP(CConfigToolView, CFormView)
|
|
52 |
// 标准打印命令
|
|
53 |
ON_COMMAND(ID_FILE_PRINT, &CFormView::OnFilePrint)
|
|
54 |
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CFormView::OnFilePrint)
|
|
55 |
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CFormView::OnFilePrintPreview)
|
|
56 |
ON_WM_CLOSE()
|
|
57 |
ON_WM_DESTROY()
|
|
58 |
ON_BN_CLICKED(IDC_BUTTON_COMM_SET, &CConfigToolView::OnBnClickedButtonCommSet)
|
|
59 |
ON_BN_CLICKED(IDC_BUTTON_CONNECT, &CConfigToolView::OnBnClickedButtonConnect)
|
|
60 |
ON_BN_CLICKED(IDC_BUTTON_DISCONNECT, &CConfigToolView::OnBnClickedButtonDisconnect)
|
|
61 |
ON_BN_CLICKED(IDC_BUTTON_UPLOAD, &CConfigToolView::OnBnClickedButtonUpload)
|
|
62 |
ON_BN_CLICKED(IDC_BUTTON_DOWNLOAD, &CConfigToolView::OnBnClickedButtonDownload)
|
|
63 |
ON_BN_CLICKED(IDC_BUTTON_EVENTLOG, &CConfigToolView::OnBnClickedButtonEventlog)
|
|
64 |
ON_WM_MOUSEWHEEL()
|
|
65 |
ON_WM_TIMER()
|
|
66 |
ON_BN_CLICKED(IDC_BUTTON_WRITEDATA, &CConfigToolView::OnBnClickedButtonWritedata)
|
|
67 |
ON_BN_CLICKED(IDC_BUTTON_TIME_NOW, &CConfigToolView::OnBnClickedButtonTimeNow)
|
|
68 |
ON_BN_CLICKED(IDC_BUTTON_LOAD_SYSCFG_FILE, &CConfigToolView::OnBnClickedButtonLoadSyscfgFile)
|
|
69 |
ON_BN_CLICKED(IDC_BUTTON_SAVE_SYSCFG_FILE, &CConfigToolView::OnBnClickedButtonSaveSyscfgFile)
|
|
70 |
END_MESSAGE_MAP()
|
|
71 |
|
|
72 |
// CConfigToolView 构造/析构
|
|
73 |
|
|
74 |
CConfigToolView::CConfigToolView() noexcept
|
|
75 |
: CFormView(IDD_CONFIGTOOL_FORM)
|
|
76 |
{
|
|
77 |
// TODO: 在此处添加构造代码
|
|
78 |
psyscfg = (pKMSysCfg)m_cfgdatabuf;
|
|
79 |
|
|
80 |
}
|
|
81 |
|
|
82 |
CConfigToolView::~CConfigToolView()
|
|
83 |
{
|
|
84 |
}
|
|
85 |
|
|
86 |
void CConfigToolView::DoDataExchange(CDataExchange* pDX)
|
|
87 |
{
|
|
88 |
CFormView::DoDataExchange(pDX);
|
|
89 |
DDX_Control(pDX, IDC_EDIT_LOG1, m_edit_log1);
|
|
90 |
}
|
|
91 |
|
|
92 |
BOOL CConfigToolView::PreCreateWindow(CREATESTRUCT& cs)
|
|
93 |
{
|
|
94 |
// TODO: 在此处通过修改
|
|
95 |
// CREATESTRUCT cs 来修改窗口类或样式
|
|
96 |
|
|
97 |
return CFormView::PreCreateWindow(cs);
|
|
98 |
}
|
|
99 |
|
|
100 |
int CConfigToolView::AddDlgItems()
|
|
101 |
{
|
|
102 |
for (int i = 0; i < nCtrls; i++)
|
|
103 |
{
|
|
104 |
if (pCStatics[i] != NULL) { delete pCStatics[i]; pCStatics[i] = NULL; }
|
|
105 |
if (pCWnds[i] != NULL) { delete pCWnds[i]; pCWnds[i] = NULL; }
|
|
106 |
|
|
107 |
}
|
|
108 |
|
|
109 |
int x0 = 20;
|
|
110 |
int y0 = 48;
|
|
111 |
|
|
112 |
int x1 = 220, x2 = 240, x3 = 480;
|
|
113 |
|
|
114 |
int height = 16;
|
|
115 |
int SpaceY = 24;
|
|
116 |
CString s1;
|
|
117 |
CRect rect1, rect2;
|
|
118 |
for (int i = 0; i < nCtrls; i++)
|
|
119 |
{
|
|
120 |
CString strs[100];
|
|
121 |
CStatic * p1;
|
|
122 |
CEdit * p2;
|
|
123 |
CComboBox * p3;
|
|
124 |
CButton * p5;
|
|
125 |
int n = 0;
|
|
126 |
rect1.left = x0, rect1.right = x1;
|
|
127 |
rect1.top = y0 + i * SpaceY;
|
|
128 |
rect1.bottom = rect1.top + height;
|
|
129 |
|
|
130 |
rect2.left = x2, rect2.right = x3;
|
|
131 |
rect2.top = y0 + i * SpaceY;
|
|
132 |
rect2.bottom = rect1.top + height;
|
|
133 |
|
|
134 |
int k = myCtrls[i].nType;
|
|
135 |
int j;
|
|
136 |
float f;
|
|
137 |
switch (k)
|
|
138 |
{
|
|
139 |
case CConfigToolDoc::typeNone:
|
|
140 |
break;
|
|
141 |
case CConfigToolDoc::typeText:
|
|
142 |
p1 = new CStatic();
|
|
143 |
// p1->SetWindowText(myCtrls[i].sName);
|
|
144 |
p1->Create(myCtrls[i].sName, SS_LEFT, rect1, this);
|
|
145 |
p1->ShowWindow(SW_SHOW);
|
|
146 |
pCStatics[i] = p1;
|
|
147 |
|
|
148 |
p2 = new CEdit;
|
|
149 |
p2->Create(ES_LEFT, rect2, this, myCtrls[i].nUID);
|
|
150 |
p2->ShowWindow(SW_SHOW);
|
|
151 |
p2->SetWindowText(myCtrls[i].Value);
|
|
152 |
|
|
153 |
pCWnds[i] = p2;
|
|
154 |
|
|
155 |
break;
|
|
156 |
case CConfigToolDoc::typeInt:
|
|
157 |
p1 = new CStatic();
|
|
158 |
// p1->SetWindowText(myCtrls[i].sName);
|
|
159 |
p1->Create(myCtrls[i].sName, SS_LEFT, rect1, this);
|
|
160 |
p1->ShowWindow(SW_SHOW);
|
|
161 |
pCStatics[i] = p1;
|
|
162 |
|
|
163 |
p2 = new CEdit;
|
|
164 |
p2->Create(ES_LEFT, rect2, this, myCtrls[i].nUID);
|
|
165 |
p2->ShowWindow(SW_SHOW);
|
|
166 |
j = _tstoi(myCtrls[i].Value);
|
|
167 |
s1.Format(_T("%d"), j);
|
|
168 |
p2->SetWindowText(s1);
|
|
169 |
|
|
170 |
pCWnds[i] = p2;
|
|
171 |
break;
|
|
172 |
case CConfigToolDoc::typeFloat:
|
|
173 |
p1 = new CStatic();
|
|
174 |
// p1->SetWindowText(myCtrls[i].sName);
|
|
175 |
p1->Create(myCtrls[i].sName, SS_LEFT, rect1, this);
|
|
176 |
p1->ShowWindow(SW_SHOW);
|
|
177 |
pCStatics[i] = p1;
|
|
178 |
|
|
179 |
p2 = new CEdit;
|
|
180 |
p2->Create(ES_LEFT, rect2, this, myCtrls[i].nUID);
|
|
181 |
p2->ShowWindow(SW_SHOW);
|
|
182 |
f = float(_tstof(myCtrls[i].Value));
|
|
183 |
s1.Format(_T("%.3f"), f);
|
|
184 |
p2->SetWindowText(s1);
|
|
185 |
pCWnds[i] = p2;
|
|
186 |
break;
|
|
187 |
case CConfigToolDoc::typeSelect:
|
|
188 |
p1 = new CStatic();
|
|
189 |
// p1->SetWindowText(myCtrls[i].sName);
|
|
190 |
p1->Create(myCtrls[i].sName, SS_LEFT, rect1, this);
|
|
191 |
p1->ShowWindow(SW_SHOW);
|
|
192 |
pCStatics[i] = p1;
|
|
193 |
|
|
194 |
p3 = new CComboBox;
|
|
195 |
p3->Create(CBS_DROPDOWN, rect2, this, myCtrls[i].nUID);
|
|
196 |
p3->ShowWindow(SW_SHOW);
|
|
197 |
s1 = myCtrls[i].Value;
|
|
198 |
n = Split(s1, _T("|"), strs);
|
|
199 |
for (int m = 0; m < n; m++)
|
|
200 |
{
|
|
201 |
p3->AddString(strs[m]);
|
|
202 |
}
|
|
203 |
p3->SetCurSel(0);
|
|
204 |
// p3->SetWindowText(myCtrls[i].Value);
|
|
205 |
pCWnds[i] = p3;
|
|
206 |
break;
|
|
207 |
case CConfigToolDoc::typeCheck:
|
|
208 |
p1 = new CStatic();
|
|
209 |
// p1->SetWindowText(myCtrls[i].sName);
|
|
210 |
p1->Create(myCtrls[i].sName, SS_LEFT, rect1, this);
|
|
211 |
p1->ShowWindow(SW_SHOW);
|
|
212 |
pCStatics[i] = p1;
|
|
213 |
|
|
214 |
p5 = new CButton;
|
|
215 |
p5->Create(myCtrls[i].sName, BS_CHECKBOX | BS_AUTOCHECKBOX, rect2, this, myCtrls[i].nUID);
|
|
216 |
p5->ShowWindow(SW_SHOW);
|
|
217 |
pCWnds[i] = p5;
|
|
218 |
break;
|
|
219 |
case CConfigToolDoc::typeButton:
|
|
220 |
p1 = new CStatic();
|
|
221 |
// p1->SetWindowText(myCtrls[i].sName);
|
|
222 |
p1->Create(myCtrls[i].sName, SS_LEFT, rect1, this);
|
|
223 |
p1->ShowWindow(SW_SHOW);
|
|
224 |
pCStatics[i] = p1;
|
|
225 |
|
|
226 |
p5 = new CButton;
|
|
227 |
p5->Create(myCtrls[i].sName, BS_PUSHBUTTON, rect2, this, myCtrls[i].nUID);
|
|
228 |
p5->ShowWindow(SW_SHOW);
|
|
229 |
pCWnds[i] = p5;
|
|
230 |
break;
|
|
231 |
|
|
232 |
default:
|
|
233 |
break;
|
|
234 |
}
|
|
235 |
}
|
|
236 |
return 0;
|
|
237 |
}
|
|
238 |
|
|
239 |
void CConfigToolView::OnInitialUpdate()
|
|
240 |
{
|
|
241 |
CFormView::OnInitialUpdate();
|
|
242 |
GetParentFrame()->RecalcLayout();
|
|
243 |
ResizeParentToFit();
|
|
244 |
|
|
245 |
CString VersionStr = _T("V1.02");
|
|
246 |
CString BuildStr = _T("20210728");
|
|
247 |
|
|
248 |
// TODO: 在此添加专用代码和/或调用基类
|
|
249 |
myLogger1.SetLogPathName(_T("D:\\Logs\\ConfigTool"), _T("ConfigTool"));
|
|
250 |
myLogger1.AttachWnd(m_edit_log1.m_hWnd);
|
|
251 |
myLogger1.bShowLog[0] = 1;
|
|
252 |
myLogger1.bShowThreadId = 0;
|
|
253 |
myLogger1.bShowChannel = 0;
|
|
254 |
myLogger1.bSaveLog[0] = 1;
|
|
255 |
myLogger1.bShowDate = 1;
|
|
256 |
SysLog(_T(" Start ") + VersionStr + _T(" ") + BuildStr + _T("\r\n"));
|
|
257 |
myLogger1.bShowDate = 0;
|
|
258 |
// myLogger1.bShowLineCount=0;
|
|
259 |
// myLogger1.bShowTime=0;
|
|
260 |
myLogger1.UpdateLogDisplay();
|
|
261 |
|
|
262 |
|
|
263 |
|
|
264 |
// AddDlgItems();
|
|
265 |
|
|
266 |
GetDlgItem(IDC_STATIC_PROP)->GetClientRect(&rect1);
|
|
267 |
m_nFrameheight = rect1.bottom - rect1.top;
|
|
268 |
GetDlgItem(IDC_STATIC_PROP)->ClientToScreen(&rect1);
|
|
269 |
this->ScreenToClient(&rect1);
|
|
270 |
|
|
271 |
|
|
272 |
m_propsyscfg1.Create(IDD_PROP_SYSREG1, this);
|
|
273 |
m_propsyscfg1.EnableWindow(true);
|
|
274 |
m_propsyscfg1.GetClientRect(&rect0);
|
|
275 |
m_nPropHeight = rect0.bottom - rect0.top;
|
|
276 |
m_propsyscfg1.ShowWindow(SW_SHOW);
|
|
277 |
m_propsyscfg1.MoveWindow(&rect1, true);
|
|
278 |
|
|
279 |
int nNewPos = m_nScrollPos;
|
|
280 |
int Scrolldel = nNewPos - m_nScrollPos;
|
|
281 |
m_propsyscfg1.ScrollWindow(0, Scrolldel);
|
|
282 |
m_nScrollPos += Scrolldel;
|
|
283 |
|
|
284 |
m_propsyscfg1.psyscfg = (pKMSysCfg)m_cfgdatabuf;
|
|
285 |
|
|
286 |
m_propsyscfg1.m_nFrameheight = m_nFrameheight;
|
|
287 |
m_propsyscfg1.UpdateScrollInfo();
|
|
288 |
|
|
289 |
SCROLLINFO si;
|
|
290 |
si.cbSize = sizeof(SCROLLINFO);
|
|
291 |
si.fMask = SIF_ALL;
|
|
292 |
si.nMin = 0;
|
|
293 |
si.nMax = m_nPropHeight;//你滑动画面的高度
|
|
294 |
si.nPage = m_nFrameheight; //这个是你显示画面的高度
|
|
295 |
si.nPos = 0;//这个是滑块的位置 初始化的时候是0 以后会根据你的操作变动
|
|
296 |
// GetDlgItem(IDC_STATIC_PROP)->SetScrollInfo(SB_VERT, &si);
|
|
297 |
// m_propsyscfg1.SetScrollInfo(SB_VERT, &si);
|
|
298 |
|
|
299 |
// m_prop_scrollbar1.SetScrollInfo(&si, true);
|
|
300 |
|
|
301 |
SetTimer(0, 10, NULL);
|
|
302 |
SetTimer(1, 100, NULL);
|
|
303 |
SetTimer(2, 500, NULL);
|
|
304 |
|
|
305 |
}
|
|
306 |
|
|
307 |
|
|
308 |
// CConfigToolView 打印
|
|
309 |
|
|
310 |
BOOL CConfigToolView::OnPreparePrinting(CPrintInfo* pInfo)
|
|
311 |
{
|
|
312 |
// 默认准备
|
|
313 |
return DoPreparePrinting(pInfo);
|
|
314 |
}
|
|
315 |
|
|
316 |
void CConfigToolView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
|
317 |
{
|
|
318 |
// TODO: 添加额外的打印前进行的初始化过程
|
|
319 |
}
|
|
320 |
|
|
321 |
void CConfigToolView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
|
322 |
{
|
|
323 |
// TODO: 添加打印后进行的清理过程
|
|
324 |
}
|
|
325 |
|
|
326 |
void CConfigToolView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
|
|
327 |
{
|
|
328 |
// TODO: 在此处添加自定义打印代码
|
|
329 |
}
|
|
330 |
|
|
331 |
|
|
332 |
// CConfigToolView 诊断
|
|
333 |
|
|
334 |
#ifdef _DEBUG
|
|
335 |
void CConfigToolView::AssertValid() const
|
|
336 |
{
|
|
337 |
CFormView::AssertValid();
|
|
338 |
}
|
|
339 |
|
|
340 |
void CConfigToolView::Dump(CDumpContext& dc) const
|
|
341 |
{
|
|
342 |
CFormView::Dump(dc);
|
|
343 |
}
|
|
344 |
|
|
345 |
CConfigToolDoc* CConfigToolView::GetDocument() const // 非调试版本是内联的
|
|
346 |
{
|
|
347 |
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CConfigToolDoc)));
|
|
348 |
return (CConfigToolDoc*)m_pDocument;
|
|
349 |
}
|
|
350 |
#endif //_DEBUG
|
|
351 |
|
|
352 |
|
|
353 |
// CConfigToolView 消息处理程序
|
|
354 |
|
|
355 |
void CConfigToolView::OnClose()
|
|
356 |
{
|
|
357 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
358 |
CFormView::OnClose();
|
|
359 |
}
|
|
360 |
|
|
361 |
void CConfigToolView::OnDestroy()
|
|
362 |
{
|
|
363 |
CFormView::OnDestroy();
|
|
364 |
for (int i = 0; i < nCtrls; i++)
|
|
365 |
{
|
|
366 |
if (pCStatics[i] != NULL) { delete pCStatics[i]; pCStatics[i] = NULL; }
|
|
367 |
if (pCWnds[i] != NULL) { delete pCWnds[i]; pCWnds[i] = NULL; }
|
|
368 |
|
|
369 |
}
|
|
370 |
// TODO: 在此处添加消息处理程序代码
|
|
371 |
}
|
|
372 |
|
|
373 |
BOOL CConfigToolView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
|
|
374 |
{
|
|
375 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
376 |
CPoint pt1 = pt;
|
|
377 |
ScreenToClient(&pt1);
|
|
378 |
if (PtInRect(rect1, pt1))
|
|
379 |
{
|
|
380 |
int nNewPos = m_nScrollPos;
|
|
381 |
m_propsyscfg1.VScrollBy(-zDelta);
|
|
382 |
if (zDelta < 0)
|
|
383 |
{
|
|
384 |
if (-m_nScrollPos < m_nPropHeight - m_nFrameheight - 30)
|
|
385 |
nNewPos = m_nScrollPos - 30;
|
|
386 |
else
|
|
387 |
nNewPos = -(m_nPropHeight - m_nFrameheight);
|
|
388 |
}
|
|
389 |
else if (zDelta > 0)
|
|
390 |
{
|
|
391 |
if (-m_nScrollPos > 30)
|
|
392 |
nNewPos = m_nScrollPos + 30;
|
|
393 |
else
|
|
394 |
nNewPos = 0;
|
|
395 |
}
|
|
396 |
else
|
|
397 |
{
|
|
398 |
}
|
|
399 |
int Scrolldel = nNewPos - m_nScrollPos;
|
|
400 |
//m_propsyscfg1.ScrollWindow(0, Scrolldel);
|
|
401 |
m_nScrollPos += Scrolldel;
|
|
402 |
return true;
|
|
403 |
}
|
|
404 |
// m_prop_scrollbar1.SetScrollPos(-m_nScrollPos);
|
|
405 |
return CFormView::OnMouseWheel(nFlags, zDelta, pt);
|
|
406 |
}
|
|
407 |
|
|
408 |
void CConfigToolView::OnTimer(UINT_PTR nIDEvent)
|
|
409 |
{
|
|
410 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
411 |
if (nIDEvent == 0)
|
|
412 |
{
|
|
413 |
KillTimer(0);
|
|
414 |
DelayInit();
|
|
415 |
}
|
|
416 |
else if (nIDEvent == 1)
|
|
417 |
{
|
|
418 |
myLogger1.UpdateLogDisplay();
|
|
419 |
}
|
|
420 |
else if (nIDEvent == 2)
|
|
421 |
{
|
|
422 |
TestAutoConnect();
|
|
423 |
}
|
|
424 |
|
|
425 |
CFormView::OnTimer(nIDEvent);
|
|
426 |
}
|
|
427 |
|
|
428 |
int CConfigToolView::DelayInit()
|
|
429 |
{
|
|
430 |
// TODO: 在此处添加实现代码.
|
|
431 |
return 0;
|
|
432 |
}
|
|
433 |
|
|
434 |
int CConfigToolView::TestAutoConnect()
|
|
435 |
{
|
|
436 |
// TODO: 在此处添加实现代码.
|
|
437 |
int res;
|
|
438 |
unsigned short nCount;
|
|
439 |
bool bNewConnected = false;
|
|
440 |
if (m_bOpened)
|
|
441 |
{
|
|
442 |
res = GetDocument()->MyKlink.GetInfo(1, &nCount, m_InfoBlockbuf);
|
|
443 |
if (res == KLink1::KL_OK)
|
|
444 |
{
|
|
445 |
bNewConnected = true;
|
|
446 |
if (m_bConnected == false)
|
|
447 |
{
|
|
448 |
// new connected one.
|
|
449 |
ShowInfoBlockParams();
|
|
450 |
m_bConnected = true;
|
|
451 |
}
|
|
452 |
}
|
|
453 |
else
|
|
454 |
{
|
|
455 |
m_bConnected = false;
|
|
456 |
ClearInfoBlockParams();
|
|
457 |
}
|
|
458 |
}
|
|
459 |
return 0;
|
|
460 |
}
|
|
461 |
|
|
462 |
|
|
463 |
int CConfigToolView::ClearInfoBlockParams()
|
|
464 |
{
|
|
465 |
// TODO: 在此处添加实现代码.
|
|
466 |
CString s1;
|
|
467 |
s1.Empty();
|
|
468 |
SetDlgItemText(IDC_EDIT_DEVICE_TYPE, s1);
|
|
469 |
SetDlgItemText(IDC_EDIT_FIRM_VER, s1);
|
|
470 |
SetDlgItemText(IDC_EDIT_KLINK_VER, s1);
|
|
471 |
SetDlgItemText(IDC_EDIT_KBUS_VER, s1);
|
|
472 |
SetDlgItemText(IDC_EDIT_KNET_VER, s1);
|
|
473 |
SetDlgItemText(IDC_EDIT_KWL_VER, s1);
|
|
474 |
SetDlgItemText(IDC_EDIT_FUNCTIONS, s1);
|
|
475 |
|
|
476 |
SetDlgItemText(IDC_EDIT_CAP_PROG, s1);
|
|
477 |
SetDlgItemText(IDC_EDIT_CAP_DT, s1);
|
|
478 |
|
|
479 |
SetDlgItemText(IDC_EDIT_CAP_WR, s1);
|
|
480 |
SetDlgItemText(IDC_EDIT_CAP_TM, s1);
|
|
481 |
SetDlgItemText(IDC_EDIT_CAP_SW, s1);
|
|
482 |
SetDlgItemText(IDC_EDIT_CAP_COM, s1);
|
|
483 |
SetDlgItemText(IDC_EDIT_CAP_CFG, s1);
|
|
484 |
SetDlgItemText(IDC_EDIT_CAP_EVENT, s1);
|
|
485 |
|
|
486 |
SetDlgItemText(IDC_EDIT_CAP_DIN, s1);
|
|
487 |
SetDlgItemText(IDC_EDIT_CAP_DOUT, s1);
|
|
488 |
SetDlgItemText(IDC_EDIT_CAP_AIN_I, s1);
|
|
489 |
SetDlgItemText(IDC_EDIT_CAP_AOUT_I, s1);
|
|
490 |
SetDlgItemText(IDC_EDIT_CAP_AIN_E, s1);
|
|
491 |
SetDlgItemText(IDC_EDIT_CAP_AOUT_E, s1);
|
|
492 |
SetDlgItemText(IDC_EDIT_CAP_HIN, s1);
|
|
493 |
SetDlgItemText(IDC_EDIT_CAP_HOUT, s1);
|
|
494 |
SetDlgItemText(IDC_EDIT_CAP_IRQ_I, s1);
|
|
495 |
SetDlgItemText(IDC_EDIT_CAP_IRQ_O, s1);
|
|
496 |
SetDlgItemText(IDC_EDIT_CAP_EXT_I, s1);
|
|
497 |
SetDlgItemText(IDC_EDIT_CAP_EXT_O, s1);
|
|
498 |
|
|
499 |
SetDlgItemText(IDC_EDIT_DEVICE_UID, s1);
|
|
500 |
|
|
501 |
return 0;
|
|
502 |
}
|
|
503 |
|
|
504 |
|
|
505 |
CString CConfigToolView::GetDeviceNameStr(int DeviceTypeVer)
|
|
506 |
{
|
|
507 |
// TODO: 在此处添加实现代码.
|
|
508 |
static CString DeviceName;
|
|
509 |
DeviceName.Empty();
|
|
510 |
CString s1,s2;
|
|
511 |
UCHAR DeviceType, DeviceVer;
|
|
512 |
DeviceType = (DeviceTypeVer>>8)&0xff;
|
|
513 |
DeviceVer = DeviceTypeVer & 0xff;
|
|
514 |
s1.Format(_T("%02X"), DeviceType);
|
|
515 |
|
|
516 |
if (DeviceList["FAMILY"].Exist(s1))
|
|
517 |
{
|
|
518 |
DeviceName = DeviceList["FAMiLY"][s1];
|
|
519 |
s2.Format(_T("%02X"), DeviceVer);
|
|
520 |
Hash h1 = DeviceList[s1];
|
|
521 |
if (DeviceList[s1].Exist(s2))
|
|
522 |
{
|
|
523 |
DeviceName.Append(_T(", "));
|
|
524 |
DeviceName.Append (DeviceList[s1][s2]);
|
|
525 |
}
|
|
526 |
else
|
|
527 |
{
|
|
528 |
DeviceName.Append(_T(", "));
|
|
529 |
DeviceName.AppendFormat(_T("Version %02X"),DeviceVer);
|
|
530 |
}
|
|
531 |
}
|
|
532 |
else { DeviceName.Format(_T("Device %02X, Version %02X"),DeviceType,DeviceVer); }
|
|
533 |
|
|
534 |
return DeviceName;
|
|
535 |
}
|
|
536 |
|
|
537 |
int CConfigToolView::ShowInfoBlockParams()
|
|
538 |
{
|
|
539 |
// TODO: 在此处添加实现代码.
|
|
540 |
CString s1;
|
|
541 |
|
|
542 |
pInfoBlock = (pKMInfoBlock)m_InfoBlockbuf;
|
|
543 |
s1.Format(_T("%04X"), pInfoBlock->nDeviceTypeVer);
|
|
544 |
SetDlgItemText(IDC_EDIT_DEVICE_TYPE, s1);
|
|
545 |
|
|
546 |
s1 = GetDeviceNameStr(pInfoBlock->nDeviceTypeVer);
|
|
547 |
SetDlgItemText(IDC_EDIT_DEVICE_NAME, s1);
|
|
548 |
|
|
549 |
s1.Format(_T("%04X"), pInfoBlock->nProgVer);
|
|
550 |
SetDlgItemText(IDC_EDIT_FIRM_VER, s1);
|
|
551 |
s1.Format(_T("%04X"), pInfoBlock->nKLinkVer);
|
|
552 |
SetDlgItemText(IDC_EDIT_KLINK_VER, s1);
|
|
553 |
s1.Format(_T("%04X"), pInfoBlock->nKBusVer);
|
|
554 |
SetDlgItemText(IDC_EDIT_KBUS_VER, s1);
|
|
555 |
s1.Format(_T("%04X"), 0);
|
|
556 |
s1.Empty();
|
|
557 |
SetDlgItemText(IDC_EDIT_KNET_VER, s1);
|
|
558 |
//s1.Format(_T("%04X"), 0);
|
|
559 |
SetDlgItemText(IDC_EDIT_KWL_VER, s1);
|
|
560 |
s1.Format(_T("%04X"), pInfoBlock->nAbility);
|
|
561 |
SetDlgItemText(IDC_EDIT_FUNCTIONS, s1);
|
|
562 |
|
|
563 |
s1.Format(_T("%d"), pInfoBlock->nCapacity1);
|
|
564 |
SetDlgItemText(IDC_EDIT_CAP_PROG, s1);
|
|
565 |
s1.Format(_T("%d"), pInfoBlock->nCapacity2);
|
|
566 |
SetDlgItemText(IDC_EDIT_CAP_DT, s1);
|
|
567 |
|
|
568 |
SetDlgItemText(IDC_EDIT_CAP_WR, s1);
|
|
569 |
SetDlgItemText(IDC_EDIT_CAP_TM, s1);
|
|
570 |
s1.Format(_T("%d"), pInfoBlock->nSwitchBits);
|
|
571 |
SetDlgItemText(IDC_EDIT_CAP_SW, s1);
|
|
572 |
s1.Format(_T("%d"), pInfoBlock->nPorts);
|
|
573 |
SetDlgItemText(IDC_EDIT_CAP_COM, s1);
|
|
574 |
s1.Format(_T("%d"), pInfoBlock->nManSize);
|
|
575 |
SetDlgItemText(IDC_EDIT_CAP_CFG, s1);
|
|
576 |
s1.Format(_T("%d"), pInfoBlock->nLogSize);
|
|
577 |
SetDlgItemText(IDC_EDIT_CAP_EVENT, s1);
|
|
578 |
|
|
579 |
s1.Format(_T("%d"), pInfoBlock->nDInput);
|
|
580 |
SetDlgItemText(IDC_EDIT_CAP_DIN, s1);
|
|
581 |
s1.Format(_T("%d"), pInfoBlock->nDInput);
|
|
582 |
SetDlgItemText(IDC_EDIT_CAP_DOUT, s1);
|
|
583 |
s1.Format(_T("%d"), pInfoBlock->nAInput);
|
|
584 |
SetDlgItemText(IDC_EDIT_CAP_AIN_I, s1);
|
|
585 |
s1.Format(_T("%d"), pInfoBlock->nAOutput);
|
|
586 |
SetDlgItemText(IDC_EDIT_CAP_AOUT_I, s1);
|
|
587 |
s1.Format(_T("%d"), pInfoBlock->nAInput);
|
|
588 |
SetDlgItemText(IDC_EDIT_CAP_AIN_E, s1);
|
|
589 |
s1.Format(_T("%d"), pInfoBlock->nAOutput);
|
|
590 |
SetDlgItemText(IDC_EDIT_CAP_AOUT_E, s1);
|
|
591 |
s1.Format(_T("%d"), pInfoBlock->nHInput);
|
|
592 |
SetDlgItemText(IDC_EDIT_CAP_HIN, s1);
|
|
593 |
s1.Format(_T("%d"), pInfoBlock->nHOutput);
|
|
594 |
SetDlgItemText(IDC_EDIT_CAP_HOUT, s1);
|
|
595 |
s1.Empty();
|
|
596 |
SetDlgItemText(IDC_EDIT_CAP_IRQ_I, s1);
|
|
597 |
SetDlgItemText(IDC_EDIT_CAP_IRQ_O, s1);
|
|
598 |
SetDlgItemText(IDC_EDIT_CAP_EXT_I, s1);
|
|
599 |
SetDlgItemText(IDC_EDIT_CAP_EXT_O, s1);
|
|
600 |
|
|
601 |
unsigned short len1;
|
|
602 |
int res = GetDocument()->MyKlink.GetUID(1, &len1, (unsigned short *)uuidbuf);
|
|
603 |
// SysLog(GetDocument()->MyKlink.m_resultStr);
|
|
604 |
s1.Format(_T("GetUID = %d %d bytes"), res, len1);
|
|
605 |
// SysLog(s1);
|
|
606 |
CString s2;
|
|
607 |
if (res == KLink1::KL_OK)
|
|
608 |
{
|
|
609 |
s1.Append(_T("\r\n"));
|
|
610 |
for (int i = 0; i < 12; i++)
|
|
611 |
{
|
|
612 |
s1.AppendFormat(_T("%02X "), uuidbuf[i]);
|
|
613 |
s2.AppendFormat(_T("%02X"), uuidbuf[12 - i - 1]);
|
|
614 |
// s3.AppendFormat(_T("%c"), buf2[12 - i - 1]);
|
|
615 |
}
|
|
616 |
}
|
|
617 |
// SysLog(s1);
|
|
618 |
struuid = s2;
|
|
619 |
SetDlgItemText(IDC_EDIT_DEVICE_UID, struuid);
|
|
620 |
|
|
621 |
return 0;
|
|
622 |
}
|
|
623 |
|
|
624 |
|
|
625 |
int CConfigToolView::ShowFactoryDataParams()
|
|
626 |
{
|
|
627 |
// TODO: 在此处添加实现代码.
|
|
628 |
pfactorydata = (stFactoryData *)m_factorydataBuf;
|
|
629 |
|
|
630 |
return 0;
|
|
631 |
}
|
|
632 |
|
|
633 |
|
|
634 |
int CConfigToolView::ShowParams()
|
|
635 |
{
|
|
636 |
// TODO: 在此处添加实现代码.
|
|
637 |
ShowInfoBlockParams();
|
|
638 |
ShowFactoryDataParams();
|
|
639 |
m_propsyscfg1.ShowParams();
|
|
640 |
return 0;
|
|
641 |
}
|
|
642 |
|
|
643 |
int CConfigToolView::GetFactoryDataParams()
|
|
644 |
{
|
|
645 |
// TODO: 在此处添加实现代码.
|
|
646 |
m_propsyscfg1.GetParams();
|
|
647 |
|
|
648 |
return 0;
|
|
649 |
}
|
|
650 |
|
|
651 |
int CConfigToolView::GetParams()
|
|
652 |
{
|
|
653 |
// TODO: 在此处添加实现代码.
|
|
654 |
|
|
655 |
return 0;
|
|
656 |
}
|
|
657 |
|
|
658 |
void CConfigToolView::OnBnClickedButtonCommSet()
|
|
659 |
{
|
|
660 |
// TODO: 在此添加控件通知处理程序代码
|
|
661 |
CString s1;
|
|
662 |
|
|
663 |
int res = ((CConfigToolDoc *)m_pDocument)->MyKlink.SetCommParam();
|
|
664 |
s1.Format(_T("Com Set = %d "),res);
|
|
665 |
SysLog(s1);
|
|
666 |
}
|
|
667 |
|
|
668 |
void CConfigToolView::OnBnClickedButtonConnect()
|
|
669 |
{
|
|
670 |
// TODO: 在此添加控件通知处理程序代码
|
|
671 |
int res = ((CConfigToolDoc *)m_pDocument)->MyKlink.Connect();
|
|
672 |
CString s1;
|
|
673 |
s1.Format(_T("connect = %d %s"), res,GetDocument()->MyKlink.m_resultStr);
|
|
674 |
SysLog(s1);
|
|
675 |
if (res == KLink1::KL_OK) m_bOpened = true;
|
|
676 |
else { return; }
|
|
677 |
|
|
678 |
unsigned short nCount;
|
|
679 |
res = ((CConfigToolDoc *)m_pDocument)->MyKlink.GetInfo(1, &nCount, m_InfoBlockbuf);
|
|
680 |
pInfoBlock = (pKMInfoBlock)m_InfoBlockbuf;
|
|
681 |
s1.Format(_T("read InfoBlock = %d %d bytes \r\n"), res, nCount);
|
|
682 |
// s1 += FormatHex(m_InfoBlockbuf, nCount);
|
|
683 |
SysLog(s1);
|
|
684 |
if (res == KLink1::KL_OK)
|
|
685 |
{
|
|
686 |
ShowInfoBlockParams();
|
|
687 |
}
|
|
688 |
unsigned char DCount = 120;
|
|
689 |
res = ((CConfigToolDoc *)m_pDocument)->MyKlink.ReadFactoryData(1, 0, DCount, &nCount, m_factorydataBuf);
|
|
690 |
pfactorydata = (stFactoryData *)m_factorydataBuf;
|
|
691 |
s1.Format(_T("read FactoryData = %d %d bytes \r\n"), res, nCount);
|
|
692 |
// s1 += FormatHex(m_factorydataBuf, nCount);
|
|
693 |
SysLog(s1);
|
|
694 |
|
|
695 |
res = ((CConfigToolDoc *)m_pDocument)->MyKlink.ReadSysCfgData(1, 0, DCount, &nCount, m_cfgdatabuf);
|
|
696 |
psyscfg = (pKMSysCfg)m_cfgdatabuf;
|
|
697 |
s1.Format(_T("read SysCfgData = %d %d bytes \r\n"), res, nCount);
|
|
698 |
// s1 += FormatHex(m_cfgdatabuf, nCount);
|
|
699 |
SysLog(s1);
|
|
700 |
|
|
701 |
}
|
|
702 |
|
|
703 |
void CConfigToolView::OnBnClickedButtonDisconnect()
|
|
704 |
{
|
|
705 |
// TODO: 在此添加控件通知处理程序代码
|
|
706 |
CString s1;
|
|
707 |
int res = ((CConfigToolDoc *)m_pDocument)->MyKlink.Close();
|
|
708 |
m_bOpened = false;
|
|
709 |
s1.Format(_T("Close = %d "), res);
|
|
710 |
SysLog(s1);
|
|
711 |
}
|
|
712 |
|
|
713 |
void CConfigToolView::OnBnClickedButtonUpload()
|
|
714 |
{
|
|
715 |
// TODO: 在此添加控件通知处理程序代码
|
|
716 |
// unsigned short values[100];
|
|
717 |
int res;
|
|
718 |
CString s1;
|
|
719 |
unsigned short nCount;
|
|
720 |
|
|
721 |
res = ((CConfigToolDoc *)m_pDocument)->MyKlink.GetInfo(1, &nCount, m_InfoBlockbuf);
|
|
722 |
pInfoBlock = (pKMInfoBlock)m_InfoBlockbuf;
|
|
723 |
s1.Format(_T("read InfoBlock = %d %d bytes \r\n"), res, nCount);
|
|
724 |
s1 += FormatHex(m_InfoBlockbuf, nCount);
|
|
725 |
SysLog(s1);
|
|
726 |
unsigned char DCount = 120;
|
|
727 |
res = ((CConfigToolDoc *)m_pDocument)->MyKlink.ReadFactoryData(1, 0, DCount, &nCount, m_factorydataBuf);
|
|
728 |
pfactorydata = (stFactoryData *)m_factorydataBuf;
|
|
729 |
s1.Format(_T("read FactoryData = %d %d bytes \r\n"), res, nCount);
|
|
730 |
s1 += FormatHex(m_factorydataBuf, nCount);
|
|
731 |
SysLog(s1);
|
|
732 |
|
|
733 |
res = ((CConfigToolDoc *)m_pDocument)->MyKlink.ReadSysCfgData(1, 0, DCount, &nCount, m_cfgdatabuf);
|
|
734 |
psyscfg = (pKMSysCfg)m_cfgdatabuf;
|
|
735 |
s1.Format(_T("read SysCfgData = %d %d bytes \r\n"), res, nCount);
|
|
736 |
s1 += FormatHex(m_cfgdatabuf, nCount);
|
|
737 |
SysLog(s1);
|
|
738 |
|
|
739 |
if (res == KLink1::KL_OK)
|
|
740 |
{
|
|
741 |
ShowParams();
|
|
742 |
}
|
|
743 |
|
|
744 |
// m_propsyscfg1.ShowParams();
|
|
745 |
}
|
|
746 |
|
|
747 |
void CConfigToolView::OnBnClickedButtonDownload()
|
|
748 |
{
|
|
749 |
int res;
|
|
750 |
CString s1;
|
|
751 |
unsigned char DCount = 120;
|
|
752 |
unsigned short nCount=0;
|
|
753 |
m_propsyscfg1.GetParams();
|
|
754 |
|
|
755 |
res = ((CConfigToolDoc *)m_pDocument)->MyKlink.WriteSysCfgData(1, 0, DCount, m_cfgdatabuf);
|
|
756 |
// m_propsyscfg1.psyscfg = (pKMSysCfg)m_cfgdatabuf;
|
|
757 |
s1.Format(_T("Download = %d %d bytes"), res, DCount);
|
|
758 |
SysLog(s1);
|
|
759 |
if (res != KLink1::KL_OK)
|
|
760 |
{
|
|
761 |
s1.Format(_T("下载失败 "));
|
|
762 |
s1 += ((CConfigToolDoc *)m_pDocument)->MyKlink.m_resultStr;
|
|
763 |
s1 += ((CConfigToolDoc *)m_pDocument)->MyKlink.GetErrDescStr(res);
|
|
764 |
SysLog(s1);
|
|
765 |
}
|
|
766 |
|
|
767 |
// TODO: 在此添加控件通知处理程序代码
|
|
768 |
}
|
|
769 |
|
|
770 |
void CConfigToolView::OnBnClickedButtonEventlog()
|
|
771 |
{
|
|
772 |
// TODO: 在此添加控件通知处理程序代码
|
|
773 |
}
|
|
774 |
|
|
775 |
|
|
776 |
void CConfigToolView::OnBnClickedButtonWritedata()
|
|
777 |
{
|
|
778 |
// TODO: 在此添加控件通知处理程序代码
|
|
779 |
}
|
|
780 |
|
|
781 |
|
|
782 |
|
|
783 |
|
|
784 |
void CConfigToolView::OnBnClickedButtonTimeNow()
|
|
785 |
{
|
|
786 |
// TODO: 在此添加控件通知处理程序代码
|
|
787 |
}
|
|
788 |
|
|
789 |
|
|
790 |
void CConfigToolView::OnBnClickedButtonLoadSyscfgFile()
|
|
791 |
{
|
|
792 |
// TODO: 在此添加控件通知处理程序代码
|
|
793 |
CString s1;
|
|
794 |
CString strFilePath1;
|
|
795 |
MHash syscfg1;
|
|
796 |
CFileDialog dlg1(true,_T("*.cfg"),NULL,NULL,_T("配置文件(*.cfg)|*.cfg|所有文件 (*.*)|*.*||"),this);
|
|
797 |
INT_PTR r= dlg1.DoModal();
|
|
798 |
if (r == IDOK)
|
|
799 |
{
|
|
800 |
strFilePath1 = dlg1.GetPathName();
|
|
801 |
int res = syscfg1.LoadFromFile(strFilePath1);
|
|
802 |
s1.Format(_T("Load from file %s = %d "), strFilePath1, res);
|
|
803 |
SysLog(s1);
|
|
804 |
psyscfg->Version = int(syscfg1["SYSTEM"]["Version"]);
|
|
805 |
psyscfg->workmode = int(syscfg1["SYSTEM"]["WorkMode"]);
|
|
806 |
psyscfg->SwitchFunc = _tstoi(syscfg1["SYSTEM"]["SwitchFunc"]);
|
|
807 |
psyscfg->Space1 = 0;
|
|
808 |
|
|
809 |
psyscfg->PortParams[0].WorkMode = int(syscfg1["Port_1"]["WorkMode"]);
|
|
810 |
psyscfg->PortParams[0].Station = int(syscfg1["Port_1"]["Station"]);
|
|
811 |
psyscfg->PortParams[0].BaudRate = int(syscfg1["Port_1"]["BaudRate"]);
|
|
812 |
psyscfg->PortParams[0].ByteSize = int(syscfg1["Port_1"]["ByteSize"]);
|
|
813 |
psyscfg->PortParams[0].Parity = int(syscfg1["Port_1"]["Parity"]);
|
|
814 |
psyscfg->PortParams[0].StopBits = int(syscfg1["Port_1"]["StopBits"]);
|
|
815 |
psyscfg->PortParams[0].EndType = int(syscfg1["Port_1"]["EndType"]);
|
|
816 |
psyscfg->PortParams[0].EofChar = int(syscfg1["Port_1"]["EofChar"]);
|
|
817 |
psyscfg->PortParams[0].SofChar = int(syscfg1["Port_1"]["SofChar"]);
|
|
818 |
psyscfg->PortParams[0].EndTime = int(syscfg1["Port_1"]["EndTime"]);
|
|
819 |
psyscfg->PortParams[0].RecvAddr = int(syscfg1["Port_1"]["RecvAddr"]);
|
|
820 |
psyscfg->PortParams[0].RecvSize = int(syscfg1["Port_1"]["RecvSize"]);
|
|
821 |
|
|
822 |
psyscfg->PortParams[1].WorkMode = int(syscfg1["Port_2"]["WorkMode"]);
|
|
823 |
psyscfg->PortParams[1].Station = int(syscfg1["Port_2"]["Station"]);
|
|
824 |
psyscfg->PortParams[1].BaudRate = int(syscfg1["Port_2"]["BaudRate"]);
|
|
825 |
psyscfg->PortParams[1].ByteSize = int(syscfg1["Port_2"]["ByteSize"]);
|
|
826 |
psyscfg->PortParams[1].Parity = int(syscfg1["Port_2"]["Parity"]);
|
|
827 |
psyscfg->PortParams[1].StopBits = int(syscfg1["Port_2"]["StopBits"]);
|
|
828 |
psyscfg->PortParams[1].EndType = int(syscfg1["Port_2"]["EndType"]);
|
|
829 |
psyscfg->PortParams[1].EofChar = int(syscfg1["Port_2"]["EofChar"]);
|
|
830 |
psyscfg->PortParams[1].SofChar = int(syscfg1["Port_2"]["SofChar"]);
|
|
831 |
psyscfg->PortParams[1].EndTime = int(syscfg1["Port_2"]["EndTime"]);
|
|
832 |
psyscfg->PortParams[1].RecvAddr = int(syscfg1["Port_2"]["RecvAddr"]);
|
|
833 |
psyscfg->PortParams[1].RecvSize = int(syscfg1["Port_2"]["RecvSize"]);
|
|
834 |
|
|
835 |
psyscfg->OutMappings[0] = int(syscfg1["OutMapping"]["Output_0"]);
|
|
836 |
psyscfg->OutMappings[1] = int(syscfg1["OutMapping"]["Output_1"]);
|
|
837 |
psyscfg->OutMappings[2] = int(syscfg1["OutMapping"]["Output_2"]);
|
|
838 |
psyscfg->OutMappings[3] = int(syscfg1["OutMapping"]["Output_3"]);
|
|
839 |
psyscfg->OutMappings[4] = int(syscfg1["OutMapping"]["Output_4"]);
|
|
840 |
psyscfg->OutMappings[5] = int(syscfg1["OutMapping"]["Output_5"]);
|
|
841 |
|
|
842 |
m_propsyscfg1.ShowParams();
|
|
843 |
|
|
844 |
}
|
|
845 |
|
|
846 |
|
|
847 |
}
|
|
848 |
|
|
849 |
|
|
850 |
void CConfigToolView::OnBnClickedButtonSaveSyscfgFile()
|
|
851 |
{
|
|
852 |
// TODO: 在此添加控件通知处理程序代码
|
|
853 |
CString s1;
|
|
854 |
CString sFilePathName1;
|
|
855 |
MHash syscfg1;
|
|
856 |
|
|
857 |
m_propsyscfg1.GetParams();
|
|
858 |
|
|
859 |
syscfg1["SYSTEM"]["Version"] = psyscfg->Version;
|
|
860 |
syscfg1["SYSTEM"]["WorkMode"] = psyscfg->workmode;
|
|
861 |
syscfg1["SYSTEM"]["SwitchFunc"] = psyscfg->SwitchFunc;
|
|
862 |
|
|
863 |
syscfg1["Port_1"]["WorkMode"] = psyscfg->PortParams[0].WorkMode;
|
|
864 |
syscfg1["Port_1"]["Station"] = psyscfg->PortParams[0].Station;
|
|
865 |
syscfg1["Port_1"]["BaudRate"] = psyscfg->PortParams[0].BaudRate;
|
|
866 |
syscfg1["Port_1"]["ByteSize"] = psyscfg->PortParams[0].ByteSize;
|
|
867 |
syscfg1["Port_1"]["Parity"] = psyscfg->PortParams[0].Parity;
|
|
868 |
syscfg1["Port_1"]["StopBits"] = psyscfg->PortParams[0].StopBits;
|
|
869 |
syscfg1["Port_1"]["EndType"] = psyscfg->PortParams[0].EndType;
|
|
870 |
syscfg1["Port_1"]["EofChar"] = psyscfg->PortParams[0].EofChar;
|
|
871 |
syscfg1["Port_1"]["SofChar"] = psyscfg->PortParams[0].SofChar;
|
|
872 |
syscfg1["Port_1"]["EndTime"] = psyscfg->PortParams[0].EndTime;
|
|
873 |
syscfg1["Port_1"]["RecvAddr"] = psyscfg->PortParams[0].RecvAddr;
|
|
874 |
syscfg1["Port_1"]["RecvSize"] = psyscfg->PortParams[0].RecvSize;
|
|
875 |
|
|
876 |
syscfg1["Port_2"]["WorkMode"] = psyscfg->PortParams[1].WorkMode;
|
|
877 |
syscfg1["Port_2"]["Station"] = psyscfg->PortParams[1].Station;
|
|
878 |
syscfg1["Port_2"]["BaudRate"] = psyscfg->PortParams[1].BaudRate;
|
|
879 |
syscfg1["Port_2"]["ByteSize"] = psyscfg->PortParams[1].ByteSize;
|
|
880 |
syscfg1["Port_2"]["Parity"] = psyscfg->PortParams[1].Parity;
|
|
881 |
syscfg1["Port_2"]["StopBits"] = psyscfg->PortParams[1].StopBits;
|
|
882 |
syscfg1["Port_2"]["EndType"] = psyscfg->PortParams[1].EndType;
|
|
883 |
syscfg1["Port_2"]["EofChar"] = psyscfg->PortParams[1].EofChar;
|
|
884 |
syscfg1["Port_2"]["SofChar"] = psyscfg->PortParams[1].SofChar;
|
|
885 |
syscfg1["Port_2"]["EndTime"] = psyscfg->PortParams[1].EndTime;
|
|
886 |
syscfg1["Port_2"]["RecvAddr"] = psyscfg->PortParams[1].RecvAddr;
|
|
887 |
syscfg1["Port_2"]["RecvSize"] = psyscfg->PortParams[1].RecvSize;
|
|
888 |
|
|
889 |
syscfg1["SYSTEM"]["Version"] = psyscfg->Version;
|
|
890 |
|
|
891 |
syscfg1["OutMapping"]["Output_0"] = psyscfg->OutMappings[0];
|
|
892 |
syscfg1["OutMapping"]["Output_1"] = psyscfg->OutMappings[1];
|
|
893 |
syscfg1["OutMapping"]["Output_2"] = psyscfg->OutMappings[2];
|
|
894 |
syscfg1["OutMapping"]["Output_3"] = psyscfg->OutMappings[3];
|
|
895 |
syscfg1["OutMapping"]["Output_4"] = psyscfg->OutMappings[4];
|
|
896 |
syscfg1["OutMapping"]["Output_5"] = psyscfg->OutMappings[5];
|
|
897 |
|
|
898 |
CFileDialog dlg1(false, _T("*.cfg"),NULL, OFN_OVERWRITEPROMPT, _T("配置文件(*.cfg)|*.cfg|所有文件 (*.*)|*.*||"),this);
|
|
899 |
INT_PTR r = dlg1.DoModal();
|
|
900 |
if (r == IDOK)
|
|
901 |
{
|
|
902 |
int res = 0;
|
|
903 |
sFilePathName1 = dlg1.GetPathName();
|
|
904 |
s1.Format(_T("Save to File %s = %d "), sFilePathName1, res);
|
|
905 |
SysLog(s1);
|
|
906 |
syscfg1.SaveToFile(sFilePathName1);
|
|
907 |
}
|
|
908 |
|
|
909 |
}
|
|
910 |
|