Project

General

Profile

Feature #1429 » 103.h

yufeng wu, 06/03/2021 12:25 PM

 
1
#ifndef	_103PROC_
2
#define	_103PROC_
3
#include "daq\daq_protocol.h"
4
 
5
#define				T103SENDBUFSIZE				300
6

    
7
#define				DC_K_CALLTIME						0			//Уʱ????
8
#define				DC_K_CALL1DATA						1			//1???ٻ?
9
#define				DC_K_CALL2DATA						2			//2???ٻ?
10
#define				DC_K_EXECCMD						3			//?ⲿ????
11

    
12
//?ٻ??鶨??
13
#define				DC_K_CALLALLDATA					20			//վ???ٻ?
14

    
15
//?????????
16
#define				DC_K_YKSELECT						10		//ң??ѡ??????
17
#define				DC_K_YKEXECUTE						11		//ң??ִ??????
18
#define				DC_K_YKCANCEL						12		//ң?س???????
19

    
20

    
21
struct S103_CONTROLFIELD
22
{
23
   BYTE		FC :4;				//??????
24
   BYTE		FCV:1;				//FCB??Ч
25
   BYTE		FCB:1;				//֡????λ
26
   BYTE		PRM:1;				//????????
27
   BYTE		DIR:1;				//????
28
};
29
 
30
typedef union
31
{
32
	S103_CONTROLFIELD	CtrlField;
33
	BYTE				BCtrlField;
34
}S103_CONTROL_BYTE;
35

    
36
enum E103_STATUS
37
{
38
	STATUS_OVERTIME=0,  //??ʱ
39
	STATUS_CRCERR,		//CRCУ???
40
	STATUS_NODATA,		//?????????????
41
	STATUS_RXOK
42
};
43

    
44
enum E103_LINKSTATUS
45
{
46
	LSTATUS_INIT=0,		//??ʼ??״̬
47
	LSTATUS_RESET,		//??ʼ??λ
48
	LSTATUS_OK			//??·???ڿ???״̬??????????Ӧ?ò???????????
49
};
50

    
51

    
52
class C103 : public CProtocol  
53
{
54
	uint8 m_rii;
55
	uint8 m_scn;
56
	int   m_LastRxProtSoe;	//?յ??????¼??Զ???10??󸴹?
57
	int   m_LastCallAllTime,m_LastSyncTime;
58
	E_CMD_SRCSORT	m_cmdprotsort;			//????Դ?Ĺ?Լ????
59
	PIPE_LABLE m_CmdSrc;	//???ڼ?¼????Դ??????ң?ط?У??г??????
60
	uint16			m_cmdsrc_rtu;			//?????????ͨ??װ?ú?
61
	uint8 m_cmdf;		//???Ͷ??????ң?????????Ҫ????
62
	void reset_protect_info();
63
protected:
64

    
65
	unsigned char m_ACDFlag;
66
	unsigned char m_MainFCBFlag;
67
	unsigned char m_SubFCBFlag;
68

    
69
	unsigned char m_OverTimeFlag;//??ʱ??־
70
	int m_CRC_ErrCnt;
71

    
72
	int m_LastSendTime;
73
	int m_RcvTimeOuts;		//??ʱʱ??
74

    
75
	int m_ReSendMaxCount;	//?ط?????
76
	int m_ReSendCnt;		//?ط??????? ==-1 δ????
77

    
78
	E103_LINKSTATUS		 m_LinkStatus;	//????״̬
79
	BYTE				 m_SendBuf[T103SENDBUFSIZE];
80
	int					 m_SendBufLen;
81

    
82
public:
83
	virtual sint32 TxProc();
84
	virtual sint32 RxProc();
85
	virtual sint32 GetZfFlag( )
86
	{
87
		return 0;
88
	};
89
	virtual void	Init( S_PROTOCOLCFG * pcfg );
90

    
91
protected:
92
	virtual ~C103();
93
	unsigned char	GetByteCheckSum(unsigned char *buf,int buflen);
94
	int				GetNowSecond();
95
	void			SetTxRxStatus(E103_STATUS  status);
96

    
97
	void			InitRtu();
98
	void			ProcShortCmd(uint8 *buf,int buflen);
99
	void			ProcLongCmd(uint8 *buf,int buflen);
100

    
101
	virtual void		Recv_ProcYC(BYTE *buf,int buflen);
102
	virtual void		Recv_ProcSOE(BYTE *buf,int buflen);
103
	virtual void		Recv_ProcKWH(BYTE *buf,int buflen);
104
	virtual short int	CalcYcShortVal(BYTE LowByte,BYTE HighByte);
105

    
106
	virtual void	SendToPhysical(BOOL bResend=FALSE);
107
	virtual void	ReSendData();
108
	virtual void	AppendIp();
109
	virtual BOOL	ProcCmd();
110

    
111
	virtual void	SendRequestLinkStatusCmd();
112
	virtual void	SendResetLinkCmd();
113
	virtual void	SendCallAllDataCmd();
114
	virtual BOOL	SendCallClassOneDataCmd();
115
	virtual BOOL	SendCallClassTwoDataCmd();
116
	virtual void	SendYKCmd( S_CmdInfo cmdinfo ,BYTE type);
117
	virtual BOOL	SendTimeCmd();
118
};
119

    
120
#endif
121

    
(2-2/3)