#pragma once // ÏÂÁÐ ifdef ¿éÊÇ´´½¨Ê¹´Ó DLL µ¼³ö¸ü¼òµ¥µÄ // ºêµÄ±ê×¼·½·¨¡£´Ë DLL ÖеÄËùÓÐÎļþ¶¼ÊÇÓÃÃüÁîÐÐÉ϶¨ÒåµÄ MDH_SOCKET_EXPORTS // ·ûºÅ±àÒëµÄ¡£ÔÚʹÓÃ´Ë DLL µÄ // ÈκÎÆäËûÏîÄ¿Éϲ»Ó¦¶¨Òå´Ë·ûºÅ¡£ÕâÑù£¬Ô´ÎļþÖаüº¬´ËÎļþµÄÈκÎÆäËûÏîÄ¿¶¼»á½« // MDH_SOCKET_API º¯ÊýÊÓΪÊÇ´Ó DLL µ¼ÈëµÄ£¬¶ø´Ë DLL Ôò½«Óô˺궨ÒåµÄ // ·ûºÅÊÓΪÊDZ»µ¼³öµÄ¡£ #ifdef KLINK_EXPORTS #define KLINK1_API __declspec(dllexport) #else #define KLINK1_API __declspec(dllimport) #endif //#include "KDefine.h" #include /* */ #include "HvSerialPort.h" //AFX_EXT_CLASS // ´ËÀàÊÇ´ÓKLink1.dll µ¼³öµÄ class KLINK1_API KLink1 { enum enServiceReqs { ReqNone, ReqInit, ReqReset, ReqStop, ReqRun, ReqBlinkLED, ReqStartDiag, ReqStopDiag, ReqPortChildInfo, ReqPortChnInfo, ReqUpdateFirm, ReqUpdateFirmInfo, ReqTransFirmware, ReqTransCfg, ReqTransProg, ReqTransData, ReqTransBlink, ReqTransChild, ReqTransInfo, ReqTransOutBandData, ReqRead1Bit, ReqWrite1Bit, ReqReadBits, ReqWriteBits, ReqReadData, ReqWriteData, ReqRemoteTran, }; typedef unsigned char UCHAR; typedef unsigned short USHORT; typedef unsigned int UINT; public: KLink1(); virtual ~KLink1(); HvSerialPort1 MySerPort1; int m_bCommParamSet = 0; int m_nPort=1; int m_nBaudRate=115200; CString m_Settings=_T("8,N,1"); /* int m_nDefaultPort=1; int m_nDefaultBaudRate=115200; CString m_DefaultSettings=_T("8,N,1"); */ #define TYPECOIL 0x00 #define TYPEDATA 0x80 enum enKLCoilTypes { KLCoilTypeX = 0 | TYPECOIL, //X Input KLCoilTypeY = 1 | TYPECOIL, //Y Output KLCoilTypeR = 2 | TYPECOIL, //R register KLCoilTypeLX = 3 | TYPECOIL, //Link register KLCoilTypeLY = 4 | TYPECOIL, //Link register KLCoilTypeT = 5 | TYPECOIL, //Timer KLCoilTypeC = 6 | TYPECOIL, //Counter KLCoilTypeLR = 7 | TYPECOIL, //Link register KLCoilTypeSR = 8 | TYPECOIL, //Link register }; enum enKLDataTypes { KLDataTypeDEC = 0 | TYPEDATA, KLDataTypeHEX = 1 | TYPEDATA, KLDataTypeFloat = 2 | TYPEDATA, KLDataTypeWX = 3 | TYPEDATA, KLDataTypeWY = 4 | TYPEDATA, KLDataTypeWR = 5 | TYPEDATA, KLDataTypeWLX = 6 | TYPEDATA, KLDataTypeWLY = 7 | TYPEDATA, KLDataTypeDT = 8 | TYPEDATA, KLDataTypeSDT = 9 | TYPEDATA, KLDataTypeWSR = 10 | TYPEDATA, KLDataTypeSV = 11 | TYPEDATA, KLDataTypeEV = 12 | TYPEDATA, KLDataTypeLD = 13 | TYPEDATA, KLDataSysCfg = 25 | TYPEDATA, KLDataTypeFlash = 33 | TYPEDATA, KLDataTypeWDT = 41 | TYPEDATA, KLDataTypeKBD = 51 | TYPEDATA, KLDataTypeKWLD = 52 | TYPEDATA, KLDataTypeTest = 254 | TYPEDATA, }; typedef struct tagKLTypeName { int nType; const char * sName; int nRange = 0; }stKLTypeName; static const stKLTypeName KLCoilTypeNames[]; static const stKLTypeName KLDataTypeNames[]; enum eKLResult { KL_ERR = -1, KL_OK = 0, KL_NG = 1, KL_UNKNOWN = 2, KL_TIMEOUT = 3, KL_BCC_ERR = 4, KL_PKG_ERR = 5, KL_SEQ_ERR = 6, KL_LENTH_EXCEED, KL_NEED_PASS, KL_NOT_SUPPORT, }; static const char * GetErrDescStr(int nErrNo); enum { KLSignStart = '%', KLSignReply = 'U', KLSignEnd = 0x0D, KLMaxPacketLength = 128, }; enum ExtraDataType { KLExtTypeNone = 0, KLExtTypeText = 1, KLExtTypeCmd = 2, KLExtTypePassTh = 3, KLExtTypeTestData = 8, }; enum enCMDs { // cmdOK = '1', //Reply OK // cmdNG = '2', //Rplay NG KLCmdNone = 0x00, //Nothing KLCmdPing = 0x01, //Ping KLCmdPingReply = 0x02, //PingReply KLCmdGetInfo = 0x03, //GetInfo KLCmdVerInfo = 0x04, //InfoReply KLCmdRead = 0x05, //Read KLCmdReadReply = 0x06, //ReadReply KLCmdWrite = 0x07, //Write KLCmdWriteReply = 0x08, //WriteReply KLCmdSaveToFlash = 0x09, //Write KLCmdExChgData = 0x0A, //ExChangeDate, = Wirte + Read KLCmdExChgDataReply, //ExchangeData Reply KLCmdSyncRead = 0x0D, //SyncRead KLCmdSyncWrite, //SyncWrite KLCmdSequenRead, //Sequence Read KLCmdSyncTime, //SyncTime KLCmdChgMode = 0x11, KLCmdGetMode = 0x12, KLCmdChkPass, KLCmdSetPass, KLCmdEraseAll, KLCmdReadProgram, KLCmdStartProgram, KLCmdWriteProgram, KLCmdFinishProgram, KLCmdReadPLCAnno, KLCmdStartPLCAnno, KLCmdWritePLCAnno, KLCmdFinishPLCAnno, KLCmdRead1Bit = 0x21, //ReadSingleBit KLCmdWrite1Bit = 0x22, //WriteSingleBit KLCmdReadBits = 0x23, //ReadBits n = 1 - 8 KLCmdWriteBits = 0x24, //ReadBits n = 1 - 8 KLCmdReadBitsByByte = 0x25, //ReadBitsByByte ,byteCount KLCmdWriteBitsByByte = 0x26, //ReadBitsByByte ,ByteCount KLCmdReadBitsByWord = 0x27, //ReadBitsByWord ,WordCount KLCmdWriteBitsByWord = 0x28, //ReadBitsByWord ,WordCount KLCmdReadDataByte = 0x31, //ByteCount KLCmdWriteDataByte = 0x32, KLCmdReadDataWord = 0x33, //WordCount KLCmdWriteDataWord = 0x34, KLCmdReadData = 0x35, //?Count KLCmdWriteData = 0x36, KLCmdStopBlinkLED = 0x4f, KLCmdBlinkLED = 0x50, KLCmdReadProg = 0x51, KLCmdWriteProg, KLCmdReadSysCfg, KLCmdWriteSysCfg, KLCmdSaveSysCfg, KLCmdSaveRunStat, KLCmdReadRunStat, KLCmdClearRunStat, KLCmdEraseFlashPage = 0x61, KLCmdWriteToFlash = 0x62, KLCmdGetEventLogCount, KLCmdGetEventLog, KLCmdClearEventLog, KLCmdGetFactoryData, KLCmdWriteFactoryData, KLCmdResetMachine, KLCmdGetUid, KLCmdSetTime, KLCmdGetSN, KLCmdMC = 0x70, KLCmdMD, KLCmdMG, KLCmdWriteFirmware, KLCmdWriteFirmInfo, KLCmdGetPortInfo, KLCmdGetPortChnInfo, KLCmdGetPortChildInfo, KLCmdPortRemoteReq, KLCmdThrough, KLCmdErrRply = 0xEE, //ERRORReply }; typedef struct tagRunStat { unsigned short Sign1; unsigned short Seq1; volatile unsigned short PowerCount; // volatile unsigned short Reserved1; volatile unsigned int UpTime; //Seconds; volatile unsigned int UserData1; volatile unsigned short WorkMode; volatile unsigned short WorkMode2; volatile unsigned short nBinProgBank; volatile unsigned short nBinProgSize; unsigned short bLEDFlick; unsigned short Reserved2[1]; unsigned short CRC1; unsigned short EndSign1; }stRunStat, *pRunStat; stRunStat KMRunStat; enum enKeventType { EventTypeNone = 0, EventTypePowerUp = 1, EventTypePowerDown = 2, EventTypePowerRecover = 3, EventTypeConnected = 4, EventTypeLostCon = 5, EventTypeSetTime = 6, EventTypeSysCfg = 7, EventTypeProg = 8, EventTypeForce = 9, EventTypeClearEvent = 10, EventType }; typedef struct tagEventLog { unsigned short Sign1; unsigned short Seq1; unsigned int nTime; unsigned short nType; unsigned short nParam1; unsigned int nParam2; }stEventLog, *pEventLog; typedef struct tagKLCmdName { const int nCmd; const char * sName; const char * sType; }KLCmdName; const KLCmdName KLCmdNames[42] = { {KLCmdNone,"None",""}, //==0 //Nothing {KLCmdPing,"Ping"}, //=1 //Ping {KLCmdPingReply,"PingReply"}, //2 //PingReply {KLCmdGetInfo,"GetInfo"},//3 //GetInfo {KLCmdVerInfo,"VerInfo"},// = 0x04, //InfoReply {KLCmdRead,"Read","WX;WY;DT;SDT;EV;SV;LD;WL;CFG;FLASH;RAM"},// = 0x05, //Read {KLCmdReadReply,"ReadReply"},// = 0x06, //ReadReply {KLCmdWrite,"Write"},// = 0x07, //Write {KLCmdWriteReply,"WriteReply"},// = 0x08, //WriteReply {KLCmdSaveToFlash,"SaveToFlash"},// = 0x09, //Write {KLCmdExChgData,"ExChgData"},// = 0x0A, //ExChangeDate, = Wirte + Read {KLCmdExChgDataReply,"ExChgDataReply"},//, //ExchangeData Reply { KLCmdSyncRead,"SyncRead"},// = 0x0D, //SyncRead { KLCmdSyncWrite, "SyncWrite"},// //SyncWrite { KLCmdSequenRead,"SequenRead"},// //Sequence Read { KLCmdSyncTime,"SyncTime"},// //SyncTime { KLCmdGetMode,"GetMode"},// = 0x12, { KLCmdChkPass,"ChkPass"},// { KLCmdSetPass,"SetPass"},// { KLCmdEraseAll,"EraseAll"},// { KLCmdReadProgram,"ReadProgram"},// { KLCmdWriteProgram,"WriteProgram"},// { KLCmdRead1Bit,"Read1Bit"},// = 0x21, //ReadSingleBit { KLCmdWrite1Bit,"Write1Bit"},// = 0x22, //WriteSingleBit { KLCmdReadBits,"ReadBits"},// = 0x23, //ReadBits n = 1 - 8 { KLCmdWriteBits,"WriteBits"},// = 0x24, //ReadBits n = 1 - 8 { KLCmdReadBitsByByte,"ReadBitsByByte"},// = 0x25, //ReadBitsByByte { KLCmdWriteBitsByByte,"WriteBitsByByte"},// = 0x26, //ReadBitsByByte { KLCmdReadBitsByWord,"ReadBitsByWord"},// = 0x27, //ReadBitsByWord { KLCmdWriteBitsByWord,"WriteBitsByWord"},// = 0x28, //ReadBitsByWord { KLCmdReadDataByte,"ReadDataByte"},// = 0x31, { KLCmdWriteDataByte,"WriteDataByte"},// = 0x32, { KLCmdReadDataWord,"ReadDataWord"},// = 0x33, { KLCmdWriteDataWord,"WriteDataWord"},// = 0x34, { KLCmdReadData,"ReadData"},// = 0x35, { KLCmdWriteData,"WriteData"},// = 0x36, { KLCmdReadProg,"ReadProg"},// = 0x51, { KLCmdWriteProg,"WriteProg"},// { KLCmdReadSysCfg,"ReadSysCfg"},// { KLCmdWriteSysCfg,"WriteSysCfg"},// { KLCmdSaveSysCfg,"SaveSysCfg"},// // KLCmdReadRunStat, { KLCmdErrRply,"ErrRply"}// = 0xEE, //ERRORReply }; typedef struct tagKLExtDataFrame { UCHAR Dst; UCHAR nType; UCHAR Len2; UCHAR Data[1]; }*pKLExtDataFrame; typedef union tagKLStatDef { UCHAR StatByte; struct { UCHAR nSEQ : 4; UCHAR HasExt : 1; UCHAR HasErr : 1; }; }unKLStat, *pKLStat; int m_nSeq = 0; int m_nRSeq = 0; unsigned char m_Dst; int m_nTotalSendCount = 0; int m_nTotalRecvCount = 0; int m_nTotalFailCount = 0; int m_nSendCount = 0; int m_nRecvCount = 0; int m_nLastSendCount = 0; int m_nLastRecvCount = 0; int m_SendSpeed = 0; int m_RecvSpeed = 0; double LastTime = 0; //unsigned char m_Stat; unKLStat m_Stat1 = { 0 }; unKLStat m_DstStat; typedef struct tagKLReqPacketDef { UCHAR StartSign; UCHAR DstAddr; UCHAR Stat; UCHAR Cmd; UCHAR Type1; UCHAR Params[1]; }stKLReqPacket, *pKLReqPacket; typedef struct tagKLRplyPktHdr { unsigned char RplyStSgn; // unsigned char DstAddr; // unsigned char nStatus; // unsigned char nRplyCMD; // unsigned char nSize1; // unsigned char Datas[1]; // }stKLRplyPktHdr, *pKLRplyPktHdr; unsigned char m_Packetbuf[256]; unsigned char m_SendBuf[1024]; unsigned char m_RecvBuf[1024]; unsigned char m_DataBuf[1024]; typedef struct tagChnStat { unsigned short Stat; unsigned short SendPackets; unsigned short RecvPackets; unsigned short LastSentTimeuS; unsigned short LostPackets; unsigned short CtnLstPkts; unsigned short MaxCtnLstPkts; unsigned short NotPkgErr; unsigned short PkgLenErr; unsigned short BCCErr; unsigned short TimeOutErr; unsigned short Delay; unsigned short MaxDelay; unsigned short SendTimeInterval; union { unsigned short ClientDatas[10]; struct { unsigned short ClientRecvPkts; // unsigned short ClientSendPkts; // unsigned short ClientNotPktErr; // unsigned short ClientMisIdPkts; // // unsigned int ClientNoEndErr; // unsigned short ClientPkgLenErr; // unsigned short ClientBccErr; // unsigned short ClientTimeOutErr; // }; }; } stChnStat, *pChnStat; enum enKLDataCounts { KLDataWXCount = 16, KLDataWYCount = 16, KLDataWRCount = 16, KLDataLDCount = 64, KLDataWLCount = 8, KLCoilXCount = KLDataWXCount * 16, KLCoilYCount = KLDataWYCount * 16, KLCoilRCount = KLDataWRCount * 16, KLCoilTCount = 64, KLCoilCCount = KLCoilTCount, KLDataSVCount = KLCoilTCount, KLDataEVCount = KLCoilTCount, KLCoilLXCount = 128, KLCoilLYCount = 128, KLCoilLRCount = 128, KLCoilSRCount = 128, KLDataDTCount = 256, KLDataSDTCount = 256, KLDataWDTCount = 256, }; struct tagMEM { union //tagWX { USHORT WX[64]; UCHAR WXB[128]; UINT WXD[32]; }; union //tagWY { USHORT WY[64]; UCHAR WYB[128]; UINT WYD[32]; }; union //tagWLX { USHORT WLX[64]; UCHAR WLXB[128]; UINT WLXD[32]; }; union //tagWLY { USHORT WLY[64]; UCHAR WLYB[128]; UINT WLYD[32]; }; union //tagDT { USHORT DT[256]; UCHAR DTB[512]; UINT DTD[128]; }; union //tagWR { USHORT WR[64]; UCHAR WRB[128]; UINT WRD[32]; }; union //tagSDT { UCHAR SDB[512]; USHORT SDT[256]; UINT SDD[128]; struct { unsigned int EffJumperSW; unsigned int CurJumperSW; unsigned int haltick; unsigned int RunStat; unsigned int ErrStat; unsigned int nTickCount; unsigned int TotalRunTime; unsigned int ThisRunTime; unsigned int PwrOnCount; unsigned int LastScanTime; unsigned int ScanTimeuS; unsigned int MinScanTimeuS; unsigned int MaxScanTimeuS; unsigned short ADCValues[20]; }; }; // union { unsigned int WDD[KLDataWDTCount / 2]; unsigned short WDT[KLDataWDTCount]; unsigned char WDB[KLDataWDTCount * 2]; }; union { UCHAR KBDB[2048]; USHORT KBDT[1024]; UINT KBDD[512]; }; union { UCHAR KWLB[256]; USHORT KWLT[128]; UINT KWLD[64]; }; }MEM; CString m_resultStr; static int xtoi(const char * hexstr, int len = 0); unsigned char KLBCC(void * pData, int nSize); int CalCRC(void * pBuf, int nSize); /* Á¬½Ó״̬ ¿ªÊ¼Á¬½Ó(䶨)-> ÐÄÌø°üÕý³£->ÒÑÁ¬½Ó -> ÐÄÌø°üÁ¬ÐøÕý³£ -> Á¬½ÓºÜºÃ Á¬½ÓºÜºÃ -> ÐÄÌø°ü ʧ°Ü / Êý¾Ý°üʧ°Ü -> ÒÑÁ¬½Ó (ÓдíÎó) ÒÑÁ¬½Ó (ÓдíÎó) -> ÐÄÌø°üÕý³£ -> ÒÑÁ¬½Ó */ int CalSpeed(); int fnTest1(int n); int ParseReqPacket(); int MakeRplyPacket(); // typedef int(*pSend)(void *, int); // typedef int(*pRecv)(void *, int); // typedef int(*pOpen)(int); // typedef int(*pClose)(int); // pSend SendPkgFunc; // pRecv RecvPkgFunc; // pOpen OpenFunc; // pClose CloseFunc; /* std::function SendPkgFunc; std::function RecvPkgFunc; std::function OpenFunc; std::function CloseFunc; */ typedef struct tagCallBackFuncs { std::function OpenFunc; std::function CloseFunc; std::function ClearBufFunc; std::function SendPkgFunc; std::function RecvPkgFunc; std::function OnConnect; std::function OnDisConnect; std::function OnError; }stCallBackFuncs, *pCallBackFuncs; stCallBackFuncs m_CallBackFuncs = { std::bind(&HvSerialPort1::Open,&MySerPort1), std::bind(&HvSerialPort1::Close,&MySerPort1), std::bind(&HvSerialPort1::ClearBuf,&MySerPort1), std::bind(&HvSerialPort1::Send,&MySerPort1, std::placeholders::_1, std::placeholders::_2), std::bind(&HvSerialPort1::Recv,&MySerPort1, std::placeholders::_1, std::placeholders::_2) }; int m_bSendCallBackSet = 1; int m_bRecvCallBackSet = 1; int m_bOpenCallBackSet = 1; int m_bCloseCallBackSet = 1; int m_bClearBufCallBackSet = 1; int m_bOnConnectCallBackSet = 0; int m_bOnDisConnectCallBackSet = 0; int m_bOnErrorCallBackSet = 0; bool m_bOpened = false; /* int SetSendCallBackFunc(std::function pSendFunc); int SetRecvCallBackFunc(std::function pRecvFunc); int SetOpenCallBackFunc(std::function pOpenFunc); int SetCloseCallBackFunc(std::function pCloseFunc); */ int SetCommParam(); int SetCallBackFuncs(pCallBackFuncs pFuncSt); int m_nErrCount = 0; int m_nContinueErrCount = 0; int Open(int OpenParam = 0); int Close(int CloseParam = 0); int Connect(int ConnectParam = 0); int DisConnect(int DisConnectParam = 0); int GotoCmdMode(int Param = 0); int ExitCmdMode(int Param = 0); int DoHeartBeat(int nParam = 0); void OnTimer(); int SendPacket(void * pBuf, int Len); int RecvPacket(void * pBuf, int LenToRead, int ReTryCount = 3); int GetNextSeq(); int MakeExtDataFrame(void * pBuf, UCHAR nDst, UCHAR nType, UCHAR len2, void * pData); //int MakeReqPacket(void * pBuf, UCHAR nDst, UCHAR Stat, UCHAR nCMD, UCHAR Type, USHORT nAddr = 0, USHORT nCount = 0, void * pData = NULL); 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); int MakeRemoteReqPacketEx(void* pBuf, UCHAR nDst, UCHAR Stat, UCHAR nPort, UCHAR nChildId, UCHAR nCMD, UCHAR Param1, USHORT nAddr = 0, USHORT nCount = 0, void* pData = NULL, int ExtFrameLen = 0, void* pExtDataFrame = NULL); int CheckPackage(void * pBuf, int nSize); int ProcessPacket(void *pBuf, int nLen); int ParseRplyPacket(void *pBuf, int nPkgLen, UCHAR * nCmd, UCHAR * Status, USHORT* nCount, void * pData); int GetInfo(UCHAR nDst, USHORT * nReadBytes, USHORT * Values); int GetSN(UCHAR nDst, USHORT * nReadBytes, USHORT * Values); int GetUID(UCHAR nDst, USHORT * nReadBytes, USHORT * Values); int ReadFactoryData(UCHAR nDst, USHORT nStartAddr, UCHAR nByteCount, USHORT * nReadBytes, USHORT * Values); int WriteFactoryData(UCHAR nDst, USHORT nStartAddr, UCHAR nByteCount, USHORT * Values); int ReadSysCfgData(UCHAR nDst, UCHAR nType, USHORT nStartAddr, UCHAR nByteCount, USHORT * nReadBytes, USHORT * Values); int WriteSysCfgData(UCHAR nDst, UCHAR nType, USHORT nStartAddr, UCHAR nByteCount, USHORT * Values); //int GetTime32(UCHAR nDst, int * nCount); //int SetTime32(UCHAR nDst, int * nCount); int GetDateTime32(UCHAR nDst, UINT * pValue); int SetDateTime32(UCHAR nDst, UINT Value); int GetEventLogCount(UCHAR nDst, int * nCount); int GetEventLog(UCHAR nDst, int nStartIndex, int nCount, stEventLog * pEventLogs); int ReadBit(UCHAR nDst, UCHAR nType, USHORT nBitAddr, UCHAR * Value);//Read 1 Single bit int WriteBit(UCHAR nDst, UCHAR nType, USHORT nBitAddr, UCHAR Value);//Write 1 Single bit int ReadBits(UCHAR nDst, UCHAR nType, USHORT nBitAddr, UCHAR nBitCount, UCHAR * Values); int WriteBits(UCHAR nDst, UCHAR nType, USHORT nBitAddr, UCHAR nBitCount, UCHAR * Values); int ReadBitsByWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT *Values); int WriteBitsByWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT *Values); int ReadDataByte(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, USHORT * nByteRead, UCHAR * Values); int WriteDataByte(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, UCHAR * Values); int ReadDataWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * nByteRead, USHORT * Values); int WriteDataWord(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values); int ReadData(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * nByteRead, USHORT * Values); int WriteData(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values); int GetMode(UCHAR nDst, UCHAR nType, UCHAR* value); int ChangeMode(UCHAR nDst, UCHAR nType); int BlinkLED(UCHAR nDst, UCHAR nSecond); int ReadPLCProgram(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values); int StartDownloadPLCProgram(UCHAR nDst, UCHAR nType, USHORT nProgBytes,USHORT nCRC = 0); int DownloadPLCProgram(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, USHORT * Values); int FinishDownloadPLCProgram(UCHAR nDst, UCHAR nType, USHORT nProgSteps, USHORT nCRC = 0); int ReadPLCAnno(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, UCHAR* Values); int StartDownloadPLCAnno(UCHAR nDst, UCHAR nType, USHORT nBytes, USHORT nCRC = 0); int DownloadPLCAnno(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, UCHAR* Values); int FinishDownloadPLCAnno(UCHAR nDst, UCHAR nType, USHORT nByteSize, USHORT nCRC = 0); int ReadRunStat(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values); int ClearStatistics(UCHAR nDst, UCHAR nType); int ResetDevice(UCHAR nDst, UCHAR nType); int WriteFirmware(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, UCHAR* Values); int WriteFirmInfo(UCHAR nDst, UCHAR nType, USHORT nByteAddr, UCHAR nByteCount, UCHAR* Values); int GetPortInfo(UCHAR nDst, UCHAR nType, UCHAR nByteCount, USHORT* nByteRead, USHORT* Values); int GetPortChildInfo(UCHAR nDst, UCHAR nType, UCHAR nChildId, UCHAR nByteCount, USHORT* nByteRead, USHORT* Values); int GetPortChnInfo(UCHAR nDst, UCHAR nType, UCHAR nChnId, UCHAR nByteCount, USHORT* nByteRead, USHORT* Values); int RunRemoteReq(UCHAR nDst, UCHAR nPort, UCHAR nChnId, UCHAR nReqId, UCHAR nParam, USHORT nByteAddr = 0, UCHAR nByteCount =0 ,void * pData = 0); int RmoteBlinkLED(UCHAR nDst, UCHAR nPort, UCHAR nChnId, UCHAR nSecond); };