提交 | 用户 | age
|
0ed438
|
1 |
|
Q |
2 |
// MultiTerminal2View.cpp: CMTerm2View 类的实现
|
|
3 |
//
|
|
4 |
|
|
5 |
#include "pch.h"
|
|
6 |
#include "framework.h"
|
|
7 |
// SHARED_HANDLERS 可以在实现预览、缩略图和搜索筛选器句柄的
|
|
8 |
// ATL 项目中进行定义,并允许与该项目共享文档代码。
|
|
9 |
#ifndef SHARED_HANDLERS
|
|
10 |
#include "MTerm2.h"
|
|
11 |
#endif
|
|
12 |
|
|
13 |
#include "MTerm2Doc.h"
|
|
14 |
#include "MTerm2View.h"
|
|
15 |
#include "ChildFrm.h"
|
|
16 |
#include "DialogSetCoil.h"
|
|
17 |
#include "DialogSetData.h"
|
|
18 |
#include "DialogIoComment.h"
|
0a20f7
|
19 |
#include "KDefine.h"
|
0ed438
|
20 |
|
Q |
21 |
#ifdef _DEBUG
|
|
22 |
#define new DEBUG_NEW
|
|
23 |
#endif
|
|
24 |
|
|
25 |
|
|
26 |
// CMTerm2View
|
|
27 |
|
|
28 |
IMPLEMENT_DYNCREATE(CMTerm2View, CScrollView)
|
|
29 |
|
|
30 |
BEGIN_MESSAGE_MAP(CMTerm2View, CScrollView)
|
|
31 |
// 标准打印命令
|
|
32 |
ON_COMMAND(ID_FILE_PRINT, &CScrollView::OnFilePrint)
|
|
33 |
ON_COMMAND(ID_FILE_PRINT_DIRECT, &CScrollView::OnFilePrint)
|
|
34 |
ON_COMMAND(ID_FILE_PRINT_PREVIEW, &CScrollView::OnFilePrintPreview)
|
|
35 |
|
|
36 |
ON_WM_CREATE()
|
|
37 |
ON_WM_TIMER()
|
|
38 |
ON_WM_ERASEBKGND()
|
|
39 |
ON_WM_SIZE()
|
|
40 |
|
|
41 |
ON_WM_LBUTTONDOWN()
|
|
42 |
ON_WM_LBUTTONUP()
|
|
43 |
ON_WM_LBUTTONDBLCLK()
|
|
44 |
ON_WM_RBUTTONDOWN()
|
|
45 |
ON_WM_RBUTTONUP()
|
|
46 |
ON_WM_CONTEXTMENU()
|
|
47 |
ON_WM_INITMENUPOPUP()
|
|
48 |
|
|
49 |
ON_COMMAND(ID_RECT_SELECT, &CMTerm2View::OnRectSelect)
|
|
50 |
ON_UPDATE_COMMAND_UI(ID_RECT_SELECT, &CMTerm2View::OnUpdateRectSelect)
|
|
51 |
ON_COMMAND(ID_TEXT_FIRST, &CMTerm2View::OnTextFirst)
|
|
52 |
ON_UPDATE_COMMAND_UI(ID_TEXT_FIRST, &CMTerm2View::OnUpdateTextFirst)
|
|
53 |
ON_COMMAND(ID_INSERT_BLANK_LINE, &CMTerm2View::OnInsertBlankLine)
|
|
54 |
ON_UPDATE_COMMAND_UI(ID_INSERT_BLANK_LINE, &CMTerm2View::OnUpdateInsertBlankLine)
|
|
55 |
ON_COMMAND(ID_DELETE_BLANK_LINE, &CMTerm2View::OnDeleteBlankLine)
|
|
56 |
ON_UPDATE_COMMAND_UI(ID_DELETE_BLANK_LINE, &CMTerm2View::OnUpdateDeleteBlankLine)
|
|
57 |
ON_COMMAND(ID_DISPLAY_COMMENTS, &CMTerm2View::OnDisplayComments)
|
|
58 |
ON_UPDATE_COMMAND_UI(ID_DISPLAY_COMMENTS, &CMTerm2View::OnUpdateDisplayComments)
|
|
59 |
ON_COMMAND(ID_MONITOR, &CMTerm2View::OnMonitor)
|
|
60 |
ON_UPDATE_COMMAND_UI(ID_MONITOR, &CMTerm2View::OnUpdateMonitor)
|
|
61 |
ON_COMMAND(ID_PROG_CONVERT, &CMTerm2View::OnProgConvert)
|
|
62 |
ON_UPDATE_COMMAND_UI(ID_PROG_CONVERT, &CMTerm2View::OnUpdateProgConvert)
|
|
63 |
ON_COMMAND(ID_PROG_CANCEL_EDIT, &CMTerm2View::OnProgCancelEdit)
|
|
64 |
ON_UPDATE_COMMAND_UI(ID_PROG_CANCEL_EDIT, &CMTerm2View::OnUpdateProgCancelEdit)
|
|
65 |
ON_COMMAND(ID_INPUT_IO_COMMENT, &CMTerm2View::OnInputIoComment)
|
|
66 |
|
|
67 |
|
|
68 |
// ON_UPDATE_COMMAND_UI_RANGE(ID_INDICATOR_MACHINE_TYPE, ID_INDICATOR_INFO_DISPLAY, OnUpdateIndicators)
|
|
69 |
ON_COMMAND_RANGE(ID_INDICATOR_MACHINE_TYPE, ID_INDICATOR_INFO_DISPLAY, NULL)
|
|
70 |
// ON_UPDATE_COMMAND_UI(ID_INDICATOR_MACHINE_TYPE, &CMTerm2View::OnUpdateMachineType)
|
|
71 |
// ON_UPDATE_COMMAND_UI(ID_INDICATOR_PROGRAM_POS, &CMTerm2View::OnUpdateProgramPos)
|
|
72 |
// ON_UPDATE_COMMAND_UI(ID_INDICATOR_CONNECTIVITY, &CMTerm2View::OnUpdateConnectivity)
|
|
73 |
// ON_UPDATE_COMMAND_UI(ID_INDICATOR_RUN_STATUS, &CMTerm2View::OnUpdateRunStatus)
|
|
74 |
// ON_UPDATE_COMMAND_UI(ID_INDICATOR_MONITOR_STATUS, &CMTerm2View::OnUpdateMonitorStatus)
|
|
75 |
// ON_UPDATE_COMMAND_UI(ID_INDICATOR_TARGET_ADDRESS, &CMTerm2View::OnUpdateTargetAddress)
|
|
76 |
// ON_UPDATE_COMMAND_UI(ID_INDICATOR_INFO_DISPLAY, &CMTerm2View::OnUpdateDisplayComments)
|
|
77 |
|
|
78 |
// ON_COMMAND(ID_INDICATOR_MONITOR_STATUS, &CMTerm2View::OnIndicatorMonitorStatus)
|
|
79 |
// ON_UPDATE_COMMAND_UI(ID_INDICATOR_MONITOR_STATUS, &CMTerm2View::OnUpdateIndicatorMonitorStatus)
|
|
80 |
ON_WM_KEYDOWN()
|
|
81 |
END_MESSAGE_MAP()
|
|
82 |
|
|
83 |
|
|
84 |
// CMTerm2View 构造/析构
|
|
85 |
|
|
86 |
CMTerm2View::CMTerm2View() noexcept
|
|
87 |
{
|
|
88 |
// TODO: 在此处添加构造代码
|
|
89 |
|
|
90 |
}
|
|
91 |
|
|
92 |
CMTerm2View::~CMTerm2View()
|
|
93 |
{
|
|
94 |
}
|
|
95 |
|
|
96 |
BOOL CMTerm2View::PreCreateWindow(CREATESTRUCT& cs)
|
|
97 |
{
|
|
98 |
// TODO: 在此处通过修改
|
|
99 |
// CREATESTRUCT cs 来修改窗口类或样式
|
|
100 |
|
|
101 |
return CScrollView::PreCreateWindow(cs);
|
|
102 |
}
|
|
103 |
|
|
104 |
void CMTerm2View::OnInitialUpdate()
|
|
105 |
{
|
|
106 |
CScrollView::OnInitialUpdate();
|
|
107 |
TextFont.CreateFont(13, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN, _T("宋体"));
|
|
108 |
MonTextFont.CreateFont(12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN, _T("宋体"));
|
|
109 |
AnnoFont.CreateFont(12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_ROMAN, _T("宋体"));
|
|
110 |
m_pStatusBar = ((CChildFrame *)GetParentFrame())->GetStatusBar();
|
|
111 |
CSize sizeTotal;
|
|
112 |
// TODO: 计算此视图的合计大小
|
|
113 |
sizeTotal.cx = m_LeftMargin + m_CellWidth* m_CellPerLine + m_CellWidth *2;
|
|
114 |
sizeTotal.cy = 2000;
|
|
115 |
SetScrollSizes(MM_TEXT, sizeTotal);
|
|
116 |
CString s1;
|
|
117 |
SetTimer(1, 50,NULL);
|
|
118 |
SetTimer(2, 10, NULL);
|
|
119 |
|
|
120 |
}
|
|
121 |
|
|
122 |
// CMTerm2View 绘图
|
|
123 |
|
|
124 |
void CMTerm2View::OnDraw(CDC* pDC)
|
|
125 |
{
|
|
126 |
CMTerm2Doc* pDoc = GetDocument();
|
|
127 |
ASSERT_VALID(pDoc);
|
|
128 |
if (!pDoc)
|
|
129 |
return;
|
|
130 |
|
|
131 |
// TODO: 在此处为本机数据添加绘制代码
|
|
132 |
CString s1;
|
|
133 |
needReDraw = 1;
|
|
134 |
DrawLDSGraph(pDC);
|
|
135 |
needReDraw = 0;
|
|
136 |
}
|
|
137 |
|
|
138 |
// CMTerm2View 打印
|
|
139 |
|
|
140 |
BOOL CMTerm2View::OnPreparePrinting(CPrintInfo* pInfo)
|
|
141 |
{
|
|
142 |
// 默认准备
|
|
143 |
return DoPreparePrinting(pInfo);
|
|
144 |
}
|
|
145 |
|
|
146 |
void CMTerm2View::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
|
147 |
{
|
|
148 |
// TODO: 添加额外的打印前进行的初始化过程
|
|
149 |
}
|
|
150 |
|
|
151 |
void CMTerm2View::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
|
|
152 |
{
|
|
153 |
// TODO: 添加打印后进行的清理过程
|
|
154 |
}
|
|
155 |
|
|
156 |
|
|
157 |
// CMTerm2View 诊断
|
|
158 |
|
|
159 |
#ifdef _DEBUG
|
|
160 |
void CMTerm2View::AssertValid() const
|
|
161 |
{
|
|
162 |
CScrollView::AssertValid();
|
|
163 |
}
|
|
164 |
|
|
165 |
void CMTerm2View::Dump(CDumpContext& dc) const
|
|
166 |
{
|
|
167 |
CScrollView::Dump(dc);
|
|
168 |
}
|
|
169 |
|
|
170 |
CMTerm2Doc* CMTerm2View::GetDocument() const // 非调试版本是内联的
|
|
171 |
{
|
|
172 |
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMTerm2Doc)));
|
|
173 |
return (CMTerm2Doc*)m_pDocument;
|
|
174 |
}
|
|
175 |
#endif //_DEBUG
|
|
176 |
|
|
177 |
int CMTerm2View::OnCreate(LPCREATESTRUCT lpCreateStruct)
|
|
178 |
{
|
|
179 |
if (CScrollView::OnCreate(lpCreateStruct) == -1)
|
|
180 |
return -1;
|
|
181 |
|
|
182 |
// TODO: 在此添加您专用的创建代码
|
|
183 |
|
|
184 |
return 0;
|
|
185 |
}
|
|
186 |
|
|
187 |
int CMTerm2View::DoReDraw()
|
|
188 |
{
|
|
189 |
// TODO: 在此处添加实现代码.
|
|
190 |
CPoint scroll1;
|
|
191 |
scroll1 = this->GetScrollPosition();
|
|
192 |
|
|
193 |
CClientDC dc1(this);
|
|
194 |
XFORM xform1;
|
|
195 |
xform1.eM11 = 1;
|
|
196 |
xform1.eM12 = 0;
|
|
197 |
xform1.eM21 = 0;
|
|
198 |
xform1.eM22 = 1;
|
65f713
|
199 |
xform1.eDx = float(-scroll1.x);
|
Q |
200 |
xform1.eDy = float(-scroll1.y);
|
0ed438
|
201 |
|
Q |
202 |
XFORM xform2 = { 1, 0, 0, 1, 0, 0 };
|
|
203 |
|
|
204 |
dc1.SetGraphicsMode(GM_ADVANCED);
|
|
205 |
dc1.SetWorldTransform(&xform1);
|
|
206 |
|
|
207 |
DrawLDSGraph(&dc1);
|
|
208 |
|
|
209 |
return 0;
|
|
210 |
}
|
|
211 |
|
0a20f7
|
212 |
int CMTerm2View::ScrollToCell(int nRow, int nCol)
|
Q |
213 |
{
|
|
214 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
215 |
|
|
216 |
CSize sizeTotal;
|
|
217 |
// TODO: 计算此视图的合计大小
|
|
218 |
sizeTotal.cx = m_LeftMargin + m_CellWidth * m_CellPerLine + m_CellWidth * 2;
|
|
219 |
sizeTotal.cy = m_TopMargin + CellTotalHeight * (m_nTotalRow );
|
|
220 |
CSize sizeSb;
|
|
221 |
GetScrollBarSizes(sizeSb);
|
|
222 |
POINT pt1;
|
|
223 |
pt1.x = 0;
|
|
224 |
pt1.y = nRow * CellTotalHeight;
|
|
225 |
ScrollToPosition(pt1);
|
|
226 |
return 0;
|
|
227 |
}
|
|
228 |
|
|
229 |
int CMTerm2View::ScrollCellIntoView(int nRow, int nCol)
|
|
230 |
{
|
|
231 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
232 |
return 0;
|
|
233 |
}
|
|
234 |
|
|
235 |
int CMTerm2View::isCellInView(int nRow, int nCol)
|
|
236 |
{
|
|
237 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
238 |
return 0;
|
|
239 |
}
|
0ed438
|
240 |
|
Q |
241 |
int CMTerm2View::DrawLDSGraph(CDC* pDC)
|
|
242 |
{
|
|
243 |
// TODO: 在此处添加实现代码.
|
|
244 |
CString s1;
|
|
245 |
CMTerm2Doc* pDoc = GetDocument();
|
|
246 |
ASSERT_VALID(pDoc);
|
|
247 |
if (!pDoc) return false;
|
|
248 |
if (m_bMonitoring) {
|
|
249 |
pDoc->DoPLCMonitor();
|
|
250 |
}
|
|
251 |
int x1, y1, x2, y2;
|
|
252 |
// RECT rect1;
|
|
253 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
254 |
|
|
255 |
int nDataType, nDataAddr;
|
|
256 |
int nStat;
|
|
257 |
CBrush br0(BkColor);
|
|
258 |
CBrush br01(BkEditColor);
|
|
259 |
int nRow, nCol;
|
|
260 |
CRect rect0;
|
|
261 |
this->GetClientRect(&rect0);
|
|
262 |
int viewWidth = rect0.Width();
|
|
263 |
CPoint scroll1;
|
|
264 |
scroll1 = this->GetScrollPosition();
|
|
265 |
|
|
266 |
int nFirstVisibleLine;
|
|
267 |
int nLastVisibleLine;
|
|
268 |
|
|
269 |
nFirstVisibleLine = (scroll1.y - m_TopMargin) / CellTotalHeight;
|
|
270 |
nLastVisibleLine = (rect0.Height() + scroll1.y - m_TopMargin) / CellTotalHeight + 1;
|
|
271 |
if (nFirstVisibleLine < 0) { nFirstVisibleLine = 0; }
|
|
272 |
if (nLastVisibleLine < 0) { nLastVisibleLine = 0; }
|
|
273 |
|
|
274 |
CFont *pOldFont;
|
|
275 |
pOldFont = (CFont *)pDC->SelectObject(&TextFont);
|
|
276 |
|
|
277 |
|
|
278 |
for (int i = nFirstVisibleLine; i < nLastVisibleLine && i < 1000; i++) {
|
|
279 |
// 画一行 单元
|
|
280 |
nRow = i;
|
|
281 |
int x0, y0;
|
|
282 |
x0 = m_LeftMargin;
|
|
283 |
y0 = m_TopMargin + CellTotalHeight * i;
|
|
284 |
y2 = y0 + CellTotalHeight;
|
|
285 |
//画背景
|
|
286 |
if (needReDraw) {
|
|
287 |
// 左半部分
|
|
288 |
if (scroll1.x < x0) {
|
|
289 |
CRect rect1(scroll1.x, y0, x0, y2);
|
|
290 |
pDC->FillRect(&rect1, &br0);
|
|
291 |
}
|
|
292 |
//中间部分
|
|
293 |
x1 = max(scroll1.x, x0);
|
|
294 |
x2 = min(scroll1.x + viewWidth, x0 + m_CellPerLine * m_CellWidth);
|
|
295 |
CRect rect2(x1, y0, x2, y2);
|
|
296 |
//背景颜色
|
|
297 |
if (!Cells[nRow][0].bEditing){
|
|
298 |
pDC->FillRect(&rect2, &br0);
|
|
299 |
} else {
|
|
300 |
pDC->FillRect(&rect2, &br01);
|
|
301 |
}
|
|
302 |
// 右边部分
|
|
303 |
if (x2 < scroll1.x + viewWidth) {
|
|
304 |
CRect rect3(x2, y0, scroll1.x + viewWidth, y2);
|
|
305 |
pDC->FillRect(&rect3, &br0);
|
|
306 |
}
|
|
307 |
|
|
308 |
if (m_FocusRow == i) DrawFocusRect(pDC);
|
|
309 |
|
|
310 |
}
|
|
311 |
//*
|
|
312 |
// 画本行左侧母线
|
|
313 |
x1 = m_LeftMargin;
|
|
314 |
y1 = m_TopMargin + CellTotalHeight * i;
|
|
315 |
x2 = x1;
|
|
316 |
y2 = y1 + CellTotalHeight;
|
|
317 |
|
|
318 |
pDC->MoveTo(x1, y1);
|
|
319 |
pDC->LineTo(x2, y2);
|
|
320 |
//画左侧母线小短横线
|
|
321 |
|
|
322 |
|
|
323 |
x1 = m_LeftMargin;
|
|
324 |
y1 = m_TopMargin + CellTotalHeight * i + m_LinePosY;
|
|
325 |
x2 = x1 + 3;
|
|
326 |
y2 = y1;
|
|
327 |
pDC->MoveTo(x1, y1);
|
|
328 |
pDC->LineTo(x2, y2);
|
|
329 |
|
|
330 |
// 如果本行第一个ST是程序段的起始,输出程序步数
|
|
331 |
//*/
|
|
332 |
int nType = Cells[nRow][0].nType;
|
|
333 |
int nProgSetp = Cells[nRow][0].nProgStep;
|
|
334 |
if (nType == typeNO || nType == typeNC || nType == typeCMP) {
|
|
335 |
int nPairTo = pDoc->Progs[nProgSetp].PairTo;
|
|
336 |
int nPairOp = 0;
|
|
337 |
if (nPairTo) nPairOp = pDoc->Progs[nPairTo].nOpType1;
|
|
338 |
if (nPairOp == 0) { //程序段开始
|
|
339 |
//在当前行的左侧输出 当前 程序步数
|
|
340 |
s1.Format(_T(" %d"), nProgSetp);
|
|
341 |
CRect rect2(0, m_TopMargin + CellTotalHeight * i + m_LinePosY - 8, m_LeftMargin - 4, m_TopMargin + CellTotalHeight * i + m_LinePosY + 14);
|
|
342 |
pDC->DrawText(s1, &rect2, DT_RIGHT);
|
|
343 |
|
|
344 |
}
|
|
345 |
}
|
|
346 |
// 获取数据 并显示各单元
|
|
347 |
for (int j = 0; j < m_CellPerLine; j++) {
|
|
348 |
nCol = j;
|
|
349 |
nDataType = Cells[nRow][nCol].nDataType;
|
|
350 |
nDataAddr = Cells[nRow][nCol].nDataAddr;
|
|
351 |
if ((nDataType&TYPEDATA) == TYPEDATA) {
|
|
352 |
nStat = pDoc->GetVarData(nDataType, nDataAddr);
|
|
353 |
}
|
|
354 |
else {
|
|
355 |
nStat = pDoc->GetCoilValue(nDataType, nDataAddr);
|
|
356 |
}
|
|
357 |
Cells[nRow][nCol].nStat = nStat;
|
|
358 |
nType = Cells[nRow][nCol].nType;
|
|
359 |
if (nType == typeNO || nType == typeNC || nType == typeCMP || nType == typeTM)
|
|
360 |
{
|
|
361 |
int nProgStep = Cells[nRow][nCol].nProgStep;
|
|
362 |
int nBinProgStep = pDoc->Progs[nProgStep].nBinStep;
|
|
363 |
Cells[nRow][nCol].nTrace = pDoc->ProgTrace[nBinProgStep];
|
|
364 |
}
|
|
365 |
DrawCell(pDC, i, j);
|
|
366 |
}
|
|
367 |
|
|
368 |
|
|
369 |
// 画本行右侧母线
|
|
370 |
//*
|
|
371 |
x1 = m_LeftMargin + m_CellWidth * m_CellPerLine;
|
|
372 |
y1 = m_TopMargin + CellTotalHeight * i;
|
|
373 |
x2 = x1;
|
|
374 |
y2 = y1 + CellTotalHeight;
|
|
375 |
|
|
376 |
pDC->MoveTo(x1, y1);
|
|
377 |
pDC->LineTo(x2, y2);
|
|
378 |
// 画本行右侧母线小短横线
|
|
379 |
x1 = m_LeftMargin + m_CellWidth * m_CellPerLine;
|
|
380 |
y1 = m_TopMargin + CellTotalHeight * i + m_LinePosY;
|
|
381 |
x2 = x1 - 3;
|
|
382 |
y2 = y1;
|
|
383 |
pDC->MoveTo(x1, y1);
|
|
384 |
pDC->LineTo(x2, y2);
|
|
385 |
|
|
386 |
//*/
|
|
387 |
}
|
|
388 |
pDC->SelectObject(pOldFont);
|
|
389 |
CRect rect2(0, 30, 240, 100);
|
|
390 |
// pDC->DrawText(_T("这是测试字符串111,222,33,aa,bb,cc"), &rect2, 0);
|
|
391 |
s1.Format(_T("This is New Info.."));
|
|
392 |
needReDraw = 0;
|
|
393 |
return 0;
|
|
394 |
}
|
|
395 |
|
|
396 |
|
|
397 |
void CMTerm2View::DrawFocusRect(CDC* pDC)
|
|
398 |
{
|
|
399 |
// DrawCell(pDC, m_oldFocusRow, m_oldFocusCol);
|
|
400 |
CPen BluePen(PS_SOLID, 3, FocusColor);
|
|
401 |
CPen * pOldPen = pDC->SelectObject(&BluePen);
|
|
402 |
//CBrush * pOldBrush = ;
|
|
403 |
pDC->SelectStockObject(NULL_BRUSH);
|
|
404 |
int x0, y0;
|
|
405 |
// int x1, y1, x2, y2;
|
|
406 |
RECT rect1;
|
|
407 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
408 |
|
|
409 |
rect1.left = m_LeftMargin + 1 + m_CellWidth * m_FocusCol;
|
|
410 |
rect1.right = rect1.left + m_CellWidth - 4;
|
|
411 |
rect1.top = m_TopMargin + CellTotalHeight * m_FocusRow;
|
|
412 |
rect1.bottom = rect1.top + CellTotalHeight - 2;
|
|
413 |
|
|
414 |
x0 = rect1.left;
|
|
415 |
y0 = rect1.top;
|
|
416 |
//pDC->DrawFocusRect(&rect1);
|
|
417 |
pDC->Rectangle(&rect1);
|
|
418 |
m_oldFocusCol = m_FocusCol;
|
|
419 |
m_oldFocusRow = m_FocusRow;
|
|
420 |
|
|
421 |
pDC->SelectObject(pOldPen);
|
|
422 |
// pDC->SelectObject(poldBrush);
|
|
423 |
}
|
|
424 |
|
|
425 |
|
|
426 |
int CMTerm2View::DrawLeftRightLine(CDC* pDC, int x0, int y0, int size1, int size2)
|
|
427 |
{
|
|
428 |
// TODO: 在此处添加实现代码.
|
|
429 |
int x1, y1, x2, y2;
|
|
430 |
//画左侧横线
|
|
431 |
x1 = x0;
|
|
432 |
y1 = y0 + m_LinePosY;
|
|
433 |
x2 = x1 + size1;
|
|
434 |
y2 = y1;
|
|
435 |
pDC->MoveTo(x1, y1);
|
|
436 |
pDC->LineTo(x2, y2);
|
|
437 |
|
|
438 |
//画右侧横线
|
|
439 |
x1 = x0 + size1 +size2;
|
|
440 |
y1 = y0 + m_LinePosY;
|
|
441 |
x2 = x0 + m_CellWidth;
|
|
442 |
y2 = y1;
|
|
443 |
pDC->MoveTo(x1, y1);
|
|
444 |
pDC->LineTo(x2, y2);
|
|
445 |
return 0;
|
|
446 |
}
|
|
447 |
|
|
448 |
|
|
449 |
void CMTerm2View::DrawOT(CDC* pDC, int x0, int y0)
|
|
450 |
{
|
|
451 |
int x1, y1;
|
|
452 |
//画左右侧横线
|
|
453 |
DrawLeftRightLine(pDC, x0, y0);
|
|
454 |
|
|
455 |
x1 = x0 +16;
|
|
456 |
y1 = y0 + m_LinePosY;
|
|
457 |
|
|
458 |
pDC->MoveTo(x1 + 6 + 6, y1);
|
|
459 |
pDC->AngleArc(x1 + 6, y1, 6, 0, 360);
|
|
460 |
}
|
|
461 |
|
|
462 |
void CMTerm2View::DrawRelay(CDC* pDC, int x0, int y0)
|
|
463 |
{
|
|
464 |
int x1, y1, x2, y2;
|
|
465 |
//画左右侧横线
|
|
466 |
DrawLeftRightLine(pDC, x0, y0);
|
|
467 |
// 画左侧竖线
|
|
468 |
x1 = x0+16;
|
|
469 |
y1 = y0 + m_LinePosY - 6;
|
|
470 |
x2 = x1;
|
|
471 |
y2 = y1 + 12;
|
|
472 |
pDC->MoveTo(x1, y1);
|
|
473 |
pDC->LineTo(x2, y2);
|
|
474 |
// 画右侧竖线
|
|
475 |
x1 = x2 + 12;
|
|
476 |
y1 = y1;
|
|
477 |
x2 = x1;
|
|
478 |
y2 = y1 + 12;
|
|
479 |
pDC->MoveTo(x1, y1);
|
|
480 |
pDC->LineTo(x2, y2);
|
|
481 |
}
|
|
482 |
|
|
483 |
int CMTerm2View::DrawBracket(CDC* pDC, int x0, int y0, int sizex, int sty, int sizey)
|
|
484 |
{
|
|
485 |
// TODO: 在此处添加实现代码.
|
|
486 |
int x1, y1, x2, y2;
|
|
487 |
// 左边的短横线
|
|
488 |
x1 = x0 ;
|
|
489 |
y1 = y0 + m_LinePosY;
|
|
490 |
x2 = x0 + 3;
|
|
491 |
y2 = y1;
|
|
492 |
pDC->MoveTo(x1, y1);
|
|
493 |
pDC->LineTo(x2, y2);
|
|
494 |
|
|
495 |
// 左方括号
|
|
496 |
x1 = x0 + 9;
|
|
497 |
y1 = y0 + sty;
|
|
498 |
x2 = x0 + 3;
|
|
499 |
y2 = y1;
|
|
500 |
pDC->MoveTo(x1, y1);
|
|
501 |
pDC->LineTo(x2, y2);
|
|
502 |
x2 = x2;
|
|
503 |
y2 = y2 + sizey;
|
|
504 |
pDC->LineTo(x2, y2);
|
|
505 |
x2 = x2 + 6;
|
|
506 |
y2 = y2;
|
|
507 |
pDC->LineTo(x2, y2);
|
|
508 |
// 右方括号
|
|
509 |
x1 = x0 + sizex - 6 - 6;
|
|
510 |
y1 = y0 + sty;
|
|
511 |
x2 = x0 + sizex -6 ;
|
|
512 |
y2 = y1;
|
|
513 |
pDC->MoveTo(x1, y1);
|
|
514 |
pDC->LineTo(x2, y2);
|
|
515 |
x2 = x2;
|
|
516 |
y2 = y2 + sizey;
|
|
517 |
pDC->LineTo(x2, y2);
|
|
518 |
x2 = x2 - 6;
|
|
519 |
y2 = y2;
|
|
520 |
pDC->LineTo(x2, y2);
|
|
521 |
// 右边的短横线
|
|
522 |
x1 = x0 + sizex - 6;
|
|
523 |
y1 = y0 + m_LinePosY;
|
|
524 |
x2 = x0 + sizex ;
|
|
525 |
y2 = y1;
|
|
526 |
pDC->MoveTo(x1, y1);
|
|
527 |
pDC->LineTo(x2, y2);
|
|
528 |
return 0;
|
|
529 |
}
|
|
530 |
int CMTerm2View::DrawAngleBracket(CDC* pDC, int x0, int y0, int size1, int size2)
|
|
531 |
{
|
|
532 |
// TODO: 在此处添加实现代码.
|
|
533 |
int x1,y1,x2, y2;
|
|
534 |
DrawLeftRightLine(pDC, x0, y0, size1, size2);
|
|
535 |
// 左尖括号
|
|
536 |
x1 = x0 + size1 + 6;
|
|
537 |
y1 = y0 + m_LinePosY -6;
|
|
538 |
x2 = x1 -6;
|
|
539 |
y2 = y1 +6 ;
|
|
540 |
pDC->MoveTo(x1, y1);
|
|
541 |
pDC->LineTo(x2, y2);
|
|
542 |
x2 = x2 +6;
|
|
543 |
y2 = y2 + 6;
|
|
544 |
pDC->LineTo(x2, y2);
|
|
545 |
// 右尖括号
|
|
546 |
x1 = x0 + size1 + size2 - 6;
|
|
547 |
y1 = y0 + m_LinePosY - 6;
|
|
548 |
x2 = x1 + 6;
|
|
549 |
y2 = y1 + 6 ;
|
|
550 |
pDC->MoveTo(x1, y1);
|
|
551 |
pDC->LineTo(x2, y2);
|
|
552 |
x2 = x2 -6 ;
|
|
553 |
y2 = y2 + 6;
|
|
554 |
pDC->LineTo(x2, y2);
|
|
555 |
return 0;
|
|
556 |
}
|
|
557 |
|
|
558 |
int CMTerm2View::DrawCellStat1(CDC * pDC, int x1, int y1, int sizex, int sizey, int nStat)
|
|
559 |
{
|
|
560 |
// TODO: 在此处添加实现代码.
|
|
561 |
CRect rect1;
|
|
562 |
rect1.left = x1;
|
|
563 |
rect1.top = y1;
|
|
564 |
rect1.right = x1+sizex;
|
|
565 |
rect1.bottom = y1+sizey;
|
|
566 |
|
|
567 |
CBrush br0(BkColor);
|
|
568 |
CBrush br1(MonCoilColor);
|
|
569 |
if (m_bMonitoring) {
|
|
570 |
if (nStat) {
|
|
571 |
pDC->FillRect(&rect1, &br1);
|
|
572 |
}else{
|
|
573 |
pDC->FillRect(&rect1, &br0);
|
|
574 |
}
|
|
575 |
}
|
|
576 |
return 0;
|
|
577 |
}
|
|
578 |
|
|
579 |
int CMTerm2View::DrawCellStat2(CDC* pDC, int x1, int y1, int sizex, int sizey, int nStat)
|
|
580 |
{
|
|
581 |
// TODO: 在此处添加实现代码.
|
|
582 |
CRect rect1;
|
|
583 |
rect1.left = x1;
|
|
584 |
rect1.top = y1;
|
|
585 |
rect1.right = x1+sizex;
|
|
586 |
rect1.bottom = y1+sizey;
|
|
587 |
CBrush br2(TraceBkColor);
|
|
588 |
CBrush br3(TraceColor);
|
|
589 |
if (m_bMonitoring) {
|
|
590 |
if (nStat) {
|
|
591 |
pDC->FillRect(&rect1, &br3);
|
|
592 |
}else{
|
|
593 |
pDC->FillRect(&rect1, &br2);
|
|
594 |
}
|
|
595 |
}
|
|
596 |
return 0;
|
|
597 |
}
|
|
598 |
|
|
599 |
int CMTerm2View::DrawCellText1(CDC* pDC, CString sText, int x1, int y1, int sizex, int sizey, int nFormat)
|
|
600 |
{
|
|
601 |
// TODO: 在此处添加实现代码.
|
|
602 |
CRect rect1;
|
|
603 |
rect1.left = x1;
|
|
604 |
rect1.top = y1;
|
|
605 |
rect1.right = rect1.left + sizex;
|
|
606 |
rect1.bottom = rect1.top + sizey;
|
|
607 |
pDC->DrawText(sText, &rect1, nFormat);
|
|
608 |
return 0;
|
|
609 |
}
|
|
610 |
|
|
611 |
int CMTerm2View::DrawCellText2(CDC* pDC, CString sText, int x1, int y1, int sizex, int sizey, int nFormat, int nTextColor)
|
|
612 |
{
|
|
613 |
// TODO: 在此处添加实现代码.
|
|
614 |
COLORREF clrOld = pDC->SetTextColor(nTextColor);
|
|
615 |
CRect rect1;
|
|
616 |
rect1.left = x1;
|
|
617 |
rect1.top = y1;
|
|
618 |
rect1.right = rect1.left + sizex;
|
|
619 |
rect1.bottom = rect1.top + sizey;
|
|
620 |
pDC->DrawText(sText, &rect1, nFormat);
|
|
621 |
pDC->SetTextColor(clrOld);
|
|
622 |
return 0;
|
|
623 |
}
|
|
624 |
|
|
625 |
int CMTerm2View::DrawCellAnno(CDC * pDC, int nRow, int nCol, CString sAnno)
|
|
626 |
{
|
|
627 |
// TODO: 在此处添加实现代码.
|
|
628 |
if (!m_bShowComments) return 0;
|
|
629 |
if (!needReDraw) return 0;
|
|
630 |
CMTerm2Doc * pDoc = GetDocument();
|
|
631 |
int x0, y0;
|
|
632 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
633 |
x0 = m_LeftMargin + 1 + m_CellWidth * nCol;
|
|
634 |
y0 = m_TopMargin + CellTotalHeight * nRow;
|
|
635 |
|
|
636 |
int nType, nAddr;
|
|
637 |
nType = Cells[nRow][nCol].nDataType;
|
|
638 |
nAddr = Cells[nRow][nCol].nDataAddr;
|
|
639 |
CString s1;
|
|
640 |
if (pDoc->GetAnno(nType, nAddr, s1)) {
|
|
641 |
CFont *pOldFont;
|
|
642 |
pOldFont = (CFont *)pDC->SelectObject(&AnnoFont);
|
|
643 |
DrawCellText2(pDC, s1, x0 + 2, y0 + m_LinePosY + 6, m_CellWidth-10, 32, DT_WORDBREAK, AnnoColor);
|
|
644 |
pDC->SelectObject(pOldFont);
|
|
645 |
}
|
|
646 |
return 0;
|
|
647 |
}
|
|
648 |
|
|
649 |
void CMTerm2View::DrawCell(CDC* pDC, int nRow, int nCol)
|
|
650 |
{
|
|
651 |
|
|
652 |
//CMTerm2Doc * pDoc= GetDocument();
|
|
653 |
int x0, y0;
|
|
654 |
int x1, y1, x2, y2;
|
|
655 |
RECT rect1;
|
|
656 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
657 |
|
|
658 |
rect1.left = m_LeftMargin + 1 + m_CellWidth * nCol;
|
|
659 |
rect1.right = rect1.left + m_CellWidth;
|
|
660 |
rect1.top = m_TopMargin + CellTotalHeight * nRow;
|
|
661 |
rect1.bottom = rect1.top + CellTotalHeight;
|
|
662 |
|
|
663 |
x0 = rect1.left;
|
|
664 |
y0 = rect1.top;
|
|
665 |
|
|
666 |
CString s1;
|
|
667 |
// pDC->DrawFocusRect(&rect1);
|
|
668 |
if (Cells[nRow][nCol].bLeftLineUp && nCol !=0)
|
|
669 |
{
|
|
670 |
if (needReDraw) {
|
|
671 |
pDC->MoveTo(x0, y0);
|
|
672 |
pDC->LineTo(x0, y0 + m_LinePosY);
|
|
673 |
}
|
|
674 |
}
|
|
675 |
if (Cells[nRow][nCol].bLeftLineDn && nCol != 0)
|
|
676 |
{
|
|
677 |
if (needReDraw) {
|
|
678 |
pDC->MoveTo(x0, y0 + m_LinePosY);
|
|
679 |
pDC->LineTo(x0, y0 + CellTotalHeight);
|
|
680 |
}
|
|
681 |
}
|
|
682 |
int nType = Cells[nRow][nCol].nType;
|
|
683 |
if (nType == typeNone)
|
|
684 |
{
|
|
685 |
|
|
686 |
}
|
|
687 |
else if (nType == typeLine1)
|
|
688 |
{ //Draw Line
|
|
689 |
//画直横线
|
|
690 |
if (needReDraw) {
|
|
691 |
pDC->MoveTo(x0, y0 + m_LinePosY);
|
|
692 |
pDC->LineTo(x0 + m_CellWidth, y0 + m_LinePosY);
|
|
693 |
}
|
|
694 |
}
|
|
695 |
else if (nType == typeLine2)
|
|
696 |
{ //Draw Line
|
|
697 |
//画直横线
|
|
698 |
// pDC->MoveTo(x0, y0);
|
|
699 |
// pDC->LineTo(x0, y0 + CellTotalHeight);
|
|
700 |
}
|
|
701 |
else if (nType == typeNO)
|
|
702 |
{
|
|
703 |
// Draw Coil
|
|
704 |
if (needReDraw) {
|
|
705 |
DrawRelay(pDC, x0, y0);
|
|
706 |
//显示文字
|
|
707 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 2, y0, m_CellWidth, 14);
|
|
708 |
DrawCellAnno(pDC, nRow, nCol, _T(""));
|
|
709 |
}
|
|
710 |
if (m_bMonitoring){
|
|
711 |
//Draw Stat
|
|
712 |
DrawCellStat1(pDC, x0 + 16 + 2, y0 + m_LinePosY - 6, 8, 12, Cells[nRow][nCol].nStat);
|
|
713 |
// tracing
|
|
714 |
DrawCellStat2(pDC, x0 + 16 + 2 + 10 + 4, y0 + m_LinePosY - 4, 4, 4, Cells[nRow][nCol].nTrace);
|
|
715 |
}
|
|
716 |
}
|
|
717 |
else if (nType == typeNC)
|
|
718 |
{
|
|
719 |
if (needReDraw) {
|
|
720 |
DrawRelay(pDC, x0, y0);
|
|
721 |
//显示文字
|
|
722 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 2, y0, m_CellWidth, 14);
|
|
723 |
DrawCellAnno(pDC, nRow, nCol, _T(""));
|
|
724 |
//画常闭斜线
|
|
725 |
x1 = x0 + 16 + 12 - 3;
|
|
726 |
y1 = y0 + m_LinePosY - 6;
|
|
727 |
x2 = x0 + 16 + 2;
|
|
728 |
y2 = y1 + 12;
|
|
729 |
pDC->MoveTo(x1, y1);
|
|
730 |
pDC->LineTo(x2, y2);
|
|
731 |
}
|
|
732 |
if (m_bMonitoring)
|
|
733 |
{
|
|
734 |
//Draw Stat
|
|
735 |
DrawCellStat1(pDC, x0 + 16 + 2, y0 + m_LinePosY - 6, 8, 12, ! Cells[nRow][nCol].nStat);
|
|
736 |
// tracing
|
|
737 |
DrawCellStat2(pDC, x0 + 16 + 2 + 10 + 4, y0 + m_LinePosY - 4, 4, 4, Cells[nRow][nCol].nTrace);
|
|
738 |
//画常闭斜线
|
|
739 |
x1 = x0 + 16 + 12 - 3;
|
|
740 |
y1 = y0 + m_LinePosY - 6;
|
|
741 |
x2 = x0 + 16 + 2;
|
|
742 |
y2 = y1 + 12;
|
|
743 |
pDC->MoveTo(x1, y1);
|
|
744 |
pDC->LineTo(x2, y2);
|
|
745 |
}
|
|
746 |
}
|
|
747 |
else if (nType == typePP)
|
|
748 |
{
|
|
749 |
if (needReDraw) {
|
|
750 |
DrawRelay(pDC, x0, y0);
|
|
751 |
//画上升沿箭头
|
|
752 |
x1 = x0 + 16 + 6;
|
|
753 |
y1 = y0 + m_LinePosY - 5;
|
|
754 |
x2 = x1;
|
|
755 |
y2 = y1 + 10;
|
|
756 |
pDC->MoveTo(x1, y1);
|
|
757 |
pDC->LineTo(x2, y2);
|
|
758 |
//*
|
|
759 |
x2 = x1 - 3;
|
|
760 |
y2 = y1 + 4;
|
|
761 |
pDC->MoveTo(x1, y1);
|
|
762 |
pDC->LineTo(x2, y2);
|
|
763 |
x2 = x1 + 3;
|
|
764 |
y2 = y1 + 4;
|
|
765 |
pDC->MoveTo(x1, y1);
|
|
766 |
pDC->LineTo(x2, y2);
|
|
767 |
//*/
|
|
768 |
//显示文字
|
|
769 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 2, y0, m_CellWidth, 14);
|
|
770 |
DrawCellAnno(pDC, nRow, nCol, _T(""));
|
|
771 |
}
|
|
772 |
}
|
|
773 |
else if (nType == typePN)
|
|
774 |
{
|
|
775 |
if (needReDraw) {
|
|
776 |
DrawRelay(pDC, x0, y0);
|
|
777 |
//画下降沿箭头
|
|
778 |
x1 = x0 + 16 + 6;
|
|
779 |
y1 = y0 + m_LinePosY + 5;
|
|
780 |
x2 = x1;
|
|
781 |
y2 = y1 - 10;
|
|
782 |
pDC->MoveTo(x1, y1);
|
|
783 |
pDC->LineTo(x2, y2);
|
|
784 |
//*
|
|
785 |
x2 = x1 - 3;
|
|
786 |
y2 = y1 - 3;
|
|
787 |
pDC->MoveTo(x1, y1);
|
|
788 |
pDC->LineTo(x2, y2);
|
|
789 |
|
|
790 |
x2 = x1 + 3;
|
|
791 |
y2 = y1 - 3;
|
|
792 |
pDC->MoveTo(x1, y1);
|
|
793 |
pDC->LineTo(x2, y2);
|
|
794 |
//*/
|
|
795 |
//显示文字
|
|
796 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 2, y0, m_CellWidth, 14);
|
|
797 |
DrawCellAnno(pDC, nRow, nCol, _T(""));
|
|
798 |
}
|
|
799 |
}
|
|
800 |
else if (nType == typeNOT) {
|
|
801 |
if (needReDraw) {
|
|
802 |
DrawLeftRightLine(pDC, x0, y0);
|
|
803 |
//画常闭斜线
|
|
804 |
x1 = x0 + 16 + 12 - 3;
|
|
805 |
y1 = y0 + m_LinePosY - 6;
|
|
806 |
x2 = x0 + 16 + 2;
|
|
807 |
y2 = y1 + 12;
|
|
808 |
pDC->MoveTo(x1, y1);
|
|
809 |
pDC->LineTo(x2, y2);
|
|
810 |
//显示文字
|
|
811 |
// DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 2, y0, m_CellWidth, 14);
|
|
812 |
}
|
|
813 |
}
|
|
814 |
else if (nType == typeDF) {
|
|
815 |
if (needReDraw) {
|
|
816 |
// DrawLeftRightLine(pDC, x0, y0);
|
|
817 |
DrawAngleBracket(pDC, x0, y0, 8, 32);
|
|
818 |
//显示文字
|
|
819 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 16, y0 + m_LinePosY - 8, 16, 14);
|
|
820 |
}
|
|
821 |
}
|
|
822 |
else if (nType == typeDF_) {
|
|
823 |
if (needReDraw) {
|
|
824 |
// DrawLeftRightLine(pDC, x0, y0);
|
|
825 |
DrawAngleBracket(pDC, x0, y0, 8, 40);
|
|
826 |
//显示文字
|
|
827 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 16, y0 + m_LinePosY - 8, 24, 14);
|
|
828 |
}
|
|
829 |
}
|
|
830 |
else if (nType == typeOUT) {
|
|
831 |
if (needReDraw) {
|
|
832 |
//显示外形
|
|
833 |
DrawOT(pDC, x0, y0);
|
|
834 |
//显示文字
|
|
835 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 2, y0, m_CellWidth, 14);
|
|
836 |
DrawCellAnno(pDC, nRow, nCol, _T(""));
|
|
837 |
}
|
|
838 |
if (m_bMonitoring) {
|
|
839 |
//Draw Stat
|
|
840 |
DrawCellStat1(pDC, x0 + 16 + 2, y0 + m_LinePosY - 6, 8, 12, Cells[nRow][nCol].nStat);
|
|
841 |
}
|
|
842 |
}
|
|
843 |
else if (nType == typeSET) {
|
|
844 |
|
|
845 |
if (needReDraw) {
|
|
846 |
//画左侧横线
|
|
847 |
//DrawLeftRightLine(pDC, x0, y0, 14, 18);
|
|
848 |
DrawAngleBracket(pDC, x0, y0, 8, 32);
|
|
849 |
DrawCellText1(pDC, _T("S"), x0 + 18, y0 + m_LinePosY - 8, 8, 14);
|
|
850 |
//显示文字
|
|
851 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 2, y0, m_CellWidth, 14);
|
|
852 |
DrawCellAnno(pDC, nRow, nCol, _T(""));
|
|
853 |
}
|
|
854 |
if (m_bMonitoring) {
|
|
855 |
//Draw Stat
|
|
856 |
DrawCellStat1(pDC, x0 + 14, y0 + m_LinePosY - 8, 16, 16, Cells[nRow][nCol].nStat);
|
|
857 |
DrawCellText1(pDC, _T("S"), x0 + 18, y0 + m_LinePosY - 8, 8, 14);
|
|
858 |
}
|
|
859 |
|
|
860 |
}
|
|
861 |
else if (nType == typeRESET) {
|
|
862 |
if (needReDraw) {
|
|
863 |
//画左右侧横线
|
|
864 |
//DrawLeftRightLine(pDC, x0, y0, 14, 18);
|
|
865 |
DrawAngleBracket(pDC, x0, y0, 8, 32);
|
|
866 |
DrawCellText1(pDC, _T("R"), x0 + 17, y0 + m_LinePosY - 8, 9, 14);
|
|
867 |
//显示文字
|
|
868 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 2, y0, m_CellWidth, 14);
|
|
869 |
DrawCellAnno(pDC, nRow, nCol, _T(""));
|
|
870 |
}
|
|
871 |
if (m_bMonitoring) {
|
|
872 |
//Draw Stat
|
|
873 |
DrawCellStat1(pDC, x0 + 14, y0 + m_LinePosY - 8, 16, 16, Cells[nRow][nCol].nStat);
|
|
874 |
DrawCellText1(pDC, _T("R"), x0 + 17, y0 + m_LinePosY - 8, 9, 14);
|
|
875 |
}
|
|
876 |
}
|
|
877 |
else if (nType == typeCMP) {
|
|
878 |
if (needReDraw) {
|
|
879 |
// 画中括号
|
|
880 |
DrawBracket(pDC, x0, y0, m_CellWidth * 3);
|
|
881 |
//显示文字
|
|
882 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 12, y0, m_CellWidth, 14);
|
|
883 |
DrawCellText1(pDC, Cells[nRow][nCol + 1].sParam, x0 + m_CellWidth + 2, y0, m_CellWidth, 14);
|
|
884 |
DrawCellText1(pDC, Cells[nRow][nCol + 2].sParam, x0 + m_CellWidth * 2 + 2, y0, m_CellWidth, 14);
|
|
885 |
DrawCellAnno(pDC, nRow, nCol + 1, _T(""));
|
|
886 |
DrawCellAnno(pDC, nRow, nCol + 2, _T(""));
|
|
887 |
}
|
|
888 |
if (m_bMonitoring) {
|
|
889 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 1].nStat);
|
|
890 |
DrawCellText2(pDC, s1,x0+m_CellWidth+2,y0+m_LinePosY-6,m_CellWidth-10,14,DT_RIGHT, MonTextColor);
|
|
891 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 2].nStat);
|
|
892 |
DrawCellText2(pDC, s1, x0 + m_CellWidth*2 + 2, y0 + m_LinePosY - 6, m_CellWidth - 10, 14, DT_RIGHT, MonTextColor);
|
|
893 |
// tracing
|
|
894 |
DrawCellStat2(pDC, x0 + m_CellWidth * 3 - 4, y0 + m_LinePosY - 8, 4, 4, Cells[nRow][nCol].nTrace);
|
|
895 |
}
|
|
896 |
}
|
|
897 |
else if (nType == typeTM) {
|
|
898 |
if (needReDraw) {
|
|
899 |
// 画中括号
|
|
900 |
DrawBracket(pDC, x0, y0, m_CellWidth * 3);
|
|
901 |
//显示文字
|
|
902 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 12, y0, m_CellWidth, 14);
|
|
903 |
DrawCellText1(pDC, Cells[nRow][nCol + 1].sParam, x0 + m_CellWidth + 2, y0, m_CellWidth, 14);
|
|
904 |
DrawCellText1(pDC, Cells[nRow][nCol + 2].sParam, x0 + m_CellWidth * 2 + 2, y0, m_CellWidth, 14);
|
|
905 |
DrawCellAnno(pDC, nRow, nCol, _T(""));
|
|
906 |
DrawCellAnno(pDC, nRow, nCol + 1, _T(""));
|
|
907 |
DrawCellAnno(pDC, nRow, nCol + 2, _T(""));
|
|
908 |
}
|
|
909 |
if (m_bMonitoring) {
|
|
910 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 1].nStat);
|
|
911 |
DrawCellText2(pDC, s1, x0 + m_CellWidth + 2, y0 + m_LinePosY - 6, m_CellWidth - 10, 14, DT_RIGHT, MonTextColor);
|
|
912 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 2].nStat);
|
|
913 |
DrawCellText2(pDC, s1, x0 + m_CellWidth * 2 + 2, y0 + m_LinePosY - 6, m_CellWidth - 10, 14, DT_RIGHT, MonTextColor);
|
|
914 |
// tracing
|
|
915 |
DrawCellStat2(pDC, x0 + m_CellWidth * 3 - 4, y0 + m_LinePosY - 8, 4, 4, Cells[nRow][nCol].nTrace);
|
|
916 |
}
|
|
917 |
}
|
|
918 |
else if (nType == typeFN1) {
|
|
919 |
if (needReDraw) {
|
|
920 |
|
|
921 |
// 画中括号
|
|
922 |
DrawBracket(pDC, x0, y0, m_CellWidth * 2, m_LinePosY - 8, 16);
|
|
923 |
//显示文字
|
|
924 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 12, y0 + m_LinePosY - 6, m_CellWidth, 14);
|
|
925 |
DrawCellText1(pDC, Cells[nRow][nCol + 1].sParam, x0 + m_CellWidth + 2, y0 + m_LinePosY - 6, m_CellWidth, 14);
|
|
926 |
DrawCellAnno(pDC, nRow, nCol + 1, _T(""));
|
|
927 |
}
|
|
928 |
if (m_bMonitoring) {
|
|
929 |
|
|
930 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 1].nStat);
|
|
931 |
DrawCellText2(pDC, s1, x0 + m_CellWidth + 2, y0 , m_CellWidth - 10, 14, DT_RIGHT, MonTextColor);
|
|
932 |
// tracing
|
|
933 |
DrawCellStat2(pDC, x0 + m_CellWidth * 2 - 4, y0 + m_LinePosY - 8, 4, 4, Cells[nRow][nCol].nTrace);
|
|
934 |
}
|
|
935 |
}
|
|
936 |
else if (nType == typeFN2) {
|
|
937 |
if (needReDraw) {
|
|
938 |
// 画中括号
|
|
939 |
DrawBracket(pDC, x0, y0, m_CellWidth * 3, m_LinePosY - 8, 16);
|
|
940 |
//显示文字
|
|
941 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 12, y0 + m_LinePosY - 6, m_CellWidth, 14);
|
|
942 |
DrawCellText1(pDC, Cells[nRow][nCol + 1].sParam, x0 + m_CellWidth + 2, y0 + m_LinePosY - 6, m_CellWidth, 14);
|
|
943 |
DrawCellText1(pDC, Cells[nRow][nCol + 2].sParam, x0 + m_CellWidth * 2 + 2, y0 + m_LinePosY - 6, m_CellWidth, 14);
|
|
944 |
DrawCellAnno(pDC, nRow, nCol + 1, _T(""));
|
|
945 |
DrawCellAnno(pDC, nRow, nCol + 2, _T(""));
|
|
946 |
}
|
|
947 |
if (m_bMonitoring) {
|
|
948 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 1].nStat);
|
|
949 |
DrawCellText2(pDC, s1, x0 + m_CellWidth + 2, y0, m_CellWidth - 10, 14, DT_RIGHT, MonTextColor);
|
|
950 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 2].nStat);
|
|
951 |
DrawCellText2(pDC, s1, x0 + m_CellWidth * 2 + 2, y0, m_CellWidth - 10, 14, DT_RIGHT, MonTextColor);
|
|
952 |
// tracing
|
|
953 |
DrawCellStat2(pDC, x0 + m_CellWidth * 3 - 4, y0 + m_LinePosY - 8, 4, 4, Cells[nRow][nCol].nTrace);
|
|
954 |
}
|
|
955 |
}
|
|
956 |
else if (nType == typeFN3) {
|
|
957 |
if (needReDraw) {
|
|
958 |
// 画中括号
|
|
959 |
DrawBracket(pDC, x0, y0, m_CellWidth * 4, m_LinePosY - 8, 16);
|
|
960 |
//显示文字
|
|
961 |
DrawCellText1(pDC, Cells[nRow][nCol].sCoilName, x0 + 12, y0 + m_LinePosY - 6, m_CellWidth, 14);
|
|
962 |
DrawCellText1(pDC, Cells[nRow][nCol + 1].sParam, x0 + m_CellWidth + 2, y0 + m_LinePosY - 6, m_CellWidth, 14);
|
|
963 |
DrawCellText1(pDC, Cells[nRow][nCol + 2].sParam, x0 + m_CellWidth * 2 + 2, y0 + m_LinePosY - 6, m_CellWidth, 14);
|
|
964 |
DrawCellText1(pDC, Cells[nRow][nCol + 3].sParam, x0 + m_CellWidth * 3 + 2, y0 + m_LinePosY - 6, m_CellWidth, 14);
|
|
965 |
DrawCellAnno(pDC, nRow, nCol + 1, _T(""));
|
|
966 |
DrawCellAnno(pDC, nRow, nCol + 2, _T(""));
|
|
967 |
DrawCellAnno(pDC, nRow, nCol + 3, _T(""));
|
|
968 |
}
|
|
969 |
if (m_bMonitoring) {
|
|
970 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 1].nStat);
|
|
971 |
DrawCellText2(pDC, s1, x0 + m_CellWidth + 2, y0, m_CellWidth - 10, 14, DT_RIGHT, MonTextColor);
|
|
972 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 2].nStat);
|
|
973 |
DrawCellText2(pDC, s1, x0 + m_CellWidth * 2 + 2, y0, m_CellWidth - 10, 14, DT_RIGHT, MonTextColor);
|
|
974 |
s1.Format(_T(" %d"), Cells[nRow][nCol + 3].nStat);
|
|
975 |
DrawCellText2(pDC, s1, x0 + m_CellWidth * 3 + 2, y0, m_CellWidth - 10, 14, DT_RIGHT, MonTextColor);
|
|
976 |
// tracing
|
|
977 |
DrawCellStat2(pDC, x0 + m_CellWidth * 4 - 4, y0 + m_LinePosY - 8, 4, 4, Cells[nRow][nCol].nTrace);
|
|
978 |
}
|
|
979 |
}
|
|
980 |
else
|
|
981 |
{
|
|
982 |
}
|
|
983 |
}
|
|
984 |
|
|
985 |
// CMTerm2View 消息处理程序
|
|
986 |
|
|
987 |
void CMTerm2View::OnUpdate(CView* /*pSender*/, LPARAM lHint, CObject* /*pHint*/)
|
|
988 |
{
|
|
989 |
// TODO: 在此添加专用代码和/或调用基类
|
|
990 |
//初始化 cell 内容
|
|
991 |
if (lHint == 0 || lHint == 1)
|
|
992 |
{
|
|
993 |
TransProgToLDS();
|
|
994 |
CRect rect0;
|
|
995 |
this->GetClientRect(&rect0);
|
|
996 |
|
|
997 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
998 |
|
|
999 |
CSize sizeTotal;
|
|
1000 |
// TODO: 计算此视图的合计大小
|
|
1001 |
sizeTotal.cx = m_LeftMargin + m_CellWidth * m_CellPerLine + m_CellWidth * 2;
|
|
1002 |
sizeTotal.cy = m_TopMargin + CellTotalHeight * (m_nTotalRow - 1) + rect0.Height();
|
|
1003 |
SetScrollSizes(MM_TEXT, sizeTotal);
|
|
1004 |
needReDraw = 1;
|
|
1005 |
this->RedrawWindow();
|
|
1006 |
}
|
|
1007 |
else if (lHint == 2) {
|
|
1008 |
UpdateStatusBar();
|
|
1009 |
}
|
|
1010 |
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
BOOL CMTerm2View::OnEraseBkgnd(CDC* pDC)
|
|
1014 |
{
|
|
1015 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
1016 |
return true;
|
|
1017 |
return CScrollView::OnEraseBkgnd(pDC);
|
|
1018 |
}
|
|
1019 |
|
|
1020 |
void CMTerm2View::OnSize(UINT nType, int cx, int cy)
|
|
1021 |
{
|
|
1022 |
CScrollView::OnSize(nType, cx, cy);
|
|
1023 |
// CString s1;
|
|
1024 |
// s1.Format(_T("OnSize %d %d %d"), nType, cx, cy);
|
|
1025 |
// DbgLog(s1);
|
|
1026 |
|
|
1027 |
if (this->IsWindowVisible())
|
|
1028 |
{
|
|
1029 |
CRect rect0;
|
|
1030 |
this->GetClientRect(&rect0);
|
|
1031 |
|
|
1032 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
1033 |
|
|
1034 |
CSize sizeTotal;
|
|
1035 |
// TODO: 计算此视图的合计大小
|
|
1036 |
sizeTotal.cx = m_LeftMargin + m_CellWidth * m_CellPerLine + m_CellWidth * 2;
|
|
1037 |
sizeTotal.cy = m_TopMargin + CellTotalHeight * (m_nTotalRow - 1) + rect0.Height();
|
|
1038 |
SetScrollSizes(MM_TEXT, sizeTotal);
|
|
1039 |
needReDraw = 1;
|
|
1040 |
this->RedrawWindow();
|
|
1041 |
}
|
|
1042 |
|
|
1043 |
needReDraw = 1;
|
|
1044 |
// TODO: 在此处添加消息处理程序代码
|
|
1045 |
}
|
|
1046 |
|
|
1047 |
BOOL CMTerm2View::OnScrollBy(CSize sizeScroll, BOOL bDoScroll)
|
|
1048 |
{
|
|
1049 |
// TODO: 在此添加专用代码和/或调用基类
|
|
1050 |
needReDraw = 1;
|
|
1051 |
return CScrollView::OnScrollBy(sizeScroll, bDoScroll);
|
|
1052 |
}
|
|
1053 |
|
|
1054 |
void CMTerm2View::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
|
|
1055 |
{
|
|
1056 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
1057 |
CString s1;
|
|
1058 |
// s1.Format(_T("KeyDown %d %d %d"), nChar, nRepCnt, nFlags);
|
|
1059 |
// DbgLog(s1);
|
|
1060 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
1061 |
|
|
1062 |
CRect rect0;
|
|
1063 |
this->GetClientRect(&rect0);
|
|
1064 |
int viewWidth = rect0.Width();
|
|
1065 |
CPoint scroll1;
|
|
1066 |
scroll1 = this->GetScrollPosition();
|
|
1067 |
|
|
1068 |
int nFirstVisibleLine;
|
|
1069 |
int nLastVisibleLine;
|
|
1070 |
int nLinesinView;
|
|
1071 |
nFirstVisibleLine = (scroll1.y - m_TopMargin) / CellTotalHeight;
|
|
1072 |
nLastVisibleLine = (rect0.Height() + scroll1.y - m_TopMargin) / CellTotalHeight + 1;
|
|
1073 |
if (nFirstVisibleLine < 0) { nFirstVisibleLine = 0; }
|
|
1074 |
if (nLastVisibleLine < 0) { nLastVisibleLine = 0; }
|
|
1075 |
nLinesinView = nLastVisibleLine - 1 - nFirstVisibleLine;
|
|
1076 |
int nRow, nCol;
|
|
1077 |
nRow = m_FocusRow;
|
|
1078 |
nCol = m_FocusCol;
|
|
1079 |
if (nChar == VK_LEFT) {
|
|
1080 |
nCol -= 1;
|
|
1081 |
if (nCol < 0) {
|
|
1082 |
if (nRow > 0) {
|
|
1083 |
nRow -= 1; nCol += m_CellPerLine;
|
|
1084 |
}else {
|
|
1085 |
nCol = 0;
|
|
1086 |
}
|
|
1087 |
}
|
|
1088 |
}
|
|
1089 |
if (nChar == VK_RIGHT) {
|
|
1090 |
nCol += 1;
|
|
1091 |
if (nCol >= m_CellPerLine) {
|
|
1092 |
if (nRow < m_nTotalRow + nLinesinView - 1 ) {
|
|
1093 |
nCol -= m_CellPerLine;
|
|
1094 |
nRow += 1;
|
|
1095 |
}
|
|
1096 |
else {
|
|
1097 |
nCol = m_CellPerLine - 1;
|
|
1098 |
}
|
|
1099 |
}
|
|
1100 |
}
|
|
1101 |
if (nChar == VK_UP) {
|
|
1102 |
nRow -= 1;
|
|
1103 |
if (nRow < 0) { nRow = 0; }
|
|
1104 |
}
|
|
1105 |
if (nChar == VK_DOWN) {
|
|
1106 |
nRow += 1;
|
|
1107 |
if (nRow >= m_nTotalRow + nLinesinView) { nRow = m_nTotalRow + nLinesinView -1; }
|
|
1108 |
|
|
1109 |
}
|
|
1110 |
m_FocusRow = nRow;
|
|
1111 |
m_FocusCol = nCol;
|
|
1112 |
if (Cells[nRow][nCol].nType) {
|
|
1113 |
m_nCurProgStep = Cells[nRow][nCol].nProgStep;
|
|
1114 |
}
|
|
1115 |
|
|
1116 |
if (nRow < nFirstVisibleLine) {
|
|
1117 |
scroll1.y -= CellTotalHeight;
|
|
1118 |
ScrollToPosition(scroll1);
|
|
1119 |
}
|
|
1120 |
if (nRow > 0 && nRow >= nLastVisibleLine - 1 ) {
|
|
1121 |
scroll1.y += CellTotalHeight;
|
|
1122 |
ScrollToPosition(scroll1);
|
|
1123 |
}
|
|
1124 |
|
|
1125 |
// DrawFocusRect();
|
|
1126 |
GetDocument()->UpdateAllViews(this, m_FocusCol);
|
|
1127 |
needReDraw = 1;
|
|
1128 |
this->RedrawWindow();
|
|
1129 |
UpdateStatusBar();
|
|
1130 |
|
|
1131 |
CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
|
|
1132 |
}
|
|
1133 |
|
|
1134 |
void CMTerm2View::OnLButtonDown(UINT nFlags, CPoint point)
|
|
1135 |
{
|
|
1136 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
1137 |
CString s1;
|
|
1138 |
CPoint scroll1;
|
|
1139 |
scroll1 = this->GetScrollPosition();
|
|
1140 |
int tx, ty;
|
|
1141 |
tx = point.x + scroll1.x;
|
|
1142 |
ty = point.y + scroll1.y;
|
|
1143 |
int nRow, nCol;
|
|
1144 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
1145 |
nRow = (ty - m_TopMargin) / CellTotalHeight;
|
|
1146 |
nCol = (tx - m_LeftMargin) / m_CellWidth;
|
|
1147 |
if (nRow < 0) { nRow = 0; }
|
|
1148 |
if (nCol < 0) { nCol = 0; }
|
|
1149 |
if (nCol >= m_CellPerLine) { nCol = m_CellPerLine - 1; }
|
|
1150 |
s1.Format(_T("LD %d %d %02X Scroll %d %d Total %d %d Row %d Col %d"), point.x, point.y, nFlags, scroll1.x, scroll1.y, tx, ty, nRow, nCol);
|
|
1151 |
m_pStatusBar->SetPaneText(6, s1);
|
|
1152 |
m_FocusRow = nRow;
|
|
1153 |
m_FocusCol = nCol;
|
|
1154 |
if (Cells[nRow][nCol].nType) {
|
|
1155 |
m_nCurProgStep = Cells[nRow][nCol].nProgStep;
|
|
1156 |
}
|
|
1157 |
|
|
1158 |
// DrawFocusRect();
|
|
1159 |
GetDocument()->UpdateAllViews(this, m_FocusCol);
|
|
1160 |
needReDraw = 1;
|
|
1161 |
this->RedrawWindow();
|
|
1162 |
UpdateStatusBar();
|
|
1163 |
// m_pStatusBar->Set
|
|
1164 |
CScrollView::OnLButtonDown(nFlags, point);
|
|
1165 |
}
|
|
1166 |
|
|
1167 |
void CMTerm2View::OnLButtonUp(UINT nFlags, CPoint point)
|
|
1168 |
{
|
|
1169 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
1170 |
|
|
1171 |
CScrollView::OnLButtonUp(nFlags, point);
|
|
1172 |
}
|
|
1173 |
|
|
1174 |
void CMTerm2View::OnLButtonDblClk(UINT nFlags, CPoint point)
|
|
1175 |
{
|
|
1176 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
1177 |
CString s1;
|
|
1178 |
CMTerm2Doc * pDoc = (CMTerm2Doc*)GetDocument();
|
|
1179 |
CPoint scroll1;
|
|
1180 |
scroll1 = this->GetScrollPosition();
|
|
1181 |
int tx, ty;
|
|
1182 |
tx = point.x + scroll1.x;
|
|
1183 |
ty = point.y + scroll1.y;
|
|
1184 |
|
|
1185 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
1186 |
int nRow = (ty - m_TopMargin) / CellTotalHeight;
|
|
1187 |
int nCol = (tx - m_LeftMargin) / m_CellWidth;
|
|
1188 |
|
|
1189 |
if (nRow < 0) { nRow = 0; }
|
|
1190 |
if (nCol < 0) { nCol = 0; }
|
|
1191 |
if (nCol >= m_CellPerLine) { nCol = m_CellPerLine - 1; }
|
|
1192 |
s1.Format(_T("LD db Clk %d %d %02X Scroll %d %d Total %d %d Row %d Col %d"),
|
|
1193 |
point.x, point.y, nFlags, scroll1.x, scroll1.y, tx, ty, nRow, nCol);
|
|
1194 |
m_pStatusBar->SetPaneText(6, s1);
|
b978bf
|
1195 |
// m_pStatusBar->SetPaneBackgroundColor(6, RGB(255, 255, 0));
|
Q |
1196 |
// m_pStatusBar->SetPaneTextColor(6, RGB(0, 0, 255));
|
0ed438
|
1197 |
// m_pStatusBar->EnablePaneProgressBar(6);
|
Q |
1198 |
// m_pStatusBar->SetPaneProgress(6, 5);
|
|
1199 |
SysLog(s1);
|
|
1200 |
|
|
1201 |
m_FocusRow = nRow;
|
|
1202 |
m_FocusCol = nCol;
|
|
1203 |
if (Cells[nRow][nCol].nType) {
|
|
1204 |
m_nCurProgStep = Cells[nRow][nCol].nProgStep;
|
|
1205 |
}
|
|
1206 |
if (!pDoc->m_bOnline) return;
|
|
1207 |
//if (!m_bMonitoring) return;
|
|
1208 |
|
|
1209 |
CString sParam;
|
|
1210 |
sParam = Cells[nRow][nCol].sParam;
|
|
1211 |
int nDataType, nDataAddr, nStat;
|
|
1212 |
nDataType = Cells[nRow][nCol].nDataType;
|
|
1213 |
nDataAddr = Cells[nRow][nCol].nDataAddr;
|
|
1214 |
nStat = Cells[nRow][nCol].nStat;
|
|
1215 |
|
|
1216 |
s1.Format(_T("Name %s DataType %d DataAddr %d Stat %d"),
|
|
1217 |
sParam, nDataType, nDataAddr, nStat);
|
|
1218 |
SysLog(s1);
|
|
1219 |
if (Cells[m_FocusRow][m_FocusCol].sParam == _T("")) {
|
|
1220 |
return;
|
|
1221 |
}
|
|
1222 |
needReDraw = 1;
|
|
1223 |
if ((nDataType&TYPEDATA) == TYPEDATA) {
|
|
1224 |
CDialogSetData dialog2;
|
|
1225 |
|
|
1226 |
dialog2.m_strAddr = sParam;
|
|
1227 |
dialog2.m_nStat = nStat;
|
|
1228 |
|
|
1229 |
INT_PTR r = dialog2.DoModal();
|
|
1230 |
if (r == IDOK)
|
|
1231 |
{
|
|
1232 |
int s = dialog2.m_nStat;
|
|
1233 |
///
|
|
1234 |
pDoc->SetVarData(nDataType, nDataAddr, s);
|
|
1235 |
//Cells[nRow][nCol].nStat = s;
|
|
1236 |
s1.Format(_T("Set Data %s as %d "), sParam, s);
|
|
1237 |
SysLog(s1);
|
|
1238 |
this->RedrawWindow();
|
|
1239 |
}
|
|
1240 |
}
|
|
1241 |
else {
|
|
1242 |
CDialogSetCoil dialog1;
|
|
1243 |
|
|
1244 |
dialog1.m_strAddr = sParam;
|
|
1245 |
dialog1.m_nStat = nStat;
|
|
1246 |
|
|
1247 |
INT_PTR r = dialog1.DoModal();
|
|
1248 |
if (r == IDOK)
|
|
1249 |
{
|
|
1250 |
int s = dialog1.m_nStat;
|
|
1251 |
///
|
|
1252 |
pDoc->SetCoilValue(nDataType, nDataAddr, s);
|
|
1253 |
// Cells[nRow][nCol].nStat = nStat;
|
|
1254 |
|
|
1255 |
// Cells[m_FocusRow][m_FocusCol].nStat = s;
|
|
1256 |
// s1.Format(_T("Set Coild %s as %d "), sParam, s);
|
|
1257 |
// AfxMessageBox(s1);
|
|
1258 |
this->RedrawWindow();
|
|
1259 |
}
|
|
1260 |
}
|
|
1261 |
CScrollView::OnLButtonDblClk(nFlags, point);
|
|
1262 |
}
|
|
1263 |
|
|
1264 |
void CMTerm2View::OnRButtonDown(UINT nFlags, CPoint point)
|
|
1265 |
{
|
|
1266 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
1267 |
CString s1;
|
|
1268 |
CPoint scroll1;
|
|
1269 |
scroll1 = this->GetScrollPosition();
|
|
1270 |
int tx, ty;
|
|
1271 |
tx = point.x + scroll1.x;
|
|
1272 |
ty = point.y + scroll1.y;
|
|
1273 |
|
|
1274 |
int nRow, nCol;
|
|
1275 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
1276 |
nRow = (ty- m_TopMargin )/ CellTotalHeight;
|
|
1277 |
nCol = (tx - m_LeftMargin) / m_CellWidth;
|
|
1278 |
|
|
1279 |
if (nRow < 0) { nRow = 0; }
|
|
1280 |
if (nCol < 0) { nCol = 0; }
|
|
1281 |
if (nCol >= m_CellPerLine) { nCol = m_CellPerLine - 1; }
|
|
1282 |
s1.Format(_T("RD %d %d %02X Scroll %d %d Total %d %d Row %d Col %d"), point.x, point.y, nFlags, scroll1.x, scroll1.y, tx, ty, m_FocusRow, m_FocusCol);
|
|
1283 |
m_pStatusBar->SetPaneText(6, s1);
|
|
1284 |
m_FocusRow = nRow;
|
|
1285 |
m_FocusCol = nCol;
|
|
1286 |
// DrawFocusRect();
|
|
1287 |
GetDocument()->UpdateAllViews(this, m_FocusCol);
|
|
1288 |
needReDraw = 1;
|
|
1289 |
this->RedrawWindow();
|
|
1290 |
|
|
1291 |
CScrollView::OnRButtonDown(nFlags, point);
|
|
1292 |
}
|
|
1293 |
|
|
1294 |
void CMTerm2View::OnRButtonUp(UINT nFlags, CPoint point)
|
|
1295 |
{
|
|
1296 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
1297 |
//CContextMenuManager
|
|
1298 |
CScrollView::OnRButtonUp(nFlags, point);
|
|
1299 |
}
|
|
1300 |
|
|
1301 |
void CMTerm2View::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
|
|
1302 |
{
|
|
1303 |
// TODO: 在此处添加消息处理程序代码
|
|
1304 |
CMenu menu1;
|
|
1305 |
menu1.LoadMenu(IDR_MENU1);
|
|
1306 |
CMenu *pContextMenu = menu1.GetSubMenu(0);
|
|
1307 |
pContextMenu->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
|
|
1308 |
}
|
|
1309 |
|
|
1310 |
void CMTerm2View::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu)
|
|
1311 |
{
|
|
1312 |
CScrollView::OnInitMenuPopup(pPopupMenu, nIndex, bSysMenu);
|
|
1313 |
|
|
1314 |
// TODO: 在此处添加消息处理程序代码
|
|
1315 |
if (!bSysMenu && pPopupMenu)
|
|
1316 |
{
|
|
1317 |
CCmdUI cmdUI;
|
|
1318 |
cmdUI.m_pOther = NULL;
|
|
1319 |
cmdUI.m_pMenu = pPopupMenu;
|
|
1320 |
cmdUI.m_pSubMenu = NULL;
|
|
1321 |
|
|
1322 |
|
|
1323 |
UINT count = pPopupMenu->GetMenuItemCount();
|
|
1324 |
cmdUI.m_nIndexMax = count;
|
|
1325 |
for (UINT i = 0; i < count; i++)
|
|
1326 |
{
|
|
1327 |
UINT nID = pPopupMenu->GetMenuItemID(i);
|
|
1328 |
if (-1 == nID || 0 == nID)
|
|
1329 |
{
|
|
1330 |
continue;
|
|
1331 |
}
|
|
1332 |
cmdUI.m_nID = nID;
|
|
1333 |
cmdUI.m_nIndex = i;
|
|
1334 |
cmdUI.DoUpdate(this, FALSE);
|
|
1335 |
}
|
|
1336 |
}
|
|
1337 |
}
|
|
1338 |
|
|
1339 |
void CMTerm2View::OnTimer(UINT_PTR nIDEvent)
|
|
1340 |
{
|
|
1341 |
// TODO: 在此添加消息处理程序代码和/或调用默认值
|
|
1342 |
CString s1;
|
|
1343 |
CMTerm2Doc * pDoc = (CMTerm2Doc*)GetDocument();
|
|
1344 |
|
|
1345 |
if (nIDEvent == 0) {
|
|
1346 |
|
|
1347 |
}
|
|
1348 |
else if (nIDEvent == 1)
|
|
1349 |
{
|
|
1350 |
if (m_bMonitoring) {
|
|
1351 |
//this->RedrawWindow();
|
|
1352 |
DoReDraw();
|
|
1353 |
}
|
|
1354 |
}
|
|
1355 |
else if (nIDEvent == 2) {
|
|
1356 |
pDoc->OnTimer(2);
|
|
1357 |
}
|
|
1358 |
else {
|
|
1359 |
|
|
1360 |
}
|
|
1361 |
CScrollView::OnTimer(nIDEvent);
|
|
1362 |
}
|
|
1363 |
|
|
1364 |
void CMTerm2View::OnMonitor()
|
|
1365 |
{
|
|
1366 |
// TODO: 在此添加命令处理程序代码
|
|
1367 |
m_bMonitoring = !m_bMonitoring;
|
|
1368 |
this->RedrawWindow();
|
|
1369 |
UpdateStatusBar();
|
|
1370 |
}
|
|
1371 |
|
|
1372 |
void CMTerm2View::OnUpdateMonitor(CCmdUI *pCmdUI)
|
|
1373 |
{
|
|
1374 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1375 |
pCmdUI->SetCheck(m_bMonitoring == true);
|
|
1376 |
}
|
|
1377 |
|
|
1378 |
void CMTerm2View::OnProgConvert()
|
|
1379 |
{
|
|
1380 |
// TODO: 在此添加命令处理程序代码
|
|
1381 |
CString s1;
|
|
1382 |
s1.Format(_T("Prog Convert"));
|
|
1383 |
SysLog(s1);
|
|
1384 |
int r = TransLDSToProg();
|
|
1385 |
s1.Format(_T("LDS To Prog result %d"), r);
|
|
1386 |
SysLog(s1);
|
|
1387 |
if (r==0) {
|
|
1388 |
// m_bModified = 0;
|
|
1389 |
int j=TransProgToLDS();
|
|
1390 |
s1.Format(_T("Porg to LDS retuls %d"), j);
|
|
1391 |
SysLog(s1);
|
|
1392 |
needReDraw = 1;
|
|
1393 |
RedrawWindow();
|
|
1394 |
}
|
|
1395 |
else {
|
|
1396 |
s1.Format(_T("Error in Prog Convert"));
|
|
1397 |
SysLog(s1);
|
|
1398 |
}
|
|
1399 |
}
|
|
1400 |
|
|
1401 |
void CMTerm2View::OnUpdateProgConvert(CCmdUI *pCmdUI)
|
|
1402 |
{
|
|
1403 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1404 |
pCmdUI->SetCheck(0);
|
|
1405 |
pCmdUI->Enable(m_bModified);
|
|
1406 |
}
|
|
1407 |
|
|
1408 |
void CMTerm2View::OnProgCancelEdit()
|
|
1409 |
{
|
|
1410 |
CString s1;
|
|
1411 |
s1.Format(_T("Prog Cancel Edit"));
|
|
1412 |
SysLog(s1);
|
|
1413 |
// TODO: 在此添加命令处理程序代码
|
|
1414 |
}
|
|
1415 |
|
|
1416 |
|
|
1417 |
void CMTerm2View::OnUpdateProgCancelEdit(CCmdUI *pCmdUI)
|
|
1418 |
{
|
|
1419 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1420 |
// pCmdUI->SetCheck(m_bModified);
|
|
1421 |
pCmdUI->Enable(m_bModified);
|
|
1422 |
}
|
|
1423 |
|
|
1424 |
|
|
1425 |
void CMTerm2View::OnInsertBlankLine()
|
|
1426 |
{
|
|
1427 |
// TODO: 在此添加命令处理程序代码
|
|
1428 |
CString s1;
|
|
1429 |
s1.Format(_T("Insert Blank Line"));
|
|
1430 |
SysLog(s1);
|
|
1431 |
m_FocusRow;
|
|
1432 |
for (int i = m_nTotalRow - 1; i >= m_FocusRow; i--) {
|
|
1433 |
for (int j = 0; j < m_CellPerLine; j++) {
|
|
1434 |
Cells[i + 1][j] = Cells[i][j];
|
|
1435 |
}
|
|
1436 |
}
|
|
1437 |
m_nTotalRow += 1;
|
|
1438 |
|
|
1439 |
for (int j = 0; j < m_CellPerLine; j++) {
|
|
1440 |
Cells[m_FocusRow][j].clear();
|
|
1441 |
Cells[m_FocusRow][j].bEditing = 1;
|
|
1442 |
Cells[m_FocusRow][j].bModified = 1;
|
|
1443 |
if (Cells[m_FocusRow + 1][j].bLeftLineUp) {
|
|
1444 |
Cells[m_FocusRow][j].bLeftLineUp = 1;
|
|
1445 |
Cells[m_FocusRow][j].bLeftLineDn = 1;
|
|
1446 |
}
|
|
1447 |
}
|
e00d5a
|
1448 |
|
YC |
1449 |
|
|
1450 |
|
0ed438
|
1451 |
m_bModified = 1;
|
Q |
1452 |
needReDraw = 1;
|
|
1453 |
this->RedrawWindow();
|
|
1454 |
}
|
e00d5a
|
1455 |
int FindTypeIndex(CString str[], CString strType, int num)
|
YC |
1456 |
{
|
|
1457 |
for (int i = 0;i < num;i++)
|
|
1458 |
{
|
|
1459 |
if (strType == str[i])
|
|
1460 |
{
|
|
1461 |
return i;
|
|
1462 |
}
|
|
1463 |
}
|
|
1464 |
return -1;
|
|
1465 |
}
|
|
1466 |
void CMTerm2View::GetIncToView(stCell cell1) //**************************************************************************************************//
|
|
1467 |
{
|
0ed438
|
1468 |
|
e00d5a
|
1469 |
|
YC |
1470 |
Cells[m_FocusRow][m_FocusCol] = cell1;
|
|
1471 |
|
|
1472 |
m_bModified = 1;
|
|
1473 |
needReDraw = 1;
|
|
1474 |
m_FocusCol += 1;
|
|
1475 |
if (m_FocusCol >= 16)
|
|
1476 |
{ m_FocusCol = 0;m_FocusRow += 1; }
|
|
1477 |
|
|
1478 |
this->RedrawWindow();
|
|
1479 |
|
|
1480 |
}
|
0ed438
|
1481 |
void CMTerm2View::OnUpdateInsertBlankLine(CCmdUI *pCmdUI)
|
Q |
1482 |
{
|
|
1483 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1484 |
}
|
|
1485 |
|
|
1486 |
void CMTerm2View::OnDeleteBlankLine()
|
|
1487 |
{
|
|
1488 |
// TODO: 在此添加命令处理程序代码
|
|
1489 |
CString s1;
|
|
1490 |
s1.Format(_T("Delete Blank Line"));
|
|
1491 |
SysLog(s1);
|
|
1492 |
}
|
|
1493 |
|
|
1494 |
void CMTerm2View::OnUpdateDeleteBlankLine(CCmdUI *pCmdUI)
|
|
1495 |
{
|
|
1496 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1497 |
}
|
|
1498 |
|
|
1499 |
void CMTerm2View::OnRectSelect()
|
|
1500 |
{
|
|
1501 |
// TODO: 在此添加命令处理程序代码
|
|
1502 |
}
|
|
1503 |
|
|
1504 |
|
|
1505 |
void CMTerm2View::OnUpdateRectSelect(CCmdUI *pCmdUI)
|
|
1506 |
{
|
|
1507 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1508 |
}
|
|
1509 |
|
|
1510 |
|
|
1511 |
void CMTerm2View::OnTextFirst()
|
|
1512 |
{
|
|
1513 |
// TODO: 在此添加命令处理程序代码
|
|
1514 |
}
|
|
1515 |
|
|
1516 |
|
|
1517 |
void CMTerm2View::OnUpdateTextFirst(CCmdUI *pCmdUI)
|
|
1518 |
{
|
|
1519 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1520 |
}
|
|
1521 |
|
|
1522 |
void CMTerm2View::OnDisplayComments()
|
|
1523 |
{
|
|
1524 |
// TODO: 在此添加命令处理程序代码
|
|
1525 |
m_bShowComments = !m_bShowComments;
|
|
1526 |
int CellTotalHeight = m_CellHeight + (m_bShowComments ? m_CommentHeight : 0);
|
|
1527 |
CRect rect0;
|
|
1528 |
this->GetClientRect(&rect0);
|
|
1529 |
|
|
1530 |
CSize sizeTotal;
|
|
1531 |
// TODO: 计算此视图的合计大小
|
|
1532 |
sizeTotal.cx = m_LeftMargin + m_CellWidth * m_CellPerLine + m_CellWidth * 2;
|
|
1533 |
sizeTotal.cy = m_TopMargin + CellTotalHeight * (m_nTotalRow-1) + rect0.Height();
|
|
1534 |
SetScrollSizes(MM_TEXT, sizeTotal);
|
|
1535 |
needReDraw = 1;
|
|
1536 |
this->Invalidate();
|
|
1537 |
}
|
|
1538 |
|
|
1539 |
|
|
1540 |
void CMTerm2View::OnUpdateDisplayComments(CCmdUI *pCmdUI)
|
|
1541 |
{
|
|
1542 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1543 |
pCmdUI->SetCheck(m_bShowComments == true);
|
|
1544 |
}
|
|
1545 |
|
|
1546 |
|
|
1547 |
|
|
1548 |
int CMTerm2View::UpdateStatusBar(int nIndex)
|
|
1549 |
{
|
|
1550 |
// TODO: 在此处添加实现代码.
|
|
1551 |
CString s1;
|
|
1552 |
CMTerm2Doc * pDoc = (CMTerm2Doc*)GetDocument();
|
|
1553 |
|
|
1554 |
if (nIndex == idxMachineType || nIndex == -1) { //机型代码
|
|
1555 |
s1 = pDoc->m_sMachineType;
|
|
1556 |
m_pStatusBar->SetPaneText(idxMachineType,s1);
|
|
1557 |
}
|
|
1558 |
if (nIndex == idxProgPos || nIndex == -1) { //程序位置/步数
|
|
1559 |
s1.Format(_T("%5d/%5d"), m_nCurProgStep,pDoc->m_nProgSteps);
|
|
1560 |
m_pStatusBar->SetPaneText(idxProgPos, s1);
|
|
1561 |
}
|
|
1562 |
if (nIndex == idxOnline || nIndex == -1) { //在线 /离线
|
|
1563 |
if (!pDoc->m_bOnline) {
|
|
1564 |
s1 = _T("离线");
|
|
1565 |
m_pStatusBar->SetPaneText(idxOnline, s1);
|
b978bf
|
1566 |
// m_pStatusBar->SetPaneBackgroundColor(idxOnline);
|
0ed438
|
1567 |
}
|
Q |
1568 |
else if (pDoc->m_bOnline) {
|
|
1569 |
if (pDoc->m_bSimulate) {
|
|
1570 |
s1 = _T("在线(仿真)");
|
|
1571 |
m_pStatusBar->SetPaneText(2, s1);
|
b978bf
|
1572 |
// m_pStatusBar->SetPaneBackgroundColor(idxOnline, OnlineColor);
|
0ed438
|
1573 |
}else{
|
Q |
1574 |
s1 = _T("在线");
|
|
1575 |
m_pStatusBar->SetPaneText(2, s1);
|
b978bf
|
1576 |
// m_pStatusBar->SetPaneBackgroundColor(idxOnline, OnlineColor);
|
0ed438
|
1577 |
}
|
Q |
1578 |
}
|
|
1579 |
}
|
|
1580 |
if (nIndex == idxRunning || nIndex == -1) { // 运行 / 停止
|
|
1581 |
if (!pDoc->m_bOnline) {
|
|
1582 |
s1 = _T("");
|
|
1583 |
m_pStatusBar->SetPaneText(idxRunning, s1);
|
b978bf
|
1584 |
// m_pStatusBar->SetPaneBackgroundColor(idxRunning);
|
Q |
1585 |
// m_pStatusBar->SetPaneWidth(idxRunning, 0);
|
0ed438
|
1586 |
m_pStatusBar->SetPaneStyle(idxRunning, SBPS_DISABLED);
|
Q |
1587 |
|
|
1588 |
}else if (!pDoc->m_bPlcRunning) {
|
|
1589 |
s1 = _T("PROG");
|
|
1590 |
m_pStatusBar->SetPaneText(idxRunning, s1);
|
b978bf
|
1591 |
// m_pStatusBar->SetPaneWidth(idxRunning, s1.GetLength()*8);
|
Q |
1592 |
// m_pStatusBar->SetPaneBackgroundColor(idxRunning, ProgColor);
|
0ed438
|
1593 |
}else {
|
Q |
1594 |
s1 = _T("RUN");
|
|
1595 |
m_pStatusBar->SetPaneText(idxRunning, s1);
|
b978bf
|
1596 |
// m_pStatusBar->SetPaneWidth(idxRunning, s1.GetLength() * 8);
|
Q |
1597 |
// m_pStatusBar->SetPaneBackgroundColor(idxRunning, RunningColor);
|
0ed438
|
1598 |
}
|
Q |
1599 |
}
|
|
1600 |
if (nIndex == idxMonitor || nIndex == -1) { // 监控 //
|
|
1601 |
// s1 = pDoc->m_sMachineType;
|
|
1602 |
if (!m_bMonitoring) {
|
|
1603 |
s1 = _T("[监控停止]");
|
|
1604 |
m_pStatusBar->SetPaneText(idxMonitor, s1);
|
b978bf
|
1605 |
// m_pStatusBar->SetPaneBackgroundColor(idxMonitor);
|
0ed438
|
1606 |
}else{
|
Q |
1607 |
s1 = _T("[正在监控]");
|
|
1608 |
m_pStatusBar->SetPaneText(idxMonitor, s1);
|
b978bf
|
1609 |
// m_pStatusBar->SetPaneBackgroundColor(idxMonitor, MonitorColor);
|
0ed438
|
1610 |
}
|
Q |
1611 |
}
|
|
1612 |
if (nIndex == idxAddress || nIndex == -1) { // 地址,本站
|
|
1613 |
// s1 = pDoc->m_sMachineType;
|
|
1614 |
if (!pDoc->m_bOnline) {
|
|
1615 |
s1 = _T("本站");
|
|
1616 |
m_pStatusBar->SetPaneText(idxAddress, s1);
|
b978bf
|
1617 |
// m_pStatusBar->SetPaneBackgroundColor(idxMonitor);
|
0ed438
|
1618 |
}else {
|
Q |
1619 |
s1 = _T("本站");
|
|
1620 |
m_pStatusBar->SetPaneText(idxAddress, s1);
|
b978bf
|
1621 |
// m_pStatusBar->SetPaneBackgroundColor(idxMonitor, AddressColor);
|
0ed438
|
1622 |
}
|
Q |
1623 |
|
|
1624 |
}
|
|
1625 |
if (nIndex == idxInfoDisp || nIndex == -1) { // INFO DISPLAY
|
|
1626 |
// s1 = pDoc->m_sMachineType;
|
|
1627 |
// m_pStatusBar->SetPaneText(idxInfoDisp, s1);
|
|
1628 |
}
|
|
1629 |
|
|
1630 |
return 0;
|
|
1631 |
}
|
|
1632 |
|
|
1633 |
|
|
1634 |
void CMTerm2View::OnUpdateIndicatorMonitorStatus(CCmdUI *pCmdUI)
|
|
1635 |
{
|
|
1636 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1637 |
|
|
1638 |
//pCmdUI->SetCheck(m_bMonitoring == true);
|
|
1639 |
if (!m_bMonitoring) pCmdUI->SetText(_T("[监控停止]"));
|
|
1640 |
else pCmdUI->SetText(_T("[正在监控]"));
|
|
1641 |
}
|
|
1642 |
|
|
1643 |
void CMTerm2View::OnUpdateIndicators(CCmdUI *pCmdUI)
|
|
1644 |
{
|
|
1645 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1646 |
CString s1;
|
|
1647 |
s1.Format(_T("pCmdUI nID %d "));
|
|
1648 |
DbgLog(s1);
|
|
1649 |
pCmdUI->m_nID;
|
|
1650 |
pCmdUI->SetText(_T("KL-D20N16"));
|
|
1651 |
}
|
|
1652 |
|
|
1653 |
void CMTerm2View::OnUpdateMachineType(CCmdUI *pCmdUI)
|
|
1654 |
{
|
|
1655 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1656 |
CString s1;
|
|
1657 |
s1.Format(_T("pCmdUI nID %d "));
|
|
1658 |
DbgLog(s1);
|
|
1659 |
pCmdUI->m_nID;
|
|
1660 |
pCmdUI->SetText(_T("KL-D20N16"));
|
|
1661 |
}
|
|
1662 |
|
|
1663 |
void CMTerm2View::OnUpdateProgramPos(CCmdUI *pCmdUI)
|
|
1664 |
{
|
|
1665 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1666 |
CString s1;
|
|
1667 |
s1.Format(_T("%5d/%5d"), 18, 55);
|
|
1668 |
pCmdUI->SetText(s1);
|
|
1669 |
}
|
|
1670 |
|
|
1671 |
void CMTerm2View::OnUpdateConnectivity(CCmdUI *pCmdUI)
|
|
1672 |
{
|
|
1673 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1674 |
CString s1;
|
|
1675 |
s1 = _T("离线");
|
|
1676 |
s1 = _T("在线");
|
|
1677 |
|
|
1678 |
pCmdUI->SetText(s1);
|
|
1679 |
}
|
|
1680 |
void CMTerm2View::OnUpdateRunStatus(CCmdUI *pCmdUI)
|
|
1681 |
{
|
|
1682 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1683 |
CString s1;
|
|
1684 |
CMTerm2Doc* pDoc = GetDocument();
|
|
1685 |
ASSERT_VALID(pDoc);
|
|
1686 |
if (!pDoc) return;
|
|
1687 |
if (pDoc->m_bPlcRunning) {
|
|
1688 |
s1 = _T("运行");
|
|
1689 |
m_pStatusBar->SetPaneText(3, s1);
|
b978bf
|
1690 |
// m_pStatusBar->SetPaneTextColor(3, RGB(0, 0, 0));
|
0ed438
|
1691 |
}
|
Q |
1692 |
else {
|
|
1693 |
s1 = _T("停止");
|
|
1694 |
m_pStatusBar->SetPaneText(3, s1);
|
b978bf
|
1695 |
// m_pStatusBar->SetPaneTextColor(3, RGB(0, 0, 0));
|
0ed438
|
1696 |
}
|
Q |
1697 |
s1.Format(_T("PCmdUI %d %d"), pCmdUI->m_nID, pCmdUI->m_nIndex);
|
|
1698 |
DbgLog(s1);
|
|
1699 |
|
|
1700 |
// pCmdUI->SetText(s1);
|
|
1701 |
}
|
|
1702 |
void CMTerm2View::OnUpdateMonitorStatus(CCmdUI *pCmdUI)
|
|
1703 |
{
|
|
1704 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1705 |
CString s1;
|
|
1706 |
s1 = _T("停止监控");
|
|
1707 |
s1 = _T("监控中");
|
|
1708 |
if (!m_bMonitoring) pCmdUI->SetText(_T("[监控停止]"));
|
|
1709 |
else pCmdUI->SetText(_T("[正在监控]"));
|
|
1710 |
|
|
1711 |
// pCmdUI->SetText(s1);
|
|
1712 |
}
|
|
1713 |
void CMTerm2View::OnUpdateTargetAddress(CCmdUI *pCmdUI)
|
|
1714 |
{
|
|
1715 |
// TODO: 在此添加命令更新用户界面处理程序代码
|
|
1716 |
CString s1;
|
|
1717 |
s1 = _T("远程");
|
|
1718 |
s1 = _T("本站");
|
|
1719 |
pCmdUI->SetText(s1);
|
|
1720 |
}
|
|
1721 |
|
|
1722 |
void CMTerm2View::OnInputIoComment()
|
|
1723 |
{
|
|
1724 |
// TODO: 在此添加命令处理程序代码
|
|
1725 |
CString s1;
|
|
1726 |
int nRow, nCol;
|
|
1727 |
nRow = m_FocusRow;
|
|
1728 |
nCol = m_FocusCol;
|
|
1729 |
if (nCol < 0) { nCol = 0; }
|
|
1730 |
if (nCol >= m_CellPerLine) { nCol = m_CellPerLine - 1; }
|
|
1731 |
|
|
1732 |
CString sParam;
|
|
1733 |
sParam = Cells[nRow][nCol].sParam;
|
|
1734 |
int nDataType, nDataAddr, nStat;
|
|
1735 |
nDataType = Cells[nRow][nCol].nDataType;
|
|
1736 |
nDataAddr = Cells[nRow][nCol].nDataAddr;
|
|
1737 |
nStat = Cells[nRow][nCol].nStat;
|
|
1738 |
|
|
1739 |
s1.Format(_T("Name %s DataType %d DataAddr %d Stat %d"),
|
|
1740 |
sParam, nDataType, nDataAddr, nStat);
|
|
1741 |
SysLog(s1);
|
|
1742 |
if (Cells[m_FocusRow][m_FocusCol].sParam == _T("")) {
|
|
1743 |
return;
|
|
1744 |
}
|
|
1745 |
|
|
1746 |
CMTerm2Doc * pDoc = GetDocument();
|
|
1747 |
CString sComment;
|
|
1748 |
pDoc->GetAnno(nDataType, nDataAddr, sComment);
|
|
1749 |
CDialogIoComment dialog1;
|
|
1750 |
dialog1.m_sIOName = sParam;
|
|
1751 |
dialog1.m_sComment = sComment;
|
|
1752 |
dialog1.m_nCoilType = nDataType;
|
|
1753 |
dialog1.m_nCoilAddr = nDataAddr;
|
|
1754 |
INT_PTR r = dialog1.DoModal();
|
|
1755 |
if (r == IDOK)
|
|
1756 |
{
|
|
1757 |
sComment = dialog1.m_sComment;
|
|
1758 |
pDoc->SetAnno(nDataType, nDataAddr, sParam, sComment);
|
|
1759 |
s1.Format(_T("Set %s %d %d comment -> %s"), sParam, nDataType, nDataAddr, sComment);
|
|
1760 |
SysLog(s1);
|
|
1761 |
//needReDraw = 1;
|
|
1762 |
this->RedrawWindow();
|
|
1763 |
}
|
|
1764 |
}
|
|
1765 |
|
|
1766 |
|
|
1767 |
int CMTerm2View::TransProgToLDS()
|
|
1768 |
{
|
|
1769 |
CString s1;
|
|
1770 |
CMTerm2Doc * pDoc = (CMTerm2Doc*)GetDocument();
|
|
1771 |
|
|
1772 |
// 先扫描分开的程序段
|
|
1773 |
int stpos[100] = { 0 };
|
|
1774 |
int nSts = 0;
|
|
1775 |
|
|
1776 |
for (int i = 0; i < m_nTotalRow && i < 2000; i++) {
|
|
1777 |
for (int j = 0; j < 16; j++) {
|
|
1778 |
Cells[i][j].clear();
|
|
1779 |
s1.Format(_T("%d:%d"), i, j);
|
|
1780 |
Cells[i][j].sCoilName = s1;
|
|
1781 |
}
|
|
1782 |
}
|
|
1783 |
POINT StPts[100];
|
|
1784 |
// StPts[0] = POINT{ 0, 0 };
|
|
1785 |
POINT EndPt[100];
|
|
1786 |
int nEndPts = 0;
|
|
1787 |
nSts = 0;
|
|
1788 |
int nCurLine = 0;
|
|
1789 |
|
|
1790 |
int cx = 0, cy = 0;
|
|
1791 |
int maxy = 0;
|
|
1792 |
for (int i = 0; i < pDoc->m_nProgSteps; i++)
|
|
1793 |
{
|
|
1794 |
int nOp = pDoc->Progs[i].nOpType1;
|
|
1795 |
int nParamCount = pDoc->Progs[i].nParamCount;
|
|
1796 |
CStringA OpName;
|
|
1797 |
CStringA ShowTxt;
|
|
1798 |
pDoc->OpToTxt(nOp, OpName);
|
|
1799 |
pDoc->OpToShowTxt(nOp, ShowTxt);
|
|
1800 |
int nPairTo = pDoc->Progs[i].PairTo;
|
|
1801 |
int nPairOp = 0;
|
|
1802 |
if (nPairTo) nPairOp = pDoc->Progs[nPairTo].nOpType1;
|
|
1803 |
int nCellType;
|
|
1804 |
switch (nOp)
|
|
1805 |
{
|
|
1806 |
|
|
1807 |
case OP_NOP:
|
|
1808 |
break;
|
|
1809 |
case OP_ST:
|
|
1810 |
case OP_ST_:
|
|
1811 |
if (i == 0) {
|
|
1812 |
|
|
1813 |
}
|
|
1814 |
else {
|
|
1815 |
//记录当前位置
|
|
1816 |
EndPt[nEndPts] = POINT{ cx,cy };
|
|
1817 |
nEndPts++;
|
|
1818 |
if (nPairOp == OP_ANS) {
|
|
1819 |
//继续前进
|
|
1820 |
//cx = 0, cy = nCurLine;
|
|
1821 |
//cx = StPts[nSts - 1].x;
|
|
1822 |
//nCurLine = cy + 1; //另起一行
|
|
1823 |
///*
|
|
1824 |
nCurLine=cy;
|
|
1825 |
int hasData = 1;
|
|
1826 |
while (hasData) {
|
|
1827 |
hasData = 0;
|
|
1828 |
for (int j = cx +1; j < m_CellPerLine; j++) {
|
|
1829 |
if (Cells[nCurLine][j].nType != 0) {
|
|
1830 |
nCurLine++; hasData = 1; break;
|
|
1831 |
}
|
|
1832 |
}
|
|
1833 |
}
|
|
1834 |
// nCurLine = maxy + 1; //另起一行
|
|
1835 |
if (nCurLine > maxy) maxy = nCurLine;
|
|
1836 |
for (int j = cy; j < nCurLine; j++) {
|
|
1837 |
Cells[j][cx].bLeftLineDn = 1;
|
|
1838 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
1839 |
}
|
|
1840 |
cy = nCurLine;
|
|
1841 |
//*/
|
|
1842 |
}
|
|
1843 |
else if (nPairOp == OP_ORS) {
|
|
1844 |
cx = StPts[nSts - 1].x;
|
|
1845 |
nCurLine = cy + 1; //另起一行
|
|
1846 |
int hasData = 1;
|
|
1847 |
while (hasData) {
|
|
1848 |
hasData = 0;
|
|
1849 |
for (int j = cx; j < m_CellPerLine; j++) {
|
|
1850 |
if (Cells[nCurLine][j].nType != 0) {
|
|
1851 |
nCurLine++; hasData = 1; break;
|
|
1852 |
}
|
|
1853 |
}
|
|
1854 |
}
|
|
1855 |
// nCurLine = maxy + 1; //另起一行
|
|
1856 |
if (nCurLine > maxy) maxy = nCurLine;
|
|
1857 |
for (int j = cy; j < nCurLine; j++) {
|
|
1858 |
Cells[j][cx].bLeftLineDn = 1;
|
|
1859 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
1860 |
}
|
|
1861 |
cy = nCurLine;
|
|
1862 |
}
|
|
1863 |
else if (nPairOp == 0) {
|
|
1864 |
nCurLine = maxy + 1; //另起一行
|
|
1865 |
maxy = nCurLine;
|
|
1866 |
cx = 0; cy = nCurLine;
|
|
1867 |
}
|
|
1868 |
}
|
|
1869 |
stpos[nSts] = i;
|
|
1870 |
StPts[nSts] = POINT{ cx,cy };
|
|
1871 |
nSts++;
|
|
1872 |
Cells[cy][cx].nType = pDoc->Progs[i].nOpType1 == OP_ST ? typeNO : typeNC; //typeNC
|
|
1873 |
Cells[cy][cx].nProgStep = i;
|
|
1874 |
Cells[cy][cx].sCoilName = pDoc->Progs[i].Params[0].sParamStr;
|
|
1875 |
Cells[cy][cx].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
1876 |
Cells[cy][cx].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
1877 |
Cells[cy][cx].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
1878 |
cx++; //移到下一格
|
|
1879 |
break;
|
|
1880 |
case OP_ST_EQ:
|
|
1881 |
case OP_ST_NE:
|
|
1882 |
case OP_ST_LT:
|
|
1883 |
case OP_ST_GT:
|
|
1884 |
case OP_ST_LE:
|
|
1885 |
case OP_ST_GE:
|
|
1886 |
if (i == 0) {
|
|
1887 |
|
|
1888 |
}
|
|
1889 |
else {
|
|
1890 |
//记录当前位置
|
|
1891 |
EndPt[nEndPts] = POINT{ cx,cy };
|
|
1892 |
nEndPts++;
|
|
1893 |
if (nPairOp == OP_ANS) {
|
|
1894 |
//继续前进
|
|
1895 |
//cx = 0, cy = nCurLine;
|
|
1896 |
}
|
|
1897 |
else if (nPairOp == OP_ORS) {
|
|
1898 |
cx = StPts[nSts - 1].x;
|
|
1899 |
nCurLine = cy + 1; //另起一行
|
|
1900 |
int hasData = 1;
|
|
1901 |
while (hasData) {
|
|
1902 |
hasData = 0;
|
|
1903 |
for (int j = cx; j < m_CellPerLine; j++) {
|
|
1904 |
if (Cells[nCurLine][j].nType != 0) {
|
|
1905 |
nCurLine++; hasData = 1; break;
|
|
1906 |
}
|
|
1907 |
}
|
|
1908 |
}
|
|
1909 |
// nCurLine = maxy + 1; //另起一行
|
|
1910 |
if (nCurLine > maxy) maxy = nCurLine;
|
|
1911 |
for (int j = cy; j < nCurLine; j++) {
|
|
1912 |
Cells[j][cx].bLeftLineDn = 1;
|
|
1913 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
1914 |
}
|
|
1915 |
cy = nCurLine;
|
|
1916 |
}
|
|
1917 |
else if (nPairOp == 0) {
|
|
1918 |
nCurLine = maxy + 1; //另起一行
|
|
1919 |
maxy = nCurLine;
|
|
1920 |
cx = 0; cy = nCurLine;
|
|
1921 |
}
|
|
1922 |
}
|
|
1923 |
stpos[nSts] = i;
|
|
1924 |
StPts[nSts] = POINT{ cx,cy };
|
|
1925 |
nSts++;
|
|
1926 |
Cells[cy][cx].nType = typeCMP;
|
|
1927 |
Cells[cy][cx].nProgStep = i;
|
|
1928 |
Cells[cy][cx].sParam = OpName;
|
|
1929 |
Cells[cy][cx].sCoilName = ShowTxt;
|
|
1930 |
Cells[cy][cx + 1].nType = typeExt1;
|
|
1931 |
Cells[cy][cx + 1].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
1932 |
Cells[cy][cx + 1].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
1933 |
Cells[cy][cx + 1].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
1934 |
Cells[cy][cx + 2].nType = typeExt1;
|
|
1935 |
Cells[cy][cx + 2].sParam = pDoc->Progs[i].Params[1].sParamStr;
|
|
1936 |
Cells[cy][cx + 2].nDataType = pDoc->Progs[i].Params[1].nParamType;
|
|
1937 |
Cells[cy][cx + 2].nDataAddr = pDoc->Progs[i].Params[1].nParamAddr;
|
|
1938 |
cx += 3; //移到下3格
|
|
1939 |
break;
|
|
1940 |
|
|
1941 |
case OP_AN:
|
|
1942 |
case OP_AN_:
|
|
1943 |
|
|
1944 |
Cells[cy][cx].nType = nOp == OP_AN ? typeNO : typeNC; //typeNC
|
|
1945 |
Cells[cy][cx].nProgStep = i;
|
|
1946 |
Cells[cy][cx].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
1947 |
Cells[cy][cx].sCoilName = pDoc->Progs[i].Params[0].sParamStr;
|
|
1948 |
Cells[cy][cx].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
1949 |
Cells[cy][cx].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
1950 |
cx++;
|
|
1951 |
break;
|
|
1952 |
case OP_AN_EQ:
|
|
1953 |
case OP_AN_NE:
|
|
1954 |
case OP_AN_LT:
|
|
1955 |
case OP_AN_GT:
|
|
1956 |
case OP_AN_LE:
|
|
1957 |
case OP_AN_GE:
|
|
1958 |
Cells[cy][cx].nType = typeCMP;
|
|
1959 |
Cells[cy][cx].nProgStep = i;
|
|
1960 |
Cells[cy][cx].sCoilName = ShowTxt;
|
|
1961 |
Cells[cy][cx + 1].nType = typeExt1;
|
|
1962 |
Cells[cy][cx + 1].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
1963 |
Cells[cy][cx + 1].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
1964 |
Cells[cy][cx + 1].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
1965 |
Cells[cy][cx + 2].nType = typeExt1;
|
|
1966 |
Cells[cy][cx + 2].sParam = pDoc->Progs[i].Params[1].sParamStr;
|
|
1967 |
Cells[cy][cx + 2].nDataType = pDoc->Progs[i].Params[1].nParamType;
|
|
1968 |
Cells[cy][cx + 2].nDataAddr = pDoc->Progs[i].Params[1].nParamAddr;
|
|
1969 |
cx += 3;
|
|
1970 |
break;
|
|
1971 |
|
|
1972 |
case OP_OR:
|
|
1973 |
case OP_OR_:
|
|
1974 |
EndPt[nEndPts] = POINT{ cx,cy };
|
|
1975 |
nEndPts++;
|
|
1976 |
cx = StPts[nSts - 1].x;
|
|
1977 |
nCurLine = cy + 1; //另起一行
|
|
1978 |
{
|
|
1979 |
int hasData = 1;
|
|
1980 |
while (hasData) {
|
|
1981 |
hasData = 0;
|
|
1982 |
for (int j = cx; j < m_CellPerLine; j++) {
|
|
1983 |
if (Cells[nCurLine][j].nType != 0) {
|
|
1984 |
nCurLine++; hasData = 1; break;
|
|
1985 |
}
|
|
1986 |
}
|
|
1987 |
}
|
|
1988 |
}
|
|
1989 |
if (nCurLine > maxy) maxy = nCurLine;
|
|
1990 |
for (int j = cy; j < nCurLine; j++) {
|
|
1991 |
Cells[j][cx].bLeftLineDn = 1;
|
|
1992 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
1993 |
}
|
|
1994 |
cy = nCurLine;
|
|
1995 |
Cells[cy][cx].nProgStep = i;
|
|
1996 |
Cells[cy][cx].nType = nOp == OP_OR ? typeNO : typeNC; //typeNC
|
|
1997 |
Cells[cy][cx].sCoilName = pDoc->Progs[i].Params[0].sParamStr;
|
|
1998 |
Cells[cy][cx].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
1999 |
Cells[cy][cx].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
2000 |
Cells[cy][cx].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
2001 |
cx++;
|
|
2002 |
if (cx < EndPt[nEndPts - 1].x)
|
|
2003 |
{ //本行补齐
|
|
2004 |
for (int j = cx; j < EndPt[nEndPts - 1].x; j++)
|
|
2005 |
{
|
|
2006 |
Cells[cy][j].nType = typeLine1;
|
|
2007 |
}
|
|
2008 |
cx = EndPt[nEndPts - 1].x;
|
|
2009 |
}
|
|
2010 |
else {
|
|
2011 |
//前一行补齐
|
|
2012 |
for (int j = EndPt[nEndPts - 1].x; j < cx; j++)
|
|
2013 |
{
|
|
2014 |
Cells[EndPt[nEndPts - 1].y][j].nType = typeLine1;
|
|
2015 |
}
|
|
2016 |
|
|
2017 |
}
|
|
2018 |
//连接上下线
|
|
2019 |
for (int j = EndPt[nEndPts - 1].y; j < cy; j++)
|
|
2020 |
{
|
|
2021 |
Cells[j][cx].bLeftLineDn = 1;
|
|
2022 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
2023 |
}
|
|
2024 |
//光标位置, 前一结束点位置
|
|
2025 |
cy = EndPt[nEndPts - 1].y;
|
|
2026 |
nEndPts--;
|
|
2027 |
|
|
2028 |
break;
|
|
2029 |
case OP_OR_EQ:
|
|
2030 |
case OP_OR_NE:
|
|
2031 |
case OP_OR_LT:
|
|
2032 |
case OP_OR_GT:
|
|
2033 |
case OP_OR_LE:
|
|
2034 |
case OP_OR_GE:
|
|
2035 |
EndPt[nEndPts] = POINT{ cx,cy };
|
|
2036 |
nEndPts++;
|
|
2037 |
cx = StPts[nSts - 1].x;
|
|
2038 |
nCurLine = cy + 1; //另起一行
|
|
2039 |
{
|
|
2040 |
int hasData = 1;
|
|
2041 |
while (hasData) {
|
|
2042 |
hasData = 0;
|
|
2043 |
for (int j = cx; j < m_CellPerLine; j++) {
|
|
2044 |
if (Cells[nCurLine][j].nType != 0) {
|
|
2045 |
nCurLine++; hasData = 1; break;
|
|
2046 |
}
|
|
2047 |
}
|
|
2048 |
}
|
|
2049 |
}
|
|
2050 |
if (nCurLine > maxy) maxy = nCurLine;
|
|
2051 |
for (int j = cy; j < nCurLine; j++) {
|
|
2052 |
Cells[j][cx].bLeftLineDn = 1;
|
|
2053 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
2054 |
}
|
|
2055 |
cy = nCurLine;
|
|
2056 |
Cells[cy][cx].nType = typeCMP;
|
|
2057 |
Cells[cy][cx].nProgStep = i;
|
|
2058 |
Cells[cy][cx].sCoilName = ShowTxt;
|
|
2059 |
Cells[cy][cx + 1].nType = typeExt1;
|
|
2060 |
Cells[cy][cx + 1].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
2061 |
Cells[cy][cx + 1].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
2062 |
Cells[cy][cx + 1].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
2063 |
Cells[cy][cx + 2].nType = typeExt1;
|
|
2064 |
Cells[cy][cx + 2].sParam = pDoc->Progs[i].Params[1].sParamStr;
|
|
2065 |
Cells[cy][cx + 2].nDataType = pDoc->Progs[i].Params[1].nParamType;
|
|
2066 |
Cells[cy][cx + 2].nDataAddr = pDoc->Progs[i].Params[1].nParamAddr;
|
|
2067 |
cx += 3;
|
|
2068 |
if (cx < EndPt[nEndPts - 1].x)
|
|
2069 |
{ //本行补齐
|
|
2070 |
for (int j = cx; j < EndPt[nEndPts - 1].x; j++)
|
|
2071 |
{
|
|
2072 |
Cells[cy][j].nType = typeLine1;
|
|
2073 |
}
|
|
2074 |
cx = EndPt[nEndPts - 1].x;
|
|
2075 |
}
|
|
2076 |
else {
|
|
2077 |
//前一行补齐
|
|
2078 |
for (int j = EndPt[nEndPts - 1].x; j < cx; j++)
|
|
2079 |
{
|
|
2080 |
Cells[EndPt[nEndPts - 1].y][j].nType = typeLine1;
|
|
2081 |
}
|
|
2082 |
|
|
2083 |
}
|
|
2084 |
//连接上下线
|
|
2085 |
for (int j = EndPt[nEndPts - 1].y; j < cy; j++)
|
|
2086 |
{
|
|
2087 |
Cells[j][cx].bLeftLineDn = 1;
|
|
2088 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
2089 |
}
|
|
2090 |
//光标位置, 前一结束点位置
|
|
2091 |
cy = EndPt[nEndPts - 1].y;
|
|
2092 |
nEndPts--;
|
|
2093 |
|
|
2094 |
break;
|
|
2095 |
case OP_NOT:
|
|
2096 |
Cells[cy][cx].nType = typeNOT;
|
|
2097 |
Cells[cy][cx].sCoilName = _T("NOT");
|
|
2098 |
|
|
2099 |
Cells[cy][cx].nProgStep = i;
|
|
2100 |
cx++;
|
|
2101 |
break;
|
|
2102 |
case OP_DF:
|
|
2103 |
case OP_DF_:
|
|
2104 |
Cells[cy][cx].nType = nOp == OP_DF ? typeDF : typeDF_;
|
|
2105 |
Cells[cy][cx].sCoilName = nOp == OP_DF ? _T("DF") : _T("DF/");
|
|
2106 |
|
|
2107 |
Cells[cy][cx].nProgStep = i;
|
|
2108 |
cx++;
|
|
2109 |
break;
|
|
2110 |
case OP_ANS:
|
|
2111 |
nSts--;
|
|
2112 |
nEndPts--;
|
|
2113 |
|
|
2114 |
break;
|
|
2115 |
case OP_ORS:
|
|
2116 |
// 当前序列与前面的序列合并。
|
|
2117 |
//当前序列的开始结束位置
|
|
2118 |
//EndPt[nEndPts] = POINT{ cx,cy };
|
|
2119 |
//nEndPts++;
|
|
2120 |
//StPts[nSts - 1]; EndPt[nEndPts - 1];
|
|
2121 |
//前一序列的开始结束位置
|
|
2122 |
StPts[nSts - 1]; EndPt[nEndPts - 1];
|
|
2123 |
//判断二者长度
|
|
2124 |
if (cx < EndPt[nEndPts - 1].x)
|
|
2125 |
{ //本行补齐
|
|
2126 |
for (int j = cx; j < EndPt[nEndPts - 1].x; j++)
|
|
2127 |
{
|
|
2128 |
Cells[cy][j].nType = typeLine1;
|
|
2129 |
}
|
|
2130 |
cx = EndPt[nEndPts - 1].x;
|
|
2131 |
}
|
|
2132 |
else {
|
|
2133 |
//前一行补齐
|
|
2134 |
for (int j = EndPt[nEndPts - 1].x; j < cx; j++)
|
|
2135 |
{
|
|
2136 |
Cells[EndPt[nEndPts - 1].y][j].nType = typeLine1;
|
|
2137 |
}
|
|
2138 |
|
|
2139 |
}
|
|
2140 |
//连接上下线
|
|
2141 |
for (int j = EndPt[nEndPts - 1].y; j < cy; j++)
|
|
2142 |
{
|
|
2143 |
Cells[j][cx].bLeftLineDn = 1;
|
|
2144 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
2145 |
}
|
|
2146 |
//光标位置, 前一结束点位置
|
|
2147 |
cy = EndPt[nEndPts - 1].y;
|
|
2148 |
nSts--;
|
|
2149 |
nEndPts--;
|
|
2150 |
|
|
2151 |
break;
|
|
2152 |
case OP_PSHS:
|
|
2153 |
EndPt[nEndPts] = POINT{ cx,cy };
|
|
2154 |
nEndPts++;
|
|
2155 |
break;
|
|
2156 |
case OP_RDS:
|
|
2157 |
cx = EndPt[nEndPts - 1].x;
|
|
2158 |
for (int j = cx; j < m_CellPerLine; j++) {
|
|
2159 |
if (Cells[cy][j].nType != 0)
|
|
2160 |
{
|
|
2161 |
cy++; j = cx - 1; //break;
|
|
2162 |
}
|
|
2163 |
}
|
|
2164 |
for (int j = EndPt[nEndPts - 1].y; j < cy; j++)
|
|
2165 |
{
|
|
2166 |
Cells[j][cx].bLeftLineDn = 1;
|
|
2167 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
2168 |
}
|
|
2169 |
break;
|
|
2170 |
case OP_POPS:
|
|
2171 |
cx = EndPt[nEndPts - 1].x;
|
|
2172 |
for (int j = cx; j < m_CellPerLine; j++) {
|
|
2173 |
if (Cells[cy][j].nType != 0)
|
|
2174 |
{
|
|
2175 |
cy++; j = cx - 1; break;
|
|
2176 |
}
|
|
2177 |
}
|
|
2178 |
for (int j = EndPt[nEndPts - 1].y; j < cy; j++)
|
|
2179 |
{
|
|
2180 |
Cells[j][cx].bLeftLineDn = 1;
|
|
2181 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
2182 |
}
|
|
2183 |
nEndPts--;
|
|
2184 |
|
|
2185 |
break;
|
|
2186 |
case OP_OUT:
|
|
2187 |
case OP_SET:
|
|
2188 |
case OP_RESET:
|
|
2189 |
nCellType = nOp == OP_OUT ? typeOUT : nOp == OP_SET ? typeSET : typeRESET;
|
|
2190 |
nCurLine = cy;
|
|
2191 |
if (cx <= m_CellPerLine) {
|
|
2192 |
|
|
2193 |
int hasData = 1;
|
|
2194 |
while (hasData) {
|
|
2195 |
hasData = 0;
|
|
2196 |
for (int j = cx; j < m_CellPerLine; j++) {
|
|
2197 |
if (Cells[nCurLine][j].nType != 0) {
|
|
2198 |
nCurLine++; hasData = 1; break;
|
|
2199 |
}
|
|
2200 |
}
|
|
2201 |
}
|
|
2202 |
//if (nCurLine > maxy) maxy = nCurLine;
|
|
2203 |
for (int j = cy; j < nCurLine; j++) {
|
|
2204 |
Cells[j][cx].bLeftLineDn = 1;
|
|
2205 |
Cells[j + 1][cx].bLeftLineUp = 1;
|
|
2206 |
}
|
|
2207 |
cy = nCurLine;
|
|
2208 |
for (int j = cx; j < m_CellPerLine; j++)
|
|
2209 |
{
|
|
2210 |
Cells[cy][j].nType = typeLine1;
|
|
2211 |
}
|
|
2212 |
Cells[cy][m_CellPerLine - 1].nType = nCellType;
|
|
2213 |
Cells[cy][m_CellPerLine - 1].nProgStep = i;
|
|
2214 |
Cells[cy][m_CellPerLine - 1].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
2215 |
Cells[cy][m_CellPerLine - 1].sCoilName = pDoc->Progs[i].Params[0].sParamStr;
|
|
2216 |
Cells[cy][m_CellPerLine - 1].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
2217 |
Cells[cy][m_CellPerLine - 1].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
2218 |
|
|
2219 |
}
|
|
2220 |
else {
|
|
2221 |
Cells[cy][cx].nType = nCellType;
|
|
2222 |
Cells[cy][cx].nProgStep = i;
|
|
2223 |
Cells[cy][cx].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
2224 |
Cells[cy][cx].sCoilName = pDoc->Progs[i].Params[0].sParamStr;
|
|
2225 |
Cells[cy][cx].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
2226 |
Cells[cy][cx].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
2227 |
}
|
|
2228 |
if (cy > maxy) { maxy = cy; }
|
|
2229 |
//cy++;
|
|
2230 |
break;
|
|
2231 |
|
|
2232 |
case OP_TML:
|
|
2233 |
case OP_TMR:
|
|
2234 |
case OP_TMX:
|
|
2235 |
case OP_TMY:
|
|
2236 |
Cells[cy][cx].nType = typeTM;
|
|
2237 |
Cells[cy][cx].nProgStep = i;
|
|
2238 |
Cells[cy][cx].sCoilName = ShowTxt;
|
|
2239 |
Cells[cy][cx + 1].nType = typeExt1;
|
|
2240 |
Cells[cy][cx + 1].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
2241 |
Cells[cy][cx + 1].nDataType = KLDataTypeEV;
|
|
2242 |
Cells[cy][cx + 1].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
2243 |
Cells[cy][cx + 2].nType = typeExt1;
|
|
2244 |
Cells[cy][cx + 2].sParam = pDoc->Progs[i].Params[1].sParamStr;
|
|
2245 |
Cells[cy][cx + 2].nDataType = pDoc->Progs[i].Params[1].nParamType;
|
|
2246 |
Cells[cy][cx + 2].nDataAddr = pDoc->Progs[i].Params[1].nParamAddr;
|
|
2247 |
cx += 3;
|
|
2248 |
break;
|
|
2249 |
case OP_INC:
|
|
2250 |
case OP_DEC:
|
|
2251 |
Cells[cy][cx].nType = typeFN1;
|
|
2252 |
Cells[cy][cx].nProgStep = i;
|
|
2253 |
Cells[cy][cx].sCoilName = ShowTxt;
|
|
2254 |
Cells[cy][cx + 1].nType = typeExt1;
|
|
2255 |
Cells[cy][cx + 1].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
2256 |
Cells[cy][cx + 1].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
2257 |
Cells[cy][cx + 1].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
2258 |
cx += 2;
|
|
2259 |
break;
|
|
2260 |
|
|
2261 |
case OP_MV:
|
|
2262 |
case OP_ADD2:
|
|
2263 |
case OP_SUB2:
|
|
2264 |
Cells[cy][cx].nType = typeFN2;
|
|
2265 |
Cells[cy][cx].nProgStep = i;
|
|
2266 |
Cells[cy][cx].sCoilName = ShowTxt;
|
|
2267 |
Cells[cy][cx + 1].nType = typeExt1;
|
|
2268 |
Cells[cy][cx + 1].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
2269 |
Cells[cy][cx + 1].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
2270 |
Cells[cy][cx + 1].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
2271 |
Cells[cy][cx + 2].nType = typeExt1;
|
|
2272 |
Cells[cy][cx + 2].sParam = pDoc->Progs[i].Params[1].sParamStr;
|
|
2273 |
Cells[cy][cx + 2].nDataType = pDoc->Progs[i].Params[1].nParamType;
|
|
2274 |
Cells[cy][cx + 2].nDataAddr = pDoc->Progs[i].Params[1].nParamAddr;
|
|
2275 |
cx += 3;
|
|
2276 |
break;
|
|
2277 |
|
|
2278 |
case OP_ADD3:
|
|
2279 |
case OP_SUB3:
|
|
2280 |
case OP_MUL:
|
|
2281 |
case OP_DIV:
|
|
2282 |
Cells[cy][cx].nType = typeFN3;
|
|
2283 |
Cells[cy][cx].nProgStep = i;
|
|
2284 |
Cells[cy][cx].sCoilName = ShowTxt;
|
|
2285 |
Cells[cy][cx + 1].nType = typeExt1;
|
|
2286 |
Cells[cy][cx + 1].sParam = pDoc->Progs[i].Params[0].sParamStr;
|
|
2287 |
Cells[cy][cx + 1].nDataType = pDoc->Progs[i].Params[0].nParamType;
|
|
2288 |
Cells[cy][cx + 1].nDataAddr = pDoc->Progs[i].Params[0].nParamAddr;
|
|
2289 |
Cells[cy][cx + 2].nType = typeExt1;
|
|
2290 |
Cells[cy][cx + 2].sParam = pDoc->Progs[i].Params[1].sParamStr;
|
|
2291 |
Cells[cy][cx + 2].nDataType = pDoc->Progs[i].Params[1].nParamType;
|
|
2292 |
Cells[cy][cx + 2].nDataAddr = pDoc->Progs[i].Params[1].nParamAddr;
|
|
2293 |
Cells[cy][cx + 3].nType = typeExt1;
|
|
2294 |
Cells[cy][cx + 3].sParam = pDoc->Progs[i].Params[2].sParamStr;
|
|
2295 |
Cells[cy][cx + 3].nDataType = pDoc->Progs[i].Params[2].nParamType;
|
|
2296 |
Cells[cy][cx + 3].nDataAddr = pDoc->Progs[i].Params[2].nParamAddr;
|
|
2297 |
cx += 4;
|
|
2298 |
break;
|
|
2299 |
|
|
2300 |
default:
|
|
2301 |
break;
|
|
2302 |
}
|
|
2303 |
}
|
|
2304 |
m_nTotalRow = maxy + 1;
|
|
2305 |
/*
|
|
2306 |
for (int i = 0; i < 25; i++)
|
|
2307 |
{
|
|
2308 |
for (int j = 0; j < 16; j++)
|
|
2309 |
{
|
|
2310 |
Cells[i][j].nType = i;
|
|
2311 |
s1.Format(_T("%d:%d"), i, j);
|
|
2312 |
Cells[i][j].sCoilName = s1;
|
|
2313 |
}
|
|
2314 |
}
|
|
2315 |
*/
|
|
2316 |
needReDraw = 1;
|
|
2317 |
return 0;
|
|
2318 |
}
|
|
2319 |
|
|
2320 |
|
|
2321 |
int CMTerm2View::TransLDSToProg()
|
|
2322 |
{
|
|
2323 |
// TODO: 在此处添加实现代码.
|
0a20f7
|
2324 |
CMTerm2Doc * pDoc = GetDocument();
|
0ed438
|
2325 |
CString s1;
|
Q |
2326 |
s1.Format(_T("Trans LDS to PRrog"));
|
|
2327 |
DbgLog(s1);
|
|
2328 |
|
|
2329 |
//梯形图 数量
|
|
2330 |
s1.Format(_T("Total Lines %d"), m_nTotalRow);
|
|
2331 |
DbgLog(s1);
|
|
2332 |
//分段
|
|
2333 |
int nDivCount = 0;
|
|
2334 |
int Divs[100] = { 0 };
|
|
2335 |
for (int i = 0; i < m_nTotalRow; i++) {
|
|
2336 |
int nRow = i;
|
|
2337 |
int bConnected = 0;
|
|
2338 |
for (int j = 0; j < m_CellPerLine; j++) {
|
|
2339 |
int nCol = j;
|
|
2340 |
if (Cells[nRow][nCol].bLeftLineDn) {
|
|
2341 |
bConnected = 1; break;
|
|
2342 |
}
|
|
2343 |
}
|
|
2344 |
if (!bConnected) {
|
|
2345 |
//找到一处分界点
|
|
2346 |
Divs[nDivCount] = i;
|
|
2347 |
s1.Format(_T("Div at Line %d "), nRow);
|
|
2348 |
DbgLog(s1);
|
|
2349 |
nDivCount++;
|
|
2350 |
}
|
|
2351 |
}
|
0a20f7
|
2352 |
stProgSection allprogs;
|
0ed438
|
2353 |
//每段单独处理
|
Q |
2354 |
for (int i = 0; i < nDivCount; i++) {
|
|
2355 |
int nStartLine, nEndLine;
|
|
2356 |
if (i == 0) { nStartLine = 0; nEndLine = Divs[i]; }
|
|
2357 |
else { nStartLine = Divs[i - 1]+1; nEndLine = Divs[i]; }
|
|
2358 |
s1.Format(_T("Process Line %d - %d "), nStartLine, nEndLine);
|
|
2359 |
DbgLog(s1);
|
|
2360 |
int nCounts[20] = { 0 };
|
|
2361 |
int nCounts2[20] = { 0 };
|
|
2362 |
int nCounts3[20] = { 0 };
|
|
2363 |
|
|
2364 |
s1.Empty();
|
|
2365 |
for (int j = 0; j < m_CellPerLine; j++) {
|
|
2366 |
int nCount = 0;
|
|
2367 |
int nCount2 = 0;
|
|
2368 |
int nCount3 = 0;
|
|
2369 |
for (int k = nStartLine; k <= nEndLine; k++) {
|
|
2370 |
if (Cells[k][j].nType) {
|
|
2371 |
nCount += 1;
|
|
2372 |
nCount2 += 1;
|
|
2373 |
nCount3 += 1;
|
|
2374 |
if (Cells[k][j].bLeftLineUp) nCount2 -= 1;
|
|
2375 |
// if (Cells[k][j].bLeftLineDn) nCount2 -= 1;
|
|
2376 |
if (j != m_CellPerLine - 1) {
|
|
2377 |
if (Cells[k][j + 1].bLeftLineUp) nCount3 -= 1;
|
|
2378 |
// if (Cells[k][j + 1].bLeftLineDn) nCount3 -= 1;
|
|
2379 |
}
|
|
2380 |
|
|
2381 |
}
|
|
2382 |
}
|
|
2383 |
nCounts[j] = nCount;
|
|
2384 |
nCounts2[j] = nCount2;
|
|
2385 |
nCounts3[j] = nCount3;
|
|
2386 |
}
|
|
2387 |
s1.Empty();
|
|
2388 |
for (int j = 0; j < m_CellPerLine; j++) {
|
|
2389 |
s1.AppendFormat(_T(" %d(%d)"), nCounts[j],nCounts3[j]);
|
|
2390 |
}
|
|
2391 |
DbgLog(s1);
|
|
2392 |
s1.Empty();
|
|
2393 |
for (int j = 0; j < m_CellPerLine; j++) {
|
|
2394 |
s1.AppendFormat(_T(" %d "), nCounts2[j]);
|
|
2395 |
}
|
|
2396 |
DbgLog(s1);
|
|
2397 |
//开始从左到右,从上到下扫描,主要关注 竖直连接线。
|
|
2398 |
int nCurPosX,nCurPosY;
|
|
2399 |
nCurPosY = nStartLine;
|
|
2400 |
nCurPosX = 0;
|
|
2401 |
CString sProg;
|
|
2402 |
int nAllSteps=0;
|
0a20f7
|
2403 |
stProgSection Progsec;
|
0ed438
|
2404 |
for (int i = nStartLine; i <= nEndLine; i++){
|
0a20f7
|
2405 |
CString sProgSec;
|
0ed438
|
2406 |
int nSteps = 0;;
|
Q |
2407 |
nCurPosY = i;
|
0a20f7
|
2408 |
stProgSection thisprogsec;
|
0ed438
|
2409 |
if (Cells[i][0].nType)
|
0a20f7
|
2410 |
ScanLDSCells(nStartLine, nEndLine, nCurPosY, nCurPosX, 0, thisprogsec, sProgSec,nSteps);
|
Q |
2411 |
sProg += sProgSec;
|
0ed438
|
2412 |
nAllSteps += nSteps;
|
0a20f7
|
2413 |
Progsec += thisprogsec;
|
0ed438
|
2414 |
}
|
Q |
2415 |
DbgLog(_T("\r\n")+ sProg);
|
65f713
|
2416 |
int n = int(Progsec.Progs.size());
|
0a20f7
|
2417 |
s1.Format(_T("progSec steps %d "), n);
|
Q |
2418 |
DbgLog(s1);
|
|
2419 |
for (int i = 0; i < n; i++) {
|
|
2420 |
int optype = Progsec.Progs[i].nOpType1;
|
|
2421 |
CStringA OpTxtA, OpShowTxtA;
|
|
2422 |
CString OpTxt, OpShowTxt;
|
|
2423 |
pDoc->OpToTxt(optype, OpTxtA);
|
|
2424 |
pDoc->OpToShowTxt(optype, OpShowTxtA);
|
|
2425 |
OpTxt = OpTxtA;
|
|
2426 |
OpShowTxt = OpShowTxtA;
|
|
2427 |
s1.Format(_T("%d %s %s"), optype, OpTxt, OpShowTxt);
|
|
2428 |
DbgLog(s1);
|
|
2429 |
}
|
|
2430 |
allprogs += Progsec;
|
0ed438
|
2431 |
}
|
Q |
2432 |
//输出程序
|
65f713
|
2433 |
int n=(int)allprogs.Progs.size();
|
0a20f7
|
2434 |
s1.Format(_T("all prog steps %d "), n);
|
Q |
2435 |
DbgLog(s1);
|
|
2436 |
for (int i = 0; i < n; i++) {
|
|
2437 |
int optype=allprogs.Progs[i].nOpType1;
|
|
2438 |
CStringA OpTxtA,OpShowTxtA;
|
|
2439 |
CString OpTxt,OpShowTxt;
|
|
2440 |
pDoc->OpToTxt(optype, OpTxtA);
|
|
2441 |
pDoc->OpToShowTxt(optype, OpShowTxtA);
|
|
2442 |
OpTxt = OpTxtA;
|
|
2443 |
OpShowTxt = OpShowTxtA;
|
|
2444 |
s1.Format(_T("%d %s %s"), optype, OpTxt, OpShowTxt);
|
65f713
|
2445 |
// DbgLog(s1);
|
0a20f7
|
2446 |
}
|
0ed438
|
2447 |
return 0;
|
Q |
2448 |
}
|
|
2449 |
|
0a20f7
|
2450 |
int CMTerm2View::ScanLDSCells(int nStartLine, int nEndLine, int nPosY, int nPosX, int nLevel, stProgSection & progsec, CString & sProgSec, int &nSteps)
|
0ed438
|
2451 |
{
|
Q |
2452 |
// TODO: 在此处添加实现代码.
|
|
2453 |
CString s1;
|
|
2454 |
int nCurPosX, nCurPosY;
|
|
2455 |
int nNextX = 1;
|
|
2456 |
nCurPosY = nPosY;
|
|
2457 |
nCurPosX = nPosX;
|
|
2458 |
|
|
2459 |
for (int j = nPosX; j < m_CellPerLine; j+=nNextX) {
|
|
2460 |
nCurPosX = j;
|
|
2461 |
//先处理当前单元;
|
|
2462 |
int nType = Cells[nCurPosY][nCurPosX].nType;
|
|
2463 |
CString sCellName = Cells[nCurPosY][nCurPosX].sCoilName;
|
0a20f7
|
2464 |
CMTerm2Doc::stProg theprog;
|
Q |
2465 |
|
0ed438
|
2466 |
if (nType == typeNO) {
|
Q |
2467 |
if (j==0) {
|
|
2468 |
s1.Format(_T("%d %d ST %s"), nCurPosY, nCurPosX,sCellName);
|
|
2469 |
sProgSec.AppendFormat(_T("ST %s\r\n"),sCellName);
|
0a20f7
|
2470 |
theprog.nOpType1 = OP_ST;
|
Q |
2471 |
progsec.Append(theprog);
|
0ed438
|
2472 |
}
|
Q |
2473 |
else {
|
|
2474 |
s1.Format(_T("%d %d AN %s"), nCurPosY, nCurPosX, sCellName);
|
|
2475 |
sProgSec.AppendFormat(_T("NO %s\r\n"), sCellName);
|
0a20f7
|
2476 |
theprog.nOpType1 = OP_AN;
|
Q |
2477 |
progsec.Append(theprog);
|
0ed438
|
2478 |
}
|
Q |
2479 |
nSteps += 1;
|
|
2480 |
DbgLog(s1);
|
|
2481 |
nNextX = 1;
|
|
2482 |
}else
|
|
2483 |
if (nType == typeNC) {
|
|
2484 |
if (j == 0) {
|
|
2485 |
s1.Format(_T("%d %d ST/ %s"), nCurPosY, nCurPosX, sCellName);
|
|
2486 |
sProgSec.AppendFormat(_T("ST/ %s\r\n"), sCellName);
|
0a20f7
|
2487 |
theprog.nOpType1 = OP_ST_;
|
Q |
2488 |
progsec.Append(theprog);
|
|
2489 |
|
0ed438
|
2490 |
}
|
Q |
2491 |
else
|
|
2492 |
{
|
|
2493 |
s1.Format(_T("%d %d AN/ %s"), nCurPosY, nCurPosX, sCellName);
|
|
2494 |
sProgSec.AppendFormat(_T("AN/ %s\r\n"), sCellName);
|
0a20f7
|
2495 |
theprog.nOpType1 = OP_AN_;
|
Q |
2496 |
progsec.Append(theprog);
|
0ed438
|
2497 |
}
|
Q |
2498 |
DbgLog(s1);
|
|
2499 |
nSteps += 1;
|
|
2500 |
nNextX = 1;
|
|
2501 |
}else
|
|
2502 |
if (nType == typePP) {
|
|
2503 |
s1.Format(_T("%d %d PP %s"), nCurPosY, nCurPosX, sCellName);
|
|
2504 |
DbgLog(s1);
|
0a20f7
|
2505 |
//progsec.Append(theprog);
|
0ed438
|
2506 |
sProgSec.AppendFormat(_T("PP %s\r\n"), sCellName);
|
Q |
2507 |
nSteps += 1;
|
|
2508 |
nNextX = 1;
|
|
2509 |
}else
|
|
2510 |
if (nType == typePN) {
|
|
2511 |
s1.Format(_T("%d %d PN %s"), nCurPosY, nCurPosX, sCellName);
|
|
2512 |
DbgLog(s1);
|
0a20f7
|
2513 |
//progsec.Append(theprog);
|
0ed438
|
2514 |
sProgSec.AppendFormat(_T("PN %s\r\n"), sCellName, sCellName);
|
Q |
2515 |
nSteps += 1;
|
|
2516 |
nNextX = 1;
|
|
2517 |
}else
|
|
2518 |
if (nType == typeNOT) {
|
|
2519 |
s1.Format(_T("%d %d NOT %s"), nCurPosY, nCurPosX, sCellName);
|
|
2520 |
DbgLog(s1);
|
|
2521 |
sProgSec.AppendFormat(_T("NOT %s\r\n"), sCellName);
|
0a20f7
|
2522 |
theprog.nOpType1 = OP_NOT;
|
Q |
2523 |
progsec.Append(theprog);
|
0ed438
|
2524 |
nSteps += 1;
|
Q |
2525 |
nNextX = 1;
|
|
2526 |
}else
|
|
2527 |
if (nType == typeDF) {
|
|
2528 |
s1.Format(_T("%d %d DF %s"), nCurPosY, nCurPosX, sCellName);
|
|
2529 |
DbgLog(s1);
|
|
2530 |
sProgSec.AppendFormat(_T("DF %s\r\n"), sCellName);
|
0a20f7
|
2531 |
theprog.nOpType1 = OP_DF;
|
Q |
2532 |
progsec.Append(theprog);
|
0ed438
|
2533 |
nSteps += 1;
|
Q |
2534 |
nNextX = 1;
|
|
2535 |
}else
|
|
2536 |
if (nType == typeDF_) {
|
|
2537 |
s1.Format(_T("%d %d DF/ %s"), nCurPosY, nCurPosX, sCellName);
|
|
2538 |
DbgLog(s1);
|
|
2539 |
sProgSec.AppendFormat(_T("DF/ %s\r\n"), sCellName);
|
0a20f7
|
2540 |
theprog.nOpType1 = OP_DF_;
|
Q |
2541 |
progsec.Append(theprog);
|
0ed438
|
2542 |
nSteps += 1;
|
Q |
2543 |
nNextX = 1;
|
|
2544 |
}else
|
|
2545 |
if (nType == typeOUT) {
|
|
2546 |
s1.Format(_T("%d %d OUT %s"), nCurPosY, nCurPosX, sCellName);
|
|
2547 |
DbgLog(s1);
|
|
2548 |
sProgSec.AppendFormat(_T("OUT %s\r\n"), sCellName);
|
0a20f7
|
2549 |
theprog.nOpType1 = OP_OUT;
|
Q |
2550 |
progsec.Append(theprog);
|
0ed438
|
2551 |
nSteps += 1;
|
Q |
2552 |
nNextX = 1;
|
|
2553 |
}else
|
|
2554 |
if (nType == typeSET) {
|
|
2555 |
s1.Format(_T("%d %d SET %s"), nCurPosY, nCurPosX, sCellName);
|
|
2556 |
DbgLog(s1);
|
|
2557 |
sProgSec.AppendFormat(_T("SET %s\r\n"), sCellName);
|
0a20f7
|
2558 |
theprog.nOpType1 = OP_SET;
|
Q |
2559 |
progsec.Append(theprog);
|
0ed438
|
2560 |
nSteps += 1;
|
Q |
2561 |
nNextX = 1;
|
|
2562 |
}else
|
|
2563 |
if (nType == typeRESET) {
|
|
2564 |
s1.Format(_T("%d %d RESET %s"), nCurPosY, nCurPosX, sCellName);
|
|
2565 |
DbgLog(s1);
|
|
2566 |
sProgSec.AppendFormat(_T("RESET %s\r\n"), sCellName);
|
0a20f7
|
2567 |
theprog.nOpType1 = OP_RESET;
|
Q |
2568 |
progsec.Append(theprog);
|
0ed438
|
2569 |
nSteps += 1;
|
Q |
2570 |
nNextX = 1;
|
|
2571 |
}else
|
|
2572 |
if (nType == typeCMP) {
|
|
2573 |
s1.Format(_T("%d %d CMP %s %s %s"), nCurPosY, nCurPosX, sCellName,Cells[nCurPosY][nCurPosX+1].sParam,Cells[nCurPosY][nCurPosX + 2].sParam);
|
|
2574 |
DbgLog(s1);
|
0a20f7
|
2575 |
theprog.nOpType1 = OP_ST_GT;
|
Q |
2576 |
progsec.Append(theprog);
|
0ed438
|
2577 |
sProgSec.AppendFormat(_T("CMP %s %s %s \r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
|
Q |
2578 |
nSteps += 1;
|
|
2579 |
nNextX = 3;
|
|
2580 |
}else
|
|
2581 |
if (nType == typeTM) {
|
|
2582 |
s1.Format(_T("%d %d TM %s %d %s"), nCurPosY, nCurPosX, sCellName,Cells[nCurPosY][nCurPosX+1].sParam,Cells[nCurPosY][nCurPosX + 2].sParam);
|
|
2583 |
DbgLog(s1);
|
0a20f7
|
2584 |
theprog.nOpType1 = OP_TMX;
|
Q |
2585 |
progsec.Append(theprog);
|
0ed438
|
2586 |
sProgSec.AppendFormat(_T("TM %s %d %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX+1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
|
Q |
2587 |
nSteps += 1;
|
|
2588 |
nNextX = 3;
|
|
2589 |
}else
|
|
2590 |
if (nType == typeFN1) {
|
|
2591 |
s1.Format(_T("%d %d FN1 %s %s"), nCurPosY, nCurPosX, sCellName,Cells[nCurPosY][nCurPosX + 1].sParam);
|
|
2592 |
DbgLog(s1);
|
0a20f7
|
2593 |
theprog.nOpType1 = OP_INC;
|
Q |
2594 |
progsec.Append(theprog);
|
0ed438
|
2595 |
sProgSec.AppendFormat(_T("FN1 %s %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam);
|
Q |
2596 |
nSteps += 1;
|
|
2597 |
nNextX = 2;
|
|
2598 |
}else
|
|
2599 |
if (nType == typeFN2) {
|
|
2600 |
s1.Format(_T("%d %d FN2 %s %s %s "), nCurPosY, nCurPosX, sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
|
|
2601 |
DbgLog(s1);
|
0a20f7
|
2602 |
theprog.nOpType1 = OP_MV;
|
Q |
2603 |
progsec.Append(theprog);
|
0ed438
|
2604 |
sProgSec.AppendFormat(_T("FN2 %s %s %s \r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
|
Q |
2605 |
nSteps += 1;
|
|
2606 |
nNextX = 3;
|
|
2607 |
}else
|
|
2608 |
if (nType == typeFN3) {
|
|
2609 |
s1.Format(_T("%d %d FN3 %s %s %s %s"), nCurPosY, nCurPosX, sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam, Cells[nCurPosY][nCurPosX + 3].sParam);
|
|
2610 |
DbgLog(s1);
|
0a20f7
|
2611 |
theprog.nOpType1 = OP_ADD3;
|
Q |
2612 |
progsec.Append(theprog);
|
0ed438
|
2613 |
sProgSec.AppendFormat(_T("FN3 %s %s %s %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam, Cells[nCurPosY][nCurPosX + 3].sParam);
|
Q |
2614 |
nSteps += 1;
|
|
2615 |
nNextX = 4;
|
|
2616 |
}else {
|
|
2617 |
nNextX = 1;
|
|
2618 |
//continue;
|
|
2619 |
}
|
0a20f7
|
2620 |
|
0ed438
|
2621 |
if (j + nNextX >= m_CellPerLine) continue;
|
Q |
2622 |
if (Cells[nCurPosY][j + nNextX].bLeftLineUp || Cells[nCurPosY][j + nNextX].bLeftLineDn) { // 发现竖线
|
|
2623 |
//先看往上面有没有连接
|
|
2624 |
if (Cells[nCurPosY][j + nNextX].bLeftLineUp) { // 往上面有连接
|
|
2625 |
s1.Format(_T("%d %d ORS "), nCurPosY, nCurPosX);
|
|
2626 |
DbgLog(s1);
|
0a20f7
|
2627 |
theprog.nOpType1 = OP_ORS;
|
Q |
2628 |
progsec.Append(theprog);
|
0ed438
|
2629 |
sProgSec.AppendFormat(_T("ORS \r\n"));
|
Q |
2630 |
nSteps += 1;
|
|
2631 |
nLevel -= 1;
|
|
2632 |
}
|
|
2633 |
int nLeftUpCon = 0;
|
|
2634 |
if (Cells[nCurPosY][j + nNextX].bLeftLineUp ) nLeftUpCon = 1;
|
|
2635 |
//向下查找,看看竖线的左侧下面还有没有连接其他东西/
|
|
2636 |
int nLeftDnCon = 0;
|
|
2637 |
for (int k = nCurPosY + 1; k <= nEndLine; k++) {
|
|
2638 |
if (!Cells[k][j + nNextX].bLeftLineUp) break; // 竖线到最下面的端点了。
|
|
2639 |
if (Cells[k][j + nNextX - 1 ].nType) { nLeftDnCon += 1; break; }
|
|
2640 |
}
|
|
2641 |
s1.Format(_T("LeftUp %d LeftDn %d"), nLeftUpCon, nLeftDnCon);
|
|
2642 |
DbgLog(s1);
|
|
2643 |
if (nLeftDnCon) { //左侧有连接,那么扫描到这个竖线,继续扫描左侧下面的内容。
|
|
2644 |
|
|
2645 |
return 1;
|
|
2646 |
}
|
|
2647 |
if (!nLeftDnCon) {// 左侧下面没有连接,那么这个就是左面最后的单元,开始处理右面的单元。
|
|
2648 |
if (nLeftUpCon) {
|
|
2649 |
if ( nPosX >0 || nLevel > 0) {
|
|
2650 |
s1.Format(_T("%d %d ANS "), nCurPosY, nCurPosX);
|
|
2651 |
DbgLog(s1);
|
0a20f7
|
2652 |
theprog.nOpType1 = OP_ANS;
|
Q |
2653 |
progsec.Append(theprog);
|
0ed438
|
2654 |
sProgSec.AppendFormat(_T("ANS \r\n"));
|
Q |
2655 |
nSteps += 1;
|
|
2656 |
nLevel -= 1;
|
|
2657 |
}
|
|
2658 |
|
|
2659 |
}
|
|
2660 |
//从头到尾处理, 查找此竖线的最高位置;
|
|
2661 |
int nLineTop = nCurPosY;
|
|
2662 |
int nLineBottom = nCurPosY;
|
|
2663 |
for (int k = nCurPosY; k >= nStartLine; k--)
|
|
2664 |
{
|
|
2665 |
if (!Cells[k][j + nNextX].bLeftLineUp) { break; }
|
|
2666 |
nLineTop = k -1;
|
|
2667 |
}
|
|
2668 |
// 查找右侧有几个连接
|
|
2669 |
int nRightCon = 0;
|
|
2670 |
for (int k = nLineTop; k <= nEndLine; k++) {
|
|
2671 |
if (Cells[k][j + nNextX].nType) { nRightCon += 1; }
|
|
2672 |
nLineBottom = k;
|
|
2673 |
if (!Cells[k][j + nNextX].bLeftLineDn) { break; }
|
|
2674 |
}
|
|
2675 |
s1.Format(_T("VLine %d - %d : %d , right = %d "), nLineTop,nLineBottom,j+nNextX,nRightCon);
|
|
2676 |
DbgLog(s1);
|
|
2677 |
if (nRightCon == 1) {
|
|
2678 |
s1.Format(_T(">>>> Go %d : %d , level %d "), nLineTop, j + nNextX, nLevel);
|
|
2679 |
DbgLog(s1);
|
|
2680 |
CString ProgSec;
|
|
2681 |
int theSteps = 0;
|
0a20f7
|
2682 |
stProgSection thisprogsec;
|
Q |
2683 |
int r = ScanLDSCells(nStartLine, nEndLine, nLineTop, j + nNextX, nLevel,thisprogsec, ProgSec,theSteps);
|
0ed438
|
2684 |
sProgSec += ProgSec;
|
Q |
2685 |
nSteps += theSteps;
|
0a20f7
|
2686 |
progsec += thisprogsec;
|
0ed438
|
2687 |
s1.Format(_T("<<<< Re %d : %d , Result %d "), nLineTop, j + nNextX, r);
|
Q |
2688 |
DbgLog(s1);
|
|
2689 |
}
|
|
2690 |
else
|
|
2691 |
{
|
|
2692 |
int nLastResult = 0;
|
|
2693 |
int nRightCount = 0;
|
|
2694 |
CString sCons[100];
|
|
2695 |
CString ProgSecs[100];
|
|
2696 |
int res[100] = { 0 };
|
|
2697 |
int nLastSteps = 0;
|
|
2698 |
for (int k = nLineTop; k <= nLineBottom; k++)
|
|
2699 |
{
|
|
2700 |
//s1.Format(_T("VLine %d - %d : %d %d of %d "), nLineTop, nLineBottom, j + nNextX, k+1,nRightCon);
|
|
2701 |
//DbgLog(s1);
|
|
2702 |
if (Cells[k][j + nNextX].nType) {
|
|
2703 |
s1.Format(_T(" >>> Go %d : %d , level %d "), k, j + nNextX, nLevel +1);
|
|
2704 |
DbgLog(s1);
|
|
2705 |
CString ProgSec;
|
|
2706 |
int theSteps = 0;
|
|
2707 |
nLevel += 1;
|
0a20f7
|
2708 |
stProgSection thisprogsec;
|
Q |
2709 |
res[nRightCount] = ScanLDSCells(nStartLine, nEndLine, k, j + nNextX, nLevel ,thisprogsec,ProgSecs[nRightCount],theSteps);
|
0ed438
|
2710 |
nLastResult = res[nRightCount];
|
Q |
2711 |
nSteps += theSteps;
|
0a20f7
|
2712 |
progsec += thisprogsec;
|
0ed438
|
2713 |
//if (res[nRightCount] > 0) nLevel += 1;
|
Q |
2714 |
sProgSec += ProgSec;
|
|
2715 |
s1.Format(_T(" <<< Re %d : %d , Result %d Steps %d Last %d"), k, j + nNextX, res[nRightCount],theSteps,nLastSteps);
|
|
2716 |
DbgLog(s1);
|
|
2717 |
if (nRightCount == 0) {
|
|
2718 |
}
|
|
2719 |
else if (res[nRightCount-1] == 0) {
|
|
2720 |
s1.Format(_T(" POPS"), k, j + nNextX, nLevel + 1);
|
|
2721 |
DbgLog(s1);
|
|
2722 |
//sProgSec.AppendFormat(_T("POPS \r\n"));
|
|
2723 |
if (nLastSteps > 1)
|
|
2724 |
{
|
|
2725 |
if (sCons[nRightCount - 1] == _T("POPS")) { sCons[nRightCount - 1] = _T("RDS"); }
|
|
2726 |
else { sCons[nRightCount - 1] = _T("PSHS"); }
|
|
2727 |
sCons[nRightCount] = _T("POPS");
|
|
2728 |
}
|
|
2729 |
}
|
|
2730 |
else {
|
|
2731 |
|
|
2732 |
}
|
|
2733 |
nLastSteps = theSteps;
|
|
2734 |
nRightCount++;
|
|
2735 |
}
|
|
2736 |
}
|
|
2737 |
nLastResult = 0;
|
|
2738 |
for (int k = 0; k < nRightCount; k++)
|
|
2739 |
{
|
|
2740 |
if (nLastResult || res[k]) { s1 = _T("ST") + ProgSecs[k]; ProgSecs[k] =s1; }
|
|
2741 |
s1= sCons[k] + _T("\r\n") + ProgSecs[k];
|
|
2742 |
sProgSec.Append(s1);
|
|
2743 |
nLastResult = res[k];
|
|
2744 |
}
|
|
2745 |
if (nLastResult) sProgSec.Append(_T("ANS\r\n"));
|
|
2746 |
return 0;
|
|
2747 |
}
|
|
2748 |
}
|
|
2749 |
}
|
|
2750 |
}
|
|
2751 |
return 0;
|
|
2752 |
}
|
e00d5a
|
2753 |
|