From 95322c84888cbe2e92024d4d65698f59b016cb52 Mon Sep 17 00:00:00 2001
From: QuakeGod <quakegod@sina.com>
Date: 星期日, 25 二月 2024 12:29:35 +0800
Subject: [PATCH] move some define from Kbus.h to KBusDefine.h

---
 ComLib/Inc/KBus.h |  237 +++--------------------------------------------------------
 1 files changed, 13 insertions(+), 224 deletions(-)

diff --git a/ComLib/Inc/KBus.h b/ComLib/Inc/KBus.h
index 3e257a6..85be510 100644
--- a/ComLib/Inc/KBus.h
+++ b/ComLib/Inc/KBus.h
@@ -5,6 +5,8 @@
   *                   This file contains the common defines of the application.
   ******************************************************************************
 	*/
+#include "KBusDefine.h"
+
 #include "KMachine.h"
 
 #ifndef __KBUS_H__
@@ -18,61 +20,10 @@
 
 extern unsigned char bKBusMaster,bKBusSlave,bKBusRepeater;;
 
-// diagnosis
-
-enum enKBusStats
-{
-		KBusStatIdel,
-		KBusStatConfig,
-		KBusStatRunning,
-		KBusStatError,
-};
-
-enum enCMDs
-{
-	cmdNone = '0',		//Nothing
-	cmdPing = '1',			//Ping
-	cmdPingReply = '2',		//PingReply
-	cmdRead = '3',				//Read
-	cmdReadReply = '4',		//ReadReply
-	cmdWrite = '5',				//Write
-	cmdWriteReply = '6',	//WriteReply
-	cmdGetVersion = '7',		//GetVersion
-	cmdVerInfo = '8',				//VersionReply
-	
-	cmdExChgData='A',				//ExChangeDate, = Wirte + Read
-	cmdExChgDataReply,			//ExchangeData Reply
-	
-	cmdSyncRead='a',				//SyncRead
-	cmdSyncWrite,						//SyncWrite
-	cmdSequenRead,					//Sequence Read
-	cmdSyncTime,						//SyncTime
-};
-
-enum {
-			SYN = 0x55,
-			StartSign='%',
-			EndSign=0x0D,
-			MaxPacketLength=128,
-};
 
 extern unsigned char PacketBuf1[MaxPacketLength];
 extern unsigned char PacketBuf2[MaxPacketLength];
 
-typedef struct tagKBusRunStat
-{
-	unsigned char bMaster;
-	unsigned char nStationID;
-	unsigned char nChildren;
-	unsigned char nCurPollId;
-	unsigned char nSeq;
-
-	unsigned char bMasterRecved;
-	unsigned char bMasterRecvOK;
-	unsigned char bSlaveRecved;
-	unsigned int nSendTimeuS;
-
-}stKBusRunStat , * pstKBusRunStat;
 
 extern unsigned char BufferIn[16];
 extern unsigned char BufferOut[16];
@@ -92,179 +43,21 @@
 
 extern volatile unsigned int nSlaveTick;
 
-typedef struct tagVerInfo
-{
-	unsigned char nMainVer;
-	unsigned char nSubVer;
-}stVerInfo;
-
-
-
-typedef struct tagMasterStat
-{
-	unsigned int CycleTime;
-} stMasterStat;
-
-typedef struct ServerStatus
-{
-	unsigned char Addr;
-	unsigned char Status;
-	unsigned short Input[16];
-	unsigned short DT[128];
-	unsigned short output[16];	
-	
-}stServerStatus,*pServerStatus;
-
-
-typedef struct tagClientInfo
-{
-	stVerInfo ClientVer;
-	unsigned char nType;
-	unsigned char nGroup;
-	unsigned char InCount;
-	unsigned char OutCount;
-	unsigned char InDWCount;
-	unsigned char OutDWCount;
-	unsigned char bOnline;
-}stClientInfo;
-
-typedef struct tagClientCfg
-{
-	unsigned int KeepOut;		//Keep Output when comm err;
-	
-	
-}stClientCfg;
-
-typedef struct tagMachineState
-{
-	unsigned char Addr;
-	unsigned char state;
-	unsigned char InStartAddrBit;
-	unsigned char OutStartAddrBit;
-	unsigned char InDWStartAddrByte;
-	unsigned char OutDWStartAddrByte;
-}ClientState;
-
-
-
-#pragma anon_unions
-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;
-	union
-	{
-		unsigned int ClientDatas[10];
-		struct {
-		unsigned int ClientRecvPkts;	//
-		unsigned int ClientSendPkts;	//
-		unsigned int ClientNotPktErr;	//
-		unsigned int ClientMisIdPkts;	//
-//		unsigned int ClientNoEndErr;	//
-		unsigned int ClientPkgLenErr;	//
-		unsigned int ClientBccErr;		//
-		unsigned int ClientTimeOutErr;	//
-		};
-	};
-} stChnStat;
-
 extern stChnStat KBusChnStats[8];
-
-typedef struct tagSlaveStat
-{
-	unsigned int nSlaveTick;
-} stSlaveStat;
-
-
-typedef struct ServerClientListElement
-{
-	unsigned char Addr;
-	unsigned char Status;
-	unsigned char Father;
-	unsigned char Childs;
-	
-}	stServerClientListElement;
-
-typedef struct ServerClientList
-{
-	unsigned char Addr;
-}stServerClientList,*pServerClientList;
 /*
-typedef struct ClientStatus
-{
-	unsigned char Addr;
-	unsigned char Status;
-	unsigned char Father;
-	unsigned char Childs;
-	unsigned short Input[16];
-	unsigned short DT[128];
-	unsigned short output[16];
+static inline char KWInit(int nPortNum) {  };
+static inline char KWStart(int nPortNum) { };
+static inline char KWGetClientNum(int nPortNum) { };
+static inline char KWGetClientInfo(int nPortNum, int nClientId) { };
+static inline char KWGetClientInCount(int nPortNum,int nClientId) {};
+
 	
-}stChnStatus,*pClientStatus;
+static inline char KWisSafeState(int nPortNum) { };
+static inline char KWisRunState(int nPortNum) { };
+static inline char KWGetState(int nPortNum) { };
+static inline char KWChangeState(int nPortNum, int nNewState){ };
 */
-typedef void *(*CBFuncDef) (void*, void *, int);	//callback func ,prama s is  void *,void *,int; return void *;
-enum enumCallBackEvent
-{
-	evNone = 0,
-	evCreate = 1,
-	evConnected = 2,
-	evDisConnected = 3,
-	evClosed = 4,
-};
 
-typedef struct tagStatusDef
-{
-			unsigned char nSeq:2;		//搴忓垪鍙�
-			unsigned char :2;
-			unsigned char nErr1:1;
-			unsigned char nErr2:1;
-}stStatus;	
-
-typedef union tagUnStatusDef
-{
-	unsigned char nStatus;
- stStatus;
-}unStatus;
-
-typedef struct tagKBPacket
-	{
-		unsigned char Sign;		//璧峰鏍囪		
-		unsigned char DstHost;	//鐩爣鍦板潃
-		unsigned char SrcAddr;	//婧愬湴鍧�
-		unsigned char nCMD;		//鍛戒护
-		union{
-		unsigned char nStatus;		//鐘舵��+搴忓垪鍙�
-		struct{
-			unsigned char nSeq:2;		//搴忓垪鍙�
-			unsigned char :2;
-			unsigned char nErr1:1;
-			unsigned char nErr2:1;
-			
-		};
-		};
-		unsigned char DataLen;	//鏁版嵁杞借嵎闀垮害	涓嶅寘鎷ご閮�5涓瓧鑺傦紝涓嶅寘鎷熬閮˙CC銆�
-		unsigned char data[1];		//鏁版嵁杞借嵎,鏈�鏈熬鏄疊CC锛屾暟鎹暱搴︿负0鏃讹紝瀹為檯涔熸湁涓�涓暟鎹��
-	}stKBPacket,* pKBPacket;	
-
-enum eResult
-{	
-	S_OK =0,
-	S_ERR=1,
-	S_TIMEOUT=2
-
-}	;
 
 unsigned char KBusBCC(void * pData, int nSize);
 //
@@ -276,11 +69,7 @@
 
 /* */
 int KBusParsePacket(int nChn, pKBPacket p1, int Len1);
-typedef struct tagMachineConfig
-{
-	int bKBusMaster;
-	int nAddr;
-}stMachineConfig;
+
 /*
 int InitMachine(stMachineConfig * pConfig);
 

--
Gitblit v1.9.1