| | |
| | | #include "DialogSetData.h"
|
| | | #include "DialogIoComment.h"
|
| | | #include "KDefine.h"
|
| | | #include "MainFrm.h"
|
| | |
|
| | | #ifdef _DEBUG
|
| | | #define new DEBUG_NEW
|
| | |
| | | }
|
| | | }
|
| | | // 获取数据 并显示各单元
|
| | |
|
| | | for (int j = 0; j < m_CellPerLine; j++) {
|
| | | nCol = j;
|
| | | nDataType = Cells[nRow][nCol].nDataType;
|
| | | nDataAddr = Cells[nRow][nCol].nDataAddr;
|
| | | if ((nDataType&TYPEDATA) == TYPEDATA) {
|
| | | nStat = pDoc->GetVarData(nDataType, nDataAddr);
|
| | | if (m_bMonitoring) {
|
| | | if ((nDataType & TYPEDATA) == TYPEDATA) {
|
| | | nStat = pDoc->GetVarData(nDataType, nDataAddr);
|
| | | }
|
| | | else {
|
| | | nStat = pDoc->GetCoilValue(nDataType, nDataAddr);
|
| | | }
|
| | | Cells[nRow][nCol].nStat = nStat;
|
| | | nType = Cells[nRow][nCol].nType;
|
| | | if (nType == typeNO || nType == typeNC || nType == typeCMP || nType == typeTM)
|
| | | {
|
| | | int nProgStep = Cells[nRow][nCol].nProgStep;
|
| | | int nBinProgStep = pDoc->Progs[nProgStep].nBinStep;
|
| | | Cells[nRow][nCol].nTrace = pDoc->ProgTrace[nBinProgStep];
|
| | | }
|
| | | }
|
| | | else {
|
| | | nStat = pDoc->GetCoilValue(nDataType, nDataAddr);
|
| | | Cells[nRow][nCol].nStat = 0; Cells[nRow][nCol].nTrace = 0;
|
| | | }
|
| | | Cells[nRow][nCol].nStat = nStat;
|
| | | nType = Cells[nRow][nCol].nType;
|
| | | if (nType == typeNO || nType == typeNC || nType == typeCMP || nType == typeTM)
|
| | | {
|
| | | int nProgStep = Cells[nRow][nCol].nProgStep;
|
| | | int nBinProgStep = pDoc->Progs[nProgStep].nBinStep;
|
| | | Cells[nRow][nCol].nTrace = pDoc->ProgTrace[nBinProgStep];
|
| | | }
|
| | |
|
| | | DrawCell(pDC, i, j);
|
| | | }
|
| | |
|
| | |
| | |
|
| | | CScrollView::OnKeyDown(nChar, nRepCnt, nFlags);
|
| | | }
|
| | | int CMTerm1View::CellFocusChg(int nRow, int nCol)
|
| | | {
|
| | | CString s1;
|
| | | stCell & thecell = Cells[nRow][nCol];
|
| | | s1.Format(_T("Cell %d %d Type %02X \r\n"), nRow, nCol, thecell.nType);
|
| | | s1.AppendFormat(_T(" sCoilName %s sParam %s \r\n"), thecell.sCoilName, thecell.sParam );
|
| | | s1.AppendFormat(_T("LeftUp %d leftDn %d "), thecell.bLeftLineUp, thecell.bLeftLineDn);
|
| | | DbgLog(s1);
|
| | |
|
| | | auto p1 = (CMainFrame*)AfxGetMainWnd();
|
| | | auto p2 = p1->GetInputWnd();
|
| | | p2->SetCurCellPos(nRow,nCol,thecell);
|
| | |
|
| | |
|
| | |
|
| | | return 0;
|
| | | }
|
| | |
|
| | | void CMTerm1View::OnLButtonDown(UINT nFlags, CPoint point)
|
| | | {
|
| | |
| | | }
|
| | |
|
| | | // DrawFocusRect();
|
| | | CellFocusChg(nRow, nCol);
|
| | | GetDocument()->UpdateAllViews(this, m_FocusCol);
|
| | | needReDraw = 1;
|
| | | this->RedrawWindow();
|
| | |
| | | return -1;
|
| | | }
|
| | |
|
| | | void CMTerm1View::GetIncToView(stCell cell1) //**************************************************************************************************//
|
| | | void CMTerm1View::SetCellToView(stCell cell1) //**************************************************************************************************//
|
| | | {
|
| | |
|
| | |
|
| | | Cells[m_FocusRow][m_FocusCol] = cell1;
|
| | |
|
| | | m_bModified = 1;
|
| | | needReDraw = 1;
|
| | | m_FocusCol += 1;
|
| | | Cells[m_FocusRow][0].bEditing = 1;
|
| | |
|
| | | if (m_nTotalRow < m_FocusRow + 1) {
|
| | | m_nTotalRow = m_FocusRow + 1;
|
| | | }
|
| | |
|
| | | if (m_FocusCol >= 16)
|
| | | { m_FocusCol = 0;m_FocusRow += 1; }
|
| | |
|
| | |
| | | DbgLog(s1);
|
| | | for (int i = 0; i < n; i++) {
|
| | | int optype=allprogs.Progs[i].nOpType1;
|
| | | allprogs.Progs[i].PairTo = 0;
|
| | | allprogs.Progs[i].nBinStep = i;
|
| | | CStringA OpTxtA,OpShowTxtA;
|
| | | CString OpTxt,OpShowTxt;
|
| | | pDoc->OpToTxt(optype, OpTxtA);
|
| | |
| | | OpTxt = OpTxtA;
|
| | | OpShowTxt = OpShowTxtA;
|
| | | s1.Format(_T("%d %s %s"), optype, OpTxt, OpShowTxt);
|
| | | pDoc->Progs[i] = allprogs.Progs[i];
|
| | | // DbgLog(s1);
|
| | | }
|
| | | pDoc->m_nProgSteps = n;
|
| | | return 0;
|
| | | }
|
| | |
|
| | |
| | | int nNextX = 1;
|
| | | nCurPosY = nPosY;
|
| | | nCurPosX = nPosX;
|
| | |
|
| | | int nCoilType, CoilAddr;
|
| | | CMTerm1Doc* pDoc = GetDocument();
|
| | | for (int j = nPosX; j < m_CellPerLine; j+=nNextX) {
|
| | | nCurPosX = j;
|
| | | //先处理当前单元;
|
| | | int nType = Cells[nCurPosY][nCurPosX].nType;
|
| | | CString sCellName = Cells[nCurPosY][nCurPosX].sCoilName;
|
| | | CMTerm1Doc::stProg theprog;
|
| | |
|
| | | CStringA sCellNameA;
|
| | | sCellNameA = sCellName;
|
| | | if (nType == typeNO) {
|
| | | if (j==0) {
|
| | | s1.Format(_T("%d %d ST %s"), nCurPosY, nCurPosX,sCellName);
|
| | | sProgSec.AppendFormat(_T("ST %s\r\n"),sCellName);
|
| | | theprog.nOpType1 = OP_ST;
|
| | | theprog.nParamCount = 1;
|
| | | pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
|
| | | theprog.Params[0].nParamType = nCoilType;
|
| | | theprog.Params[0].nParamAddr = CoilAddr;
|
| | | theprog.Params[0].sParamStr = sCellNameA;
|
| | | progsec.Append(theprog);
|
| | | }
|
| | | else {
|
| | | s1.Format(_T("%d %d AN %s"), nCurPosY, nCurPosX, sCellName);
|
| | | sProgSec.AppendFormat(_T("NO %s\r\n"), sCellName);
|
| | | theprog.nOpType1 = OP_AN;
|
| | | theprog.nParamCount = 1;
|
| | | pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
|
| | | theprog.Params[0].nParamType = nCoilType;
|
| | | theprog.Params[0].nParamAddr = CoilAddr;
|
| | | theprog.Params[0].sParamStr = sCellNameA;
|
| | | progsec.Append(theprog);
|
| | | }
|
| | | nSteps += 1;
|
| | |
| | | s1.Format(_T("%d %d ST/ %s"), nCurPosY, nCurPosX, sCellName);
|
| | | sProgSec.AppendFormat(_T("ST/ %s\r\n"), sCellName);
|
| | | theprog.nOpType1 = OP_ST_;
|
| | | theprog.nParamCount = 1;
|
| | | pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
|
| | | theprog.Params[0].nParamType = nCoilType;
|
| | | theprog.Params[0].nParamAddr = CoilAddr;
|
| | | theprog.Params[0].sParamStr = sCellNameA;
|
| | | progsec.Append(theprog);
|
| | |
|
| | | }
|
| | |
| | | s1.Format(_T("%d %d AN/ %s"), nCurPosY, nCurPosX, sCellName);
|
| | | sProgSec.AppendFormat(_T("AN/ %s\r\n"), sCellName);
|
| | | theprog.nOpType1 = OP_AN_;
|
| | | theprog.nParamCount = 1;
|
| | | pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
|
| | | theprog.Params[0].nParamType = nCoilType;
|
| | | theprog.Params[0].nParamAddr = CoilAddr;
|
| | | theprog.Params[0].sParamStr = sCellNameA;
|
| | | progsec.Append(theprog);
|
| | | }
|
| | | DbgLog(s1);
|
| | |
| | | DbgLog(s1);
|
| | | sProgSec.AppendFormat(_T("OUT %s\r\n"), sCellName);
|
| | | theprog.nOpType1 = OP_OUT;
|
| | | theprog.nParamCount = 1;
|
| | | pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
|
| | | theprog.Params[0].nParamType = nCoilType;
|
| | | theprog.Params[0].nParamAddr = CoilAddr;
|
| | | theprog.Params[0].sParamStr = sCellNameA;
|
| | | progsec.Append(theprog);
|
| | | nSteps += 1;
|
| | | nNextX = 1;
|
| | |
| | | DbgLog(s1);
|
| | | sProgSec.AppendFormat(_T("SET %s\r\n"), sCellName);
|
| | | theprog.nOpType1 = OP_SET;
|
| | | theprog.nParamCount = 1;
|
| | | pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
|
| | | theprog.Params[0].nParamType = nCoilType;
|
| | | theprog.Params[0].nParamAddr = CoilAddr;
|
| | | theprog.Params[0].sParamStr = sCellNameA;
|
| | | progsec.Append(theprog);
|
| | | nSteps += 1;
|
| | | nNextX = 1;
|
| | |
| | | DbgLog(s1);
|
| | | sProgSec.AppendFormat(_T("RESET %s\r\n"), sCellName);
|
| | | theprog.nOpType1 = OP_RESET;
|
| | | theprog.nParamCount = 1;
|
| | | pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
|
| | | theprog.Params[0].nParamType = nCoilType;
|
| | | theprog.Params[0].nParamAddr = CoilAddr;
|
| | | theprog.Params[0].sParamStr = sCellNameA;
|
| | | progsec.Append(theprog);
|
| | | nSteps += 1;
|
| | | nNextX = 1;
|
| | |
| | | s1.Format(_T("%d %d CMP %s %s %s"), nCurPosY, nCurPosX, sCellName,Cells[nCurPosY][nCurPosX+1].sParam,Cells[nCurPosY][nCurPosX + 2].sParam);
|
| | | DbgLog(s1);
|
| | | theprog.nOpType1 = OP_ST_GT;
|
| | | theprog.nParamCount = 1;
|
| | | progsec.Append(theprog);
|
| | | sProgSec.AppendFormat(_T("CMP %s %s %s \r\n"), sCellName, Cells[nCurPosY][nCurPosX + 1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
|
| | | nSteps += 1;
|
| | |
| | | s1.Format(_T("%d %d TM %s %d %s"), nCurPosY, nCurPosX, sCellName,Cells[nCurPosY][nCurPosX+1].sParam,Cells[nCurPosY][nCurPosX + 2].sParam);
|
| | | DbgLog(s1);
|
| | | theprog.nOpType1 = OP_TMX;
|
| | | theprog.nParamCount = 1;
|
| | | pDoc->TxtToCoilType(sCellNameA, &nCoilType, &CoilAddr);
|
| | | theprog.Params[0].nParamType = nCoilType;
|
| | | theprog.Params[0].nParamAddr = CoilAddr;
|
| | | theprog.Params[0].sParamStr = sCellNameA;
|
| | | progsec.Append(theprog);
|
| | | sProgSec.AppendFormat(_T("TM %s %d %s\r\n"), sCellName, Cells[nCurPosY][nCurPosX+1].sParam, Cells[nCurPosY][nCurPosX + 2].sParam);
|
| | | nSteps += 1;
|