提交 | 用户 | age
|
0a20f7
|
1 |
/*
|
Q |
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
*/
|
|
7 |
#pragma once
|
|
8 |
|
|
9 |
#define TYPECOIL 0x00
|
|
10 |
#define TYPEDATA 0x80
|
|
11 |
|
|
12 |
#define TOTAL_WDFS (16) //Total DF Count
|
|
13 |
#define TOTAL_CurVAL (16) //
|
|
14 |
|
|
15 |
//extern unsigned short X[256];
|
|
16 |
//extern unsigned short Y[256];
|
|
17 |
//extern unsigned short R[256];
|
|
18 |
|
|
19 |
#define TOTALTIMERS (64)
|
|
20 |
#define TICK_OF_MS (10) //1ms
|
|
21 |
#define TICK_OF_RS (100) //10mS
|
|
22 |
#define TICK_OF_XS (1000) //100mS
|
|
23 |
#define TICK_OF_YS (10000) //1S
|
|
24 |
|
|
25 |
|
|
26 |
enum enKLCoilTypes
|
|
27 |
{
|
|
28 |
KLCoilTypeX = 0 | TYPECOIL, //X Input
|
|
29 |
KLCoilTypeY = 1 | TYPECOIL, //Y Output
|
|
30 |
KLCoilTypeR = 2 | TYPECOIL, //R register
|
|
31 |
KLCoilTypeLX = 3 | TYPECOIL, //Link register
|
|
32 |
KLCoilTypeLY = 4 | TYPECOIL, //Link register
|
|
33 |
KLCoilTypeT = 5 | TYPECOIL, //Timer
|
|
34 |
KLCoilTypeC = 6 | TYPECOIL, //Counter
|
|
35 |
KLCoilTypeLR = 7 | TYPECOIL, //Link register
|
|
36 |
KLCoilTypeSR = 8 | TYPECOIL, //Link register
|
|
37 |
|
|
38 |
};
|
|
39 |
enum enKLDataTypes
|
|
40 |
{
|
|
41 |
KLDataTypeDEC = 0 | TYPEDATA,
|
|
42 |
KLDataTypeHEX = 1 | TYPEDATA,
|
|
43 |
KLDataTypeFloat = 2 | TYPEDATA,
|
|
44 |
KLDataTypeWX = 3 | TYPEDATA,
|
|
45 |
KLDataTypeWY = 4 | TYPEDATA,
|
|
46 |
KLDataTypeWR = 5 | TYPEDATA,
|
|
47 |
KLDataTypeWLX = 6 | TYPEDATA,
|
|
48 |
KLDataTypeWLY = 7 | TYPEDATA,
|
|
49 |
KLDataTypeDT = 8 | TYPEDATA,
|
|
50 |
KLDataTypeSDT = 9 | TYPEDATA,
|
|
51 |
KLDataTypeWSR = 10 | TYPEDATA,
|
|
52 |
KLDataTypeSV = 11 | TYPEDATA,
|
|
53 |
KLDataTypeEV = 12 | TYPEDATA,
|
|
54 |
KLDataTypeLD = 13 | TYPEDATA,
|
|
55 |
KLDataSysCfg = 25 | TYPEDATA,
|
|
56 |
KLDataTypeFlash = 33 | TYPEDATA,
|
|
57 |
KLDataTypeTest = 254 | TYPEDATA,
|
|
58 |
};
|
|
59 |
enum enKLDataCounts
|
|
60 |
{
|
|
61 |
KLDataDTCount = 256,
|
|
62 |
KLDataSDTCount = 256,
|
|
63 |
|
|
64 |
KLDataWXCount = 16,
|
|
65 |
KLDataWYCount = 16,
|
|
66 |
KLDataWRCount = 16,
|
|
67 |
KLDataLDCount = 64,
|
|
68 |
KLDataWLCount = 8,
|
|
69 |
|
|
70 |
KLCoilXCount = KLDataWXCount * 16,
|
|
71 |
KLCoilYCount = KLDataWYCount * 16,
|
|
72 |
KLCoilRCount = KLDataWRCount * 16,
|
|
73 |
|
|
74 |
KLCoilTCount = 64,
|
|
75 |
KLCoilCCount = KLCoilTCount,
|
|
76 |
KLDataSVCount = KLCoilTCount,
|
|
77 |
KLDataEVCount = KLCoilTCount,
|
|
78 |
|
|
79 |
KLCoilLXCount = 128,
|
|
80 |
KLCoilLYCount = 128,
|
|
81 |
KLCoilLRCount = 128,
|
|
82 |
KLCoilSRCount = 128,
|
|
83 |
|
|
84 |
|
|
85 |
};
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
typedef struct tagTimer
|
|
90 |
{
|
|
91 |
unsigned int LastActTime;
|
|
92 |
union {
|
|
93 |
unsigned short StatByte;
|
|
94 |
struct
|
|
95 |
{
|
|
96 |
unsigned short nScale : 2; //Time Scale, 0:1ms 1:10ms 2:100ms 3:1S
|
|
97 |
unsigned short nType : 1; //0 : timer 1 : counter ;
|
|
98 |
unsigned short nDir : 1; //0 : count down. 1 count up;
|
|
99 |
unsigned short nInited : 1;
|
|
100 |
unsigned short bSet : 1;
|
|
101 |
unsigned short bTon : 1;
|
|
102 |
|
|
103 |
};
|
|
104 |
// stTimerStat Stat;
|
|
105 |
};
|
|
106 |
}stTimer;
|
|
107 |
|
|
108 |
typedef struct tagKMem
|
|
109 |
{
|
|
110 |
unsigned short WDFs[TOTAL_WDFS];
|
|
111 |
unsigned char CurVALs[TOTAL_CurVAL];
|
|
112 |
unsigned char CurVAL;
|
|
113 |
|
|
114 |
stTimer Timers[TOTALTIMERS];
|
|
115 |
|
|
116 |
unsigned short WX[KLDataWXCount]; //
|
|
117 |
unsigned short WY[KLDataWYCount]; //
|
|
118 |
unsigned short WR[KLDataWRCount];
|
|
119 |
unsigned short WT[16];
|
|
120 |
|
|
121 |
unsigned short WC[16];
|
|
122 |
unsigned short EV[KLDataEVCount];
|
|
123 |
unsigned short SV[KLDataSVCount];
|
|
124 |
|
|
125 |
unsigned short WLX[16]; //
|
|
126 |
unsigned short WLY[16];
|
|
127 |
unsigned short WLR[16];
|
|
128 |
unsigned short WSR[16];
|
|
129 |
unsigned short DT[KLDataDTCount];
|
|
130 |
|
|
131 |
union {
|
|
132 |
unsigned int SDD[KLDataSDTCount / 2];
|
|
133 |
unsigned short SDT[KLDataSDTCount];
|
|
134 |
unsigned char SDB[KLDataSDTCount * 2];
|
|
135 |
struct {
|
|
136 |
unsigned int EffJumperSW;
|
|
137 |
unsigned int CurJumperSW;
|
|
138 |
unsigned int haltick;
|
|
139 |
unsigned int nRunCount;
|
|
140 |
unsigned int RunStat;
|
|
141 |
unsigned int ErrStat;
|
|
142 |
unsigned int PwrOnCount;
|
|
143 |
unsigned int ThisRunTime;
|
|
144 |
unsigned int TotalRunTime;
|
|
145 |
unsigned int CurTimeSec;
|
|
146 |
unsigned int PwrFailCount;
|
|
147 |
unsigned int LastPwrFailTime;
|
|
148 |
unsigned int LastScanTime;
|
|
149 |
unsigned int ScanTimeuS;
|
|
150 |
unsigned int MinScanTimeuS;
|
|
151 |
unsigned int MaxScanTimeuS;
|
|
152 |
unsigned int nEventCount;
|
|
153 |
unsigned int nEventMinIndex;
|
|
154 |
unsigned int nEventMaxIndex;
|
|
155 |
unsigned int Rev2[5];
|
|
156 |
unsigned short ADCValues[20];
|
|
157 |
};
|
|
158 |
};
|
|
159 |
int Reserverd5[1024];
|
|
160 |
}stKMem;
|
|
161 |
|
|
162 |
|
|
163 |
enum enOpType
|
|
164 |
{
|
|
165 |
OP_NONE = 0,
|
|
166 |
OP_NOP = 0,
|
|
167 |
OP_ST = 1, //
|
|
168 |
OP_ST_ = 2, //
|
|
169 |
OP_AN = 3, //
|
|
170 |
OP_AN_ = 4, //
|
|
171 |
OP_OR = 5, //
|
|
172 |
OP_OR_ = 6, //
|
|
173 |
OP_NOT = 7, //
|
|
174 |
OP_ANS = 8, //
|
|
175 |
OP_ORS = 9, //
|
|
176 |
|
|
177 |
OP_PSHS = 10, //
|
|
178 |
OP_RDS = 11, //
|
|
179 |
OP_POPS = 12, //
|
|
180 |
|
|
181 |
OP_OUT = 16, //
|
|
182 |
OP_SET = 17, //
|
|
183 |
OP_RESET = 18, //
|
|
184 |
OP_DF = 19, //
|
|
185 |
OP_DF_ = 20, //
|
|
186 |
|
|
187 |
OP_ST_EQ, //
|
|
188 |
OP_ST_LT, //
|
|
189 |
OP_ST_GT, //
|
|
190 |
OP_ST_LE, //
|
|
191 |
OP_ST_GE, //
|
|
192 |
OP_ST_NE, //
|
|
193 |
OP_AN_EQ, //
|
|
194 |
OP_AN_LT, //
|
|
195 |
OP_AN_GT,
|
|
196 |
OP_AN_LE,
|
|
197 |
OP_AN_GE,
|
|
198 |
OP_AN_NE,
|
|
199 |
OP_OR_EQ,
|
|
200 |
OP_OR_LT,
|
|
201 |
OP_OR_GT,
|
|
202 |
OP_OR_LE,
|
|
203 |
OP_OR_GE,
|
|
204 |
OP_OR_NE,
|
|
205 |
|
|
206 |
|
|
207 |
OP_MV = 51,
|
|
208 |
OP_INC = 52,
|
|
209 |
OP_ADD2 = 53,
|
|
210 |
OP_ADD3 = 54,
|
|
211 |
OP_DEC = 55,
|
|
212 |
OP_SUB2 = 56,
|
|
213 |
OP_SUB3 = 57,
|
|
214 |
OP_MUL = 58,
|
|
215 |
OP_DIV = 59,
|
|
216 |
OP_BKMV = 60,
|
|
217 |
OP_COPY = 61,
|
|
218 |
OP_CLR = 62,
|
|
219 |
|
|
220 |
OP_BRK,
|
|
221 |
OP_PAUSE,
|
|
222 |
OP_JP,
|
|
223 |
OP_CALL,
|
|
224 |
|
|
225 |
OP_TML = 0xC8, //
|
|
226 |
OP_TMR = 0xDC, //
|
|
227 |
OP_TMX = 0xDD, //
|
|
228 |
OP_TMY = 0xFA, //
|
|
229 |
|
|
230 |
};
|
|
231 |
|
|
232 |
typedef struct stBinProg1
|
|
233 |
{
|
|
234 |
unsigned char nOp;
|
|
235 |
unsigned char nParamType;
|
|
236 |
unsigned short nParamAddr;
|
|
237 |
}stBinProg1;
|
|
238 |
typedef struct stBinProg15
|
|
239 |
{ //定时器
|
|
240 |
//单参数高级指令
|
|
241 |
unsigned char nOp;
|
|
242 |
unsigned char nOpNum;
|
|
243 |
unsigned short nParamAddr1;
|
|
244 |
unsigned char nParamType1;
|
|
245 |
unsigned char resvr1;
|
|
246 |
unsigned short resvr2;
|
|
247 |
}stBinProg15;
|
|
248 |
typedef struct stBinProg2
|
|
249 |
{ //比较指令
|
|
250 |
//双参数高级指令
|
|
251 |
unsigned char nOp;
|
|
252 |
unsigned char nOpNum;
|
|
253 |
unsigned short nParamAddr1;
|
|
254 |
unsigned char nParamType1;
|
|
255 |
unsigned char nParamType2;
|
|
256 |
unsigned short nParamAddr2;
|
|
257 |
}stBinProg2;
|
|
258 |
typedef struct stBinProg3
|
|
259 |
{ //三参数高级指令
|
|
260 |
unsigned char nOp;
|
|
261 |
unsigned char nOpNum;
|
|
262 |
unsigned short nParamAddr1;
|
|
263 |
unsigned char nParamType1;
|
|
264 |
unsigned char nParamType2;
|
|
265 |
unsigned short nParamAddr2;
|
|
266 |
unsigned char resvr1;
|
|
267 |
unsigned char nParamType3;
|
|
268 |
unsigned short nParamAddr3;
|
|
269 |
}stBinProg3;
|
|
270 |
|