QuakeGod
2024-11-25 9aed5d7e7b3c7bf09da712e9c272ece401a7acc9
提交 | 用户 | age
483170 1 /**
Q 2   ******************************************************************************
3   * @file           : KMachine.h
4   * @brief          : Header for KMachine.c file.
5   *                   This file contains the common defines of the application.
6   ******************************************************************************
7     */
8 #ifndef __KMACHINE_H__
9 #define __KMACHINE_H__
10
11 #define FACTORY_DATA_BASE (FLASH_BASE + 0x00007C00)        //31k //and 
5dd1b7 12 //#define FACTORY_DATA_PAGESIZE (0x00000400)                        //Page Size = 1K
483170 13 #define FACOTRY_DATA_PAGES 1                                                  // use 1 page(s)
Q 14
15 #define STORE_PRG_BASE (FLASH_BASE + 0x00008000)        //32k //and FLASH_BANK1_END
5dd1b7 16 //#define STORE_PRG_PAGESIZE (0x00000400)                            //Page Size = 1K
483170 17 #define STORE_PRG_PAGES 8                                                    //use 4 pages
Q 18
19 #define ALT_PRG_BASE (FLASH_BASE + 0x0000A000)        //40k //and FLASH_BANK1_END
5dd1b7 20 //#define ALT_PRG_PAGESIZE (0x00000400)                            //Page Size = 1K
483170 21 #define ALT_PRG_PAGES 8                                                    //use 4 pages
Q 22
23 #define STORE_SYSREG_BASE (FLASH_BASE + 0x0000C000)        //48k //and 
5dd1b7 24 //#define STORE_SYSREG_PAGESIZE (0x00000400)                            //Page Size = 1K
483170 25 #define STORE_SYSREG_PAGES 1                                                        //use 1 pages
Q 26
27 #define STORE_RUNSTAT_BASE (FLASH_BASE + 0x0000C800)        //50k K //and 
5dd1b7 28 //#define STORE_RUNSTAT_PAGESIZE (0x00000400)                            //Page Size = 1K
483170 29 #define STORE_RUNSTAT_PAGES 1                                                        //use 1 pages
Q 30
842bb6 31 #define STORE_PLC_ANNO_BASE (FLASH_BASE + 0x0000D000)    //56k 
Q 32 #define STORE_PLC_ANNO_PAGES 4                                                // use 4 pages , 1K /page
483170 33
842bb6 34
Q 35 #define STORE_LOG_BASE (FLASH_BASE + 0x0000E000)        //52k and FLASH_BANK1_END
5dd1b7 36 //#define STORE_LOG_PAGESIZE (0x00000400)                            //Page Size = 1K
483170 37 #define STORE_LOG_PAGES 4                                                        //use 4 pages
842bb6 38
483170 39
Q 40 typedef unsigned char uchar;
41 typedef unsigned char UCHAR;
5dd1b7 42 typedef unsigned short ushort;
483170 43 typedef unsigned short USHORT;
Q 44 typedef unsigned int UINT;
45 typedef unsigned int uint32_t;
46 typedef unsigned int DWORD;
47 typedef unsigned short WORD;
48 typedef unsigned char BYTE;
49
50 #define LoBofW(x) ((x)&0xff)
51 #define HiBofW(x) (((x)>>8)&0xff)
52
53 #define LoHofB(x) ((x)&0xf)
54 #define HiHofB(x) (((x)>>4)&0xf)
55
56 //  信息块
57 //  工厂参数配置块
58 //  用户/系统参数配置块
59 //  
60 //
842bb6 61 #pragma anon_unions
483170 62 typedef struct tagInfoBlock // 23 bytes
Q 63 {
64 //    USHORT nBlockLenth;
65     USHORT nDeviceTypeVer;            //device type        x.y
66 //    UCHAR nDevierVer;
842bb6 67     union {
Q 68         USHORT nProgVer;                    //prog version    x.y
69         struct {
70             UCHAR nProgVerMinor;
71             UCHAR nProgVerMajor;
72         };
73     };
483170 74     USHORT KLinkVer;                //x.y
Q 75     USHORT KBusVer;                    //x.y
76 //    USHORT KNetVer;                    //x.y
77 //    USHORT KWLVer;                    //x.y
78     
79     UCHAR nCapacity1;                //    ? K
80     UCHAR nCapacity2;                //    ? k
81     
82     UCHAR nDInput;
83     UCHAR nDOutput;
84     UCHAR nAInput;
85     UCHAR nAOutput;
86     UCHAR nHInput;
87     UCHAR nHOutput;
88     UCHAR nExt1;
89     UCHAR nExt2;
90     UCHAR nLogSize;
91     UCHAR nPorts;
92     UCHAR nManSize;
93     UCHAR nAbility;
94     UCHAR nSwitchBits;
95     
96 }stKMInfoBlock;
97
98 /*
99 typedef struct tagFactData
100 {
101     USHORT Sign;                    //
102     USHORT nLength;                //
103     UCHAR LOT_NO[16];            //
104     UINT MANDate;                    //
105     UINT SN;                            //
106     UINT REV1[24];                //
107     USHORT rev9;
108     USHORT CRC;
109     
110 }stFactData;
111 */
112 typedef struct tagFactoryData        //工厂量产参数,数据
113 {
114     USHORT Sign1;
115     USHORT Seq1;
116     USHORT nModelNo;
117     USHORT nModelVer;
118     UINT nLotNo;
119      UINT nProductDateTime;
120     UINT SN1;
121     UINT nProtocalVer;
122     UINT nDefaultFunc;
123     UCHAR ModelStr[16];
124     UCHAR LOT_NO[16];            //
125     UCHAR SNStr[16];
126     unsigned short CRC1;
127     unsigned short EndSign1;
128     
129 }stFactoryData,* pFactoryData;
130
5dd1b7 131 typedef struct tagNewAppInfoBlock
Q 132 {
133     unsigned short Sign;
134     unsigned short Version;
135     unsigned int Length;
136     unsigned int nCRC;
137     
138 }stNewAppInfoBlock,*pNewAppInfoBlock;
483170 139
Q 140 enum enStoreCfg
141 {
142     CFG_VER        = 0x100,
143     START_SIGN = 0x55aa,
144     END_SIGN    =    0x5aa5,
145 };
146
147 enum enInputFilter
148 {
149     InputFilter_None =0,
150     InputFilter_1mS =1,
151     InputFilter_2mS =2,
152     InputFilter_4mS =3,
153     InputFilter_8mS =4,
154     InputFilter_16mS =5,
155     InputFilter_32mS =6,
156     InputFilter_64mS =7,
157     InputFilter_128mS =8,
158     InputFilter_256mS =9,
159 };
160
161 enum enOutputHold
162 {
163     Output_Hold = 0,
164     Output_Set_0 = 1,
165     Output_Set_1 = 2,
166 };
167
168 typedef struct tagPortStatus
169 {
170     USHORT porttype;        //232,485,net , wireless// KLink, KBus, KNet, KWireless
171     UCHAR StationID;
172     UCHAR MaxStations;
173     UCHAR CurStations;
174     UCHAR Running;
175     UCHAR Health;
176 }stPortStatus,*pPortStatus;
177
178 enum enPortType
179 {
180     PortType_Default = 0, //默认
181     PortType_KLink = 1, //KLink通讯
182     PortType_KBus = 2,     //KBus通讯
183     PortType_KNet = 3,     // KNet通讯
184     PortType_ModbusRTU = 4, //Modbus RTU 通讯
185     PortType_Com = 5,    //    计算机通讯
186     PortType_Gen = 6,    //通用通讯,自由口
187 };
188
189 typedef struct tagComPortParam            //4 Bytes
190 {
191     USHORT WorkMode;                /* 0-5=Default,KLink,KBus,KNet,RTU,Com,Gen */
192     USHORT Station;                    /* 0=From jumper */
193     USHORT BaudRate;       /* =*100 Baudrate at which running       */
194   USHORT ByteSize:2;        /* 0-1=Number of bits/byte, 7-8    */
195     USHORT Parity:4;                    /* 0-4=None,Odd,Even,Mark,Space    */
196   USHORT StopBits:2;        /* 0,1,2 = 1, 1.5, 2               */
197     USHORT EndType:2;                    /* 0=ByChar, 1= ByTime */
198   USHORT EofChar:4;         /* 0,1,2 = None, CR, CR+LF, ETX;  End of character  */
199     USHORT SofChar:2;                    /* 0,1,2 = None, STX */
200     USHORT EndTime;                        /*(*0.01mS) */
201     USHORT RecvAddr;
202     USHORT RecvSize;
203
204 }stComPortParam, *pstComPortParam;
205
206 //每个模块有 0/1/2/3/4/5/6/7/8个 通讯port
207 //不限于 UART, 网口,无线,单总线等,都是port
208 //甚至可以有虚拟的port
209
210 typedef struct tagPortStat
211 {
212     UCHAR PortType;            //端口工作模式
213     UCHAR nStation;            //自己站号
214     UCHAR bWorking;            //工作中
215     UCHAR bBus;                    //总线?,,全双工?
216     UCHAR bMaster;            //主机
217     UCHAR nDevices;            //连接的设备数量//不包括自己 //device list;
218     
219 }stPortStat,*pPortStat;
220
221 typedef struct tagKMFuncParam
222 {
223     USHORT EnablePLC:1;        //使能内部PLC功能
224     USHORT RunMode;                //工作模式
225 }stKMFuncParam;
226
227 // 输入输出地址映射
228
229 typedef struct tagInputFilterParam        // 1 Bytes
230 {
231     BYTE Filter0:4;
232     BYTE Filter1:4;
233
234 }stInputFilterParam;
235
236 typedef struct tagOutputHoldParam            //1 Bytes
237 {
238     BYTE Hold1:4;
239     BYTE Hold2:4;
240 }stOutputHoldParam;    
241
842bb6 242 typedef struct tagOutMapping
Q 243 {
244             USHORT bitPos:4;
245             USHORT byteAddr:8;
246             USHORT type:4;    
247 }stOutMapping;
248
249 typedef struct tagCfgBlockInfo
250 {
251     UCHAR nBlockType;
252     UCHAR nBlockSize;
253 }stCfgBlockInfo;
254
483170 255 typedef struct tagKMSysCfg        //120 Bytes total
Q 256 {
257     USHORT Version;                                        // SC0    // 2 Bytes
258     USHORT workmode;                                    // SC1  // 2 Bytes 0=From jumper  
259     USHORT SwitchFunc;                                // SC2  // 2 Bytes 
842bb6 260     USHORT nCfgBlockCount;                                            // 2 Bytes
483170 261     
Q 262     stComPortParam PortParams[2];                            // 8 Bytes
263     stInputFilterParam InputParams[16];                //16 Bytes
264     stOutputHoldParam OutputParams[16];                //16 Bytes
265     
842bb6 266     union{
Q 267         USHORT value;                                        //12 Bytes //输出映射
268         stOutMapping;
269     }OutMappings[8];
270
271     USHORT nProgBank;
272     USHORT nProgSize;
273     USHORT nAnnoSize;
274     USHORT nCount;
483170 275     
842bb6 276     stCfgBlockInfo CfgBlockInfos[8];
483170 277     UINT cfgvar8;                                                            // 4 Bytes
Q 278     UINT cfgvar9;                                                            // 4 Bytes
279     UINT cfgvar10;                                                        // 4 Bytes
842bb6 280 //    UINT cfgvar11;                                                        // 4 Bytes
Q 281 //    UINT cfgvar12;                                                        // 4 Bytes
483170 282 //    UINT cfgvar13;                                                        // 4 Bytes
Q 283 //    UINT cfgvar14;                                                        // 4 Bytes
284 //    UINT cfgvar15;                                                        // 4 Bytes
285 //    UINT cfgvar16;                                                        // 4 Bytes
286 //    UINT Space1[4];                                                        //16 Bytes
287
288 }stKMSysCfg,* pKMSysCfg;
289
290 typedef struct tagStoredKMSysCfg
291 {
292     unsigned short Sign1;
293     unsigned short Seq1;
294     stKMSysCfg theKMSysCfg;
295     unsigned short CRC1;
296     unsigned short EndSign1;
297 }stStoredKMSysCfg,*pStoredKMSysCfg;
298
299 enum enKeventType
300 {
301     EventTypeNone = 0,
302     EventTypePowerUp = 1,
303     EventTypePowerDown = 2,
304     EventTypePowerRecover = 3,
305     EventTypeConnected = 4,
306     EventTypeLostCon = 5,
307     EventTypeSetTime = 6,
308     EventTypeSysCfg = 7,
309     EventTypeProg = 8,
310     EventTypeForce = 9,
311     EventTypeClearEvent = 10,
312     
313     
314     EventType
315 };
316
317 typedef struct tagEventLog
318 {
319     unsigned short Sign1;
320     unsigned short Seq1;
321     unsigned int nTime;
322     unsigned short nType;
323     unsigned short nParam1;
324     unsigned int nParam2;
325 }stEventLog,* pEventLog;
326
327 typedef struct WorkStatus
328 {
329     unsigned short bPLCRunning:1;
330     unsigned short bPLCError:1;
331     
332 }stWorkStatus;
333
334 typedef struct tagRunStat
335 {
336     unsigned short Sign1;
337     unsigned short Seq1;
338     volatile unsigned short PowerCount;    //
339     volatile unsigned short Reserved1;
340     volatile unsigned int UpTime;        //Seconds;
341     volatile unsigned int UserData1;
342     volatile unsigned short WorkMode;
343     volatile unsigned short WorkMode2;
344     volatile unsigned short nBinProgBank;
345     volatile unsigned short nBinProgSize;
346     unsigned short bLEDFlick;
347     unsigned short Reserved2[1];
348     unsigned short CRC1;
349     unsigned short EndSign1;
350 }stRunStat, *pRunStat;
351
352 extern stRunStat KMRunStat;
353
354 //stStoreCfg * GetCurStoreCfgAddr(void );
355 //stStoreCfg * GetNextStoreCfgAddr(stStoreCfg * CurCfg );
356
357 extern stStoredKMSysCfg storedKMSysCfg;
358
359 #define TYPECOIL 0x00
360 #define TYPEDATA 0x80
361
362     enum enKLCoilTypes
363     {
364         KLCoilTypeX = 0 | TYPECOIL ,        //X Input
365         KLCoilTypeY = 1 | TYPECOIL,        //Y Output
366         KLCoilTypeR = 2 | TYPECOIL,        //R register
367         KLCoilTypeLX = 3 | TYPECOIL,        //Link register
368         KLCoilTypeLY = 4 | TYPECOIL,        //Link register
369         KLCoilTypeT = 5 | TYPECOIL,        //Timer
370         KLCoilTypeC = 6 | TYPECOIL,        //Counter
371         KLCoilTypeLR = 7 | TYPECOIL,        //Link register
372         KLCoilTypeSR = 8 | TYPECOIL,        //Link register
373
374     };
375     enum enKLDataTypes
376     {
377         KLDataTypeDEC = 0 | TYPEDATA,
378         KLDataTypeHEX = 1 | TYPEDATA,
379         KLDataTypeFloat = 2 | TYPEDATA,
380         KLDataTypeWX = 3 | TYPEDATA,
381         KLDataTypeWY = 4 | TYPEDATA,
382         KLDataTypeWR = 5 | TYPEDATA,
383         KLDataTypeWLX = 6 | TYPEDATA,
384         KLDataTypeWLY = 7 | TYPEDATA,
385         KLDataTypeDT = 8 | TYPEDATA,
386         KLDataTypeSDT = 9 | TYPEDATA,
387         KLDataTypeWSR = 10 | TYPEDATA,
388         KLDataTypeSV = 11 | TYPEDATA,
389         KLDataTypeEV = 12 | TYPEDATA,
390         KLDataTypeLD = 13 | TYPEDATA,
391         KLDataSysCfg = 25 | TYPEDATA,
392         KLDataTypeFlash = 33 | TYPEDATA,
8b51c7 393         KLDataTypeWDT = 41 | TYPEDATA,                    //调试监控数据
Q 394         KLDataTypeKBD = 51 | TYPEDATA,                    //KBus 调试数据
395         KLDataTypeKWLD = 52 | TYPEDATA,                    //无线调试数据
5dd1b7 396         KLDataTypeNewApp = 61 | TYPEDATA,                // New FirmWare
Q 397         KLDataTypeNewAppInfo = 62 | TYPEDATA,     // New Firmware Info Block;
483170 398         KLDataTypeTest = 254 | TYPEDATA,
Q 399     };
400
401 enum enKLDataCounts
402     {
403
404         KLDataWXCount = 16,
405         KLDataWYCount = 16,
406         KLDataWRCount = 16,
407         KLDataLDCount = 64,
408         KLDataWLCount = 8, 
409         
410         KLCoilXCount = KLDataWXCount * 16,
411         KLCoilYCount = KLDataWYCount * 16,
412         KLCoilRCount = KLDataWRCount * 16,
413
414         KLCoilTCount = 64,
415         KLCoilCCount = KLCoilTCount,
416
417         KLDataSVCount = KLCoilTCount,
418         KLDataEVCount = KLCoilTCount,
419
420         KLCoilLXCount = 128,
421         KLCoilLYCount = 128,
422         KLCoilLRCount = 128,
423         KLCoilSRCount = 128,
424
425         KLDataDTCount = 128,
426         KLDataSDTCount = 128,
427         KLDataWDTCount = 128,
428
429     };
430
842bb6 431
Q 432 // 通信端口, 注册到 KMachine 里, 统一管理
433
434 enum enPortHardType
483170 435 {
842bb6 436     PortHardType_None    =    0,    //    空接口,无类型
Q 437     PortHardType_SOFT    =    1,    //    软件虚拟接口,可能是隧道等.
438     PortHardType_UART    =    2,    //    串行接口
439     PortHardType_RS232    =    3,    //    232接口
440     PortHardType_RS485    =    4,    //    485接口
441     PortHardType_SLP    =    5,    //    单总线接口
442     PortHardType_RF        =    6,    //    无线接口
443     PortHardType_LORA    =    7,    //    LoRa无线接口
444     PortHardType_OPTI    =    8,    //    光纤接口
445     PortHardType_ETH    =    9,    //    以太网接口
446     PortHardType_WIFI    =    10,    //    WiFi接口
447     PortHardType_BT        =    11,    //    以太网接口
448
449 };
450 enum enPortUseType
451 {
452     PortUse_Default = 0,    //默认
453     PortUse_Console = 1,    //控制台接口
454     PortUse_KLink = 2,        //KLink通讯
455     PortUse_KBus = 3,         //KBus通讯
456     PortUse_KNet = 4,         // KNet通讯
457     PortUse_SLP = 5,        // SLP单总线
458     PortUse_KRF = 6,         // 无线通讯
459     PortUse_ModbusRTU = 7, //Modbus RTU 通讯
460     PortUse_ModbusTCP = 8, //Modbus TCP 通讯
461     PortUse_Com = 9,        //    计算机通讯
462     PortUse_Gen = 10,        //通用通讯,自由口
463 };
464
465 typedef struct tagPortAbility
466 {
467     ushort ChildList:1;
468     ushort AccessChild:1;
469     ushort TranProg:1;
470     ushort TranCfg:1;
471     ushort Diag:1;
472     ushort TranOutBandData:1;
473     ushort Tunnel:1;
474     ushort TranFirmware:1;
475     ushort TranBlink:1;
476
477 }stPortAbility;
478
479 enum enServiceReqs
480 {
481     ReqNone,
482     ReqInit,
483     ReqReset,
484     ReqStop,
485     ReqRun,
486     ReqBlinkLED,
487     ReqStartDiag,
488     ReqStopDiag,
489     ReqPortChildInfo,
490     ReqPortChnInfo,
491     ReqUpdateFirm,
492     ReqUpdateFirmInfo,
483170 493     
842bb6 494     ReqTransFirmware,
Q 495     ReqTransCfg,
496     ReqTransProg,
497     ReqTransData,
498     ReqTransBlink,
499     ReqTransChild,
500     ReqTransInfo,
501     ReqTransOutBandData,
502     ReqRead1Bit,
503     ReqWrite1Bit,
504     ReqReadBits,
505     ReqWriteBits,
506     ReqReadData,
507     ReqWriteData,
508     ReqRemoteTran,
509     
510 };
483170 511
842bb6 512 // 各端口 互联 通信
Q 513 typedef int (*CommFuncDef)(void * pInstance, int ReqId , int nParam1, int nParam2, void ** pData, unsigned short * len1);
514 typedef struct tagPortDef
483170 515 {
Q 516     union {
842bb6 517         USHORT nPortType;
Q 518         struct {
519             UCHAR nPortHardType;
520             UCHAR nPortUseType;
521         };
483170 522     };
842bb6 523     ushort ability;        //能力, 获取子机信息等。
Q 524     uchar bEnable;
525     uchar bRunning;
526     uchar StationId;
527     uchar bMaster;
528     uchar nMaxStations;
529     uchar nCurStations;
530     uchar nHealth;
531     short PortConfigType;
532     short PortConfigSize;
533     short PortRunStatType;
534     short PortRunStatSize;
7eb19e 535     
842bb6 536     void * pInstance;                    //通信结构实体
7eb19e 537     void * pPortConfig;
Q 538     void * pPortRunStatus;
842bb6 539     CommFuncDef ReqCommFunc;    //通信请求函数指针
Q 540     // func2 CommReq;
541     
542 }stPortDef,* pstPortDef;
483170 543
7eb19e 544
Q 545 typedef struct tagPortPtDef
546 {
547     void * pt;
548     
549 }stPortPtDef,* pstPortPtDef;
550
842bb6 551 typedef struct tagInterComm
Q 552 {
553     int nId;
554     
555 }stInterComm;
483170 556
Q 557 typedef struct tagKMem
558 {
559     union {
560     unsigned short WX[KLDataWXCount];        //本机的X和Y
561     unsigned char WXB[KLDataWXCount*2];    
562     };
563     union {
564     unsigned short WY[KLDataWYCount];        //本机的X和Y
565     unsigned char WYB[KLDataWYCount*2];        //本机的X和Y
566     }; 
567     unsigned short WR[KLDataWRCount];
568     
569     
842bb6 570     //虚拟的X和Y,远程通讯时映射用。
Q 571     union{
572     ushort WLX[16];
573     uchar WLXB[32];
574     };
575     union{
576     ushort WLY[16];
577     uchar WLYB[32];
578     };
483170 579     unsigned short WFX[16];
Q 580     unsigned short WFY[16];
842bb6 581
Q 582     unsigned short WLR[16];
483170 583     unsigned short WSR[16];
Q 584
585 union {
586     unsigned int DTD[KLDataDTCount/2];
587     unsigned short DT[KLDataDTCount];
588     unsigned char DTB[KLDataDTCount*2];
589 };
590
591     // 配置寄存器
592     // 系统状态寄存器
593     // 特殊寄存器
594     // 调试,监控寄存器
595     union {
596         unsigned int SDD[KLDataSDTCount/2];
597         unsigned short SDT[KLDataSDTCount];
598         unsigned char SDB[KLDataSDTCount*2];
599         struct {
600             unsigned int EffJumperSW;
601             unsigned int CurJumperSW;
602             unsigned int haltick;
603             unsigned int nRunCount;
604             unsigned int RunStat;
605             unsigned int ErrStat;
606             unsigned int PwrOnCount;
607             unsigned int ThisRunTime;
608             unsigned int TotalRunTime;
609             unsigned int CurTimeSec;
610             unsigned int PwrFailCount;
611             unsigned int LastPwrFailTime;
612             unsigned int LastScanTime;
613             unsigned int ScanTimeuS;
614             unsigned int MinScanTimeuS;
615             unsigned int MaxScanTimeuS;
616             unsigned int nEventCount;
617             unsigned int nEventMinIndex;
618             unsigned int nEventMaxIndex;
619             unsigned int Rev2[5];
620             unsigned short ADCValues[20];
621         };
622     };
623     // 调试,监控寄存器
624     union {
625         unsigned int WDD[KLDataWDTCount/2];
626         unsigned short WDT[KLDataWDTCount];
627         unsigned char WDB[KLDataWDTCount*2];
628     };
629     
842bb6 630     int nTotalPorts;
Q 631     stPortDef * pPorts[8];
632
483170 633 }stKMem;
Q 634
5dd1b7 635
Q 636
483170 637 extern stKMem KMem;
Q 638 extern const stKMInfoBlock KMInfoBlock;
639 extern const stStoredKMSysCfg KMDefaultSysCfg;
640
9aed5d 641 extern volatile int PowerDownFlag;
Q 642 extern volatile int OldPowerDownFlag;
483170 643 extern volatile int OldPowerDownEventTime;
Q 644
645 int KMachineInit(void);
842bb6 646 int KMachineLoopProc(void);
Q 647
648 /*
649     向KMachine 注册 通讯端口,以便通讯端口之间的功能互通
650 */
651 int KMRegisterPort(ushort nType,stPortDef * thePortParam);
652
653 int KMPortReqFunc(int nPortIndex,int nReqId, int nParam1, int nParam2, void ** pData, unsigned short * nlen1);
654
655
483170 656 int ReadFlashMem(void * pBuf, void * pAddrFlash, int nByteSize);
Q 657 int EraseAndWriteToFlashMem(void * pBuf, void * pAddrFlash, unsigned int nByteSize);
5dd1b7 658 int WriteToFlashMemNoErase(void * pBuf, void * pAddrFlash, unsigned int nByteSize);
842bb6 659 int WriteToFlashAutoErase(void * pBuf, void * pAddrFlash, unsigned int nByteSize);
483170 660
Q 661 int ReadFactoryData(void * pDatabuf, int nByteCount);
662 int WriteFactoryData(void * pDataBuf, int nByteCount);
663
664 // active Program bank
842bb6 665
Q 666 int ReadPLCProgram(int nBank, int nProgByteAddr, void *pBuf, int nByteSize);
667 int StartPLCProgram(int nBank, int nByteSize, int nCRC);
668 int WritePLCProgram(int nBank, int nProgByteAddr, void * pBuf, int nByteSize);
669 int FinishiPLCProgram(int nBank, int nByteSize, int nCRC );
670
671 int ReadPLCAnno(int nType, int nProgByteAddr, void *pBuf, int nByteSize);
672 int StartPLCAnno(int nType, int nByteSize, int nCRC);
673 int WritePLCAnno(int nType, int nProgByteAddr, void * pBuf, int nByteSize);
674 int FinishiPLCAnno(int nType, int nByteSize, int nCRC );
483170 675
Q 676 int WriteSysCfgToFlash(pStoredKMSysCfg theStoredKMSysCfg);
677 int ReadSysCfgFromFlash(pStoredKMSysCfg theStoredKMSysCfg);
678
842bb6 679 int KMRunService(int nSvrId, int nParam1, int nParam2, void **pData, unsigned short *nled1);
Q 680
681 int CheckEventLog(void);
483170 682 int AddEventLog(uint32_t nTime, USHORT nEvent, USHORT nParam1, UINT nParam2);
Q 683 pEventLog GetEventLogAddr(int nIndex);
684 int ClearEventLog(void);
685 int LoadRunStat(pRunStat theRunStat);
686 int SaveRunStat(pRunStat theRunStat);
687
5dd1b7 688 int WriteNewApp(int nProgByteAddr, void *pBuf, int nByteSize);
Q 689 int WriteNewAppInfo(int nProgByteAddr, void *pBuf, int nByteSize);
483170 690
Q 691 unsigned char GetCoilValue(unsigned char nCoilType, unsigned short nCoilAddr);
692 int SetCoilValue(unsigned char nCoilType, unsigned short nCoilAddr, unsigned char nCoilValue);
693 int GetVarData(int nDataType, int nDataAddr);
694 int SetVarData(int nDataType, int nDataAddr, int nDataValue);
695
5dd1b7 696 typedef int (*KMSvCBDef) (int nChn, int nSvType, int ,void *, int);    //Service Req callback func ,param is  int ,int, int, void *,int; return int;
Q 697
698
699 #endif    /* __KMACHINE_H__ */