From 61deef5cdf96cbfdd6ad45be49e80d597c00ca65 Mon Sep 17 00:00:00 2001 From: QuakeGod <QuakeGod@sina.com> Date: 星期二, 24 十二月 2024 08:37:21 +0800 Subject: [PATCH] 2024-12-24 --- MTerm1/MTerm1View.h | 150 +++++++++++++++++++++++++++++++++++++++++++++---- 1 files changed, 137 insertions(+), 13 deletions(-) diff --git a/MTerm1/MTerm1View.h b/MTerm1/MTerm1View.h index 34fe522..773acd5 100644 --- a/MTerm1/MTerm1View.h +++ b/MTerm1/MTerm1View.h @@ -6,6 +6,7 @@ #include <memory> #include <vector> +#include <stack> #include "MTerm1Doc.h" class CMTerm1View : public CScrollView @@ -52,18 +53,22 @@ typeExt1, //23 0x17 //琚墠闈㈢殑鎸囦护鍗犵敤鐨勭┖闂� typeExt2, typeExt3, + typeExt4, - typeTM=30, //瀹氭椂鍣� - typeFN1=40, //1涓弬鏁扮殑鍑芥暟 - typeFN2=50, //2涓弬鏁扮殑鍑芥暟 - typeFN3=60, //3涓弬鏁扮殑鍑芥暟 + typeTM = 30, //瀹氭椂鍣� + typeFN1 = 40, //1涓弬鏁扮殑鍑芥暟 + typeFN2 = 50, //2涓弬鏁扮殑鍑芥暟 + typeFN3 = 60, //3涓弬鏁扮殑鍑芥暟 + typeFN4 = 70, //3涓弬鏁扮殑鍑芥暟 typeCoil=99, + typeEND = 255, }; struct stCell { int nType; //鍗曞厓绫诲瀷銆� + int nOpType; //鎸囦护鐮併�� int nProgStep; //瀵瑰簲绋嬪簭鐨勬鏁� int bFocused = 0; //鐑偣閫変腑 int bSelected = 0; //閫変腑 @@ -89,32 +94,146 @@ } }; stCell Cells[2000][16] = { 0 }; - struct stProgSection { + int Prefix = 0; + int Suffix = 0; + int bModifyVal = 1; std::vector <CMTerm1Doc::stProg> Progs; - int Append(CMTerm1Doc::stProg prog) { + int Append(CMTerm1Doc::stProg prog) { Progs.push_back(prog); return 0; }; - int Append(struct stProgSection progsec){ - int n=(int)progsec.Progs.size(); + 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) { + int operator+=(const struct stProgSection progsec) { Append(progsec); - return 0; + bModifyVal = bModifyVal | progsec.bModifyVal; + return 0; }; - int Insert(CMTerm1Doc::stProg prog) { + int Insert(CMTerm1Doc::stProg prog) { Progs.insert(Progs.begin(), prog); return 0; } + CString ToText() { + CString s1; + CStringA s2A; + int n = (int)Progs.size(); + s2A.Format(" +%d ", Prefix); + for (int k = 0; k < n; k++) { + CMTerm1Doc::stProg& prog0 = Progs.at(k); + s2A = prog0.ToText(); + s1 += s2A; + } + return s1; + } + int reduce() + { + if (Prefix > 0) { + int level = 0; + int j = Progs.size(); + for (int i = 0; i < j; i++) { + int nOp = Progs[i].nOpType1; + if (nOp == OP_ST || nOp == OP_ST_) { + level += 1;; + } + else if (nOp == OP_ORS) { + level -= 1; + } + if (nOp == OP_ANS) { + level -= 1; + if (level == 0) { + Progs.erase(Progs.begin() + i); + Prefix -= 1; + break; + } + } + } + + } + return Prefix; + } + }; + std::pair<int, int> popsPoint[100]; + + struct arc; + struct node { + int nId; + int bEnable; + int nType; + char input; + char result; + char indeep; //杈撳叆 娣卞害 + char outdeep; //杈撳嚭 娣卞害 + + int indegree; //鍏ュ害 + int outdegree; //鍑哄害 + int parameter1; + int parameter2; + struct arc *firstIn; + struct arc *firstOut; + int nCellX; + int nCellY; + CString Op; + CString CoilName; + int InProcCount; + int OutProcCount; + int OutProcAllDone; + stProgSection prog1; + + }; + struct arc { + int nId; + int bEnable; + int tailNode; + int headNode; + int hlinkId; + int tlinkId; + struct node* tailvex; + struct node* headvex; + struct arc* hlink; + struct arc* tlink; + //stProgSection prog1; }; + node nodes[1000]; + arc arcs[1000]; + + node* rootnode; + + int nNodeCount = 0; + int nArcCount = 0; + int AddNode(int nType, int CellX,int CellY, CString sCoilName, int PrevNode=0); + int AddArc(int nNodeID1, int nNodeID2); + int RemoveNode(int nIndex); + int RemoveArc(int nIndex); + + int MergeNode(int nNodeId1, int nNodeId2); + int MergeVPSubSerialNodes(int nNodeId); + int MergeParallelNodeWithinVP(int nVPNodeId1, int nVPNodeId2); + + + int FindVPNode(int x, int y,int endy); + + int TransLDSToProg(); + int TransLDSToProgAOV(); + + int ScanAOV1(int nNodeid); + int ScanVPAOV(int nVPNodeId1, int nVPNodeId2); + + int MergeVPSerialNodes(int nNodeId); +// int ScanAOV2(int nNodeid); + + int nPSHS = -1; + bool firstCoil = true;//鏈绗竴涓崟鍏冩牸 + + bool isPops = false; int m_nTotalRow=0; bool m_bMonitoring = false; //鐩戞帶涓� bool m_bShowComments = true; //鏄剧ず娉ㄩ噴 @@ -286,11 +405,16 @@ 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); - void chuansileitetoprog(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 }; -- Gitblit v1.9.1