提交 | 用户 | age
|
418cb3
|
1 |
/*
|
Q |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
*/
|
|
7 |
#pragma once
|
|
8 |
#include "KDefine.h"
|
61deef
|
9 |
typedef struct tagInfoBlockHdr {
|
Q |
10 |
unsigned short nBlkSign; // 开始标志
|
|
11 |
unsigned short nBlkTypeVer; // 类型和版本
|
|
12 |
unsigned short nBlkSize; // Block 大小, 包括开始和结束标志
|
|
13 |
unsigned short Pad1;
|
|
14 |
}stInfoBlockHdr;
|
|
15 |
|
|
16 |
typedef struct tagInfoBlockTail {
|
|
17 |
|
|
18 |
unsigned short CRC16;
|
|
19 |
unsigned short EndSign;
|
|
20 |
}stInfoBlockTail;
|
|
21 |
|
|
22 |
typedef struct tagBtLdrInfoBlock {
|
|
23 |
stInfoBlockHdr Hdr;
|
|
24 |
unsigned short nBtldrVer;
|
|
25 |
unsigned short nBtldrDevice;
|
|
26 |
unsigned short nBtldrSize; // 设计大小
|
|
27 |
unsigned short nBtldrDataSize; //代码大小
|
|
28 |
unsigned int nBtldr_AppAddr;
|
|
29 |
unsigned int nBtldr_NewAppInfoAddr;
|
|
30 |
unsigned int nBtldr_NewAppAddr;
|
|
31 |
stInfoBlockTail tail;
|
|
32 |
}stBtLdrInfoBlock, * pBtLdrInfoBlock;
|
|
33 |
|
|
34 |
typedef struct tagAppInfoBlock {
|
|
35 |
stInfoBlockHdr Hdr;
|
|
36 |
unsigned short nAppVer;
|
|
37 |
unsigned short nAppDevice;
|
|
38 |
unsigned short nAppSize; // 设计大小
|
|
39 |
unsigned short nAppDataSize; //代码大小
|
|
40 |
unsigned int nAppStartAddr;
|
|
41 |
unsigned int nAppStartOffset;
|
|
42 |
unsigned int nApp;
|
|
43 |
stInfoBlockTail tail;
|
|
44 |
}stAppInfoBlock, * pAppInfoBlock;
|
|
45 |
|
418cb3
|
46 |
class KMachine
|
Q |
47 |
{
|
|
48 |
|
|
49 |
public:
|
|
50 |
KMachine::KMachine();
|
|
51 |
KMachine::~KMachine();
|
|
52 |
|
|
53 |
stKMem KMem;
|
|
54 |
double StartTime;
|
|
55 |
int nScanCount = 0;
|
|
56 |
int ProgTrace[2048] = { 0 };
|
|
57 |
|
|
58 |
stBinProg1 BinProgs[2000];
|
|
59 |
int nBinProgSteps = 0;
|
|
60 |
|
|
61 |
int m_bPlcRunning = 0;
|
|
62 |
|
|
63 |
double GetTimemS();
|
|
64 |
int GetTick100uS();
|
|
65 |
|
|
66 |
int Init();
|
|
67 |
|
|
68 |
int Download(stBinProg1 * pBinrog, int nBinSteps);
|
|
69 |
|
|
70 |
int Upload();
|
|
71 |
int StartPLC();
|
|
72 |
int StopPLC();
|
|
73 |
int AddMonitor();
|
|
74 |
int ClearMonitor();
|
|
75 |
int DoMonitor();
|
|
76 |
|
|
77 |
|
|
78 |
int GetCoilValue(int nCoilType, int nCoilAddr);
|
|
79 |
int SetCoilValue(int nCoilType, int nCoilAddr, int nCoilValue);
|
|
80 |
|
|
81 |
int GetVarData(int nDataType, int nDataAddr);
|
|
82 |
int SetVarData(int nDataType, int nDataAddr, int nDataValue);
|
|
83 |
|
|
84 |
int InitTimer(int nIndex, int nType);
|
|
85 |
int RunTimer(int nIndex, int SV);
|
|
86 |
int StopTimer(int nIndex);
|
|
87 |
int ResetTimer(int nIndex);
|
|
88 |
int SetTimerValue(int nIndex, int bSet, int SV);
|
|
89 |
int ProcessTimer(int nIndex);
|
|
90 |
int IsTimerOn(int nIndex);
|
|
91 |
int GetTimerSV(int nIndex);
|
|
92 |
int GetTimerEV(int nIndex);
|
|
93 |
|
|
94 |
|
|
95 |
int PushInVal(void);
|
|
96 |
int PopOutVal(void);
|
|
97 |
// int ProcessPLCProg(const stProg * prog, int nSize);
|
|
98 |
int ProcPLC();
|
61deef
|
99 |
int ProcessPLCBinProg(const stBinProg1 * pBinprog, int nProgSteps);
|
418cb3
|
100 |
|
Q |
101 |
};
|
|
102 |
|