QuakeGod
2023-10-23 4dfb88353b3671a71bc397d5f210d71f67f8fb04
提交 | 用户 | age
418cb3 1 #pragma once
Q 2 // 下列 ifdef 块是创建使从 DLL 导出更简单的
3 // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 MDH_SOCKET_EXPORTS
4 // 符号编译的。在使用此 DLL 的
5 // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
6 // MDH_SOCKET_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
7 // 符号视为是被导出的。
8 #ifdef KLINK_EXPORTS
9 #define KLINK1_API __declspec(dllexport)
10 #else
11 #define KLINK1_API __declspec(dllimport)
12 #endif
13
14 //#include "KDefine.h"
15 #include <functional>
16 /*
17
18
19
20 */
21 #include "HvSerialPort.h"
22 //AFX_EXT_CLASS 
23 // 此类是从KLink1.dll 导出的
24 class KLINK1_API KLink1 {
25
26
27     typedef unsigned char UCHAR;
28     typedef unsigned short USHORT;
29     typedef unsigned int UINT;
30
31 public:
32     KLink1();
33     virtual ~KLink1();
34
35     HvSerialPort1 MySerPort1;
36     int m_bCommParamSet = 0;
37     int m_nPort;
38     int m_nBaudRate;
39     CString m_Settings;
40
41 #define TYPECOIL 0x00
42 #define TYPEDATA 0x80
43     enum enKLCoilTypes
44     {
45         KLCoilTypeX = 0 | TYPECOIL,        //X Input
46         KLCoilTypeY = 1 | TYPECOIL,        //Y Output
47         KLCoilTypeR = 2 | TYPECOIL,        //R register
48         KLCoilTypeLX = 3 | TYPECOIL,        //Link register
49         KLCoilTypeLY = 4 | TYPECOIL,        //Link register
50         KLCoilTypeT = 5 | TYPECOIL,        //Timer
51         KLCoilTypeC = 6 | TYPECOIL,        //Counter
52         KLCoilTypeLR = 7 | TYPECOIL,        //Link register
53         KLCoilTypeSR = 8 | TYPECOIL,        //Link register
54
55
56     };
57     enum enKLDataTypes
58     {
59         KLDataTypeDEC = 0 | TYPEDATA,
60         KLDataTypeHEX = 1 | TYPEDATA,
61         KLDataTypeFloat = 2 | TYPEDATA,
62         KLDataTypeWX = 3 | TYPEDATA,
63         KLDataTypeWY = 4 | TYPEDATA,
64         KLDataTypeWR = 5 | TYPEDATA,
65         KLDataTypeWLX = 6 | TYPEDATA,
66         KLDataTypeWLY = 7 | TYPEDATA,
67         KLDataTypeDT = 8 | TYPEDATA,
68         KLDataTypeSDT = 9 | TYPEDATA,
69         KLDataTypeWSR = 10 | TYPEDATA,
70         KLDataTypeSV = 11 | TYPEDATA,
71         KLDataTypeEV = 12 | TYPEDATA,
72         KLDataTypeLD = 13 | TYPEDATA,
73         KLDataSysCfg = 25 | TYPEDATA,
74         KLDataTypeFlash = 33 | TYPEDATA,
75         KLDataTypeWDT = 41 | TYPEDATA,
76         KLDataTypeKBD = 51 | TYPEDATA,
77         KLDataTypeKWLD = 52 | TYPEDATA,
78         KLDataTypeTest = 254 | TYPEDATA,
79     };
80
81     typedef struct tagKLTypeName
82     {
83         int nType;
84         const char * sName;
85         int nRange = 0;
86     }stKLTypeName;
87
88     static const stKLTypeName KLCoilTypeNames[];
89     static const stKLTypeName KLDataTypeNames[];
90
91     enum eKLResult
92     {
93         KL_ERR = -1,
94         KL_OK = 0,
95         KL_NG = 1,
96         KL_UNKNOWN = 2,
97         KL_TIMEOUT = 3,
98         KL_BCC_ERR = 4,
99         KL_PKG_ERR = 5,
100         KL_SEQ_ERR = 6,
101         KL_LENTH_EXCEED,
102         KL_NEED_PASS,
103         KL_NOT_SUPPORT,
104     };
105
106     const char * GetErrDescStr(int nErrNo);
107
108     enum
109     {
110         KLSignStart = '%',
111         KLSignReply = 'U',
112         KLSignEnd = 0x0D,
113         KLMaxPacketLength = 128,
114
115     };
116     enum ExtraDataType
117     {
118         KLExtTypeNone = 0,
119         KLExtTypeText = 1,
120         KLExtTypeCmd = 2,
121         KLExtTypePassTh = 3,
122
123         KLExtTypeTestData = 8,
124     };
125
126     enum enCMDs
127     {
128         //        cmdOK = '1',        //Reply OK
129         //        cmdNG = '2',        //Rplay NG
130         KLCmdNone = 0x00,        //Nothing
131         KLCmdPing = 0x01,            //Ping
132         KLCmdPingReply = 0x02,        //PingReply
133         KLCmdGetInfo = 0x03,            //GetInfo
134         KLCmdVerInfo = 0x04,            //InfoReply
135
136         KLCmdRead = 0x05,            //Read
137         KLCmdReadReply = 0x06,        //ReadReply
138         KLCmdWrite = 0x07,            //Write
139         KLCmdWriteReply = 0x08,    //WriteReply
140         KLCmdSaveToFlash = 0x09,                //Write
141
142         KLCmdExChgData = 0x0A,                //ExChangeDate, = Wirte + Read
143         KLCmdExChgDataReply,            //ExchangeData Reply
144
145         KLCmdSyncRead = 0x0D,                //SyncRead
146         KLCmdSyncWrite,                        //SyncWrite
147         KLCmdSequenRead,                    //Sequence Read
148         KLCmdSyncTime,                        //SyncTime
149
150         KLCmdChgMode = 0x11,
151         KLCmdGetMode = 0x12,
152
153         KLCmdChkPass,
154         KLCmdSetPass,
155         KLCmdEraseAll,
156         KLCmdReadProgram,
157         KLCmdStartProgram,
158         KLCmdWriteProgram,
159         KLCmdFinishProgram,
160
161         KLCmdRead1Bit = 0x21,                //ReadSingleBit
162         KLCmdWrite1Bit = 0x22,                //WriteSingleBit
163
164         KLCmdReadBits = 0x23,                //ReadBits        n = 1 - 8
165         KLCmdWriteBits = 0x24,                //ReadBits        n = 1 - 8
166
167         KLCmdReadBitsByByte = 0x25,            //ReadBitsByByte    ,byteCount
168         KLCmdWriteBitsByByte = 0x26,        //ReadBitsByByte    ,ByteCount
169
170         KLCmdReadBitsByWord = 0x27,            //ReadBitsByWord    ,WordCount
171         KLCmdWriteBitsByWord = 0x28,        //ReadBitsByWord    ,WordCount
172
173         KLCmdReadDataByte = 0x31,            //ByteCount
174         KLCmdWriteDataByte = 0x32,
175
176         KLCmdReadDataWord = 0x33,            //WordCount
177         KLCmdWriteDataWord = 0x34,
178
179         KLCmdReadData = 0x35,                //?Count
180         KLCmdWriteData = 0x36,
181
182         KLCmdStopBlinkLED = 0x4f, 
183         KLCmdBlinkLED = 0x50,
184
185         KLCmdReadProg = 0x51,
186         KLCmdWriteProg,
187         KLCmdReadSysCfg,
188         KLCmdWriteSysCfg,
189         KLCmdSaveSysCfg,
190         KLCmdSaveRunStat,
191         KLCmdReadRunStat,
192         KLCmdClearRunStat,
193
194         KLCmdEraseFlashPage = 0x61,
195         KLCmdWriteToFlash = 0x62,
196
197         KLCmdGetEventLogCount,
198         KLCmdGetEventLog,
199         KLCmdClearEventLog,
200         KLCmdGetFactoryData,
201         KLCmdWriteFactoryData,
202         KLCmdResetMachine,
203         KLCmdGetUid,
204         KLCmdSetTime,
205         KLCmdGetSN,
206
207
208         KLCmdMC = 0x70,
209         KLCmdMD,
210         KLCmdMG,
211
212         KLCmdThrough,
213
214         KLCmdErrRply = 0xEE,                //ERRORReply
215     };
216
217     typedef struct tagRunStat
218     {
219         unsigned short Sign1;
220         unsigned short Seq1;
221         volatile unsigned short PowerCount;    //
222         volatile unsigned short Reserved1;
223         volatile unsigned int UpTime;        //Seconds;
224         volatile unsigned int UserData1;
225         volatile unsigned short WorkMode;
226         volatile unsigned short WorkMode2;
227         volatile unsigned short nBinProgBank;
228         volatile unsigned short nBinProgSize;
df0321 229         unsigned short bLEDFlick;
Q 230         unsigned short Reserved2[1];
418cb3 231         unsigned short CRC1;
Q 232         unsigned short EndSign1;
233     }stRunStat, *pRunStat;
234
235     stRunStat KMRunStat;
236
237     enum enKeventType
238     {
239         EventTypeNone = 0,
240         EventTypePowerUp = 1,
241         EventTypePowerDown = 2,
242         EventTypePowerRecover = 3,
243         EventTypeConnected = 4,
244         EventTypeLostCon = 5,
245         EventTypeSetTime = 6,
246         EventTypeSysCfg = 7,
247         EventTypeProg = 8,
248         EventTypeForce = 9,
249         EventTypeClearEvent = 10,
250
251         EventType
252     };
253
254     typedef struct tagEventLog
255     {
256         unsigned short Sign1;
257         unsigned short Seq1;
258         unsigned int nTime;
259         unsigned short nType;
260         unsigned short nParam1;
261         unsigned int nParam2;
262     }stEventLog, *pEventLog;
263
264
265     typedef struct tagKLCmdName
266     {
267         const int nCmd;
268         const char * sName;
269         const char * sType;
270
271     }KLCmdName;
272
273     const KLCmdName KLCmdNames[42] =
274     {
275         {KLCmdNone,"None",""},    //==0    //Nothing
276         {KLCmdPing,"Ping"},    //=1        //Ping
277         {KLCmdPingReply,"PingReply"}, //2        //PingReply
278         {KLCmdGetInfo,"GetInfo"},//3            //GetInfo
279         {KLCmdVerInfo,"VerInfo"},// = 0x04,            //InfoReply
280
281         {KLCmdRead,"Read","WX;WY;DT;SDT;EV;SV;LD;WL;CFG;FLASH;RAM"},// = 0x05,            //Read
282         {KLCmdReadReply,"ReadReply"},// = 0x06,        //ReadReply
283         {KLCmdWrite,"Write"},// = 0x07,            //Write
284         {KLCmdWriteReply,"WriteReply"},// = 0x08,    //WriteReply
285         {KLCmdSaveToFlash,"SaveToFlash"},// = 0x09,                //Write
286
287         {KLCmdExChgData,"ExChgData"},// = 0x0A,                //ExChangeDate, = Wirte + Read
288         {KLCmdExChgDataReply,"ExChgDataReply"},//,            //ExchangeData Reply
289
290         {    KLCmdSyncRead,"SyncRead"},// = 0x0D,                //SyncRead
291         {    KLCmdSyncWrite,    "SyncWrite"},//                     //SyncWrite
292         {    KLCmdSequenRead,"SequenRead"},//                     //Sequence Read
293         {    KLCmdSyncTime,"SyncTime"},//                         //SyncTime
294
295         {    KLCmdGetMode,"GetMode"},//  = 0x12,
296
297         {    KLCmdChkPass,"ChkPass"},// 
298         {    KLCmdSetPass,"SetPass"},// 
299         {    KLCmdEraseAll,"EraseAll"},// 
300         {    KLCmdReadProgram,"ReadProgram"},// 
301         {    KLCmdWriteProgram,"WriteProgram"},// 
302
303         {    KLCmdRead1Bit,"Read1Bit"},//  = 0x21,                //ReadSingleBit
304         {    KLCmdWrite1Bit,"Write1Bit"},//  = 0x22,                //WriteSingleBit
305
306         {    KLCmdReadBits,"ReadBits"},//  = 0x23,                //ReadBits        n = 1 - 8
307         {    KLCmdWriteBits,"WriteBits"},//  = 0x24,                //ReadBits        n = 1 - 8
308
309         {    KLCmdReadBitsByByte,"ReadBitsByByte"},//  = 0x25,            //ReadBitsByByte
310         {    KLCmdWriteBitsByByte,"WriteBitsByByte"},//  = 0x26,        //ReadBitsByByte
311
312         {    KLCmdReadBitsByWord,"ReadBitsByWord"},//  = 0x27,            //ReadBitsByWord
313         {    KLCmdWriteBitsByWord,"WriteBitsByWord"},//  = 0x28,        //ReadBitsByWord
314
315         {    KLCmdReadDataByte,"ReadDataByte"},//  = 0x31,
316         {    KLCmdWriteDataByte,"WriteDataByte"},//  = 0x32,
317
318         {    KLCmdReadDataWord,"ReadDataWord"},//  = 0x33,
319         {    KLCmdWriteDataWord,"WriteDataWord"},//  = 0x34,
320
321         {    KLCmdReadData,"ReadData"},//  = 0x35,
322         {    KLCmdWriteData,"WriteData"},//  = 0x36,
323
324         {    KLCmdReadProg,"ReadProg"},//  = 0x51,
325         {    KLCmdWriteProg,"WriteProg"},// 
326         {    KLCmdReadSysCfg,"ReadSysCfg"},// 
327         {    KLCmdWriteSysCfg,"WriteSysCfg"},// 
328
329         {    KLCmdSaveSysCfg,"SaveSysCfg"},// 
330     //        KLCmdReadRunStat,
331
332
333         {    KLCmdErrRply,"ErrRply"}//  = 0xEE,                //ERRORReply
334     };
335
336     typedef struct tagKLExtDataFrame
337     {
338         UCHAR Dst;
339         UCHAR nType;
340         UCHAR Len2;
341         UCHAR Data[1];
342     }*pKLExtDataFrame;
343
344
345     typedef union tagKLStatDef
346     {
347         UCHAR StatByte;
348         struct {
349             UCHAR nSEQ : 4;
350             UCHAR HasExt : 1;
351             UCHAR HasErr : 1;
352         };
353     }unKLStat, *pKLStat;
354
355     int m_nSeq = 0;
356     int m_nRSeq = 0;
357     unsigned char m_Dst;
358     int m_nTotalSendCount = 0;
359     int m_nTotalRecvCount = 0;
360     int m_nTotalFailCount = 0;
361     int m_nSendCount = 0;
362     int m_nRecvCount = 0;
363     int m_nLastSendCount = 0;
364     int m_nLastRecvCount = 0;
365     int m_SendSpeed = 0;
366     int m_RecvSpeed = 0;
367     double LastTime = 0;
368
369
370     //unsigned char m_Stat;
371
372     unKLStat m_Stat1 = { 0 };
373     unKLStat m_DstStat;
374
375     typedef struct tagKLReqPacketDef
376     {
377
378         UCHAR StartSign;
379         UCHAR DstAddr;
380         UCHAR Stat;
381         UCHAR Cmd;
382         UCHAR Type1;
383         UCHAR Params[1];
384     }stKLReqPacket, *pKLReqPacket;
385
386     typedef struct tagKLRplyPktHdr
387     {
388         unsigned char RplyStSgn;    //
389         unsigned char DstAddr;        //
390         unsigned char nStatus;        //
391         unsigned char nRplyCMD;        //
392         unsigned char nSize1;            //
393         unsigned char Datas[1];        //
394     }stKLRplyPktHdr, *pKLRplyPktHdr;
395
396     unsigned char m_Packetbuf[256];
397     unsigned char m_SendBuf[1024];
398     unsigned char m_RecvBuf[1024];
399     unsigned char m_DataBuf[1024];
400
401     typedef struct tagChnStat
402     {
403         unsigned int Stat;
404         unsigned int SendPackets;
405         unsigned int RecvPackets;
406         unsigned int LastSentTimeuS;
407         unsigned int LostPackets;
408         unsigned int CtnLstPkts;
409         unsigned int MaxCtnLstPkts;
410         unsigned int NotPkgErr;
411         unsigned int PkgLenErr;
412         unsigned int BCCErr;
413         unsigned int TimeOutErr;
414         unsigned int Delay;
415         unsigned int MaxDelay;
416         unsigned int SendTimeInterval;
417         union
418         {
419             unsigned int ClientDatas[10];
420             struct {
421                 unsigned int ClientRecvPkts;    //
422                 unsigned int ClientSendPkts;    //
423                 unsigned int ClientNotPktErr;    //
424                 unsigned int ClientMisIdPkts;    //
425                 unsigned int ClientPkgLenErr;    //
426                 unsigned int ClientBccErr;        //
427                 unsigned int ClientTimeOutErr;    //
428             };
429         };
430     } stChnStat, *pChnStat;
431     enum enKLDataCounts
432     {
433         KLDataWXCount = 16,
434         KLDataWYCount = 16,
435         KLDataWRCount = 16,
436         KLDataLDCount = 64,
437         KLDataWLCount = 8,
438
439         KLCoilXCount = KLDataWXCount * 16,
440         KLCoilYCount = KLDataWYCount * 16,
441         KLCoilRCount = KLDataWRCount * 16,
442
443         KLCoilTCount = 64,
444         KLCoilCCount = KLCoilTCount,
445         KLDataSVCount = KLCoilTCount,
446         KLDataEVCount = KLCoilTCount,
447
448         KLCoilLXCount = 128,
449         KLCoilLYCount = 128,
450         KLCoilLRCount = 128,
451         KLCoilSRCount = 128,
452
453         KLDataDTCount = 256,
454         KLDataSDTCount = 256,
455         KLDataWDTCount = 256,
456     };
457     struct tagMEM
458     {
459         union //tagWX
460         {
461             USHORT WX[64];
462             UCHAR WXB[128];
463             UINT WXD[32];
464         };
465         union //tagWY
466         {
467             USHORT WY[64];
468             UCHAR WYB[128];
469             UINT WYD[32];
470         };
471         union //tagDT
472         {
473             USHORT DT[256];
474             UCHAR DTB[512];
475             UINT DTD[128];
476         };
477         union //tagWR
478         {
479             USHORT WR[64];
480             UCHAR WRB[128];
481             UINT WRD[32];
482         };
483         union //tagSDT
484         {
485             UCHAR SDB[512];
486             USHORT SDT[256];
487             UINT SDD[128];
488             struct {
489                 unsigned int EffJumperSW;
490                 unsigned int CurJumperSW;
491                 unsigned int haltick;
492                 unsigned int RunStat;
493                 unsigned int ErrStat;
494                 unsigned int nTickCount;
495                 unsigned int TotalRunTime;
496                 unsigned int ThisRunTime;
497                 unsigned int PwrOnCount;
498                 unsigned int LastScanTime;
499                 unsigned int ScanTimeuS;
500                 unsigned int MinScanTimeuS;
501                 unsigned int MaxScanTimeuS;
502                 unsigned short ADCValues[20];
503             };
504         };
505         //
506         union {
507             unsigned int WDD[KLDataWDTCount / 2];
508             unsigned short WDT[KLDataWDTCount];
509             unsigned char WDB[KLDataWDTCount * 2];
510         };
511     }MEM;
512
513     CString m_resultStr;
514
515     static int xtoi(const char * hexstr, int len = 0);
516     unsigned char KLBCC(void * pData, int nSize);
517
518     int CalCRC(void * pBuf, int nSize);
519
520     /*
521         连接状态
522         开始连接(未定)-> 心跳包正常->已连接 -> 心跳包连续正常 -> 连接很好
523
524         连接很好 -> 心跳包 失败 / 数据包失败 -> 已连接 (有错误)
525
526         已连接 (有错误) -> 心跳包正常 -> 已连接
527     */
528     int CalSpeed();
529     int fnTest1(int n);
530
531     int ParseReqPacket();
532     int MakeRplyPacket();
533
534 //    typedef int(*pSend)(void *, int);
535 //    typedef int(*pRecv)(void *, int);
536 //    typedef int(*pOpen)(int);
537 //    typedef int(*pClose)(int);
538
539     // pSend SendPkgFunc;
540     //  pRecv RecvPkgFunc;
541     //  pOpen OpenFunc;
542     //  pClose CloseFunc;
543 /*
544     std::function<int(void *, int)> SendPkgFunc;
545     std::function<int(void *, int)> RecvPkgFunc;
546     std::function<int(int)> OpenFunc;
547     std::function<int(int)> CloseFunc;
548 */
549     typedef struct tagCallBackFuncs
550     {
551         std::function<int(void)> OpenFunc;
552         std::function<int(void)> CloseFunc;
553         std::function<int(void)> ClearBufFunc;
554         std::function<int(void *, int)> SendPkgFunc;
555         std::function<int(void *, int)> RecvPkgFunc;
556         std::function<int(void)> OnConnect;
557         std::function<int(int ErrCode)> OnDisConnect;
558         std::function<int(int ErrCode)> OnError;
559
560     }stCallBackFuncs, *pCallBackFuncs;
561
562     stCallBackFuncs m_CallBackFuncs = {
563         std::bind(&HvSerialPort1::Open,&MySerPort1),
564         std::bind(&HvSerialPort1::Close,&MySerPort1),
565         std::bind(&HvSerialPort1::ClearBuf,&MySerPort1),
566         std::bind(&HvSerialPort1::Send,&MySerPort1, std::placeholders::_1, std::placeholders::_2),
567         std::bind(&HvSerialPort1::Recv,&MySerPort1, std::placeholders::_1, std::placeholders::_2)
568     };
569
570     int m_bSendCallBackSet = 1;
571     int m_bRecvCallBackSet = 1;
572     int m_bOpenCallBackSet = 1;
573     int m_bCloseCallBackSet = 1;
574     int m_bClearBufCallBackSet = 1;
575     int m_bOnConnectCallBackSet = 0;
576     int m_bOnDisConnectCallBackSet = 0;
577     int m_bOnErrorCallBackSet = 0;
578
579     bool m_bOpened = false;
580 /*
581     int SetSendCallBackFunc(std::function<int(void *, int)> pSendFunc);
582     int SetRecvCallBackFunc(std::function<int(void *, int)> pRecvFunc);
583     int SetOpenCallBackFunc(std::function<int(int)> pOpenFunc);
584     int SetCloseCallBackFunc(std::function<int(int)> pCloseFunc);
585 */
586
587     int SetCommParam();
588
589     int SetCallBackFuncs(pCallBackFuncs pFuncSt);
590
591     int m_nErrCount = 0;
592     int m_nContinueErrCount = 0;
593     int Open(int OpenParam = 0);
594     int Close(int CloseParam = 0);
595
596     int Connect(int ConnectParam = 0);
597     int DisConnect(int DisConnectParam = 0);
598     
599     int DoHeartBeat(int nParam = 0);
600
601     void OnTimer();
602
603     int SendPacket(void * pBuf, int Len);
604     int RecvPacket(void * pBuf, int LenToRead, int ReTryCount = 3);
605
606     int GetNextSeq();
607
608     int MakeExtDataFrame(void * pBuf, UCHAR nDst, UCHAR nType, UCHAR len2, void * pData);
609
610     //int MakeReqPacket(void * pBuf, UCHAR nDst, UCHAR Stat, UCHAR nCMD, UCHAR Type, USHORT nAddr = 0, USHORT nCount = 0, void * pData = NULL);
611
612     int MakeReqPacketEx(void * pBuf, UCHAR nDst, UCHAR Stat, UCHAR nCMD, UCHAR Type, USHORT nAddr = 0, USHORT nCount = 0, void * pData = NULL, int ExtFrameLen = 0, void * pExtDataFrame = NULL);
613
614     int CheckPackage(void * pBuf, int nSize);
615     int ProcessPacket(void *pBuf, int nLen);
616     int ParseRplyPacket(void *pBuf, int nPkgLen, UCHAR * nCmd, UCHAR * Status, USHORT* nCount, void * pData);
617
618     int GetInfo(UCHAR nDst, USHORT * nReadBytes, USHORT * Values);
619     int GetSN(UCHAR nDst, USHORT * nReadBytes, USHORT * Values);
620     int GetUID(UCHAR nDst, USHORT * nReadBytes, USHORT * Values);
621     int ReadFactoryData(UCHAR nDst, USHORT nStartAddr, UCHAR nByteCount, USHORT * nReadBytes, USHORT * Values);
622     int WriteFactoryData(UCHAR nDst, USHORT nStartAddr, UCHAR nByteCount, USHORT * Values);
623
624     int ReadSysCfgData(UCHAR nDst, USHORT nStartAddr, UCHAR nByteCount, USHORT * nReadBytes, USHORT * Values);
625     int WriteSysCfgData(UCHAR nDst, USHORT nStartAddr, UCHAR nByteCount, USHORT * Values);
626
627
628     //int GetTime32(UCHAR nDst, int * nCount);
629     //int SetTime32(UCHAR nDst, int * nCount);
630     int GetDateTime32(UCHAR nDst, UINT * pValue);
631     int SetDateTime32(UCHAR nDst, UINT Value);
632
633
634     int GetEventLogCount(UCHAR nDst, int * nCount);
635     int GetEventLog(UCHAR nDst, int nStartIndex, int nCount, stEventLog * pEventLogs);
636
637
638     int ReadBit(UCHAR nDst, UCHAR nType, USHORT nBitAddr, UCHAR * Value);//Read 1 Single bit
639     int WriteBit(UCHAR nDst, UCHAR nType, USHORT nBitAddr, UCHAR Value);//Write 1 Single bit
640     int ReadBits(UCHAR nDst, UCHAR nType, USHORT nBitAddr, UCHAR nBitCount, UCHAR * Values);
641     int WriteBits(UCHAR nDst, UCHAR nType, USHORT nBitAddr, UCHAR nBitCount, UCHAR * Values);
642     int ReadBitsByWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT *Values);
643     int WriteBitsByWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT *Values);
644
645     int ReadDataByte(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, USHORT * nByteRead, UCHAR * Values);
646     int WriteDataByte(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, UCHAR * Values);
647
648     int ReadDataWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * nByteRead, USHORT * Values);
649     int WriteDataWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
650
651     int ReadData(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * nByteRead, USHORT * Values);
652     int WriteData(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
653
df0321 654     int GetMode(UCHAR nDst, UCHAR nType, UCHAR* value);
418cb3 655     int ChangeMode(UCHAR nDst, UCHAR nType);
Q 656
657     int BlinkLED(UCHAR nDst, UCHAR nSecond);
658
659     int ReadProgram(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
660
661     int StartProgram(UCHAR nDst, UCHAR nType);
662     int WriteProgram(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
663     int FinishProgram(UCHAR nDst, UCHAR nType, USHORT nStepSize);
664
665     int ReadRunStat(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
666
667     int ClearStatistics(UCHAR nDst, UCHAR nType);
668
669 };
670