Project

General

Profile

Bug #1891 » Gena_notify_s5.cpp

yufeng wu, 12/09/2021 02:46 PM

 
1
// Gena_Notify.cpp: implementation of the Gena_Notify class.
2
//
3
//////////////////////////////////////////////////////////////////////
4

    
5
//#include "stdafx.h"
6
#include "Gena_Notify_s.h"
7

    
8
#ifdef _DEBUG
9
#undef THIS_FILE
10
static char THIS_FILE[]=__FILE__;
11
#define new DEBUG_NEW
12
#endif
13

    
14
#define MaxPacket	50
15
//////////////////////////////////////////////////////////////////////
16
// Construction/Destruction
17
//////////////////////////////////////////////////////////////////////
18

    
19
Gena_Notify::~Gena_Notify()
20
{
21

    
22
}
23

    
24
void   Gena_Notify::Init( S_PROTOCOLCFG * pcfg )
25
{
26
	PRawCtrl	=	pcfg->PRawCtrl;
27
	pRxBuf		=	pcfg->pRxBuf;
28
	pTxBuf		=	pcfg->pTxBuf;
29
	pCmdMem		=	pcfg->pCmdMem;
30
	pRtu		=	pcfg->pRtu;
31
	pLink		=	pcfg->pLink;
32
	pTable		=	pcfg->pTable;
33
	pZfDataCtrl	=	pcfg->pZfDataCtrl;
34
//	pHis		=	pcfg->pHis;
35
	pVst		=	pcfg->pVst;
36
	pPara		=   pcfg->pPara;
37

    
38
	m_sendFireSubResqFlag = 0;
39
	m_sendVentSubResqFlag = 0;
40
	m_sendPowerSubResqFlag = 0;
41

    
42
	m_responseFlag = 0;
43
	m_rollingFlag = 0;
44

    
45
	m_ventStepFlag=1;
46
	m_StepFlag = 1;
47

    
48
//	m_lastSubTime = GetNowSecond();
49
	m_LastSendTime = GetNowSecond();
50
//WYF 20181228
51
	char filename[512];
52
	CReadConf readconf;
53
	char *pWorkPath;	
54
	pWorkPath=getenv("FEPROOT");
55
	if(pWorkPath!=NULL){
56
#if defined(__unix)
57
    sprintf(filename,"%s%s",pWorkPath,"/cfg/AtsDef.ini");
58
#else
59
    sprintf(filename,"%s%s",pWorkPath,"\\cfg\\AtsDef.ini");
60
#endif
61
	}
62
	StaNum=0;
63
	StaNum=readconf.ReadLong("HEADCODE","count",filename,"1");
64
	if(40<StaNum)StaNum=40;
65
	if(0<StaNum)StaNum-=1;
66
	readconf.ReadString("ATSSUBObj","EMCS",bEMCS,filename,"YES");
67
	readconf.ReadString("ATSSUBObj","PSCDAA",bPSCADA,filename,"YES");
68
	readconf.ReadString("ATSSUBObj","FAS",bFAS,filename,"NO");
69

    
70
	m_RxTimeout=pLink->GetRxTimeouts();//WYF 20190118 ȫ????ɨ??????
71
	if(m_RxTimeout<10)m_RxTimeout=30;
72
	m_CallAlldata=0;
73
}
74

    
75

    
76
sint32 Gena_Notify::TxProc()
77
{
78
	E_RAW_ComStat commstatus = pLink->GetCommStatus();
79
	
80
	if( commstatus !=CMST_TX_CNT &&
81
		commstatus !=CMST_NORMAL)
82
		return 0;
83
/*
84
	if(m_com_status == DEF_MSG_COMMDOWN)
85
	{
86
	
87
	
88
	}
89
*/
90
	//??ⶩ??״??
91

    
92
	//??ʼ?????Ƿ?Ҫһ?????͹?ȥ??????һ?????͵Ļ?????ʼ?ı??Ļ?ûȫ?????꣬???¶??ľ͹????ˡ?
93
	uint8 value = 0;
94
	//float fvalue;
95
	int nowtime = GetNowSecond();
96

    
97
//	if ((nowtime-m_LastSendTime) < 1)
98
//		return 1;
99
		//WYF 20190118
100

    
101
	PRawCtrl->GetAYx(m_rtuNO,3,&value);
102

    
103
	if ((2==value) && ((nowtime-m_LastSendTime) > m_RxTimeout))//WYF 20190118update???ճ?ʱʱ????Ϊ????ȫ???ݷ???ʱ??
104
		m_CallAlldata=1;
105
	
106
	if(value==1 && m_sendVentSubResqFlag==0 && m_StepFlag==1) //һ???ԶԷ?ֻ?ܽ???50?????ݣ????????132?????????η??͡?
107
	{
108
//		if ((nowtime-m_LastSendTime) < 1)
109
//			return 1;		
110
//if(strncmp(bEMCS,"YES",3)==0){	//WYF 20190104	
111
		PrintLog(LOG_INFORMATION,"֪ͨ?????ʼ????");
112
		
113

    
114
		if(m_ventStepFlag==1)
115
		{
116
			//PrintLog(LOG_INFORMATION,"?????ʼ????1-45");	
117
			getVentStatus();
118
			NotifyVent1Birth();
119
			m_ventStepFlag=2;
120
			return 1;
121
		}else if(m_ventStepFlag==2)
122
		{	//PrintLog(LOG_INFORMATION,"?????ʼ????46-90");		
123
			NotifyVent2Birth();
124
			m_ventStepFlag=3;
125
			return 1;
126
		}
127
		else
128
		{
129
			//PrintLog(LOG_INFORMATION,"?????ʼ????91-132");
130
			NotifyVent3Birth();
131
			m_sendVentSubResqFlag =1 ;
132
			m_ventStepFlag=1;
133
			m_StepFlag=2;
134
			return 1;
135
		}		
136
	}
137
	else if(value ==2 && m_StepFlag==1)
138
	{
139
		//PrintLog(LOG_INFORMATION,"֪ͨ??????±???");	
140
		if(m_ventStepFlag==1)
141
		{
142
			//PrintLog(LOG_INFORMATION,"??????±???1-45");
143
			getVentStatus();
144
			NotifyVent1Update();
145
			m_ventStepFlag=2;
146
			return 1;
147
		}
148
		else if(m_ventStepFlag==2)
149
		{//	PrintLog(LOG_INFORMATION,"??????±???46-90");		
150
			NotifyVent2Update();
151
			m_ventStepFlag=3;
152
			return 1;
153
		}
154
		else
155
		{
156
		//	PrintLog(LOG_INFORMATION,"??????±???91-132");
157
			NotifyVent3Update();
158
			m_sendVentSubResqFlag =1 ;
159
			m_ventStepFlag=1;
160
			m_StepFlag=2;
161
			return 1;
162
		}	
163
	}
164
//}//WYF 20190104
165
//if(strncmp(bPSCADA,"YES",3)==0){//WYF 20190104
166
//	if(strncmp(bEMCS,"YES",3)!=0)m_StepFlag=2;//WYF 20190104
167
	value = 0;
168
	PRawCtrl->GetAYx(m_rtuNO,5,&value);
169
	//m_rollingFlag = POWERSECTIONSTATUS_START;
170

    
171
	if(value == 1 && m_sendPowerSubResqFlag == 0&& m_StepFlag==2)
172
	{
173
		PrintLog(LOG_INFORMATION,"???????γ?ʼ????");	
174
		getPowerStatus();
175
		NotifyPowerBirth();
176
		m_sendPowerSubResqFlag = 1 ;
177
		if(strncmp(bFAS,"YES",3)==0)
178
		m_StepFlag=3;//SHL6789=1;//SHL5=3;//WYF 20190103 6789?޻???Ҫ??
179
		else{
180
//			if(strncmp(bEMCS,"YES",3)==0)
181
			m_StepFlag=1;
182
//			else
183
//			m_StepFlag=2;
184
		}
185
		return 1;
186
	}
187
	else if(value == 2&& m_StepFlag==2)
188
	{
189
		//PrintLog(LOG_INFORMATION,"???????θ??±???");	
190
		getPowerStatus();
191

    
192
		NotifyPowerUpdate();
193
		if(strncmp(bFAS,"YES",3)==0)
194
		m_StepFlag=3;//SHL6789=1;//SHL5=3;//WYF 20190103 6789?޻???Ҫ??
195
		else{
196
//			if(strncmp(bEMCS,"YES",3)==0)
197
			m_StepFlag=1;
198
			if(0<m_CallAlldata)m_CallAlldata=0;//WYF 20190118
199
//			else
200
//			m_StepFlag=2;
201
		}
202
		return 1;
203
	}
204
//}//WYF 20190104
205
if(strncmp(bFAS,"YES",3)==0){//WYF 20190104
206
	value = 0;
207
	PRawCtrl->GetAYx(m_rtuNO,1,&value);
208
	//m_rollingFlag = FIRESTATUS_START;
209

    
210
	if(value == 1 && m_sendFireSubResqFlag == 0&& m_StepFlag==3)
211
	{
212
		PrintLog(LOG_INFORMATION,"???ֳ?ʼ????");	
213
		getFireStatus();
214
		NotifyFireBirth();
215
		m_sendFireSubResqFlag = 1;
216
		m_StepFlag=1;
217
		return 1;
218
	}
219
	else if(value ==2&& m_StepFlag==3)
220
	{
221
		//PrintLog(LOG_INFORMATION,"???ָ??±???");
222
		//NotifyUpdate(SUB_FIRE);
223
		getFireStatus();
224
		NotifyFireUpdate();	
225
		m_StepFlag=1;
226
		if(0<m_CallAlldata)m_CallAlldata=0;//WYF 20190118
227
		return 1;
228
	}
229
}//WYF 20190104
230
//else//WYF 20190104
231
//	m_StepFlag=1;//WYF 20190104
232

    
233
	return 1;
234

    
235
}
236

    
237
/*
238
typedef  struct S_RDB_ZFYx{
239
	uint16		zfrtuno;
240
	uint16		YxNo;
241
	sint16		sr_rtuno;
242
	sint16		sr_yxno;
243
	uint8		freverse;	//?Ƿ?ȡ??
244
	uint8		OldVal;
245
	uint8		Val;
246
	uint32		changetime;
247
	uint8		chgFlag;			//<xyanglee>200705 ?ı??־
248
}S_RDB_ZFYx;
249
*/
250
sint32 Gena_Notify::RxProc()
251
{
252
	
253
	sint32 rtuno			=	pLink->GetRtuNo();
254
	unsigned char rtuaddr		=	pRtu->GetRtuAddr(rtuno);
255

    
256
	int buflen=pRxBuf->GetReadableSize();
257

    
258
	int nowtime=GetNowSecond();
259

    
260
	E_RAW_ComStat coms = pLink->GetCommStatus();
261
//	if ( coms ==CMST_RX_CNT && (nowtime-m_lastSubTime) >= 50)
262
	if ( coms ==CMST_RX_CNT && (nowtime-m_LastSendTime) >= m_RxTimeout)//50)//WYF 20190118
263
	{		
264
		//??ʱ???ط???ֱ????????һ???ն?
265
		pRxBuf->Move(buflen);
266
		pLink->RegisterFrm(FRAME_RX_TIMEOUT);
267
		pLink->SetCommStatus(CMST_NORMAL);
268
		PrintLog(LOG_INFORMATION,"???ճ?ʱ");
269
		return 1;
270
	}
271

    
272

    
273
	if (buflen<14)		//??????
274
	{
275
		//PrintLog(LOG_INFORMATION,"?????ݷ???");
276
		return 1;
277
	}
278
	int nRet= 0;
279
	
280
	uint8  buf[1024];
281
	memset(buf,0,1024);
282

    
283
	sint32 datalen = 0;
284
	sint32 contlen = 0;
285
 	while((buflen=pRxBuf->GetReadableSize())>0)
286
    {
287
		if(buflen > 1024)
288
			buflen = 1024;
289
        datalen = pRxBuf->Read(buf,buflen,DEF_BUFF_NOMOVE);
290
	
291
		contlen = m_Soap.ParseMessage((const char*)(buf),datalen);
292

    
293
		//PrintLog(LOG_INFORMATION,">>>>>????%s",buf);
294

    
295
		if(contlen<0)	//error
296
		{
297
			pRxBuf->Move(datalen);
298
			return 0;
299
		}
300
		if(contlen == 0)
301
			return 1;
302

    
303
		DataProcess();
304

    
305
		//PrintLog(LOG_INFORMATION,"ɾ??????%d",contlen);
306
		pRxBuf->Move(contlen);
307

    
308
		pLink->RegisterFrm(FRAME_RX_SUC);
309
		pLink->SetCommStatus(CMST_NORMAL);
310

    
311
    }
312

    
313
 	return 1;
314
}
315

    
316
void Gena_Notify::DataProcess()
317
{	
318
	HTTP_RESP_TYPE resptype = m_Soap.GetRespType();
319
	if(resptype == RESPTYPE_STATUS)//??ʼ???ijɹ???Ӧ?ɹ?????Ҫ????SID?????¶??ijɹ?????????
320
	{
321
		//m_waitRespFlag = 0 ;
322
		if(m_Soap.GetStatusCode() == 200)//??ӦOK
323
		{
324
			PrintLog(LOG_INFORMATION,"???յ???Ӧ200");
325
			m_responseFlag =1;
326
		}
327
		else //??Ӧ???????
328
		{
329
			PrintLog(LOG_INFORMATION,"???յ?http 1.1 %d",m_Soap.GetStatusCode());
330
			//m_responseFlag =1;
331
			
332
		}
333
	}
334
	else
335
	{
336
		PrintLog(LOG_INFORMATION,"???յ????????");
337
	
338
	}
339

    
340
}
341

    
342
void Gena_Notify::SetExtendedPara(uint16 no, sint32 val)
343
{
344
	if(no == 1)
345
	{
346
		m_rtuNO = val; //ȡ?ö???RTU??
347
		PrintLog(LOG_INFORMATION,"ȡ?ö???RTU??:%d",m_rtuNO);
348
	}
349

    
350
}
351

    
352

    
353
void 	Gena_Notify::NotifyVentBirth()
354
{
355
	int len = 0;
356
	char *pCode = NULL;
357
	for(int i=0;i<StaNum*4;i++)//132//WYF 20181231
358
	{		
359
		m_oldVent[i] = m_curVent[i];
360

    
361
		m_Soap.SetFanStatusContent(m_curVent[i]);
362

    
363
		//ȡ??sid??
364
		uint8 sid;
365
		PRawCtrl->GetAYx(m_rtuNO,4,&sid);
366
		m_Soap.SetSrvSID(sid);
367

    
368
//		pCode = m_Soap.NotifyUpdate(len);
369
		pCode = m_Soap.NotifyBirth(len);//WYF 20190118
370

    
371
		if(len>0)
372
		{			
373
			pTxBuf->Write((uint8*)pCode,len);			
374
			//pLink->SetCommStatus(CMST_RX_CNT);
375
		}	
376
	}
377
}
378

    
379
void 	Gena_Notify::NotifyVent1Birth()
380
{
381
	int len = 0;
382
	char *pCode = NULL;
383
	for(int i=0;i<MaxPacket;i++)//45//WYF 20181231
384
	{
385
		PrintLog(LOG_INFORMATION,"%d?ŷ????ʼ״̬:״̬%d,????%d",i+1,m_curVent[i].status,m_curVent[i].direction);
386
		m_oldVent[i] = m_curVent[i];
387

    
388
		m_Soap.SetFanStatusContent(m_curVent[i]);
389

    
390
		//ȡ??sid??
391
		uint8 sid;
392
		PRawCtrl->GetAYx(m_rtuNO,4,&sid);
393
		m_Soap.SetSrvSID(sid);
394

    
395
//		pCode = m_Soap.NotifyUpdate(len);
396
		pCode = m_Soap.NotifyBirth(len);//WYF 20190118
397

    
398
		if(len>0)
399
		{			
400
			pTxBuf->Write((uint8*)pCode,len);			
401
			//pLink->SetCommStatus(CMST_RX_CNT);
402
			m_LastSendTime = GetNowSecond();
403
		}	
404
	}
405
}
406
void 	Gena_Notify::NotifyVent2Birth()
407
{
408
	int len = 0;
409
	char *pCode = NULL;
410
	for(int i=MaxPacket;i<MaxPacket*2;i++)//45-90//WYF 20181231
411
	{
412
		PrintLog(LOG_INFORMATION,"%d?ŷ????ʼ???״̬:״̬%d,????%d",i+1,m_curVent[i].status,m_curVent[i].direction);
413
		m_oldVent[i] = m_curVent[i];
414
	
415
		m_Soap.SetFanStatusContent(m_curVent[i]);
416

    
417
		//ȡ??sid??
418
		uint8 sid;
419
		PRawCtrl->GetAYx(m_rtuNO,4,&sid);
420
		m_Soap.SetSrvSID(sid);
421

    
422
//		pCode = m_Soap.NotifyUpdate(len);
423
		pCode = m_Soap.NotifyBirth(len);//WYF 20190118
424

    
425
		if(len>0)
426
		{			
427
			pTxBuf->Write((uint8*)pCode,len);			
428
			//pLink->SetCommStatus(CMST_RX_CNT);
429
			m_LastSendTime = GetNowSecond();
430
		}	
431
	}
432
}
433
void 	Gena_Notify::NotifyVent3Birth()
434
{
435
	int len = 0;
436
	char *pCode = NULL;
437
	for(int i=MaxPacket*2;i<StaNum*4;i++)//90-132//WYF 20181231
438
	{
439
		PrintLog(LOG_INFORMATION,"%d?ŷ????ʼ???״̬:״̬%d,????%d",i+1,m_curVent[i].status,m_curVent[i].direction);
440
		m_oldVent[i] = m_curVent[i];
441

    
442
		m_Soap.SetFanStatusContent(m_curVent[i]);
443

    
444
		//ȡ??sid??
445
		uint8 sid;
446
		PRawCtrl->GetAYx(m_rtuNO,4,&sid);
447
		m_Soap.SetSrvSID(sid);
448

    
449
//		pCode = m_Soap.NotifyUpdate(len);
450
		pCode = m_Soap.NotifyBirth(len);//WYF 20190118
451

    
452
		if(len>0)
453
		{			
454
			pTxBuf->Write((uint8*)pCode,len);			
455
			//pLink->SetCommStatus(CMST_RX_CNT);
456
			m_LastSendTime = GetNowSecond();
457
		}	
458
	}
459
}
460

    
461
void 	Gena_Notify::NotifyFireBirth()
462
{
463
	int len = 0;
464
	char *pCode = NULL;
465
	ST_FIRE_ALARM st_fire;
466
	for(int i=0;i<StaNum;i++)//33
467
	{
468
		m_oldFire[i] = m_curFire[i];
469

    
470
		st_fire.objid = i+1;
471
		if((12-1)<=i && i<=(19-1))st_fire.objid += 90;//WYF 20190630 5????12-19վ????Ӧ102-109վid
472
		st_fire.stat_flag=1;
473
		st_fire.status=m_curFire[i];
474

    
475
		PrintLog(LOG_INFORMATION,"%d?Ż𾯳?ʼ״̬:״̬%d",i+1,m_curFire[i]);
476
		m_Soap.SetFireAlarmContent(st_fire);
477

    
478
		//ȡ??sid??
479
		uint8 sid;
480
		PRawCtrl->GetAYx(m_rtuNO,2,&sid);
481
		m_Soap.SetSrvSID(sid);
482

    
483
//		pCode = m_Soap.NotifyUpdate(len);
484
		pCode = m_Soap.NotifyBirth(len);//WYF 20190118
485

    
486
		if(len>0)
487
		{			
488
			pTxBuf->Write((uint8*)pCode,len);			
489
			//pLink->SetCommStatus(CMST_RX_CNT);
490
			m_LastSendTime = GetNowSecond();
491
		}	
492
	}
493
}
494

    
495
void 	Gena_Notify::NotifyPowerBirth()
496
{
497
	int len = 0;
498
	char *pCode = NULL;
499
	ST_POWERSECTION st_power;
500
	for(int i=0;i<StaNum*2;i++)//28 WYF 20190103
501
	{
502
		PrintLog(LOG_INFORMATION,"%d?ŵ??????γ?ʼ״̬:״̬%d",i+1,m_curPower[i]);
503
		m_oldPower[i] = m_curPower[i];
504

    
505
		st_power.objid = i+1;
506
		st_power.stat_flag=1;
507
		st_power.status=m_curFire[i];
508

    
509
		m_Soap.SetPowerSectionContent(st_power);
510

    
511
		//ȡ??sid??
512
		uint8 sid;
513
		PRawCtrl->GetAYx(m_rtuNO,6,&sid);
514
		m_Soap.SetSrvSID(sid);
515

    
516
//		pCode = m_Soap.NotifyUpdate(len);
517
		pCode = m_Soap.NotifyBirth(len);//WYF 20190118
518

    
519
		if(len>0)
520
		{			
521
			pTxBuf->Write((uint8*)pCode,len);			
522
			//pLink->SetCommStatus(CMST_RX_CNT);
523
			m_LastSendTime = GetNowSecond();
524
		}	
525
	}
526
}
527

    
528
void	Gena_Notify::NotifyVentUpdate()
529
{
530
	int len = 0;
531
	char *pCode = NULL;
532
	for(int i=0;i<StaNum*4;i++)//132//WYF 20181231
533
	{
534
		if(1>m_CallAlldata){//??30-60sʱ??ȫ???ݷ???
535
		if(m_oldVent[i].status == m_curVent[i].status && m_oldVent[i].direction == m_curVent[i].direction)
536
			continue;
537
		}
538
		m_oldVent[i] = m_curVent[i];
539

    
540
		m_Soap.SetFanStatusContent(m_curVent[i]);
541

    
542
		//ȡ??sid??
543
		uint8 sid;
544
		PRawCtrl->GetAYx(m_rtuNO,4,&sid);
545
		m_Soap.SetSrvSID(sid);
546

    
547
		pCode = m_Soap.NotifyUpdate(len);
548

    
549
		if(len>0)
550
		{			
551
			pTxBuf->Write((uint8*)pCode,len);			
552
			//pLink->SetCommStatus(CMST_RX_CNT);
553
			m_LastSendTime = GetNowSecond();
554
		}	
555
	}
556
}
557

    
558
void	Gena_Notify::NotifyVent1Update()
559
{
560
	int len = 0;
561
	char *pCode = NULL;
562
	for(int i=0;i<MaxPacket;i++)//45//WYF 20181231
563
	{
564
		if(1>m_CallAlldata){//??30-60sʱ??ȫ???ݷ???
565
		if(m_oldVent[i].status == m_curVent[i].status && m_oldVent[i].direction == m_curVent[i].direction)
566
			continue;
567
		}
568
		PrintLog(LOG_INFORMATION,"%d?ŷ?????·??״̬:״̬%d,????%d",i+1,m_curVent[i].status,m_curVent[i].direction);
569
		m_oldVent[i] = m_curVent[i];
570

    
571
		m_Soap.SetFanStatusContent(m_curVent[i]);
572

    
573
		//ȡ??sid??
574
		uint8 sid;
575
		PRawCtrl->GetAYx(m_rtuNO,4,&sid);
576
		m_Soap.SetSrvSID(sid);
577

    
578
		pCode = m_Soap.NotifyUpdate(len);
579

    
580
		if(len>0)
581
		{			
582
			pTxBuf->Write((uint8*)pCode,len);			
583
			//pLink->SetCommStatus(CMST_RX_CNT);
584
			m_LastSendTime = GetNowSecond();
585
		}	
586
	}
587
}
588

    
589
void	Gena_Notify::NotifyVent2Update()
590
{
591
	int len = 0;
592
	char *pCode = NULL;
593
	for(int i=MaxPacket;i<MaxPacket*2;i++)//45-90//WYF 20181231
594
	{
595
		if(1>m_CallAlldata){//??30-60sʱ??ȫ???ݷ???
596
		if(m_oldVent[i].status == m_curVent[i].status && m_oldVent[i].direction == m_curVent[i].direction)
597
			continue;
598
		}
599
		PrintLog(LOG_INFORMATION,"%d?ŷ?????·??״̬:״̬%d,????%d",i+1,m_curVent[i].status,m_curVent[i].direction);
600
		m_oldVent[i] = m_curVent[i];
601

    
602
		m_Soap.SetFanStatusContent(m_curVent[i]);
603

    
604
		//ȡ??sid??
605
		uint8 sid;
606
		PRawCtrl->GetAYx(m_rtuNO,4,&sid);
607
		m_Soap.SetSrvSID(sid);
608

    
609
		pCode = m_Soap.NotifyUpdate(len);
610

    
611
		if(len>0)
612
		{			
613
			pTxBuf->Write((uint8*)pCode,len);			
614
			//pLink->SetCommStatus(CMST_RX_CNT);
615
			m_LastSendTime = GetNowSecond();
616
		}	
617
	}
618
}
619

    
620
void	Gena_Notify::NotifyVent3Update()
621
{
622
	int len = 0;
623
	char *pCode = NULL;
624
	for(int i=MaxPacket*2;i<StaNum*4;i++)//90-132//WYF 20181231
625
	{
626
		if(1>m_CallAlldata){//??30-60sʱ??ȫ???ݷ???
627
		if(m_oldVent[i].status == m_curVent[i].status && m_oldVent[i].direction == m_curVent[i].direction)
628
			continue;
629
		}
630
		PrintLog(LOG_INFORMATION,"%d?ŷ?????·??״̬:״̬%d,????%d",i+1,m_curVent[i].status,m_curVent[i].direction);
631

    
632
		m_oldVent[i] = m_curVent[i];
633

    
634
		m_Soap.SetFanStatusContent(m_curVent[i]);
635

    
636
		//ȡ??sid??
637
		uint8 sid;
638
		PRawCtrl->GetAYx(m_rtuNO,4,&sid);
639
		m_Soap.SetSrvSID(sid);
640

    
641
		pCode = m_Soap.NotifyUpdate(len);
642

    
643
		if(len>0)
644
		{			
645
			pTxBuf->Write((uint8*)pCode,len);			
646
			//pLink->SetCommStatus(CMST_RX_CNT);
647
			m_LastSendTime = GetNowSecond();
648
		}	
649
	}
650
}
651

    
652
void	Gena_Notify::NotifyFireUpdate()
653
{	
654
	int len = 0;
655
	char *pCode = NULL;
656
	ST_FIRE_ALARM st_fire;
657
	for(int i=0;i<StaNum;i++)//33
658
	{
659
		if(1>m_CallAlldata){//??30-60sʱ??ȫ???ݷ???
660
		if(m_oldFire[i] == m_curFire[i])
661
			continue;
662
		}
663
	PrintLog(LOG_INFORMATION,"%d?Ż𾯸???״̬:״̬%d",i+1,m_curFire[i]);
664

    
665
		m_oldFire[i] = m_curFire[i];
666

    
667
		st_fire.objid = i+1;
668
		if((12-1)<=i && i<=(19-1))st_fire.objid += 90;//WYF 20190630 5????12-19վ????Ӧ102-109վid
669
		st_fire.stat_flag=1;
670
		st_fire.status=m_curFire[i];
671

    
672
		m_Soap.SetFireAlarmContent(st_fire);
673

    
674
		//ȡ??sid??
675
		uint8 sid;
676
		PRawCtrl->GetAYx(m_rtuNO,2,&sid);
677
		m_Soap.SetSrvSID(sid);
678

    
679
		pCode = m_Soap.NotifyUpdate(len);
680

    
681
		if(len>0)
682
		{			
683
			pTxBuf->Write((uint8*)pCode,len);			
684
			//pLink->SetCommStatus(CMST_RX_CNT);
685
			m_LastSendTime = GetNowSecond();
686
		}	
687
	}
688
}
689

    
690
void	Gena_Notify::NotifyPowerUpdate()
691
{
692
	int len = 0;
693
	char *pCode = NULL;
694
	ST_POWERSECTION st_power;
695
	for(int i=0;i<StaNum*2;i++)//28 WYF 20190103
696
	{
697
		if(1>m_CallAlldata){//??30-60sʱ??ȫ???ݷ???
698
		if(m_oldPower[i] == m_curPower[i])
699
			continue;
700
		}
701
		PrintLog(LOG_INFORMATION,"%d?ŵ??????θ???״̬:״̬%d",i+1,m_curPower[i]);
702

    
703
		m_oldPower[i] = m_curPower[i];
704

    
705
		st_power.objid = i+1;
706
		st_power.stat_flag=1;
707
		st_power.status=m_curPower[i];
708

    
709
		m_Soap.SetPowerSectionContent(st_power);
710

    
711
		//ȡ??sid??
712
		uint8 sid;
713
		PRawCtrl->GetAYx(m_rtuNO,6,&sid);
714
		m_Soap.SetSrvSID(sid);
715

    
716
		pCode = m_Soap.NotifyUpdate(len);
717

    
718
		if(len>0)
719
		{			
720
			pTxBuf->Write((uint8*)pCode,len);			
721
			//pLink->SetCommStatus(CMST_RX_CNT);
722
			m_LastSendTime = GetNowSecond();
723
		}	
724
	}
725
}
726
void	Gena_Notify::NotifyDeath(SUB_ENUM subObj)
727
{
728
	//??ô?ж??Ƿ??ͽ???????
729
	//??ת??????ȡ?????ݣ?Ȼ??ת????ATS
730

    
731
}
732
void    Gena_Notify::getFireStatus()
733
{
734
	CEasyList *yxlist=pZfDataCtrl->GetYxStructList();
735

    
736
	sint32 numYx = yxlist->GetListLen();
737
	uint8 yxVal=0,yxVal1=0;
738
	if(numYx<=0)
739
	{
740
		return ;	
741
	}
742
	
743
	S_RDB_ZFYx *yxinfo,*yxinfo1;
744
	int i=0;
745

    
746
	//1---33ң?ź?Ϊ33????վ??״̬?? 34 ---66Ϊ????????״̬?? 67?Ժ?Ϊ?????з??״̬??...?Դ?????..
747

    
748
	for(i=0;i<StaNum;i++)//
749
	{
750
		m_curFire[i] = 0;
751

    
752
		yxinfo=(S_RDB_ZFYx *)((*yxlist)[FIRESTATUS_START+i*2]);
753
PRawCtrl->GetAYx(yxinfo->sr_rtuno,yxinfo->sr_yxno,&yxVal);//WYF 20190103
754
		yxinfo1=(S_RDB_ZFYx *)((*yxlist)[FIRESTATUS_START+i*2+1]);
755
PRawCtrl->GetAYx(yxinfo1->sr_rtuno,yxinfo1->sr_yxno,&yxVal1);//WYF 20190103
756
			
757
//		if(yxinfo->Val>0 && yxinfo1->Val==1)
758
		if(yxVal>0 && yxVal1==1)
759
		{
760
			m_curFire[i] = 1;				
761
		}/*
762
		else if(yxinfo->Val==0 && yxinfo1->Val==1)
763
		{
764
			m_curFire[i] = 0;				
765
		}
766
		else{
767
			m_curFire[i] = 2;
768
		
769
		}*/
770
		
771
	}	
772
	return ;
773

    
774
}
775
void    Gena_Notify::getVentStatus()
776
{
777
	CEasyList *yxlist=pZfDataCtrl->GetYxStructList();
778

    
779
	sint32 numYx = yxlist->GetListLen();
780

    
781
	if(numYx<=0)
782
	{
783
		return ;	
784
	}	
785

    
786
	uint8 yxVal=0,yxVal1=0,yxVal2=0;
787
	S_RDB_ZFYx *yxinfo,*yxinfo1;
788
	int i=0;
789
	for(i=0;i<StaNum*4;i++)//132//WYF 20181231
790
	{
791
		
792
		m_curVent[i].direct_flag =0;
793
		m_curVent[i].direction=0;
794
		m_curVent[i].stat_flag=0;
795
		m_curVent[i].status=0;
796
		
797
		m_curVent[i].objid = i+1;
798
		yxinfo=(S_RDB_ZFYx *)((*yxlist)[VENTSTATUS_START+i*4]);//???ϵ?//0Ϊ?ǹ??ϣ?1Ϊ????
799

    
800
		PRawCtrl->GetAYx(yxinfo->sr_rtuno,yxinfo->sr_yxno,&yxVal);//WYF 20190103
801
		if(/*yxinfo->Val*/yxVal == 1)		
802
		{		
803
			m_curVent[i].stat_flag = 1;
804
			m_curVent[i].status = 2;//??SetFanStatusContent??????status=0Ϊֹͣ 1Ϊ???? 2Ϊ???ϣ????õ??Ϊ2??"Fault"
805
			//PrintLog(LOG_INFORMATION,"?????????ʼ????,?????:%d,???????",fanStatus.objid);				
806
		}
807
		else
808
		{
809
			yxinfo=(S_RDB_ZFYx *)((*yxlist)[VENTSTATUS_START+i*4+1]);//ֹͣ??
810
			
811
			m_curVent[i].stat_flag = 1;	
812
			PRawCtrl->GetAYx(yxinfo->sr_rtuno,yxinfo->sr_yxno,&yxVal);//WYF 20190103
813
			if(/*yxinfo->Val*/yxVal == 0)//???Ϊ??״̬?????жϷ??????
814
			{			
815
				yxinfo=(S_RDB_ZFYx *)((*yxlist)[VENTSTATUS_START+i*4+2]);//??????????е?
816
PRawCtrl->GetAYx(yxinfo->sr_rtuno,yxinfo->sr_yxno,&yxVal);//WYF 20190103
817
				yxinfo1=(S_RDB_ZFYx *)((*yxlist)[VENTSTATUS_START+i*4+3]);//??????????е?
818
PRawCtrl->GetAYx(yxinfo1->sr_rtuno,yxinfo1->sr_yxno,&yxVal1);//WYF 20190103
819
//				if(yxinfo->Val == yxinfo1->Val)
820
				if(yxVal == yxVal1)
821
				{
822
					m_curVent[i].status = 2;//	???????
823
					
824
				}
825
				else
826
				{
827
					m_curVent[i].status = 1;//	???????					
828
					m_curVent[i].direct_flag = 1;
829
					if(/*yxinfo->Val*/yxVal == 1)
830
					{								
831
						m_curVent[i].direction = 1;//????Ϊ1	
832
					}
833
					else
834
					{
835
						m_curVent[i].direction = 0;	
836
					}
837
					//PrintLog(LOG_INFORMATION,"?????????ʼ????,?????:%d,״̬%d",m_curVent[i].objid,m_curVent[i].direction);
838
				}
839
					
840
			}
841
			else
842
			{					
843
				m_curVent[i].status = 0;//
844
				//PrintLog(LOG_INFORMATION,"?????????ʼ????,?????:%d,??",m_curVent[i].objid);
845
				
846
			}
847
				
848
		}
849

    
850
	
851
	}
852
}
853

    
854
void	Gena_Notify::getPowerStatus()
855
{
856
	int power[STANUMS*4];//WYF 20190103
857
	int i=0;
858
	uint8 yxVal=0,yxVal1=0,yxVal2=0,yxVal3=0,yxVal4=0,yxVal5=0,yxVal6=0;
859
	float32 ycVal=0,ycVal1=0;
860
	CEasyList *yxlist=pZfDataCtrl->GetYxStructList();
861
	sint32 numYx = yxlist->GetListLen();
862

    
863
	CEasyList *yclist=pZfDataCtrl->GetYcStructList();
864
	sint32 numYc = yclist->GetListLen();
865

    
866
	if(numYx<=0||numYc<=0)
867
	{
868
		return ;	
869
	}
870

    
871
	S_RDB_ZFYx *yxinfo,*yxinfo1,*yxinfo2,*yxinfo3,*yxinfo4,*yxinfo5;
872
	S_RDB_ZFYc *ycinfo,*ycinfo1;
873

    
874
	
875
	for(i=0; i<StaNum*2; i++)//28 WYF 20190103
876
	{
877
		power[i] = 0;
878
		yxinfo=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6]);
879
PRawCtrl->GetAYx(yxinfo->sr_rtuno,yxinfo->sr_yxno,&yxVal);//WYF 20190103
880
		yxinfo1=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+1]);
881
PRawCtrl->GetAYx(yxinfo1->sr_rtuno,yxinfo1->sr_yxno,&yxVal1);//WYF 20190103
882
		yxinfo2=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+2]);
883
PRawCtrl->GetAYx(yxinfo2->sr_rtuno,yxinfo2->sr_yxno,&yxVal2);//WYF 20190103
884
		yxinfo3=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+3]);
885
PRawCtrl->GetAYx(yxinfo3->sr_rtuno,yxinfo3->sr_yxno,&yxVal3);//WYF 20190103
886
		yxinfo4=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+4]);
887
PRawCtrl->GetAYx(yxinfo4->sr_rtuno,yxinfo4->sr_yxno,&yxVal4);//WYF 20190103
888
		yxinfo5=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+5]);
889
PRawCtrl->GetAYx(yxinfo5->sr_rtuno,yxinfo5->sr_yxno,&yxVal5);//WYF 20190103
890

    
891
		ycinfo=(S_RDB_ZFYc *)((*yclist)[POWERSECTIONSTATUS_AISTART+i*2]);
892
PRawCtrl->GetAYc(ycinfo->sr_rtuno,ycinfo->sr_ycno,&ycVal);//WYF 20190103
893
		ycinfo1=(S_RDB_ZFYc *)((*yclist)[POWERSECTIONSTATUS_AISTART+i*2+1]);
894
PRawCtrl->GetAYc(ycinfo1->sr_rtuno,ycinfo1->sr_ycno,&ycVal1);//WYF 20190103
895

    
896
//		if((ycinfo->Val>100)&&(yxinfo->Val==1)&&(yxinfo1->Val==1)||(ycinfo1->Val>100)&&(yxinfo3->Val==1)&&(yxinfo4->Val==1))
897
		if((ycVal>100)&&(yxVal==1)&&(yxVal1==1)||(ycVal1>100)&&(yxVal3==1)&&(yxVal4==1))
898
		{
899
			power[i] = 1;
900
		}
901
	}
902

    
903
	for(i=0;i<StaNum*2;i++)//28 WYF 20190103
904
	{
905
		m_curPower[i] = 0;
906
		if(power[i]==0)//û?????Ҫ?б????????εĵ???״̬
907
		{
908
			if(i==0||i==1)//????????????????Σ??б?????????????????
909
			{
910
				yxinfo5=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+5]);
911
PRawCtrl->GetAYx(yxinfo5->sr_rtuno,yxinfo5->sr_yxno,&yxVal5);//WYF 20190103
912
//				if(yxinfo5->Val==1)
913
				if(yxVal5==1)
914
				{
915
					m_curPower[i] = (power[i]==1)||(power[i+2]==1);
916

    
917
					yxinfo=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+(i+2)*6+5]);
918
PRawCtrl->GetAYx(yxinfo->sr_rtuno,yxinfo->sr_yxno,&yxVal);//WYF 20190103
919

    
920
//					if(yxinfo->Val==1)
921
					if(yxVal==1)
922
					{
923
						m_curPower[i] = (power[i]==1)||(power[i+2]==1)||(power[i+4]==1);
924
					
925
					}
926
				}
927
			
928
			}
929
			if(i==2||i==3)//????????????????Σ??б?????????????????
930
			{
931
				yxinfo3=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+2]);
932
PRawCtrl->GetAYx(yxinfo3->sr_rtuno,yxinfo3->sr_yxno,&yxVal3);//WYF 20190103
933
//				if(yxinfo3->Val==1)//????һ????
934
				if(yxVal3==1)//????һ????
935
				{
936
					m_curPower[i] = (power[i]==1)||(power[i-2]==1);
937
				
938
				}
939
				if(m_curPower[i]!=1)//???????û?磬???б???????????
940
				{
941
					yxinfo5=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+5]);
942
PRawCtrl->GetAYx(yxinfo5->sr_rtuno,yxinfo5->sr_yxno,&yxVal5);//WYF 20190103
943
//					if(yxinfo5->Val==1)
944
					if(yxVal5==1)
945
					{
946
						m_curPower[i] = (power[i]==1)||(power[i+2]==1);
947

    
948
						yxinfo=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+(i+2)*6+5]);
949
PRawCtrl->GetAYx(yxinfo->sr_rtuno,yxinfo->sr_yxno,&yxVal);//WYF 20190103
950
//						if(yxinfo->Val==1)
951
						if(yxVal==1)
952
						{
953
							m_curPower[i] = (power[i]==1)||(power[i+2]==1)||(power[i+4]==1);
954
						
955
						}
956
					}
957
				}				
958
			
959
			}
960
			else
961
			{
962
				yxinfo3=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+2]);
963
PRawCtrl->GetAYx(yxinfo3->sr_rtuno,yxinfo3->sr_yxno,&yxVal3);//WYF 20190103
964
//				if(yxinfo3->Val==1)//????????????
965
				if(yxVal3==1)//????????????
966
				{
967
					m_curPower[i] = (power[i]==1)||(power[i-2]==1);
968
					yxinfo=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+(i-2)*6+5]);
969
PRawCtrl->GetAYx(yxinfo->sr_rtuno,yxinfo->sr_yxno,&yxVal);//WYF 20190103
970
//					if(yxinfo->Val==1)
971
					if(yxVal==1)
972
					{
973
						m_curPower[i] = (power[i]==1)||(power[i-2]==1)||(power[i-4]==1);						
974
					}
975
				
976
				}
977
				if(m_curPower[i]!=1)//???????û?磬???б???????????
978
				{
979
					yxinfo5=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+i*6+5]);
980
PRawCtrl->GetAYx(yxinfo5->sr_rtuno,yxinfo5->sr_yxno,&yxVal5);//WYF 20190103
981
//					if(yxinfo5->Val==1)
982
					if(yxVal5==1)
983
					{
984
						m_curPower[i] = (power[i]==1)||(power[i+2]==1);
985

    
986
						yxinfo=(S_RDB_ZFYx *)((*yxlist)[POWERSECTIONSTATUS_START+(i+2)*6+5]);
987
PRawCtrl->GetAYx(yxinfo->sr_rtuno,yxinfo->sr_yxno,&yxVal);//WYF 20190103
988
//						if(yxinfo->Val==1)
989
						if(yxVal==1)
990
						{
991
							m_curPower[i] = (power[i]==1)||(power[i+2]==1)||(power[i+4]==1);
992
						
993
						}
994
					}
995
				}			
996
			
997
			}		
998
		}
999
		else
1000
		{
1001
			m_curPower[i] = 1;
1002
		}	
1003
	}
1004

    
1005
}
1006

    
1007

    
1008
int Gena_Notify::GetNowSecond()
1009
{
1010
	CSeTime     SE_T;
1011
	TCriterionTime tmptime;
1012
	SE_T.GetNow(&tmptime);
1013
	return (int)tmptime;
1014
}
1015

    
1016
sint32  Gena_Notify::MsgProc(sint32 msg)
1017
{
1018
	if(msg == DEF_MSG_COMMDOWN)
1019
	{
1020
		m_com_status = DEF_MSG_COMMDOWN;	
1021
	}
1022
	return 1;
1023
}
1024

    
1025
//??Լ???󴴽?????
1026
#ifdef __unix
1027
extern "C" CProtocol* CreateProtocol(char *defpara)
1028
#else
1029
extern "C" __declspec(dllexport)  CProtocol* CreateProtocol(char *defpara)
1030
#endif
1031
{
1032
	CProtocol *pEpv = new Gena_Notify;
1033
	return pEpv;
1034
} 
(1-1/2)