/* */ #pragma once #include "KDefine.h" typedef struct tagInfoBlockHdr { unsigned short nBlkSign; // ¿ªÊ¼±êÖ¾ unsigned short nBlkTypeVer; // ÀàÐͺͰ汾 unsigned short nBlkSize; // Block ´óС, °üÀ¨¿ªÊ¼ºÍ½áÊø±êÖ¾ unsigned short Pad1; }stInfoBlockHdr; typedef struct tagInfoBlockTail { unsigned short CRC16; unsigned short EndSign; }stInfoBlockTail; typedef struct tagBtLdrInfoBlock { stInfoBlockHdr Hdr; unsigned short nBtldrVer; unsigned short nBtldrDevice; unsigned short nBtldrSize; // Éè¼Æ´óС unsigned short nBtldrDataSize; //´úÂë´óС unsigned int nBtldr_AppAddr; unsigned int nBtldr_NewAppInfoAddr; unsigned int nBtldr_NewAppAddr; stInfoBlockTail tail; }stBtLdrInfoBlock, * pBtLdrInfoBlock; typedef struct tagAppInfoBlock { stInfoBlockHdr Hdr; unsigned short nAppVer; unsigned short nAppDevice; unsigned short nAppSize; // Éè¼Æ´óС unsigned short nAppDataSize; //´úÂë´óС unsigned int nAppStartAddr; unsigned int nAppStartOffset; unsigned int nApp; stInfoBlockTail tail; }stAppInfoBlock, * pAppInfoBlock; class KMachine { public: KMachine::KMachine(); KMachine::~KMachine(); stKMem KMem; double StartTime; int nScanCount = 0; int ProgTrace[2048] = { 0 }; stBinProg1 BinProgs[2000]; int nBinProgSteps = 0; int m_bPlcRunning = 0; double GetTimemS(); int GetTick100uS(); int Init(); int Download(stBinProg1 * pBinrog, int nBinSteps); int Upload(); int StartPLC(); int StopPLC(); int AddMonitor(); int ClearMonitor(); int DoMonitor(); 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); int InitTimer(int nIndex, int nType); int RunTimer(int nIndex, int SV); int StopTimer(int nIndex); int ResetTimer(int nIndex); int SetTimerValue(int nIndex, int bSet, int SV); int ProcessTimer(int nIndex); int IsTimerOn(int nIndex); int GetTimerSV(int nIndex); int GetTimerEV(int nIndex); int PushInVal(void); int PopOutVal(void); // int ProcessPLCProg(const stProg * prog, int nSize); int ProcPLC(); int ProcessPLCBinProg(const stBinProg1 * pBinprog, int nProgSteps); };