1
|
#ifndef _SE104PROC_
|
2
|
#define _SE104PROC_
|
3
|
|
4
|
#include "daq/daq_protocol.h"
|
5
|
|
6
|
#ifdef NET_BYTEORDER
|
7
|
#define BITORDER 1
|
8
|
#endif
|
9
|
|
10
|
|
11
|
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
12
|
//??????ʼ??ֹ??ַ????
|
13
|
#define START_YC 0x4000
|
14
|
#define START_ACC 0xc01
|
15
|
#define START_YK 0x6000
|
16
|
#define END_YK 0x6200
|
17
|
|
18
|
#define APP_DATALEN 300
|
19
|
#define FRAME_MAXLEN 255
|
20
|
|
21
|
#define APP_UFORMAT_STARTACT 0x04
|
22
|
#define APP_UFORMAT_STARTCON 0x08
|
23
|
#define APP_UFORMAT_STOPACT 0x10
|
24
|
#define APP_UFORMAT_STOPCON 0x20
|
25
|
#define APP_UFORMAT_TESTACT 0x40
|
26
|
#define APP_UFORMAT_TESTCON 0x80
|
27
|
//????ԭ??
|
28
|
#define APP_COT_SPONT 3 //ͻ??
|
29
|
#define APP_COT_ACT 6 //????
|
30
|
#define APP_COT_ACT_CON 7 //????ȷ??
|
31
|
#define APP_COT_DEACT 8 //ֹͣ????
|
32
|
#define APP_COT_DEACT_CON 9 //ֹͣ????ȷ??
|
33
|
#define APP_COT_ACT_TERM 10 //???????
|
34
|
//???ͱ?ʶ
|
35
|
//??վ-->??վ
|
36
|
#define M_SP_NA_1 1 //????ʱ??ĵ?????Ϣ
|
37
|
#define M_SP_TA_1 2 //??ʱ??ĵ?????Ϣ
|
38
|
#define M_DP_NA_1 3 //????ʱ???˫????Ϣ
|
39
|
#define M_DP_TA_1 4 //??ʱ???˫????Ϣ
|
40
|
#define M_ST_NA_1 5 //??λ????Ϣ????ѹ???ֽ?ͷ??
|
41
|
#define M_ST_TA_1 6 //??ʱ??IJ?λ????Ϣ????ѹ???ֽ?ͷ??
|
42
|
#define M_BO_NA_1 7 //??վԶ???ն?״̬
|
43
|
#define M_ME_NA_1 9 //????ֵ
|
44
|
#define M_ME_TA_1 10 //??ʱ??IJ???ֵ
|
45
|
#define M_ME_NC_1 13 //????ֵ???̸?????
|
46
|
#define M_IT_NA_1 15 //?????????????
|
47
|
#define M_IT_TA_1 16 //??ʱ??ĵ????????????
|
48
|
#define M_EP_TA_1 17
|
49
|
#define M_EP_TB_1 18
|
50
|
#define M_EP_TC_1 19
|
51
|
#define M_PS_NA_1 20 //״̬??״̬?仯???
|
52
|
#define M_ME_ND_1 21 //??Ʒ???????IJ???ֵ
|
53
|
#define M_SP_TB_1 30
|
54
|
#define M_BD_NA_1 232 //BCD??(ˮλֵ)
|
55
|
#define M_EI_NA_1 70 //??ʼ??????
|
56
|
//??վ-->??վ
|
57
|
#define C_SC_NA_1 45 //????????
|
58
|
#define C_DC_NA_1 46 //˫??????
|
59
|
#define C_RC_NA_1 47 //??????????
|
60
|
#define C_SE_NA_1 48 //?趨????,??һ??ֵ
|
61
|
#define C_BO_NA_1 51 //32λ??λ??
|
62
|
#define C_IC_NA_1 100 //?ٻ?????
|
63
|
#define C_CI_NA_1 101 //?????????ٻ?????
|
64
|
#define C_RD_NA_1 102 //??????????
|
65
|
#define C_CS_NA_1 103 //ʱ??ͬ??????
|
66
|
#define C_TS_NA_1 104 //????????
|
67
|
#define C_RP_NA_1 105 //??λ????????
|
68
|
#define P_ME_NA_1 110 //װ?ز???????
|
69
|
#define P_AC_NA_1 113 //????????
|
70
|
//?ļ?????
|
71
|
#define F_FR_NA_1 120 //?ļ???????
|
72
|
#define F_SR_NA_1 121 //????????
|
73
|
#define F_SC_NA_1 122 //?ٻ?Ŀ¼??ѡ???ļ????ٻ??ļ????ٻ???
|
74
|
#define F_LS_NA_1 123 //???Ľڡ????Ķ?
|
75
|
#define F_AF_NA_1 124 //ȷ???ļ???ȷ??
|
76
|
#define F_SG_NA_1 125 //??
|
77
|
#define F_DR_NA_1 126 //Ŀ¼
|
78
|
|
79
|
//?ٻ??鶨??
|
80
|
#define COT_CALLALLDATA 20 //վ???ٻ?
|
81
|
#define COT_CALLALLKWH 37 //??????ٻ?
|
82
|
#define QCC_CALLALLKWH 5 //??????ٻ????
|
83
|
|
84
|
//????ֵ????????
|
85
|
#define DC_K_THRESHOLD 0X1 //????ֵ
|
86
|
#define DC_K_WAVEFILTER 0X2 //?˲?ϵ??
|
87
|
#define DC_K_LOWERLIMIT 0X3 //????ֵ
|
88
|
#define DC_K_UPPERLIMIT 0X4 //????ֵ
|
89
|
//ң?????Ͷ???
|
90
|
#define DC_K_YKSELECT 10 //ѡ??
|
91
|
#define DC_K_YKEXE 11 //ִ??
|
92
|
#define DC_K_YKCANCEL 12 //????
|
93
|
|
94
|
//Ӧ?ò?״̬
|
95
|
#define IEC104_APP_STATE_IDLE 0
|
96
|
#define IEC104_APP_STATE_UNRESET 10
|
97
|
|
98
|
|
99
|
|
100
|
|
101
|
typedef struct
|
102
|
{
|
103
|
BYTE MilliSecLo;
|
104
|
BYTE MilliSecHi;
|
105
|
BYTE Minutes;
|
106
|
BYTE Hours;
|
107
|
struct
|
108
|
{
|
109
|
#if defined(BITORDER)
|
110
|
BYTE Weeks:3;
|
111
|
BYTE Days:5;
|
112
|
#else
|
113
|
BYTE Days:5;
|
114
|
BYTE Weeks:3;
|
115
|
#endif
|
116
|
}DaysWeeks;
|
117
|
struct
|
118
|
{
|
119
|
#if defined(BITORDER)
|
120
|
BYTE res3:4;
|
121
|
BYTE Months:4;
|
122
|
#else
|
123
|
BYTE Months:4;
|
124
|
BYTE res3:4;
|
125
|
#endif
|
126
|
BYTE Year;
|
127
|
}YearMonth;
|
128
|
}CP56Time2a;
|
129
|
|
130
|
typedef struct
|
131
|
{
|
132
|
// uint16 Milliseconds;
|
133
|
uint8 MilliSecLo;
|
134
|
uint8 MilliSecHi;
|
135
|
struct
|
136
|
{
|
137
|
#if defined(BITORDER)
|
138
|
uint8 IV:1;
|
139
|
uint8 res:1;
|
140
|
uint8 Minutes:6;
|
141
|
#else
|
142
|
uint8 Minutes:6;
|
143
|
uint8 res:1;
|
144
|
uint8 IV:1;
|
145
|
#endif
|
146
|
}Minu;
|
147
|
}CP24Time2a;
|
148
|
|
149
|
|
150
|
const int DC_D_INFOADDRLEN = 3; //??Ϣ???ַ????
|
151
|
const int DC_D_HEADLEN = 6; //APCI ????
|
152
|
|
153
|
typedef struct
|
154
|
{
|
155
|
uint8 TypeID;
|
156
|
struct
|
157
|
{
|
158
|
#if defined(BITORDER)
|
159
|
uint8 SQ:1;
|
160
|
uint8 Num:7;
|
161
|
#else
|
162
|
uint8 Num:7;
|
163
|
uint8 SQ:1;
|
164
|
#endif
|
165
|
}VSQ; //?ɱ?ṹ????
|
166
|
uint8 Cause;
|
167
|
uint8 SrcAddr;
|
168
|
uint8 CommonAddrLo;
|
169
|
uint8 CommonAddrHi;
|
170
|
}DC_D_DATAUNITID; //???ݵ?Ԫ??ʾ??
|
171
|
|
172
|
typedef struct
|
173
|
{
|
174
|
union
|
175
|
{
|
176
|
uint8 bDCO;
|
177
|
struct
|
178
|
{
|
179
|
#if defined(BITORDER)
|
180
|
uint8 SE:1;
|
181
|
uint8 QU:5;
|
182
|
uint8 DCS:2;
|
183
|
#else
|
184
|
uint8 DCS:2;
|
185
|
uint8 QU:5;
|
186
|
uint8 SE:1;
|
187
|
#endif
|
188
|
}DCO;
|
189
|
}YkInfo;
|
190
|
}YKDCO;//ң??????DCO
|
191
|
|
192
|
|
193
|
typedef struct _databuf
|
194
|
{
|
195
|
uint16 headP;
|
196
|
uint16 trailP;
|
197
|
uint8 databuf[APP_DATALEN];
|
198
|
}DATABUF;
|
199
|
|
200
|
class CSE104S : public CProtocol
|
201
|
{
|
202
|
protected:
|
203
|
sint32 GetNowSecond();
|
204
|
void AppToLink();
|
205
|
void App_RxFixFrame(uint8 *buf,sint32 buflen);
|
206
|
sint32 App_RxVarFrame(uint8 *buf,sint32 buflen);
|
207
|
sint32 App_SendAppUFormat(sint32 type);
|
208
|
sint32 App_SendAppSFormat();
|
209
|
|
210
|
sint32 App_Ack_SyncTime(CP56Time2a * ptime);
|
211
|
sint32 App_Ack_Yk(sint32 ykno,uint8 cause,uint8 dco);
|
212
|
sint32 App_Ack_Rst(uint8 QRP);
|
213
|
sint32 App_Ack_Kwh( );
|
214
|
sint32 App_AllData_Conf( uint8 cause,uint8 QOI=COT_CALLALLDATA);
|
215
|
sint32 App_AllKwh_Conf( uint8 cause,uint8 QCC=QCC_CALLALLKWH);
|
216
|
sint32 App_Ack_AllYx( );
|
217
|
sint32 App_Ack_AllYc();
|
218
|
sint32 App_Ack_ChangeYx();
|
219
|
sint32 App_Ack_ChangeYc();
|
220
|
sint32 App_Ack_Soe();
|
221
|
|
222
|
BOOL ProcZfMail();
|
223
|
void InitStation();
|
224
|
|
225
|
//<xyanglee>
|
226
|
sint32 Proc_AllData();
|
227
|
sint32 Proc_AllKwh();
|
228
|
sint32 Proc_SyncTime();
|
229
|
sint32 Proc_RstCmd();
|
230
|
sint32 Proc_YkCmd();
|
231
|
|
232
|
sint32 App_ReplyData();
|
233
|
|
234
|
sint32 ProcYkResponse(S_DO_CTL& cmdinfo);
|
235
|
|
236
|
public:
|
237
|
virtual sint32 TxProc(); // һ?½ӿ?
|
238
|
virtual sint32 RxProc();
|
239
|
virtual sint32 GetZfFlag( )
|
240
|
{
|
241
|
return 1;
|
242
|
};
|
243
|
virtual void Init( S_PROTOCOLCFG * pcfg );
|
244
|
virtual void SetExtendedPara(uint16 no, sint32 val);
|
245
|
private:
|
246
|
sint32 m_staNum;
|
247
|
sint32 m_rtuQX;
|
248
|
sint32 m_zone[16+1];
|
249
|
sint32 AppLayerStat;
|
250
|
|
251
|
sint32 SendSeqNo;
|
252
|
sint32 RecvSeqNo;
|
253
|
sint32 ConSeqNo;
|
254
|
|
255
|
sint32 LastRxTime,LastTxTime;
|
256
|
|
257
|
BYTE m_flagCallReply; //վ?ٻ????ۼ?????Ӧ??־??λ??????
|
258
|
//res,res,finish,kwh | res,finish,ai,di
|
259
|
sint8 m_groupNo; //???//acc3,acc2,acc1, data5 | data4,data3,data2,data1
|
260
|
|
261
|
uint8 SendACKFlag;
|
262
|
sint16 SendFrameNo;
|
263
|
sint16 SendKwhFrameNo;
|
264
|
|
265
|
DATABUF recvdata;
|
266
|
DATABUF senddata;
|
267
|
sint32 LostNum;
|
268
|
|
269
|
private:
|
270
|
uint8 Timeout2;
|
271
|
uint8 Timeout3;
|
272
|
uint8 W_IFrame; //???ȷ??APDU???????Ŀ
|
273
|
uint8 K_IFrame; //I??ʽAPDU???????ĿK
|
274
|
};
|
275
|
|
276
|
#endif
|
277
|
|
278
|
|