| | |
| | |
|
| | | // ON_COMMAND(ID_INDICATOR_MONITOR_STATUS, &CMTerm1View::OnIndicatorMonitorStatus)
|
| | | // ON_UPDATE_COMMAND_UI(ID_INDICATOR_MONITOR_STATUS, &CMTerm1View::OnUpdateIndicatorMonitorStatus)
|
| | | ON_WM_KEYDOWN()
|
| | | ON_WM_KEYDOWN()
|
| | | END_MESSAGE_MAP()
|
| | |
|
| | |
|
| | |
| | | {
|
| | |
|
| | | }
|
| | | else if (nType == typeEND) {
|
| | |
|
| | | if (needReDraw) {
|
| | | //画左侧横线
|
| | | //DrawLeftRightLine(pDC, x0, y0, 14, 18);
|
| | | DrawAngleBracket(pDC, x0, y0, 8, 32);
|
| | | DrawCellText1(pDC, _T("ED"), x0 + 16, y0 + m_LinePosY - 8, 24, 14);
|
| | | }
|
| | | }
|
| | | else if (nType == typeLine1)
|
| | | { //Draw Line
|
| | | //画直横线
|
| | |
| | | m_nCurProgStep = Cells[nRow][nCol].nProgStep;
|
| | | }
|
| | | if (!pDoc->m_bOnline) return;
|
| | | //if (!m_bMonitoring) return;
|
| | |
|
| | | if (!m_bMonitoring || !pDoc->m_bOnline) {
|
| | | |
| | | };
|
| | | |
| | | CString sParam;
|
| | | sParam = Cells[nRow][nCol].sParam;
|
| | | int nDataType, nDataAddr, nStat;
|
| | |
| | | // TODO: 在此添加消息处理程序代码和/或调用默认值
|
| | | CString s1;
|
| | | CMTerm1Doc * pDoc = (CMTerm1Doc*)GetDocument();
|
| | |
|
| | | static int nCount = 0;
|
| | | if (nIDEvent == 0) {
|
| | |
|
| | | }
|
| | | else if (nIDEvent == 1)
|
| | | {
|
| | | if (m_bMonitoring) {
|
| | | nCount++;
|
| | | if (m_bMonitoring && (nCount &1)) {
|
| | | //this->RedrawWindow();
|
| | | DoReDraw();
|
| | | }
|
| | |
| | | {
|
| | | case OP_NOP:
|
| | | break;
|
| | | case OP_END:
|
| | | nCellType = typeEND;
|
| | | nCurLine = cy;
|
| | | cx = 0;
|
| | | if (cx <= m_CellPerLine) {
|
| | |
|
| | | int hasData = 1;
|
| | | while (hasData) {
|
| | | hasData = 0;
|
| | | for (int j = 0; j < m_CellPerLine; j++) {
|
| | | if (Cells[nCurLine][j].nType != 0) {
|
| | | nCurLine++; hasData = 1; break;
|
| | | }
|
| | | }
|
| | | }
|
| | | cy = nCurLine;
|
| | | for (int j = 0; j < m_CellPerLine; j++)
|
| | | {
|
| | | Cells[cy][j].nType = typeLine1;
|
| | | }
|
| | | Cells[cy][m_CellPerLine - 1].nType = nCellType;
|
| | | Cells[cy][cx].nOpType = nOp;
|
| | | Cells[cy][m_CellPerLine - 1].nProgStep = i;
|
| | | }
|
| | | if (cy > maxy) { maxy = cy; }
|
| | | //cy++;
|
| | | break;
|
| | | break;
|
| | | case OP_ST:
|
| | | case OP_ST_:
|
| | | if (i == 0)
|
| | |
| | | nSts--;
|
| | | nEndPts--;
|
| | | cy = EndPt[nEndPts].y;
|
| | | cx = EndPt[nEndPts].x;
|
| | | // cx = EndPt[nEndPts].x;
|
| | | break;
|
| | | case OP_PSHS:
|
| | | EndPt[nEndPts] = POINT{ cx,cy };
|
| | |
| | | case OP_TMR:
|
| | | case OP_TMX:
|
| | | case OP_TMY:
|
| | | nCurLine = cy;
|
| | | {
|
| | | int hasData = 1;
|
| | | while (hasData) {
|
| | | hasData = 0;
|
| | | for (int j = cx; j < m_CellPerLine; j++) {
|
| | | if (Cells[nCurLine][j].nType != 0) {
|
| | | nCurLine++; hasData = 1; break;
|
| | | }
|
| | | }
|
| | | }
|
| | | //if (nCurLine > maxy) maxy = nCurLine;
|
| | | for (int j = cy; j < nCurLine; j++) {
|
| | | Cells[j][cx].bLeftLineDn = 1;
|
| | | Cells[j + 1][cx].bLeftLineUp = 1;
|
| | | }
|
| | | }
|
| | | cy = nCurLine;
|
| | | Cells[cy][cx].nType = typeTM;
|
| | | Cells[cy][cx].nOpType = nOp;
|
| | | Cells[cy][cx].nProgStep = i;
|
| | |
| | | if (nType == typeNO)
|
| | | {
|
| | | CMTerm1Doc::stProg prog0;
|
| | | if (nOp >= 1 && nOp <= 255) {
|
| | | prog0.nOpType1 = nOp; // OP_AN;
|
| | | }
|
| | | else if (CellX==0) {
|
| | | if (CellX == 0) {
|
| | | prog0.nOpType1 = OP_ST; // OP_AN;
|
| | | }else |
| | | if (nOp >= 1 && nOp <= 255) {
|
| | | //prog0.nOpType1 = nOp; // OP_AN;
|
| | | prog0.nOpType1 = OP_AN; // OP_AN;
|
| | | }
|
| | | else {
|
| | | prog0.nOpType1 = OP_AN; // OP_AN;
|
| | |
| | | }
|
| | | else if (nType == typeNC) {
|
| | | CMTerm1Doc::stProg prog0;
|
| | | if (nOp >= 1 && nOp <= 255) {
|
| | | prog0.nOpType1 = nOp; // OP_AN;
|
| | | }
|
| | | else if (CellX == 0) {
|
| | | if (CellX == 0) {
|
| | | prog0.nOpType1 = OP_ST_; // OP_AN;
|
| | | }
|
| | | else {
|
| | | else if (nOp >= 1 && nOp <= 255) {
|
| | | //prog0.nOpType1 = nOp; // OP_AN;
|
| | | prog0.nOpType1 = OP_AN_; // OP_AN;
|
| | | }
|
| | | else {
|
| | | prog0.nOpType1 = OP_AN_; // OP_AN;
|
| | | }
|
| | | prog0.nParamCount = 1;
|
| | |
| | | prog0.Params[0].nParamType = nCoilType;
|
| | | prog0.Params[0].nParamAddr = nCoilAddr;
|
| | | theNode.prog1.Append(prog0);
|
| | | }
|
| | | else if (nType == typeEND) {
|
| | | theNode.prog1.Append(CMTerm1Doc::stProg(OP_END));
|
| | | }
|
| | | else if (nType == typePP) {
|
| | | CMTerm1Doc::stProg prog0;
|
| | |
| | | node* pThisNode1 = ptheArc1->headvex; // 第一个实节点
|
| | | stProgSection prog1 = pThisNode1->prog1;
|
| | | if (prog1.Progs[0].nOpType1 == OP_AN) { prog1.Progs[0].nOpType1 = OP_ST; }
|
| | | else if (prog1.Progs[0].nOpType1 == OP_AN_) { prog1.Progs[0].nOpType1 = OP_ST_; }
|
| | | else if (prog1.Progs[0].nOpType1 == OP_ST || prog1.Progs[0].nOpType1 == OP_ST_ ){
|
| | | prog1.Prefix += 1;
|
| | | s1.Format(_T(" <+1 %s"),prog1.ToText()); DbgLog(s1);
|
| | | }
|
| | | else {
|
| | | prog1.Prefix += 0;
|
| | | s1.Format(_T(" < +0 %s"),prog1.ToText()); DbgLog(s1);
|
| | | }
|
| | | prog2 = prog1; // 取得第一个实节点的程序
|
| | | ptheArc1 = ptheArc1->tlink; //下一个弧
|
| | | while (ptheArc1)
|
| | |
| | | node* pThisNode2 = ptheArc1->headvex;
|
| | | stProgSection prog1 = pThisNode2->prog1;
|
| | | if (prog1.Progs[0].nOpType1 == OP_AN) { prog1.Progs[0].nOpType1 = OP_ST; }
|
| | | else if (prog1.Progs[0].nOpType1 == OP_AN_) { prog1.Progs[0].nOpType1 = OP_ST_; }
|
| | | else if (prog1.Progs[0].nOpType1 == OP_ST || prog1.Progs[0].nOpType1 == OP_ST_) {
|
| | | prog1.Prefix += 1;
|
| | | s1.Format(_T(" < 2 +1 %s"), prog1.ToText()); DbgLog(s1);
|
| | | if (theNode1.nType == -1) { prog1.reduce(); }
|
| | | }
|
| | | else {
|
| | | prog1.Prefix += 0;
|
| | | s1.Format(_T(" < 2 +0 %s"),prog1.ToText()); DbgLog(s1);
|
| | | }
|
| | |
|
| | | if (prog1.Progs.size() > 1) {
|
| | | prog1.Append(CMTerm1Doc::stProg(OP_ORS));
|
| | | }
|
| | |
| | | }
|
| | | if (theNode1.nType == -1 && theNode2.nType == -1) { prog2.Append(CMTerm1Doc::stProg(OP_ANS)); }
|
| | | pThisNode1->prog1 = prog2; //将所有程序汇总到第一个实节点
|
| | | // pThisNode1->prog1.reduce();
|
| | | // s1 = prog2.ToText(GetDocument());
|
| | | // DbgLog(_T("------ ") + s1);
|
| | | }
|
| | |
| | | node* pThisNode1 = ptheArc1->tailvex; // 第一个实节点
|
| | | stProgSection prog1 = pThisNode1->prog1;
|
| | | if (prog1.Progs[0].nOpType1 == OP_AN) { prog1.Progs[0].nOpType1 = OP_ST; }
|
| | | else if (prog1.Progs[0].nOpType1 == OP_AN_) { prog1.Progs[0].nOpType1 = OP_ST_; }
|
| | | else if (prog1.Progs[0].nOpType1 == OP_ST || prog1.Progs[0].nOpType1 == OP_ST_) {
|
| | | prog1.Prefix += 1;
|
| | | s1.Format(_T(" > +1 %s"),prog1.ToText()); DbgLog(s1);
|
| | | }
|
| | | else {
|
| | | prog1.Prefix += 0;
|
| | | s1.Format(_T(" > +0 %s"), prog1.ToText()); DbgLog(s1);
|
| | | }
|
| | | prog2 = prog1; // 取得第一个实节点的程序
|
| | |
|
| | | ptheArc1 = ptheArc1->hlink;
|
| | | bool NeedANS = 0;
|
| | | while (ptheArc1)
|
| | | {
|
| | | //取得相连的虚节点地址
|
| | |
| | |
|
| | | stProgSection prog1 = pThisNode2->prog1;
|
| | | if (prog1.Progs[0].nOpType1 == OP_AN) { prog1.Progs[0].nOpType1 = OP_ST; }
|
| | | else if (prog1.Progs[0].nOpType1 == OP_AN_) { prog1.Progs[0].nOpType1 = OP_ST_; }
|
| | | else if (prog1.Progs[0].nOpType1 == OP_ST || prog1.Progs[0].nOpType1 == OP_ST_) {
|
| | | prog1.Prefix += 1;
|
| | | s1.Format(_T(" > 2 +1 %s"),prog1.ToText()); DbgLog(s1);
|
| | | }
|
| | | else {
|
| | | prog1.Prefix += 0;
|
| | | s1.Format(_T(" >2 +0 %s"),prog1.ToText()); DbgLog(s1);
|
| | | }
|
| | | if (prog1.Progs.size() > 1) {
|
| | | prog1.Append(CMTerm1Doc::stProg(OP_ORS));
|
| | | NeedANS = 1;
|
| | | }
|
| | | else {
|
| | | if (pThisNode2->nType == typeNC) prog1.Progs[0].nOpType1 = OP_OR_;
|
| | | else if (pThisNode2->nType == typeNO) prog1.Progs[0].nOpType1 = OP_OR;
|
| | | else prog1.Progs[0].nOpType1 = OP_OR;
|
| | | NeedANS = 1;
|
| | | }
|
| | | prog2 += prog1;
|
| | |
|
| | |
| | | pThisNode2->bEnable = 0; //删除实节点
|
| | | ptheArc1 = pTheNextArc;
|
| | | }
|
| | | if (theNode1.nType == -1 && theNode2.nType == -1) { prog2.Append(CMTerm1Doc::stProg(OP_ANS)); }
|
| | | if (theNode1.nType == -1 && theNode2.nType == -1 && NeedANS) { prog2.Append(CMTerm1Doc::stProg(OP_ANS)); }
|
| | | pThisNode1->prog1 = prog2; //将所有程序汇总到第一个实节点
|
| | | // pThisNode1->prog1.reduce();
|
| | | // s1 = prog2.ToText(GetDocument());
|
| | | // DbgLog(_T("------ ") + s1);
|
| | | }
|
| | |
| | | s1.Format(_T("- %d type %d op %s coil %s in %d out %d"), thisNode->nId, thisNode->nType, thisNode->Op, thisNode->CoilName, thisNode->indegree, thisNode->outdegree);
|
| | | DbgLog(s1);
|
| | | s1 = thisNode->prog1.ToText();
|
| | | DbgLog(_T("------ ") + s1);
|
| | | DbgLog(_T("------ \r\n") + s1);
|
| | |
|
| | | arc* thisArc = thisNode->firstOut;
|
| | | if (thisNode->outdegree > 0) { allOutputMerged = 0; }
|
| | | if (thisNode->nType != typeOUT && thisNode->nType != typeSET && thisNode->nType != typeRESET) { allOutputSimple = 0; }
|
| | | if (thisNode->nType == typeOUT || thisNode->nType == typeSET || thisNode->nType == typeRESET) {
|
| | | thisNode->prog1.bModifyVal = 0;
|
| | | }
|
| | | else {
|
| | | allOutputSimple = 0;
|
| | | thisNode->prog1.bModifyVal = 1;
|
| | | }
|
| | | while (thisArc) {
|
| | | thisNode = thisArc->headvex;
|
| | | thisNode->InProcCount++;
|
| | |
| | | node* thisNode = thisArc->headvex;
|
| | | stProgSection prog2;
|
| | | prog2.Append(CMTerm1Doc::stProg(OP_PSHS));
|
| | | int bLastModify = 1;
|
| | | prog2 += thisNode->prog1;
|
| | | if (thisNode->prog1.bModifyVal == 0) { bLastModify = 0; s1.Format(_T(" ModifyVal = 0, %s"), thisNode->prog1.ToText()); }
|
| | | thisArc = thisArc->tlink;
|
| | |
|
| | | for (int i = 1; i < nOutput && thisArc != 0; i++) {
|
| | | node* thatNode = thisArc->headvex;
|
| | | if (i == nOutput - 1) { // 最后一个
|
| | | prog2.Append(CMTerm1Doc::stProg(OP_POPS));
|
| | | }
|
| | | else {
|
| | | prog2.Append(CMTerm1Doc::stProg(OP_RDS));
|
| | | if (bLastModify) { prog2.Append(CMTerm1Doc::stProg(OP_RDS)); }
|
| | | }
|
| | | if (thisNode->prog1.bModifyVal == 0) { bLastModify = 0;s1.Format(_T(" ModifyVal = 0, %s"), thisNode->prog1.ToText()); }
|
| | | else { bLastModify = 1; }
|
| | | prog2 += thatNode->prog1;
|
| | | arc* tempArc = thisArc->tlink;
|
| | | RemoveArc(thisArc->nId);
|
| | |
| | | case typeLine1:
|
| | |
|
| | | break;
|
| | | case typeEND:
|
| | | PrevNode = AddNode(nType, k, j, theCell.sCoilName, PrevNode);
|
| | | break;
|
| | | case typeNO:
|
| | | PrevNode = AddNode(nType, k, j, theCell.sCoilName, PrevNode);
|
| | | break;
|
| | |
| | | }
|
| | | //输出已经生成的 AOV 图 顶点信息
|
| | | for (int j = 1; j < nNodeCount; j++) {
|
| | | s1.Format(_T("%d %d %s %s in %d out %d"), j, nodes[j].nType,nodes[j].Op, nodes[j].CoilName,nodes[j].indegree,nodes[j].outdegree);
|
| | | // DbgLog(s1);
|
| | | s1.Format(_T("%d %d %s %s in %d out %d %s "), j, nodes[j].nType,nodes[j].Op, nodes[j].CoilName,nodes[j].indegree,nodes[j].outdegree, nodes[j].prog1.ToText());
|
| | | DbgLog(s1);
|
| | | }
|
| | | //输出AOV图的 弧 数据
|
| | | for (int j = 1; j < nArcCount; j++) {
|
| | |
| | | // 处理 AOV 图
|
| | | // 从 母线 开始
|
| | | //串联归并 // 归并原则, 普通节点,非虚节点, 两个虚节点之间 多个连续的,归并, 非输出。
|
| | | s1.Format(_T("合并串联的节点 %d "), n);
|
| | | DbgLog(s1);
|
| | | MergeVPSubSerialNodes(1);
|
| | | // 处理虚节点
|
| | | // 虚节点的多输入处理, 单 OR 或者 多 ORS。
|
| | |
| | | // 对于后面还有改变的, PSHS, RDS, POPS
|
| | | // 另外,可以后期简化, ST 后紧跟 ORS 的, 简化为 OR。
|
| | | // PSHS RDS POPS 后跟不改变的。 简化
|
| | | s1.Format(_T("处理虚节点的输出 %d "), n);
|
| | | DbgLog(s1);
|
| | | ScanAOV1(1);
|
| | | if (nodes[2].outdegree == 0) break;
|
| | | }
|