| | |
| | |
|
| | | // MTerm1Doc.h: CMTerm1Doc 类的接口
|
| | | // MultiTerminal2Doc.h: CMTerm1Doc 类的接口
|
| | | //
|
| | |
|
| | |
|
| | | #pragma once
|
| | | //#include "HvSerialPort.h"
|
| | | #include "AnsiParser.h"
|
| | | #include "DataParser1.h"
|
| | | #include "KDefine.h"
|
| | | //#include "KLink.h"
|
| | | #include "KMachine.h"
|
| | |
|
| | | #include "../KLink1/KLink.h"
|
| | |
|
| | | #pragma comment(lib,"KLink1.lib")
|
| | |
|
| | | class CMTerm1Doc : public CDocument
|
| | | {
|
| | |
| | |
|
| | | // 特性
|
| | | public:
|
| | | //通讯参数。
|
| | | CAnsiParser MyAnsiParser1;
|
| | | CDataParser1 MyDataParser1;
|
| | | // KLink MyKLink1;
|
| | | // CSerialCom MySerialCom1;
|
| | | // HvSerialPort myHvSerialPort1;
|
| | | KMachine myKMachine1;
|
| | | KLink1 MyKLink1;
|
| | |
|
| | | // 操作
|
| | | union {
|
| | | unsigned char KBDD[2048];
|
| | | unsigned short KBDT[1024];
|
| | | unsigned char KBDB[2048];
|
| | | };
|
| | |
|
| | | union {
|
| | | unsigned char KWLD[2048];
|
| | | unsigned short KWLT[1024];
|
| | | unsigned char KWLB[2048];
|
| | | };
|
| | |
|
| | |
|
| | | bool m_bCommParamSet = false;
|
| | | int nComPort;
|
| | | int nBaud;
|
| | | CStringA ComSettings;
|
| | | bool m_bOnline = false;
|
| | | bool m_bSimulate = false;
|
| | | bool m_bPlcRunning = false;
|
| | |
|
| | | double StartTime;
|
| | | //系统配置文件
|
| | |
|
| | | //数据存储区
|
| | | int m_nNum=15;
|
| | | CString m_Str;
|
| | | CString m_sMachineType = _T("KL20N16D");;
|
| | |
|
| | | //程序存储
|
| | | CString ProgTxt;
|
| | |
|
| | |
|
| | | struct stTypeNameDef
|
| | | {
|
| | | int nType;
|
| | | CStringA TypeTxt;
|
| | | };
|
| | | static stTypeNameDef CoilTypeNameDef[];
|
| | | static int nCoilTypeDefCount;
|
| | |
|
| | | static stTypeNameDef DataTypeNameDef[];
|
| | | static int nDataTypeDefCount;
|
| | |
|
| | | stKMem KMem;
|
| | |
|
| | | enum enParamTypes //参数类型
|
| | | {
|
| | | KLParamCoil, //参数为线圈,1bit
|
| | | KLParamWord, //参数为字类型, 16bit
|
| | | KLParamNum, //参数为立即数
|
| | | };
|
| | | struct stOpDef //指令定义
|
| | | {
|
| | | int nOpType1; //指令类型
|
| | | CStringA OpTxt; //指令文本显示
|
| | | int nParamCount; //指令的参数个数
|
| | | int nParamType; //指令的参数类型
|
| | | CStringA ShowTxt; //指令的显示文本
|
| | | };
|
| | | static stOpDef OpDef[];
|
| | |
|
| | | static int nOpDefCount;
|
| | | struct stParam //参数定义
|
| | | {
|
| | | CStringA sParamStr; //参数显示文本
|
| | | int nParamType; //参数类型
|
| | | int nParamAddr; //参数地址.
|
| | | };
|
| | |
|
| | | struct stProg //程序定义
|
| | | {
|
| | | int nOpType1; //指令类型
|
| | | int nBinStep; //指令步
|
| | | int nParamCount; //参数数量
|
| | | stParam Params[3]; //参数们
|
| | | int PairTo; //对应指令
|
| | | };
|
| | |
|
| | |
|
| | | struct stCoilAnno //线圈注释定义
|
| | | {
|
| | | unsigned short nType; //类型
|
| | | unsigned short nAddr; //地址
|
| | | CString sCoilName; //线圈名称
|
| | | CString sAnno; //注释文本
|
| | | };
|
| | | stCoilAnno mCoilAnnos[10000] =
|
| | | {
|
| | | };
|
| | |
|
| | | int nCoilAnnoCount = 0;
|
| | |
|
| | |
|
| | |
|
| | | enum enSection { //数据节类型定义
|
| | | SectionNone = 0, //
|
| | | SectionSysCfg = 1, //系统配置节
|
| | | SectionProg = 2, //程序节
|
| | | SectionAnno = 3, //注释节
|
| | | SectionCoilList = 4, //线圈列表节
|
| | | SectionDataList = 5, //数据列表节
|
| | | };
|
| | |
|
| | | struct stSectionDef
|
| | | {
|
| | | int nSectionType;
|
| | | CStringA SectionName;
|
| | | };
|
| | | stSectionDef SectionDef[5] =
|
| | | {
|
| | | {SectionSysCfg,"SYSCFG"},
|
| | | {SectionProg,"PROG"},
|
| | | {SectionAnno,"COMMENT"},
|
| | | {SectionCoilList,"MONCOILLIST"},
|
| | | {SectionDataList,"MONDATALIST"},
|
| | | };
|
| | |
|
| | | int nSectionDefCount = sizeof(SectionDef) / sizeof(stSectionDef);
|
| | | int TxtToSection(CStringA txt);
|
| | | int GetSectionTxt(int nSectionType, CStringA& txt);
|
| | | int ScanSections();
|
| | |
|
| | | struct stSection {
|
| | | int nSectionType;
|
| | | int nSectionLineNo;
|
| | | int nLines;
|
| | | };
|
| | | stSection Sections[100] = { 0 };
|
| | | int nSectionCount;
|
| | |
|
| | | int GetSectionPos(int nSectionType, int* nSectionLine, int* nSectionLines);
|
| | |
|
| | | // 操作
|
| | | public:
|
| | | int TxtToOp(CStringA optxt, int* ParamCount, int* ParamType);
|
| | | int OpToTxt(int nOp, CStringA & OpTxt);
|
| | | int OpToShowTxt(int nOp, CStringA & OpShowTxt);
|
| | |
|
| | | int TxtToCoilType(CStringA Typetxt, int* nCoilType, int* CoilAddr);
|
| | | int CoilTypeToTxt(int nType, CStringA & typeTxt);
|
| | |
|
| | | int TxtToDataType(CStringA Typetxt, int * nDataType, int* nDataAddr);
|
| | | int DataTypeToTxt(int nType, CStringA & typeTxt);
|
| | |
|
| | | int TransLinesToProg(const CStringArray & txtLines, int StartLine = 0, int ProgLines = -1);
|
| | |
|
| | | int TransFileToProg(CStringA ProgTxt);
|
| | | int TransToTxt(CStringA &ProgTxt);
|
| | |
|
| | | int TransTxtToProg(CStringA ProgTxtA);
|
| | | int ReadAnnoFromTxt(CStringA AnnoTxtA);
|
| | |
|
| | | int TransProgToBin();
|
| | | int TransBinToProg();
|
| | |
|
| | |
|
| | | int LoadFromFile(CString sFilePathName);
|
| | | int SaveToFile(CString sFilePathName);
|
| | |
|
| | | stProg Progs[2048] = { 0 };
|
| | | int ProgTrace[2048] = { 0 };
|
| | | int m_nProgSteps = 0;
|
| | | stBinProg1 BinProgs[2000];
|
| | | int nBinProgSteps = 0;
|
| | |
|
| | |
|
| | | int nScanCount = 0;
|
| | | int GetAnno(unsigned short nType, unsigned short nAddr, CString & sAnno);
|
| | | int SetAnno(CString sCoilName, CString sAnno);
|
| | | int SetAnno(unsigned short nType, unsigned short nAddr, CString sCoilName, CString sAnno);
|
| | |
|
| | | // 重写
|
| | | public:
|
| | |
| | | virtual void Dump(CDumpContext& dc) const;
|
| | | #endif
|
| | |
|
| | | enum UpdataHint {
|
| | | UpdateAll=0,
|
| | | UpdateProg=1,
|
| | | UpdateStat=2,
|
| | | };
|
| | | protected:
|
| | |
|
| | | // 生成的消息映射函数
|
| | |
| | | // 用于为搜索处理程序设置搜索内容的 Helper 函数
|
| | | void SetSearchContent(const CString& value);
|
| | | #endif // SHARED_HANDLERS
|
| | | public:
|
| | | int SetCommParam();
|
| | | int Connect();
|
| | | int DisConnect();
|
| | | int SendPacket(void * pBuf, int Len);
|
| | | int RecvPacket(void * pBuf, int Len);
|
| | |
|
| | | CView * CMTerm1Doc::FindView(CRuntimeClass * pClass);
|
| | |
|
| | | virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
|
| | | virtual BOOL OnSaveDocument(LPCTSTR lpszPathName);
|
| | | virtual void OnCloseDocument();
|
| | |
|
| | | afx_msg void OnUploadFromPlc();
|
| | | afx_msg void OnOnline();
|
| | | afx_msg void OnUpdateOnline(CCmdUI *pCmdUI);
|
| | | afx_msg void OnOffline();
|
| | | afx_msg void OnUpdateOffline(CCmdUI *pCmdUI);
|
| | | afx_msg void OnPlcRun();
|
| | | afx_msg void OnUpdatePlcRun(CCmdUI *pCmdUI);
|
| | | afx_msg void OnDownloadToPlc();
|
| | | afx_msg void OnUpdateDownloadToPlc(CCmdUI *pCmdUI);
|
| | | afx_msg void OnComunicationSet();
|
| | | afx_msg void OnPlcSysregSet();
|
| | |
|
| | | afx_msg void OnMenuViewLds();
|
| | | afx_msg void OnMenuViewBld();
|
| | | afx_msg void OnMenuViewBnl();
|
| | | afx_msg void OnMenuShowConsole();
|
| | |
|
| | | afx_msg void OnMenuCommTest();
|
| | |
|
| | | int GetCoilValue(int nCoilType, int nCoilAddr);
|
| | | int SetCoilValue(int nCoilType, int nCoilAddr, int nCoilValue);
|
| | |
|
| | | int GetVarData(int nDataType, int nDataAddr);
|
| | | int SetVarData(int nDataType, int nDataAddr, int nDataValue);
|
| | |
|
| | |
|
| | | void OnTimer(UINT_PTR nIDEvent);
|
| | |
|
| | | int StartPLC();
|
| | | int StopPLC();
|
| | |
|
| | |
|
| | | afx_msg void OnSimulate();
|
| | | afx_msg void OnUpdateSimulate(CCmdUI *pCmdUI);
|
| | | int DownloadToPLC();
|
| | |
|
| | | int AddMonitorCoil(int nCoilType, int nCoilAddr, int nCount);
|
| | | int AddMonitorData(int nDataType, int nDataAddr, int nDataCount);
|
| | | int ClearMonitor();
|
| | | int DoPLCMonitor(); |
| | | afx_msg void OnMenuStatusShow();
|
| | | afx_msg void OnMenuFactCfg();
|
| | | afx_msg void OnMenuDatetimeSet();
|
| | | afx_msg void OnMenuEventLog();
|
| | | };
|