| | |
| | | // 此类是从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;
|
| | |
| | |
|
| | | HvSerialPort1 MySerPort1;
|
| | | int m_bCommParamSet = 0;
|
| | | int m_nPort;
|
| | | int m_nBaudRate;
|
| | | CString m_Settings;
|
| | | 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
|
| | |
| | | KL_NOT_SUPPORT,
|
| | | };
|
| | |
|
| | | const char * GetErrDescStr(int nErrNo);
|
| | | static const char * GetErrDescStr(int nErrNo);
|
| | |
|
| | | enum
|
| | | {
|
| | |
| | | KLCmdStartProgram,
|
| | | KLCmdWriteProgram,
|
| | | KLCmdFinishProgram,
|
| | | KLCmdReadPLCAnno,
|
| | | KLCmdStartPLCAnno,
|
| | | KLCmdWritePLCAnno,
|
| | | KLCmdFinishPLCAnno,
|
| | |
|
| | | KLCmdRead1Bit = 0x21, //ReadSingleBit
|
| | | KLCmdWrite1Bit = 0x22, //WriteSingleBit
|
| | |
| | | KLCmdMC = 0x70,
|
| | | KLCmdMD,
|
| | | KLCmdMG,
|
| | |
|
| | | |
| | | KLCmdWriteFirmware,
|
| | | KLCmdWriteFirmInfo,
|
| | | KLCmdGetPortInfo,
|
| | | KLCmdGetPortChnInfo,
|
| | | KLCmdGetPortChildInfo,
|
| | | KLCmdPortRemoteReq,
|
| | | KLCmdThrough,
|
| | |
|
| | | KLCmdErrRply = 0xEE, //ERRORReply
|
| | |
| | |
|
| | | typedef struct tagChnStat
|
| | | {
|
| | | unsigned int Stat;
|
| | | unsigned int SendPackets;
|
| | | unsigned int RecvPackets;
|
| | | unsigned int LastSentTimeuS;
|
| | | unsigned int LostPackets;
|
| | | unsigned int CtnLstPkts;
|
| | | unsigned int MaxCtnLstPkts;
|
| | | unsigned int NotPkgErr;
|
| | | unsigned int PkgLenErr;
|
| | | unsigned int BCCErr;
|
| | | unsigned int TimeOutErr;
|
| | | unsigned int Delay;
|
| | | unsigned int MaxDelay;
|
| | | unsigned int SendTimeInterval;
|
| | | 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 int ClientDatas[10];
|
| | | unsigned short ClientDatas[10];
|
| | | struct {
|
| | | unsigned int ClientRecvPkts; //
|
| | | unsigned int ClientSendPkts; //
|
| | | unsigned int ClientNotPktErr; //
|
| | | unsigned int ClientMisIdPkts; //
|
| | | unsigned int ClientPkgLenErr; //
|
| | | unsigned int ClientBccErr; //
|
| | | unsigned int ClientTimeOutErr; //
|
| | | 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,
|
| | |
| | | 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
|
| | | {
|
| | |
| | | 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);
|
| | |
| | | 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 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 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, USHORT nStartAddr, UCHAR nByteCount, USHORT * nReadBytes, USHORT * Values);
|
| | | int WriteSysCfgData(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 BlinkLED(UCHAR nDst, UCHAR nSecond);
|
| | |
|
| | | int ReadProgram(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
|
| | | 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 StartProgram(UCHAR nDst, UCHAR nType);
|
| | | int WriteProgram(UCHAR nDst, UCHAR nType, USHORT nWordAddr, UCHAR nWordCount, USHORT * Values);
|
| | | int FinishProgram(UCHAR nDst, UCHAR nType, USHORT nStepSize);
|
| | | 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);
|
| | |
|
| | | };
|
| | |
|