From 4dfb88353b3671a71bc397d5f210d71f67f8fb04 Mon Sep 17 00:00:00 2001 From: QuakeGod <quakegod@sina.com> Date: 星期一, 23 十月 2023 15:17:10 +0800 Subject: [PATCH] fix1 --- MTerm1/MTerm1View.h | 271 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 265 insertions(+), 6 deletions(-) diff --git a/MTerm1/MTerm1View.h b/MTerm1/MTerm1View.h index cf0c9b4..8647820 100644 --- a/MTerm1/MTerm1View.h +++ b/MTerm1/MTerm1View.h @@ -1,11 +1,15 @@ 锘� -// MTerm1View.h: CMTerm1View 绫荤殑鎺ュ彛 +// MultiTerminal2View.h: CMTerm1View 绫荤殑鎺ュ彛 // #pragma once +#include <memory> +#include <vector> +#include <stack> -class CMTerm1View : public CView +#include "MTerm1Doc.h" +class CMTerm1View : public CScrollView { protected: // 浠呬粠搴忓垪鍖栧垱寤� CMTerm1View() noexcept; @@ -13,16 +17,217 @@ // 鐗规�� public: + CMFCStatusBar * m_pStatusBar; CMTerm1Doc* GetDocument() const; + + //浠庢枃妗h幏鍙栫▼搴� + + //鏂囨。鍙樺姩閫氱煡 + enum enCellType{ + typeNone=0, + typeLine1=1, //妯嚎 + typeLine2, //绔栫嚎 + typeLine3, + typeLine4, + typeLine5, + typeLine6, + typeLine7, + typeLine8, + typeLine9, + typeLine10, + typeLine11, + + typeNO=12, + typeNC=13, + typePP=14, //涓婂崌娌� + typePN=15, //涓嬮檷娌� + typeNOT=16, + typeDF = 17, + + typeDF_ = 18, + typeOUT=19, + typeSET=20, + typeRESET=21, + + typeCMP, + typeExt1, //23 0x17 //琚墠闈㈢殑鎸囦护鍗犵敤鐨勭┖闂� + typeExt2, + typeExt3, + + typeTM=30, //瀹氭椂鍣� + typeFN1=40, //1涓弬鏁扮殑鍑芥暟 + typeFN2=50, //2涓弬鏁扮殑鍑芥暟 + typeFN3=60, //3涓弬鏁扮殑鍑芥暟 + + typeCoil=99, + + }; + struct stCell + { + int nType; //鍗曞厓绫诲瀷銆� + int nProgStep; //瀵瑰簲绋嬪簭鐨勬鏁� + int bFocused = 0; //鐑偣閫変腑 + int bSelected = 0; //閫変腑 + int bEditing = 0; //缂栬緫涓� + int bModified = 0; //琚慨鏀逛簡 + + int bErrFocus = 0; //閿欒鐑偣 + + int bLeftLineUp = 0; //宸︿晶鍚戜笂绔栫嚎 + int bLeftLineDn = 0; //宸︿晶鍚戜笅绔栫嚎 + int nStat = 0; //褰撳墠鐘舵��// 鐩戞帶鏃舵牴鎹姸鎬侊紝鏄剧ず鏁板�兼垨鑹插潡 + int nTrace = 0; //褰撳墠璺熻釜鐘舵�� +// int nDataWidth = 0; + int nDataType=0; //鍙傛暟鏁版嵁绫诲瀷 + int nDataAddr=0; //鍙傛暟鏁版嵁鍦板潃/鍊� + CString sParam; //鍙傛暟鍚� + CString sCoilName; //绾垮湀鍚� + void clear() { + nType = 0; bFocused = 0; bSelected = 0; bEditing = 0; bModified = 0; + bLeftLineUp = 0; bLeftLineDn = 0; nStat = 0; + nDataType = 0; nDataAddr = 0; + sParam.Empty(); sCoilName.Empty(); + } + }; + stCell Cells[2000][16] = { 0 }; + + struct stProgSection + { + std::vector <CMTerm1Doc::stProg> Progs; + int Append(CMTerm1Doc::stProg prog) { + Progs.push_back(prog); + return 0; + }; + int Append(struct stProgSection progsec){ + int n=(int)progsec.Progs.size(); + for (int i = 0; i < n; i++) { + Progs.push_back(progsec.Progs[i]); + } + return 0; + }; + int operator+=(const struct stProgSection progsec) { + Append(progsec); + return 0; + }; + + int Insert(CMTerm1Doc::stProg prog) { + Progs.insert(Progs.begin(), prog); + return 0; + } + }; + std::pair<int, int> popsPoint[100]; + + int nPSHS = -1; + bool firstCoil = true;//鏈绗竴涓崟鍏冩牸 + + bool isPops = false; + int m_nTotalRow=0; + bool m_bMonitoring = false; //鐩戞帶涓� + bool m_bShowComments = true; //鏄剧ず娉ㄩ噴 + + bool m_bEditing = false; + + int m_TopMargin = 0; + int m_LeftMargin = 54; //宸︿晶杈硅窛 + int m_CellPerLine = 16; //姣忚鍗曞厓鏁� + int m_CellWidth = 64; //鍗曞厓瀹藉害 + int m_CellHeight = 28; //鍗曞厓楂樺害 + int m_CommentHeight = 32; //娉ㄩ噴楂樺害 + + int m_LinePosY = 20; //鍏冧欢鏄剧ず浣嶇疆 + + int m_FocusRow = 0; //鐒︾偣琛屽垪浣嶇疆 + int m_FocusCol = 0; + + int m_oldFocusRow = 0; + int m_oldFocusCol = 0; + int m_nCurProgStep = 0; + int m_TextFontSize=13; + int m_nAnnoFontSize=12; + + int m_bModified = 1; + + COLORREF BkColor = RGB(255,255,255); //Cell鑳屾櫙棰滆壊 + COLORREF BkEditColor = RGB(192, 192, 192); //Editing Cell 鑳屾櫙棰滆壊 + + COLORREF TextColor =RGB(0,0,0); + COLORREF FocusColor = RGB(128,255,128); + COLORREF SelectedColor; + COLORREF EditColor; + COLORREF AnnoColor = RGB(0,0,255); + COLORREF BlockAnnoColor; + COLORREF MonCoilColor= RGB(0,255,255); + COLORREF MonTextColor = RGB(0, 128, 255); + + COLORREF TraceBkColor = RGB(204,204,204); + COLORREF TraceColor = RGB(0,255,255); + COLORREF ForceIOColor; + + COLORREF OnlineColor = RGB(0, 255, 255); + COLORREF ProgColor = RGB(0, 255, 0); + COLORREF RunningColor = RGB(0, 255, 0); + COLORREF MonitorColor = RGB(0, 255, 255); + COLORREF AddressColor = RGB(0, 255, 255); + + CFont TextFont; +// CFont * pOldFont; + CFont MonTextFont; + CFont AnnoFont; + + + enum StatusBarIndicators { + idxMachineType = 0, + idxProgPos = 1, + idxOnline = 2, + idxRunning = 3, + idxMonitor = 4, + idxAddress = 5, + idxInfoDisp = 6, + }; + +// CBrush brBkColor(BkColor); + // 鎿嶄綔 public: + void DrawFocusRect(CDC* pDC); + int DrawLeftRightLine(CDC* pDC, int x0, int y0, int size1=16, int size2=12); + void DrawRelay(CDC* pDC, int x0, int y0); + int DrawBracket(CDC* pDC, int x0, int y0, int sizex, int sty=0, int sizey = 24); + int DrawAngleBracket(CDC* pDC, int x0, int y0, int sizex, int size2); + void DrawOT(CDC* pDC, int x0, int y0); + + int DrawCellStat1(CDC * pDC, int x1, int y1, int sizex, int sizey, int nStat); + int DrawCellStat2(CDC* pDC, int x1, int y1, int sizex, int sizey, int nStat); + int DrawCellText1(CDC* pDC, CString sText, int x1, int y1, int sizex, int sizey, int nFormat=0); + int DrawCellText2(CDC* pDC, CString sText, int x1, int y1, int sizex, int sizey, int nFormat, int nTextColor); + int DrawCellAnno(CDC * pDC, int nRow, int nCol, CString sAnno); + + void DrawCell(CDC* pDC, int nRow, int nCol); + int TransProgToLDS(); + + /// <summary> + /// Flag::鏄惁闇�瑕侀噸缁樿鍥撅紝榛樿涓�1=>true + /// </summary> + int needReDraw = 1; + + int DoReDraw(); + int DrawLDSGraph(CDC* pDC); + + int ScrollToCell(int nRow, int nCol); + + int ScrollCellIntoView(int nRow, int nCol); + int isCellInView(int nRow, int nCol); + int CellFocusChg(int nRow, int nCol); + + std::pair<int, CString> CMTerm1View::LDSCheckRule(); // 閲嶅啓 public: virtual void OnDraw(CDC* pDC); // 閲嶅啓浠ョ粯鍒惰瑙嗗浘 virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: + virtual void OnInitialUpdate(); // 鏋勯�犲悗绗竴娆¤皟鐢� virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); @@ -33,19 +238,73 @@ #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; + #endif protected: // 鐢熸垚鐨勬秷鎭槧灏勫嚱鏁� protected: - afx_msg void OnFilePrintPreview(); - afx_msg void OnRButtonUp(UINT nFlags, CPoint point); - afx_msg void OnContextMenu(CWnd* pWnd, CPoint point); DECLARE_MESSAGE_MAP() +public: + afx_msg void OnMonitor(); + afx_msg void OnUpdateMonitor(CCmdUI *pCmdUI); + afx_msg void OnProgConvert(); + afx_msg void OnUpdateProgConvert(CCmdUI *pCmdUI); + afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); + afx_msg void OnRectSelect(); + afx_msg void OnUpdateRectSelect(CCmdUI *pCmdUI); + afx_msg void OnTextFirst(); + afx_msg void OnUpdateTextFirst(CCmdUI *pCmdUI); + afx_msg void OnInsertBlankLine(); + afx_msg void OnUpdateInsertBlankLine(CCmdUI *pCmdUI); + afx_msg void OnDeleteBlankLine(); + afx_msg void OnUpdateDeleteBlankLine(CCmdUI *pCmdUI); + afx_msg void OnDisplayComments(); + afx_msg void OnUpdateDisplayComments(CCmdUI *pCmdUI); + + afx_msg void OnUpdateMachineType(CCmdUI *pCmdUI); + afx_msg void OnUpdateProgramPos(CCmdUI *pCmdUI); + afx_msg void OnUpdateConnectivity(CCmdUI *pCmdUI); + afx_msg void OnUpdateRunStatus(CCmdUI *pCmdUI); + afx_msg void OnUpdateMonitorStatus(CCmdUI *pCmdUI); + afx_msg void OnUpdateTargetAddress(CCmdUI *pCmdUI); + + int UpdateStatusBar(int nIndex=-1); + + virtual void OnUpdate(CView* /*pSender*/, LPARAM /*lHint*/, CObject* /*pHint*/); + afx_msg void OnLButtonDown(UINT nFlags, CPoint point); + afx_msg void OnLButtonUp(UINT nFlags, CPoint point); + afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point); + afx_msg void OnRButtonDown(UINT nFlags, CPoint point); + afx_msg void OnRButtonUp(UINT nFlags, CPoint point); + + afx_msg void OnIndicatorMonitorStatus(); + afx_msg void OnUpdateIndicators(CCmdUI *pCmdUI); + + afx_msg void OnUpdateIndicatorMonitorStatus(CCmdUI *pCmdUI); + afx_msg void OnTimer(UINT_PTR nIDEvent); + afx_msg BOOL OnEraseBkgnd(CDC* pDC); + afx_msg void OnSize(UINT nType, int cx, int cy); + virtual BOOL OnScrollBy(CSize sizeScroll, BOOL bDoScroll = TRUE); + + afx_msg void OnContextMenu(CWnd* /*pWnd*/, CPoint /*point*/); + afx_msg void OnProgCancelEdit(); + afx_msg void OnUpdateProgCancelEdit(CCmdUI *pCmdUI); + afx_msg void OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu); + int TransLDSToProg(); + afx_msg void OnInputIoComment(); + afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); + int ScanLDSCells(int nStartLine, int nEndLine, int nPosY, int nPosX, int nLevel, stProgSection & progsec, CString & sProgSec, int &nSteps); + int ScanLDSCells2(int nStartLine, int nEndLine, int nPosY, int nPosX, int nSizeX, int nLevel, stProgSection& progsec, CString& sProgSec, int& nSteps); + int CMTerm1View::Translate2Prog( + int nType, int nCurPosY, int nCurPosX, CString sCellName, + stProgSection& progsec, CString& sProgSec, int& nSteps); + void SetCellToView(stCell cell1, int flag = 0);//modify0919zxd + }; -#ifndef _DEBUG // MTerm1View.cpp 涓殑璋冭瘯鐗堟湰 +#ifndef _DEBUG // MultiTerminal2View.cpp 涓殑璋冭瘯鐗堟湰 inline CMTerm1Doc* CMTerm1View::GetDocument() const { return reinterpret_cast<CMTerm1Doc*>(m_pDocument); } #endif -- Gitblit v1.9.1