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