提交 | 用户 | age
|
418cb3
|
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
|
4ed7fc
|
37 |
KLCoilTypeP = 9 | TYPECOIL, //P register
|
Z |
38 |
KLCoilTypeE = 10 | TYPECOIL, //E register
|
418cb3
|
39 |
|
Q |
40 |
};
|
|
41 |
enum enKLDataTypes
|
|
42 |
{
|
|
43 |
KLDataTypeDEC = 0 | TYPEDATA,
|
|
44 |
KLDataTypeHEX = 1 | TYPEDATA,
|
|
45 |
KLDataTypeFloat = 2 | TYPEDATA,
|
|
46 |
KLDataTypeWX = 3 | TYPEDATA,
|
|
47 |
KLDataTypeWY = 4 | TYPEDATA,
|
|
48 |
KLDataTypeWR = 5 | TYPEDATA,
|
|
49 |
KLDataTypeWLX = 6 | TYPEDATA,
|
|
50 |
KLDataTypeWLY = 7 | TYPEDATA,
|
|
51 |
KLDataTypeDT = 8 | TYPEDATA,
|
|
52 |
KLDataTypeSDT = 9 | TYPEDATA,
|
|
53 |
KLDataTypeWSR = 10 | TYPEDATA,
|
|
54 |
KLDataTypeSV = 11 | TYPEDATA,
|
|
55 |
KLDataTypeEV = 12 | TYPEDATA,
|
|
56 |
KLDataTypeLD = 13 | TYPEDATA,
|
|
57 |
KLDataSysCfg = 25 | TYPEDATA,
|
|
58 |
KLDataTypeFlash = 33 | TYPEDATA,
|
|
59 |
KLDataTypeWDT = 41 | TYPEDATA,
|
|
60 |
KLDataTypeKBD = 51 | TYPEDATA,
|
|
61 |
KLDataTypeTest = 254 | TYPEDATA,
|
|
62 |
};
|
|
63 |
enum enKLDataCounts
|
|
64 |
{
|
|
65 |
KLDataDTCount = 256,
|
|
66 |
KLDataSDTCount = 256,
|
|
67 |
|
|
68 |
KLDataWXCount = 16,
|
|
69 |
KLDataWYCount = 16,
|
|
70 |
KLDataWRCount = 16,
|
|
71 |
KLDataLDCount = 64,
|
|
72 |
KLDataWLCount = 8,
|
|
73 |
|
|
74 |
KLCoilXCount = KLDataWXCount * 16,
|
|
75 |
KLCoilYCount = KLDataWYCount * 16,
|
|
76 |
KLCoilRCount = KLDataWRCount * 16,
|
|
77 |
|
|
78 |
KLCoilTCount = 64,
|
|
79 |
KLCoilCCount = KLCoilTCount,
|
|
80 |
KLDataSVCount = KLCoilTCount,
|
|
81 |
KLDataEVCount = KLCoilTCount,
|
|
82 |
|
|
83 |
KLCoilLXCount = 128,
|
|
84 |
KLCoilLYCount = 128,
|
|
85 |
KLCoilLRCount = 128,
|
|
86 |
KLCoilSRCount = 128,
|
|
87 |
|
|
88 |
|
|
89 |
};
|
|
90 |
|
|
91 |
enum enInputFilter
|
|
92 |
{
|
|
93 |
InputFilter_None = 0,
|
|
94 |
InputFilter_1mS = 1,
|
|
95 |
InputFilter_2mS = 2,
|
|
96 |
InputFilter_4mS = 3,
|
|
97 |
InputFilter_8mS = 4,
|
|
98 |
InputFilter_16mS = 5,
|
|
99 |
InputFilter_32mS = 6,
|
|
100 |
InputFilter_64mS = 7,
|
|
101 |
InputFilter_128mS = 8,
|
|
102 |
InputFilter_256mS = 9,
|
|
103 |
};
|
|
104 |
|
|
105 |
enum enOutputHold
|
|
106 |
{
|
|
107 |
Output_Hold = 0,
|
|
108 |
Output_Set_0 = 1,
|
|
109 |
Output_Set_1 = 2,
|
|
110 |
};
|
|
111 |
|
61deef
|
112 |
enum enPortHardType
|
418cb3
|
113 |
{
|
61deef
|
114 |
PortHardType_None = 0, // 空接口,无类型
|
Q |
115 |
PortHardType_SOFT = 1, // 软件虚拟接口,可能是隧道等.
|
|
116 |
PortHardType_UART = 2, // 串行接口
|
|
117 |
PortHardType_RS232 = 3, // 232接口
|
|
118 |
PortHardType_RS485 = 4, // 485接口
|
|
119 |
PortHardType_SLP = 5, // 单总线接口
|
|
120 |
PortHardType_RF = 6, // 无线接口
|
|
121 |
PortHardType_LORA = 7, // LoRa无线接口
|
|
122 |
PortHardType_OPTI = 8, // 光纤接口
|
|
123 |
PortHardType_ETH = 9, // 以太网接口
|
|
124 |
PortHardType_WIFI = 10, // WiFi接口
|
|
125 |
PortHardType_BT = 11, // 以太网接口
|
|
126 |
|
418cb3
|
127 |
};
|
61deef
|
128 |
static CString PortHardTypeToStr(int nPortHardType)
|
Q |
129 |
{
|
|
130 |
static CString s1;
|
|
131 |
switch (nPortHardType)
|
|
132 |
{
|
|
133 |
case PortHardType_None:
|
|
134 |
return _T("NULL");
|
|
135 |
case PortHardType_SOFT: // = 1, // 软件虚拟接口,可能是隧道等.
|
|
136 |
return _T("Soft");
|
|
137 |
case PortHardType_UART: // = 2, // 串行接口
|
|
138 |
return _T("UART");
|
|
139 |
case PortHardType_RS232: //= 3, // 232接口
|
|
140 |
return _T("RS232");
|
|
141 |
case PortHardType_RS485: //= 4, // 485接口
|
|
142 |
return _T("RS485");
|
|
143 |
case PortHardType_SLP: //= 5, // 单总线接口
|
|
144 |
return _T("SLP");
|
|
145 |
case PortHardType_RF: //= 6, // 无线接口
|
|
146 |
return _T("RF");
|
|
147 |
case PortHardType_LORA: //= 7, // LoRa无线接口
|
|
148 |
return _T("LoRa");
|
|
149 |
case PortHardType_OPTI: //= 8, // 光纤接口
|
|
150 |
return _T("Opti");
|
|
151 |
case PortHardType_ETH: //= 9, // 以太网接口
|
|
152 |
return _T("ETH");
|
|
153 |
case PortHardType_WIFI: //= 10, // WiFi接口
|
|
154 |
return _T("WiFi");
|
|
155 |
case PortHardType_BT: //= 11, // 以太网接口
|
|
156 |
return _T("BT");
|
|
157 |
default:
|
|
158 |
return _T("UNKNOWN");
|
|
159 |
break;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
enum enPortUseType
|
|
164 |
{
|
|
165 |
PortUse_Default = 0, //默认
|
|
166 |
PortUse_Console = 1, //控制台接口
|
|
167 |
PortUse_KLink = 2, //KLink通讯
|
|
168 |
PortUse_KBus = 3, //KBus通讯
|
|
169 |
PortUse_KNet = 4, // KNet通讯
|
|
170 |
PortUse_SLP = 5, // SLP单总线
|
|
171 |
PortUse_KRF = 6, // 无线通讯
|
|
172 |
PortUse_ModbusRTU = 7, //Modbus RTU 通讯
|
|
173 |
PortUse_ModbusTCP = 8, //Modbus TCP 通讯
|
|
174 |
PortUse_Com = 9, // 计算机通讯
|
|
175 |
PortUse_Gen = 10, //通用通讯,自由口
|
|
176 |
};
|
|
177 |
|
|
178 |
static CString PortUseTypeToStr(int nPortHardType)
|
|
179 |
{
|
|
180 |
static CString s1;
|
|
181 |
switch (nPortHardType)
|
|
182 |
{
|
|
183 |
case PortUse_Default: // = 0 默认
|
|
184 |
return _T("NULL");
|
|
185 |
case PortUse_Console: // = 1, //控制台接口
|
|
186 |
return _T("终端");
|
|
187 |
case PortUse_KLink: // = 2, //KLink通讯
|
|
188 |
return _T("KLink");
|
|
189 |
case PortUse_KBus: //= 3, // KNet通讯
|
|
190 |
return _T("KBus");
|
|
191 |
case PortUse_KNet: //= 4, // 串行接口
|
|
192 |
return _T("KNet");
|
|
193 |
case PortHardType_SLP: //= 5, // SLP单总线
|
|
194 |
return _T("KSLP");
|
|
195 |
case PortUse_KRF: //= 6, // 无线通讯
|
|
196 |
return _T("KwRF");
|
|
197 |
case PortUse_ModbusRTU: //= 7, // Modbus RTU 通讯
|
|
198 |
return _T("ModbusRTU");
|
|
199 |
case PortUse_ModbusTCP: //= 8, // Modbus TCP 通讯
|
|
200 |
return _T("ModbusTCP");
|
|
201 |
case PortUse_Com: //= 9, // 计算机通讯
|
|
202 |
return _T("");
|
|
203 |
case PortUse_Gen: //= 10, // 通用通讯,自由口
|
|
204 |
return _T("WiFi");
|
|
205 |
default:
|
|
206 |
return _T("UNKNOWN");
|
|
207 |
break;
|
|
208 |
}
|
|
209 |
}
|
|
210 |
|
|
211 |
enum enServiceReqs
|
|
212 |
{
|
|
213 |
ReqNone,
|
|
214 |
ReqInit,
|
|
215 |
ReqReset,
|
|
216 |
ReqStop,
|
|
217 |
ReqRun,
|
|
218 |
ReqBlinkLED,
|
|
219 |
ReqStartDiag,
|
|
220 |
ReqStopDiag,
|
|
221 |
ReqPortChildInfo,
|
|
222 |
ReqPortChnInfo,
|
|
223 |
ReqUpdateFirm,
|
|
224 |
ReqUpdateFirmInfo,
|
|
225 |
|
|
226 |
ReqTransFirmware,
|
|
227 |
ReqTransCfg,
|
|
228 |
ReqTransProg,
|
|
229 |
ReqTransData,
|
|
230 |
ReqTransBlink,
|
|
231 |
ReqTransChild,
|
|
232 |
ReqTransInfo,
|
|
233 |
ReqTransOutBandData,
|
|
234 |
ReqRead1Bit,
|
|
235 |
ReqWrite1Bit,
|
|
236 |
ReqReadBits,
|
|
237 |
ReqWriteBits,
|
|
238 |
ReqReadData,
|
|
239 |
ReqWriteData,
|
|
240 |
ReqRemoteTran,
|
|
241 |
};
|
|
242 |
|
|
243 |
typedef struct tagPortAbility
|
|
244 |
{
|
|
245 |
USHORT ChildList : 1;
|
|
246 |
USHORT AccessChild : 1;
|
|
247 |
USHORT TranProg : 1;
|
|
248 |
USHORT TranCfg : 1;
|
|
249 |
USHORT Diag : 1;
|
|
250 |
USHORT TranOutBandData : 1;
|
|
251 |
USHORT Tunnel : 1;
|
|
252 |
USHORT TranFirmware : 1;
|
|
253 |
USHORT TranBlink : 1;
|
|
254 |
}stPortAbility;
|
|
255 |
|
|
256 |
// 各端口 互联 通信
|
|
257 |
typedef int (*CommFuncDef)(int ReqId, int nParam, void* pData, int len1);
|
|
258 |
typedef struct tagPortDef
|
|
259 |
{
|
|
260 |
union {
|
|
261 |
USHORT nPortType;
|
|
262 |
struct {
|
|
263 |
UCHAR nPortHardType;
|
|
264 |
UCHAR nPortUseType;
|
|
265 |
};
|
|
266 |
};
|
|
267 |
USHORT ability; //能力, 获取子机信息等。
|
|
268 |
UCHAR bEnable;
|
|
269 |
UCHAR bRunning;
|
|
270 |
UCHAR StationId;
|
|
271 |
UCHAR bMaster;
|
|
272 |
UCHAR nMaxStations;
|
|
273 |
UCHAR nCurStations;
|
|
274 |
UCHAR nHealth;
|
|
275 |
short PortConfigType;
|
|
276 |
short PortConfigSize;
|
|
277 |
short PortRunStatType;
|
|
278 |
short PortRunStatSize;
|
|
279 |
|
|
280 |
// CommFuncDef ReqCommFunc;
|
|
281 |
// func2 CommReq;
|
|
282 |
|
|
283 |
}stPortDef, * pstPortDef;
|
418cb3
|
284 |
|
Q |
285 |
enum enKeventType
|
|
286 |
{
|
|
287 |
EventTypeNone = 0,
|
|
288 |
EventTypePowerUp = 1,
|
|
289 |
EventTypePowerDown = 2,
|
|
290 |
EventTypePowerRecover = 3,
|
|
291 |
EventTypeConnected = 4,
|
|
292 |
EventTypeLostCon = 5,
|
|
293 |
EventTypeSetTime = 6,
|
|
294 |
EventTypeSysCfg = 7,
|
|
295 |
EventTypeProg = 8,
|
|
296 |
EventTypeForce = 9,
|
|
297 |
EventTypeClearEvent = 10,
|
|
298 |
EventType
|
|
299 |
};
|
61deef
|
300 |
|
Q |
301 |
typedef struct tagDevPortDef
|
|
302 |
{
|
|
303 |
union {
|
|
304 |
USHORT nPortType;
|
|
305 |
struct {
|
|
306 |
UCHAR nPortHardType;
|
|
307 |
UCHAR nPortUseType;
|
|
308 |
};
|
|
309 |
};
|
|
310 |
UCHAR bEnabled;
|
|
311 |
UCHAR bRunning;
|
|
312 |
UCHAR StationID;
|
|
313 |
UCHAR bMaster;
|
|
314 |
UCHAR MaxStations;
|
|
315 |
UCHAR CurStations;
|
|
316 |
UCHAR Health;
|
|
317 |
|
|
318 |
}stDevPortDef;
|
|
319 |
|
|
320 |
typedef struct tagDeviceDef
|
|
321 |
{
|
|
322 |
USHORT nDeviceTypeVer;
|
|
323 |
USHORT nProgVer;
|
|
324 |
UCHAR InBitCount;
|
|
325 |
UCHAR OutBitCount;
|
|
326 |
unsigned short nPortCount;
|
|
327 |
stDevPortDef Ports[8]; //最多8个通讯端口
|
|
328 |
}stDeviceDef;
|
|
329 |
|
|
330 |
typedef struct tagDeviceInfo // KBus 子机基本信息
|
|
331 |
{
|
|
332 |
unsigned short DeviceType; // 子机类型
|
|
333 |
union {
|
|
334 |
unsigned short DeviceVer; // 子机版本
|
|
335 |
struct {
|
|
336 |
unsigned char DeviceVerMinor;
|
|
337 |
unsigned char DeviceVerMajor;
|
|
338 |
};
|
|
339 |
};
|
|
340 |
unsigned char InBitCount; // 输入开关量数量
|
|
341 |
unsigned char OutBitCount; // 输出开关量数量
|
|
342 |
unsigned char ExInBitCount; // 扩展的输入开关量数量
|
|
343 |
unsigned char ExOutBitCount; // 扩展的输出开关量数量
|
|
344 |
unsigned char DWStartAddr; // 输出数据字数
|
|
345 |
unsigned char OutDWCount; // 输出数据字数
|
|
346 |
unsigned char AIWCount; // 输入模拟量通道(字)数 // 16位为一个字(通道)
|
|
347 |
unsigned char AQWCount; // 输出模拟量通道(字)数 // 16位为一个字(通道)
|
|
348 |
// unsigned char AIBits; // 每通道位数 // 16位以下
|
|
349 |
// unsigned char AQbits; // 每通道位数 // 16位以下
|
|
350 |
|
|
351 |
|
|
352 |
}stDeviceInfo;
|
418cb3
|
353 |
|
Q |
354 |
typedef struct tagInfoBlock // 20 bytes
|
|
355 |
{
|
|
356 |
// USHORT nBlockLenth;
|
|
357 |
USHORT nDeviceTypeVer; //device type x.y
|
|
358 |
// UCHAR nDevierVer;
|
61deef
|
359 |
union {
|
Q |
360 |
USHORT nProgVer; //prog version x.y
|
|
361 |
struct {
|
|
362 |
UCHAR nProgVerMinor;
|
|
363 |
UCHAR nProgVerMajor;
|
|
364 |
};
|
|
365 |
};
|
|
366 |
|
418cb3
|
367 |
USHORT nKLinkVer; //x.y
|
Q |
368 |
USHORT nKBusVer; //x.y
|
|
369 |
// USHORT nKNetVer; //x.y
|
|
370 |
// USHORT nKWLVer; //x.y
|
|
371 |
|
|
372 |
UCHAR nCapacity1; // ? K
|
|
373 |
UCHAR nCapacity2; // ? k
|
|
374 |
|
|
375 |
UCHAR nDInput;
|
|
376 |
UCHAR nDOutput;
|
|
377 |
UCHAR nAInput;
|
|
378 |
UCHAR nAOutput;
|
|
379 |
UCHAR nHInput;
|
|
380 |
UCHAR nHOutput;
|
|
381 |
UCHAR nExt1;
|
|
382 |
UCHAR nExt2;
|
|
383 |
UCHAR nLogSize;
|
|
384 |
UCHAR nPorts;
|
|
385 |
UCHAR nManSize;
|
|
386 |
UCHAR nAbility;
|
|
387 |
UCHAR nSwitchBits;
|
|
388 |
|
|
389 |
}stKMInfoBlock, *pKMInfoBlock;
|
|
390 |
|
|
391 |
typedef struct tagFactoryData //¹¤³§Á¿²ú²ÎÊý£¬Êý¾Ý
|
|
392 |
{
|
|
393 |
USHORT Sign1;
|
|
394 |
USHORT Seq1;
|
|
395 |
USHORT nModelNo;
|
|
396 |
USHORT nModelVer;
|
|
397 |
UINT nLotNo;
|
|
398 |
UINT nProductDateTime;
|
|
399 |
UINT SN1;
|
|
400 |
UINT nProtocalVer;
|
|
401 |
UINT nDefaultFunc;
|
|
402 |
UCHAR ModelStr[16];
|
|
403 |
UCHAR LOT_NO[16]; //
|
|
404 |
UCHAR SNStr[16];
|
|
405 |
unsigned short CRC1;
|
|
406 |
unsigned short EndSign1;
|
|
407 |
|
|
408 |
}stFactoryData, *pFactoryData;
|
|
409 |
|
61deef
|
410 |
typedef struct tagNewAppInfoBlock
|
Q |
411 |
{
|
|
412 |
unsigned short Sign;
|
|
413 |
unsigned short Version;
|
|
414 |
unsigned int Length;
|
|
415 |
unsigned int nCRC;
|
|
416 |
|
|
417 |
}stNewAppInfoBlock, * pNewAppInfoBlock;
|
418cb3
|
418 |
|
Q |
419 |
typedef struct tagKMFuncParam
|
|
420 |
{
|
|
421 |
USHORT EnablePLC : 1; //使能内部PLC功能
|
|
422 |
USHORT RunMode; //工作模式
|
|
423 |
}stKMFuncParam;
|
|
424 |
|
|
425 |
//输入输出地址映射
|
|
426 |
typedef struct tagAddrMapping
|
|
427 |
{
|
|
428 |
USHORT InputAddr;
|
|
429 |
USHORT OutputAddr;
|
|
430 |
USHORT WRAddr;
|
|
431 |
USHORT DTAddr;
|
|
432 |
}stAddrMapping;
|
|
433 |
|
|
434 |
typedef struct tagComPortParam //4 Bytes
|
|
435 |
{
|
|
436 |
USHORT WorkMode; /* 0-5=Default,KLink,KBus,KNet,RTU,Com,Gen */
|
|
437 |
USHORT Station; /* 0=From jumper */
|
|
438 |
USHORT BaudRate; /* =*100 Baudrate at which running */
|
|
439 |
USHORT ByteSize : 2; /* 0-1=Number of bits/byte, 7-8 */
|
|
440 |
USHORT Parity : 4; /* 0-4=None,Odd,Even,Mark,Space */
|
|
441 |
USHORT StopBits : 2; /* 0,1,2 = 1, 1.5, 2 */
|
|
442 |
USHORT EndType : 2; /* 0=ByChar, 1= ByTime */
|
|
443 |
USHORT EofChar : 4; /* 0,1,2 = None, CR, CR+LF, ETX; End of character */
|
|
444 |
USHORT SofChar : 2; /* 0,1,2 = None, STX */
|
|
445 |
USHORT EndTime; /*(*0.01mS) */
|
|
446 |
USHORT RecvAddr;
|
|
447 |
USHORT RecvSize;
|
|
448 |
|
|
449 |
}stComPortParam, *pstComPortParam;
|
|
450 |
|
|
451 |
|
|
452 |
typedef struct tagInputFilterParam
|
|
453 |
{
|
|
454 |
BYTE Filter0 : 4;
|
|
455 |
BYTE Filter1 : 4;
|
|
456 |
|
|
457 |
}stInputFilterParam;
|
|
458 |
|
|
459 |
typedef struct tagOutputHoldParam
|
|
460 |
{
|
|
461 |
BYTE Hold1 : 4;
|
|
462 |
BYTE Hold2 : 4;
|
|
463 |
}stOutputHoldParam;
|
|
464 |
// 硬件描述文件
|
61deef
|
465 |
typedef struct tagOutMapping
|
Q |
466 |
{
|
|
467 |
USHORT bitPos : 4;
|
|
468 |
USHORT byteAddr : 8;
|
|
469 |
USHORT type : 4;
|
|
470 |
}stOutMapping;
|
|
471 |
|
|
472 |
typedef struct tagCfgBlockInfo
|
|
473 |
{
|
|
474 |
UCHAR nBlockType;
|
|
475 |
UCHAR nBlockSize;
|
|
476 |
}stCfgBlockInfo;
|
418cb3
|
477 |
|
Q |
478 |
//#pragma pack(2)
|
61deef
|
479 |
|
418cb3
|
480 |
typedef struct tagKMSysCfg //120 Bytes total
|
Q |
481 |
{
|
61deef
|
482 |
USHORT Version; // SC0 // 2 Bytes
|
Q |
483 |
USHORT workmode; // SC1 // 2 Bytes 0=From jumper
|
|
484 |
USHORT SwitchFunc; // SC2 // 2 Bytes
|
|
485 |
USHORT nCfgBlockCount; // 2 Bytes
|
418cb3
|
486 |
|
61deef
|
487 |
stComPortParam PortParams[2]; // 8 Bytes
|
Q |
488 |
stInputFilterParam InputParams[16]; //16 Bytes
|
418cb3
|
489 |
stOutputHoldParam OutputParams[16]; //16 Bytes
|
Q |
490 |
|
61deef
|
491 |
union {
|
Q |
492 |
USHORT value; //12 Bytes //输出映射
|
|
493 |
struct {
|
|
494 |
USHORT bitPos : 4;
|
|
495 |
USHORT byteAddr : 8;
|
|
496 |
USHORT type : 4;
|
|
497 |
};
|
|
498 |
}OutMappings[8];
|
418cb3
|
499 |
|
61deef
|
500 |
USHORT nProgBank;
|
Q |
501 |
USHORT nProgSize;
|
|
502 |
USHORT nAnnoSize;
|
|
503 |
USHORT nCount;
|
|
504 |
|
|
505 |
stCfgBlockInfo CfgBlockInfos[8];
|
|
506 |
UINT cfgvar8; // 4 Bytes
|
|
507 |
UINT cfgvar9; // 4 Bytes
|
|
508 |
UINT cfgvar10; // 4 Bytes
|
|
509 |
// UINT cfgvar11; // 4 Bytes
|
|
510 |
// UINT cfgvar12; // 4 Bytes
|
|
511 |
// UINT cfgvar13; // 4 Bytes
|
|
512 |
// UINT cfgvar14; // 4 Bytes
|
|
513 |
// UINT cfgvar15; // 4 Bytes
|
|
514 |
// UINT cfgvar16; // 4 Bytes
|
|
515 |
// UINT Space1[4]; //16 Bytes
|
|
516 |
|
|
517 |
}stKMSysCfg, * pstKMSysCfg;
|
|
518 |
|
|
519 |
typedef struct tagStoredKMSysCfg
|
|
520 |
{
|
|
521 |
unsigned short Sign1;
|
|
522 |
unsigned short Seq1;
|
|
523 |
stKMSysCfg theKMSysCfg;
|
|
524 |
unsigned short CRC1;
|
|
525 |
unsigned short EndSign1;
|
|
526 |
}stStoredKMSysCfg, * pStoredKMSysCfg;
|
418cb3
|
527 |
|
Q |
528 |
|
|
529 |
typedef struct tagTimer
|
|
530 |
{
|
|
531 |
unsigned int LastActTime;
|
|
532 |
union {
|
|
533 |
unsigned short StatByte;
|
|
534 |
struct
|
|
535 |
{
|
|
536 |
unsigned short nScale : 2; //Time Scale, 0:1ms 1:10ms 2:100ms 3:1S
|
|
537 |
unsigned short nType : 1; //0 : timer 1 : counter ;
|
|
538 |
unsigned short nDir : 1; //0 : count down. 1 count up;
|
|
539 |
unsigned short nInited : 1;
|
|
540 |
unsigned short bSet : 1;
|
|
541 |
unsigned short bTon : 1;
|
|
542 |
|
|
543 |
};
|
|
544 |
// stTimerStat Stat;
|
|
545 |
};
|
|
546 |
}stTimer;
|
|
547 |
|
|
548 |
typedef struct tagKMem
|
|
549 |
{
|
|
550 |
unsigned short WDFs[TOTAL_WDFS];
|
|
551 |
unsigned char CurVALs[TOTAL_CurVAL];
|
|
552 |
unsigned char CurVAL;
|
|
553 |
|
|
554 |
stTimer Timers[TOTALTIMERS];
|
|
555 |
|
|
556 |
unsigned short WX[KLDataWXCount]; //
|
|
557 |
unsigned short WY[KLDataWYCount]; //
|
|
558 |
unsigned short WR[KLDataWRCount];
|
|
559 |
unsigned short WT[16];
|
|
560 |
|
|
561 |
unsigned short WC[16];
|
|
562 |
unsigned short EV[KLDataEVCount];
|
|
563 |
unsigned short SV[KLDataSVCount];
|
|
564 |
|
|
565 |
unsigned short WLX[16]; //
|
|
566 |
unsigned short WLY[16];
|
|
567 |
unsigned short WLR[16];
|
|
568 |
unsigned short WSR[16];
|
|
569 |
unsigned short DT[KLDataDTCount];
|
|
570 |
|
|
571 |
union {
|
|
572 |
unsigned int SDD[KLDataSDTCount / 2];
|
|
573 |
unsigned short SDT[KLDataSDTCount];
|
|
574 |
unsigned char SDB[KLDataSDTCount * 2];
|
|
575 |
struct {
|
|
576 |
unsigned int EffJumperSW;
|
|
577 |
unsigned int CurJumperSW;
|
|
578 |
unsigned int haltick;
|
|
579 |
unsigned int nRunCount;
|
|
580 |
unsigned int RunStat;
|
|
581 |
unsigned int ErrStat;
|
|
582 |
unsigned int PwrOnCount;
|
|
583 |
unsigned int ThisRunTime;
|
|
584 |
unsigned int TotalRunTime;
|
|
585 |
unsigned int CurTimeSec;
|
|
586 |
unsigned int PwrFailCount;
|
|
587 |
unsigned int LastPwrFailTime;
|
|
588 |
unsigned int LastScanTime;
|
|
589 |
unsigned int ScanTimeuS;
|
|
590 |
unsigned int MinScanTimeuS;
|
|
591 |
unsigned int MaxScanTimeuS;
|
|
592 |
unsigned int nEventCount;
|
|
593 |
unsigned int nEventMinIndex;
|
|
594 |
unsigned int nEventMaxIndex;
|
|
595 |
unsigned int Rev2[5];
|
|
596 |
unsigned short ADCValues[20];
|
|
597 |
};
|
|
598 |
};
|
|
599 |
int Reserverd5[1024];
|
|
600 |
}stKMem;
|
|
601 |
|
|
602 |
|
|
603 |
enum enOpType
|
|
604 |
{
|
|
605 |
OP_NONE = 0,
|
|
606 |
OP_NOP = 0,
|
|
607 |
OP_ST = 1, //
|
|
608 |
OP_ST_ = 2, //
|
|
609 |
OP_AN = 3, //
|
|
610 |
OP_AN_ = 4, //
|
|
611 |
OP_OR = 5, //
|
|
612 |
OP_OR_ = 6, //
|
|
613 |
OP_NOT = 7, //
|
|
614 |
OP_ANS = 8, //
|
|
615 |
OP_ORS = 9, //
|
|
616 |
|
|
617 |
OP_PSHS = 10, //
|
|
618 |
OP_RDS = 11, //
|
|
619 |
OP_POPS = 12, //
|
|
620 |
|
|
621 |
OP_OUT = 16, //
|
|
622 |
OP_SET = 17, //
|
|
623 |
OP_RESET = 18, //
|
|
624 |
OP_DF = 19, //
|
|
625 |
OP_DF_ = 20, //
|
|
626 |
|
|
627 |
OP_ST_EQ, //
|
|
628 |
OP_ST_LT, //
|
|
629 |
OP_ST_GT, //
|
|
630 |
OP_ST_LE, //
|
|
631 |
OP_ST_GE, //
|
|
632 |
OP_ST_NE, //
|
|
633 |
OP_AN_EQ, //
|
|
634 |
OP_AN_LT, //
|
|
635 |
OP_AN_GT,
|
|
636 |
OP_AN_LE,
|
|
637 |
OP_AN_GE,
|
|
638 |
OP_AN_NE,
|
|
639 |
OP_OR_EQ,
|
|
640 |
OP_OR_LT,
|
|
641 |
OP_OR_GT,
|
|
642 |
OP_OR_LE,
|
|
643 |
OP_OR_GE,
|
|
644 |
OP_OR_NE,
|
|
645 |
|
|
646 |
|
|
647 |
OP_MV = 51,
|
|
648 |
OP_INC = 52,
|
|
649 |
OP_ADD2 = 53,
|
|
650 |
OP_ADD3 = 54,
|
|
651 |
OP_DEC = 55,
|
|
652 |
OP_SUB2 = 56,
|
|
653 |
OP_SUB3 = 57,
|
|
654 |
OP_MUL = 58,
|
|
655 |
OP_DIV = 59,
|
|
656 |
OP_BKMV = 60,
|
|
657 |
OP_COPY = 61,
|
|
658 |
OP_CLR = 62,
|
|
659 |
|
|
660 |
OP_BRK,
|
|
661 |
OP_PAUSE,
|
|
662 |
OP_JP,
|
|
663 |
OP_CALL,
|
|
664 |
|
|
665 |
OP_TML = 0xC8, //
|
|
666 |
OP_TMR = 0xDC, //
|
|
667 |
OP_TMX = 0xDD, //
|
|
668 |
OP_TMY = 0xFA, //
|
61deef
|
669 |
OP_END = 0xFF,
|
418cb3
|
670 |
};
|
Q |
671 |
|
|
672 |
typedef struct stBinProg1
|
|
673 |
{
|
|
674 |
unsigned char nOp;
|
|
675 |
unsigned char nParamType;
|
|
676 |
unsigned short nParamAddr;
|
|
677 |
}stBinProg1;
|
|
678 |
typedef struct stBinProg15
|
|
679 |
{ //定时器
|
|
680 |
//单参数高级指令
|
|
681 |
unsigned char nOp;
|
|
682 |
unsigned char nOpNum;
|
|
683 |
unsigned short nParamAddr1;
|
|
684 |
unsigned char nParamType1;
|
|
685 |
unsigned char resvr1;
|
|
686 |
unsigned short resvr2;
|
|
687 |
}stBinProg15;
|
|
688 |
typedef struct stBinProg2
|
|
689 |
{ //比较指令
|
|
690 |
//双参数高级指令
|
|
691 |
unsigned char nOp;
|
|
692 |
unsigned char nOpNum;
|
|
693 |
unsigned short nParamAddr1;
|
|
694 |
unsigned char nParamType1;
|
|
695 |
unsigned char nParamType2;
|
|
696 |
unsigned short nParamAddr2;
|
|
697 |
}stBinProg2;
|
|
698 |
typedef struct stBinProg3
|
|
699 |
{ //三参数高级指令
|
|
700 |
unsigned char nOp;
|
|
701 |
unsigned char nOpNum;
|
|
702 |
unsigned short nParamAddr1;
|
|
703 |
unsigned char nParamType1;
|
|
704 |
unsigned char nParamType2;
|
|
705 |
unsigned short nParamAddr2;
|
|
706 |
unsigned char resvr1;
|
|
707 |
unsigned char nParamType3;
|
|
708 |
unsigned short nParamAddr3;
|
|
709 |
}stBinProg3;
|
|
710 |
|