| | |
| | |
|
| | | #include <memory>
|
| | | #include <vector>
|
| | | #include <stack>
|
| | |
|
| | | #include "MTerm1Doc.h"
|
| | | class CMTerm1View : public CScrollView
|
| | |
| | | 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; //选中
|
| | |
| | | }
|
| | | };
|
| | | 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; //显示注释
|
| | |
| | | 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
|
| | |
|
| | | };
|