提交 | 用户 | age
|
418cb3
|
1 |
// CDialogSysRegSet.cpp: 实现文件
|
Q |
2 |
//
|
|
3 |
|
|
4 |
#include "pch.h"
|
|
5 |
#include "MTerm1.h"
|
|
6 |
#include "DialogSysRegSet.h"
|
|
7 |
#include "afxdialogex.h"
|
|
8 |
|
|
9 |
|
|
10 |
#include <atlbase.h>
|
|
11 |
#include <msxml6.h>
|
|
12 |
|
|
13 |
#pragma comment(lib, "msxml6.lib")
|
|
14 |
|
|
15 |
#include "MTerm1Doc.h"
|
|
16 |
MHash gsd1;
|
|
17 |
|
|
18 |
|
|
19 |
// CDialogSysRegSet 对话框
|
|
20 |
|
|
21 |
IMPLEMENT_DYNAMIC(CDialogSysRegSet, CDialogEx)
|
|
22 |
|
|
23 |
CDialogSysRegSet::CDialogSysRegSet(CWnd* pParent /*=nullptr*/)
|
|
24 |
: CDialogEx(IDD_DIALOG_SYSREG_SET, pParent)
|
|
25 |
{
|
|
26 |
|
|
27 |
}
|
|
28 |
|
|
29 |
CDialogSysRegSet::~CDialogSysRegSet()
|
|
30 |
{
|
|
31 |
}
|
|
32 |
|
|
33 |
void CDialogSysRegSet::DoDataExchange(CDataExchange* pDX)
|
|
34 |
{
|
|
35 |
CDialogEx::DoDataExchange(pDX);
|
|
36 |
DDX_Control(pDX, IDC_SCROLLBAR1, m_prop_scrollbar1);
|
|
37 |
DDX_Control(pDX, IDC_LIST_SEL1, m_listSel1);
|
|
38 |
}
|
|
39 |
|
|
40 |
|
|
41 |
BEGIN_MESSAGE_MAP(CDialogSysRegSet, CDialogEx)
|
|
42 |
ON_WM_VSCROLL()
|
|
43 |
ON_WM_MOUSEWHEEL()
|
|
44 |
ON_LBN_SELCHANGE(IDC_LIST_SEL1, &CDialogSysRegSet::OnLbnSelchangeListSel1)
|
|
45 |
ON_BN_CLICKED(IDC_BUTTON_READ_FROM_PLC, &CDialogSysRegSet::OnBnClickedButtonReadFromPlc)
|
|
46 |
ON_WM_TIMER()
|
|
47 |
ON_BN_CLICKED(IDC_BUTTON_WRITE_TO_PLC, &CDialogSysRegSet::OnBnClickedButtonWriteToPlc)
|
|
48 |
ON_BN_CLICKED(IDC_BUTTON_READ_FROM_PLC2, &CDialogSysRegSet::OnBnClickedButtonReadFromPlc2)
|
|
49 |
END_MESSAGE_MAP()
|
|
50 |
|
|
51 |
|
|
52 |
// CDialogSysRegSet 消息处理程序
|
|
53 |
|
|
54 |
int CDialogSysRegSet::LoadDeviceDescriptionFile()
|
|
55 |
{
|
|
56 |
// TODO: 在此处添加实现代码.
|
|
57 |
gsd1.LoadFromFile(_T("FP0Ext.cfg"));
|
|
58 |
CString s1;
|
|
59 |
|
|
60 |
s1 = gsd1["configs"]["output1"];
|
|
61 |
|
|
62 |
SysLog(s1);
|
|
63 |
|
|
64 |
s1 = MyCfg1["dafd"]["sdfdf"];
|
|
65 |
|
|
66 |
return 0;
|
|
67 |
}
|
|
68 |
|
|
69 |
int CDialogSysRegSet::AddPropPage(CString sName, CMyPropPage * rDlg, int IDD, void * DataAddr)
|
|
70 |
{
|
|
71 |
// TODO: 在此处添加实现代码.
|
|
72 |
m_listSel1.AddString(sName);
|
|
73 |
if (rDlg->GetSafeHwnd() == NULL ) { }
|
|
74 |
|
|
75 |
m_PropPages[m_nTotalProp] = rDlg;
|
|
76 |
PropPageIDD[m_nTotalProp] = IDD;
|
|
77 |
rDlg->DataPtr = DataAddr;
|
|
78 |
m_nTotalProp++;
|
|
79 |
return 0;
|
|
80 |
}
|
|
81 |
|
|
82 |
int CDialogSysRegSet::testXmlParser()
|
|
83 |
{
|
|
84 |
// TODO: 在此处添加实现代码.
|
|
85 |
CString s1;
|
|
86 |
using namespace std;
|
|
87 |
|
|
88 |
// TODO: 在此添加额外的初始化
|
|
89 |
CoInitialize(NULL);
|
|
90 |
//定义DOM模型中的文档对象
|
|
91 |
CComPtr<IXMLDOMDocument> spXmldoc;
|
|
92 |
//初始化库对象
|
|
93 |
HRESULT hr = spXmldoc.CoCreateInstance(CLSID_DOMDocument60);
|
|
94 |
s1.Format(_T("Create Instance Hr = %d "), hr);
|
|
95 |
SysLog(s1);
|
|
96 |
if (SUCCEEDED(hr))
|
|
97 |
{
|
|
98 |
//读取 xml 文件
|
|
99 |
char *pPath = "config1.xml";
|
|
100 |
CComBSTR Path = CComBSTR(pPath);
|
|
101 |
//将XML文件导入内存中的文档对象
|
|
102 |
VARIANT_BOOL success;
|
|
103 |
hr = spXmldoc->load(CComVariant(Path), &success);
|
|
104 |
s1.Format(_T("Load File Hr = %d "), hr);
|
|
105 |
SysLog(s1);
|
|
106 |
CComPtr<IXMLDOMNodeList> spChildren;
|
|
107 |
|
|
108 |
spXmldoc->get_childNodes(&spChildren);
|
|
109 |
|
|
110 |
int i = 0;
|
|
111 |
long numChildren = 0;
|
|
112 |
spChildren->get_length(&numChildren);
|
|
113 |
s1.Format(_T("num of Children = %d "), numChildren);
|
|
114 |
SysLog(s1);
|
|
115 |
for (int i = 0; i < numChildren; i++) {
|
|
116 |
CComPtr<IXMLDOMNode> spNode;
|
|
117 |
CComBSTR NodeName;
|
|
118 |
spChildren->get_item(i, &spNode);
|
|
119 |
spNode->get_nodeName(&NodeName);
|
|
120 |
CComPtr<IXMLDOMNodeList> spChildren2;
|
|
121 |
spNode->get_childNodes(&spChildren2);
|
|
122 |
long numChildren2 = 0;
|
|
123 |
spChildren2->get_length(&numChildren2);
|
|
124 |
|
|
125 |
CString s2;
|
|
126 |
s2 = NodeName;
|
|
127 |
s1.Format(_T("Root node %d name = %s num of Child %d "), i, s2, numChildren2);
|
|
128 |
SysLog(s1);
|
|
129 |
}
|
|
130 |
|
|
131 |
// spXmldoc
|
|
132 |
|
|
133 |
// spXmldoc->Release();
|
|
134 |
// spXmldoc.Release();
|
|
135 |
}
|
|
136 |
return 0;
|
|
137 |
}
|
|
138 |
|
|
139 |
CMTerm1Doc * CDialogSysRegSet::GetDocument()
|
|
140 |
{
|
|
141 |
// TODO: 在此处添加实现代码.
|
|
142 |
CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()->m_pMainWnd;
|
|
143 |
CMDIChildWnd *pChild = (CMDIChildWnd *)pFrame->GetActiveFrame();
|
|
144 |
CView *pV = (CView*)pChild->GetActiveView();
|
|
145 |
CMTerm1Doc* pDoc = (CMTerm1Doc *)(pV->GetDocument());
|
|
146 |
return pDoc;
|
|
147 |
}
|
|
148 |
|
|
149 |
BOOL CDialogSysRegSet::OnInitDialog()
|
|
150 |
{
|
|
151 |
CDialogEx::OnInitDialog();
|
|
152 |
|
|
153 |
testXmlParser();
|
|
154 |
LoadDeviceDescriptionFile();
|
|
155 |
|
|
156 |
|
|
157 |
SetTimer(0, 10, NULL);
|
|
158 |
|
|
159 |
|
|
160 |
// m_prop_scrollbar1.SetScrollRange(1, 100);
|
|
161 |
// m_prop_scrollbar1.SetScrollPos(20);
|
|
162 |
return TRUE; // return TRUE unless you set the focus to a control
|
|
163 |
// 异常: OCX 属性页应返回 FALSE
|
|
164 |
}
|
|
165 |
|
|
166 |
|
|
167 |
void CDialogSysRegSet::OnTimer(UINT_PTR nIDEvent)
|
|
168 |
{
|
|
169 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
170 |
if (nIDEvent == 0)
|
|
171 |
{
|
|
172 |
KillTimer(0);
|
|
173 |
DelayInit();
|
|
174 |
}
|
|
175 |
else if (nIDEvent == 1)
|
|
176 |
{
|
|
177 |
|
|
178 |
}
|
|
179 |
CDialogEx::OnTimer(nIDEvent);
|
|
180 |
}
|
|
181 |
|
|
182 |
|
|
183 |
int CDialogSysRegSet::DelayInit()
|
|
184 |
{
|
|
185 |
// TODO: 在此处添加实现代码.
|
|
186 |
CMTerm1Doc* pDoc = (CMTerm1Doc *)GetDocument();
|
|
187 |
unsigned short DCount = 120;
|
|
188 |
unsigned short nCount=0;
|
61deef
|
189 |
int res = theApp.MyKLink1.ReadDataWord(1, KLDataSysCfg, 0, DCount, &nCount, m_databuf1);
|
418cb3
|
190 |
CString s1;
|
Q |
191 |
s1.Format(_T("ReadDataWord = %d %d %p %p"), res,nCount, m_databuf1, &pSysCfg->PortParams[0]);
|
|
192 |
SysLog(s1);
|
|
193 |
|
|
194 |
s1.Empty(); s1.Append(_T("\r\n"));
|
|
195 |
for (int i = 0; i < nCount / 2; i++)
|
|
196 |
{
|
|
197 |
if ((i & 0x7) == 0) s1.AppendFormat(_T("%02X "),i);
|
|
198 |
s1.AppendFormat(_T("%04X "), m_databuf1[i]);
|
|
199 |
if (((i + 1) & 0x7) == 0) s1.Append(_T("\r\n"));
|
|
200 |
}
|
|
201 |
SysLog(s1);
|
|
202 |
|
61deef
|
203 |
pSysCfg = (pstKMSysCfg)m_databuf1;
|
418cb3
|
204 |
|
Q |
205 |
m_listSel1.GetCount();
|
|
206 |
AddPropPage(_T("工作模式设置1"), &m_propmodecfg1, IDD_PROP_MODE_CFG1, &pSysCfg->workmode);
|
|
207 |
///*
|
|
208 |
AddPropPage(_T("内存分配1"), &m_propmemcfg1, IDD_PROP_MEM_CFG, 0);
|
|
209 |
AddPropPage(_T("保持/非保持11"), &m_propmodecfg1, IDD_PROP_MODE_CFG1, 0);
|
|
210 |
AddPropPage(_T("保持/非保持21"), &m_propmodecfg1, IDD_PROP_MODE_CFG1, 0);
|
|
211 |
AddPropPage(_T("232通信端口设置1"), &m_propcommcfg1, IDD_PROP_COMM_CFG, &pSysCfg->PortParams[0]);
|
|
212 |
AddPropPage(_T("485通信端口设置1"), &m_propcommcfg2, IDD_PROP_COMM_CFG, &pSysCfg->PortParams[1]);
|
|
213 |
AddPropPage(_T("输入时间常数设置1"), &m_propinputcfg1, IDD_PROP_INPUT_CFG, &pSysCfg->InputParams[0]);
|
|
214 |
// AddPropPage(_T("输入时间常数设置2"), &m_propinputcfg2, IDD_PROP_INPUT_CFG, 0);
|
|
215 |
AddPropPage(_T("输出保持时间设置1"), &m_propoutputcfg1, IDD_PROP_OUTPUT_SET, 0);
|
|
216 |
AddPropPage(_T("输出保持时间设置2"), &m_propoutputcfg2, IDD_PROP_OUTPUT_SET, 0);
|
|
217 |
AddPropPage(_T("485通信端口设置2"), &m_propcommcfg3, IDD_PROP_COMM_CFG, 0);
|
|
218 |
AddPropPage(_T("内置SPI端口设置1"), &m_propmodecfg1, IDD_PROP_MODE_CFG1, 0);
|
|
219 |
AddPropPage(_T("外置扩展SPI端口设置1"), &m_propmodecfg1, IDD_PROP_MODE_CFG1, 0);
|
|
220 |
//*/
|
|
221 |
//GetDlgItem(IDC_STATIC_PROP)->
|
|
222 |
|
|
223 |
GetDlgItem(IDC_STATIC_PROP)->GetClientRect(&rect1);
|
|
224 |
m_nFrameheight = rect1.bottom - rect1.top;
|
|
225 |
GetDlgItem(IDC_STATIC_PROP)->ClientToScreen(&rect1);
|
|
226 |
this->ScreenToClient(&rect1);
|
|
227 |
|
|
228 |
|
|
229 |
m_propsysreg1.Create(IDD_PROP_SYSREG1, this);
|
|
230 |
m_propsysreg1.EnableWindow(true);
|
|
231 |
m_propsysreg1.GetClientRect(&rect0);
|
|
232 |
m_nPropHeight = rect0.bottom - rect0.top;
|
|
233 |
// m_propsysreg1.ShowWindow(SW_SHOW);
|
|
234 |
|
|
235 |
m_propmodecfg1.Create(IDD_PROP_MODE_CFG1, this);
|
|
236 |
m_propmodecfg1.EnableWindow(true);
|
|
237 |
m_propmodecfg1.MoveWindow(&rect1, true);
|
|
238 |
m_propmodecfg1.ShowWindow(SW_SHOW);
|
|
239 |
PropPageInited[0] = 1;
|
|
240 |
|
|
241 |
|
|
242 |
/*
|
|
243 |
m_propmemcfg1.Create(IDD_PROP_MEM_CFG, this);
|
|
244 |
m_propmemcfg1.MoveWindow(&rect1, true);
|
|
245 |
m_propmemcfg1.EnableWindow(true);
|
|
246 |
|
|
247 |
|
|
248 |
m_propcommcfg1.Create(IDD_PROP_COMM_CFG, this);
|
|
249 |
m_propcommcfg1.MoveWindow(&rect1, true);
|
|
250 |
m_propcommcfg1.EnableWindow(true);
|
|
251 |
|
|
252 |
m_propcommcfg2.Create(IDD_PROP_COMM_CFG, this);
|
|
253 |
m_propcommcfg2.MoveWindow(&rect1, true);
|
|
254 |
m_propcommcfg2.EnableWindow(true);
|
|
255 |
|
|
256 |
m_propcommcfg3.Create(IDD_PROP_COMM_CFG, this);
|
|
257 |
m_propcommcfg3.MoveWindow(&rect1, true);
|
|
258 |
m_propcommcfg3.EnableWindow(true);
|
|
259 |
|
|
260 |
m_propinputcfg1.Create(IDD_PROP_INPUT_CFG, this);
|
|
261 |
m_propinputcfg1.MoveWindow(&rect1, true);
|
|
262 |
m_propinputcfg1.EnableWindow(true);
|
|
263 |
|
|
264 |
m_propinputcfg2.Create(IDD_PROP_INPUT_CFG, this);
|
|
265 |
m_propinputcfg2.MoveWindow(&rect1, true);
|
|
266 |
m_propinputcfg2.EnableWindow(true);
|
|
267 |
|
|
268 |
m_propinputcfg3.Create(IDD_PROP_INPUT_CFG, this);
|
|
269 |
m_propinputcfg3.MoveWindow(&rect1, true);
|
|
270 |
m_propinputcfg3.EnableWindow(true);
|
|
271 |
|
|
272 |
m_propinputcfg4.Create(IDD_PROP_INPUT_CFG, this);
|
|
273 |
m_propinputcfg4.MoveWindow(&rect1, true);
|
|
274 |
m_propinputcfg4.EnableWindow(true);
|
|
275 |
|
|
276 |
m_propoutputcfg1.Create(IDD_PROP_OUTPUT_SET, this);
|
|
277 |
m_propoutputcfg1.MoveWindow(&rect1, true);
|
|
278 |
m_propoutputcfg1.EnableWindow(true);
|
|
279 |
|
|
280 |
m_propoutputcfg2.Create(IDD_PROP_OUTPUT_SET, this);
|
|
281 |
m_propoutputcfg2.MoveWindow(&rect1, true);
|
|
282 |
m_propoutputcfg2.EnableWindow(true);
|
|
283 |
|
|
284 |
m_propoutputcfg3.Create(IDD_PROP_OUTPUT_SET, this);
|
|
285 |
m_propoutputcfg3.MoveWindow(&rect1, true);
|
|
286 |
m_propoutputcfg3.EnableWindow(true);
|
|
287 |
|
|
288 |
m_propoutputcfg4.Create(IDD_PROP_OUTPUT_SET, this);
|
|
289 |
m_propoutputcfg4.MoveWindow(&rect1, true);
|
|
290 |
m_propoutputcfg4.EnableWindow(true);
|
|
291 |
*/
|
|
292 |
m_propsysreg1.MoveWindow(&rect1, true);
|
|
293 |
|
|
294 |
int nNewPos = m_nScrollPos;
|
|
295 |
int Scrolldel = nNewPos - m_nScrollPos;
|
|
296 |
m_propsysreg1.ScrollWindow(0, Scrolldel);
|
|
297 |
m_nScrollPos += Scrolldel;
|
|
298 |
|
|
299 |
SCROLLINFO si;
|
|
300 |
si.cbSize = sizeof(SCROLLINFO);
|
|
301 |
si.fMask = SIF_ALL;
|
|
302 |
si.nMin = 0;
|
|
303 |
si.nMax = m_nPropHeight;//你滑动画面的高度
|
|
304 |
si.nPage = m_nFrameheight; //这个是你显示画面的高度
|
|
305 |
si.nPos = 0;//这个是滑块的位置 初始化的时候是0 以后会根据你的操作变动
|
|
306 |
// GetDlgItem(IDC_STATIC_PROP)->SetScrollInfo(SB_VERT, &si);
|
|
307 |
// m_propsysreg1.SetScrollInfo(SB_VERT, &si);
|
|
308 |
|
|
309 |
m_prop_scrollbar1.SetScrollInfo(&si, true);
|
|
310 |
|
|
311 |
return 0;
|
|
312 |
}
|
|
313 |
|
|
314 |
|
|
315 |
void CDialogSysRegSet::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
|
|
316 |
{
|
|
317 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
318 |
int nMin, nMax;
|
|
319 |
pScrollBar->GetScrollRange(&nMin, &nMax); //取得滚动条范围
|
|
320 |
int TempPos = pScrollBar->GetScrollPos();
|
|
321 |
CString s1;
|
|
322 |
// s1.Format(_T("DialogSysReg OnVScroll %d %d %d"), nSBCode, nPos,TempPos);
|
|
323 |
// SysLog(s1);
|
|
324 |
switch (nSBCode)
|
|
325 |
{
|
|
326 |
case SB_THUMBPOSITION://拖动滑块
|
|
327 |
case SB_THUMBTRACK:
|
|
328 |
pScrollBar->SetScrollPos(nPos);
|
|
329 |
TempPos = nPos;
|
|
330 |
break;
|
|
331 |
case SB_LINEUP://点击上边/左边的箭头
|
|
332 |
if (TempPos > 1)
|
|
333 |
{
|
|
334 |
TempPos--;
|
|
335 |
}
|
|
336 |
pScrollBar->SetScrollPos(TempPos);
|
|
337 |
break;
|
|
338 |
case SB_LINEDOWN://点击下边/右边的箭头
|
|
339 |
if (TempPos < nMax)
|
|
340 |
{
|
|
341 |
TempPos++;
|
|
342 |
}
|
|
343 |
pScrollBar->SetScrollPos(TempPos);
|
|
344 |
|
|
345 |
break;
|
|
346 |
|
|
347 |
case SB_PAGEUP: // 如果向上/左滚动一页
|
|
348 |
if (TempPos >10) TempPos -= 10;
|
|
349 |
pScrollBar->SetScrollPos(TempPos);
|
|
350 |
break;
|
|
351 |
|
|
352 |
case SB_PAGEDOWN: // 如果向下/右滚动一页
|
|
353 |
if (TempPos < nMax - 10) TempPos += 10;
|
|
354 |
pScrollBar->SetScrollPos(TempPos);
|
|
355 |
break;
|
|
356 |
}
|
|
357 |
int nNewPos = -TempPos;
|
|
358 |
int Scrolldel = nNewPos - m_nScrollPos;
|
|
359 |
// s1.Format(_T("DialogSysReg Scroll %d %d %d"), m_nScrollPos, nNewPos, Scrolldel);
|
|
360 |
// SysLog(s1);
|
|
361 |
|
|
362 |
m_propsysreg1.ScrollWindow(0, Scrolldel);
|
|
363 |
m_nScrollPos += Scrolldel;
|
|
364 |
|
|
365 |
// m_propsysreg1.ScrollWindow(0, -TempPos);
|
|
366 |
|
|
367 |
CDialogEx::OnVScroll(nSBCode, nPos, pScrollBar);
|
|
368 |
}
|
|
369 |
|
|
370 |
|
|
371 |
BOOL CDialogSysRegSet::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
|
|
372 |
{
|
|
373 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
374 |
/*
|
|
375 |
int nNewPos=m_nScrollPos;
|
|
376 |
if (zDelta < 0)
|
|
377 |
{
|
|
378 |
if (-m_nScrollPos < m_nPropHeight -m_nFrameheight - 30)
|
|
379 |
nNewPos = m_nScrollPos - 30;
|
|
380 |
else
|
|
381 |
nNewPos = - (m_nPropHeight - m_nFrameheight);
|
|
382 |
}
|
|
383 |
else if (zDelta > 0)
|
|
384 |
{
|
|
385 |
if (-m_nScrollPos > 30)
|
|
386 |
nNewPos = m_nScrollPos + 30;
|
|
387 |
else
|
|
388 |
nNewPos = 0;
|
|
389 |
}
|
|
390 |
else
|
|
391 |
{
|
|
392 |
}
|
|
393 |
int Scrolldel = nNewPos - m_nScrollPos;
|
|
394 |
m_propsysreg1.ScrollWindow(0, Scrolldel);
|
|
395 |
m_nScrollPos += Scrolldel;
|
|
396 |
m_prop_scrollbar1.SetScrollPos(-m_nScrollPos);
|
|
397 |
*/
|
|
398 |
return CDialogEx::OnMouseWheel(nFlags, zDelta, pt);
|
|
399 |
|
|
400 |
}
|
|
401 |
|
|
402 |
|
|
403 |
void CDialogSysRegSet::OnLbnSelchangeListSel1()
|
|
404 |
{
|
|
405 |
// TODO: 在此添加控件通知处理程序代码
|
|
406 |
CString s1;
|
|
407 |
int j = m_listSel1.GetCurSel();
|
|
408 |
s1.Format(_T("LbnSelChange %d"),j);
|
|
409 |
SysLog(s1);
|
|
410 |
m_PropPages[m_nCurProp]->ShowWindow(SW_HIDE);
|
|
411 |
|
|
412 |
if (m_PropPages[j]->GetSafeHwnd() == NULL) {
|
|
413 |
m_PropPages[j]->Create(PropPageIDD[j], this);
|
|
414 |
m_PropPages[j]->GetData();
|
|
415 |
}
|
|
416 |
m_PropPages[j]->MoveWindow(&rect1, true);
|
|
417 |
m_PropPages[j]->EnableWindow(true);
|
|
418 |
m_PropPages[j]->ShowWindow(SW_SHOW);
|
|
419 |
/*
|
|
420 |
switch (j)
|
|
421 |
{
|
|
422 |
case 0:
|
|
423 |
m_propmodecfg1.ShowWindow(SW_SHOW);
|
|
424 |
m_propmodecfg1.MoveWindow(&rect1, true);
|
|
425 |
break;
|
|
426 |
case 1:
|
|
427 |
m_propmemcfg1.ShowWindow(SW_SHOW);
|
|
428 |
m_propmodecfg1.MoveWindow(&rect1, true);
|
|
429 |
break;
|
|
430 |
case 2:
|
|
431 |
//m_propmodecfg1.ShowWindow(SW_SHOW);
|
|
432 |
break;
|
|
433 |
case 3:
|
|
434 |
//m_propmodecfg1.ShowWindow(SW_SHOW);
|
|
435 |
break;
|
|
436 |
case 4:
|
|
437 |
m_propcommcfg1.ShowWindow(SW_SHOW);
|
|
438 |
m_propmodecfg1.MoveWindow(&rect1, true);
|
|
439 |
break;
|
|
440 |
case 5:
|
|
441 |
m_propcommcfg2.ShowWindow(SW_SHOW);
|
|
442 |
m_propmodecfg1.MoveWindow(&rect1, true);
|
|
443 |
break;
|
|
444 |
case 6:
|
|
445 |
m_propinputcfg1.ShowWindow(SW_SHOW);
|
|
446 |
break;
|
|
447 |
case 7:
|
|
448 |
m_propinputcfg2.ShowWindow(SW_SHOW);
|
|
449 |
break;
|
|
450 |
case 8:
|
|
451 |
m_propinputcfg3.ShowWindow(SW_SHOW);
|
|
452 |
break;
|
|
453 |
case 9:
|
|
454 |
m_propinputcfg4.ShowWindow(SW_SHOW);
|
|
455 |
break;
|
|
456 |
case 10:
|
|
457 |
m_propoutputcfg1.ShowWindow(SW_SHOW);
|
|
458 |
break;
|
|
459 |
case 11:
|
|
460 |
m_propoutputcfg2.ShowWindow(SW_SHOW);
|
|
461 |
break;
|
|
462 |
case 12:
|
|
463 |
m_propoutputcfg3.ShowWindow(SW_SHOW);
|
|
464 |
break;
|
|
465 |
case 13:
|
|
466 |
m_propoutputcfg4.ShowWindow(SW_SHOW);
|
|
467 |
break;
|
|
468 |
|
|
469 |
case 14:
|
|
470 |
m_propcommcfg3.ShowWindow(SW_SHOW);
|
|
471 |
break;
|
|
472 |
default:
|
|
473 |
break;
|
|
474 |
}
|
|
475 |
*/
|
|
476 |
m_nCurProp = j;
|
|
477 |
}
|
|
478 |
|
|
479 |
|
|
480 |
void CDialogSysRegSet::OnBnClickedButtonReadFromPlc()
|
|
481 |
{
|
|
482 |
// TODO: 在此添加控件通知处理程序代码
|
|
483 |
CMTerm1Doc* pDoc = (CMTerm1Doc *)GetDocument();
|
|
484 |
unsigned short buf1[256];
|
|
485 |
unsigned short DCount=150;
|
|
486 |
unsigned short nCount;
|
|
487 |
CString s1;
|
|
488 |
|
|
489 |
s1.Format(_T("sizeof (syscfg) %d"), sizeof(stKMSysCfg));
|
|
490 |
SysLog(s1);
|
61deef
|
491 |
UCHAR nType = 0;
|
Q |
492 |
int res = theApp.MyKLink1.ReadSysCfgData(1, nType, 0, DCount, &nCount, buf1);
|
418cb3
|
493 |
s1.Format(_T("ReadDataWord = %d %d"), res, nCount);
|
Q |
494 |
SysLog(s1);
|
|
495 |
s1.Empty(); s1.Append(_T("\r\n"));
|
|
496 |
for (int i = 0; i < nCount/2; i++)
|
|
497 |
{
|
|
498 |
if ((i & 0x7) == 0) s1.AppendFormat(_T("%02X "), i);
|
|
499 |
s1.AppendFormat(_T("%04X "), buf1[i]);
|
|
500 |
if (((i+1) & 0x7) == 0) s1.Append(_T("\r\n"));
|
|
501 |
}
|
|
502 |
SysLog(s1);
|
|
503 |
for (int i = 0; i < m_nTotalProp; i++)
|
|
504 |
{
|
|
505 |
if (PropPageInited[i])
|
|
506 |
{
|
|
507 |
m_PropPages[i]->GetData();
|
|
508 |
}
|
|
509 |
}
|
|
510 |
}
|
|
511 |
|
|
512 |
|
|
513 |
|
|
514 |
|
|
515 |
void CDialogSysRegSet::OnBnClickedButtonWriteToPlc()
|
|
516 |
{
|
|
517 |
// TODO: 在此添加控件通知处理程序代码
|
|
518 |
CMTerm1Doc* pDoc = (CMTerm1Doc *)GetDocument();
|
|
519 |
unsigned short DCount = 120;
|
|
520 |
unsigned short nCount;
|
|
521 |
unsigned short buf2[256];
|
|
522 |
for (int i=0;i<256;i++)
|
|
523 |
{
|
|
524 |
buf2[i] = i;
|
|
525 |
}
|
|
526 |
CString s1;
|
|
527 |
pSysCfg->PortParams[0].BaudRate++;
|
|
528 |
|
|
529 |
s1.Format(_T("sizeof (syscfg) %d"), sizeof(stKMSysCfg));
|
|
530 |
SysLog(s1);
|
61deef
|
531 |
UCHAR nType = 0;
|
Q |
532 |
int res = theApp.MyKLink1.WriteSysCfgData(1, nType, 0, DCount, m_databuf1);
|
418cb3
|
533 |
s1.Format(_T("Write syscfg = %d "), res);
|
Q |
534 |
SysLog(s1);
|
|
535 |
}
|
|
536 |
|
|
537 |
|
|
538 |
void CDialogSysRegSet::OnBnClickedButtonReadFromPlc2()
|
|
539 |
{
|
|
540 |
// TODO: 在此添加控件通知处理程序代码
|
|
541 |
CMTerm1Doc* pDoc = (CMTerm1Doc *)GetDocument();
|
|
542 |
unsigned short buf1[256];
|
|
543 |
unsigned short DCount = 150;
|
|
544 |
unsigned short nCount;
|
|
545 |
CString s1;
|
|
546 |
|
|
547 |
s1.Format(_T("sizeof (syscfg) %d"), sizeof(stKMSysCfg));
|
|
548 |
SysLog(s1);
|
61deef
|
549 |
int res = theApp.MyKLink1.ReadDataWord(1, KLDataSysCfg,0,DCount, &nCount, buf1);
|
418cb3
|
550 |
s1.Format(_T("ReadDataWord = %d %d"), res, nCount);
|
Q |
551 |
SysLog(s1);
|
|
552 |
s1.Empty(); s1.Append(_T("\r\n"));
|
|
553 |
for (int i = 0; i < nCount / 2; i++)
|
|
554 |
{
|
|
555 |
if ((i & 0x7) == 0) s1.AppendFormat(_T("%02X "), i);
|
|
556 |
s1.AppendFormat(_T("%04X "), buf1[i]);
|
|
557 |
if (((i + 1) & 0x7) == 0) s1.Append(_T("\r\n"));
|
|
558 |
}
|
|
559 |
SysLog(s1);
|
|
560 |
}
|