提交 | 用户 | age
|
0ed438
|
1 |
|
418cb3
|
2 |
// MultiTerminal2View.h: CMTerm1View 类的接口
|
0ed438
|
3 |
//
|
Q |
4 |
|
|
5 |
#pragma once
|
|
6 |
|
418cb3
|
7 |
#include <memory>
|
Q |
8 |
#include <vector>
|
4ed7fc
|
9 |
#include <stack>
|
0ed438
|
10 |
|
418cb3
|
11 |
#include "MTerm1Doc.h"
|
Q |
12 |
class CMTerm1View : public CScrollView
|
0ed438
|
13 |
{
|
Q |
14 |
protected: // 仅从序列化创建
|
|
15 |
CMTerm1View() noexcept;
|
|
16 |
DECLARE_DYNCREATE(CMTerm1View)
|
|
17 |
|
|
18 |
// 特性
|
|
19 |
public:
|
418cb3
|
20 |
CMFCStatusBar * m_pStatusBar;
|
0ed438
|
21 |
CMTerm1Doc* GetDocument() const;
|
418cb3
|
22 |
|
Q |
23 |
//从文档获取程序
|
|
24 |
|
|
25 |
//文档变动通知
|
|
26 |
enum enCellType{
|
|
27 |
typeNone=0,
|
|
28 |
typeLine1=1, //横线
|
|
29 |
typeLine2, //竖线
|
|
30 |
typeLine3,
|
|
31 |
typeLine4,
|
|
32 |
typeLine5,
|
|
33 |
typeLine6,
|
|
34 |
typeLine7,
|
|
35 |
typeLine8,
|
|
36 |
typeLine9,
|
|
37 |
typeLine10,
|
|
38 |
typeLine11,
|
|
39 |
|
|
40 |
typeNO=12,
|
|
41 |
typeNC=13,
|
|
42 |
typePP=14, //上升沿
|
|
43 |
typePN=15, //下降沿
|
|
44 |
typeNOT=16,
|
|
45 |
typeDF = 17,
|
ad1b4b
|
46 |
|
418cb3
|
47 |
typeDF_ = 18,
|
Q |
48 |
typeOUT=19,
|
|
49 |
typeSET=20,
|
|
50 |
typeRESET=21,
|
|
51 |
|
|
52 |
typeCMP,
|
df0321
|
53 |
typeExt1, //23 0x17 //被前面的指令占用的空间
|
418cb3
|
54 |
typeExt2,
|
Q |
55 |
typeExt3,
|
|
56 |
|
|
57 |
typeTM=30, //定时器
|
|
58 |
typeFN1=40, //1个参数的函数
|
|
59 |
typeFN2=50, //2个参数的函数
|
|
60 |
typeFN3=60, //3个参数的函数
|
|
61 |
|
|
62 |
typeCoil=99,
|
|
63 |
|
|
64 |
};
|
|
65 |
struct stCell
|
|
66 |
{
|
df0321
|
67 |
int nType; //单元类型。
|
Q |
68 |
int nProgStep; //对应程序的步数
|
|
69 |
int bFocused = 0; //热点选中
|
|
70 |
int bSelected = 0; //选中
|
|
71 |
int bEditing = 0; //编辑中
|
|
72 |
int bModified = 0; //被修改了
|
418cb3
|
73 |
|
df0321
|
74 |
int bErrFocus = 0; //错误热点
|
418cb3
|
75 |
|
df0321
|
76 |
int bLeftLineUp = 0; //左侧向上竖线
|
Q |
77 |
int bLeftLineDn = 0; //左侧向下竖线
|
|
78 |
int nStat = 0; //当前状态// 监控时根据状态,显示数值或色块
|
|
79 |
int nTrace = 0; //当前跟踪状态
|
|
80 |
// int nDataWidth = 0;
|
|
81 |
int nDataType=0; //参数数据类型
|
|
82 |
int nDataAddr=0; //参数数据地址/值
|
|
83 |
CString sParam; //参数名
|
|
84 |
CString sCoilName; //线圈名
|
418cb3
|
85 |
void clear() {
|
Q |
86 |
nType = 0; bFocused = 0; bSelected = 0; bEditing = 0; bModified = 0;
|
|
87 |
bLeftLineUp = 0; bLeftLineDn = 0; nStat = 0;
|
df0321
|
88 |
nDataType = 0; nDataAddr = 0;
|
418cb3
|
89 |
sParam.Empty(); sCoilName.Empty();
|
Q |
90 |
}
|
|
91 |
};
|
|
92 |
stCell Cells[2000][16] = { 0 };
|
|
93 |
|
|
94 |
struct stProgSection
|
|
95 |
{
|
|
96 |
std::vector <CMTerm1Doc::stProg> Progs;
|
|
97 |
int Append(CMTerm1Doc::stProg prog) {
|
|
98 |
Progs.push_back(prog);
|
|
99 |
return 0;
|
|
100 |
};
|
|
101 |
int Append(struct stProgSection progsec){
|
|
102 |
int n=(int)progsec.Progs.size();
|
|
103 |
for (int i = 0; i < n; i++) {
|
|
104 |
Progs.push_back(progsec.Progs[i]);
|
|
105 |
}
|
|
106 |
return 0;
|
|
107 |
};
|
|
108 |
int operator+=(const struct stProgSection progsec) {
|
|
109 |
Append(progsec);
|
|
110 |
return 0;
|
|
111 |
};
|
|
112 |
|
|
113 |
int Insert(CMTerm1Doc::stProg prog) {
|
|
114 |
Progs.insert(Progs.begin(), prog);
|
|
115 |
return 0;
|
|
116 |
}
|
|
117 |
};
|
|
118 |
|
|
119 |
int m_nTotalRow=0;
|
|
120 |
bool m_bMonitoring = false; //监控中
|
|
121 |
bool m_bShowComments = true; //显示注释
|
|
122 |
|
|
123 |
bool m_bEditing = false;
|
|
124 |
|
|
125 |
int m_TopMargin = 0;
|
|
126 |
int m_LeftMargin = 54; //左侧边距
|
|
127 |
int m_CellPerLine = 16; //每行单元数
|
d34256
|
128 |
int m_CellWidth = 64; //单元宽度
|
418cb3
|
129 |
int m_CellHeight = 28; //单元高度
|
Q |
130 |
int m_CommentHeight = 32; //注释高度
|
|
131 |
|
|
132 |
int m_LinePosY = 20; //元件显示位置
|
|
133 |
|
d34256
|
134 |
int m_FocusRow = 0; //焦点行列位置
|
418cb3
|
135 |
int m_FocusCol = 0;
|
d34256
|
136 |
|
418cb3
|
137 |
int m_oldFocusRow = 0;
|
Q |
138 |
int m_oldFocusCol = 0;
|
|
139 |
int m_nCurProgStep = 0;
|
|
140 |
int m_TextFontSize=13;
|
|
141 |
int m_nAnnoFontSize=12;
|
|
142 |
|
|
143 |
int m_bModified = 1;
|
|
144 |
|
|
145 |
COLORREF BkColor = RGB(255,255,255); //Cell背景颜色
|
|
146 |
COLORREF BkEditColor = RGB(192, 192, 192); //Editing Cell 背景颜色
|
|
147 |
|
|
148 |
COLORREF TextColor =RGB(0,0,0);
|
|
149 |
COLORREF FocusColor = RGB(128,255,128);
|
|
150 |
COLORREF SelectedColor;
|
|
151 |
COLORREF EditColor;
|
|
152 |
COLORREF AnnoColor = RGB(0,0,255);
|
|
153 |
COLORREF BlockAnnoColor;
|
|
154 |
COLORREF MonCoilColor= RGB(0,255,255);
|
|
155 |
COLORREF MonTextColor = RGB(0, 128, 255);
|
|
156 |
|
|
157 |
COLORREF TraceBkColor = RGB(204,204,204);
|
|
158 |
COLORREF TraceColor = RGB(0,255,255);
|
|
159 |
COLORREF ForceIOColor;
|
|
160 |
|
|
161 |
COLORREF OnlineColor = RGB(0, 255, 255);
|
|
162 |
COLORREF ProgColor = RGB(0, 255, 0);
|
|
163 |
COLORREF RunningColor = RGB(0, 255, 0);
|
|
164 |
COLORREF MonitorColor = RGB(0, 255, 255);
|
|
165 |
COLORREF AddressColor = RGB(0, 255, 255);
|
|
166 |
|
|
167 |
CFont TextFont;
|
|
168 |
// CFont * pOldFont;
|
|
169 |
CFont MonTextFont;
|
|
170 |
CFont AnnoFont;
|
|
171 |
|
|
172 |
|
|
173 |
enum StatusBarIndicators {
|
|
174 |
idxMachineType = 0,
|
|
175 |
idxProgPos = 1,
|
|
176 |
idxOnline = 2,
|
|
177 |
idxRunning = 3,
|
|
178 |
idxMonitor = 4,
|
|
179 |
idxAddress = 5,
|
|
180 |
idxInfoDisp = 6,
|
|
181 |
};
|
|
182 |
|
|
183 |
// CBrush brBkColor(BkColor);
|
|
184 |
|
0ed438
|
185 |
|
Q |
186 |
// 操作
|
|
187 |
public:
|
418cb3
|
188 |
void DrawFocusRect(CDC* pDC);
|
Q |
189 |
int DrawLeftRightLine(CDC* pDC, int x0, int y0, int size1=16, int size2=12);
|
|
190 |
void DrawRelay(CDC* pDC, int x0, int y0);
|
|
191 |
int DrawBracket(CDC* pDC, int x0, int y0, int sizex, int sty=0, int sizey = 24);
|
|
192 |
int DrawAngleBracket(CDC* pDC, int x0, int y0, int sizex, int size2);
|
|
193 |
void DrawOT(CDC* pDC, int x0, int y0);
|
|
194 |
|
|
195 |
int DrawCellStat1(CDC * pDC, int x1, int y1, int sizex, int sizey, int nStat);
|
|
196 |
int DrawCellStat2(CDC* pDC, int x1, int y1, int sizex, int sizey, int nStat);
|
|
197 |
int DrawCellText1(CDC* pDC, CString sText, int x1, int y1, int sizex, int sizey, int nFormat=0);
|
|
198 |
int DrawCellText2(CDC* pDC, CString sText, int x1, int y1, int sizex, int sizey, int nFormat, int nTextColor);
|
|
199 |
int DrawCellAnno(CDC * pDC, int nRow, int nCol, CString sAnno);
|
|
200 |
|
|
201 |
void DrawCell(CDC* pDC, int nRow, int nCol);
|
|
202 |
int TransProgToLDS();
|
d34256
|
203 |
|
Z |
204 |
/// <summary>
|
|
205 |
/// Flag::是否需要重绘视图,默认为1=>true
|
|
206 |
/// </summary>
|
418cb3
|
207 |
int needReDraw = 1;
|
Q |
208 |
|
|
209 |
int DoReDraw();
|
|
210 |
int DrawLDSGraph(CDC* pDC);
|
|
211 |
|
|
212 |
int ScrollToCell(int nRow, int nCol);
|
|
213 |
|
|
214 |
int ScrollCellIntoView(int nRow, int nCol);
|
|
215 |
int isCellInView(int nRow, int nCol);
|
df0321
|
216 |
int CellFocusChg(int nRow, int nCol);
|
0ed438
|
217 |
|
ad1b4b
|
218 |
std::pair<int, CString> CMTerm1View::LDSCheckRule();
|
Z |
219 |
|
0ed438
|
220 |
// 重写
|
Q |
221 |
public:
|
|
222 |
virtual void OnDraw(CDC* pDC); // 重写以绘制该视图
|
|
223 |
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
|
|
224 |
protected:
|
418cb3
|
225 |
virtual void OnInitialUpdate(); // 构造后第一次调用
|
0ed438
|
226 |
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
|
Q |
227 |
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
|
|
228 |
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
|
|
229 |
|
|
230 |
// 实现
|
|
231 |
public:
|
|
232 |
virtual ~CMTerm1View();
|
|
233 |
#ifdef _DEBUG
|
|
234 |
virtual void AssertValid() const;
|
|
235 |
virtual void Dump(CDumpContext& dc) const;
|
418cb3
|
236 |
|
0ed438
|
237 |
#endif
|
Q |
238 |
|
|
239 |
protected:
|
|
240 |
|
|
241 |
// 生成的消息映射函数
|
|
242 |
protected:
|
|
243 |
DECLARE_MESSAGE_MAP()
|
418cb3
|
244 |
public:
|
Q |
245 |
afx_msg void OnMonitor();
|
|
246 |
afx_msg void OnUpdateMonitor(CCmdUI *pCmdUI);
|
|
247 |
afx_msg void OnProgConvert();
|
|
248 |
afx_msg void OnUpdateProgConvert(CCmdUI *pCmdUI);
|
|
249 |
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
|
250 |
afx_msg void OnRectSelect();
|
|
251 |
afx_msg void OnUpdateRectSelect(CCmdUI *pCmdUI);
|
|
252 |
afx_msg void OnTextFirst();
|
|
253 |
afx_msg void OnUpdateTextFirst(CCmdUI *pCmdUI);
|
|
254 |
afx_msg void OnInsertBlankLine();
|
|
255 |
afx_msg void OnUpdateInsertBlankLine(CCmdUI *pCmdUI);
|
|
256 |
afx_msg void OnDeleteBlankLine();
|
|
257 |
afx_msg void OnUpdateDeleteBlankLine(CCmdUI *pCmdUI);
|
|
258 |
afx_msg void OnDisplayComments();
|
|
259 |
afx_msg void OnUpdateDisplayComments(CCmdUI *pCmdUI);
|
|
260 |
|
|
261 |
afx_msg void OnUpdateMachineType(CCmdUI *pCmdUI);
|
|
262 |
afx_msg void OnUpdateProgramPos(CCmdUI *pCmdUI);
|
|
263 |
afx_msg void OnUpdateConnectivity(CCmdUI *pCmdUI);
|
|
264 |
afx_msg void OnUpdateRunStatus(CCmdUI *pCmdUI);
|
|
265 |
afx_msg void OnUpdateMonitorStatus(CCmdUI *pCmdUI);
|
|
266 |
afx_msg void OnUpdateTargetAddress(CCmdUI *pCmdUI);
|
|
267 |
|
|
268 |
int UpdateStatusBar(int nIndex=-1);
|
|
269 |
|
|
270 |
virtual void OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/);
|
|
271 |
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
|
|
272 |
afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
|
|
273 |
afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
|
|
274 |
afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
|
|
275 |
afx_msg void OnRButtonUp(UINT nFlags, CPoint point);
|
|
276 |
|
|
277 |
afx_msg void OnIndicatorMonitorStatus();
|
|
278 |
afx_msg void OnUpdateIndicators(CCmdUI *pCmdUI);
|
|
279 |
|
|
280 |
afx_msg void OnUpdateIndicatorMonitorStatus(CCmdUI *pCmdUI);
|
|
281 |
afx_msg void OnTimer(UINT_PTR nIDEvent);
|
|
282 |
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
|
283 |
afx_msg void OnSize(UINT nType, int cx, int cy);
|
|
284 |
virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE);
|
|
285 |
|
|
286 |
afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/);
|
|
287 |
afx_msg void OnProgCancelEdit();
|
|
288 |
afx_msg void OnUpdateProgCancelEdit(CCmdUI *pCmdUI);
|
|
289 |
afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu);
|
|
290 |
int TransLDSToProg();
|
|
291 |
afx_msg void OnInputIoComment();
|
|
292 |
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
|
|
293 |
int ScanLDSCells(int nStartLine, int nEndLine, int nPosY, int nPosX, int nLevel, stProgSection & progsec, CString & sProgSec, int &nSteps);
|
4ed7fc
|
294 |
int ScanLDSCells2(int nStartLine, int nEndLine, int nPosY, int nPosX, int nSizeX, int nLevel, stProgSection& progsec, CString& sProgSec, int& nSteps);
|
Z |
295 |
int CMTerm1View::Translate2Prog(
|
|
296 |
int nType, int nCurPosY, int nCurPosX, CString sCellName,
|
|
297 |
stProgSection& progsec, CString& sProgSec, int& nSteps);
|
ad1b4b
|
298 |
void SetCellToView(stCell cell1, int flag = 0);//modify0919zxd
|
d34256
|
299 |
|
0ed438
|
300 |
};
|
Q |
301 |
|
418cb3
|
302 |
#ifndef _DEBUG // MultiTerminal2View.cpp 中的调试版本
|
0ed438
|
303 |
inline CMTerm1Doc* CMTerm1View::GetDocument() const
|
Q |
304 |
{ return reinterpret_cast<CMTerm1Doc*>(m_pDocument); }
|
|
305 |
#endif
|
|
306 |
|