📄 protocal.h
字号:
#ifndef __PROTOCAL_H__
#define __PROTOCAL_H__
#include "Communication.h"
//Command define
#define WOCRTRAIN 1
#define WOCRCOGWITHPARAM 2
#define WOCRCOGWITHRCP 3
#define WOCRCOGWITHDEFPARAM 4
#define WOCRCOGWITHDEFRCP 5
#define WOCRGETLASTID 6
#define GETNETINFO 1024
#define GETIMAGE 1025
#define GETVERINFO 1026
#define GETMODEINFO 1027
#define GETSPINFO 1028
#define GETCALIBRATION 1029
#define GETGLOBALGAIN 1030
#define GETREDGAIN 1031
#define GETBLUEGAIN 1032
#define GETGREEN1GAIN 1033
#define GETSHUTTER 1034
#define GETIO 1035
#define GETGREEN2GAIN 1036
#define GETTIME 1037
#define GETTEMPERATURE 1038
#define GETPROGTYPE 1039
#define GETAVERAGEPIXELVALUE 1040
//实时获取的网络状态 1为由网络断而恢复的连接,0为其他
#define GETLINKSTATUS 2047
#define CFGNETINFO 2048
#define CFGCAMINFODYN 2049
#define CFGLEDINFODYN 2050
#define CFGMODEINFO 2051
#define CFGUPDATE 2052
#define CFGTRAINCANCEL 2053
#define CFGSPINFO 2054
#define CFGCALIBRATION 2055
#define CFGLOADPROG 2056
#define CFGCAPTUREMODE 2057
#define CFGREDGAIN 2058
#define CFGBLUEGAIN 2059
#define CFGGREEN1GAIN 2060
#define CFGSHUTTER 2061
#define CFGIO1 2062
#define CFGGREEN2GAIN 2063
#define CFGAFEPGA 2064
#define CFGBRIGHTNESS 2065
#define CFGSETMODE 2066
#define CFGIO2 2067
#define CFGENABLESTROBE 2068
#define CFGDISABLESTROBE 2069
#define CFGSTROBEOFFSET 2070
#define CFGSTARTSERIALIMAGE 2071
#define CFGSTOPSERIALIMAGE 2072
#define CFGFORMAT 2073
#define CFGENABLESATURATION 2074
#define CFGSATURATION 2075
#define CFGTIME 2076
#define CFGRESET 2077
#define CFGENABLEDOG 2078
#define CFGDISABLEDOG 2079
#define CFGSTARTFEEDDOG 2080
#define CFGSTOPFEEDDOG 2081
#define CFGBITSDEPTH 2082
#define CFGSTROBELEVEL 2083
#define CFGAGEMODE 2084
#define CFGAGEPARAM 2085
#define CFGAGEPRD 2086
#define CFGJPEGQUALITY 2087
#define CFGSTRIGGERLEVEL 2088
#define CFGENABLERSMODE 2089
#define FSREADFILEINFO 3072
#define FSREADIMG 3073
#define FSDELIMG 3074
#define FSREADRCP 3075
#define FSWRITERCP 3076
#define FSDELRCP 3077
#define FSREADLOG 3078
#define FSDELLOG 3079
#define FSCLEAR 3080
#define FSDOWNLOADRCPDATA 3081
#define CTRLTRAINSTOP 4096
#define CTRLREADSTATUS 4097
//Packet type
#define COMU_REQUEST 1
#define COMU_RESPONSE 2
#define COMU_INPROGRESS 3
//Protocal type defines
#define PROTO_HYTERMINAL 1
#define PROTO_SIEMENS 2
#define PROTO_TEST 3
//Terminal defines
#define MAX_TERMINAL_OUTBUFFER_SIZE 0x10000
#define MAX_TERMINAL_OUTITEM_SIZE 256
#define MAX_TERMINAL_INBUFFER_SIZE 0x1000
#define MAX_TERMINAL_CMD_LEN 32
#define TERMINAL_IN_CR 0
#define TERMINAL_IN_LF 1
#define TERMINAL_IN_DL 2
#define TERMINAL_IN_CRLF 3
#define TERMINAL_IN_LFCR 4
#define TERMINAL_IN_DLCR 5
#define TERMINAL_IN_CR_LF 6
#define TERMINAL_IN_CR_LF_XON 7
#define TERMINAL_OUT_CR 0
#define TERMINAL_OUT_LF 1
#define TERMINAL_OUT_CRLF 2
#define TERMINAL_OUT_LFCR 3
//Siemens protocal definition
#define SI_TIMEOUT_NORMAL 1000
#define SI_TIMEOUT_FOREVER -1
#define SI_MAX_COMMAND_LEN 64
#define SI_MAX_DATA_LEN 64
#define MSG_START_SEND 0
#define MSG_STOP_SEND 1
//Test protocal
#define TEST_MAX_COMMAND_LEN 64
//Packet header
typedef struct _tagComuHead
{
unsigned int nDataLen;
unsigned short nDataType;
unsigned short nCheckSum;
unsigned short nCommandType;
unsigned short nCommand;
unsigned short nError;
}COMU_HEAD,*pCOMU_HEAD;
// DATA type
#define DATA_IMAGE 1
#define DATA_STRING 2
#define DATA_INT 3
#define DATA_JPEG 4
#define DATA_YUV 5
//自动增益曝光模式
#define AGE_AUTOGAIN 0x2
#define AGE_AUTOEXPOSURE 0x1
typedef enum _tagTSK_ID
{
TSK_NETNORMAL = 0,
TSK_NETPRIOR,
TSK_COG,
TSK_TST,
TSK_CFG,
TSK_FILE,
TSK_PRIOR,
TSK_SERIPORT
// TSK_STARTSERIAL,
// TSK_STOPSERIAL,
// TSK_SENDSERIAL,
// TSK_GETIMAGE
}eTSK_ID;
typedef struct _tagLinkAddr
{
int nLinkIp;
int nLinkPortNum;
}LINKADDR, *PLINKADDR;
typedef struct tag_SerialImageParam
{
LINKADDR linkAddr;
IMAGE_INFO image_info;
}SERIALPARAM, *PSERIALPARAM;
//iLink protocal, communicate with iLink.dll in pc
class CiLink : public CProtocal
{
private:
char* m_pNetBuffer;
unsigned int m_unBufLen;
public:
CiLink(CCommunication* pCommunication, char* pBuffer, unsigned int unBufLen);
virtual ~CiLink();
virtual void ParseProcess(int nCommuType);
//int ContinuousSendData(char * pBuffer, int nLen);
private:
int LinkCommonParse(char* pBuffer);
void LinkIPParse();
void LinkIPReply();
int LinkGetCmd();
int LinkReply(char* pBuffer);
int LinkSerialReply(char* pBuffer);
unsigned short LinkCheckSum(unsigned short* pBuffer, int nLen);
};
//terminal protocal, commucate with hyper terminal
class CTerminal : public CProtocal
{
private:
//Current curse position of client terminal
int m_nCurrentPos;
//Position of the last valid char in command buffer
int m_nMaxPos;
//Position of the last valid item in terminal output info buffer
int m_nCurrentToiPos;
//Output end string
char m_strOutputEnd[4];
//Buffer the input command
char m_strCmd[MAX_TERMINAL_CMD_LEN];
char m_strTerminalOutBuffer[MAX_TERMINAL_OUTBUFFER_SIZE];
public:
CTerminal(CCommunication* pCommunication);
virtual ~CTerminal();
//Get command from serial port recv buffer, the valid command is saved in m_strCmd
int GetCmd();
//Output string to client terminal
void OutString(char* pBuffer, int nLen);
//If client terminal send a char each time, this function used to trace the input terminal key
void ShrinkString(char* pBuffer, int nPos);
//Parse command line, detach command and parameters and call certain function
int ParseCommand();
//Command read
int OnRead(char* pParam1, char* pParam2);
//Command version
int OnVersion();
//Command file
int OnFile();
//Command query
int OnQuery(char* pParam);
//Terminal process:GetCmd-->ParseCommand
virtual void ParseProcess(int nCommuType);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -