Project

General

Profile

Feature #406 » GWnd.cpp

yufeng wu, 01/04/2020 10:48 AM

 
1
// GWnd.cpp : implementation file
2
//
3
#include "stdafx.h"
4
#include "ehmi.h"
5
#include "GWnd.h"
6

    
7
#include "MainFrm.h"
8
#include "ehmiView.h"
9

    
10
#include "ehmisubdlg.h"
11
#include "NaviDialog.h"
12
#include "DlgLayerControl.h"
13
#include "PopWndDlg.h"
14
#include "DlgManSetYx.h"
15
#include "XInfoTip.h"
16

    
17
#ifdef _DEBUG
18
#define new DEBUG_NEW
19
#undef THIS_FILE
20
static char THIS_FILE[] = __FILE__;
21
#endif
22

    
23
extern CMainFrame * g_ehmiMainFrame;
24

    
25
static const int ZooehminOFF = 30;	//?϶??Ŵ??ݲ??С
26

    
27
static CMapPtrToWord s_mapWnd;
28

    
29
const int MaxPopupMenuItems = 1024;	// ?????˵????????˵?????
30

    
31
bool g_bYKDlgShow; //???????Կ??Ƿ??Ѿ???ʾ.
32

    
33
bool g_bSetTipHide = false;//????Tip?Ƿ???ʾ
34

    
35
/////////////////////////////////////////////////////////////////////////////
36
// CGWnd
37

    
38
BEGIN_MESSAGE_MAP(CGWnd, CWnd)
39
	//{{AFX_MSG_MAP(CGWnd)
40
	ON_WM_RBUTTONDOWN()
41
	ON_WM_RBUTTONUP()
42
	ON_WM_CREATE()
43
	ON_WM_LBUTTONDOWN()
44
	ON_WM_LBUTTONUP()
45
	ON_WM_TIMER()
46
	ON_WM_PAINT()
47
	ON_WM_KEYDOWN()
48
	ON_WM_MOUSEMOVE()
49
	ON_WM_SETCURSOR()
50
	ON_WM_LBUTTONDBLCLK()
51
	ON_WM_ERASEBKGND()
52
	ON_WM_SIZE()
53
	ON_WM_DESTROY()
54
	ON_WM_INITMENUPOPUP()
55
	//}}AFX_MSG_MAP
56
	// Standard printing commands
57

    
58
	ON_COMMAND_RANGE(ID_OBJMENU_YCCLEAR,ID_OBJMENU_MANAGEKGBH,OnCmdObjMenu)
59
	ON_UPDATE_COMMAND_UI_RANGE(ID_OBJMENU_YCCLEAR,ID_OBJMENU_MANAGEKGBH,OnUpdateObjMenu)
60

    
61
	ON_COMMAND(ID_OBJMENU_DEVREALPNT,   OnObjmenuDevrealpnt)
62
	ON_COMMAND(ID_OBJMENU_HISDATA,		OnObjmenuHisData)
63

    
64
	ON_COMMAND_RANGE(ID_GET_PROTECTVAL,ID_OBJMENU_PROTDEVPARA,OnCmdProtMenu)
65
	ON_UPDATE_COMMAND_UI_RANGE(ID_GET_PROTECTVAL,ID_OBJMENU_PROTDEVPARA,OnUpdateProtMenu)
66

    
67
	ON_COMMAND_RANGE(ID_GRAPH_UP,ID_GRAPH_EQUAL,OnTbGraphCmd)
68
	ON_UPDATE_COMMAND_UI_RANGE(ID_GRAPH_UP,ID_GRAPH_EQUAL,OnTbGraphCmdUpdate)
69

    
70
	ON_MESSAGE(NEWDATARCV_MSG, OnGetRdbData)
71
	ON_MESSAGE(DRAWOBJ_MSG, OnDrawObj)
72

    
73
	ON_COMMAND_RANGE(ID_POPUP_MENU, ID_POPUP_MENU+MaxPopupMenuItems, OnPopupMenuCmd)
74

    
75
	ON_COMMAND(ID_IMS_DIAGNOSE, OnDevDiagnose)
76
	ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
77
END_MESSAGE_MAP()
78

    
79
/////////////////////////////////////////////////////////////////////////////
80
// CGWnd construction/destruction
81

    
82
CGWnd::CGWnd(UINT nID, CWnd* pParent)
83
{
84
	m_pView = (CehmiView *)pParent;
85
	m_wndId  = nID;
86
	m_Rect = CRect(0,0,600,600);
87
	m_wndType = GWND_REPLACE;
88

    
89
	m_NaviDlg = NULL;
90
	m_LayDlg = NULL;
91

    
92
	m_bTrack = FALSE;
93
	m_prevcmd = c_none;
94
	m_cmd = c_none;
95

    
96
	m_TimeCount = 0;
97
	m_tagCount = 0;
98

    
99
	m_path[0] = 0;
100
	m_title[0]    = 0;
101

    
102
	m_rdbpara.SetPara(100,sizeof(SRDB_PARAINFO),1);
103
	m_rdbdata.SetPara(100,sizeof(ST_VISITRDB),1);
104

    
105
	SourceRealData		= DEF_DATA_FROM_REAL_RDB;
106
	OldSourceRealData	= DEF_DATA_FROM_REAL_RDB;
107

    
108
	m_shapeid = OS_UNKNOWN;
109
	m_hottype = HLT_UNKNOWN;
110

    
111
	m_pCurObj = NULL;
112
	m_runScript = FALSE;
113
	m_pObjPressed = NULL;
114
	m_pObjColor = NULL;
115
	m_pObjMenu  = NULL;
116
	m_pObjButton = NULL;
117
	m_pObjSelect = NULL;
118

    
119
	m_bTrackLeave = FALSE;    // not traking mouse
120
	m_closeFlag = FALSE;
121

    
122
	m_selCtrlType = 0;
123
	m_selDllType = 0;
124
	m_bFlash = FALSE;
125

    
126
	m_disp = FALSE;
127
	memset(m_analogcode, 0, DEF_OBJCODE_LEN);
128

    
129
	m_bWndAnalogF = FALSE;
130
}
131

    
132
CGWnd::~CGWnd()
133
{	
134
	CRdbSubScibe * subscibeclient = g_ehmiMainFrame->subscibeclient;
135
	if(subscibeclient){
136
		subscibeclient->CancelSubScibe(m_wndId-DEF_ID_BASEWND);
137
	}
138

    
139
	//ɾ?????еĹ???
140
	for(int i=0;i<m_TagedDevlist.GetSize();i++)
141
	{
142
		TAGPARA Tagpara = m_TagedDevlist[i];
143

    
144
		if( Tagpara.pfather) 
145
		{
146
			Tagpara.pfather->DeleteNth(Tagpara.metapos);		
147
			Tagpara.pfather->Del(Tagpara.pobj); //??ͼԪ???ڵ?ͼ???ɶ????Ƴ?
148
		}
149
		if(Tagpara.pobj)
150
		{
151
          	delete Tagpara.pobj; 			
152
		}
153
		Tagpara.pobj = NULL;
154
		Tagpara.pfather = NULL;
155
		Tagpara.metapos = 0;		  
156
	}
157
    m_TagedDevlist.RemoveAll();
158

    
159
	m_tmpSelection.RemoveAll();
160
    m_Flashlist.RemoveAll();
161

    
162
	if(m_NaviDlg != NULL)
163
		delete m_NaviDlg;
164

    
165
	if(m_LayDlg != NULL)
166
		delete m_LayDlg;
167

    
168
	m_map.ClosePic();
169

    
170
	FreeObjAry();
171
}
172

    
173
BOOL CGWnd::PreCreateWindow(CREATESTRUCT& cs)
174
{
175
	return CWnd::PreCreateWindow(cs);
176
}
177

    
178
/////////////////////////////////////////////////////////////////////////////
179
// CGWnd printing
180

    
181

    
182
/////////////////////////////////////////////////////////////////////////////
183
// CGWnd drawing
184

    
185
/////////////////////////////////////////////////////////////////////////////
186
// CGWnd diagnostics
187

    
188
#ifdef _DEBUG
189
void CGWnd::AssertValid() const
190
{
191
//	CWnd::AssertValid();
192
}
193

    
194
void CGWnd::Dump(CDumpContext& dc) const
195
{
196
	CWnd::Dump(dc);
197
}
198

    
199
#endif //_DEBUG
200

    
201
/////////////////////////////////////////////////////////////////////////////
202
// CGWnd message handlers
203

    
204
int CGWnd::OnCreate(LPCREATESTRUCT lpCreateStruct) 
205
{
206
	if (CWnd::OnCreate(lpCreateStruct) == -1)
207
		return -1;
208

    
209
	SetTimer(1, 1000, NULL);
210
	SetTimer(2, g_ehmiMainFrame->m_freshTm, NULL);
211

    
212
	g_bYKDlgShow = FALSE;
213
	return 0;
214
}
215

    
216
BOOL CGWnd::PointSelect(UINT nFlags, CPoint point, MouseFlag flag)
217
{
218
	//??ѡ??ʱ???ж?һ???Ƿ?Ϊ??????ʩ
219
	m_FlashType = 0;
220
	m_devid		=	SE_K_DEV_NULL;
221
    m_shapeid	=	OS_UNKNOWN;
222
	m_hottype	=	HLT_UNKNOWN;
223
	m_runScript =   FALSE;
224
	kwhflag		=   0;
225
	m_seltblid.Empty();
226
	m_selobjid.Empty();
227
	m_selfldid.Empty();	
228

    
229
	m_pObjMenu = NULL;
230

    
231
    CFPoint ptSel(point.x, point.y);
232
	m_GraphGUI.ClientToMap(&ptSel);
233

    
234
	CEasyList *pObjList = m_GraphGUI.PointSelect(ptSel,0,FALSE,FALSE);
235

    
236
	if (pObjList == NULL || pObjList->GetListLen() == 0)
237
	{
238
		if (m_pObjPressed)
239
		{
240
			CFRect fRect = m_pObjPressed->GetObjectRect();
241
			m_pObjPressed->SetObjPressed(FALSE);
242
			m_pObjPressed->OnLButtonUp(nFlags, point);//fgt 20170707
243
			DrawObj(&fRect, &m_pObjPressed->GetObjectRect());
244
		}
245

    
246
		if (m_pObjButton)
247
		{
248
			m_pObjButton->OnMouseLeave((WPARAM)&nFlags, (LPARAM)&point);
249
			DrawObj(&m_pObjButton->GetObjectRect());
250
			m_pObjButton = NULL;
251
		}
252

    
253
		return FALSE;
254
	}
255
	m_pObjSelect = NULL;
256
	CHotLink *hotlink = m_map.GetHotLink(ptSel);
257

    
258
	BOOL selText = FALSE;
259
	BOOL findObj = FALSE;
260

    
261
    for (int pos=0; pos < pObjList->GetListLen(); pos++)
262
	{
263
		CBaseObj *pObj = (CBaseObj *)pObjList->GetNth(pos);
264
		if (pObj == NULL)
265
			continue;
266

    
267
		m_shapeid = pObj->GetObjectShape();
268
	
269
		if (m_shapeid == OS_BUTTON && (pObj->GetStyle() & OS_ENABLED))
270
		{
271
			switch (flag)
272
			{
273
			case lbtn_down:
274
				if (pObj->IsObjectMouseIn())
275
				{
276
					pObj->OnLButtonDown(nFlags, point);	
277
				}
278
				break;
279

    
280
			case lbtn_up:	
281
				{
282
					CButtonObj *pBtnObj = (CButtonObj *)pObj;
283
					pObj->OnLButtonUp(nFlags, point);	
284
					int nGroup = pBtnObj->GetGroups();
285
					UpdateObjGroups(pObj->GetObjectName(), nGroup);				
286
				}
287
				break;
288

    
289
			case mouse_move:
290
				{
291
					if (pObj != m_pObjButton)
292
					{
293
						if (m_pObjButton)
294
						{
295
							m_pObjButton->OnMouseLeave((WPARAM)&nFlags, (LPARAM)&point);
296
							DrawObj(&m_pObjButton->GetObjectRect());
297
						}
298

    
299
						pObj->OnMouseMove(nFlags, point);
300
						m_pObjButton = pObj;
301
					}
302
					else
303
					{
304
						CButtonObj *pBtnObj = (CButtonObj *)pObj;
305
						if (pBtnObj->IsObjectMouseIn())
306
						{
307
							CString strToolTip = pBtnObj->GetToolTip();
308
							if (strToolTip != _T(""))
309
							{
310
								CPoint pt;
311
								GetCursorPos(&pt);
312

    
313
								g_ehmiMainFrame->m_Tip.Show(strToolTip, &pt);
314
							}
315
						}
316
						else
317
							g_ehmiMainFrame->m_Tip.Hide();
318
					}
319
				}
320
				break;
321
			}
322

    
323
			DrawObj(&pObj->GetObjectRect());
324
		}
325
		else if (flag == mouse_move
326
			|| pObj->GetScriptLen() > 0
327
			|| m_shapeid == OS_YAOKONG
328
			|| hotlink)
329
		{
330
			CFRect fRect = pObj->GetObjectRect();
331

    
332
			switch (flag)
333
			{
334
			case lbtn_down:
335
				if ((pObj->GetStyle() & OS_ENABLED))
336
				{
337
					pObj->SetObjPressed(TRUE);
338
					DrawObj(&fRect, &pObj->GetObjectRect());
339
					m_pObjPressed = pObj;
340
				}
341
				break;
342
			case lbtn_up:
343
				if (pObj == m_pObjPressed)
344
				{
345
					pObj->SetObjPressed(FALSE);
346
					DrawObj(&fRect, &pObj->GetObjectRect());
347
					m_pObjPressed = NULL;
348
				}
349
				break;
350
			case mouse_move:
351
				if (m_pObjPressed)
352
				{
353
					CFRect fRect = m_pObjPressed->GetObjectRect();
354
					m_pObjPressed->SetObjPressed(pObj == m_pObjPressed);
355
					DrawObj(&fRect, &m_pObjPressed->GetObjectRect());
356
				}
357

    
358
				if (m_pView->m_bfgclr && m_shapeid == OS_TEXT)
359
				{
360
					selText = TRUE;
361

    
362
					if (m_pObjColor && pObj != m_pObjColor)
363
					{
364
						CFRect fRect = m_pObjColor->GetObjectRect();
365
						fRect.InflateRect(8.0, 2.0);
366
						((CTextObj *)m_pObjColor)->SetTextColor(m_fgcolor);
367
						DrawObj(&fRect);
368
						m_pObjColor = NULL;
369
					}
370

    
371
					if (m_pObjColor == NULL)
372
					{
373
						CFRect fRect = pObj->GetObjectRect();
374
						fRect.InflateRect(8.0, 2.0);
375
						m_fgcolor = ((CTextObj *)pObj)->SetTextColor(m_pView->m_fgcolor);
376
						DrawObj(&fRect);
377
						m_pObjColor = pObj;
378
					}
379
				}
380
				break;
381
			default:
382
				break;
383
			}
384
		}
385

    
386
		if (g_ehmiMainFrame->m_bScript && pObj->GetScriptLen() > 0 && pObj->GetStyle() & OS_ENABLED)
387
		{
388
			if (flag == lbtn_up)
389
			{
390
				if (RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR))
391
				{
392
					BeginWaitCursor();	// display the hourglass cursor
393

    
394
					m_pCurObj = pObj;
395
					if (m_shapeid == OS_BUTTON)
396
					{
397
						if (pObj->IsObjectMouseIn())
398
						{
399
							m_pView->m_Script.ExecString((const char *)pObj->m_pScriptData, this);
400
						}
401
					}
402
					else
403
					{
404
						m_pView->m_Script.ExecString((const char *)pObj->m_pScriptData, this);
405
					}
406
					m_pCurObj = NULL;
407

    
408
					EndWaitCursor();	// remove the hourglass cursor
409
				}
410
				m_runScript = TRUE;
411
			}
412
			else if (flag == mouse_move)
413
				m_runScript = TRUE;
414
		}
415

    
416
		if(m_shapeid == OS_POINTDEV)
417
		{
418
			CPointDevice *pdev = (CPointDevice *)pObj;
419
			m_pObjSelect = pdev;
420
			pdev->GetDevInfo(m_seldev);
421

    
422
			m_devid       = m_seldev.nDevType;
423
			m_curstate    = pObj->GetObjectStatus();
424
			m_FlashType   = pdev->GetFlashType();
425
			m_selCtrlType = pdev->GetConType();			//???????? 0:?ޣ?1:Ĭ?ϣ?2:?Զ???
426
			m_selDllType  = pdev->GetDllType();
427

    
428
			if (flag == lbtn_db)
429
			{//Added by wyf 20180806
430
				if(m_pView->m_OperateID==ID_OPT_SERIALSEL)
431
				{
432
//					if(m_devid == SE_K_DEV_BREAK || m_devid==SE_K_DEV_SWITCH || m_shapeid == OS_STATUSOBJ)
433
					if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_S)){
434
						uint8 val=0;
435
						CRdbSqlAccess rdb;
436
						rdb.SetUserPwd("guest", "");
437
						rdb.OptTbl("digital");
438
						rdb.SelectCol("Value");
439
						rdb.SetCond ("PointCode",REALDB_STRING,m_seldev.sYXCode, REALDB_COND_EQU);
440
						rdb.ExecSelect();
441
						if(rdb.GetRcdCount()>0)
442
							val=rdb.GetIntVal(0,0);
443
						AddSerialYKObj(m_seldev, !val);
444
					}
445
				}
446
			}//Added by wyf 20180806
447
			else if (flag == lbtn_down || flag == rbtn_down)
448
			{
449
				m_pView->SetPlugInParam(0, m_seldev.sYXCode);
450

    
451
				CJKPropertyDlg *pQueryDlg = g_ehmiMainFrame->pQueryDlg;
452
				if (pQueryDlg && pQueryDlg->IsWindowVisible())
453
				{
454
					ShowScadaParaDlg(m_seldev.sYXCode, 0);
455
					pQueryDlg->SetForegroundWindow();
456
				}
457
			}
458
			else if (flag == mouse_move && *m_seldev.sDevCode)
459
			{
460
				 CPoint point;
461
				 GetCursorPos(&point);
462
				 if(m_LdnPt!=point)//wyf 20180910
463
				 {	m_LdnPt=point;
464
				 g_ehmiMainFrame->ShowInfoTip(m_seldev.sDevCode, &point);}
465
			}
466

    
467
			findObj = TRUE;
468
//			break;	// ???豸?ر?֧????????
469
		}
470
		else if(m_shapeid == OS_DEVPOWERLINE)
471
		{
472
			 CDevPowerLine* pdev=(CDevPowerLine*)pObj;
473
			 pdev->GetDevInfo(m_seldev); 
474

    
475
			 m_devid=m_seldev.nDevType;
476

    
477
			 m_curstate =  pObj->GetObjectStatus();
478

    
479
			 break;
480
		}			
481
		else if(m_shapeid == OS_DEVBUSLINE)
482
        {
483
			 CDevBusLine* pdev=(CDevBusLine*)pObj;
484
			 pdev->GetDevInfo(m_seldev); 
485

    
486
			 m_devid=m_seldev.nDevType;
487

    
488
			 m_curstate =  pObj->GetObjectStatus();
489

    
490
			findObj = TRUE;
491
//			break;	// ĸ???ر?֧????????
492
		}
493
		else if(m_shapeid == OS_DEVLINE)
494
		{
495
             CDevLine* pdev=(CDevLine*)pObj;
496
			 pdev->GetDevInfo(m_seldev); 
497

    
498
			 m_devid=m_seldev.nDevType;
499

    
500
			 m_curstate =  pObj->GetObjectStatus();
501

    
502
			 break;
503
		}	
504
		else if(m_shapeid == OS_ANALOG)
505
		{
506
			CYaoCeObj * pyc = (CYaoCeObj *)pObj;
507
			strncpy(m_analogcode,pyc->GetYCCode(),DEF_OBJCODE_LEN-1);
508
			kwhflag = pyc->GetTypeID();			
509

    
510
			findObj = TRUE;
511
//			break;	// ģ?????ر?֧????????
512
		}
513
		else if(m_shapeid == OS_STATUSOBJ)
514
		{
515
			CStatusObj * psts = (CStatusObj *)pObj;
516
	
517
			m_seltblid = psts->GetTableID();
518
			m_selobjid = psts->GetStatusCode();
519
			m_selfldid = psts->GetFieldID();
520

    
521
			//Ҫȡ???豸???룬??Ȼ??ѯ????ʱ??ʱ??һ??ѡ????豸????Ϣ
522
			char tbl[40]="\0";
523
			char field[40]="\0";
524

    
525
			strncpy(tbl,m_seltblid,40);
526
			strncpy(field,m_selobjid,40);
527
            CRdbSqlAccess sqlCliSts;
528
			sqlCliSts.OptTbl(tbl);
529
			sqlCliSts.SelectCol ("DeviceCode");			
530
			sqlCliSts.SetCond("PointCode",REALDB_STRING,(void*)field);
531
			sqlCliSts.SetUserPwd("sa","se_root");
532
			if(sqlCliSts.ExecSelect() == 0)
533
			{
534
				int stspointNum = sqlCliSts.GetRcdCount();
535
				if(stspointNum>0)
536
				{
537
					strncpy(m_seldev.sDevCode,sqlCliSts.GetString(0, 0),DEF_OBJCODE_LEN);						
538
				}
539
			}
540
			strcpy(m_seldev.sYXCode,m_selobjid);
541
			m_FlashType = psts->GetFlashType();
542
			findObj = TRUE;
543
//			break;	// ״̬???ر?֧????????
544
		}
545
	/*	else if(m_shapeid == OS_REALSTRINGOBJ)
546
		{               
547
			CRealStringObj * pdev = (CRealStringObj *)pObj;
548
			m_seltblid = pdev->GetTableID();
549
			m_selobjid = pdev->GetRealStringCode();
550
			m_selfldid = pdev->GetFieldID();
551
			strcpy(m_seldev.sYXCode,m_selobjid);
552
		
553
			break;
554
		}*/
555
		else if(m_shapeid== OS_TERMOBJ)
556
		{
557
			//????????
558
			strncpy(m_analogcode,"",DEF_OBJCODE_LEN-1);
559

    
560
            CTermObj *pdev=(CTermObj*)pObj;
561
           int index=pdev->PtInObject(ptSel);
562
		   
563
		   if(index > 0)
564
		   {
565
			   //ʵʱ̬
566
			   DynaField oneyc;
567
               pdev->GetYCItem(index-1,oneyc);
568
           
569
			   if(strlen(oneyc.sYCCode) != 0)
570
			   {
571
				   strncpy(m_analogcode,oneyc.sYCCode,DEF_OBJCODE_LEN-1);
572
				   kwhflag=0;
573
				   break;
574
			   }
575
		   }
576
		}
577
		else if(m_shapeid == OS_YAOKONG)
578
		{
579
			CYaokongObj * pYK = (CYaokongObj *)pObj;
580

    
581
			//??m_curstate ?? m_seldev
582
			strcpy(m_seldev.sYXCode, pYK->GetYKCode());
583
			m_curstate = pYK->GetYKStatusValue();
584

    
585
			break;
586
		}
587
		else if (m_shapeid == OS_BITMAP)
588
		{
589
			CImageObj *pdev = (CImageObj *)pObj;
590

    
591
			if (pdev->IsGif())
592
			{
593
				pdev->GetDevInfo(m_seldev);
594

    
595
				m_devid = m_seldev.nDevType;
596

    
597
				m_curstate = pObj->GetObjectStatus();
598

    
599
				m_imgcode = pdev->GetGifYxCode();
600

    
601
				break;
602
			}
603
		}
604
		else if (m_shapeid == OS_ATSTRAIN)
605
		{
606
			CString strHeadCode,strTrainNo;
607
			if ((pObj->GetStyle() & OS_ENABLED))
608
			{
609
				strHeadCode = ((CAtsTrain *)pObj)->GetHeadCode();
610
				if (flag == mouse_move && strHeadCode != _T(""))
611
				{
612
					CPoint pt;
613
					GetCursorPos(&pt);					
614
					g_ehmiMainFrame->ShowInfoTip(strHeadCode, &pt);					
615
				}
616
				if (flag == lbtn_down){	//Added by WYF 20191201
617
					char tAtsTrainPath[256]="";
618
					strcat(tAtsTrainPath,g_ehmiMainFrame->m_AtsTrainPath);
619
					strTrainNo=((CAtsTrain *)pObj)->GetTrianNo();
620
					strcat(tAtsTrainPath,strTrainNo);
621
					strcat(tAtsTrainPath,".SVM");
622
					m_pView->OpenSvm(tAtsTrainPath, TRUE, FALSE, NULL, NULL, "");
623
				}//Added by WYF 20191201
624
			}
625
		}
626

    
627
		if (hotlink)
628
		{
629
			m_hottype	= (HOTLINK_TYPE)hotlink->LinkType();
630
			m_hotstring = hotlink->LinkString();
631
			m_hotpara   = hotlink->LinkNote();
632
			m_pObjMenu  = hotlink->GetAttachObj();
633

    
634
			if (m_hottype != HLT_UNKNOWN)
635
			{
636
				if (!(pObj->GetStyle() & OS_ENABLED))
637
					m_hottype = HLT_UNKNOWN;
638

    
639
				break;
640
			}
641
		}
642

    
643
		if (findObj)
644
			break;
645
	}//End For
646

    
647
	m_seldev.sYXCode[DEF_OBJCODE_LEN-1] = 0;
648
	m_seldev.sDevCode[DEF_OBJCODE_LEN-1] = 0;
649

    
650
	if (pObjList)
651
		delete pObjList;
652

    
653
	return selText;
654
}
655

    
656
void CGWnd::OnRButtonDown(UINT nFlags, CPoint point) 
657
{
658
	CWnd::OnRButtonDown(nFlags, point);
659

    
660
	BOOL bTrack = m_bTrack;
661
	BOOL bIsCmd = GetMapStatus() == c_zoomout || GetMapStatus() == c_zoomin
662
		|| GetMapStatus() == c_zoombox || GetMapStatus() == c_pan || m_pView->m_OperateID;
663

    
664
	//??????ֱ?־λ
665
	m_bTrack = FALSE;
666
	m_prevcmd = c_none;
667
	m_cmd = c_none;
668
	m_pView->m_OperateID = 0;
669

    
670
	if (bIsCmd)
671
	{
672
		if ( bTrack )
673
			m_pView->m_Script.Pause();
674

    
675
		return;
676
	}
677

    
678
	PointSelect(nFlags, point, rbtn_down);
679

    
680
	if (g_ehmiMainFrame->IsAlmTotal(m_seldev.sYXCode))
681
	{
682
		return;
683
	}
684
	m_LdnPt=point;//WYF 20180803
685
	POINT TmpPoint = point;
686
	ClientToScreen (&TmpPoint);
687

    
688
	g_ehmiMainFrame->m_cmdPt = TmpPoint;
689

    
690
	char menuType[200] = {0};
691

    
692
	//????????????ң?⴦??
693
	if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ ) 
694
		  && !kwhflag)
695
	{//??ң??˵?
696
		if(strlen(g_ehmiMainFrame->m_user)<=0)
697
		{
698
			strcpy(menuType,"ң???Ҽ??˵?_NOUSER");
699
		}
700
		else 
701
		{
702
			strcpy(menuType,"ң???Ҽ??˵?");
703
		}
704
	}
705
	else if(m_devid == SE_K_DEV_NULL && m_shapeid == OS_ANALOG && kwhflag)
706
	{//????Ȳ˵?
707
		strcpy(menuType,"????Ҽ??˵?");
708
	}
709
	else if(m_shapeid == OS_STATUSOBJ && m_seltblid==CString(PROTDEV_RDB_TBLNAME))
710
	{//???????豸?˵?????ʱ??ң??
711
		if(strlen(g_ehmiMainFrame->m_user)<=0)
712
		{
713
			strcpy(menuType,"?????豸?Ҽ??˵?_NOUSER");
714
		}
715
		else 
716
		{
717
			strcpy(menuType,"?????豸?Ҽ??˵?");
718
		}
719
	}
720
	else if ( m_shapeid == OS_POINTDEV
721
		   || (m_shapeid == OS_STATUSOBJ && m_seltblid == DIGITAL_RDB_TBLNAME)
722
		   || (m_shapeid == OS_BITMAP && m_imgcode != "")
723
		   )
724
	{ // ң?Ų˵?/?豸?˵?
725
		if(strlen(g_ehmiMainFrame->m_user)<=0)
726
		{
727
			strcpy(menuType,"ң???Ҽ??˵?_NOUSER");
728
		}
729
		else
730
		{
731
			if (strcmp(m_seldev.sDevCode, ""))
732
			{
733
				if (strcmp(m_seldev.sYXCode, "") || m_selDllType)
734
					if (m_selCtrlType)
735
						strcpy(menuType, "ң???Ҽ??˵?");
736
					else
737
						strcpy(menuType, "ң???Ҽ??˵?_?޿???");
738
				else
739
					if (m_selCtrlType)
740
						strcpy(menuType, "?豸?Ҽ??˵?_????");
741
					else
742
						strcpy(menuType, "?豸?Ҽ??˵?");
743
			}
744
			else
745
			{
746
				if (strcmp(m_seldev.sYXCode, "") || m_selDllType)
747
				{
748
					if (m_selCtrlType == 1)
749
						strcpy(menuType, "ң???Ҽ??˵?_???豸");
750
					else
751
						strcpy(menuType, "ң???Ҽ??˵?_?޿??????豸");
752
				}
753
				else
754
					strcpy(menuType, "??ͨ?Ҽ??˵?");
755
			}
756
		}
757
	}
758
	else
759
	{//??ͨ?Ҽ??˵?  Ϊ?˼ӿ???ʾ?ٶ????⴦??
760
		if (RBAC_CheckPrivilege(DEF_RIGHT_DTS_ADMIN))
761
		{
762
			if (m_ViewMenu1.SetTypeName("??ͨ?Ҽ??˵?_??Ա"))
763
				m_ViewMenu1.CreateMenu();
764

    
765
			m_ViewMenu1.ShowMenu(TmpPoint,GetParentFrame());
766
		}
767
		else
768
		{
769
			if (m_ViewMenu2.SetTypeName("??ͨ?Ҽ??˵?"))
770
				m_ViewMenu2.CreateMenu();
771

    
772
			m_ViewMenu2.ShowMenu(TmpPoint,GetParentFrame());
773
		}
774

    
775
		return;
776
	}
777

    
778
	CVGInterfaceCtrl menu(menuType, this);
779
	if (strcmp(menuType, "??ͨ?Ҽ??˵?") == 0)
780
		menu.SetParentWnd(m_pView);
781
	menu.CreateMenu();
782
	menu.ShowMenu(TmpPoint);
783
}
784

    
785
void CGWnd::OnRButtonUp(UINT nFlags, CPoint point) 
786
{
787
	CmdState tmpcmd;
788
	tmpcmd = m_cmd;
789
	m_cmd = m_prevcmd;
790
	m_prevcmd = tmpcmd;
791
	OnSetCursor(this, HTCLIENT, 0);
792
	
793
	CWnd::OnRButtonUp(nFlags, point);
794
}
795

    
796
void CGWnd::OnUpdateObjMenu(CCmdUI* pCmdUI) 
797
{
798
	UINT nID= pCmdUI->m_nID; 
799
    switch (nID){
800
	case ID_OBJMENU_YCPARA:
801
	case ID_OBJMENU_QSQX:
802
	case ID_OBJMENU_TODAYQX:
803
	case ID_OBJMENU_YXPARA:
804
	case ID_OBJMENU_KWHPARA:
805
	case ID_OBJMENU_DEVPARA:
806
		pCmdUI->Enable(1);
807
		break;
808
	case ID_OBJMENU_YT:
809
	case ID_OBJMENU_YK:
810
	case ID_OBJMENU_YXRETURN:
811
	case ID_OBJMENU_YCCLEAR:
812
	case ID_OBJMENU_MANSETYC:
813
	case ID_OBJMENU_YXCLEAR:
814
	case ID_OBJMENU_TAG:
815
	case ID_OBJMENU_STOPYC:
816
	case ID_OBJMENU_PL:
817
	case ID_OBJMENU_MANAGEKGBH:
818
		pCmdUI->Enable(RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR));
819
		break;
820
	case ID_OBJMENU_STOPYX:
821
		pCmdUI->Enable(RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR));
822
		if (m_FlashType == FLASH_STATE_EQUAL) 
823
		{
824
			pCmdUI->Enable(0);
825
		}			
826
		break;	
827
	default:
828
		pCmdUI->Enable (1);
829
	}
830
}
831

    
832
void CGWnd::OnUpdateProtMenu(CCmdUI* pCmdUI) 
833
{
834
	UINT nID= pCmdUI->m_nID; 
835
    switch (nID){
836
	case ID_OBJMENU_PROTDEVPARA:
837
		pCmdUI->Enable (1);
838
		break;
839
	case ID_GET_PROTECTVAL:
840
	case ID_SET_PROTECTVAL:
841
	case ID_RESET_PROTECTVAL:
842
		pCmdUI->Enable (RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR));
843
		break;
844
	default:
845
		pCmdUI->Enable (1);	
846
	}
847
}
848

    
849
void CGWnd::OnLButtonDown(UINT nFlags, CPoint point) 
850
{
851
	//??????ƶԻ????Ѿ???ʾ????ʱ?????Ի????????????????Ӧ??
852
	if (!ClickInSpeciallyDlgRect(point))
853
	{
854
		return;
855
	}
856
	switch(m_cmd)
857
	{
858
	case c_zoomout:
859
		GetGraphGUI()->ZoomOut();
860
		return;
861

    
862
	case c_zoomin:
863
		GetGraphGUI()->ZoomIn();
864
		return;
865

    
866
	case c_boxsel:
867
	case c_zoombox:
868
	case c_pan:
869
		{
870
			m_bTrack = TRUE;
871
			m_startPt = m_endPt = point;
872
			SetCapture();
873
			m_pView->m_Script.Pause(true);
874

    
875
			CWnd::OnLButtonDown(nFlags, point);
876
			return;
877
		}
878
		break;
879
	case c_pointsel:
880
		{
881
		}
882
		break;
883
	}
884

    
885
	PointSelect(nFlags, point, lbtn_down);
886
	//WYF 20190621
887
	POINT PointTmp = point;
888
	ClientToScreen (&PointTmp);	
889
	int cx = GetSystemMetrics(SM_CXSCREEN);
890
	int screenIndex=(PointTmp.x+cx-1)/cx-1;
891
	if(screenIndex!=g_ehmiMainFrame->m_ScreenIndex)
892
		g_ehmiMainFrame->m_ScreenIndex=screenIndex;
893
	//WYF 20190621
894
//Added by xzf 20180622	
895
	UINT xls=0;
896
	if(m_shapeid == OS_POINTDEV || m_shapeid == OS_ANALOG)
897
	{	
898
	xls=m_pView->m_OperateID;
899
	m_pView->m_OperateID=ID_OPT_REALDATA;
900
	m_LdnPt=point;//WYF 20180803
901
//	g_ehmiMainFrame->m_cmdPt = point;//wyf 20180910
902
	POINT TmpPoint = point;
903
	ClientToScreen (&TmpPoint);	
904
	g_ehmiMainFrame->m_cmdPt = TmpPoint;
905
	}
906
//Added by xzf 20180622	
907
	UINT ID = 0;
908
	switch(m_pView->m_OperateID)
909
	{
910
	case ID_OPT_YK:
911
		ID = ID_OBJMENU_YK;
912
		break;
913
	case ID_OPT_YT:
914
		ID = ID_OBJMENU_YT;
915
		break;
916
	case ID_OPT_YXREVERSE:
917
		ID = ID_OBJMENU_YXRETURN;
918
		break;
919
	case ID_OPT_STOPYXS:
920
		ID = ID_OBJMENU_STOPYX;
921
		break;
922
	case ID_OPT_MANSET:
923
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)  && !kwhflag)
924
			ID = ID_OBJMENU_MANSETYC;
925
		else
926
			if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_S))
927
				ShowManSetDlg(m_seldev,0);
928
		break;
929
	case ID_OPT_CLEARSET:
930
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)	&& !kwhflag)
931
			ID = ID_OBJMENU_YCCLEAR;
932
		else
933
			ID = ID_OBJMENU_YXCLEAR;
934
		break;
935
	case ID_OPT_PL:
936
		if(m_devid == SE_K_DEV_BREAK || m_devid==SE_K_DEV_SWITCH)
937
		if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_S))
938
		{
939
			CMMIPLDlg * pldlg = (CMMIPLDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_PLDLG);
940
			if(pldlg){
941
				if(pldlg->IsWindowVisible()) {
942
					pldlg->AddPlBreak(m_seldev.sYXCode);
943
					break;	
944
				}
945
			}
946
			ShowPlDlg(m_seldev.sYXCode);
947
		}
948
		break;
949
	case ID_OPT_TAG:
950
		ID = ID_OBJMENU_TAG;
951
		break;
952
	case ID_OPT_SERIALSEL:
953
		if(m_devid == SE_K_DEV_BREAK || m_devid==SE_K_DEV_SWITCH || m_shapeid == OS_STATUSOBJ)
954
			if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_S))
955
				AddSerialYKObj(m_seldev, !m_curstate);
956
		break;
957
	case ID_OPT_ALMCONTRL:
958
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ))
959
		{
960
			if (CheckAoj(m_analogcode, p_ai, DEF_RIGHT_DEVICE_S))
961
				ShowAlarmCtrl(m_analogcode,0);
962
		}
963
		else
964
			if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_S))
965
				ShowAlarmCtrl(m_seldev.sYXCode,1);
966
		break;
967
	case ID_OPT_SCADAPARA:
968
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ))
969
			ShowScadaParaDlg(m_analogcode,kwhflag ? 2 : 1);
970
		else
971
			ShowScadaParaDlg(m_seldev.sYXCode,0);
972
		break;
973
	case ID_OPT_DEVPARA:
974
		ID = ID_OBJMENU_DEVPARA;
975
		break;
976
	case ID_OPT_QXTODAY:
977
		ID = ID_OBJMENU_TODAYQX;
978
		break;
979
	case ID_OPT_QSQX:
980
		ID = ID_OBJMENU_QSQX;
981
		break;
982
	case ID_OPT_REALDATA: //ʵʱ???????
983
		if(m_devid != SE_K_DEV_NULL)
984
			ShowDevRealPntDlg(m_seldev.sDevCode);
985
		else if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ) && !kwhflag)
986
			//????ң??????ȡ???????豸??ʵʱ????
987
//            ShowDevRealPntDlgByYCCode(m_analogcode);
988
/**/			//XZF 20180716
989
			if (CheckAoj(m_analogcode, p_ao, DEF_RIGHT_DEVICE_C))
990
				ShowYTDlg(m_analogcode);
991
			//XZF 20180716
992
		else if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ) && kwhflag)
993
			//???ݵ?ȵ????ȡ???????豸??ʵʱ????
994
            ShowDevRealPntDlgByKWHCode(m_analogcode);
995
		else if(m_shapeid == OS_STATUSOBJ)
996
			ShowDevRealPntDlgByYXCode(m_seldev.sYXCode);
997
		break;
998
	default:
999
		if (m_hottype == HLT_MENU)	//?ȵ㵯???˵?
1000
		{
1001
			ShowPopupMenu(point);
1002
		}
1003
		break;
1004
	}
1005

    
1006
	if (ID > 0)
1007
		OnCmdObjMenu(ID);
1008
//XZF 20180716
1009
	if(m_shapeid == OS_POINTDEV)
1010
	{	
1011
		m_pView->m_OperateID=xls;
1012
	}
1013
//XZF 20180716
1014
//	CWnd::OnLButtonDown(nFlags, point);//delete by peak 20171213
1015
}
1016

    
1017
void CGWnd::OnLButtonUp(UINT nFlags, CPoint point) 
1018
{	//??????ƶԻ????Ѿ???ʾ????ʱ?????Ի????????????????Ӧ??
1019
	if (!ClickInSpeciallyDlgRect(point))
1020
	{
1021
		return ;
1022
	}
1023
	CWnd::OnLButtonUp(nFlags, point);
1024

    
1025
	switch(m_cmd)
1026
	{
1027
	case c_boxsel:
1028
		if ( m_bTrack )
1029
		{
1030
			m_endPt = point;
1031
			CFRect rcSelect(m_startPt.x,m_startPt.y,m_endPt.x,m_endPt.y);
1032
			rcSelect.NormalizeRect();
1033
			CEasyList *abc = m_GraphGUI.BoxSelect(rcSelect);	
1034
			if ( abc->GetListLen() > 0 )
1035
			{
1036
				CBaseObj *pObj =(CBaseObj *)abc->GetNth(0);
1037
				CFRect rect = pObj->GetObjectRect();
1038

    
1039
				CString str;
1040
				str.Format("name: %s, position (%d, %d, %d, %d)",
1041
					pObj->GetObjectName(), rect.left, rect.top, rect.right, rect.bottom);
1042
				AfxMessageBox(str);
1043

    
1044
				rcSelect.InflateRect(2, 2);
1045
				CRect rcRect(rcSelect.left,rcSelect.top,rcSelect.right,rcSelect.bottom);
1046
				InvalidateRect(rcRect, FALSE);	//ˢ??ȥ?????????
1047
			}
1048
		}
1049
		break;
1050

    
1051
	case c_zoombox:
1052
		if ( m_bTrack )
1053
		{
1054
			CRect rect(m_startPt, m_endPt);
1055
			rect.NormalizeRect();
1056
			DrawRect(rect);
1057
			bool bLarger ;
1058
			if ( m_endPt.x >= m_startPt.x ) //?Ŵ?
1059
				bLarger = TRUE;
1060
			else
1061
				bLarger = FALSE;
1062
			if(rect.Width () > ZooehminOFF && rect.Height ()>ZooehminOFF)
1063
				m_GraphGUI.ZoomBox(rect, bLarger);
1064
		}
1065
		break;
1066

    
1067
	case c_pan:
1068
		if ( m_bTrack ) 
1069
		{
1070
			m_GraphGUI.ReDraw();
1071
		}
1072
		break;
1073

    
1074
	case c_pointsel:
1075
		{
1076
		    CFPoint ptSel(point.x, point.y);
1077
        	m_GraphGUI.ClientToMap(&ptSel);
1078
			CEasyList *abc = m_GraphGUI.PointSelect(ptSel);
1079
			if (abc->GetListLen() > 0 )
1080
			{
1081
				CBaseObj *pObj =(CBaseObj *)abc->GetNth(0);
1082
				CFRect rect = pObj->GetObjectRect();
1083

    
1084
				CString str;
1085
				str.Format("name: %s, position (%d, %d, %d, %d)",
1086
					pObj->GetObjectName(), rect.left, rect.top, rect.right, rect.bottom);
1087
				AfxMessageBox(str);
1088
			}
1089
		}
1090
		break;
1091
	}
1092

    
1093
	if ( m_bTrack ) 
1094
	{
1095
		m_bTrack = FALSE;
1096
		ReleaseCapture();
1097
		m_pView->m_Script.Pause();
1098
	}
1099

    
1100
	PointSelect(nFlags, point, lbtn_up);
1101

    
1102
	if(m_shapeid == OS_YAOKONG)
1103
	{
1104
		if (RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR))
1105
		{
1106
			g_ehmiMainFrame->scdclient->DiscreteControl(g_ehmiMainFrame->m_user,
1107
				m_seldev.sYXCode, CSI_K_ONLY_EXECUTE, !m_curstate);
1108
		}
1109
		else
1110
			AfxMessageBox("?Բ?????û??ң?ص?Ȩ??");
1111

    
1112
		return;
1113
	}
1114

    
1115
	BeginWaitCursor();	// display the hourglass cursor
1116

    
1117
	//?ȵ㴦??
1118
	if(m_hottype == HLT_FILE)
1119
	{//?ȵ??ͼ
1120
		m_pView->OpenSvm(m_hotstring, TRUE, FALSE, NULL, NULL, m_hotpara);
1121
	}
1122
	else if(m_hottype == HLT_EXEFILE)
1123
	{//?ȵ?ִ?г???
1124
		STARTUPINFO si = { sizeof(si) };	//?????õ?exe??????????ʾλ?ã???exe?п?ͨ??GetStartupInfo??ȡ?˽ṹ???ֵ?????????ⷽʽ(??Щ??????)exe?в?????λ??ʱҲ???޸???ʾλ??
1125
		si.dwX= 0;		//??????????Ļ????˵?????ֵ 0 1920 1920*2
1126
		si.dwY = 120;
1127
		int screenWidth = GetSystemMetrics(SM_CXSCREEN);
1128
		si.dwFlags = STARTF_USEPOSITION;  // | STARTF_USESHOWWINDOW;
1129
		POINT posCur;
1130
		memset(&posCur, 0, sizeof(posCur));
1131
		GetCursorPos(&posCur);
1132
		si.dwX = (posCur.x)/screenWidth * screenWidth;
1133
		
1134
		PROCESS_INFORMATION pi;
1135
		char cmd[MAX_PATH];
1136
		sprintf(cmd, "\"%s\" %s", m_hotstring, m_hotpara);
1137
		CreateProcess(NULL,cmd,NULL,NULL,FALSE,0,NULL,NULL,&si,&pi);
1138
	}
1139
	else if(m_hottype == HLT_SCPFILE)
1140
	{//?ȵ㷢????????Ϣ
1141
		UINT msgId = atoi(m_hotstring) + 1;
1142
		UINT cmdNums = GetPrivateProfileInt(
1143
			"??????Ϣ", "???????", 0, g_ehmiMainFrame->GetCfgPath());
1144

    
1145
		if (msgId <= cmdNums)
1146
		{
1147
			char key[32];
1148
			sprintf(key, "??Ϣ%d", msgId);
1149
			UINT nID = GetPrivateProfileInt(
1150
				"??????Ϣ", key, 0, g_ehmiMainFrame->GetCfgPath());
1151

    
1152
			if (nID == ID_FILE_PRINT_SETUP)//CWinApp??????ֻ??ID_FILE_PRINT_SETUP,??֧??ID_FILE_PRINT??Preview
1153
			{
1154
				//AfxGetApp()->OnCmdMsg(ID_FILE_PRINT_SETUP, 0, NULL, NULL);
1155
				OnBtnPrint(nID);
1156
			}
1157
			else
1158
			{
1159
				if (m_pView->m_pCurGWnd == NULL ||
1160
					m_pView->m_pCurGWnd->SendMessage(WM_COMMAND, nID) == 0)
1161
					m_pView->SendMessage(WM_COMMAND, nID);
1162
			}
1163
		}
1164
	}
1165
	else if(m_hottype == HLT_YK)
1166
	{//?ȵ㷢??ң??????
1167
		if (RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR))
1168
		{
1169
			POINT TmpPoint = point;
1170
			ClientToScreen (&TmpPoint);
1171

    
1172
			g_ehmiMainFrame->m_cmdPt = TmpPoint;
1173

    
1174
			g_ehmiMainFrame->scdclient->DiscreteControl(g_ehmiMainFrame->m_user,
1175
				(LPTSTR)(LPCTSTR)m_hotstring, CSI_K_ONLY_EXECUTE, atoi(m_hotpara));
1176
		}
1177
		else
1178
			AfxMessageBox("?Բ?????û???ȵ?ң?ص?Ȩ??");
1179
	}
1180
	else if(m_hottype == HLT_XK)
1181
	{//?ȵ㷢?????????
1182
		if (RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR))
1183
		{
1184
			g_ehmiMainFrame->scdclient->TrainControl(g_ehmiMainFrame->m_user,
1185
				(LPTSTR)(LPCTSTR)m_hotpara, 0, 0);
1186
		}
1187
		else
1188
			AfxMessageBox("?Բ?????û???ȵ???ص?Ȩ??");
1189
	}
1190
	else if(m_hottype == HLT_EYESHOT)
1191
	{//??ͼ
1192
		DrawNameView(m_hotstring);
1193
	}
1194
	else if(m_hottype == HLT_YT)
1195
	{//?ȵ㷢??ң??????
1196
		if (RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR))
1197
		{
1198
			POINT TmpPoint = point;
1199
			ClientToScreen (&TmpPoint);
1200

    
1201
			g_ehmiMainFrame->m_cmdPt = TmpPoint;
1202

    
1203
			g_ehmiMainFrame->scdclient->TapControl(g_ehmiMainFrame->m_user,
1204
				(LPTSTR)(LPCTSTR)m_hotstring, CSI_K_ONLY_EXECUTE, atoi(m_hotpara));
1205
		}
1206
		else
1207
			AfxMessageBox("?Բ?????û???ȵ?ң?ص?Ȩ??");
1208
	}
1209
	else if(m_hottype == HLT_STOPFLASH)
1210
	{//ȫվͣ??
1211
		if (RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR))
1212
		{
1213
			g_ehmiMainFrame->scdclient->SubstControl(g_ehmiMainFrame->m_user,
1214
				(LPTSTR)(LPCTSTR)m_hotstring, SE_K_SUBST_STOP_FLASHING);
1215
		}
1216
	}
1217
	else if (m_hottype == HLT_GWND_STOPFLASH)
1218
	{
1219
		// ȫͼͣ??
1220
		if (RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR))
1221
		{
1222
			if (m_pView->m_pCurGWnd != NULL)
1223
			{
1224
				m_pView->m_pCurGWnd->StopFlash();
1225
			}			
1226
		}
1227
	}
1228
	else if (m_hottype == HLT_SCREEN_OPENGRAPH)
1229
	{
1230
		if (RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR))
1231
		{
1232
			m_pView->ScreenOpenGraph();
1233
		}
1234
	}
1235

    
1236
	EndWaitCursor();	// remove the hourglass cursor
1237
}
1238

    
1239
void CGWnd::OnTimer(UINT nIDEvent) 
1240
{
1241
	// 1??Ķ?ʱ??
1242
	if (nIDEvent == 1)
1243
	{
1244
		m_TimeCount ++;
1245

    
1246
		if(DEF_DATA_FROM_PDR != SourceRealData)
1247
		{
1248
			CVGRegion region;
1249

    
1250
			// ÿ?????ʱ?ӡ?????
1251
			UpdateAllMoveObj(&region);
1252

    
1253
		   	// ??˸????
1254
			COLORREF oldColor = CGlobal::m_FreshColor;
1255
			if(g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_FLASH])
1256
			{
1257
			  	UpdateFlashObj(&region);
1258
			}
1259

    
1260
			UpdateMetaStatus(region);
1261

    
1262
			UpdateCounter(region);
1263

    
1264
			// ???±?־????Ϣ
1265
			if (m_tagCount > 0)
1266
			{
1267
				m_tagCount--;
1268
				UpdateAllTagInfo();
1269
			}
1270

    
1271
			// ÿ??1???Ӹ???һ????????Ϣ
1272
			if (m_TimeCount % 60 == 0)
1273
				UpdateAllCurInfo(&region);
1274

    
1275
			if (region.GetRectCount()>0)
1276
				m_map.RefreshRegion(region, &m_GraphGUI);
1277

    
1278
			CGlobal::m_FreshColor = oldColor;
1279
		}
1280

    
1281
		if(SourceRealData != OldSourceRealData)
1282
		{
1283
			OldSourceRealData = SourceRealData;
1284
			if(SourceRealData == DEF_DATA_FROM_PDR)
1285
			{
1286
				ClearAllMapData();
1287
			}
1288
			else
1289
			{                
1290
				CollectAllData();
1291
			}
1292

    
1293
			m_GraphGUI.ReDraw();
1294
		}
1295

    
1296
		// ÿ??ִ??һ?δ??ڽű?
1297
		if (g_ehmiMainFrame->m_bScript && m_map.m_nScriptLenrun > 0)
1298
		{
1299
			m_pView->m_Script.ExecString((const char *)m_map.m_pVgScriptDatarun, this, true);
1300
		}
1301

    
1302
		if (m_disp)
1303
			UpdateDataSrc();
1304
	}
1305
	// ?Զ???ʱ????ˢ?¶???ͼԪ
1306
	else if (nIDEvent == 2)
1307
	{
1308
		CVGRegion region;
1309

    
1310
		CBaseObjArray & objArray = GetFeatureObjects(OS_POINTDEV);
1311

    
1312
		for (int i = 0; i < objArray.GetSize(); i++)
1313
		{
1314
			CPointObj *pPointObj = (CPointObj *)objArray[i];
1315

    
1316
			if (pPointObj->GetIsMotion())
1317
			{
1318
				pPointObj->FreshMotion();
1319
				region.Add(pPointObj);
1320
			}
1321
		}
1322

    
1323
		if (region.GetRectCount() > 0)
1324
			m_map.RefreshRegion(region, &m_GraphGUI);
1325
		else
1326
			KillTimer(2);
1327
	}
1328

    
1329
	CWnd::OnTimer(nIDEvent);
1330
}
1331

    
1332
void CGWnd::OnCmdObjMenu(UINT ID)
1333
{ 
1334
    switch (ID){
1335
	case ID_OBJMENU_MANSETYC:
1336
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)	&& !kwhflag)
1337
		if (CheckAoj(m_analogcode, p_ai, DEF_RIGHT_DEVICE_S))
1338
			ShowManSetDlg(m_analogcode,1);
1339
		break;
1340
	case ID_OBJMENU_YCCLEAR:
1341
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)	&& !kwhflag)
1342
		if (CheckAoj(m_analogcode, p_ai, DEF_RIGHT_DEVICE_S))
1343
			ClearManSet(m_analogcode,1);
1344
		break;
1345
	case ID_OBJMENU_YT:
1346
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)  && !kwhflag)
1347
		if (CheckAoj(m_analogcode, p_ao, DEF_RIGHT_DEVICE_C))
1348
			ShowYTDlg(m_analogcode);
1349
		break;
1350
	case ID_OBJMENU_YCPARA:
1351
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)  && !kwhflag)
1352
			ShowScadaParaDlg(m_analogcode,1);
1353
		break;
1354
	case ID_OBJMENU_KWHPARA:
1355
		if(m_devid == SE_K_DEV_NULL && m_shapeid == OS_ANALOG)
1356
			ShowScadaParaDlg(m_analogcode,2);
1357
		break;
1358
	case ID_OBJMENU_QSQX:
1359
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)  && !kwhflag)
1360
			ShowNewQsDlg(m_analogcode);
1361
		break;
1362
	case ID_OBJMENU_TODAYQX:
1363
		if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)  && !kwhflag)
1364
			ShowTadayQxDlg(m_analogcode);
1365
		break;
1366
	case ID_OBJMENU_YXPARA:
1367
			ShowScadaParaDlg(m_seldev.sYXCode,0);
1368
		break;
1369
	case ID_OBJMENU_DEVPARA:
1370
		if(m_devid != SE_K_DEV_NULL)
1371
			ShowDevParaDlg(m_seldev.sDevCode);
1372
		else if(m_shapeid == OS_STATUSOBJ)
1373
			ShowDevParaDlgByYXCode(m_seldev.sYXCode);
1374
		break;
1375
	case ID_OBJMENU_YK:
1376
		if (g_ehmiMainFrame->m_uniCtrl)
1377
		{
1378
			if (strcmp(m_seldev.sDevCode, ""))
1379
			{
1380
				if (m_selCtrlType == 1 && CheckAoj(m_seldev.sYXCode,  p_do,  DEF_RIGHT_DEVICE_C) ||
1381
					m_selCtrlType == 2 && CheckAoj(m_seldev.sDevCode, p_dev, DEF_RIGHT_DEVICE_C))
1382
					ShowCtrlDlg(Ctrl);
1383
			}
1384
			else
1385
				if (m_selCtrlType == 1 && CheckAoj(m_seldev.sYXCode, p_do, DEF_RIGHT_DEVICE_C))
1386
					ShowYKDlg();
1387
		}
1388
		else
1389
		{
1390
		if (strcmp(m_seldev.sAttchGraph, "Ĭ??"))
1391
		{
1392
			if (CheckAoj(m_seldev.sDevCode, p_dev, DEF_RIGHT_DEVICE_C))
1393
				m_pView->OpenSvm(m_seldev.sAttchGraph, FALSE, FALSE, NULL, &g_ehmiMainFrame->m_cmdPt);
1394
		}
1395
		else
1396
			if (CheckAoj(m_seldev.sYXCode, p_do, DEF_RIGHT_DEVICE_C))
1397
				ShowYKDlg();
1398
		}
1399
		break;
1400
	case ID_OBJMENU_YXRETURN:
1401
		if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_S))
1402
			SetYxReturn(m_seldev);
1403
		break;
1404
	case ID_OBJMENU_STOPYC:
1405
		if (CheckAoj(m_analogcode, p_di, DEF_RIGHT_DEVICE_S))
1406
			StopYcFlash(m_analogcode);
1407
		break;
1408
	case ID_OBJMENU_STOPYX:
1409
		if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_S))
1410
			StopYxFlash(m_seldev.sYXCode);
1411
		break;
1412
	case ID_OBJMENU_MANAGEKGBH:
1413
		if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_M))
1414
			ManageKGBH(m_seldev.sYXCode);
1415
		break;
1416
	case ID_OBJMENU_YXCLEAR:
1417
		if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_S))
1418
			ClearManSet(m_seldev.sYXCode,0);
1419
		break;
1420
	case ID_OBJMENU_TAG:
1421
		if (m_devid != SE_K_DEV_NULL)
1422
		if (strcmp(m_seldev.sYXCode, "") != 0 && CheckAoj(m_seldev.sYXCode,  p_di,  DEF_RIGHT_DEVICE_S) ||
1423
			strcmp(m_seldev.sYXCode, "") == 0 && CheckAoj(m_seldev.sDevCode, p_dev, DEF_RIGHT_DEVICE_S))
1424
			ShowTagDlg(m_seldev.sDevCode);
1425
		break;
1426
	case ID_OBJMENU_PL:
1427
		if(m_devid == SE_K_DEV_BREAK || m_devid==SE_K_DEV_SWITCH)
1428
		if (CheckAoj(m_seldev.sYXCode, p_di, DEF_RIGHT_DEVICE_S))
1429
		{
1430
			ShowPlDlg(m_seldev.sYXCode);
1431
		    //?????Ҽ??˵??е???·???????ѡ??ң?ŵ?
1432
			m_pView->m_OperateID=ID_OPT_PL;
1433
		}
1434
		break;
1435
	}
1436
}
1437

    
1438
void CGWnd::OnCmdProtMenu(UINT ID)
1439
{
1440
	unsigned char ret;
1441
    switch (ID){
1442
	case ID_GET_PROTECTVAL:
1443
		{
1444
			CDlgGetPreValue*  pdlg = (CDlgGetPreValue*)g_ehmiMainFrame->GetOptDlg(CTRL_GETPREVAL);
1445
			if(!pdlg)
1446
			{
1447
				pdlg = new CDlgGetPreValue();
1448
				pdlg->Create(IDD_DIALOG_GETPREVALUE,this);
1449
				g_ehmiMainFrame->SetOptDlg(CTRL_GETPREVAL,pdlg);
1450
			}
1451
//			if(m_shapeid == OS_STATUSOBJ && m_seltblid==CString(PROTECT_RDB_TBLNAME))
1452
			if(m_shapeid == OS_STATUSOBJ && m_seltblid==CString(DIGITAL_RDB_TBLNAME))
1453
				ret=pdlg->CreateDlgAccordingDev(m_seldev.sYXCode);
1454
			else
1455
				ret=pdlg->CreateDlgAccordingDev(NULL);
1456
		    if(ret)
1457
				pdlg->ShowWindow(SW_SHOW);
1458
		}
1459
		break;
1460
	case ID_SET_PROTECTVAL:
1461
		{
1462
			CDlgSetPreValue* pdlg = (CDlgSetPreValue *)g_ehmiMainFrame->GetOptDlg(CTRL_SETPREVAL);
1463
			if(!pdlg)
1464
			{
1465
				pdlg = new CDlgSetPreValue();
1466
				pdlg->Create(IDD_DIALOG_SETPREVALUE,this);
1467
				g_ehmiMainFrame->SetOptDlg(CTRL_SETPREVAL,pdlg);
1468
			}
1469
			if(m_shapeid == OS_STATUSOBJ && m_seltblid==CString(DIGITAL_RDB_TBLNAME))
1470
				ret=pdlg->CreateDlgAccordingDev(m_seldev.sYXCode);
1471
			else
1472
				ret=pdlg->CreateDlgAccordingDev(NULL);
1473
			if(ret)
1474
				pdlg->ShowWindow(SW_SHOW);
1475
		}		
1476
		break;
1477
	case ID_RESET_PROTECTVAL:
1478
		{
1479
			CDlgProtReset* pdlg =(CDlgProtReset*)g_ehmiMainFrame->GetOptDlg(CTRL_PROTRESET);
1480
			if(!pdlg)
1481
			{
1482
				pdlg = new CDlgProtReset();
1483
				pdlg->Create(IDD_DIALOG_PROTRESET,this);
1484
				g_ehmiMainFrame->SetOptDlg(CTRL_PROTRESET,pdlg);
1485
			}
1486
			if(m_shapeid == OS_STATUSOBJ && m_seltblid==CString(DIGITAL_RDB_TBLNAME))
1487
				ret=pdlg->CreateDlgAccordingDev(m_seldev.sYXCode);
1488
			else
1489
				ret=pdlg->CreateDlgAccordingDev(NULL);
1490
			if(ret)
1491
				pdlg->ShowWindow(SW_SHOW);
1492
		}
1493
		break;
1494
	case ID_OBJMENU_PROTDEVPARA:
1495
		if( m_shapeid == OS_STATUSOBJ)
1496
			ShowScadaParaDlg(m_seldev.sYXCode,3);
1497
		break;
1498
	}
1499
}
1500

    
1501
void CGWnd::OnPaint() 
1502
{
1503
	CPaintDC dc(this); // device context for painting
1504

    
1505
	CRect rectUpdate;
1506
	dc.GetClipBox(&rectUpdate);
1507

    
1508
	if (m_disp)
1509
	{
1510
		CDC *pDC = m_GraphGUI.GetPopupDC();
1511
		int mode = pDC->SetBkMode(TRANSPARENT);
1512
		COLORREF clr = pDC->SetTextColor(RGB(255, 0, 0));
1513
		pDC->TextOut(10, 0, m_tip);
1514
		pDC->SetTextColor(clr);
1515
		pDC->SetBkMode(mode);
1516
	}
1517

    
1518
	m_GraphGUI.BitBlt2DC(&dc, rectUpdate);
1519

    
1520
	if(m_bTrack && m_cmd == c_zoombox ) {
1521
		CRect oldRect(m_startPt, m_endPt);
1522
		oldRect.NormalizeRect();
1523
		DrawRect(oldRect,&dc);
1524
	}
1525
}
1526

    
1527
void CGWnd::BeginGraphLocalzoom()
1528
{
1529
	m_prevcmd = m_cmd;
1530
	m_cmd = c_zoombox;	
1531
}
1532

    
1533
void CGWnd::BeginGraphPan()
1534
{
1535
	m_prevcmd = m_cmd;
1536
	m_cmd = c_pan;
1537
}
1538

    
1539
void CGWnd::EndGraphOperate()
1540
{
1541
	m_prevcmd = m_cmd;
1542
	m_cmd = c_none;
1543
	OnSetCursor(this, HTCLIENT, 0);
1544
}
1545

    
1546
void CGWnd::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
1547
{
1548
	CWnd::OnKeyDown(nChar, nRepCnt, nFlags);
1549

    
1550
	char * path = g_ehmiMainFrame->GetGraphNameByKey(nChar);
1551
	if(path)
1552
	{
1553
		OpenSvm(path);
1554
		return;
1555
	}
1556
	if(!m_map.IsMapMovable())
1557
		return;
1558

    
1559
	switch (nChar)
1560
	{
1561
		case VK_LEFT:
1562
			m_GraphGUI.Pan(CPoint(0,0), CPoint(-(g_ehmiMainFrame->m_faceSetting.graph_step),0), TRUE);
1563
			break;
1564
		case VK_UP:
1565
			m_GraphGUI.Pan(CPoint(0,0), CPoint(0,-(g_ehmiMainFrame->m_faceSetting.graph_step)), TRUE);
1566
			break;
1567
		case VK_RIGHT:
1568
			m_GraphGUI.Pan(CPoint(0,0), CPoint((g_ehmiMainFrame->m_faceSetting.graph_step),0) , TRUE);
1569
			break;
1570
		case VK_DOWN:
1571
			m_GraphGUI.Pan(CPoint(0,0), CPoint(0,(g_ehmiMainFrame->m_faceSetting.graph_step)), TRUE);
1572
			break;
1573
	}
1574
}
1575

    
1576
LRESULT CGWnd::OnMouseLeave(WPARAM wParam, LPARAM lParam)
1577
{
1578
	m_bTrackLeave = FALSE;            // no longer tracking
1579

    
1580
	if (m_pObjPressed)
1581
	{
1582
		CFRect fRect = m_pObjPressed->GetObjectRect();
1583
		m_pObjPressed->SetObjPressed(FALSE);
1584
		DrawObj(&fRect, &m_pObjPressed->GetObjectRect());
1585
		m_pObjPressed = NULL;
1586
	}
1587

    
1588
	if (m_pObjButton)
1589
	{
1590
		m_pObjButton->OnMouseLeave(wParam, lParam);
1591
		DrawObj(&m_pObjButton->GetObjectRect());
1592
		m_pObjButton = NULL;
1593
	}
1594

    
1595
	g_ehmiMainFrame->m_Tip.Hide();
1596

    
1597
	return 0;
1598
}
1599

    
1600
void CGWnd::OnMouseMove(UINT nFlags, CPoint point) 
1601
{
1602
	//?ű???ִ??Pause??????ʱ??,??û?н???MouseMove?¼?,
1603
	if(g_bSetTipHide == TRUE)//??ʱ?????Ƶ?????ƶ????POINT,PointSelect????????????ָ???쳣???³???????. Yansx 2019-07-16							 
1604
	{
1605
		return;
1606
	}
1607

    
1608
	if (!m_bTrackLeave)
1609
	{
1610
		// First time since mouse entered my window: request leave notification
1611
		TRACKMOUSEEVENT tme;
1612
		tme.cbSize = sizeof(tme);
1613
		tme.hwndTrack = m_hWnd;
1614
		tme.dwFlags = TME_LEAVE;
1615
		_TrackMouseEvent(&tme);
1616
		m_bTrackLeave = TRUE;
1617
	}
1618

    
1619
	BOOL selText = PointSelect(nFlags, point, mouse_move);
1620

    
1621
	if (m_pObjColor && !selText)
1622
	{
1623
		CFRect fRect = m_pObjColor->GetObjectRect();
1624
		fRect.InflateRect(8.0, 2.0);
1625
		((CTextObj *)m_pObjColor)->SetTextColor(m_fgcolor);
1626
		DrawObj(&fRect);
1627
		m_pObjColor = NULL;
1628
	}
1629

    
1630
	if ( m_bTrack )
1631
	{
1632
		switch (m_cmd)
1633
		{
1634
		case c_boxsel:
1635
		case c_zoombox:
1636
			{
1637
				CRect oldRect(m_startPt, m_endPt);
1638
				oldRect.NormalizeRect();
1639
				DrawRect(oldRect);
1640
				m_endPt = point;
1641
				CRect rect(m_startPt, m_endPt);
1642
				rect.NormalizeRect();
1643
				DrawRect(rect);
1644
			}
1645
			break;
1646

    
1647
		case c_pan:
1648
			m_GraphGUI.Pan(m_endPt, point);
1649
			m_endPt = point;
1650
			break;
1651
		}
1652
	}
1653

    
1654
	CWnd::OnMouseMove(nFlags, point);
1655
}
1656

    
1657
BOOL CGWnd::OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message) 
1658
{
1659
	switch( m_cmd )
1660
	{
1661
	case c_pan:
1662
		::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_PAN));
1663
		break;
1664
	case c_pointsel:
1665
		::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_PS));
1666
		break;
1667
	case c_boxsel:
1668
		::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_BS));
1669
		break;
1670
	case c_zoombox:
1671
		::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_ZB));
1672
		break;
1673
	case c_zoomin:
1674
		::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_ZI));
1675
		break;
1676
	case c_zoomout:
1677
		::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_ZO));
1678
		break;
1679
	default:
1680
		{
1681
			int handflag =0;
1682
			//ȡ?ö?Ӧ??ͼԪ
1683
			switch(m_pView->m_OperateID)
1684
			{
1685
			case ID_OPT_YK:	//ң?ز???
1686
			case ID_OPT_SERIALSEL:
1687
				if(m_devid == SE_K_DEV_BREAK 
1688
					|| m_devid==SE_K_DEV_SWITCH 
1689
					|| m_shapeid == OS_STATUSOBJ
1690
//					|| m_seltblid==CString(PROTECT_RDB_TBLNAME))
1691
					|| m_seltblid==CString(DIGITAL_RDB_TBLNAME))
1692
				{
1693
					handflag = 1;	
1694
				}
1695
				break;
1696
			case ID_OPT_YT:
1697
			case ID_OPT_QXTODAY:
1698
			case ID_OPT_QSQX:
1699
				if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)
1700
					&& !kwhflag)
1701
					handflag = 1;	
1702
				break;
1703
			case ID_OPT_MANSET:
1704
			case ID_OPT_CLEARSET:
1705
				if(m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ) 
1706
					  && !kwhflag)
1707
				{
1708
				   handflag = 1;	
1709
				}
1710
				else if(m_devid == SE_K_DEV_BREAK || m_devid==SE_K_DEV_SWITCH || m_shapeid == OS_STATUSOBJ)
1711
						handflag = 1;	
1712
				break;
1713
			case ID_OPT_SCADAPARA:
1714
				if(m_devid == SE_K_DEV_NULL && ( m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)) 
1715
						handflag = 1;	
1716
				else if(m_devid == SE_K_DEV_BREAK || m_devid==SE_K_DEV_SWITCH || m_shapeid == OS_STATUSOBJ)
1717
						handflag = 1;	
1718
				break;
1719
			case ID_OPT_PL:
1720
				if(m_devid == SE_K_DEV_BREAK || m_devid==SE_K_DEV_SWITCH)
1721
						handflag = 1;	
1722
				break;
1723
			case ID_OPT_YXREVERSE:
1724
			case ID_OPT_STOPYXS:
1725
				if(m_devid == SE_K_DEV_BREAK || m_devid==SE_K_DEV_SWITCH 
1726
					|| m_shapeid == OS_STATUSOBJ)
1727
					handflag = 1;	
1728
				break;
1729
			case ID_OPT_ALMCONTRL:
1730
				if(m_devid == SE_K_DEV_BREAK || m_devid==SE_K_DEV_SWITCH 
1731
					|| m_shapeid == OS_STATUSOBJ|| (m_devid == SE_K_DEV_NULL && (m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)))
1732
					handflag = 1;	
1733
				break;
1734
			case ID_OPT_TAG:
1735
				if(m_devid != SE_K_DEV_NULL)
1736
					handflag = 1;	
1737
				break;		
1738
			case ID_OPT_DEVPARA:
1739
				if(m_devid != SE_K_DEV_NULL || m_shapeid == OS_STATUSOBJ)
1740
					handflag = 1;
1741
				break;
1742
			case ID_OPT_REALDATA: //ʵʱ???????
1743
                if(m_devid != SE_K_DEV_NULL || m_shapeid == OS_STATUSOBJ || ((m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)) )
1744
					handflag = 1;			
1745
				break;
1746
			default:
1747
				if(m_shapeid == OS_YAOKONG && RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR))
1748
					handflag = 1;
1749
				//?ȵ㴦??
1750
				if(m_hottype != HLT_UNKNOWN || m_runScript)
1751
					handflag = 1;	
1752
				break;
1753
			}	
1754
			if(handflag == 1)
1755
				::SetCursor(AfxGetApp()->LoadCursor(IDC_CURSOR_HAND));
1756
			else
1757
				return CWnd::OnSetCursor(pWnd, nHitTest, message);
1758
		}
1759
		break;
1760
	}
1761
	return true;	
1762
}
1763

    
1764
void CGWnd::DrawRect(CRect rc,CDC * pdc)  //??????
1765
{
1766
	int noldrop = 0;
1767
	CClientDC dc(this);
1768
	if(pdc == NULL){
1769
		pdc = &dc;
1770
	}
1771
	CPen pen(PS_DASH, 1, RGB(0,0,0));
1772
	noldrop = pdc->SetROP2(R2_NOTXORPEN);
1773
	CPen* pOldPen = pdc->SelectObject(&pen);
1774

    
1775
	pdc->Rectangle(rc);
1776
	pdc->SelectObject(pOldPen);
1777
	pdc->SetROP2(noldrop);
1778
	pen.DeleteObject();
1779
}
1780

    
1781
void CGWnd::DrawTmpLine(CPoint startpt, CPoint endpt)
1782
{
1783
	CClientDC dc(this);
1784
	int noldrop = 0;
1785

    
1786
	CPen pen(PS_DASH, 1, RGB(0,0,0));
1787
	noldrop = dc.SetROP2(R2_NOTXORPEN);
1788
	CPen* pOldPen = dc.SelectObject(&pen);
1789

    
1790
	dc.MoveTo(startpt);
1791
	dc.LineTo(endpt);
1792

    
1793
	dc.SelectObject(pOldPen);
1794
	dc.SetROP2(noldrop);
1795
	pen.DeleteObject();
1796
}
1797

    
1798
void CGWnd::OnLButtonDblClk(UINT nFlags, CPoint point) 
1799
{
1800
	switch(m_cmd)
1801
	{
1802
	case c_zoomout:
1803
		GetGraphGUI()->ZoomOut();
1804
		break;
1805

    
1806
	case c_zoomin:
1807
		GetGraphGUI()->ZoomIn();
1808
		break;
1809

    
1810
	case c_pan:
1811
		EndGraphOperate();
1812
		break;
1813
	}
1814
	PointSelect(nFlags, point, lbtn_db);//WYF 20180806
1815
	CWnd::OnLButtonDblClk(nFlags, point);
1816
}
1817

    
1818
int CGWnd::CreatePlugWnd()
1819
{
1820
	CBaseObjArray  & ObjArray = GetFeatureObjects(OS_PLUG);
1821
	for(int i=0; i < ObjArray.GetSize(); i++)
1822
	{
1823
		CPlugObj * pObj = (CPlugObj*)ObjArray[i];
1824
		if(!pObj)
1825
			continue;
1826

    
1827
		pObj->SetParentWnd(this);
1828
		pObj->SetRunType(TRUE);
1829
		char szGroup[32];
1830
		sprintf(szGroup, "%s", m_pView->GetGroupCode());
1831
		CVGPlugInCore *pPlugin = pObj->CreatePlug(szGroup);
1832
		if (pPlugin)
1833
		{
1834
			m_pView->AddPlugIn(this, pPlugin, pObj->GetObjectName());
1835
		}
1836
	}
1837

    
1838
	return 1;
1839
}
1840

    
1841
BOOL CGWnd::CreateCanvas(RECT rect)
1842
{
1843
	CWnd * pParent = m_pView;
1844

    
1845
	RECT canRect;
1846
	CPopWndDlg *pPopDlg = NULL;
1847
	if (m_wndType != GWND_REPLACE)
1848
	{
1849
		pPopDlg = new CPopWndDlg();
1850

    
1851
		if (!pPopDlg->Create(IDD_DIALOG_POP))
1852
			return FALSE;
1853

    
1854
		if (m_wndType == GWND_OVERLAY)
1855
			pPopDlg->SetChildStyle();
1856

    
1857
		pParent = pPopDlg;
1858
		canRect.left = canRect.top = 0;
1859
		canRect.right = rect.right - rect.left;
1860
		canRect.bottom = rect.bottom - rect.top;
1861
	}
1862
	else
1863
		canRect = rect;
1864

    
1865
	if (GetSafeHwnd() == NULL)
1866
	{
1867
		if (!Create(NULL, NULL, WS_VISIBLE, canRect, pParent, m_wndId, NULL))
1868
			return FALSE;
1869

    
1870
		if (pPopDlg)
1871
		{
1872
			pPopDlg->ShowPopWnd(this, &rect, m_pView->m_screenId);
1873
		}
1874
	}
1875
	else
1876
	{
1877
		MoveWindow(&rect);
1878
	}
1879

    
1880
	return TRUE;
1881
}
1882

    
1883
void CGWnd::InitWndRect(PRECT pRect, PPOINT pPoint)
1884
{
1885
	RECT &rect = m_Rect;
1886

    
1887
	rect = *(pRect && CRect(0, 0, 0, 0) != *pRect ? pRect : m_map.m_rcInit);
1888

    
1889
	if (g_ehmiMainFrame->m_bScale)
1890
	{
1891
		rect.left   *= g_ehmiMainFrame->m_xScale;
1892
		rect.right  *= g_ehmiMainFrame->m_xScale;
1893
		rect.top    *= g_ehmiMainFrame->m_yScale;
1894
		rect.bottom *= g_ehmiMainFrame->m_yScale;
1895
	}
1896

    
1897
	// ????????λ??????????
1898
	if (m_wndType != GWND_REPLACE && pPoint)
1899
	{
1900
		int wide    = rect.right  - rect.left;
1901
		int height  = rect.bottom - rect.top;
1902

    
1903
		rect.left   = pPoint->x;
1904
		rect.right  = rect.left + wide;
1905

    
1906
		int cy = GetSystemMetrics(SM_CYSCREEN);
1907
		int edge = GetSystemMetrics(SM_CYDLGFRAME) * 2 + GetSystemMetrics(SM_CYCAPTION);
1908
		int bottom = pPoint->y + height + edge;
1909

    
1910
		if (bottom < cy)
1911
		{
1912
			rect.top    = pPoint->y;
1913
			rect.bottom = pPoint->y + height;
1914
		}
1915
		else
1916
		{
1917
			rect.top    = cy - edge - height;
1918
			rect.bottom = cy - edge;
1919
		}
1920
	}
1921
}
1922

    
1923
int CGWnd::OpenSvm(const char *path, PRECT pRect /*= NULL*/, PPOINT pPoint /*= NULL*/, LPCTSTR pView /*= NULL*/)
1924
{
1925
	//?ж??ļ??Ƿ????
1926
	if (access(path, 0) == -1)
1927
	{
1928
		MessageBeep(0);
1929
		return 0;
1930
	}
1931

    
1932
	strcpy(m_path, path);
1933
	_splitpath( path, 0, 0, m_title, 0 );
1934

    
1935
	//??ͼ
1936
	if (m_map.OpenPic(path))
1937
	{
1938
		m_wndType = m_map.m_nShowType >= 0 && m_map.m_nShowType <= 2
1939
			? (GWndType)m_map.m_nShowType : GWND_REPLACE;
1940

    
1941
		InitWndRect(pRect, pPoint);
1942

    
1943
		if(!CreateCanvas(m_Rect))
1944
			return 0;
1945
		//++++wyf 2010.03.04 ??ֹ??δ򿪵???m_dcMain?վ??????;
1946
		if (!(m_GraphGUI.hasInitMem()))
1947
		{
1948
			m_GraphGUI.AttachWnd(this->m_hWnd);
1949
			m_GraphGUI.AttachMap(&m_map);
1950
			m_GraphGUI.InitMemDC(NULL);
1951
		}
1952

    
1953
		CreatePlugWnd();
1954

    
1955
		if (pView == NULL || !DrawNameView(pView))
1956
		{
1957
			// ???Ρ??????ŵ?ͼ????ͼ?κ???Ļ??????ͬʱ??????
1958
			if ((m_map.m_nZoomPan && g_ehmiMainFrame->m_bEqual) ||
1959
				(m_map.m_bCanZoom == 0 && g_ehmiMainFrame->m_bScale == 0))
1960
			{
1961
				m_GraphGUI.SetPage(&m_Rect);
1962
				DrawEqual(TRUE);
1963
			}
1964
			else
1965
				m_GraphGUI.ZoomAll();
1966
		}
1967

    
1968
		CollectAllData();
1969

    
1970
        //???¼??ص???ͼ??????Ҫ???رյ???ͼ???л?????ʱ
1971
		if (m_NaviDlg != NULL && m_NaviDlg->m_bClose == FALSE)
1972
		{
1973
			ShowEagleDlg();
1974
		}
1975

    
1976
		if (m_LayDlg != NULL && m_LayDlg->m_bClose == FALSE)
1977
		{
1978
            ShowLayerDlg();
1979
		}
1980

    
1981
		// ???ڴ򿪽ű?
1982
		if (g_ehmiMainFrame->m_bScript && m_map.m_nScriptLenload > 0)
1983
		{
1984
			m_pView->m_Script.ExecString((const char *)m_map.m_pVgScriptDataload, this, true);
1985
		}
1986

    
1987
		s_mapWnd[this] = 1;
1988
	}
1989
	else 
1990
	{//??ͼʧ??
1991
		m_GraphGUI.ZoomAll();
1992

    
1993
		if (this->GetSafeHwnd())
1994
		{
1995
			RECT rect;
1996
			GetClientRect(&rect);
1997
			InvalidateRect(&rect);
1998
		}
1999

    
2000
		return 0;
2001
	}
2002

    
2003
	return 1;
2004
}
2005

    
2006
//???豸??Ϣ???뵽?豸????ȥ
2007
short int CGWnd::AddDevList(CEasyList *devlist, STRUCT_DEVTERMINFO *devcodeinfo)
2008
{
2009
    int i;
2010
	STRUCT_DEVTERMINFO *tmpdevinfo;
2011
	if(strcmp(devcodeinfo->DevCode,"")==0)
2012
		return FALSE;
2013
	if(!devlist)
2014
		return FALSE;
2015
   
2016
	{
2017
		for(i=0;i<devlist->GetListLen();i++)
2018
		{
2019
			tmpdevinfo=(STRUCT_DEVTERMINFO *)devlist->GetNth(i);
2020
			//??????豸?????????Ѵ??ڣ?????
2021
			if(strcmp(tmpdevinfo->DevCode,devcodeinfo->DevCode)==0)
2022
				return FALSE;
2023
		}
2024
	}
2025
	
2026
	devlist->AddLast(devcodeinfo);
2027
	return TRUE;
2028
}
2029

    
2030
void CGWnd::ShowTadayQxDlg(char * obj/*?????*/)
2031
{
2032
	//????ط???Ҫ?޸ģ?Ҫ?鿴??ʷ???߱????н??յ?????
2033

    
2034
	if(g_ehmiMainFrame->GetDlgNum(DEF_REGDLG_TODAYQX) < DEF_REGDLG_ONECOUNT){
2035
		CDlgTodayCurve * qsdlg = new CDlgTodayCurve();
2036
		qsdlg->Create(IDD_DIALOG_QX,this);//wyf
2037
		if(qsdlg->SetYCCode(obj))
2038
			qsdlg->ShowWindow(SW_SHOW);
2039
		else
2040
		{
2041
			g_ehmiMainFrame->DetachDlg(qsdlg,DEF_REGDLG_TODAYQX);
2042
			delete qsdlg;
2043
		}		
2044
	}
2045
}
2046

    
2047
void CGWnd::ShowNewQsDlg(char * obj/*?????*/)
2048
{
2049
	if(g_ehmiMainFrame->GetDlgNum(DEF_REGDLG_QSQX) < DEF_REGDLG_ONECOUNT)
2050
	{
2051
		CDlgYCQSCurve * qsdlg = new CDlgYCQSCurve();
2052
		qsdlg->Create(IDD_DIALOG_QSQX,this);
2053
       
2054
		if(qsdlg->SetYCCode(obj))
2055
			qsdlg->ShowWindow(SW_SHOW);
2056
		else
2057
		{
2058
			g_ehmiMainFrame->DetachDlg(qsdlg,DEF_REGDLG_QSQX);
2059
			delete qsdlg;
2060
		}
2061
	}
2062
}
2063

    
2064
void CGWnd::ShowDevRealPntDlg(char * obj/*?豸????*/)
2065
{
2066
	if (g_ehmiMainFrame->m_uniCtrl)
2067
	{
2068
	//Added by xzf20180627
2069
		if(obj && ((strlen(m_seldev.sYXCode)!=0) ||(strlen(m_seldev.sDevCode)!=0)))
2070
		{	
2071
			
2072
			if ( m_selCtrlType == 1 && CheckAoj(m_seldev.sYXCode,  p_do,  DEF_RIGHT_DEVICE_C) ||
2073
						m_selCtrlType == 2 && CheckAoj(m_seldev.sDevCode, p_dev, DEF_RIGHT_DEVICE_C))
2074
			{
2075
			
2076
				ShowCtrlDlg(Ctrl, obj);
2077
			}
2078
			else
2079
	//Added by xzf20180627
2080
			{	//wyf 20181103 ???⴦??????ͼԪ?????õġ??豸???ӡ?code??TB1004?в?????ʱ??????IDD_MMI_YK????
2081
				CString sql;
2082
				sql.Format("select F1004_DEVDESC from SEMODEL.TB1004_DEVICE where F1004_DEVCODE = '%s'", m_seldev.sDevCode);			
2083
				CSE_DBOption dbo;
2084
				dbo.BeginSelectRcdSet(sql.GetBuffer(0));
2085
				if (dbo.GetRcdCount() > 0)//wyf 20181103
2086
				ShowCtrlDlg(Real, obj);
2087
			}
2088
		}
2089
	}
2090
	else
2091
	if(g_ehmiMainFrame->GetDlgNum(DEF_REGDLG_REALPNT) < DEF_REGDLG_ONECOUNT)
2092
	{
2093

    
2094
		CDlgDevRealPnt * dlg = new CDlgDevRealPnt();
2095
		dlg->Create(IDD_DIALOG_DEVREALPNT,this);
2096
		if(dlg->SetDevCode(obj))
2097
		{
2098
			dlg->ShowWindow(SW_SHOW);
2099
		}
2100
		else
2101
		{
2102
			g_ehmiMainFrame->DetachDlg(dlg,DEF_REGDLG_REALPNT);
2103
			delete dlg;
2104
		}
2105
		
2106
	}
2107
}
2108
void CGWnd::ShowScadaParaDlg(char * obj/*?????*/,int YCFlag)
2109
{
2110
	CJKPropertyDlg * pDlg = g_ehmiMainFrame->pQueryDlg; 
2111
	if(!pDlg)return;
2112
	CPointItemArray aryPointItem;
2113
	if (GetLogicDataSet(aryPointItem))
2114
	{
2115
		pDlg->AnotherQuery(aryPointItem);
2116
	}
2117
	else
2118
	{
2119
		int devtype;
2120
		if(YCFlag == 1){
2121
			devtype = DEF_YC_SIMILARDEV;
2122
		}
2123
		else if(YCFlag == 2){
2124
			devtype = DEF_KWH_SIMILARDEV;
2125
		}
2126
		else if(YCFlag==3)
2127
			devtype=DEF_PROTDEV_SIMILARDEV;
2128
		else 
2129
			devtype = DEF_YX_SIMILARDEV;
2130
		CString str = obj;
2131
		pDlg->AnotherQuery(devtype,str);
2132
	}
2133
	pDlg->ShowWindow(SW_NORMAL); 
2134
}
2135

    
2136
void CGWnd::ShowDevParaDlg(char * obj/*?豸????*/)
2137
{
2138
	CJKPropertyDlg * pDlg = g_ehmiMainFrame->pQueryDlg; 
2139
	if(!pDlg)return;
2140

    
2141
	int devtype;
2142
	devtype = GetDevType(obj);
2143
	CString str = obj;
2144
	pDlg->AnotherQuery(devtype,str);
2145
	pDlg->ShowWindow(SW_NORMAL); 
2146
}
2147
void CGWnd::ShowDevParaDlgByYXCode(char* yxcode)
2148
{
2149
	CSE_DBOption dboption;
2150
	SEDB_CMDINFO cmdinfo;
2151
	SEDB_DATAFMT *datafmt=NULL;
2152
	char cmdbuf[1256];
2153
	int i,count;
2154
	
2155
	//?????????????ȡ?豸????
2156
	sprintf(cmdinfo.table,"%s.dbo.%s",SCADA_PARALIB,YX_PARA_TBLNAME);
2157
	
2158
	char * Field[] = {"F1004_DEVCODE"};
2159
	
2160
	strcpy(cmdbuf,"select ");
2161
	for(i=0;i<sizeof(Field)/sizeof(char *);i++){
2162
		strcat(cmdbuf,Field[i]);
2163
		if(i<(sizeof(Field)/sizeof(char *)-1))strcat(cmdbuf,",");
2164
	}
2165
	strcat(cmdbuf," from ");
2166
	strcat(cmdbuf,cmdinfo.table);
2167
	strcat(cmdbuf," where F4009_POINTCODE='");
2168
	strcat(cmdbuf, yxcode);
2169
	strcat(cmdbuf,"'");
2170
	
2171
	dboption.BeginSelectRcdSet(cmdbuf);
2172
	count = dboption.GetRcdCount();
2173
	if(count <=0){
2174
		AfxMessageBox("???󲻴???????????豸????!");
2175
		dboption.EndSelectRcdSet();
2176
		return ;
2177
	}
2178
	char devcode[DEF_OBJCODE_LEN];
2179
	strcpy(devcode,dboption.GetStringVal(0,0));
2180
	dboption.EndSelectRcdSet();
2181

    
2182
	if(devcode[0] !=0)
2183
	{
2184
		ShowDevParaDlg(devcode);
2185
	}
2186
	
2187
}
2188
void CGWnd::ShowDevRealPntDlgByKWHCode(char *KWHcode)
2189
{
2190
   //????ң?Ŵ???ȡ?ö?Ӧ?豸??ʵʱ???ݵ?????
2191
    if(strcmp(KWHcode,"") == 0)
2192
		return;
2193

    
2194
	CSE_DBOption dboption;
2195
	SEDB_CMDINFO cmdinfo;
2196
	SEDB_DATAFMT *datafmt=NULL;
2197
	char cmdbuf[1256];
2198
	int i,count;
2199
	
2200
	//?????????????ȡ?豸????
2201
	sprintf(cmdinfo.table,"%s.dbo.%s",SCADA_PARALIB,KWH_PARA_TBLNAME);
2202
	
2203
	char * Field[] = {"F1004_DEVCODE"};
2204
	
2205
	strcpy(cmdbuf,"select ");
2206
	for(i=0;i<sizeof(Field)/sizeof(char *);i++){
2207
		strcat(cmdbuf,Field[i]);
2208
		if(i<(sizeof(Field)/sizeof(char *)-1))strcat(cmdbuf,",");
2209
	}
2210
	strcat(cmdbuf," from ");
2211
	strcat(cmdbuf,cmdinfo.table);
2212
	strcat(cmdbuf," where F4014_POINTCODE='");
2213
	strcat(cmdbuf, KWHcode);
2214
	strcat(cmdbuf,"'");
2215
	
2216
	dboption.BeginSelectRcdSet(cmdbuf);
2217
	count = dboption.GetRcdCount();
2218
	if(count <=0){
2219
		AfxMessageBox("???󲻴???????????豸????!");
2220
		dboption.EndSelectRcdSet();
2221
		return ;
2222
	}
2223
	char devcode[DEF_OBJCODE_LEN];
2224
	strcpy(devcode,dboption.GetStringVal(0,0));
2225
	dboption.EndSelectRcdSet();
2226

    
2227
	if(devcode[0] !=0)
2228
	{
2229
		ShowDevRealPntDlg(devcode);
2230
	}
2231
}
2232
void CGWnd::ShowDevRealPntDlgByYCCode(char* yccode)
2233
{
2234
	//????ң?Ŵ???ȡ?ö?Ӧ?豸??ʵʱ???ݵ?????
2235
    if(strcmp(yccode,"") == 0)
2236
		return;
2237

    
2238
	CSE_DBOption dboption;
2239
	SEDB_CMDINFO cmdinfo;
2240
	SEDB_DATAFMT *datafmt=NULL;
2241
	char cmdbuf[1256];
2242
	int i,count;
2243
	
2244
	//?????????????ȡ?豸????
2245
	sprintf(cmdinfo.table,"%s.dbo.%s",SCADA_PARALIB,YC_PARA_TBLNAME);
2246
	
2247
	char * Field[] = {"F1004_DEVCODE"};
2248
	
2249
	strcpy(cmdbuf,"select ");
2250
	for(i=0;i<sizeof(Field)/sizeof(char *);i++){
2251
		strcat(cmdbuf,Field[i]);
2252
		if(i<(sizeof(Field)/sizeof(char *)-1))strcat(cmdbuf,",");
2253
	}
2254
	strcat(cmdbuf," from ");
2255
	strcat(cmdbuf,cmdinfo.table);
2256
	strcat(cmdbuf," where F4007_POINTCODE='");
2257
	strcat(cmdbuf, yccode);
2258
	strcat(cmdbuf,"'");
2259
	
2260
	dboption.BeginSelectRcdSet(cmdbuf);
2261
	count = dboption.GetRcdCount();
2262
	if(count <=0){
2263
		AfxMessageBox("???󲻴???????????豸????!");
2264
		dboption.EndSelectRcdSet();
2265
		return ;
2266
	}
2267
	char devcode[DEF_OBJCODE_LEN];
2268
	strcpy(devcode,dboption.GetStringVal(0,0));
2269
	dboption.EndSelectRcdSet();
2270

    
2271
	if(devcode[0] !=0)
2272
	{
2273
		ShowDevRealPntDlg(devcode);
2274
	}
2275
	
2276
}
2277
void CGWnd::ShowDevRealPntDlgByYXCode(char* yxcode)
2278
{
2279
	//????ң?Ŵ???ȡ?ö?Ӧ?豸??ʵʱ???ݵ?????
2280
    if(strcmp(yxcode,"") == 0)
2281
		return;
2282

    
2283
	CSE_DBOption dboption;
2284
	SEDB_CMDINFO cmdinfo;
2285
	SEDB_DATAFMT *datafmt=NULL;
2286
	char cmdbuf[1256];
2287
	int i,count;
2288
	
2289
	//?????????????ȡ?豸????
2290
	sprintf(cmdinfo.table,"%s.dbo.%s",SCADA_PARALIB,YX_PARA_TBLNAME);
2291
	
2292
	char * Field[] = {"F1004_DEVCODE"};
2293
	
2294
	strcpy(cmdbuf,"select ");
2295
	for(i=0;i<sizeof(Field)/sizeof(char *);i++){
2296
		strcat(cmdbuf,Field[i]);
2297
		if(i<(sizeof(Field)/sizeof(char *)-1))strcat(cmdbuf,",");
2298
	}
2299
	strcat(cmdbuf," from ");
2300
	strcat(cmdbuf,cmdinfo.table);
2301
	strcat(cmdbuf," where F4009_POINTCODE='");
2302
	strcat(cmdbuf, yxcode);
2303
	strcat(cmdbuf,"'");
2304
	
2305
	dboption.BeginSelectRcdSet(cmdbuf);
2306
	count = dboption.GetRcdCount();
2307
	if(count <=0){
2308
		AfxMessageBox("???󲻴???????????豸????!");
2309
		dboption.EndSelectRcdSet();
2310
		return ;
2311
	}
2312
	char devcode[DEF_OBJCODE_LEN];
2313
	strcpy(devcode,dboption.GetStringVal(0,0));
2314
	dboption.EndSelectRcdSet();
2315

    
2316
	if(devcode[0] !=0)
2317
	{
2318
		ShowDevRealPntDlg(devcode);
2319
	}
2320
	
2321
}
2322

    
2323
void CGWnd::ShowYKDlg(STRUCT_DEVBASEINFO devinfo)
2324
{
2325
	char* obj = devinfo.sYXCode;
2326
	if(obj == 0)
2327
		return;
2328

    
2329
	CDialog* ytdlg  = g_ehmiMainFrame->GetOptDlg(CTRL_YTDLG);
2330
	CDialog* yt2dlg = g_ehmiMainFrame->GetOptDlg(CTRL_YTAODLG);
2331

    
2332
	if (ytdlg && ytdlg->IsWindowVisible() || yt2dlg && yt2dlg->IsWindowVisible())
2333
	{
2334
		AfxMessageBox("????ͬʱ????ң?غ?ң??????");
2335
		return;
2336
	}
2337

    
2338
	CMMIYKDlg * ykdlg = (CMMIYKDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_YKDLG);
2339
	if(!ykdlg){
2340
		ykdlg = new CMMIYKDlg(this);
2341
		ykdlg->Create(IDD_MMI_YK,this);
2342
		g_ehmiMainFrame->SetOptDlg(CTRL_YKDLG,ykdlg);
2343
	}
2344
	else
2345
	{
2346
		//?õ?Ԥ?ð?ť״̬
2347
		int bItemEnable = (ykdlg->GetDlgItem(IDC_BTN_YKYZ))->IsWindowEnabled();
2348
		int bDlgEnable = ykdlg->IsWindowVisible();
2349
		if(!bItemEnable&&bDlgEnable)
2350
			return;
2351
	}
2352
	ykdlg->SetPara (obj);
2353
	ykdlg->SetRelYxFlag(g_ehmiMainFrame->m_faceSetting.yk_relyx); 
2354

    
2355
//??ʱ????????? 2006.10
2356
/*
2357
	//????ǿ??ػ????ǵ?բ????????ļ???
2358
	CRdbCltAccess ra;
2359
	SRDB_PARAINFO rdbpara[1];
2360
	int valnum=0;
2361
	if(strcmp(ykdlg->rdbtblname,BREAK_RDB_TBLNAME)==0 ||strcmp(ykdlg->rdbtblname,SWITCH_RDB_TBLNAME)==0)
2362
	{
2363
		strcpy(rdbpara[0].tbl, EPS_RDB_TBLNAME);
2364
		strcpy(rdbpara[0].obj,devinfo.sDevCode);
2365
		strcpy(rdbpara[0].field,"fiveInf");
2366
		ra.SetUserPwd("guest","");
2367
		valnum = ra.SendGetDataPara (1, rdbpara);
2368
	}
2369
	if(valnum>0)
2370
	{
2371
		int fivelock;
2372
		int tmprawno = ra.GetIntVal(0,fivelock);
2373
		if(fivelock!=0)
2374
		{
2375
			CString str;
2376
			//str.Format(_T("????:\r\n    %s\r\n    ?Ƿ?Ҫ????ң?ش˿????!"),DevStatusExp.GetFiveInf(fivelock));
2377
			str.Format(_T("????:\r\n    %s!"),DevStatusExp.GetFiveInf(fivelock));//FIVECHECK___20060627
2378
			WarningDlg dlg(this);
2379
			dlg.SetInfo(str);
2380
			dlg.SetSndInfo(DevStatusExp.GetFiveInf(fivelock));//FIVECHECK___20060627
2381
			if(dlg.DoModal() == IDCANCEL)
2382
			{
2383
				return;
2384
			}
2385
		}
2386
	}
2387
*/
2388

    
2389
	if(ykdlg->GetSuperviseFlag() == SE_K_SUPERVISETYPE_ACK_OTHER){
2390
		char userName[RBAC_K_USER_NAME_LEN] = "";
2391
		char userDesc[RBAC_K_USER_DESCRIPTION_LEN] = "";
2392
		if(!RBAC_SpecLogin(DEF_RIGHT_OPERATOR, userName, userDesc))
2393
		{
2394
				char Text[400];
2395
				sprintf(Text,"?Բ???%sû??ң?ؼල??Ȩ??", userDesc);
2396
				AfxMessageBox(Text);
2397
				return;
2398
		}
2399
		ykdlg->SetSuperviseMan(userName);
2400
	}
2401
	else if(g_ehmiMainFrame->m_faceSetting.yk_needlogin ){
2402
		if(RBAC_Login(NULL, 3, true)){
2403
			if(!RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR)){
2404
				AfxMessageBox("?Բ?????û??ң?ص?Ȩ??");
2405
				return;
2406
			}
2407
		}
2408
		else {
2409
				return;
2410
		}
2411
	}
2412
	if(ykdlg->ykok) ykdlg->ShowWindow (SW_SHOW);
2413
}
2414
void CGWnd::ShowAlarmCtrl(char *obj/*?????*/,char objtype)
2415
{
2416
	CAlarmCtrl * almlibCtrlDlg= (CAlarmCtrl*) g_ehmiMainFrame->GetOptDlg(CTRL_ALMlibCtrlDlg);
2417
	if(!almlibCtrlDlg)
2418
	{
2419
		almlibCtrlDlg = new CAlarmCtrl(this);
2420
		almlibCtrlDlg->Create(IDD_MMI_ALMCTRL,this);
2421
		g_ehmiMainFrame->SetOptDlg(CTRL_ALMlibCtrlDlg,almlibCtrlDlg);
2422
	}
2423
	almlibCtrlDlg->SetPara(obj,objtype);
2424
	almlibCtrlDlg->ShowWindow (SW_SHOW);
2425
}
2426

    
2427
void CGWnd::ShowYTDlg(char * obj/*?????*/)
2428
{
2429
	char cmdbuf[256];
2430
	sprintf(cmdbuf, "select F4008_SUPERVISE, F4008_CTRLACTION, F4007_POINTDESC from %s a, %s b"
2431
		" where a.F4007_POINTCODE = '%s' and b.F4007_POINTCODE = a.F4007_POINTCODE",
2432
		YT_PARA_TBLNAME, YC_PARA_TBLNAME, obj);
2433

    
2434
	CSE_DBOption dboption;
2435
	dboption.BeginSelectRcdSet(cmdbuf);
2436
	int count = dboption.GetRcdCount();
2437
	if (count <= 0)
2438
	{
2439
		AfxMessageBox("??????AO???????в?????!");
2440
		return;
2441
	}
2442

    
2443
	int supervise   = *(BYTE *)dboption.GetColVal(0, 0);
2444
	int ctrlAction  = *(BYTE *)dboption.GetColVal(0, 1);
2445
	char *pointDesc = (char *)dboption.GetColVal(0, 2);
2446

    
2447
	if (supervise == SE_K_SUPERVISETYPE_ACK_SELF)
2448
	{
2449
		CString msg;
2450
		msg.Format("????ȷ???Ƿ?Ҫ?ԡ?%s?????е??ڣ?", pointDesc);
2451

    
2452
		if (MessageBox(msg, "????ȷ??", MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON2)
2453
			!= IDOK)
2454
			return;
2455
	}
2456

    
2457
	if (ctrlAction != 0 && ctrlAction != 1)
2458
		return;
2459

    
2460
	CDialog * ykdlg  = g_ehmiMainFrame->GetOptDlg(CTRL_YKDLG);
2461
	CDialog * yk2dlg = g_ehmiMainFrame->GetOptDlg(CTRL_YKDODLG);
2462

    
2463
	if (ykdlg && ykdlg->IsWindowVisible() || yk2dlg && yk2dlg->IsWindowVisible())
2464
	{
2465
		AfxMessageBox("????ͬʱ????ң?غ?ң??????");
2466
		return;
2467
	}
2468

    
2469
	CBaselibCtrlDlg * ytdlg = (CBaselibCtrlDlg *)
2470
		g_ehmiMainFrame->GetOptDlg(ctrlAction ? CTRL_YTDLG : CTRL_YTAODLG);
2471
	if(!ytdlg){
2472
		ctrlAction ? ytdlg = new CMMIYTDlg() : ytdlg = new CMMIYTAODlg();
2473
		ytdlg->Create(ctrlAction ? IDD_MMI_YT : IDD_MMI_YTAO,this);
2474
		g_ehmiMainFrame->SetOptDlg(ctrlAction ? CTRL_YTDLG : CTRL_YTAODLG,ytdlg);
2475
	}
2476
	ytdlg->SetPara (obj);
2477

    
2478
	int flag;
2479
	if (ctrlAction)
2480
		flag = ((CMMIYTDlg *)ytdlg)->GetSuperviseFlag();
2481
	else
2482
		flag = ((CMMIYTAODlg *)ytdlg)->GetSuperviseFlag();
2483

    
2484
	if(flag == SE_K_SUPERVISETYPE_ACK_OTHER){
2485
		char userName[RBAC_K_USER_NAME_LEN];
2486
		char userDesc[RBAC_K_USER_DESCRIPTION_LEN];
2487
		if(!RBAC_SpecLogin(DEF_RIGHT_OPERATOR, userName, userDesc))
2488
		{
2489
				char Text[400];
2490
				sprintf(Text,"?Բ???%sû??ң???ල??Ȩ??",userDesc);
2491
				AfxMessageBox(Text);
2492
				return;
2493
		}
2494
		if (ctrlAction)
2495
			((CMMIYTDlg *)ytdlg)->SetSuperviseMan(userName);
2496
		else
2497
			((CMMIYTAODlg *)ytdlg)->SetSuperviseMan(userName);
2498
	}
2499
	else if(g_ehmiMainFrame->m_faceSetting.yk_needlogin){
2500
		if(RBAC_Login(NULL, 3, true)){
2501
			if(!RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR)){
2502
				AfxMessageBox("?Բ?????û??ң????Ȩ??");
2503
				return;
2504
			}
2505
		}
2506
		else {
2507
				return;
2508
		}
2509
	}  
2510
	if(ctrlAction ? ((CMMIYTDlg *)ytdlg)->ytok : ((CMMIYTAODlg *)ytdlg)->ytok)
2511
		ytdlg->ShowWindow (SW_SHOW);
2512
}
2513

    
2514
// ȫͼͣ??
2515
typedef CArray<CSI_D_CLEARFLASH, CSI_D_CLEARFLASH&> CFlashObjArray;
2516
void CGWnd::StopFlash()
2517
{
2518
	CFlashObjArray aryFlashObj;	
2519
	char YCCode[DEF_OBJCODE_LEN];	
2520
	STRUCT_DEVBASEINFO DevInfo;
2521

    
2522
	if (!g_ehmiMainFrame->scdclient)
2523
	{
2524
		return;
2525
	}
2526

    
2527
	int nCount = m_rdbdata.GetUnitNum();
2528
	int i = 0;
2529
	for ( i = 0; i < nCount; i++)
2530
	{
2531
		ST_VISITRDB *pdata = (ST_VISITRDB *)m_rdbdata.GetUnit(i);
2532
		if (pdata == NULL)
2533
		{
2534
			continue;
2535
		}
2536
		SREALDB_VAR * pvar = &(pdata->sval);
2537
		unsigned int status = pvar->m_val.uintval;
2538
		if (PT_IS_FLASHING(status))
2539
		{
2540
			if (pdata->flag == ehmi_FRESH_YCSTATUS)
2541
			{
2542
				// ??ǰ??????????ң??ֹͣ??˸
2543
				CYaoCeObj *pYC = (CYaoCeObj *)pdata->obj;
2544
				strncpy(YCCode, pYC->GetYCCode(), DEF_OBJCODE_LEN - 1);
2545
				if (CheckAoj(YCCode, p_ai, DEF_RIGHT_DEVICE_S))
2546
				{
2547
					CSI_D_CLEARFLASH FlashObj;
2548
					strcpy(FlashObj.TableName, ANA_RDB_TBLNAME);
2549
					strcpy(FlashObj.ObjectCode, YCCode);
2550
					aryFlashObj.Add(FlashObj);
2551
				}
2552
			}
2553
			else if (pdata->flag == ehmi_FRESH_YXSTATUS)
2554
			{
2555
				// ??ǰ??????????ң??ֹͣ??˸
2556
				CPointDevice *pDev = (CPointDevice *)pdata->obj;
2557
				pDev->GetDevInfo(DevInfo);
2558
				if (CheckAoj(DevInfo.sYXCode, p_di, DEF_RIGHT_DEVICE_S))
2559
				{
2560
					CSI_D_CLEARFLASH FlashObj;
2561
					strcpy(FlashObj.TableName, DIGITAL_RDB_TBLNAME);
2562
					strcpy(FlashObj.ObjectCode, DevInfo.sYXCode);
2563
					aryFlashObj.Add(FlashObj);					
2564
				}
2565
			}
2566
		}		
2567
	}
2568
	int nSize = aryFlashObj.GetSize();
2569
	if (nSize > 0)
2570
	{
2571
		int nLen = nSize * sizeof(CSI_D_CLEARFLASH);
2572
		CSI_D_CLEARFLASH *pFlashObj = (CSI_D_CLEARFLASH *)malloc(nLen);
2573

    
2574
		for (i = 0; i < aryFlashObj.GetSize(); i++)
2575
		{
2576
			CSI_D_CLEARFLASH FlashObj = (CSI_D_CLEARFLASH )aryFlashObj.GetAt(i);
2577
			memcpy(pFlashObj + i, &FlashObj, sizeof(CSI_D_CLEARFLASH));
2578
		}
2579
		g_ehmiMainFrame->scdclient->ClearFlashing(g_ehmiMainFrame->m_user, nSize, pFlashObj);
2580
		
2581
		free(pFlashObj);
2582
	}	
2583
}
2584

    
2585
void CGWnd::StopYcFlash(char * obj/*?????*/)
2586
{
2587
	if(!g_ehmiMainFrame->scdclient || obj==NULL)return;
2588

    
2589
	int val,status;
2590
	if (GetYCValue(obj, val, status))
2591
	{
2592
		if (PT_IS_FLASHING(status))
2593
		{
2594
			g_ehmiMainFrame->scdclient->ClearFlashing(g_ehmiMainFrame->m_user, ANA_RDB_TBLNAME, obj);
2595
		}
2596
	}	
2597
}
2598

    
2599
void CGWnd::StopYxFlash(char * obj/*?????*/)
2600
{
2601
	if (!g_ehmiMainFrame->scdclient || obj == NULL)return;
2602

    
2603
	int val,status;
2604
	char rdbtblname[DEF_OBJCODE_LEN];
2605
	if (GetYXValue(obj, val, status, rdbtblname))
2606
	{
2607
		if(PT_IS_FLASHING(status))
2608
		{
2609
			g_ehmiMainFrame->scdclient->ClearFlashing(g_ehmiMainFrame->m_user,rdbtblname,obj);
2610
		}
2611
	}
2612
}
2613
void CGWnd::ManageKGBH(char* obj/*?????*/)
2614
{
2615
	if(obj==NULL)
2616
		return;
2617

    
2618
	int val,status;
2619
	char rdbtablename[DEF_OBJCODE_LEN];
2620
	if(GetYXValue(obj,val,status,rdbtablename))
2621
	{
2622
		ManageKGBHDlg * kgbhdlg = (ManageKGBHDlg  *)g_ehmiMainFrame->GetOptDlg(CTRL_MANAGEKGBHDLG);
2623
		if(!kgbhdlg){
2624
			kgbhdlg = new ManageKGBHDlg();
2625
			kgbhdlg->Create(IDD_DIALOG_MANAGEKGBH,this);
2626
			g_ehmiMainFrame->SetOptDlg(CTRL_MANAGEKGBHDLG,kgbhdlg);
2627
		}
2628
		kgbhdlg->setpara(g_ehmiMainFrame->m_user,obj,rdbtablename);
2629
		kgbhdlg->ShowWindow(SW_SHOW);
2630
	}
2631
	else
2632
	{
2633
		AfxMessageBox("??????ʵʱ???в?????!");
2634
	}
2635
}
2636

    
2637
void CGWnd::SetYxReturn(STRUCT_DEVBASEINFO devinfo)
2638
{
2639
	char *obj = devinfo.sYXCode;
2640
	if(!g_ehmiMainFrame->scdclient || obj==NULL)return;
2641
	int val,status;
2642
	char rdbtblname[DEF_OBJCODE_LEN];
2643

    
2644
// ??ʱ?????????
2645
/*
2646
	//????ǿ??ػ?բ??????????????
2647
	CRdbCltAccess ra;
2648
	SRDB_PARAINFO rdbpara[1];
2649
	int valnum=0;
2650
	//??ǰ?豸???????ǿ??ػ????ǵ?բ
2651
	if(m_devid == SE_K_DEV_BREAK
2652
		||m_devid==SE_K_DEV_SWITCH)
2653
	{
2654
		strcpy(rdbpara[0].tbl, EPS_RDB_TBLNAME);
2655
		strcpy(rdbpara[0].obj,devinfo.sDevCode);
2656
		strcpy(rdbpara[0].field,"fiveInf");
2657
		ra.SetUserPwd("guest","");
2658
		valnum = ra.SendGetDataPara (1, rdbpara,SourceRealData);
2659
	}
2660
	
2661
	if(valnum>0)
2662
	{
2663
		int fivelock;
2664
		int tmprawno = ra.GetIntVal(0,fivelock);
2665
		if(fivelock!=0)
2666
		{
2667
			CString str;
2668
			//str.Format(_T("????:\r\n    %s\r\n    ?Ƿ?Ҫ?????????˿????!"),DevStatusExp.GetFiveInf(fivelock));
2669
			str.Format(_T("????:\r\n    %s!"),DevStatusExp.GetFiveInf(fivelock));//FIVECHECK___20060627
2670
			WarningDlg dlg(this);
2671
			dlg.SetInfo(str);
2672
			dlg.SetSndInfo(DevStatusExp.GetFiveInf(fivelock));//FIVECHECK___20060627
2673
			
2674
			if(dlg.DoModal() == IDCANCEL)
2675
			{
2676
				return;
2677
			}
2678
		}
2679
	}
2680
*/
2681

    
2682
	CPointItemArray aryPointItem;
2683
	if (GetLogicDataSet(aryPointItem))
2684
	{
2685
		CDlgManSetYx dlg(this, aryPointItem);
2686
		dlg.DoModal();
2687
	}
2688
	else
2689
	{
2690
		if(GetYXValue(obj,val,status,rdbtblname))
2691
		{
2692
			uchar setval = 1;
2693
			if(val) setval = 0;
2694
			g_ehmiMainFrame->scdclient->ManualEntry(g_ehmiMainFrame->m_user,rdbtblname,obj,REALDB_UCHAR,&setval,0);
2695
		}
2696
	}
2697
}
2698
void CGWnd::ShowManSetDlg(STRUCT_DEVBASEINFO devinfo,int YCFlag)
2699
{
2700
	if(YCFlag)
2701
	{
2702
		return;
2703
	}
2704
	char* obj = devinfo.sYXCode; 
2705

    
2706
// ??ʱ?????????
2707
/*
2708
	//????ǿ??ػ?բ??????????????
2709
	CRdbCltAccess ra;
2710
	SRDB_PARAINFO rdbpara[1];
2711
	int valnum=0;
2712
	//??ǰ?豸???????ǿ??ػ????ǵ?բ
2713
	if(m_devid == SE_K_DEV_BREAK
2714
		||m_devid==SE_K_DEV_SWITCH)
2715
	{
2716
		strcpy(rdbpara[0].tbl, EPS_RDB_TBLNAME);
2717
		strcpy(rdbpara[0].obj,devinfo.sDevCode);
2718
		strcpy(rdbpara[0].field,"fiveInf");
2719
		ra.SetUserPwd("guest","");
2720
		valnum = ra.SendGetDataPara (1, rdbpara,SourceRealData);
2721
	}
2722
	
2723
	if(valnum>0)
2724
	{
2725
		int fivelock;
2726
		int tmprawno = ra.GetIntVal(0,fivelock);
2727
		if(fivelock!=0)
2728
		{
2729
			CString str;
2730
			//str.Format(_T("????:\r\n    %s\r\n    ?Ƿ?Ҫ?????????˿????!"),DevStatusExp.GetFiveInf(fivelock));
2731
			str.Format(_T("????:\r\n    %s!"),DevStatusExp.GetFiveInf(fivelock));//FIVECHECK___20060627
2732
			WarningDlg dlg(this);
2733
			dlg.SetInfo(str);
2734
			dlg.SetSndInfo(DevStatusExp.GetFiveInf(fivelock));//FIVECHECK___20060627
2735
			if(dlg.DoModal() == IDCANCEL)
2736
			{
2737
				return;
2738
			}
2739
		}
2740
	}
2741
*/
2742

    
2743

    
2744
	CMMIYXZRDlg * yxmansetdlg = (CMMIYXZRDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_YXDLG);
2745
	if(!yxmansetdlg){
2746
		yxmansetdlg = new CMMIYXZRDlg();
2747
		yxmansetdlg->Create(IDD_MMI_YXZR,this);
2748
		g_ehmiMainFrame->SetOptDlg(CTRL_YXDLG,yxmansetdlg);
2749
	}
2750
	SetSysCtrlPara(NULL,NULL);
2751
	{
2752
		yxmansetdlg->SetPara(obj);
2753
	}
2754
	yxmansetdlg->ShowWindow (SW_SHOW);
2755
}
2756
void CGWnd::ShowManSetDlg(char *obj,int YCFlag)
2757
{
2758
	if(YCFlag){
2759
		CMMIYCZRDlg * ycmansetdlg = (CMMIYCZRDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_YCDLG);
2760
		if(!ycmansetdlg){
2761
			ycmansetdlg = new CMMIYCZRDlg();
2762
			ycmansetdlg->Create(IDD_MMI_YCZR,this);
2763
			g_ehmiMainFrame->SetOptDlg(CTRL_YCDLG,ycmansetdlg);
2764
		}
2765
		ycmansetdlg->SetPara(obj);
2766
		ycmansetdlg->ShowWindow (SW_SHOW);
2767
	}
2768

    
2769
}
2770
void CGWnd::ClearManSet(char * obj/*?????*/,int YCFlag)
2771
{
2772
	if(!g_ehmiMainFrame->scdclient || obj==NULL)return;
2773
	int val,status;
2774
	char rdbtblname[DEF_OBJCODE_LEN];
2775
	if(YCFlag){
2776
		if(GetYCValue(obj,val,status)){
2777
			if(PT_IS_MAN_VAL(status)){//Ӧ?ж??Ƿ???????״̬
2778
				g_ehmiMainFrame->scdclient->Activate(g_ehmiMainFrame->m_user,ANA_RDB_TBLNAME,obj);
2779
			}
2780
		}
2781
	}
2782
	else{
2783
		CPointItemArray aryPointItem;
2784
		if (GetLogicDataSet(aryPointItem))
2785
		{
2786
			for (int i = 0; i < aryPointItem.GetSize(); i++)
2787
			{
2788
				POINTITEM Item = (POINTITEM)aryPointItem.GetAt(i);
2789
				obj = Item.PointCode;
2790
				if (GetYXValue(obj, val, status, rdbtblname))
2791
				{
2792
					if (PT_IS_MAN_VAL(status))
2793
					{
2794
						// Ӧ?ж??Ƿ???????״̬
2795
						g_ehmiMainFrame->scdclient->Activate(g_ehmiMainFrame->m_user,rdbtblname,obj);
2796
					}
2797
				}
2798
			}
2799
		}
2800
		else
2801
		{
2802
			if (GetYXValue(obj, val, status, rdbtblname))
2803
			{
2804
				if (PT_IS_MAN_VAL(status))
2805
				{
2806
					// Ӧ?ж??Ƿ???????״̬
2807
					g_ehmiMainFrame->scdclient->Activate(g_ehmiMainFrame->m_user,rdbtblname,obj);
2808
				}
2809
			}
2810
		}
2811
	}
2812
}
2813

    
2814
void CGWnd::ShowEpcDlg(int no)
2815
{
2816
	CHMIEPCDlg * epcdlg = (CHMIEPCDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_EPCDLG);
2817
	if(!epcdlg){
2818
		epcdlg = new CHMIEPCDlg();
2819
		epcdlg->Create(IDD_DIALOG_EPC,this);
2820
		g_ehmiMainFrame->SetOptDlg(CTRL_EPCDLG,epcdlg);
2821
	}
2822
//	epcdlg->SetCurEpc (no);
2823
	epcdlg->SelectMode(no);
2824
	epcdlg->ShowWindow (SW_SHOW);
2825

    
2826
}
2827

    
2828
void CGWnd::ShowPlDlg(char * obj/*?????*/)
2829
{
2830
	CMMIPLDlg * pldlg = (CMMIPLDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_PLDLG);
2831
	if(!pldlg){
2832
		pldlg = new CMMIPLDlg();
2833
		pldlg->Create(IDD_MMI_PL,this);
2834
		g_ehmiMainFrame->SetOptDlg(CTRL_PLDLG,pldlg);
2835
	}
2836
	pldlg->SetPara (obj);
2837
	pldlg->ShowWindow (SW_SHOW);
2838
}
2839

    
2840
void CGWnd::ShowTagDlg(char * obj/*?豸????*/)
2841
{
2842
	if (g_ehmiMainFrame->m_uniCtrl)
2843
	{		
2844
//		ShowCtrlDlg(Tag);
2845
		ShowCtrlDlg(Ctrl);//xzf 20180813
2846
	}
2847
	else
2848
	{
2849
	CMMITagDlg * tagdlg = (CMMITagDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_TAGDLG);
2850
	if(!tagdlg){
2851
		tagdlg = new CMMITagDlg();
2852
		tagdlg->SetTagPara(g_ehmiMainFrame->ptagdb);
2853
		tagdlg->Create(IDD_MMI_TAG,this);
2854
		g_ehmiMainFrame->SetOptDlg(CTRL_TAGDLG,tagdlg);
2855
	}
2856

    
2857
	//?ӱ????ڴ?ȡ?豸״̬.
2858
	int powerflag =0;
2859
	int groundflag = 0;//FIVECHECK___20060627
2860
	tagdlg->SetPowerFlag(powerflag);
2861
	tagdlg->SetGroundFlag(groundflag);//FIVECHECK___20060627
2862
	tagdlg->SetPara (obj);
2863
	tagdlg->SetWnd(this);
2864
	tagdlg->ShowWindow (SW_SHOW);
2865
	}
2866
}
2867

    
2868
void CGWnd::AddSerialYKObj(STRUCT_DEVBASEINFO devinfo,int act)
2869
{
2870
	char * obj = devinfo.sYXCode;
2871
/*	CMMISOCDlg * sykdlg = (CMMISOCDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_SERIALYKDLG);
2872
	if(!sykdlg){
2873
		sykdlg = new CMMISOCDlg();
2874
		sykdlg->Create(IDD_MMI_SOC,this);
2875
		g_ehmiMainFrame->SetOptDlg(CTRL_SERIALYKDLG,sykdlg); 
2876
	}
2877
	CMMISerialYKDlg * sykdlg = (CMMISerialYKDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_SERIALYKDLG);
2878
	if(!sykdlg){
2879
		sykdlg = new CMMISerialYKDlg();
2880
		sykdlg->Create(IDD_MMI_SERIALYK,this);
2881
		g_ehmiMainFrame->SetOptDlg(CTRL_SERIALYKDLG,sykdlg); 
2882
	}
2883
*///gong 20180522
2884
	CSeqYkDlg * sykdlg = (CSeqYkDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_SERIALYKDLG);
2885
	if(!sykdlg){
2886
		sykdlg = new CSeqYkDlg();
2887
		sykdlg->Create(IDD_DLG_SEQUENYK,this);
2888
		g_ehmiMainFrame->SetOptDlg(CTRL_SERIALYKDLG,sykdlg); 
2889
	}
2890
	
2891
	if(!sykdlg->IsWindowVisible()){
2892
//		sykdlg->Reset ();
2893
//		sykdlg->SetSerialYKType(DEF_SERIALYK_TYPE_AFTER);
2894
		sykdlg->ShowWindow (SW_SHOW);
2895
	}
2896

    
2897
// ??ʱ?????????
2898
/*
2899
	//????ǿ??ػ?բ??????????????
2900
	CRdbCltAccess ra;
2901
	SRDB_PARAINFO rdbpara[1];
2902
	int valnum=0;
2903
	//??ǰ?豸???????ǿ??ػ????ǵ?բ
2904
	if(m_devid == SE_K_DEV_BREAK
2905
	   ||m_devid==SE_K_DEV_SWITCH)
2906
	{
2907
		strcpy(rdbpara[0].tbl, EPS_RDB_TBLNAME);
2908
		strcpy(rdbpara[0].obj,devinfo.sDevCode);
2909
		strcpy(rdbpara[0].field,"fiveInf");
2910
		ra.SetUserPwd("guest","");
2911
		valnum = ra.SendGetDataPara (1, rdbpara);
2912
	}
2913
	if(valnum>0)
2914
	{
2915
		int fivelock;
2916
		int tmprawno = ra.GetIntVal(0,fivelock);
2917
		if(fivelock!=0)
2918
		{
2919
			CString str;
2920
			//str.Format(_T("????:\r\n    %s\r\n    ?Ƿ?Ҫ????ң?ش˿????!"),DevStatusExp.GetFiveInf(fivelock));
2921
			str.Format(_T("????:\r\n    %s!"),DevStatusExp.GetFiveInf(fivelock));//FIVECHECK___20060627
2922
			WarningDlg dlg(this);
2923
			dlg.SetInfo(str);
2924
			dlg.SetSndInfo(DevStatusExp.GetFiveInf(fivelock));//FIVECHECK___20060627
2925
			if(dlg.DoModal() == IDCANCEL)
2926
			{
2927
				return;
2928
			}
2929
		}
2930
	}
2931
*/
2932

    
2933
	if(obj){
2934
		YKOBJNAME yks;
2935
		strcpy(yks.objname,obj);
2936
		yks.acttype = act;
2937
		sykdlg->AddObjs (&yks,1);
2938
	}
2939
}
2940

    
2941
char CGWnd::NeedYXStatus()
2942
{
2943
	for(int i=0;i<YX_BACKCOLOR_NUM;i++){
2944
		if(g_ehmiMainFrame->m_faceSetting.fyxback[i])return 1;
2945
	}
2946
	return 0;
2947
}
2948

    
2949
int CGWnd::NeedYCStatus()
2950
{
2951
	for(int i=0;i<YC_BACKCOLOR_NUM;i++){
2952
		if(g_ehmiMainFrame->m_faceSetting.fycback[i])return 1;
2953
	}
2954
	return 0;
2955
}
2956

    
2957
int CGWnd::NeedDEVStatus()
2958
{
2959
	if(g_ehmiMainFrame->m_faceSetting.colormode)return 1;
2960
	return 0;
2961
}
2962

    
2963
COLORREF CGWnd::GetColorBySourceID(int sourceid)
2964
{
2965
	int i = 0;
2966
	for( i=0;i<g_ehmiMainFrame->m_faceSetting.stationcol.GetSize()-1;i++){
2967
		if(g_ehmiMainFrame->m_faceSetting.stationcol[i].id == sourceid){
2968
			return g_ehmiMainFrame->m_faceSetting.stationcol[i].color;
2969
		}
2970
	} 
2971
	return g_ehmiMainFrame->m_faceSetting.stationcol[i].color;//?????????Դ??ɫ
2972
}
2973

    
2974
COLORREF CGWnd::GetColorByVoltID(int voltid)
2975
{
2976
	int i = 0;
2977
	for( i=0;i<g_ehmiMainFrame->m_faceSetting.voltcol.GetSize()-1;i++)
2978
	{
2979
		if(g_ehmiMainFrame->m_faceSetting.voltcol[i].id == voltid)
2980
		{
2981
			return g_ehmiMainFrame->m_faceSetting.voltcol[i].color;
2982
		}
2983
	} 
2984
	return g_ehmiMainFrame->m_faceSetting.voltcol[i].color;//??????ѹ?ȼ???ɫ
2985
}
2986

    
2987
//??????е?ͼ?ϵ?ʵʱ???? bErase=1???????ʵʱ???? bErase=2ʱ??????ͣ???͹???
2988
void CGWnd::ClearAllMapData(int bErase)
2989
{
2990
	int i;
2991

    
2992
	CRdbSubScibe * subscibeclient = g_ehmiMainFrame->subscibeclient;
2993
	if(subscibeclient){
2994
		subscibeclient->CancelSubScibe(m_wndId-DEF_ID_BASEWND);
2995
	}
2996

    
2997
	CVGRegion updateregion;
2998
	if(bErase!=2)
2999
	{
3000
		//?Ȼ?ԭ??????ɫ
3001
		for(i=0;i<m_Flashlist.GetSize ();i++)
3002
		{
3003
			if(bErase)
3004
				updateregion.Add (m_Flashlist[i]);
3005
			m_Flashlist[i]->Refresh(&m_GraphGUI,&m_Flashlist[i]->GetObjectRect());
3006
		/*	if(m_Flashlist[i]->Refresh(&m_GraphGUI,&m_Flashlist[i]->GetObjectRect()))
3007
			{//??ԭ??ɫ
3008
				m_Flashlist[i]->Refresh(&m_GraphGUI,&m_Flashlist[i]->GetObjectRect());
3009
			}*/
3010
		}
3011
		m_Flashlist.RemoveAll (); 	
3012
		//??ɾ?????й???
3013
	    for(i=0;i<m_TagedDevlist.GetSize();i++){
3014
			m_TagedDevlist[i].pobj		= NULL;
3015
			m_TagedDevlist[i].pfather	= NULL;
3016
			m_TagedDevlist[i].metapos	= NULL;
3017
		}      
3018
	}
3019
		
3020
	m_rdbpara.FreeMem();
3021
	m_rdbdata.FreeMem();
3022

    
3023
	//???е?ң??
3024
	//???е??豸
3025
	//???е?ң??
3026
	{
3027

    
3028
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_ANALOG);
3029
		for(i=0;i<ObjArray.GetSize ();i++)
3030
		{
3031
			CYaoCeObj * pyc =(CYaoCeObj *)ObjArray[i];
3032
			if(!pyc)
3033
				continue;
3034
			if(bErase)
3035
				updateregion.Add(pyc);
3036
			pyc->SetFloat(0.0);
3037
			pyc->SetUserControl(FALSE);
3038
		}
3039
	}
3040
	
3041
	//???????еİ?ͼ
3042
	{
3043
		CBaseObjArray & ObjArray =GetFeatureObjects(OS_BAR);
3044
		for(i=0;i<ObjArray.GetSize ();i++)
3045
		{
3046
			CBarObj *pbar =(CBarObj*) ObjArray[i];
3047
			if(bErase)
3048
				updateregion.Add(pbar);
3049
			pbar->SetBarValue(0.0);
3050
			//??????????
3051
			double up2,down2,up1,down1;
3052
			STRUCT_BAR_INFO * barinfo = pbar->GetBarInfo();
3053
			if(!barinfo)
3054
				continue;
3055

    
3056
			if(GetYcLimit(barinfo->Code,up2,down2,up1,down1))
3057
			{
3058
				pbar->SetBarUpLimit((float)up1);
3059
				pbar->SetBarDownLimit ((float)down1);
3060
			}
3061
		}
3062
	}
3063

    
3064
	{
3065
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_POINTDEV);
3066
		for(i=0;i<ObjArray.GetSize ();i++)
3067
		{
3068
			CPointDevice *pdev =(CPointDevice *)ObjArray[i];
3069
			if(!pdev)
3070
				continue;
3071
			if(bErase)
3072
				updateregion.Add(ObjArray[i]);
3073
			ObjArray[i]->SetObjectStatus(ST_NORMAL);
3074
			ObjArray[i]->SetRealSetColor(FALSE,RGB(192,192,192));
3075
			((CPointDevice *)pdev)->SetUserControl(FALSE);
3076
		}
3077
	}
3078

    
3079
	//???????е?״̬??
3080
	{
3081
		CBaseObjArray & ObjArray =GetFeatureObjects(OS_STATUSOBJ);
3082
		for(i=0;i<ObjArray.GetSize ();i++)
3083
		{
3084
		//	pdev =(CPowerBase *)ObjArray[i];
3085
			if(!ObjArray[i])
3086
				continue;
3087
			if(bErase)
3088
				updateregion.Add(ObjArray[i]);
3089
			ObjArray[i]->SetObjectStatus(ST_NORMAL);
3090
		}
3091
	}
3092
/*
3093
	//???е??豸
3094
	long dev_feature[]={
3095
				FT_TRANS,
3096
				FT_CAP,
3097
				FT_DKQ,
3098
				FT_BLQ,
3099
				FT_RDQ,
3100
				FT_POLE,
3101
				FT_LOAD,
3102
				FT_BUSLINE,
3103
				FT_POWERLINE,		
3104
				FT_LINKLINE};
3105
	for(i=0;i<11;i++)
3106
	{
3107
		CBaseObjArray & ObjArray =GetFeatureObjects(dev_feature[i]);
3108
		for(j=0;j<ObjArray.GetSize();j++)
3109
		{
3110
		//	pdev =(CPowerBase *)ObjArray[j];
3111
			if(!ObjArray[j])
3112
				continue;
3113

    
3114
			if(bErase)
3115
				updateregion.Add(ObjArray[j]);
3116
			//pdev->SetCurState(0);
3117
			ObjArray[j]->SetRealSetColor(FALSE,RGB(192,192,192));
3118
		}
3119
	}
3120
*/	
3121
	//???еĶ???????
3122
	{
3123
		
3124
	}
3125
	//if(bErase && updateregion.GetRectCount()>0)m_map.RefreshRegion(updateregion);
3126
}
3127

    
3128
static char * charKWHField[DEF_OBJCODE_LEN] ={
3129
	"ValSave",
3130
	"ValMark",
3131
	"ValIntegral",
3132
	"DaySum",
3133
	"MonthSum",
3134
	"YearSum",
3135
	"DayInterVal1",
3136
	"DayInterVal2",
3137
	"DayInterVal3",
3138
	"DayInterVal4",
3139
	"MonInterVal1",
3140
	"MonInterVal2",
3141
	"MonInterVal3",
3142
	"MonInterVal4",
3143
	"YearInterVal1",
3144
	"YearInterVal2",
3145
	"YearInterVal3",
3146
	"YearInterVal4"
3147
};
3148

    
3149
#define DEF_KWHVAL_TYPENUM 18
3150

    
3151
// ???º???????ʵʱ???ݵ?ˢ?º??ռ?
3152
void CGWnd::CollectAllData()
3153
{
3154
	int i,j;
3155
	short int type ;
3156
	register char needycs	= NeedYCStatus();
3157
	register char needyxs	= NeedYXStatus();
3158
	register char needdevs	= NeedDEVStatus();
3159

    
3160
	//???????е?ң??
3161
	//???????е??豸
3162

    
3163
	SRDB_PARAINFO *para;
3164
	ST_VISITRDB   *data;
3165
	//???????е?ң??
3166
	{
3167
		CBaseObjArray  & ObjArray = GetFeatureObjects(OS_ANALOG);
3168
	  
3169
		for(i=0;i<ObjArray.GetSize();i++)
3170
		{
3171
			CYaoCeObj * pyc =(CYaoCeObj * )ObjArray[i];
3172
			if(!pyc)
3173
				continue;
3174

    
3175
			if(pyc->GetTypeID())
3176
			{//???
3177
				pyc->SetUserControl(FALSE);
3178
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3179
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3180
				strcpy(para->tbl,KWH_RDB_TBLNAME);
3181
				strcpy(para->obj,pyc->GetYCCode());
3182
				type = pyc->GetKWHType();
3183
				if(type<0 || type >= DEF_KWHVAL_TYPENUM)type =0;
3184
				strcpy(para->field ,charKWHField[type]);
3185
				data->obj = pyc;
3186
				data->valide = 1;
3187
				data->sval.m_type = REALDB_DOUBLE;
3188
				data->sval.m_val.doubleval = 0.0;
3189
				data->flag = ehmi_FRESH_YCDATA;
3190
			}
3191
			else{
3192
				//ң??????
3193
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3194
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3195
				strcpy(para->tbl,ANA_RDB_TBLNAME);
3196
				strcpy(para->obj,pyc->GetYCCode());
3197
				strcpy(para->field ,"Value");
3198
					
3199
				data->obj = pyc;
3200
				data->valide = 1;
3201
				data->sval.m_type = REALDB_FLOAT;
3202
				data->sval.m_val.floatval = 0.0;
3203
				data->flag = ehmi_FRESH_YCDATA;
3204

    
3205
				//ң??״̬
3206
				if(needycs){
3207
					para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3208
					data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3209
					strcpy(para->tbl,ANA_RDB_TBLNAME);
3210
					strcpy(para->obj,pyc->GetYCCode());
3211
					strcpy(para->field ,"Status");
3212
						
3213
					data->obj = pyc;
3214
					data->valide = 1;
3215
					data->sval.m_type = REALDB_UINT;
3216
					data->sval.m_val.uintval  = 0;
3217
					data->flag = ehmi_FRESH_YCSTATUS;
3218
				}
3219
				else 
3220
				{
3221
			     	pyc->SetUserControl(FALSE);
3222
				}
3223
			}
3224
		}
3225
	}
3226
	
3227
	//???????еİ?ͼ
3228
	{
3229
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_BAR);
3230
		for(i=0;i<ObjArray.GetSize ();i++)
3231
		{
3232
			CBarObj * pbar =(CBarObj *)ObjArray[i];
3233
			if(!pbar)continue;
3234
			pbar->SetBarValue(0.0);
3235
			STRUCT_BAR_INFO * barinfo = pbar->GetBarInfo();
3236
			if(!barinfo)continue;
3237

    
3238
			para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3239
			data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3240
			strcpy(para->tbl,ANA_RDB_TBLNAME);
3241
			strcpy(para->obj,barinfo->Code);
3242
			strcpy(para->field ,"Value");
3243
				
3244
			data->obj = pbar;
3245
			data->valide = 1;
3246
			data->sval.m_type = REALDB_FLOAT;
3247
			data->sval.m_val.floatval = 0.0;
3248
			data->flag = ehmi_FRESH_BARDATA;
3249

    
3250
			//??????????
3251
			double up2,down2,up1,down1;
3252
			if(GetYcLimit(barinfo->Code,up2,down2,up1,down1))
3253
			{
3254
				pbar->SetBarUpLimit((float)up1);
3255
				pbar->SetBarDownLimit ((float)down1);
3256
			}
3257
		}
3258
	}
3259

    
3260
	//???????е?????
3261
	{
3262
		STRUCT_ONECUR_INFO * cur = NULL;
3263
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_CURVER);
3264
		for(i=0;i<ObjArray.GetSize ();i++)
3265
		{
3266
			CCurverObj *pcur =(CCurverObj *) ObjArray[i];
3267
			if(!pcur)
3268
				continue;
3269
			int curcount = pcur->GetCurveNum();
3270
			if(curcount<=0)
3271
				break;
3272
			
3273
			for(j=0;j<curcount;j++)
3274
			{
3275
				cur = pcur->GetOneCurveInfo(j);
3276
				if(cur)
3277
				{
3278
					para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3279
					data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3280
					if (pcur->GetCurType() == 0) // YC
3281
					{
3282
						strcpy(para->tbl,ANA_RDB_TBLNAME);
3283
						strcpy(para->obj,cur->Code);
3284
						strcpy(para->field ,"Value");
3285
						data->sval.m_type = REALDB_FLOAT;
3286
						data->sval.m_val.floatval = 0.0;
3287
					}
3288
					else
3289
					{
3290
						strcpy(para->tbl,KWH_RDB_TBLNAME);
3291
						strcpy(para->obj,cur->Code);
3292
						strcpy(para->field ,"ValSave");
3293
						data->sval.m_type = REALDB_DOUBLE;
3294
						data->sval.m_val.doubleval = 0.0;
3295
					}
3296
					data->obj = pcur;
3297
					data->valide = 1;
3298
					
3299
					data->flag = ehmi_FRESH_CURDATA;
3300
					data->userdata1 = j;
3301

    
3302
					//???ô??̼??????????
3303
					SetRealCurPara(cur,j,pcur);
3304
					//??????ʷ???ݿ??е????ݣ?????ʾ֮
3305
					SetRealCurData(cur,j,pcur);
3306
				}
3307
			}
3308
		}
3309
	}
3310

    
3311
	//???????б?ͼ
3312
	{
3313
		STRUCT_ONEPIE_INFO *pie = NULL;
3314
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_PIEGRP);
3315
		for(i=0;i<ObjArray.GetSize();i++)
3316
		{
3317
			CPieGrp* ppie = (CPieGrp*) ObjArray[i];
3318
			if(!ppie) continue;
3319
			int piecount = ppie->GetPieNum();
3320
			if(piecount <= 0) continue;
3321

    
3322
			for(j = 0; j<piecount; j++)
3323
			{
3324
				pie = ppie->GetOnePieInfo(j);
3325
				if(pie)
3326
				{
3327
					para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3328
					data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3329
					if(ppie->GetValType())
3330
					{
3331
						strcpy(para->tbl,KWH_RDB_TBLNAME);
3332
						strcpy(para->field ,VALUE);
3333
					}
3334
					else
3335
					{
3336
						strcpy(para->tbl,ANA_RDB_TBLNAME);
3337
						strcpy(para->field ,"Value");
3338
					}
3339
					strcpy(para->obj,pie->Code);					
3340

    
3341
					data->obj = ppie;
3342
					data->valide = 1;
3343
					data->sval.m_type = REALDB_FLOAT;
3344
					data->sval.m_val.floatval = 0.0;
3345
					data->flag = ehmi_FRESH_PIEDATA;
3346
					data->userdata1 = j;
3347
				}
3348
			}
3349
		}
3350
	}
3351
    
3352
	// plugin
3353
	{
3354
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_PLUG);
3355
		for(i=0;i<ObjArray.GetSize();i++)
3356
		{
3357
			CPlugObj * pplug = (CPlugObj*) ObjArray[i];
3358
			if(!pplug) continue;
3359

    
3360
			CVGPlugInCore* pCore = pplug->m_pCore;
3361
			if(!pCore) continue;
3362
//fgt 20170707  ??? ΪʲôҪע?????
3363
/*			SRDB_PARAINFO * pRdbInfo=NULL;
3364
			int num = pCore->GetRdbInf(&pRdbInfo);
3365
			for(j=0; j<num; j++)
3366
			{
3367
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3368
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3369

    
3370
				memcpy(para,pRdbInfo+j,sizeof(SRDB_PARAINFO));
3371
				data->obj = pplug;
3372
				data->valide = 1;
3373
//				data->sval.m_type = REALDB_FLOAT;
3374
//				data->sval.m_val.floatval = 0.0;
3375
				data->flag = ehmi_FRESH_PLUGDATA;
3376
				data->userdata1 = j;
3377
			}
3378
			if(pRdbInfo)
3379
				free(pRdbInfo);*/
3380
//fgt 20170707
3381
		}
3382
	}
3383

    
3384
	// ?????DZ?
3385
	{
3386
		char szPointCode[24];		
3387
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_METER);
3388
		for (i = 0; i < ObjArray.GetSize(); i++)
3389
		{
3390
			CMeterObj * pMeterObj = (CMeterObj*) ObjArray[i];
3391
			if (!pMeterObj) continue;
3392

    
3393
			para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3394
			data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3395
//			int nType = pMeterObj->GetPointType();
3396
			if (pMeterObj->GetDataType())
3397
			{
3398
				strcpy(para->tbl, KWH_RDB_TBLNAME);
3399
/*				if(nType < 0 || nType >= DEF_KWHVAL_TYPENUM) 
3400
				{
3401
					nType = 0;
3402
				}*/
3403
				strcpy(para->field ,"ValMark");
3404
				data->sval.m_type = REALDB_DOUBLE;
3405
				data->sval.m_val.doubleval = 0.0;
3406
			}
3407
			else
3408
			{
3409
				strcpy(para->tbl, ANA_RDB_TBLNAME);
3410
				strcpy(para->field, "Value");
3411
				data->sval.m_type = REALDB_FLOAT;
3412
				data->sval.m_val.floatval = 0.0;
3413
			}
3414
			memset(szPointCode, 0, sizeof(szPointCode));
3415
			pMeterObj->GetPointCode(szPointCode);
3416
			strcpy(para->obj, szPointCode);					
3417
			data->obj = pMeterObj;
3418
			data->valide = 1;		
3419
			data->flag = ehmi_FRESH_METERDATA;
3420
			data->userdata1 = i;
3421
		}
3422
	}
3423

    
3424
	// ???밴ť
3425
	{
3426
		char szPointCode[24];		
3427
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_BUTTON);
3428
		for (i = 0; i < ObjArray.GetSize(); i++)
3429
		{
3430
			CButtonObj * pBtnObj = (CButtonObj*) ObjArray[i];
3431
			if (!pBtnObj) continue;
3432

    
3433
			if (!pBtnObj->GetExtendFlag()) continue;
3434

    
3435
			para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3436
			data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3437
			strcpy(para->tbl, DIGITAL_RDB_TBLNAME);
3438
			strcpy(para->field, "Value");
3439
			data->sval.m_type = REALDB_INT;
3440
			data->sval.m_val.intval = 0;
3441
		
3442
			memset(szPointCode, 0, sizeof(szPointCode));
3443
			pBtnObj->GetPointCode(szPointCode);
3444
			strcpy(para->obj, szPointCode);					
3445
			data->obj = pBtnObj;
3446
			data->valide = 1;		
3447
			data->flag = ehmi_FRESH_BUTTONDATA;
3448
			data->userdata1 = i;
3449
		}
3450
	}
3451

    
3452
	STRUCT_DEVBASEINFO dev;
3453
//	Tdevmeta.Empty();
3454

    
3455
	//???????еĵ??豸
3456
	{
3457
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_POINTDEV);
3458
		for(i=0;i<ObjArray.GetSize();i++)
3459
		{
3460
			CPointDevice *pdev =(CPointDevice *)ObjArray[i];
3461

    
3462
			if(!pdev)
3463
				continue;
3464

    
3465
			if (pdev->GetDllType()>0)
3466
				continue;
3467

    
3468
			pdev->SetObjectStatus(ST_NORMAL);
3469

    
3470
			pdev->GetDevInfo(dev);
3471

    
3472
			if (strcmp(dev.sYXCode, ""))
3473
			{
3474
				// ????ң??ֵ??--Value
3475
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3476
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3477
				strcpy(para->tbl,DIGITAL_RDB_TBLNAME);
3478
				strcpy(para->obj,dev.sYXCode);
3479
				strcpy(para->field ,"Value");
3480

    
3481
				data->obj = ObjArray[i];
3482
				data->valide = 1;
3483
				data->sval.m_type = REALDB_UCHAR;
3484
				data->sval.m_val.ucharval = 0;
3485
				data->flag = ehmi_FRESH_YXDATA;
3486

    
3487
				// ????ң??״̬??--Status
3488
				if(needyxs)
3489
				{
3490
					para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3491
					data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3492
					strcpy(para->tbl,DIGITAL_RDB_TBLNAME);
3493
					strcpy(para->obj,dev.sYXCode);
3494
					strcpy(para->field ,"Status");
3495
						
3496
					data->obj = ObjArray[i];
3497
					data->valide = 1;
3498
					data->sval.m_type = REALDB_UINT;
3499
					data->sval.m_val.uintval = 0;
3500
					data->flag = ehmi_FRESH_YXSTATUS;
3501
				}
3502
				else
3503
					((CPointDevice*)pdev)->SetUserControl(FALSE);
3504

    
3505
				// ????ң?Ź?????--Tag
3506
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3507
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3508
				strcpy(para->tbl,DIGITAL_RDB_TBLNAME);
3509
				strcpy(para->obj,dev.sYXCode);
3510
				strcpy(para->field ,"Tag");
3511

    
3512
				data->obj = ObjArray[i];
3513
				data->valide = 1;
3514
				data->sval.m_type = REALDB_UCHAR;
3515
				data->sval.m_val.ucharval = 0;
3516
				data->flag = ehmi_FRESH_TAG;
3517
			}
3518

    
3519
			// ?????豸״̬??--Status
3520
			if(needdevs)
3521
			{
3522
				ObjArray[i]->SetRealSetColor(TRUE,g_ehmiMainFrame->m_faceSetting.other_back[NOPOWER_COLOR]);
3523

    
3524
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3525
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3526
				strcpy(para->tbl,DEV_RDB_TBLNAME);
3527
				strcpy(para->obj,dev.sDevCode);
3528
				strcpy(para->field ,"Status");
3529
					
3530
				data->obj = ObjArray[i];
3531
				data->valide = 1;
3532
				data->sval.m_type = REALDB_UINT;
3533
				data->sval.m_val.uintval = 0;
3534
				data->flag = ehmi_FRESH_DEVSTATUS;
3535
			}
3536
			else 
3537
			{
3538
				ObjArray[i]->SetRealSetColor(FALSE,RGB(192,192,192));
3539
			}
3540
		}
3541
	}
3542

    
3543
    //??????????? ʵʱ̬
3544
	{
3545
		DynaField TermObjInfo;
3546
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_TERMOBJ);
3547
		for(i=0;i<ObjArray.GetSize();i++)
3548
		{
3549
			CTermObj* pTermObj = (CTermObj*) ObjArray[i];
3550
			if(!pTermObj) 
3551
				continue;
3552

    
3553
			pTermObj->RemoveAllItems();
3554
			
3555
			int YCcount = pTermObj->GetYCCount();
3556
			if(YCcount <= 0) continue;
3557

    
3558
			for(j = 0; j<YCcount; j++)
3559
			{
3560
				int ret=pTermObj->GetYCItem(j,TermObjInfo);			
3561

    
3562
				if(ret)
3563
				{  
3564
					
3565
					pTermObj->AddTextItem(TermObjInfo.sYCCode,0,TermObjInfo.frColor,
3566
										  TRUE,TermObjInfo.bkColor);
3567
					float f=0.0;
3568
					char szVal[24];
3569
					memset(szVal,0,24);
3570
				//	sprintf(szVal,"%s: %.2f",TermObjInfo.sYCCode,f);
3571
					sprintf(szVal,"%.2f",f);
3572
					pTermObj->UpdateItemText(j,szVal);
3573

    
3574
					para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3575
					data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3576
			
3577
					
3578
					strcpy(para->tbl,ANA_RDB_TBLNAME);
3579
					strcpy(para->field ,"Value");						
3580
					strcpy(para->obj,TermObjInfo.sYCCode);
3581
					
3582

    
3583
					data->obj = pTermObj;
3584
					data->valide = 1;
3585
					data->sval.m_type = REALDB_FLOAT;
3586
					data->sval.m_val.floatval = 0.0;
3587
					data->flag = ehmi_FRESH_TERMDATA;
3588
					data->userdata1 = j;
3589
                  
3590
					//ң??״̬
3591
					if(needycs)
3592
					{
3593
						para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3594
						data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3595
						strcpy(para->tbl,ANA_RDB_TBLNAME);
3596
						strcpy(para->obj,TermObjInfo.sYCCode);
3597
						strcpy(para->field ,"Status");
3598
							
3599
						data->obj = pTermObj;
3600
						data->valide = 1;
3601
						data->sval.m_type = REALDB_UINT;
3602
						data->sval.m_val.uintval  = 0;
3603
						data->flag = ehmi_FRESH_TERMSTATUS;
3604
						data->userdata1 = j;
3605
					}
3606
					else 
3607
					{				
3608
                       pTermObj->SetItemStyle(j,TermObjInfo.frColor,TRUE);
3609
					}
3610
				}
3611
			}
3612
		}
3613
	}
3614

    
3615
	//???????е?״̬??
3616
	{
3617
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_STATUSOBJ);
3618
		
3619
		for(i=0;i<ObjArray.GetSize ();i++)
3620
		{
3621
			CStatusObj * pdev =(CStatusObj *)ObjArray[i];
3622
			if(!pdev)
3623
				continue;
3624

    
3625
			ObjArray[i]->SetObjectStatus(ST_NORMAL);
3626

    
3627
			para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3628
			data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3629
			strcpy(para->tbl,((CStatusObj*)ObjArray[i])->GetTableID());
3630

    
3631
			strcpy(para->obj,((CStatusObj*)ObjArray[i])->GetStatusCode());
3632

    
3633
			strcpy(para->field ,((CStatusObj*)ObjArray[i])->GetFieldID());
3634

    
3635
			data->obj = ObjArray[i];
3636
			data->valide = 1;
3637
			data->sval.m_type = REALDB_UCHAR;
3638
			data->sval.m_val.ucharval = 0;
3639
			data->flag = ehmi_FRESH_YXDATA;
3640

    
3641
			if(needyxs)
3642
			{
3643
				//????״̬???ͱ????豸????ȡ״̬
3644
               if((((CStatusObj*)ObjArray[i])->GetTableID() != DIGITAL_RDB_TBLNAME))
3645
				   continue;
3646

    
3647
				//״̬???ɼ???־
3648
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3649
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3650
				strcpy(para->tbl,((CStatusObj*)ObjArray[i])->GetTableID());
3651
				strcpy(para->obj,((CStatusObj*)ObjArray[i])->GetStatusCode());
3652
				strcpy(para->field ,"Status");
3653
					
3654
				data->obj = ObjArray[i];
3655
				data->valide = 1;
3656
				data->sval.m_type = REALDB_UINT;
3657
				data->sval.m_val.uintval = 0;
3658
				data->flag = ehmi_FRESH_YXSTATUS;
3659
			}
3660
			else 
3661
			{
3662
				ObjArray[i]->SetRealSetColor(FALSE,RGB(192,192,192));
3663
			}
3664
		}
3665
	}
3666

    
3667
    //???????еĶ?̬ʵʱ????
3668
	{
3669
        CBaseObjArray & ObjArray =GetFeatureObjects(OS_REALSTRINGOBJ);
3670
		
3671
		for(i=0;i<ObjArray.GetSize ();i++)
3672
		{
3673
			CRealStringObj * pdev =(CRealStringObj *)ObjArray[i];
3674
			if(!pdev)
3675
				continue;
3676

    
3677
			ObjArray[i]->SetObjectStatus(ST_NORMAL);
3678

    
3679
			para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3680
			data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3681
			strcpy(para->tbl,((CRealStringObj*)ObjArray[i])->GetTableID());
3682

    
3683
			strcpy(para->obj,((CRealStringObj*)ObjArray[i])->GetRealStringCode());
3684

    
3685
			strcpy(para->field ,((CRealStringObj*)ObjArray[i])->GetFieldID());
3686

    
3687
			data->obj = ObjArray[i];
3688
			data->valide = 1;
3689
			data->sval.m_type = REALDB_FLOAT;
3690
			data->sval.m_val.floatval = 0;
3691
			data->flag = ehmi_FRESH_YXDATA;
3692

    
3693
			if(needyxs){
3694
				//ʵʱ???????ɼ???־
3695
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3696
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3697
				strcpy(para->tbl,((CRealStringObj*)ObjArray[i])->GetTableID());
3698
				strcpy(para->obj,((CRealStringObj*)ObjArray[i])->GetRealStringCode());
3699
				strcpy(para->field ,"Status");
3700
					
3701
				data->obj = ObjArray[i];
3702
				data->valide = 1;
3703
				data->sval.m_type = REALDB_UINT;
3704
				data->sval.m_val.uintval = 0;
3705
				data->flag = ehmi_FRESH_YXSTATUS;
3706
			}
3707
			else 
3708
			{
3709
				ObjArray[i]->SetRealSetColor(FALSE,RGB(192,192,192));
3710
			}
3711
		}
3712
	}
3713

    
3714
    //???????е?ң??ʵʱ????
3715
	{
3716
        CBaseObjArray & ObjArray =GetFeatureObjects(OS_YAOKONG);
3717
		
3718
		for(i=0;i<ObjArray.GetSize ();i++)
3719
		{
3720
			CYaokongObj * pdev =(CYaokongObj *)ObjArray[i];
3721
			if(!pdev)
3722
				continue;
3723

    
3724
			ObjArray[i]->SetObjectStatus(ST_NORMAL);
3725

    
3726
			para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3727
			data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3728

    
3729
			strcpy(para->tbl, DIGITAL_RDB_TBLNAME);
3730
			strcpy(para->obj,((CYaokongObj*)ObjArray[i])->GetAttchYx());
3731
			strcpy(para->field, "Value");
3732

    
3733
			data->obj = ObjArray[i];
3734
			data->valide = 1;
3735
			data->sval.m_type = REALDB_UCHAR;
3736
			data->sval.m_val.ucharval = 0;
3737
			data->flag = ehmi_FRESH_YXDATA;
3738

    
3739
			if(needyxs){
3740
				//ʵʱ???????ɼ???־
3741
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3742
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3743

    
3744
				strcpy(para->tbl, DIGITAL_RDB_TBLNAME);
3745
				strcpy(para->obj,((CYaokongObj*)ObjArray[i])->GetAttchYx());
3746
				strcpy(para->field ,"Status");
3747
					
3748
				data->obj = ObjArray[i];
3749
				data->valide = 1;
3750
				data->sval.m_type = REALDB_UINT;
3751
				data->sval.m_val.uintval = 0;
3752
				data->flag = ehmi_FRESH_YXSTATUS;
3753
			}
3754
			else 
3755
			{
3756
				ObjArray[i]->SetRealSetColor(FALSE,RGB(192,192,192));
3757
			}
3758
		}
3759
	}
3760

    
3761
	// ???????еĽű???ʵʱ???ݶ???
3762
	CEasyList *pLayList = m_map.GetAllFeatureLayers();
3763
	if (pLayList)
3764
	{
3765
		for (int i=0; i < pLayList->GetListLen(); i++)
3766
		{
3767
			CFeatureLayer *pLayer = (CFeatureLayer *)pLayList->GetNth(i);
3768
			CEasyList *pObjLst = pLayer->GetObjects();
3769

    
3770
			if (pObjLst == NULL || pObjLst->GetListLen() == 0)
3771
				continue;
3772

    
3773
			for(int j=0; j < pObjLst->GetListLen(); j++)
3774
			{
3775
				CBaseObj *pObj = (CBaseObj *)pObjLst->GetNth(j);
3776

    
3777
				if (pObj == NULL)
3778
					continue;
3779

    
3780
				if (pObj->GetObjectShape() == OS_POINTDEV)
3781
				{
3782
					CPointDevice *pDev = (CPointDevice *)pObj;
3783

    
3784
					AnalyseString((const char *)pDev->m_pParamData, pDev->GetParamLen(), pObj);
3785
				}
3786
				AnalyseString((const char *)pObj->m_pScriptPoint, pObj->GetScriptLenPoint(), pObj, TRUE);
3787
			}
3788
		}
3789
	}
3790

    
3791
	// ?????????
3792
	{
3793
		char szPointCode[24];		
3794
		CBaseObjArray & ObjArray = GetFeatureObjects(OS_COUNTER);
3795
		for (i = 0; i < ObjArray.GetSize(); i++)
3796
		{
3797
			CCounterObj * pCounterObj = (CCounterObj*) ObjArray[i];
3798
			if (!pCounterObj) continue;
3799

    
3800
			para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3801
			data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3802
						
3803
			strcpy(para->tbl, ANA_RDB_TBLNAME);
3804
			strcpy(para->field, "Value");
3805
			data->sval.m_type = REALDB_UINT;
3806
			data->sval.m_val.uintval = 0;
3807
		
3808
			memset(szPointCode, 0, sizeof(szPointCode));
3809
			pCounterObj->GetPointCode(szPointCode);
3810
			strcpy(para->obj, szPointCode);					
3811
			data->obj = pCounterObj;
3812
			data->valide = 1;		
3813
			data->flag = ehmi_FRESH_COUNTERDATA;
3814
			data->userdata1 = i;
3815
		}
3816
	}
3817

    
3818
	// ????ATS?ռ?
3819
	CollectATSData();
3820
/*
3821
	//???????е??豸
3822
	long dev_feature[]={
3823
				FT_TRANS, //??ѹ??
3824
				FT_CAP,  //??????
3825
				FT_DKQ, //?翹??
3826
				FT_BLQ, //??????
3827
				FT_RDQ,//?۶???
3828
				FT_POLE,//????
3829
				FT_LOAD,  //????
3830
				FT_HWG,//??????
3831
				FT_BDZ,//???վ
3832
				FT_KBS,//?۶???
3833
				FT_FDC,//"???糧"
3834
				FT_FEEDLINE,//????
3835
				FT_PDF,//??緿
3836
				FT_DLFZX,//???·?֧??
3837
				FT_BUSLINE,//ĸ??
3838
				FT_POWERLINE,//???߶?
3839
				FT_DEVLINE, //??·
3840
				FT_LINKLINE //??????				
3841
	}; 	
3842
	
3843

    
3844
	for(i=0;i<18;i++)
3845
	{
3846
		CBaseObjArray & ObjArray = GetFeatureObjects(dev_feature[i]);
3847
		for(j=0;j<ObjArray.GetSize ();j++)
3848
		{
3849
			CBaseObj *pobj =(CBaseObj *)ObjArray[j];			
3850
			if(!pobj)
3851
				continue;
3852

    
3853
			OBJECT_SHAPE shapeId;
3854
		    shapeId=pobj->GetObjectShape();
3855
			
3856
			 //??־??????????????
3857
			if(shapeId == OS_SIGNOBJ)
3858
               continue;
3859
			  
3860
			if(needdevs)
3861
			{
3862
			  if(shapeId == OS_DEVBUSLINE) //ĸ??
3863
			  {
3864
				  CDevBusLine *pdev=(CDevBusLine*)ObjArray[j];
3865
				  if(pdev)
3866
				    pdev->GetDevInfo(dev);
3867
			  }
3868
			  else if(shapeId == OS_DEVPOWERLINE) //???߶?
3869
			  {
3870
				  CDevPowerLine *pdev=(CDevPowerLine*)ObjArray[j];
3871
				  if(pdev)
3872
				  {
3873
					  pdev->GetDevInfo(dev);	  
3874
				      //???????·????ʼ״̬û?г???????
3875
					  pdev->SetFlow(FALSE);
3876
				  }
3877
			  }			
3878
			  else if(shapeId ==OS_DEVLINE) //??·
3879
			  {
3880
				  CDevLine *pdev=(CDevLine*)ObjArray[j];
3881
				  pdev->GetDevInfo(dev);
3882
			  }			  
3883
			  else if(shapeId == OS_POINTDEV) //???豸
3884
			  {
3885
				  CPointDevice *pdev=(CPointDevice*)ObjArray[j];
3886
                  pdev->GetDevInfo(dev);
3887
			  }
3888
			  else 
3889
			  {                  
3890
				   {
3891
					   //??????????ߣ???ʼ״̬Ϊ??????ɫ
3892
                       if(i==FT_LINKLINE)
3893
					   {
3894
							pobj->SetRealSetColor(TRUE,
3895
								g_ehmiMainFrame->m_faceSetting.other_back[NOPOWER_COLOR]);
3896
							continue;
3897
					   }	
3898
				   }				   		
3899
			  }
3900
			  pobj->SetRealSetColor(TRUE,g_ehmiMainFrame->m_faceSetting.other_back[NOPOWER_COLOR]);
3901
			  para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
3902
			  data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
3903
			  strcpy(para->tbl,DEV_RDB_TBLNAME);
3904
			  strcpy(para->obj,dev.sDevCode);
3905
			  strcpy(para->field ,"Status");
3906
			  data->obj = pobj;
3907
			  data->valide = 1;
3908
			  data->sval.m_type = REALDB_UINT;
3909
			  data->sval.m_val.uintval = 0;
3910
			  data->flag = ehmi_FRESH_DEVSTATUS;
3911
			  Tdevmeta.Insert(dev.sDevCode,m_rdbdata.GetUnitNum()-1);
3912
			}
3913
			else 
3914
			{
3915
				pobj->SetRealSetColor(FALSE,RGB(192,192,192));
3916
			}
3917
		}
3918
	}
3919
*/	
3920
	int paracount = m_rdbpara.GetUnitNum();
3921

    
3922
	if (paracount > 0)
3923
	{
3924
		//?????µ????ݶ??IJ???
3925
		CRdbSubScibe * subscibeclient = g_ehmiMainFrame->subscibeclient;
3926
		if(!subscibeclient)
3927
			return;
3928
		int ret = subscibeclient->SetSubScibePara(
3929
							g_ehmiMainFrame->m_faceSetting.fresh_timeout,
3930
							paracount,
3931
							(SRDB_PARAINFO *)m_rdbpara.GetMemInfo(),
3932
							m_wndId-DEF_ID_BASEWND,
3933
							m_hWnd,
3934
							SourceRealData);
3935
	}
3936
}
3937

    
3938
LRESULT CGWnd::OnGetRdbData(WPARAM wParam, LPARAM lParam)
3939
{
3940
    int SerialNo = wParam;
3941
	if (SerialNo != m_wndId-DEF_ID_BASEWND)
3942
		return 0;
3943

    
3944
	CRdbSubScibe * subscibeclient = g_ehmiMainFrame->subscibeclient;
3945
	if (!subscibeclient)
3946
		return 0;
3947

    
3948
	int newdatanum = 0;
3949
	int count = subscibeclient->GetNews(SerialNo);
3950
	if (count > 0)
3951
	{
3952
		int paracount = m_rdbpara.GetUnitNum();
3953
		for (int i=0; i < count; i++)
3954
		{
3955
			SREALDB_VAR	rdbdata;
3956
			int No = subscibeclient->GetVal(SerialNo, i, &rdbdata);
3957
			if (No >= 0 && No < paracount)
3958
			{
3959
				SRDB_PARAINFO *para = (SRDB_PARAINFO *)m_rdbpara.GetUnit(No);
3960
				ST_VISITRDB   *data = (ST_VISITRDB   *)m_rdbdata.GetUnit(No);
3961
				if (!data)
3962
					continue;
3963

    
3964
				if (CDTOperE::Vt_Compare(&rdbdata, &(data->sval)) != 0)
3965
				{
3966
					// ?????б仯
3967
					data->sval = rdbdata;
3968
					data->valide = 1;			
3969
				}
3970

    
3971
				if (data->valide)
3972
					newdatanum ++;
3973
			}
3974
		}
3975
	}
3976

    
3977
	if (SourceRealData != DEF_DATA_FROM_PDR && newdatanum > 0)
3978
		FreshRealGraph(newdatanum >= 50);
3979

    
3980
	return 0;
3981
}
3982

    
3983
void CGWnd::FreshRealGraph(BOOL bReDrawAll)
3984
{
3985
	if (!bReDrawAll)
3986
		m_map.InitUpdateRgn();
3987

    
3988
	int paracount = m_rdbpara.GetUnitNum();
3989
	for (int i=0; i < paracount; i++)
3990
	{
3991
		ST_VISITRDB * pdata = (ST_VISITRDB * )m_rdbdata.GetUnit(i);
3992
		if (!pdata || !pdata->obj || (!pdata->valide && !bReDrawAll))
3993
			continue;
3994

    
3995
		if (!bReDrawAll)
3996
			m_map.AddUpdateObject(pdata->obj);
3997

    
3998
		switch (pdata->flag)
3999
		{
4000
		case ehmi_FRESH_YCDATA:
4001
			FreshYc(pdata->obj,&(pdata->sval));  
4002
			break;
4003
		case ehmi_FRESH_YCSTATUS:
4004
			FreshYcStatus(pdata->obj,&(pdata->sval));  
4005
			break;
4006
		case ehmi_FRESH_BARDATA:
4007
			FreshBar(pdata->obj,&(pdata->sval));  
4008
			break;
4009
		case ehmi_FRESH_YXDATA:
4010
			FreshYx(pdata->obj,&(pdata->sval));  
4011
			break;
4012
		case ehmi_FRESH_YXSTATUS:
4013
			FreshYxStatus(pdata->obj,&(pdata->sval));  
4014
			break;
4015
		case ehmi_FRESH_DEVSTATUS:
4016
			FreshDevStatus(pdata->obj,&(pdata->sval));  
4017
			break;
4018
		case ehmi_FRESH_TAG:
4019
			FreshTag(pdata->obj,&(pdata->sval));
4020
			break;
4021
		case ehmi_FRESH_CURDATA:
4022
			FreshCur(pdata->obj,&(pdata->sval),pdata->userdata1);	
4023
			break;
4024
		case ehmi_FRESH_PIEDATA:
4025
			FreshPie(pdata->obj,&(pdata->sval),pdata->userdata1);
4026
			break;
4027
		case ehmi_FRESH_TERMDATA: //????????
4028
            FreshTerm(pdata->obj,&(pdata->sval),pdata->userdata1);
4029
			break;
4030
		case ehmi_FRESH_TERMSTATUS: //????????״̬  
4031
			FreshTermStatus(pdata->obj,&(pdata->sval),pdata->userdata1);
4032
			break;
4033
		case ehmi_FRESH_SCRIPLINKDATA: //ˢ?½ű????ӵ?????
4034
			FreshScriptLinkData(pdata->obj);
4035
			break;
4036
		case ehmi_FRESH_PLUGDATA: //???ˢ??
4037
			FreshPlugObj(pdata);
4038
			break;
4039
		case ehmi_FRESH_METERDATA:
4040
			FreshMeterObj(pdata->obj, &(pdata->sval));
4041
			break;
4042
		case ehmi_FRESH_BUTTONDATA:
4043
			FreshButtonObj(pdata->obj, &(pdata->sval));
4044
			break;
4045
		case ehmi_FRESH_LOGICLINKDATA: //ˢ???߼?DLL??????
4046
			FreshLogicLinkData(pdata->obj);
4047
			break;
4048
		case ehmi_FRESH_COUNTERDATA:
4049
			FreshCounterObj(pdata->obj, &(pdata->sval));
4050
			break;
4051
		case ehmi_FRESH_ATSTRAIN:
4052
			FreshTrainObj(pdata->obj, &(pdata->sval), i);			
4053
			break;
4054
		}
4055
		pdata->valide = 0;
4056

    
4057
		if (!bReDrawAll)
4058
		{
4059
			if (pdata->flag == ehmi_FRESH_ATSTRAIN)
4060
			{
4061
				CFRect fRect1, fRect2;
4062
				// ˢ??ԭʼλ??
4063
				fRect1 = (pdata->obj)->GetObjectRect();
4064
				DrawObj(&fRect1);
4065
				// ˢ??????λ??
4066
				fRect2 = (pdata->obj)->GetObjectRect();
4067
				DrawObj(&fRect2);				
4068
			}
4069
			else
4070
			{
4071
				m_map.AddUpdateObject(pdata->obj);			
4072
			}			
4073
		}
4074
	}
4075

    
4076
	if (!bReDrawAll)
4077
		m_map.ApplyUpdateRgn();
4078
	else
4079
		m_GraphGUI.ReDraw();
4080
}
4081

    
4082
void CGWnd::FreshPie(CBaseObj *pobj,SREALDB_VAR *pvar,char pieno)
4083
{
4084
	if(pobj == 0 || pieno <0)
4085
		return;
4086
	CPieGrp* ppie = (CPieGrp*)pobj;
4087
	float f=0.0;
4088
	CDTOperE::Vt_OutValByType(pvar,REALDB_FLOAT,0,&f);
4089
	ppie->SetRealValue(pieno,f);
4090
}
4091

    
4092
void CGWnd::FreshPlugObj(ST_VISITRDB * pdata)	//???
4093
{
4094
	CVGPlugInCore* pCore=((CPlugObj*)(pdata->obj))->m_pCore;
4095
	if(!pCore)
4096
		return;
4097

    
4098
	pCore->SetRdbVal(pdata->userdata1,pdata->sval);
4099
}
4100

    
4101
void CGWnd::FreshYc(CBaseObj * pobj,SREALDB_VAR * pvar)
4102
{
4103
	double d=0.0;
4104
	CDTOperE::Vt_OutValByType(pvar,REALDB_DOUBLE,0,&d);
4105
	CYaoCeObj * pyc = (CYaoCeObj *) pobj;
4106
	pyc->SetFloat(d);
4107
}
4108

    
4109
void CGWnd::FreshMeterObj(CBaseObj *pobj, SREALDB_VAR *pvar)
4110
{
4111
	double d = 0.0;
4112
	CDTOperE::Vt_OutValByType(pvar, REALDB_DOUBLE, 0, &d);
4113
	CMeterObj * pMeterObj = (CMeterObj *) pobj;
4114
	pMeterObj->SetValue(d);
4115
}
4116

    
4117
void CGWnd::FreshCounterObj(CBaseObj *pobj, SREALDB_VAR *pvar)
4118
{
4119
	UINT d = 0;
4120
	CDTOperE::Vt_OutValByType(pvar, REALDB_UINT, 0, &d);
4121
	CCounterObj * pObj = (CCounterObj *) pobj;
4122
	pObj->SetValue(d);
4123
}
4124

    
4125
void CGWnd::FreshTrainObj(CBaseObj *pobj, SREALDB_VAR *pvar, int nNo)
4126
{
4127
	SRDB_PARAINFO * pRdbdata = (SRDB_PARAINFO *)m_rdbpara.GetUnit(nNo);
4128
	ST_VISITRDB *pDatdata = (ST_VISITRDB *)m_rdbdata.GetUnit(nNo);
4129
	if (pRdbdata && pDatdata)
4130
	{
4131
		CAtsTrain * pObj = (CAtsTrain *)pobj;
4132
		TRAIN_VALUE tv = (TRAIN_VALUE)pDatdata->userdata1;	
4133
		int trainNo=atoi(pObj->GetTrianNo());//WYF 20200103
4134
		if(g_ehmiMainFrame->m_AtsTrainNo>=0){
4135
			if(g_ehmiMainFrame->m_AtsTrainNo==trainNo)
4136
			{	
4137
				if(!(pObj->GetFlag()))	pObj->SetFlag(1);
4138
			}
4139
			else
4140
				if(pObj->GetFlag())	pObj->SetFlag(0);
4141
		}
4142
		else{
4143
			if(pObj->GetFlag())	pObj->SetFlag(0);
4144
		}//WYF 20200103
4145
		pObj->SetValue(tv, *pvar);
4146
		COLORREF clrActive;
4147
		CBaseObj *pStatic = pObj->CheckArrivalPlatForm(clrActive);
4148
		if (pStatic)
4149
		{
4150
			int			penStyle; // ????
4151
			short int	penWidth; // ?߿?
4152
			penStyle = pStatic->GetLineStyle().penStyle;
4153
			penWidth = pStatic->GetLineStyle().penWidth;
4154
			CLineStyle type(penStyle, clrActive, penWidth);
4155
			pStatic->SetLineStyle(type);
4156
			
4157
			CFRect fRect;
4158
			fRect = pStatic->GetObjectRect();
4159
			DrawObj(&fRect);		
4160
		}
4161
	}
4162
}
4163

    
4164
void CGWnd::FreshButtonObj(CBaseObj * pobj, SREALDB_VAR * pvar)
4165
{
4166
	int n = 0;
4167
	CDTOperE::Vt_OutValByType(pvar, REALDB_INT, 0, &n);
4168
	CButtonObj * pBtnObj = (CButtonObj *) pobj;
4169
	pBtnObj->SetEventFlag(n);
4170
}
4171

    
4172
void CGWnd::FreshYcStatus(CBaseObj * pobj,SREALDB_VAR * pvar)
4173
{
4174
	BOOL bSpecialCtrl = FALSE;
4175
	CYaoCeObj * pyc = (CYaoCeObj *) pobj;
4176
	unsigned int status = pvar->m_val.uintval;
4177
	if (g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_ALMCTRL] && PT_IS_INHIB_ALM(status))
4178
	{
4179
		pyc->SetRealBackColor(g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_ALMCTRL]);
4180
	}
4181
	else if(g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_LOCK] && 
4182
		     PT_IS_MAN_VAL(status))
4183
	{
4184
		pyc->SetRealBackColor(g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_LOCK]);
4185
	}
4186
	else if( g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_LIMIT] &&
4187
			(PT_IS_RL_ALM(status) || 
4188
			PT_IS_LEL_ALM(status) || 
4189
			PT_IS_LNL_ALM(status) || 
4190
			PT_IS_HNL_ALM(status)|| 
4191
			PT_IS_HEL_ALM(status)))
4192
	{
4193
		// ң??ֻ?ж???˸״̬λ
4194
		if (PT_IS_FLASHING(status)) 
4195
		{
4196
			bSpecialCtrl = TRUE;			
4197
		}	
4198
		pyc->SetRealBackColor(g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_LIMIT]);
4199
	}
4200
	else if(g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_INVALITE] && 
4201
			(PT_IS_DEAD(status)||
4202
			PT_IS_INCONSISTE(status)||
4203
			PT_IS_UNCHG_VAL(status)))
4204
	{
4205
		pyc->SetRealBackColor (g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_INVALITE]);
4206
	}
4207
	else if(g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_PL] && PT_IS_REPLACED(status))
4208
	{
4209
		pyc->SetRealBackColor (g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_PL]);
4210
	}	
4211
	else 
4212
	{	
4213
		pyc->SetUserControl(FALSE);
4214
	}
4215
	if (bSpecialCtrl)					
4216
	{
4217
		//???ӵ???˸?б???
4218
		AddObjToList(pobj);	
4219
	}
4220
	else
4221
	{
4222
		DeleteObjFromList(pobj);
4223
	}
4224
}
4225

    
4226
void CGWnd::FreshCur(CBaseObj * pobj,SREALDB_VAR * pvar,char curno)
4227
{
4228
	CCurverObj	* pcur = (CCurverObj *) pobj;
4229
	if (pcur->GetCurType() == 0) // YC
4230
	{
4231
		pcur->SetRealValue(curno, pvar->m_val.floatval);
4232
	}
4233
	else
4234
	{
4235
		pcur->SetRealValue(curno, pvar->m_val.doubleval);
4236
	}
4237
}
4238

    
4239
void CGWnd::FreshBar(CBaseObj * pobj,SREALDB_VAR * pvar)
4240
{
4241
	CBarObj * pbar = (CBarObj *) pobj;
4242
	pbar->SetBarValue(pvar->m_val.floatval);
4243
	
4244
}
4245

    
4246
void CGWnd::FreshYx(CBaseObj * pobj,SREALDB_VAR * pvar)
4247
{
4248
	OBJECT_SHAPE shapeId=OS_UNKNOWN;
4249
    shapeId=pobj->GetObjectShape();
4250
	switch(shapeId)
4251
	{	
4252
	case OS_POINTDEV:
4253
		{
4254
			CPointDevice * pdev = (CPointDevice *) pobj;
4255

    
4256
//		    if(pdev->GetDeviceType() == SE_K_DEV_SWITCH||
4257
//			pdev->GetDeviceType() == SE_K_DEV_BREAK)
4258
			{
4259
				STRUCT_POINTOBJINFO info;
4260
				pdev->GetPointInfo(info);
4261
				CSymbol *pSym = 0;
4262
				short posnum;
4263
			
4264
				pSym    = g_SymLib.GetSymbol(info.nGeneralCls , info.nDetailCls);
4265
				if(pSym)
4266
				{
4267
					posnum=pSym->GetStatusNum();
4268
				
4269
				if(posnum < pvar->m_val.ucharval)
4270
				{
4271
				     STRUCT_DEVBASEINFO devinfo;
4272
					 pdev->GetDevInfo(devinfo);
4273
                     CString sz;
4274
					 sz = devinfo.sYXCode;
4275
                //     AfxMessageBox(sz +"?????쳣");
4276
				     return;
4277
				}
4278
				else
4279
				  pdev->SetSymbolStatus(pvar->m_val.ucharval);
4280
			}
4281
			}
4282
			// ??˸????Ϊ2,ֻ?ж??Ƿ??????˸????
4283
			if (pdev->GetFlashType() == FLASH_STATE_EQUAL)
4284
			{
4285
				if (pdev->GetFlashState() == pvar->m_val.ucharval) 
4286
				{
4287
					// ???ӵ???˸?б???
4288
					AddObjToList(pobj);
4289
				}
4290
				else 
4291
				{
4292
					DeleteObjFromList(pobj);
4293
				}
4294
			}
4295
		}
4296
		break;
4297
	case OS_STATUSOBJ:
4298
		{
4299
			CStatusObj *pstatus = (CStatusObj*)pobj;
4300
          
4301
			STRUCT_POINTOBJINFO info;
4302
			pstatus->GetPointInfo(info);
4303
			CSymbol *pSym = 0;
4304
			short posnum;
4305
			pSym    = g_SymLib.GetSymbol(info.nGeneralCls , info.nDetailCls);
4306
            if(pSym)
4307
			{
4308
				posnum=pSym->GetStatusNum();
4309

    
4310
			if(posnum < pvar->m_val.ucharval) 
4311
			{
4312
			//	AfxMessageBox(pstatus->GetStatusCode()+"?????쳣");
4313
				return;
4314
			}
4315

    
4316
			pstatus->SetSymbolStatus(pvar->m_val.ucharval);
4317
			}
4318

    
4319
			// ??˸????Ϊ2,ֻ?ж??Ƿ??????˸????
4320
			if (pstatus->GetFlashType() == FLASH_STATE_EQUAL) 
4321
			{
4322
				if (pstatus->GetFlashState() == pvar->m_val.ucharval) 
4323
				{
4324
					// ???ӵ???˸?б???
4325
					AddObjToList(pobj);
4326
				}
4327
				else 
4328
				{
4329
					DeleteObjFromList(pobj);
4330
				}
4331
			}
4332
		}
4333
		break;
4334
	case OS_REALSTRINGOBJ:
4335
		{
4336
			CRealStringObj *pRealString = (CRealStringObj*)pobj;
4337
            
4338
			char szTemp[20];
4339
			int pointnum=pRealString->GetPointNum();
4340
			//ֱ?????ַ??????
4341
            CDTOperE::Vt_OutValByChar(pvar,szTemp,20,pointnum);
4342
	
4343
            pRealString->SetText(szTemp);
4344
			 
4345
		}
4346
		break;
4347
	case OS_YAOKONG:
4348
		{
4349
			CYaokongObj * pYK = (CYaokongObj *) pobj;
4350

    
4351
			pYK->SetDisplayType(pvar->m_val.ucharval);
4352
			pYK->SetYKStatusValue(pvar->m_val.ucharval);
4353
		}
4354
		break;
4355
	}
4356
}
4357

    
4358
void CGWnd::FreshYxStatus(CBaseObj * pobj,SREALDB_VAR * pvar)
4359
{
4360
	OBJECT_SHAPE shapeId=OS_UNKNOWN;
4361
    shapeId=pobj->GetObjectShape();
4362
	unsigned int status =  pvar->m_val.uintval;
4363
	switch(shapeId)
4364
	{
4365
	case OS_POINTDEV:
4366
        {
4367
			CPointDevice * pdev = (CPointDevice *)pobj;
4368
			if(!pdev) 
4369
				return;
4370
			// ң???ж???˸״̬λ?Լ??Ƿ??????˸????
4371
			BOOL bStatus = FALSE;
4372
			BYTE FlashType = pdev->GetFlashType();			
4373
			if (FlashType == FLASH_STATE_CHANGE)
4374
			{
4375
				bStatus = PT_IS_FLASHING(status);
4376
				if (bStatus) 
4377
				{
4378
					// ???ӵ???˸?б???
4379
					AddObjToList(pobj);
4380
					//++++pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_FLASH]); 
4381
					//++++pdev->SetUserControl(FALSE);		
4382
				}
4383
				else
4384
				{
4385
					DeleteObjFromList(pobj);
4386
				}
4387
			}
4388
			else if (FlashType == FLASH_STATE_EQUAL)
4389
			{
4390
				short int status;
4391
				pdev->GetSymbolStatus(status);
4392
				if (status > 0)
4393
				{
4394
					AddObjToList(pobj);
4395
				}
4396
				else
4397
				{
4398
					DeleteObjFromList(pobj);
4399
				}
4400
			}
4401
			else if (FlashType == FLASH_STATE_EXPR)
4402
			{
4403
				pdev->GetExprStatus(bStatus);
4404
				if (bStatus)
4405
				{
4406
					AddObjToList(pobj);
4407
				}
4408
				else
4409
				{
4410
					DeleteObjFromList(pobj);
4411
				}
4412
			}
4413
			BOOL bSpecialCtrl = g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_FLASH] && bStatus;
4414
			if (!bSpecialCtrl)		
4415
			{
4416
				if( g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_ALMCTRL] &&PT_IS_INHIB_ALM(status))
4417
				{
4418
					pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_ALMCTRL]);
4419
				}
4420
				else if(g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_LOCK] && PT_IS_MAN_VAL(status))
4421
				{
4422
					pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_LOCK]);
4423
				}
4424
				else if(g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_PL] && PT_IS_REPLACED(status))
4425
				{
4426
					pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_PL]);
4427
				}
4428
				else if(g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_INVALITE] && ( PT_IS_RTU_FAIL(status)))
4429
				{
4430
					pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_INVALITE]);
4431
				}
4432
				else 
4433
				{
4434
					int v;
4435
					if (!m_frmObj.Lookup(pobj, v))
4436
						pdev->SetUserControl(FALSE);
4437
				}
4438
			}
4439
		}
4440
		break;
4441
	case OS_STATUSOBJ:
4442
		{
4443
			CStatusObj * pdev = (CStatusObj *)pobj;
4444
			if(!pdev) 
4445
				return;
4446
			
4447
			// ң???ж???˸״̬λ?Լ??Ƿ??????˸????
4448
			BOOL bStatus = PT_IS_FLASHING(status);
4449
			if (pdev->GetFlashType() == FLASH_STATE_CHANGE)
4450
			{
4451
				if (bStatus) 
4452
				{
4453
					// ???ӵ???˸?б???
4454
					AddObjToList(pobj);
4455
					//++++pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_FLASH]); 
4456
					//++++pdev->SetUserControl(FALSE);		
4457
				}
4458
				else
4459
				{
4460
					DeleteObjFromList(pobj);
4461
				}
4462
			}
4463
			if (!bStatus)  
4464
			{
4465
			   if( g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_ALMCTRL] &&PT_IS_INHIB_ALM(status))
4466
				{
4467
					pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_ALMCTRL]);
4468
				}
4469
				else if(g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_LOCK] && PT_IS_MAN_VAL(status))
4470
				{
4471
					pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_LOCK]);
4472
				}
4473
				else if(g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_PL] && PT_IS_REPLACED(status))
4474
				{
4475
					pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_PL]);
4476
				}
4477
				else if(g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_INVALITE] && ( PT_IS_ABN_VAL(status)))
4478
				{
4479
					pdev->SetUserColor(g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_INVALITE]);
4480
				}
4481
				else 
4482
				{
4483
					pdev->SetUserControl(FALSE);
4484
				}
4485
			}
4486
		}
4487
		break;
4488
	}  
4489
}
4490

    
4491
//Ӧ?ü???һ????????ӵ?
4492
/*?????ӵ?
4493
{
4494
	?????߶???????;
4495
	???????????????豸????????;
4496
	?????ӵ???ɫ;
4497
}
4498

    
4499
typedef struct {
4500
	CBaseObjArray linkLineArray;
4501
	CBaseObjArray devObjArray;
4502
	COLORREF color;
4503
}ConnectNode;
4504
*/
4505

    
4506

    
4507
void CGWnd::FreshDevStatus(CBaseObj * pobj,SREALDB_VAR * pvar)
4508
{
4509
	//?޸IJ???????ɫ??????ʱ?򣬲????豸??ʧ??ɫ
4510

    
4511
	unsigned int status =  pvar->m_val.uintval;
4512
//	CBaseObj * pdev = (CBaseObj *) pobj;
4513
    OBJECT_SHAPE shapeId=OS_UNKNOWN;
4514
	int type;
4515
	CString szDevCode;
4516

    
4517
    shapeId=pobj->GetObjectShape();
4518

    
4519
	STRUCT_DEVBASEINFO devinfo;
4520
	if(shapeId == OS_DEVBUSLINE) //ĸ??
4521
	{
4522
		CDevBusLine *pdev=(CDevBusLine*)pobj;
4523
		szDevCode=pdev->GetDevCode();
4524
		type= pdev->GetDeviceType();
4525
		pdev->GetDevInfo(devinfo);
4526
	
4527
	}
4528
	else if(shapeId == OS_DEVPOWERLINE) //???߶?
4529
	{
4530
		  CDevPowerLine *pdev=(CDevPowerLine*)pobj;
4531
		  szDevCode=pdev->GetDevCode();
4532
		  type= pdev->GetDeviceType();
4533
		  pdev->GetDevInfo(devinfo);
4534
	}			
4535
	else if(shapeId ==OS_DEVLINE) //??·
4536
	{
4537
		  CDevLine *pdev=(CDevLine*)pobj;
4538
		  szDevCode=pdev->GetDevCode();
4539
		  type= pdev->GetDeviceType();
4540
		  pdev->GetDevInfo(devinfo);
4541
	}			  
4542
	else if(shapeId == OS_POINTDEV) //???豸
4543
	{
4544
		  CPointDevice *pdev=(CPointDevice*)pobj;
4545
		  szDevCode=pdev->GetDevCode();
4546
          type= pdev->GetDeviceType();
4547
		  pdev->GetDevInfo(devinfo);
4548
	}	
4549
	else if(shapeId == OS_SIGNOBJ) //??־?Ʋ???ɫ
4550
	{
4551
        pobj->SetRealSetColor(FALSE,0L);
4552
	    return;
4553
	}
4554

    
4555
	if(g_ehmiMainFrame->m_faceSetting.colormode ==0) //????ɫ
4556
	{
4557
		//???????ɫ??û???õ?
4558
		pobj->SetRealSetColor(FALSE,0L);
4559
		return;
4560
	}
4561

    
4562
	if(g_ehmiMainFrame->m_faceSetting.fotherback[NOPOWER_COLOR])
4563
	{
4564
		if(strcmp(devinfo.sDevCode,"") == 0 )  //???û??ѡ?㲻??ʧ??ɫ
4565
		{
4566
			pobj->SetRealSetColor(FALSE,0L);
4567
		}		
4568
		else
4569
		   pobj->SetRealSetColor(TRUE,g_ehmiMainFrame->m_faceSetting.other_back[NOPOWER_COLOR]);
4570
	}
4571
	else
4572
		pobj->SetRealSetColor(FALSE,0L);
4573
}
4574

    
4575
void CGWnd::FreshTag(CBaseObj * pobj,SREALDB_VAR * pvar)
4576
{
4577
	g_ehmiMainFrame->UpdateTagDev();
4578

    
4579
	m_tagCount = 5;
4580
}
4581

    
4582
void CGWnd::FreshScriptLinkData(CBaseObj *pobj)
4583
{
4584
	
4585
	if (pobj->GetScriptLenRun() > 0)
4586
	{
4587
		BOOL bHaveChange = FALSE;
4588
		CString script;
4589
		CString str;
4590

    
4591
		int idx;
4592
		if (m_scriptObj.Lookup(pobj, idx))
4593
		{
4594
			int index    = idx & 0xffff;
4595
			int paranums = idx >> 16;
4596

    
4597
			for (int i=0; i < paranums; i++)
4598
			{
4599
				ST_VISITRDB *rdata = (ST_VISITRDB *) m_rdbdata.GetUnit(m_scriptNo[index+i]);
4600
				if (!rdata)
4601
					return;
4602

    
4603
				UREALDB_VT &vt = rdata->sval.m_val;
4604
				float val = rdata->sval.m_type == REALDB_FLOAT ? vt.floatval : vt.ucharval;
4605
				str.Format("local %s = %f;", m_scriptVar[index+i], val);
4606
				script += str;
4607
				//<wyf 2010.03.11 ??ʱʹ??0??Ϊģ?????ķֽ??,??????ֵƯ?Ʊ仯??????ű??𵴴???>
4608
				//fgt 20170707  ??? ΪʲôҪע?????
4609
/*				if (m_bWndAnalogF)
4610
				{
4611
					char NewFlag = val > 0.00001 ? 1 : 0;
4612
					if (rdata->userdata1 != NewFlag)
4613
					{
4614
						rdata->userdata1 = NewFlag;
4615
						bHaveChange = TRUE;					
4616
					}	
4617
				}
4618
				else
4619
				{
4620
					bHaveChange = TRUE;	
4621
				}*/
4622
				bHaveChange = TRUE;	
4623
				//fgt 20170707  ??? ΪʲôҪע?????
4624
			}
4625
		}
4626
		
4627
		if (m_metaObj.Lookup(pobj, idx))
4628
		{
4629
			int index    = idx & 0xffff;
4630
			int paranums = idx >> 16;
4631

    
4632
			for (int i=0; i < paranums; i++)
4633
			{
4634
				str.Format("local %s = %d;", m_metaSta[index+i].var, m_metaSta[index+i].val);
4635

    
4636
				script += str;
4637

    
4638
				//<wyf 2010.03.11>
4639
				//fgt 20170707  ??? ΪʲôҪע?????
4640
			/*	char NewFlag = m_metaSta[index+i].val;
4641
				if (m_metaSta[index+i].userdata1 != NewFlag)
4642
				{
4643
					m_metaSta[index+i].userdata1 = NewFlag;
4644
					bHaveChange = TRUE;					
4645
				}*/	
4646
				bHaveChange = TRUE;	
4647
				//fgt 20170707  ??? ΪʲôҪע?????
4648
			}
4649
		}
4650

    
4651
		script += (const char *)pobj->m_pScriptDataRun;
4652
		
4653
		if (!bHaveChange)
4654
		{			
4655
			script = _T("");
4656
		}
4657
		m_pCurObj = pobj;
4658
		m_pView->m_Script.ExecString(script, this);		
4659
		m_pCurObj = NULL;
4660
	}
4661
}
4662

    
4663
void CGWnd::FreshLogicLinkData(CBaseObj *pobj)
4664
{
4665
	BOOL bLogicDll = FALSE;
4666
	int logic = 0;
4667

    
4668
	if (pobj->GetObjectShape() == OS_POINTOBJ || pobj->GetObjectShape() == OS_POINTDEV)
4669
	{
4670
		logic = ((CPointObj *)pobj)->GetDllType() - 1;
4671

    
4672
		if (logic >= 0 && logic < g_ehmiMainFrame->m_pfLogic.GetSize()
4673
			&& g_ehmiMainFrame->m_pfLogic[logic] != NULL)
4674
		{
4675
			bLogicDll = TRUE;
4676
		}
4677
	}
4678

    
4679
	if (bLogicDll)
4680
	{
4681
		int idx;
4682
		if (!m_logicObj.Lookup(pobj, idx))
4683
			return;
4684

    
4685
		int index    = idx & 0xffff;
4686
		int paranums = idx >> 16;
4687

    
4688
		CArray<int, int> para;
4689
		para.SetSize(paranums);
4690

    
4691
		for (int i=0; i < paranums; i++)
4692
		{
4693
			ST_VISITRDB *rdata = (ST_VISITRDB *) m_rdbdata.GetUnit(m_logicNo[index+i]);
4694
			if (!rdata)
4695
				return;
4696

    
4697
			UREALDB_VT &val = rdata->sval.m_val;
4698
			para[i] = rdata->sval.m_type == REALDB_FLOAT ? val.floatval : val.ucharval;
4699
		}
4700

    
4701
		int result = g_ehmiMainFrame->m_pfLogic[logic](para.GetData(), para.GetSize());
4702

    
4703
		if (result >= 0)
4704
		{
4705
			unsigned char status = 0;
4706
			unsigned char nums = 0;
4707

    
4708
			if (logic == 0)		// ????ͼԪ???ö???̬??δ֪̬
4709
			{
4710
				STRUCT_POINTOBJINFO info;
4711
				((CPointObj *)pobj)->GetPointInfo(info);
4712

    
4713
				short statusNum = 0;
4714

    
4715
				CSymbol *pSym = g_SymLib.GetSymbol(info.nGeneralCls, info.nDetailCls);
4716
				if (pSym)
4717
					statusNum = pSym->GetStatusNum();
4718

    
4719
				int unknow = ((CPointObj *)pobj)->GetMotionType() < 2 ? 2 : 3;
4720
//WYF 20180711
4721
//				status = result < unknow ? result : statusNum - 1;
4722
				if(statusNum>=8)
4723
					status = result < unknow ? result : 7;
4724
				else
4725
					status = result < unknow ? result : statusNum - 1;
4726
//WYF 20180711
4727
				nums = statusNum - 2;
4728

    
4729
				if (status < 0)
4730
					status = 0;
4731

    
4732
				if (nums < 0)
4733
					nums = 0;
4734
			}
4735
			else
4736
			{
4737
				status = result;
4738
				nums = 0;
4739
			}
4740
//WYF 20180711
4741
//			((CPointObj *)pobj)->SetSymbolStatus(status, nums);
4742
			if(nums>=6)
4743
				((CPointObj *)pobj)->SetSymbolStatus(status, 6);
4744
			else
4745
				((CPointObj *)pobj)->SetSymbolStatus(status, nums);
4746
//WYF 20180711
4747
			CPointObj *pdev = (CPointObj *)pobj;
4748
			// ??????ң?ŵ?,ֻ?ж??Ƿ??????˸????
4749
			if (pdev->GetFlashType() == FLASH_STATE_EQUAL)
4750
			{
4751
				if (pdev->GetFlashState() == status) 
4752
				{
4753
					//???ӵ???˸?б???
4754
					AddObjToList(pobj);
4755
				}
4756
				else 
4757
				{
4758
					DeleteObjFromList(pobj);
4759
				}
4760
			}
4761
		}
4762
	}
4763
}
4764

    
4765
BOOL CGWnd::OnEraseBkgnd(CDC* pDC) 
4766
{
4767
	if (m_map.hasOpened() )return true;
4768
	return CWnd::OnEraseBkgnd(pDC);
4769
}
4770

    
4771
void CGWnd::OnSize(UINT nType, int cx, int cy) 
4772
{
4773
	CWnd::OnSize(nType, cx, cy);
4774
	
4775
	if (m_GraphGUI.hasInitMem())
4776
		m_GraphGUI.ReSize(cx,cy);
4777
}
4778

    
4779
void CGWnd::SetRealCurPara(STRUCT_ONECUR_INFO *curinfo,int curno, CCurverObj *pcur)
4780
{
4781
	CSE_DBOption dboption;
4782
	SEDB_CMDINFO cmdinfo;
4783
	SEDB_DATAFMT *datafmt=NULL;
4784
	char cmdbuf[1256];
4785
	int count;
4786
	if (pcur->GetCurType() == 0) // YC
4787
	{
4788
		sprintf(cmdbuf,"select F4007_SAVEINTERVAL,F4007_PLANINTERVAL from %s.dbo.%s where F4007_POINTCODE='%s'",
4789
			SCADA_PARALIB,YC_PARA_TBLNAME,
4790
			curinfo->Code);	
4791
	}
4792
	else
4793
	{
4794
		sprintf(cmdbuf,"select F4014_SAVEINTERVAL from %s.dbo.%s where F4014_POINTCODE='%s'",
4795
			SCADA_PARALIB,KWH_PARA_TBLNAME,
4796
			curinfo->Code);		
4797
	}
4798
	dboption.BeginSelectRcdSet(cmdbuf);
4799
	count = dboption.GetRcdCount();
4800
	if(count <=0){
4801
		pcur->SetOneCurverSaveSpace(curno,60);
4802
		dboption.EndSelectRcdSet();
4803
		return;
4804
	}
4805

    
4806
	short saveinterl;
4807
	short planinterl;
4808
	if (pcur->GetCurType() == 0) // YC
4809
	{
4810
		saveinterl = dboption.GetShortVal(0,0);
4811
		planinterl = dboption.GetShortVal(0,1);
4812
	}
4813
	else
4814
	{
4815
		saveinterl = dboption.GetShortVal(0,0);
4816
		planinterl = 10;
4817
	}
4818

    
4819
	if(curinfo->CurDatType == 0 || curinfo->CurDatType ==2)
4820
		pcur->SetOneCurverSaveSpace(curno,(int)saveinterl);
4821
	else 
4822
		pcur->SetOneCurverSaveSpace(curno,(int)planinterl);
4823
	dboption.EndSelectRcdSet();
4824
	return;
4825
}
4826

    
4827
void CGWnd::SetRealCurData(STRUCT_ONECUR_INFO *curinfo,int curno, CCurverObj *pcur)
4828
{
4829
	int i;
4830
	CSE_DBOption dboption;
4831
	SEDB_CMDINFO cmdinfo;
4832
	SEDB_DATAFMT *datafmt=NULL;
4833
	char cmdbuf[1256];
4834
	int count;
4835
	
4836
	int flag =0;
4837
	char tabname[256];
4838
	if(curno==0)pcur->ClearAllCurverData();
4839
	//??ȡ???ݿ??е?????
4840
	CAutoMalloc   curdata;
4841
	curdata.SetPara(10,sizeof(STRUCT_CURDATVAL),1);
4842

    
4843
	SSE_CLOCK kk;
4844
	CSeTime	kt;
4845
	TCriterionTime endsecond;
4846
	TCriterionTime beginsecond;
4847
	kt.GetNow(&kk);
4848
	kk.hour =0;
4849
	kk.minute =0;
4850
	kk.second =0;
4851
	kk.msecond =0;
4852
	kt.CovertClock(&kk,&beginsecond);
4853
	kt.GetNow(&endsecond);
4854
	CString strTableName = "";
4855
	if (pcur->GetCurType() == 0) // YC
4856
	{
4857
		strTableName = SCADA_DATA_TBLHEAD;
4858
		flag = HISDATA_REAL_INSTANT;
4859
	}
4860
	else
4861
	{
4862
		strTableName = "se_accdata";
4863
		flag = HISDATA_REAL_ACC;
4864
	}
4865
	if(curinfo->CurDatType ==0){////0:????ֵ 1???ƻ?ֵ 2??????ֵ
4866
		//flag = HISDATA_REAL_INSTANT;
4867
		sprintf(tabname,"%s.dbo.%s%4d%02d",SCADA_DATALIB,strTableName,kk.year,kk.month);
4868
	}
4869
	else if(curinfo->CurDatType ==1){
4870
		flag = HISDATA_PLAN;
4871
		endsecond = beginsecond + 24*60*60;
4872
		sprintf(tabname,"%s.dbo.%s%4d%02d",SCADA_DATALIB,strTableName,kk.year,kk.month);
4873
	}
4874
	else /*if(curinfo->CurDatType ==2)*/{
4875
		endsecond = beginsecond;
4876
		beginsecond = beginsecond - 24*60*60;
4877
		SSE_DATE curdate;
4878
		kt.GetYestoday (&curdate);
4879
		//flag = HISDATA_REAL_INSTANT;
4880
		sprintf(tabname,"%s.dbo.%s%4d%02d",SCADA_DATALIB,strTableName,curdate.year,curdate.month);
4881
	}
4882

    
4883
	sprintf(cmdbuf,"select SEDATUM,SE_T from %s where SECODE='%s' and SE_T>=%d and SE_T<=%d and FLAG=%d",
4884
		tabname,
4885
		curinfo->Code,
4886
		beginsecond,
4887
		endsecond,
4888
		flag);
4889
	dboption.BeginSelectRcdSet(cmdbuf);
4890
	count = dboption.GetRcdCount();
4891
	if(count <=0){
4892
		dboption.EndSelectRcdSet();
4893
		return;
4894
	}
4895
	float minval=9999.0,maxval=-9999.0;
4896
	STRUCT_CURDATVAL * pcurdata;
4897
	for(i=0;i<count;i++){
4898
		float val	= dboption.GetFloatVal(i,0);
4899
		int   second = dboption.GetIntVal(i,1);
4900
		if(minval>val) minval = val;
4901
		if(maxval<val) maxval = val;
4902
		pcurdata = (STRUCT_CURDATVAL * )curdata.GetNextUnit();
4903
		pcurdata->minute = (second-beginsecond)/60;
4904
		pcurdata->value  = val;
4905
	}
4906
	pcur->InputOneCurveData (curno,count,(STRUCT_CURDATVAL*)curdata.GetMemInfo());
4907
	dboption.EndSelectRcdSet();
4908
}
4909

    
4910
void CGWnd::UpdateAllCurInfo(CVGRegion * region)
4911
{
4912
	STRUCT_ONECUR_INFO * cur = NULL;
4913
	CBaseObjArray & ObjArray = GetFeatureObjects(OS_CURVER);
4914
	STRUCT_CURDATVAL curdata;
4915

    
4916
	SSE_CLOCK kk;
4917
	CSeTime	kt;
4918
	kt.GetNow(&kk);
4919

    
4920
	for(int i=0;i<ObjArray.GetSize ();i++)
4921
	{
4922
		CCurverObj * pcur =(CCurverObj *)ObjArray[i];
4923
		if(!pcur)
4924
			continue;
4925

    
4926
		int curcount = pcur->GetCurveNum();
4927
		if(curcount<=0)break;
4928
		region->Add(pcur);
4929
		for(int j=0;j<curcount;j++)
4930
		{
4931
			cur = pcur->GetOneCurveInfo(j);
4932
			if(kk.hour == 0 && kk.minute == 3)
4933
			{//?賿ʱ????????
4934
				if(j==0)pcur->ClearAllCurverData();
4935
				//???ô??̼??????????
4936
				SetRealCurPara(cur,j,pcur);
4937
				//??????ʷ???ݿ??е????ݣ?????ʾ֮
4938
				SetRealCurData(cur,j,pcur);
4939
			}
4940
			if(cur && cur->CurDatType ==0)
4941
			{//ʵʱ????
4942
				curdata.minute = kk.hour *60+kk.minute;
4943
				curdata.value  = pcur->GetRealValue(j);
4944
				pcur->InputOneCurveData (j,1,&curdata);
4945
			}
4946
		}
4947
	}
4948
}
4949

    
4950
void CGWnd::UpdateAllMoveObj(CVGRegion * region)
4951
{
4952
	CEasyList *playList = m_map.GetAllFeatureLayers();
4953
	if (playList)
4954
	{
4955
		for (int i=0; i < playList->GetListLen(); i++)
4956
		{
4957
			CEasyList *pObjLst = ((CFeatureLayer *)playList->GetNth(i))->GetObjects();
4958
			if (pObjLst)
4959
			{
4960
				for(int j=0; j < pObjLst->GetListLen(); j++)
4961
				{
4962
					CBaseObj *pObj = (CBaseObj*)pObjLst->GetNth(j);
4963
					if (pObj)
4964
					{
4965
						OBJECT_SHAPE shapeId = pObj->GetObjectShape();
4966

    
4967
						// ˢ??ʱ?ӡ?????
4968
						if (shapeId == OS_CLOCK || shapeId == OS_DEVPOWERLINE)
4969
						{						
4970
							region->Add(pObj);							
4971
						}
4972
					}
4973
				}
4974
			}
4975
		}
4976
	}
4977
}
4978

    
4979
void CGWnd::AddObjToList(CBaseObj * pobj)
4980
{	
4981
	if(g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_FLASH])
4982
	{
4983
		//?Ƿ??Ѿ????б???
4984
		for(int i=0;i<m_Flashlist.GetSize();i++)
4985
		{
4986
			if(m_Flashlist[i]==pobj)
4987
				return;
4988
		}
4989
	     //m_Flashlist.Add(pobj);
4990
		//ֻ?п??غ͵?բ????˸
4991
       OBJECT_SHAPE shapeId=OS_UNKNOWN;
4992
	   shapeId=pobj->GetObjectShape();
4993
	   if(shapeId == OS_POINTDEV)
4994
	   {
4995
		 CPointDevice *pDev=(CPointDevice*)pobj;
4996
		 if(pDev)
4997
		 {
4998
 //            int Devid=pDev->GetDeviceType();
4999
 //            if(Devid==SE_K_DEV_BREAK || Devid==SE_K_DEV_SWITCH)
5000
		         m_Flashlist.Add(pobj);
5001
		 }	    
5002
	   }
5003
	   else if(shapeId == OS_STATUSOBJ)
5004
	   {
5005
		 CStatusObj *pStatus=(CStatusObj*)pobj;
5006
		 if(pStatus)
5007
		 {
5008
	         m_Flashlist.Add(pobj);
5009
		 }	    
5010
	   }
5011
	}	
5012
}
5013

    
5014
void CGWnd::DeleteObjFromList(CBaseObj *pobj)
5015
{	
5016
	if(g_ehmiMainFrame->m_faceSetting.fyxback[YXBACK_COLOR_FLASH])
5017
	{
5018
		for(int i =0;i<m_Flashlist.GetSize();i++)
5019
		{
5020
			if(m_Flashlist[i]==pobj)
5021
			{				
5022
				m_Flashlist.RemoveAt(i);
5023
				pobj->SetFreshFlag(FALSE);
5024
				pobj->Refresh(&m_GraphGUI,&pobj->GetObjectRect());
5025
				break;;
5026
			}
5027
		}
5028
	}
5029
}
5030

    
5031
void CGWnd::UpdateAllTagInfo(BOOL buffer)
5032
{
5033
	//??ȡ??־????Ϣ:---------------------
5034
	int i,j;
5035
	CArray<TAGPARA ,TAGPARA&> tagedDev;
5036
	TAGPARA tagpara;
5037

    
5038
	if (buffer)
5039
	{
5040
		g_ehmiMainFrame->GetTagDev(tagedDev);
5041

    
5042
		int rcdcnt = tagedDev.GetSize();
5043
		for (i=0; i < rcdcnt; i++)
5044
		{
5045
			//?????ݿ????е??ƹҵ?ͼ???С?
5046
			AddOneTag(tagedDev[i].devcode, tagedDev[i].type, tagedDev[i].pos);
5047
		}
5048
	}
5049
	else
5050
	{
5051
		CRdbSqlAccess tagsqlcli;
5052
		tagsqlcli.OptTbl(TAG_RDB_TBLNAME);
5053
		tagsqlcli.SelectCol ("TagType");
5054
		tagsqlcli.SelectCol ("DevCode");
5055
		tagsqlcli.SelectCol ("Orientation");
5056
		tagsqlcli.SetUserPwd("guest","");
5057

    
5058
		int ret = tagsqlcli.ExecSelect();
5059
		if(ret==REALDB_TRUE) {
5060
			int rcdcnt=tagsqlcli.GetRcdCount();
5061
			for(i=0;i<rcdcnt;i++){
5062
				memset(&tagpara,0,sizeof(TAGPARA));
5063
				tagpara.type = tagsqlcli.GetUIntVal(i,0);
5064
				strcpy(tagpara.devcode ,tagsqlcli.GetString(i,1));
5065
				tagpara.pos  = tagsqlcli.GetUIntVal(i,2);
5066
				//?????ݿ????е??ƹҵ?ͼ???С?
5067
				AddOneTag(tagpara.devcode ,tagpara.type ,tagpara.pos );
5068
				tagedDev.Add (tagpara);
5069
			}
5070
		}
5071
		else
5072
			return;
5073
	}
5074

    
5075
	//?????ݿ???û?е??????
5076
	int tagnum = tagedDev.GetSize();
5077
	for(i=0;i<m_TagedDevlist.GetSize();i++){
5078
		for(j=0;j<tagnum;j++){
5079
			if(strcmp(m_TagedDevlist[i].devcode,tagedDev[j].devcode)==0 && 
5080
				(int)m_TagedDevlist[i].type ==  (int)tagedDev[j].type){
5081
				break;
5082
			}
5083
		}
5084
		if(j==tagnum){//??ʵʱ????û??
5085
			DelOneTag(m_TagedDevlist[i].devcode,m_TagedDevlist[i].type);	
5086
			i--;
5087
		}
5088
	}
5089
}
5090

    
5091
#define DEF_TAG_SIZE	10
5092

    
5093
CBaseObj * CGWnd::AddOneTag(TAGPARA & tagpara ,CBaseObj * pobj)
5094
{
5095
	CFRect rect = pobj->GetObjectRect(); 
5096
	CFRect tagrect;
5097
	CSignObj *tagobj = (CSignObj *)new CSignObj(rect);
5098

    
5099
	tagobj->SetSignType(tagpara.type);
5100

    
5101
	tagobj->SetDrawingAttr(FT_SIGN, tagpara.type, 0);
5102
//	tagobj->AttachWnd(GetSafeHwnd());
5103
	STRUCT_DEVBASEINFO devinfo;
5104
    OBJECT_SHAPE shapeId	=	pobj->GetObjectShape();            
5105
    switch(shapeId)
5106
	{
5107
	case OS_POINTDEV:
5108
		{
5109
           CPointDevice *pDev=(CPointDevice*)pobj;
5110
		   if(pDev)
5111
		   {
5112
			   pDev->GetDevInfo(devinfo);             
5113
		   }
5114
		}
5115
		break;
5116
	case OS_DEVBUSLINE:
5117
        {
5118
           CDevBusLine *pDev=(CDevBusLine*)pobj;
5119
		   if(pDev)
5120
		   {
5121
			   pDev->GetDevInfo(devinfo);              
5122
			   
5123
		   }
5124
		}
5125
		break;
5126
	case OS_DEVPOWERLINE:
5127
		{
5128
           CDevPowerLine *pDev=(CDevPowerLine*)pobj;
5129
		   if(pDev)
5130
		   {
5131
			   pDev->GetDevInfo(devinfo);              
5132
			   
5133
		   }
5134
		}
5135
		break;
5136
	case OS_DEVLINE:
5137
		{
5138
           CDevLine *pDev=(CDevLine*)pobj;
5139
		   if(pDev)
5140
		   {
5141
			   pDev->GetDevInfo(devinfo);              
5142
			   
5143
		   }
5144
		}
5145
		break;
5146
	}
5147
//	((CPowerBase*)pobj)->GetDevInfo(devinfo);	
5148

    
5149
//???????κ͵????豸
5150
	CFPoint point;
5151
	point = rect.CenterPoint();
5152

    
5153
	//???????????2??ȡ?ڶ???????Ϊ??׼??
5154
	if(devinfo.nDevType == SE_K_DEV_LINE )
5155
	{
5156
		CBaseLine * pline = (CBaseLine * )pobj;
5157
		unsigned int count = pline->GetPointCount();
5158
			if(count >2)
5159
			{
5160
				point = pline->GetPointPos(1);
5161
			}
5162
	}
5163

    
5164
	switch (tagpara.pos)
5165
	{
5166
	case 1://??	
5167
		point.y = rect.bottom + DEF_TAG_SIZE;
5168
		break;
5169
	case 2://??
5170
		point.y = rect.top  - DEF_TAG_SIZE;
5171
		break;
5172
	case 3://??
5173
		point.x = rect.left  - DEF_TAG_SIZE;
5174
		break;
5175
	case 4://??
5176
		point.x = rect.right + DEF_TAG_SIZE;
5177
		break;
5178
	case 5://????
5179
		point.x = rect.left  - DEF_TAG_SIZE;
5180
		point.y = rect.bottom + DEF_TAG_SIZE;
5181
		break;
5182
	case 6://????
5183
		point.x = rect.right + DEF_TAG_SIZE;
5184
		point.y = rect.bottom + DEF_TAG_SIZE;
5185
		break;
5186
	case 7://????
5187
		point.x = rect.left  - DEF_TAG_SIZE;
5188
		point.y = rect.top  - DEF_TAG_SIZE;
5189
		break;
5190
	case 8://????
5191
		point.x = rect.right + DEF_TAG_SIZE;
5192
		point.y = rect.top  - DEF_TAG_SIZE;
5193
		break;
5194
	default: //case 0://????
5195
		break;
5196
	}
5197

    
5198
	tagrect.top		=point.y -  DEF_TAG_SIZE;
5199
	tagrect.bottom	=point.y +  DEF_TAG_SIZE;
5200
	tagrect.left	=point.x - (2*DEF_TAG_SIZE);//ͼƬ?dz????ε?,???Գ???Ҫ?Ӵ?һ??,??Ȼ?ᱻѹ??,??????. Yansx 2019-08-20
5201
	tagrect.right   =point.x +  DEF_TAG_SIZE;
5202
   
5203
	tagobj->SetObjectRect(tagrect);
5204
	return tagobj; 
5205
}
5206

    
5207
CBaseObj * CGWnd::GetMetaByCode(char *code,char type , CEasyList **plist)
5208
{
5209
	//type 0:?豸  1:ң?? 2:ң??
5210
	CEasyList	*layerlist = m_map.GetAllFeatureLayers(); 
5211
	if(!layerlist)
5212
		return NULL;
5213

    
5214
	for(int layerpos=0;layerpos<layerlist->GetListLen();layerpos++)
5215
	{
5216
        CFeatureLayer *player =(CFeatureLayer *)layerlist->GetNth(layerpos);
5217
		if(!player)
5218
			 continue;
5219
		 
5220
		if (player->IsClosed())
5221
			continue;
5222

    
5223
        CEasyList *pObjList=player->GetObjects();
5224
		if(!pObjList)
5225
			continue;
5226

    
5227
		for(int objpos=0;objpos<pObjList->GetListLen();objpos++)
5228
		{
5229
            CBaseObj *pobj =(CBaseObj *)pObjList->GetNth(objpos);
5230
			if(!pobj)
5231
				continue;
5232

    
5233
            int devid;
5234
            STRUCT_DEVBASEINFO devinfo;
5235
            OBJECT_SHAPE shapeId	=	pobj->GetObjectShape();            
5236
            switch(shapeId)
5237
			{
5238
			case OS_POINTDEV:
5239
				{
5240
                   CPointDevice *pDev=(CPointDevice*)pobj;
5241
				   if(pDev)
5242
				   {
5243
					   devid=pDev->GetDeviceType();
5244
					   pDev->GetDevInfo(devinfo);
5245
                     //  if(devid == SE_K_DEV_BREAK || devid == SE_K_DEV_SWITCH)
5246
					   {
5247
						    if(strcmp(devinfo.sDevCode,code)==0)
5248
							{
5249
								if(plist) 
5250
									*plist = pObjList;
5251
								return pobj;
5252
							}						
5253
					   }			   
5254
				   }
5255
				}
5256
				break;
5257
			case OS_DEVBUSLINE:
5258
				{
5259
					CDevBusLine *pDev=(CDevBusLine*)pobj;
5260
				    if(pDev)
5261
					{
5262
                       pDev->GetDevInfo(devinfo);
5263
					   if(strcmp(devinfo.sDevCode,code)==0)
5264
					   {
5265
								if(plist) 
5266
									*plist = pObjList;
5267
								return pobj;
5268
					   }
5269
					}
5270
				}
5271
				break;
5272
			case OS_DEVPOWERLINE:
5273
				{
5274
					CDevPowerLine *pDev=(CDevPowerLine*)pobj;
5275
				    if(pDev)
5276
					{
5277
                       pDev->GetDevInfo(devinfo);
5278
					   if(strcmp(devinfo.sDevCode,code)==0)
5279
					   {
5280
							if(plist) 
5281
								*plist = pObjList;
5282
							return pobj;
5283
					   }
5284
					}
5285
				}
5286
				break;
5287
			case OS_DEVLINE:
5288
				{
5289
					CDevLine *pDev=(CDevLine*)pobj;
5290
				    if(pDev)
5291
					{
5292
                       pDev->GetDevInfo(devinfo);
5293
					   if(strcmp(devinfo.sDevCode,code)==0)
5294
					   {
5295
							if(plist) 
5296
								*plist = pObjList;
5297
							return pobj;
5298
					   }
5299
					}	
5300
				}
5301
				break;
5302
			case OS_STATUSOBJ:
5303
				{
5304
					CStatusObj *pdev = (CStatusObj *)pobj;
5305
					if(strcmp(pdev->GetStatusCode(),code)==0)
5306
					{
5307
						if(plist) 
5308
							*plist = pObjList;
5309
						return pobj;
5310
					}
5311
				}
5312
				break;
5313
			case OS_ANALOG:
5314
				{
5315
                    CYaoCeObj * pyc = (CYaoCeObj *)pobj;
5316
					if(strcmp(pyc->GetYCCode(),code)==0)
5317
					{
5318
						if(plist) *plist = pObjList;
5319
						return pobj;
5320
					}
5321
				}
5322
				break;
5323
			}
5324
	/*		((CPowerBase*)pobj)->GetDevInfo(devinfo);	
5325
			int devid =	((CPowerBase*)pobj)->GetDeviceType();
5326
		
5327
			switch (type)
5328
			{
5329
			case 1://ң?ţ????????أ???բ??״̬??
5330
				if(devid == SE_K_DEV_BREAK || devid==SE_K_DEV_SWITCH)
5331
				{
5332
					if(strcmp(devinfo.sYXCode,code)==0)
5333
					{
5334
						if(plist) *plist = pObjList;
5335
						return pobj;
5336
					}
5337
				}
5338
				else if(shapeid == OS_STATUSOBJ)
5339
				{
5340
					CStatusObj *pdev = (CStatusObj *)pobj;
5341
					if(strcmp(pdev->GetStatusCode(),code)==0)
5342
					{
5343
						if(plist) 
5344
							*plist = pObjList;
5345
						return pobj;
5346
					}
5347
				}
5348
				break;
5349
			case 2://ң??
5350
				if(shapeid == OS_ANALOG){
5351
					CYaoCeObj * pyc = (CYaoCeObj *)pobj;
5352
					if(strcmp(pyc->GetYCCode(),code)==0)
5353
					{
5354
						if(plist) *plist = pObjList;
5355
						return pobj;
5356
					}
5357
				}
5358
				break;
5359
			default: //case 0:?豸
5360
				if(devinfo.nDevType != SE_K_DEV_NULL)
5361
				{
5362
					if(strcmp(devinfo.sDevCode,code)==0)
5363
					{
5364
						*plist = pObjList;
5365
						return pobj;
5366
					}
5367
				}
5368
				break;
5369
			}//switch type*/
5370
		} // objlist         
5371
	}//laylist
5372

    
5373

    
5374
/*	CSE100LayerList	* layerlist = m_map.GetLayers(); 
5375
	if(!layerlist)return NULL;
5376
	POSITION  layerpos = layerlist->GetHeadPosition();
5377
	while(layerpos)
5378
	{
5379
		CSE100Layer * player = layerlist->GetNext(layerpos);
5380
		if(!player)
5381
			continue;
5382

    
5383
		CBaseObjList* pobjlist = player->GetObjects();
5384
		if(!pobjlist)
5385
			continue;
5386

    
5387
		POSITION objpos = pobjlist->GetHeadPosition();
5388
		while(objpos)
5389
		{
5390
			CBaseObj * pobj = pobjlist->GetNext(objpos);
5391
			if(!pobj)
5392
				continue;
5393
			STRUCT_DEVBASEINFO devinfo;
5394
			((CPowerBase*)pobj)->GetDevInfo(devinfo);	
5395
			int devid				=	((CPowerBase*)pobj)->GetDeviceType ();
5396
			OBJECT_SHAPE shapeid	=	pobj->GetObjectShape();
5397
			switch (type)
5398
			{
5399
			case 1://ң?ţ????????أ???բ??״̬??
5400
				if(devid == SE_K_DEV_BREAK || devid==SE_K_DEV_SWITCH)
5401
				{
5402
					if(strcmp(devinfo.sYXCode,code)==0)
5403
					{
5404
						if(plist) *plist = pobjlist;
5405
						return pobj;
5406
					}
5407
				}
5408
				else if(shapeid == OS_STATUSOBJ)
5409
				{
5410
					CPowerBase *pdev = (CPowerBase *)pobj;
5411
					if(strcmp(pdev->GetDevCode(),code)==0)
5412
					{
5413
						if(plist) 
5414
							*plist = pobjlist;
5415
						return pobj;
5416
					}
5417
				}
5418
				break;
5419
			case 2://ң??
5420
				if(shapeid == OS_ANALOG){
5421
					CYaoCeObj * pyc = (CYaoCeObj *)pobj;
5422
					if(strcmp(pyc->GetYCCode(),code)==0){
5423
						if(plist) *plist = pobjlist;
5424
						return pobj;
5425
					}
5426
				}
5427
				break;
5428
			default: //case 0:?豸
5429
				if(devinfo.nDevType != SE_K_DEV_NULL){
5430
					if(strcmp(devinfo.sDevCode,code)==0){
5431
						*plist = pobjlist;
5432
						return pobj;
5433
					}
5434
				}
5435
				break;
5436
			}//switch type
5437
		}//while(objpos)
5438
	}//while(layerpos)*/
5439
	return NULL;
5440
}
5441

    
5442
void CGWnd::AddOneTag(char * devcode,int tagtype,int pos)
5443
{
5444
	//?Ȳ????Ƿ??Ѿ?????
5445
	for(int i=0;i<m_TagedDevlist.GetSize();i++)
5446
	{
5447
		if(strcmp(m_TagedDevlist[i].devcode,devcode)==0 && 
5448
			tagtype ==  (int)m_TagedDevlist[i].type)
5449
		{
5450
			return;
5451
		}
5452
	}
5453

    
5454
	TAGPARA tag;
5455
	strcpy(tag.devcode,devcode);
5456
	tag.type = tagtype;
5457
	tag.pos  = pos;
5458
	tag.pobj = NULL;
5459
	tag.pfather = NULL;
5460
	tag.metapos = NULL;
5461

    
5462
	CBaseObj * pobj = NULL;
5463
	CEasyList *plist = NULL;
5464
	pobj = GetMetaByCode(devcode,0,&plist); 
5465
	if (pobj && plist)
5466
	{
5467
		CBaseObj * ptagobj = AddOneTag(tag,pobj);
5468
		plist->AddLast(ptagobj);
5469
		tag.pobj = ptagobj;
5470
		tag.pfather	= plist;
5471
		tag.metapos	=(plist->GetListLen()-1);
5472

    
5473
		CVGRegion updateregion;
5474
		updateregion.Add(ptagobj);
5475
		m_map.RefreshRegion(updateregion);
5476
	}
5477
	m_TagedDevlist.Add(tag);
5478
}
5479

    
5480
void CGWnd::DelOneTag(char *devcode,int tagtype)
5481
{
5482
	for(int i=0;i<m_TagedDevlist.GetSize ();i++)
5483
	{
5484
		TAGPARA Tagpara = m_TagedDevlist[i];
5485
		if(strcmp(devcode,Tagpara.devcode)==0 && tagtype== (int)Tagpara.type ) 
5486
		{
5487
			if(Tagpara.pobj && Tagpara.pfather)
5488
			{
5489
				CVGRegion updateregion;
5490
				updateregion.Add(Tagpara.pobj);
5491
				Tagpara.pfather->DeleteNth((int)Tagpara.metapos);
5492
				
5493
				Tagpara.pfather->Del(Tagpara.pobj); //??ͼԪ???ڵ?ͼ???????Ƴ?
5494

    
5495
				delete Tagpara.pobj; 
5496
				m_TagedDevlist[i].pobj = NULL;
5497
				m_TagedDevlist[i].pfather = NULL;
5498
				m_TagedDevlist[i].metapos = NULL;
5499
				m_map.RefreshRegion(updateregion);                
5500
			}
5501
			m_TagedDevlist.RemoveAt(i);//ɾ??
5502
			return;
5503
		}
5504
	}
5505
}
5506

    
5507
void CGWnd::SetPdrData(ST_PDRDATA * pdata, int num)
5508
{
5509
	if(SourceRealData != DEF_DATA_FROM_PDR || !pdata || num<=0)return;
5510
	SREALDB_VAR var;
5511
	CVGRegion updateregion;
5512
	for(int i=0;i<num;i++){
5513
			CBaseObj * pobj  = NULL; 
5514
			if(pdata[i].type>=SE_K_MEASTYPE_ANA_START && pdata[i].type<= SE_K_MEASTYPE_ANA_END){//ң??
5515
				pobj = GetMetaByCode(pdata[i].code,2);
5516
				if(pobj){
5517
					updateregion.Add (pobj);
5518
					var.m_type = REALDB_FLOAT;
5519
					var.m_val.floatval =  pdata[i].val ;
5520
					FreshYc(pobj,&var);
5521
					var.m_type = REALDB_UINT;
5522
					var.m_val.uintval  = pdata[i].status ;
5523
					FreshYcStatus(pobj,&var);
5524
				}
5525
			}
5526
			else if( pdata[i].type>=  SE_K_MEASTYPE_BRK_START && pdata[i].type<=SE_K_MEASTYPE_PROT_END){//ң??
5527
				pobj = GetMetaByCode(pdata[i].code,1);
5528
				if(pobj){
5529
					updateregion.Add (pobj);
5530
					var.m_type = REALDB_UCHAR;
5531
					var.m_val.ucharval = (unsigned char )(pdata[i].val);
5532
					FreshYx(pobj,&var);
5533
					var.m_type = REALDB_UINT;
5534
					var.m_val.uintval  = pdata[i].status ;
5535
					FreshYxStatus(pobj,&var);
5536
				}
5537
			}
5538
	}
5539
	if(updateregion.GetRectCount()>0)m_map.RefreshRegion(updateregion);
5540
}
5541

    
5542
void CGWnd::CallNameView(UINT nID)
5543
{
5544
	DrawNameView(NULL, nID - ID_NAMEVIEW_MENUID_BEGIN);
5545
}
5546

    
5547
LRESULT CGWnd::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
5548
{
5549
	if(message == WM_MEASUREITEM)
5550
	{
5551
		HMENU hMenu = AfxGetThreadState()->m_hTrackingMenu;
5552
		if(hMenu != NULL)
5553
		{
5554
			CMenu	*pMenu = CMenu::FromHandle(hMenu);
5555
			pMenu->MeasureItem((LPMEASUREITEMSTRUCT)lParam);
5556
		}
5557
		return NULL;
5558
	}
5559
	return CWnd::WindowProc(message, wParam, lParam);
5560
}
5561

    
5562
CBaseObjArray &CGWnd::GetFeatureObjects(long objshape)
5563
{
5564
    m_tmpSelection.RemoveAll();
5565

    
5566
	CEasyList *pLayList = m_map.GetAllFeatureLayers();
5567
	if (!pLayList || pLayList->GetListLen() == 0)
5568
		return m_tmpSelection;
5569

    
5570
    for (int j=0; j < pLayList->GetListLen(); j++)
5571
	{
5572
		CFeatureLayer *pLayer = (CFeatureLayer *)pLayList->GetNth(j);
5573
		if (!pLayer)
5574
			break;
5575

    
5576
		CEasyList *pObjLst = pLayer->GetObjects();
5577
		if (!pObjLst || pObjLst->GetListLen() == 0)
5578
			continue;
5579
 
5580
		for (int i=0; i < pObjLst->GetListLen(); i++)
5581
		{
5582
			CBaseObj *pObj = (CBaseObj *) pObjLst->GetNth(i);
5583
			if (pObj && pObj->GetObjectShape() == objshape)
5584
				m_tmpSelection.Add(pObj);
5585
		}
5586
	}
5587

    
5588
	return m_tmpSelection;  
5589
}
5590

    
5591
void CGWnd::ShowEagleDlg(BOOL bShow)
5592
{   
5593
    if ( bShow )
5594
	{
5595
		if (m_NaviDlg !=NULL)
5596
		{
5597
			delete m_NaviDlg;
5598
			m_NaviDlg = NULL;
5599
		}
5600

    
5601
		CWnd *pMainWnd = g_ehmiMainFrame;
5602
		m_NaviDlg = new CNaviDialog(&m_map, pMainWnd);
5603
		m_NaviDlg->Create(IDD_DIALOG_NAVI, pMainWnd);
5604

    
5605
		m_NaviDlg->InitGUI(m_pView);
5606
//WYF 20190426
5607
		CRect rc;
5608
		m_NaviDlg->GetWindowRect(rc);
5609
		POINT point;
5610
		GetCursorPos(&point);
5611
		m_NaviDlg->SetWindowPos(NULL, point.x-25, point.y-rc.Height()-30, 0, 0,
5612
		SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
5613
//		m_NaviDlg->ShowWindow(SW_NORMAL);//WYF 20190426
5614
	}
5615
	else
5616
	{
5617
		if (m_NaviDlg != NULL)
5618
		{
5619
			m_NaviDlg->InitGUI(m_pView);
5620
			m_NaviDlg->ShowWindow(SW_HIDE);
5621
		}
5622
	}
5623
}
5624

    
5625
void CGWnd::ShowLayerDlg(BOOL bShow)
5626
{
5627
	if ( bShow )
5628
	{
5629
		if (m_LayDlg != NULL)
5630
		{
5631
			delete m_LayDlg;
5632
			m_LayDlg = NULL;
5633
		}
5634

    
5635
		CWnd *pMainWnd = g_ehmiMainFrame;
5636
		m_LayDlg = new CDlgLayerControl(&m_map, pMainWnd);
5637
		m_LayDlg->Create(IDD_DLG_LAYERCONTROL, pMainWnd);
5638

    
5639
		m_LayDlg->InitLayTree(m_pView);
5640
		m_LayDlg->CenterWindow(m_pView);
5641
		m_LayDlg->ShowWindow(SW_NORMAL);
5642
	}
5643
	else
5644
	{
5645
		if (m_LayDlg != NULL)
5646
		{
5647
			m_LayDlg->InitLayTree(m_pView);
5648
			m_LayDlg->ShowWindow(SW_HIDE);
5649
		}
5650
	}
5651
}
5652

    
5653
short int CGWnd::GetLinkLineLinkDev(/*CEasyList *lyrlist, */CBaseObj *linkobj, CEasyList *devlist)
5654
{
5655
    int i;
5656
	LINKINFOARRAY *linklist;
5657
	if(linkobj->GetFeatureType()==FT_LINKLINE)
5658
		linklist=((CLinkLine *)linkobj)->Link();
5659
	else 
5660
		return FALSE;
5661

    
5662
	ProcLinkLineList.DelAll();
5663
	ProcLinkNodeList.DelAll();
5664

    
5665
	for(i=0;i<linklist->GetSize();i++)
5666
        GetNodeGrpLinkDevInfo(devlist,(*linklist)[i],NULL);
5667
    
5668
	return TRUE;
5669
}
5670

    
5671
short int CGWnd::GetNodeGrpLinkDevInfo(/*CEasyList *lyrlist,*/ CEasyList *devlist, STRUCT_LINKINFO &grplink, CBaseObj *parentlinkobj)
5672
{
5673
    CBaseObj *linkobj;//,*linkobj1;
5674
	LINKINFOARRAY *linklist;
5675
	CFeatureLayer *lyrpt;
5676
	
5677
//	lyrpt=GetFeatureLayer(lyrlist,grplink.FeatureID);
5678
	lyrpt=m_map.GetFeatureLayer((FT_TYPE)grplink.FeatureID);
5679
    
5680
	if(lyrpt==NULL)
5681
		return FALSE;
5682

    
5683
	linkobj=lyrpt->FindObject(grplink.LinkID);
5684
	if(linkobj==NULL)
5685
		return FALSE;
5686

    
5687
	int i;
5688
	STRUCT_DEVTERMINFO *devcodeinfo;
5689
	char str[256];
5690
	unsigned char flag;
5691
	int DevUGrade; //?????????ӵ??豸???е磩?ĵ?ѹ?ȼ???Ϊ?????ߵĵ?ѹ?ȼ?
5692
	OBJECT_SHAPE shapeid;
5693
	switch(grplink.FeatureID)
5694
	{
5695
	case FT_LINKLINE:
5696
	case FT_LINKNODE:
5697
		if(grplink.FeatureID==FT_LINKLINE)
5698
		{
5699
			for(i=0;i<ProcLinkLineList.GetListLen();i++)
5700
			{
5701
				if((void *)linkobj==ProcLinkLineList[i])
5702
					break;
5703
			}
5704
			if(i<ProcLinkLineList.GetListLen())
5705
				break;
5706
			linklist=((CLinkLine *)linkobj)->Link();
5707
			ProcLinkLineList.AddLast((void *)linkobj);
5708
		}
5709
		else
5710
		{
5711
			for(i=0;i<ProcLinkNodeList.GetListLen();i++)
5712
			{
5713
				if((void *)linkobj==ProcLinkNodeList[i])
5714
					break;
5715
			}
5716
			if(i<ProcLinkNodeList.GetListLen())
5717
				break;
5718
			linklist=((CLinkNode *)linkobj)->Link();
5719
			ProcLinkNodeList.AddLast((void *)linkobj);
5720
		}
5721
		//??????????ߣ??????????????ӵ??豸?????豸??Ϣ????
5722
		for(i=0;i<linklist->GetSize();i++)
5723
	        GetNodeGrpLinkDevInfo(devlist,(*linklist)[i],parentlinkobj);
5724
		break;
5725
	default:
5726
			//????ƽ?????豸?????????뵽?豸??Ϣ????
5727
		flag=1;
5728
		switch(linkobj->GetObjectShape())
5729
		{
5730
			case OS_POINTDEV:
5731
				strcpy(str,((CPointDevice *)linkobj)->GetDevCode());
5732
				DevUGrade =((CPointDevice *)linkobj)->GetDevUGrade();
5733
				shapeid = OS_POINTDEV ;
5734
				break;
5735
			case OS_DEVBUSLINE:
5736
				strcpy(str,((CDevBusLine *)linkobj)->GetDevCode());
5737
				DevUGrade =((CDevBusLine *)linkobj)->GetDevUGrade();
5738
				shapeid = OS_DEVBUSLINE ;
5739
				break;
5740
			case OS_DEVPOWERLINE:
5741
				strcpy(str,((CDevPowerLine *)linkobj)->GetDevCode());
5742
				DevUGrade =((CDevPowerLine *)linkobj)->GetDevUGrade();
5743
				shapeid = OS_DEVPOWERLINE ;
5744
				break;
5745
			default:
5746
				flag=0;
5747
				break;
5748
		}
5749
		if(flag==0)
5750
			break;
5751

    
5752
		devcodeinfo=new	STRUCT_DEVTERMINFO;
5753
		if(devcodeinfo==NULL)
5754
			break;
5755
		strcpy(devcodeinfo->DevCode,str);
5756
		devcodeinfo->DevType=shapeid;
5757
		devcodeinfo->VGrade=DevUGrade;
5758
		if(AddDevList(devlist,devcodeinfo)==FALSE)
5759
		{
5760
			delete devcodeinfo;
5761
			devcodeinfo=NULL;
5762
		}
5763
		break;
5764
	}
5765
	return TRUE;
5766
}
5767

    
5768

    
5769
void CGWnd::FreshTerm(CBaseObj *pobj, SREALDB_VAR *pvar, char termno)
5770
{
5771
  	if(pobj == 0 || termno <0)
5772
		return;
5773
   
5774
	CTermObj* pTermObj = (CTermObj*)pobj;
5775
	if(!pTermObj) 
5776
		return;
5777

    
5778
	DynaField oneYc;
5779
	pTermObj->GetYCItem(termno,oneYc);    
5780
    char szVal[24];
5781
	memset(szVal, 0, 24);
5782

    
5783
	float f=0.0;
5784
	CDTOperE::Vt_OutValByType(pvar,REALDB_FLOAT,0,&f);
5785

    
5786
   // sprintf(szVal,"%s:%.2f",oneYc.sYCCode,f);
5787
    sprintf(szVal,"%.2f"/*,oneYc.sYCCode,*/,f);
5788

    
5789
	pTermObj->UpdateItemText(termno,szVal);
5790
}
5791
void CGWnd::FreshTermStatus(CBaseObj *pobj, SREALDB_VAR *pvar, char termno)
5792
{
5793
    if(pobj == 0 || termno <0)
5794
		return;
5795
   
5796
	CTermObj* pTermObj = (CTermObj*)pobj;
5797
	if(!pTermObj) 
5798
		return;
5799

    
5800
	DynaField oneYc;
5801
	pTermObj->GetYCItem(termno,oneYc);
5802
    
5803
	unsigned int status = pvar->m_val.uintval;
5804
   
5805
	if(g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_ALMCTRL] && PT_IS_INHIB_ALM(status))
5806
	{
5807
		pTermObj->SetItemStyle(termno,oneYc.frColor,FALSE/*????Ҫ??ɫʱ͸??????ΪFALSE*/,
5808
			g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_ALMCTRL]);
5809
	}
5810
	else if(g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_LOCK] && 
5811
		     PT_IS_MAN_VAL(status))
5812
	{
5813
		pTermObj->SetItemStyle(termno,oneYc.frColor,FALSE/*????Ҫ??ɫʱ͸??????ΪFALSE*/,
5814
			g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_LOCK]);
5815
	}
5816
	else if( g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_LIMIT] &&
5817
			(PT_IS_RL_ALM(status) || 
5818
			PT_IS_LEL_ALM(status) || 
5819
			PT_IS_LNL_ALM(status) || 
5820
			PT_IS_HNL_ALM(status)|| 
5821
			PT_IS_HEL_ALM(status)))
5822
	{
5823
		pTermObj->SetItemStyle(termno,oneYc.frColor,FALSE/*????Ҫ??ɫʱ͸??????ΪFALSE*/,
5824
			g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_LIMIT]);
5825
	}
5826
	else if(g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_INVALITE] && 
5827
			(PT_IS_DEAD(status)||
5828
			PT_IS_INCONSISTE(status)||
5829
			PT_IS_UNCHG_VAL(status)))
5830
	{
5831
		pTermObj->SetItemStyle(termno,oneYc.frColor,FALSE/*????Ҫ??ɫʱ͸??????ΪFALSE*/,
5832
				g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_INVALITE]);	
5833
	}
5834
	else if(g_ehmiMainFrame->m_faceSetting.fycback[YCBACK_COLOR_PL] && PT_IS_REPLACED(status))
5835
	{
5836
         pTermObj->SetItemStyle(termno,oneYc.frColor,FALSE/*????Ҫ??ɫʱ͸??????ΪFALSE*/,
5837
			 g_ehmiMainFrame->m_faceSetting.yc_back[YCBACK_COLOR_PL]);	
5838
	}	
5839
	else 
5840
	{
5841
		//????????????????ʱ?ָ?????????ı???ɫ??ֱ????͸??????ΪTRUE
5842
	    pTermObj->SetItemStyle(termno,oneYc.frColor,TRUE);
5843
	}
5844
}
5845

    
5846
float CGWnd::GetOneTermRdbData(char *DevCode, int MeasType)
5847
{
5848
	//?????豸????????????ͣ?ȡ??ʵʱ???Ӧ??ֵ
5849
	float f=0.0;
5850
    char szDev[DEF_OBJCODE_LEN] = "\0";  
5851
	
5852
   	CRdbSqlAccess termsqlcli;
5853
	termsqlcli.OptTbl(ANA_RDB_TBLNAME);
5854
	termsqlcli.SelectCol("DeviceCode");	
5855
	termsqlcli.SelectCol("MeasType");
5856
	termsqlcli.SelectCol("Value");
5857
	termsqlcli.SetUserPwd("guest","");
5858
	int ret = termsqlcli.ExecSelect();
5859

    
5860
	if(ret==REALDB_TRUE) 
5861
	{
5862
		int rcdcnt=termsqlcli.GetRcdCount();
5863
		for(int i=0;i<rcdcnt;i++)
5864
		{		
5865
			strcpy(szDev,termsqlcli.GetString(i,0));
5866
			if(strcmp(szDev,DevCode) != 0)
5867
			    continue;
5868
			if(MeasType != termsqlcli.GetUIntVal(i,1))
5869
				continue;
5870
            f=termsqlcli.GetFloatVal(i,2);
5871
			return f;
5872
		}
5873
	}
5874
	return f;   
5875
}
5876

    
5877
char * CGWnd::GetTermYCCode(char *DevCode, int index)
5878
{      
5879
	  int key=0;
5880
	  int bfind=0;
5881
	  static char YCCode[DEF_OBJCODE_LEN] = "\0";
5882

    
5883
	  for(int i=0;i<g_ehmiMainFrame->m_items.GetListLen();i++)
5884
	  {				
5885
		 CItem *pItem = (CItem*)g_ehmiMainFrame->m_items.GetNth(i);
5886
		 if(!pItem)
5887
			 continue;
5888

    
5889
		 if(!pItem->bChk)
5890
			continue;
5891

    
5892
		 if(index == key)
5893
		 {
5894
            //?õ?ң?????
5895
			strncpy(YCCode,GetTermYCCodeByDev(DevCode,pItem->MeasType),DEF_OBJCODE_LEN-1);          
5896
			bfind=1;
5897
		    break;
5898
		 }
5899
		 else
5900
		     key++;
5901
	  }
5902
	
5903
	  return YCCode;
5904
}
5905

    
5906
char* CGWnd::GetTermYCCodeByDev(char *DevCode, int MeasType)
5907
{
5908
    static char YCCode[DEF_OBJCODE_LEN] = "\0";
5909
    
5910
    char szDev[DEF_OBJCODE_LEN] = "\0";  
5911
	
5912
   	CRdbSqlAccess termsqlcli;
5913
	termsqlcli.OptTbl(ANA_RDB_TBLNAME);
5914
	termsqlcli.SelectCol("DeviceCode");	
5915
	termsqlcli.SelectCol("MeasType");
5916
	termsqlcli.SelectCol("PointCode");
5917
	termsqlcli.SetUserPwd("guest","");
5918
	int ret = termsqlcli.ExecSelect();
5919

    
5920
	if(ret==REALDB_TRUE) 
5921
	{
5922
		int rcdcnt=termsqlcli.GetRcdCount();
5923
		for(int i=0;i<rcdcnt;i++)
5924
		{		
5925
			strncpy(szDev,termsqlcli.GetString(i,0),DEF_OBJCODE_LEN-1);
5926

    
5927
			if(strcmp(szDev,DevCode) != 0)
5928
			    continue;
5929
			if(MeasType != termsqlcli.GetUIntVal(i,1))
5930
				continue;
5931

    
5932
            strncpy(YCCode,termsqlcli.GetString(i,2),DEF_OBJCODE_LEN-1);
5933
		    break;
5934
		}
5935
	}
5936
	
5937
	return YCCode;   
5938
}
5939

    
5940
void CGWnd::UpdateFlashObj(CVGRegion *region)
5941
{   
5942
	if (m_Flashlist.GetSize() == 0)
5943
		return;
5944

    
5945
	CBaseObj *pObject;
5946

    
5947
	if (m_bFlash)
5948
	{
5949
		COLORREF freshColor = g_ehmiMainFrame->m_faceSetting.yx_back[YXBACK_COLOR_FLASH];
5950
		CGlobal::m_FreshColor = freshColor;
5951

    
5952
		CLineStyle linestyle;
5953

    
5954
		for (int i = 0; i < m_Flashlist.GetSize(); i++)
5955
		{
5956
			pObject = m_Flashlist[i];
5957
			if (!pObject)
5958
				continue;
5959

    
5960
			linestyle = pObject->GetLineStyle();
5961
			int r1,g1,b1, r2,g2,b2;
5962
			r1 = GetRValue(linestyle.penColor);
5963
			g1 = GetGValue(linestyle.penColor);
5964
			b1 = GetBValue(linestyle.penColor);
5965
			r2 = GetRValue(freshColor);
5966
			g2 = GetGValue(freshColor);
5967
			b2 = GetBValue(freshColor);
5968
			if ((abs(r1-r2) < 10) && (abs(g1-g2) < 10) && (abs(b1-b2) < 10))
5969
			{
5970
				freshColor = RGB(255-r1, 255-g1, 255-b1);
5971
				CGlobal::m_FreshColor = freshColor;
5972
			}
5973

    
5974
			pObject->SetFreshFlag(TRUE);
5975
			region->Add(pObject);
5976
		}
5977
	}
5978
	else
5979
	{
5980
		for (int i = 0; i < m_Flashlist.GetSize(); i++)
5981
		{
5982
			pObject = m_Flashlist[i];
5983
			if (!pObject)
5984
				continue;
5985
		
5986
			pObject->SetFreshFlag(FALSE);
5987
			region->Add(pObject);
5988
		}
5989
	}
5990

    
5991
	m_bFlash = !m_bFlash;
5992
}
5993

    
5994
void CGWnd::OnObjmenuDevrealpnt() 
5995
{
5996
	if(strcmp(m_seldev.sDevCode,"") == 0) //û??ѡ??
5997
	{
5998
		AfxMessageBox("û??ѡ??");
5999
		return;
6000
	}
6001

    
6002
	if(m_devid != SE_K_DEV_NULL)
6003
//XZF 20180627
6004
//		ShowDevRealPntDlg(m_seldev.sDevCode);
6005
		ShowCtrlDlg(Real,m_seldev.sDevCode);
6006
	else if(m_shapeid == OS_STATUSOBJ)
6007
		ShowDevRealPntDlgByYXCode(m_seldev.sYXCode);
6008
}
6009

    
6010
void CGWnd::OnObjmenuHisData() 
6011
{
6012
	if (g_ehmiMainFrame->m_uniCtrl)
6013
	{
6014
//		ShowCtrlDlg(His);
6015
		ShowCtrlDlg(Real);//xzf 20180813
6016
	}
6017
	else
6018
	{
6019
	if(  m_devid == SE_K_DEV_NULL && 
6020
		(m_shapeid == OS_ANALOG || m_shapeid == OS_TERMOBJ)
6021
		 && !kwhflag )
6022
		ShowHisDataDlgByYc(m_analogcode);
6023
	else if( m_devid == SE_K_DEV_NULL && m_shapeid == OS_STATUSOBJ)
6024
		ShowHisDataDlgByDev(m_seldev.sDevCode);
6025
	else if(m_devid != SE_K_DEV_NULL)
6026
		ShowHisDataDlgByDev(m_seldev.sDevCode);
6027
	}
6028
}
6029

    
6030
void CGWnd::ShowHisDataDlgByYc(char * yccode)
6031
{
6032
	CHisDataDlg * hisdatadlg = (CHisDataDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_HISDATA);
6033
	if(!hisdatadlg){
6034
		hisdatadlg = new CHisDataDlg();
6035
		hisdatadlg->Create(IDD_MMI_HISDATA,this);
6036
		g_ehmiMainFrame->SetOptDlg(CTRL_HISDATA,hisdatadlg);
6037
	}
6038
	hisdatadlg->SetPara(yccode);
6039
	hisdatadlg->ShowWindow (SW_SHOW);
6040
}
6041

    
6042
void CGWnd::ShowHisDataDlgByDev(char * devcode)
6043
{
6044
	CHisDataDlg * hisdatadlg = (CHisDataDlg *)g_ehmiMainFrame->GetOptDlg(CTRL_HISDATA);
6045
	if(!hisdatadlg){
6046
		hisdatadlg = new CHisDataDlg();
6047
		hisdatadlg->Create(IDD_MMI_HISDATA,this);
6048
		g_ehmiMainFrame->SetOptDlg(CTRL_HISDATA,hisdatadlg);
6049
	}
6050
	hisdatadlg->SetPara(NULL,devcode);
6051
	hisdatadlg->ShowWindow (SW_SHOW);
6052
}
6053

    
6054
void CGWnd::OnDestroy() 
6055
{
6056
	CWnd::OnDestroy();
6057

    
6058
	KillTimer(1);
6059
	KillTimer(2);
6060

    
6061
	if (m_pView->m_pCurGWnd == this)
6062
		m_pView->m_pCurGWnd = NULL;
6063

    
6064
	// ???ڹرսű?
6065
	if (g_ehmiMainFrame->m_bScript && m_map.m_nScriptLenclose > 0)
6066
	{
6067
		m_pView->m_Script.ExecString((const char *)m_map.m_pVgScriptDataclose, this);
6068
	}
6069

    
6070
	m_pView->RemovePlugIn(this);
6071

    
6072
	s_mapWnd[this] = 0;
6073

    
6074
	m_pView->m_Script.Wait();
6075
}
6076

    
6077
void CGWnd::OnTbGraphCmd(UINT nID)
6078
{
6079
	m_pView->m_OperateID = 0;
6080

    
6081
	if(nID!=ID_GRAPH_MOVE && nID!=ID_GRAPH_LOCALZOOM)
6082
		EndGraphOperate();
6083

    
6084
	CVGGraph *pmap = GetMap();
6085
	CGraphGUI *pGraphGUI=GetGraphGUI();
6086

    
6087
	if(pmap == NULL || pGraphGUI == NULL) return;
6088
    
6089
	switch(nID)
6090
	{
6091
	case ID_GRAPH_MOVE:
6092
		if(GetMapStatus()==c_pan)
6093
			EndGraphOperate();
6094
		else 
6095
			BeginGraphPan();
6096
		break;
6097
	case ID_GRAPH_UP:
6098
		pGraphGUI->Pan(CPoint(0,0), CPoint(0,-(g_ehmiMainFrame->m_faceSetting.graph_step)), TRUE);
6099
		break;
6100
	case ID_GRAPH_DOWN:
6101
		pGraphGUI->Pan(CPoint(0,0), CPoint(0,(g_ehmiMainFrame->m_faceSetting.graph_step)), TRUE);
6102
		break;
6103
	case ID_GRAPH_LEFT:
6104
		pGraphGUI->Pan(CPoint(0,0), CPoint(-(g_ehmiMainFrame->m_faceSetting.graph_step),0), TRUE);
6105
		break;
6106
	case ID_GRAPH_RIGHT:
6107
		pGraphGUI->Pan(CPoint(0,0), CPoint((g_ehmiMainFrame->m_faceSetting.graph_step),0) , TRUE);
6108
		break;
6109
	case ID_GRAPH_ZOOMOUT:
6110
		m_cmd = c_zoomout;
6111
		pGraphGUI->ZoomOut();
6112
		break;
6113
	case ID_GRAPH_ZOOMIN:
6114
		m_cmd = c_zoomin;
6115
		pGraphGUI->ZoomIn();
6116
		break;
6117
	case ID_GRAPH_NORMAL:
6118
		pGraphGUI->ZoomAll();
6119
		break;
6120
	case ID_GRAPH_LOCALZOOM:
6121
		if(GetMapStatus()==c_zoombox)
6122
			EndGraphOperate();
6123
		else 
6124
			BeginGraphLocalzoom();
6125
		break;
6126
	case ID_GRAPH_PREV:
6127
		m_pView->PreehGraph();
6128
		break;
6129
	case ID_GRAPH_NEXT:
6130
		m_pView->NextGraph();
6131
		break;
6132
	case ID_GRAPH_LAYER:
6133
		ShowLayerDlg();
6134
		break;
6135
	case ID_GRAPH_NAVIGATE:
6136
		ShowEagleDlg();	
6137
		break;
6138
	case ID_GRAPH_HOMEPAG:
6139
		m_pView->MainGraph();
6140
		break;
6141
	case ID_VIEW_PREV:
6142
		pGraphGUI->Undo();
6143
		break;
6144
	case ID_VIEW_NEXT:
6145
		pGraphGUI->Redo();
6146
		break;
6147
	case ID_GRAPH_EQUAL:
6148
		DrawEqual();
6149
		break;
6150
	default:
6151
		break;
6152
	}
6153
}
6154

    
6155
void CGWnd::OnTbGraphCmdUpdate(CCmdUI* pCmdUI)
6156
{
6157
	UINT nID= pCmdUI->m_nID; 
6158
	CVGGraph *pmap = GetMap();
6159
	CGraphGUI *pGraphGUI=GetGraphGUI();
6160

    
6161
	if(pmap == NULL) return;
6162

    
6163
	switch(nID)
6164
	{
6165
	case ID_GRAPH_MOVE:
6166
		pCmdUI->SetCheck (GetMapStatus()==c_pan);
6167
	case ID_GRAPH_UP:
6168
	case ID_GRAPH_DOWN:
6169
	case ID_GRAPH_LEFT:
6170
	case ID_GRAPH_RIGHT:
6171
		pCmdUI->Enable (TRUE);
6172
		break;
6173
	case ID_GRAPH_LOCALZOOM:
6174
		pCmdUI->SetCheck (GetMapStatus()==c_zoombox);
6175
	case ID_GRAPH_ZOOMOUT:
6176
	case ID_GRAPH_ZOOMIN:
6177
	case ID_GRAPH_NORMAL:
6178
	case ID_GRAPH_EQUAL:
6179
		pCmdUI->Enable(TRUE);
6180
	case ID_GRAPH_PREV:
6181
		break;
6182
	case ID_GRAPH_NEXT:
6183
		break;
6184
	case ID_GRAPH_LAYER:
6185
	case ID_GRAPH_HOMEPAG:
6186
		pCmdUI->Enable (1);
6187
		break;
6188
	case ID_VIEW_PREV:
6189
		pCmdUI->Enable (pGraphGUI->CanUndo());
6190
		break;
6191
	case ID_VIEW_NEXT:
6192
		pCmdUI->Enable (pGraphGUI->CanRedo());
6193
		break;
6194
	default:
6195
		break;
6196
	}
6197
}
6198

    
6199
void CGWnd::DrawObj(CFRect *fRect1, CFRect *fRect2)
6200
{
6201
	CRect rc1;
6202
	m_GraphGUI.MapToClient(fRect1, &rc1);
6203

    
6204
	CRect rc;
6205
	if (fRect2)
6206
	{
6207
		CRect rc2;
6208
		m_GraphGUI.MapToClient(fRect2, &rc2);
6209
		rc.UnionRect(rc1, rc2);
6210
	}
6211
	else
6212
	{
6213
		rc = rc1;
6214
	}
6215

    
6216
	rc.InflateRect(1, 1);
6217
	m_GraphGUI.Draw(rc);
6218
}
6219

    
6220
LRESULT CGWnd::OnDrawObj(WPARAM wParam, LPARAM lParam)
6221
{
6222
	LPMSGOBJINFO lpMsgInfo = (LPMSGOBJINFO)lParam;
6223
	if (lpMsgInfo)
6224
	{
6225
		if (lpMsgInfo->Type == MSG_OBJ_VISIBLE)
6226
		{
6227
			CBaseObj *pObj = (CBaseObj *)wParam;
6228
			int visible = lpMsgInfo->bEnable;
6229
			
6230
			if (!visible && pObj->GetObjectShape() == OS_BITMAP && ((CImageObj *)pObj)->IsGif())
6231
			{
6232
				((CImageObj *)pObj)->SetGifVisible(TRUE);
6233
			}
6234
			
6235
			DrawObj(&pObj->GetObjectRect());
6236
		}
6237
		else if (lpMsgInfo->Type == MSG_OBJ_FLASH)
6238
		{
6239
			CBaseObj *pObj = (CBaseObj *)wParam;
6240
			if (pObj->GetObjectShape() == OS_POINTDEV)
6241
			{
6242
				CPointObj *pDev = (CPointObj *)pObj;
6243
				if (pDev->GetFlashType() == FLASH_STATE_EXPR)
6244
				{					
6245
					BOOL bFlash = lpMsgInfo->bEnable;
6246
					pDev->SetExprStatus(bFlash);
6247
					if (bFlash == TRUE)
6248
					{
6249
						AddObjToList(pObj);
6250
					}
6251
					else
6252
					{
6253
						DeleteObjFromList(pObj);
6254
					}
6255
				}
6256
			}			
6257
		}
6258
		else if (lpMsgInfo->Type == MSG_OBJ_REDRAW)
6259
		{
6260
			CFRect *pRect = (CFRect *)wParam;
6261
			DrawObj(&pRect[0], &pRect[1]);
6262
		}
6263
		else if (lpMsgInfo->Type == MSG_OBJ_TRAINID)
6264
		{
6265
			CBaseObjArray &ObjTrainArray = GetFeatureObjects(OS_ATSTRAIN);
6266
			for (int k = 0; k < ObjTrainArray.GetSize(); k++)
6267
			{
6268
				CAtsTrain *pTrain = (CAtsTrain *)ObjTrainArray[k];
6269
				pTrain->ShowID(lpMsgInfo->bEnable);
6270
			}		
6271
		}
6272
	}
6273
	return 0;
6274
}
6275

    
6276
void CGWnd::PostNcDestroy() 
6277
{
6278
	m_pView->RemoveGWnd(this);
6279
}
6280

    
6281
BOOL CGWnd::CheckAoj(char *pcode, PointType type, char *auth/* = NULL*/)
6282
{
6283
	char msg[256] = "ȡ??ǰ?û???Ȩ??????ʧ?ܣ?";
6284

    
6285
	const char *pName = type == p_dev ? "?豸" : "??";
6286

    
6287
	if (*pcode == 0)
6288
	{
6289
		sprintf(msg, "??ǰ?豸δ???????κε㣡");
6290
	}
6291
	else
6292
	{
6293
		AOJ_D_ASSIGNMENT aoj;
6294
		if (AOJ_GetAssignment(NULL, aoj, auth) > 0)
6295
		{
6296
			const struct
6297
			{
6298
				char aoj[32];
6299
				char tbl[32];
6300
				char pnt[32];
6301
			} fields[] =
6302
			{
6303
				{"F4007_AOJ", "TB4007_ANAPOINT", "F4007_POINTCODE"},
6304
				{"F4008_AOJ", "TB4008_AO",		 "F4007_POINTCODE"},
6305
				{"F4009_AOJ", "TB4009_DIGPOINT", "F4009_POINTCODE"},
6306
				{"F4011_AOJ", "TB4011_DO",		 "F4011_POINTCODE"},
6307
				{"F1000_AOJ", "TB1004_DEVICE",	 "F1004_DEVCODE"}
6308
			};
6309

    
6310
			char cmdbuf[256];
6311
			sprintf(cmdbuf, "select %s from SEMODEL.%s where %s = '%s'",
6312
				fields[type].aoj, fields[type].tbl, fields[type].pnt, pcode);
6313

    
6314
			CSE_DBOption dbo;
6315
			dbo.BeginSelectRcdSet(cmdbuf);
6316
			if (dbo.GetRcdCount() > 0)
6317
			{
6318
				if (AOJ_Validate(dbo.GetIntVal(0, 0), aoj))
6319
					return TRUE;
6320

    
6321
				sprintf(msg, "??ǰ?û?????%s??%s ??Ȩ???????У?", pName, pcode);
6322
			}
6323
			else
6324
				sprintf(msg, "ȡ%s???е?%s??%s ??Ȩ??????ʧ?ܣ?", fields[type].tbl, pName, pcode);
6325
		}
6326
	}
6327

    
6328
	CString str;
6329
	str.Format("????Ա?Ը?%s?޿???Ȩ?ޣ?\n%s", pName, msg);
6330
	g_ehmiMainFrame->ShowInfoTip(str);
6331

    
6332
	return FALSE;
6333
}
6334

    
6335
CBaseObj *CGWnd::GetObjByName(char *pObj, CGWnd *&pGWnd)
6336
{
6337
	pGWnd = NULL;
6338

    
6339
	if (s_mapWnd[this] == 0)
6340
		return NULL;
6341

    
6342
	pGWnd = this;
6343

    
6344
	if (pObj == NULL)
6345
		return m_pCurObj;
6346

    
6347
	char *pObjName = strchr(pObj, '.');
6348
	if (pObjName)
6349
	{
6350
		char wndName[MAX_PATH] = "";
6351
		strncpy(wndName, pObj, pObjName - pObj);
6352

    
6353
		pGWnd = m_pView->FindGWnd(wndName, true);
6354
		if (s_mapWnd[pGWnd] == 0)
6355
			return NULL;
6356

    
6357
		pObjName++;
6358
	}
6359
	else
6360
		pObjName = pObj;
6361

    
6362
	return pGWnd->m_map.GetObjectbyname(pObjName);
6363
}
6364

    
6365
CehmiView* CGWnd::GetParentWnd()
6366
{
6367
	if (s_mapWnd[this] == 0)
6368
		return NULL;
6369

    
6370
	return m_pView;
6371
}
6372

    
6373
BOOL CGWnd::PreTranslateMessage(MSG* pMsg) 
6374
{
6375
	g_ehmiMainFrame->m_Tip.RelayEvent(pMsg);
6376
	
6377
	return CWnd::PreTranslateMessage(pMsg);
6378
}
6379

    
6380
void CGWnd::ShowYKDlg()
6381
{
6382
	char cmdbuf[256];
6383
	sprintf(cmdbuf, "select F4011_SUPERVISE, F4011_CTRLACTION, F4009_POINTDESC from %s, %s"
6384
		" where F4011_POINTCODE = '%s' and F4009_POINTCODE = F4011_POINTCODE",
6385
		YK_PARA_TBLNAME, YX_PARA_TBLNAME, m_seldev.sYXCode);
6386

    
6387
	CSE_DBOption dboption;
6388
	dboption.BeginSelectRcdSet(cmdbuf);
6389
	int count = dboption.GetRcdCount();
6390
	if (count <= 0)
6391
	{
6392
		AfxMessageBox("??????DO???????в?????!");
6393
		return;
6394
	}
6395

    
6396
	int supervise   = *(BYTE *)dboption.GetColVal(0, 0);
6397
	int ctrlAction  = *(BYTE *)dboption.GetColVal(0, 1);
6398
	char *pointDesc = (char *)dboption.GetColVal(0, 2);
6399

    
6400
	if (supervise == SE_K_SUPERVISETYPE_ACK_SELF)
6401
	{
6402
		CString msg;
6403
		msg.Format("????ȷ???Ƿ?Ҫ?ԡ?%s?????п??ƣ?", pointDesc);
6404

    
6405
		if (MessageBox(msg, "????ȷ??", MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON2)
6406
			!= IDOK)
6407
			return;
6408
	}
6409

    
6410
	if (ctrlAction != 0)
6411
	{
6412
		if (ctrlAction == 1)
6413
			ShowYKDlg(m_seldev);
6414

    
6415
		return;
6416
	}
6417

    
6418
	// The following codes are same as yk
6419

    
6420
	char* obj = m_seldev.sYXCode;
6421
	if(obj == 0)
6422
		return;
6423

    
6424
	CDialog* ytdlg  = g_ehmiMainFrame->GetOptDlg(CTRL_YTDLG);
6425
	CDialog* yt2dlg = g_ehmiMainFrame->GetOptDlg(CTRL_YTAODLG);
6426

    
6427
	if (ytdlg && ytdlg->IsWindowVisible() || yt2dlg && yt2dlg->IsWindowVisible())
6428
	{
6429
		AfxMessageBox("????ͬʱ????ң?غ?ң??????");
6430
		return;
6431
	}
6432

    
6433
	CMMIYKDODlg * ykdlg = (CMMIYKDODlg *)g_ehmiMainFrame->GetOptDlg(CTRL_YKDODLG);
6434
	if(!ykdlg){
6435
		ykdlg = new CMMIYKDODlg(this);
6436
		ykdlg->Create(IDD_MMI_YKDO,this);
6437
		g_ehmiMainFrame->SetOptDlg(CTRL_YKDODLG,ykdlg);
6438
	}
6439

    
6440
	ykdlg->SetPara (obj);
6441
	ykdlg->SetRelYxFlag(g_ehmiMainFrame->m_faceSetting.yk_relyx); 
6442

    
6443
	if(g_ehmiMainFrame->m_faceSetting.yk_needlogin ){
6444
		if(RBAC_Login(NULL, 3, true)){
6445
			if(!RBAC_CheckPrivilege(DEF_RIGHT_OPERATOR)){
6446
				AfxMessageBox("?Բ?????û??DO?IJ???Ȩ??");
6447
				return;
6448
			}
6449
		}
6450
		else {
6451
				return;
6452
		}
6453
	}
6454
	if(ykdlg->ykok) ykdlg->ShowWindow (SW_SHOW);
6455
}
6456

    
6457
void CGWnd::ShowPopupMenu(CPoint point)
6458
{
6459
	if (m_pObjPressed)
6460
	{
6461
		CFRect fRect = m_pObjPressed->GetObjectRect();
6462
		m_pObjPressed->SetObjPressed(FALSE);
6463
		DrawObj(&fRect, &m_pObjPressed->GetObjectRect());
6464
		m_pObjPressed = NULL;
6465
	}
6466

    
6467
	if (m_pObjColor)
6468
	{
6469
		CFRect fRect = m_pObjColor->GetObjectRect();
6470
		fRect.InflateRect(8.0, 2.0);
6471
		((CTextObj *)m_pObjColor)->SetTextColor(m_fgcolor);
6472
		DrawObj(&fRect);
6473
		m_pObjColor = NULL;
6474
	}
6475

    
6476
	CPoint pt(point);
6477

    
6478
	if (m_pObjMenu)
6479
	{
6480
		CFRect fRect = m_pObjMenu->GetObjectRect();
6481

    
6482
		CRect rc;
6483
		m_GraphGUI.MapToClient(&fRect, &rc);
6484

    
6485
		pt.x = (fRect.left + fRect.right) / 2;
6486
		pt.y = GetSystemMetrics(SM_CYSCREEN) - m_Rect.bottom
6487
			> 10 ? rc.bottom : rc.top - 2;
6488
	}
6489

    
6490
	ClientToScreen(&pt);
6491
	PopupMenu(pt);
6492
}
6493

    
6494
void CGWnd::PopupMenu(CPoint point)
6495
{
6496
	// ?????˵??????ļ?·??
6497
	char cfgFile[_MAX_PATH];
6498
	sprintf(cfgFile, "%s\\%s", g_ehmiMainFrame->GetSysPath(), MENUCFG_PATH);
6499

    
6500
	UINT menuNums = GetPrivateProfileInt(m_hotpara, "?˵?????", 0, cfgFile);
6501
	if (menuNums > 0)
6502
	{
6503
		int menuID = 0;
6504
		if (m_menuIDArray.GetSize() == 0)
6505
			m_menuIDArray.SetSize(MaxPopupMenuItems);
6506

    
6507
		// ???????ļ???ȡ?˵?ͼ??
6508

    
6509
		char bmpName[_MAX_PATH];
6510
		GetPrivateProfileString("?˵?????", "ͼ???ļ?", "", bmpName, _MAX_PATH, cfgFile);
6511

    
6512
		char bmpFile[_MAX_PATH];
6513
		sprintf(bmpFile, "%s\\bmp\\%s", g_ehmiMainFrame->GetSysPath(), bmpName);
6514

    
6515
		HBITMAP hBitmap = (HBITMAP)LoadImage(NULL, bmpFile, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
6516
		CBitmap bitmap;
6517

    
6518
		if (hBitmap)
6519
			bitmap.Attach(hBitmap);
6520
		else
6521
			bitmap.LoadBitmap(IDB_BITMAP_POPMENU);
6522

    
6523
		CImageList imgList;
6524
		imgList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 0, 2);
6525
		imgList.SetBkColor(CLR_NONE);
6526
		imgList.Add(&bitmap, CLR_NONE);
6527
		if (hBitmap != NULL)
6528
			DeleteObject(hBitmap);
6529

    
6530
		// ??ͼ???ļ???ȡ?˵?????
6531

    
6532
		LOGFONT lf;
6533
		LOGFONT *plf = NULL;
6534
		if (m_hotstring != "")
6535
		{
6536
			plf = &lf;
6537
			sscanf(m_hotstring, "%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%s",
6538
				&lf.lfHeight,
6539
				&lf.lfWidth,
6540
				&lf.lfEscapement,
6541
				&lf.lfOrientation,
6542
				&lf.lfWeight,
6543
				&lf.lfItalic,
6544
				&lf.lfUnderline,
6545
				&lf.lfStrikeOut,
6546
				&lf.lfCharSet,
6547
				&lf.lfOutPrecision,
6548
				&lf.lfClipPrecision,
6549
				&lf.lfQuality,
6550
				&lf.lfPitchAndFamily,
6551
				&lf.lfFaceName);
6552
		}
6553

    
6554
		COLORREF clr[4];
6555

    
6556
		BOOL sysClr = GetPrivateProfileInt("?˵?????", "Ĭ??ɫ", 1, cfgFile);
6557
		if (!sysClr)
6558
		{
6559
			const char *KeyName[] = { "????ɫ", "????ɫ", "????ɫ", "????????ɫ" };
6560
			const char *Default[] = { "255,255,255", "0,0,0", "49,106,197", "255,255,255" };
6561

    
6562
			char str[_MAX_PATH];
6563
			int r, g, b;
6564

    
6565
			for (int i=0; i < 4; i++)
6566
			{
6567
				GetPrivateProfileString("?˵?????", KeyName[i], Default[i], str, _MAX_PATH, cfgFile);
6568

    
6569
				sscanf(str, "%d,%d,%d", &r, &g, &b);
6570
				clr[i] = RGB(r, g, b);
6571
			}
6572
		}
6573

    
6574
		char group[32];
6575
		strcpy(group, m_pView->GetGroupCode());
6576
		strupr(group);
6577

    
6578
		CBitmapMenu menu(&imgList, plf);
6579
		PopupSubMenu(&menu, NULL, (LPSTR)(LPCTSTR)m_hotpara, menuNums, menuID,
6580
			&imgList, plf, cfgFile, group, sysClr ? NULL : clr);
6581

    
6582
		menu.TrackPopupMenu(TPM_CENTERALIGN | TPM_RIGHTBUTTON, point.x, point.y, this);
6583
	}
6584
}
6585

    
6586
void CGWnd::PopupSubMenu(CBitmapMenu *pMenu, char *name, char *app, UINT menuNums, int &menuID,
6587
						 CImageList* plist, LOGFONT* plf, char *cfg, char *group, COLORREF *clr)
6588
{
6589
	CBitmapMenu *pSubMenu = name == NULL ? pMenu : new CBitmapMenu(plist, plf);
6590
	pSubMenu->CreatePopupMenu();
6591

    
6592
	if (clr)
6593
	{
6594
		pSubMenu->SetBackColor(clr[0]);
6595
		pSubMenu->SetTextColor(clr[1]);
6596
		pSubMenu->SetHighlightColor(clr[2]);
6597
		pSubMenu->SetHighlightTextColor(clr[3]);
6598
	}
6599

    
6600
	char key[_MAX_PATH];
6601
	char str[_MAX_PATH];
6602
	char cmd[_MAX_PATH];
6603
	char sta[_MAX_PATH];
6604
	for (UINT i=1; i <= menuNums; i++)
6605
	{
6606
		sprintf(key, "?˵?%d", i);
6607
		GetPrivateProfileString(app, key, "", str, _MAX_PATH, cfg);
6608

    
6609
		sprintf(key, "????%d", i);
6610
		GetPrivateProfileString(app, key, "", cmd, _MAX_PATH, cfg);
6611

    
6612
		sprintf(key, "????%d", i);
6613
		GetPrivateProfileString(app, key, "", sta, _MAX_PATH, cfg);
6614

    
6615
		if (strstr(strupr(sta), group))
6616
			continue;
6617

    
6618
		UINT menuNums = GetPrivateProfileInt(cmd, "?˵?????", 0, cfg);
6619
		if (menuNums > 0)
6620
		{
6621
			PopupSubMenu(pSubMenu, str, cmd, menuNums, menuID,
6622
				plist, plf, cfg, group, clr);
6623
		}
6624
		else
6625
		{
6626
			if (strcmp(str, "?ָ???"))
6627
			{
6628
				pSubMenu->AppendMenu(MF_STRING, menuID+ID_POPUP_MENU, str, 0, 1, 2);
6629
				m_menuIDArray[menuID++] = cmd;
6630
			}
6631
			else
6632
				pSubMenu->AppendMenu(MF_SEPARATOR | MF_OWNERDRAW, MF_SEPARATOR, "");
6633
		}
6634
	}
6635

    
6636
	if (name)
6637
	{
6638
		pMenu->AppendMenu(MF_STRING | MF_POPUP, (UINT)pSubMenu->m_hMenu, name, 0, 1, 2);
6639
		pMenu->AddSubMenu(pSubMenu);
6640
	}
6641
}
6642

    
6643
void CGWnd::OnPopupMenuCmd(UINT nID)
6644
{
6645
	UINT index = nID - ID_POPUP_MENU;
6646
	if (index >= 0 && index < MaxPopupMenuItems)
6647
	{
6648
		CString str = m_menuIDArray[index];
6649
		str.MakeLower();
6650

    
6651
		if (str.Find(".exe") != -1)
6652
		{
6653
			STARTUPINFO si = { sizeof(si) };
6654
			PROCESS_INFORMATION pi = { 0 };
6655
			CreateProcess(NULL, str.GetBuffer(0), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi);
6656
		}
6657
		else if (str.Find(".svm") != -1)
6658
		{
6659
			m_pView->OpenSvms(str);
6660
		}
6661
		else if (str.Find('.') != -1)
6662
		{
6663
			ShellExecute(m_hWnd, "open", str, NULL, NULL, SW_SHOWNORMAL);
6664
		}
6665
		else
6666
		{
6667
			int cmd = 0;
6668
			if (g_ehmiMainFrame->m_cmdMap.Lookup(str, cmd))
6669
			{
6670
				if (m_pView->m_pCurGWnd == NULL ||
6671
					m_pView->m_pCurGWnd->SendMessage(WM_COMMAND, cmd) == 0)
6672
					m_pView->SendMessage(WM_COMMAND, cmd);
6673
			}
6674
		}
6675

    
6676
		CBaseObj *pObj = m_pObjMenu;
6677
		if (pObj)
6678
		{
6679
			int nGroup = ((CButtonObj *)pObj)->GetGroups();
6680
			UpdateObjGroups(pObj->GetObjectName(), nGroup);		
6681
			pObj->OnLButtonUp(MK_LBUTTON, CPoint(0, 0));			
6682
		}
6683
	}
6684
}
6685

    
6686
void CGWnd::OnInitMenuPopup(CMenu* pPopupMenu, UINT nIndex, BOOL bSysMenu) 
6687
{
6688
    ASSERT(pPopupMenu != NULL);
6689
    // Check the enabled state of various menu items.
6690
	
6691
    CCmdUI state;
6692
    state.m_pMenu = pPopupMenu;
6693
    ASSERT(state.m_pOther == NULL);
6694
    ASSERT(state.m_pParentMenu == NULL);
6695
	
6696
    // Determine if menu is popup in top-level menu and set m_pOther to
6697
    // it if so (m_pParentMenu == NULL indicates that it is secondary popup).
6698
    HMENU hParentMenu;
6699
    if (AfxGetThreadState()->m_hTrackingMenu == pPopupMenu->m_hMenu)
6700
        state.m_pParentMenu = pPopupMenu;    // Parent == child for tracking popup.
6701
    else if ((hParentMenu = ::GetMenu(m_hWnd)) != NULL)
6702
    {
6703
        CWnd* pParent = this;
6704
		// Child windows don't have menus--need to go to the top!
6705
        if (pParent != NULL &&
6706
			(hParentMenu = ::GetMenu(pParent->m_hWnd)) != NULL)
6707
        {
6708
			int nIndexMax = ::GetMenuItemCount(hParentMenu);
6709
			for (int nIndex = 0; nIndex < nIndexMax; nIndex++)
6710
			{
6711
				if (::GetSubMenu(hParentMenu, nIndex) == pPopupMenu->m_hMenu)
6712
				{
6713
					// When popup is found, m_pParentMenu is containing menu.
6714
					state.m_pParentMenu = CMenu::FromHandle(hParentMenu);
6715
					break;
6716
				}
6717
			}
6718
        }
6719
    }
6720
	
6721
    state.m_nIndexMax = pPopupMenu->GetMenuItemCount();
6722
    for (state.m_nIndex = 0; state.m_nIndex < state.m_nIndexMax;
6723
	state.m_nIndex++)
6724
    {
6725
        state.m_nID = pPopupMenu->GetMenuItemID(state.m_nIndex);
6726
        if (state.m_nID == 0)
6727
			continue; // Menu separator or invalid cmd - ignore it.
6728
		
6729
        ASSERT(state.m_pOther == NULL);
6730
        ASSERT(state.m_pMenu != NULL);
6731
        if (state.m_nID == (UINT)-1)
6732
        {
6733
			// Possibly a popup menu, route to first item of that popup.
6734
			state.m_pSubMenu = pPopupMenu->GetSubMenu(state.m_nIndex);
6735
			if (state.m_pSubMenu == NULL ||
6736
				(state.m_nID = state.m_pSubMenu->GetMenuItemID(0)) == 0 ||
6737
				state.m_nID == (UINT)-1)
6738
			{
6739
				continue;       // First item of popup can't be routed to.
6740
			}
6741
			state.DoUpdate(this, TRUE);   // Popups are never auto disabled.
6742
        }
6743
        else
6744
        {
6745
			// Normal menu item.
6746
			// Auto enable/disable if frame window has m_bAutoMenuEnable
6747
			// set and command is _not_ a system command.
6748
			state.m_pSubMenu = NULL;
6749
			state.DoUpdate(this, FALSE);
6750
        }
6751
		
6752
        // Adjust for menu deletions and additions.
6753
        UINT nCount = pPopupMenu->GetMenuItemCount();
6754
        if (nCount < state.m_nIndexMax)
6755
        {
6756
			state.m_nIndex -= (state.m_nIndexMax - nCount);
6757
			while (state.m_nIndex < nCount &&
6758
				pPopupMenu->GetMenuItemID(state.m_nIndex) == state.m_nID)
6759
			{
6760
				state.m_nIndex++;
6761
			}
6762
        }
6763
        state.m_nIndexMax = nCount;
6764
    }
6765
}
6766

    
6767
void CGWnd::DrawEqual(BOOL init/* = FALSE*/)
6768
{
6769
	CRect rc;
6770
	GetClientRect(rc);
6771

    
6772
	m_GraphGUI.SetPara(CFPoint(rc.Width()/2.0, rc.Height()/2.0), 1.0);
6773

    
6774
	if (init)
6775
	{
6776
		CRgn rgnUpdate;
6777
		rgnUpdate.CreateRectRgnIndirect(rc);
6778

    
6779
		m_GraphGUI.Draw(rgnUpdate);
6780
	}
6781
	else
6782
		m_GraphGUI.ReDraw();
6783
}
6784

    
6785
void CGWnd::OnDevDiagnose() 
6786
{
6787
	if (g_ehmiMainFrame->m_pfDiagnose == NULL
6788
/*		|| m_devid == SE_K_DEV_NULL*/)
6789
		return;
6790

    
6791
	CDialog *pDlg = g_ehmiMainFrame->m_pfDiagnose (m_seldev.sDevCode);
6792

    
6793
	CDlgDevRealPnt * dlg = new CDlgDevRealPnt();
6794
	dlg->Create(IDD_DIALOG_DEVREALPNT, CWnd::FromHandle(pDlg->GetSafeHwnd()));
6795
	if (dlg->SetDevCode(m_seldev.sDevCode))
6796
		dlg->ShowWindow(SW_SHOW);
6797
	else
6798
		delete dlg;
6799
}
6800

    
6801
void CGWnd::UpdateObjGroups(char *pObjName, int nGroup)
6802
{
6803
	m_csSelection.Lock();
6804

    
6805
	CVGRegion region;
6806

    
6807
	CBaseObjArray & ObjArray = GetFeatureObjects(OS_BUTTON);
6808

    
6809
	for (int i = 0; i < ObjArray.GetSize(); i++)
6810
	{
6811
		CButtonObj *pBtnObj = (CButtonObj *)ObjArray[i];
6812

    
6813
		if (pBtnObj)
6814
		{
6815
			if (pBtnObj->GetGroups() == nGroup && nGroup > 0)
6816
			{
6817
				if (pObjName && strcmp(pObjName, pBtnObj->GetObjectName()) == 0)
6818
				{
6819
					if (!pBtnObj->GetActiveSate())
6820
					{
6821
						pBtnObj->SetActiveSate(TRUE);						
6822
					}
6823
					pBtnObj->ModifyStyle(0, OS_FOCUS, 0);
6824
				}
6825
				else
6826
				{
6827
					if (pBtnObj->GetActiveSate())
6828
					{
6829
						pBtnObj->SetActiveSate(FALSE);				
6830
					}
6831
					pBtnObj->ModifyStyle(OS_FOCUS, 0, 0);
6832
				}
6833
			}
6834
			region.Add(pBtnObj);
6835
		}	
6836
	}
6837

    
6838
	if (region.GetRectCount() > 0)
6839
		m_map.RefreshRegion(region, &m_GraphGUI);
6840

    
6841
	m_csSelection.Unlock();
6842
}
6843

    
6844
void CGWnd::EnableObjects(OBJECT_SHAPE shape, BOOL enable)
6845
{
6846
	CVGRegion region;
6847

    
6848
	CBaseObjArray & ObjArray = GetFeatureObjects(shape);
6849

    
6850
	for (int i = 0; i < ObjArray.GetSize(); i++)
6851
	{
6852
		CBaseObj *pObj = ObjArray[i];
6853

    
6854
		pObj->EnableObject(enable);
6855

    
6856
		region.Add(pObj);
6857
	}
6858

    
6859
	if (region.GetRectCount() > 0)
6860
		m_map.RefreshRegion(region, &m_GraphGUI);
6861
}
6862

    
6863
//?жϱ???????Ƿ????ָ???ĶԻ????????ڣ???????ƶԻ????Ѿ???ʾ?????ˣ?????Ի???֮??????򣬲???ЧӦ??2019-11-07 ?????? yansx
6864
BOOL CGWnd::ClickInSpeciallyDlgRect(CPoint point)
6865
{
6866
	CMainFrame * pFrame = (CMainFrame*)(AfxGetApp()->GetMainWnd());
6867
	CDlgDevInf *pDevDlg = pFrame->GetDevInfoDlg();
6868

    
6869
	int nSettingValue = pFrame->m_faceSetting.nControlDlgShowDisableClick;//0??ʾ???????ƣ???ģ̬?Ի???ģʽ??1??ʾ???ã?????ģ̬?Ի???
6870

    
6871
	if ((pDevDlg != NULL && !pDevDlg->IsWindowVisible()) || nSettingValue == 0)//???ƿ???ʾ??ʱ?򣬲????????й???
6872
	{
6873
		return TRUE;
6874
	}
6875

    
6876
	CRect dlgRect;
6877
	pDevDlg->GetWindowRect(dlgRect);
6878

    
6879
	if (dlgRect.PtInRect(point))//?ж?һ?????Ƿ???һ????????
6880
	{
6881
		return TRUE;
6882
	}
6883

    
6884
	return FALSE;
6885
}
6886
void CGWnd::ShowCtrlDlg(DlgType type, char *obj /*= NULL*/)
6887
{
6888
	if(g_bYKDlgShow == TRUE)//???????ͼԪʱ?????????л????Կ򣬱????ֶ??ر?. Add by Yansx 2019-05-13 feature #24
6889
	{
6890
		return;
6891
	}
6892
	CMainFrame * pFrame = (CMainFrame*) (AfxGetApp()->GetMainWnd());
6893
	CDlgDevInf *pDevDlg = pFrame->GetDevInfoDlg();
6894
	pDevDlg->SetPara(type, obj ? obj : m_seldev.sDevCode,
6895
		m_selCtrlType, m_seldev.sYXCode, m_seldev.sAttchGraph,
6896
		m_analogcode, m_shapeid, m_devid, kwhflag);
6897

    
6898
	CRect rc1;
6899
	CRect rc2;
6900
	GetWindowRect(rc1);
6901
	pDevDlg->GetWindowRect(rc2);
6902

    
6903
	int x = rc1.left + (rc1.Width()  - rc2.Width())  / 2;
6904
	int y = rc1.top  + (rc1.Height() - rc2.Height()) / 2;
6905
/*Modified by WYF2017*******************************/
6906
POINT point=m_LdnPt;//WYF 20180803
6907

    
6908
//GetCursorPos(&point);
6909
x=point.x+25;
6910
if(x+rc2.Width()>rc1.Width())x-=rc2.Width()+25*2;
6911
/*Modified by WYF2017*******************************/
6912
pDevDlg->SetWindowPos(NULL, x+rc1.left, y, 0, 0,/*wyf 20181123*/
6913
		SWP_NOSIZE | SWP_NOZORDER | SWP_SHOWWINDOW);
6914
//pDevDlg->SetWindowPos(NULL, x, y, 380, 322,
6915
//		SWP_NOZORDER | SWP_SHOWWINDOW);//XZF 20180716
6916
}
6917

    
6918
void CGWnd::AnalyseString(const char *s, int len, CBaseObj *pObj, BOOL script /*= FALSE*/)
6919
{
6920
	CString str;
6921
	TrimString(str, s, len);
6922

    
6923
	if (str.GetLength() == 0)
6924
		return;
6925

    
6926
	int f = -1;
6927
	int n = 0;
6928

    
6929
	int f1 = -1;
6930
	int n1 = 0;
6931

    
6932
	char *p1 = str.GetBuffer(0);
6933
	char *p2;
6934
	char *p3;
6935
	while (p1)
6936
	{
6937
		if ((p3 = strchr(p1, ';')))
6938
			*p3++ = 0;
6939

    
6940
		if (*p1)
6941
		{
6942
			n++;
6943

    
6944
			bool isDigital = true;
6945
			int index = 0;
6946
			if (p2 = strchr(p1, ':'))
6947
			{
6948
				*p2++ = 0;
6949

    
6950
				if (*p1 == 'M' || *p1 == 'm')
6951
				{
6952
					CBaseObj *pBaseObj = m_map.GetObjectbyname(p2);
6953

    
6954
					if (pBaseObj)
6955
					{
6956
						ST_META m;
6957
						m.sobj = pObj;
6958
						m.obj = pBaseObj;
6959
						m.var = p1;
6960
						m.val = 0;
6961
						//m.chg = 1;
6962
						//+++wyf 2010.03.11 ??ʼ??ֵ??Ϊ0
6963
						m.chg = 0;
6964

    
6965
						index = m_metaSta.Add(m);
6966

    
6967
						n1++;
6968
						if (f1 < 0)
6969
							f1 = index;
6970

    
6971
						m_metaObj[pObj] = n1 << 16 | f1;
6972
					}
6973

    
6974
					n--;
6975
					p1 = p3;
6976
					continue;
6977
				}
6978
				else
6979
				{
6980
					if (*p1 == 'A' || *p1 == 'a')
6981
					{
6982
						isDigital = false;
6983
					}
6984

    
6985
					if (script)
6986
						m_scriptVar.Add(p1);
6987
				}
6988
			}
6989
			else
6990
			{
6991
				p2 = p1;
6992

    
6993
				if (script)
6994
				{
6995
					char var[16];
6996
					sprintf(var, "var%d", n);
6997
					m_scriptVar.Add(var);
6998
				}
6999
			}
7000

    
7001
			SRDB_PARAINFO *para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
7002
			ST_VISITRDB   *data = (ST_VISITRDB   *)m_rdbdata.GetNextUnit();
7003

    
7004
			int no = m_rdbdata.GetUnitNum() - 1;
7005
			if (script)
7006
				index = m_scriptNo.Add(no);
7007
			else
7008
				index = m_logicNo.Add(no);
7009

    
7010
			if (f < 0)
7011
				f = index;
7012

    
7013
			strcpy(para->tbl, isDigital ? DIGITAL_RDB_TBLNAME : ANA_RDB_TBLNAME);
7014
			strcpy(para->obj, p2);
7015
			strcpy(para->field, "Value");
7016

    
7017
			data->obj = pObj;
7018
			data->sval.m_type = isDigital ? REALDB_UCHAR : REALDB_FLOAT;
7019
			data->sval.m_val.floatval = 0;
7020
			data->valide = 1;
7021
			data->flag = script ? ehmi_FRESH_SCRIPLINKDATA : ehmi_FRESH_LOGICLINKDATA;
7022
			data->userdata1 = 0xff;
7023
		}
7024
		p1 = p3;
7025
	}//End while
7026

    
7027
	if (f >= 0 && n > 0)
7028
	{
7029
		if (script)
7030
			m_scriptObj[pObj] = n << 16 | f;
7031
		else
7032
			m_logicObj[pObj]  = n << 16 | f;
7033
	}
7034
}
7035

    
7036
BOOL CGWnd::DrawNameView(const char *name, int index /*= 0*/)
7037
{
7038
	CEasyList *pvmList = m_map.GetViewMarkList();
7039

    
7040
	for (int i=0; i < pvmList->GetListLen(); i++)
7041
	{
7042
		CViewMark *pViewMark = (CViewMark *)pvmList->GetNth(i);
7043
		if (pViewMark)
7044
		{
7045
			if (name != NULL && strcmp(pViewMark->Name(), name) == 0 ||
7046
				name == NULL && i == index)
7047
			{
7048
				m_GraphGUI.DrawMapExtent(pViewMark->GetViewRect()); 
7049
				return TRUE;
7050
			}
7051
		}
7052
	}
7053

    
7054
	return FALSE;
7055
}
7056

    
7057
void CGWnd::UpdateCounter(CVGRegion &region)
7058
{
7059
	CBaseObjArray & ObjArray = GetFeatureObjects(OS_COUNTER);
7060
	for (int i = 0; i < ObjArray.GetSize(); i++)
7061
	{
7062
		CCounterObj * pCounterObj = (CCounterObj*) ObjArray[i];
7063
		if (!pCounterObj) 
7064
			continue;		
7065
		pCounterObj->OnTimer();	
7066
		region.Add(pCounterObj);
7067
	}
7068
}
7069

    
7070
void CGWnd::CollectATSData()
7071
{
7072
	CBaseObjArray & ObjArray = GetFeatureObjects(OS_ATS);
7073
	for (int i = 0; i < ObjArray.GetSize(); i++)
7074
	{
7075
		CAtsObj * pObj = (CAtsObj*) ObjArray[i];
7076
		// ??֤ϵͳֻ??һ??ATSObject
7077
		if (!pObj || i >= 1) 
7078
		{
7079
			continue;
7080
		}
7081
		CEasyList lstEdges, lstNodes, lstStatic;
7082
		CBaseObjArray &ObjEdgeArray = GetFeatureObjects(OS_ATSEDGE);
7083
		int j = 0;
7084
		for ( j = 0; j < ObjEdgeArray.GetSize(); j++)
7085
		{
7086
			CAtsEdge *pEdgeObj = (CAtsEdge *)ObjEdgeArray[j];
7087
			lstEdges.AddLast(pEdgeObj);
7088
	
7089
			LINKINFOARRAY *pAry = pEdgeObj->Link();
7090
			int nSize = pAry->GetSize();
7091
			if (nSize != 2)
7092
			{
7093
				continue;
7094
			}
7095
		
7096
			for (int k = 0; k < nSize; k++)
7097
			{						
7098
				STRUCT_LINKINFO stLink = (STRUCT_LINKINFO)pAry->GetAt(k);
7099
				CAtsNode *pNodeObj = (CAtsNode *)m_map.FindObject(
7100
					stLink.FeatureID, stLink.LinkID);
7101
				lstNodes.AddLast(pNodeObj);
7102
			}
7103
			pEdgeObj->WndNodes(lstNodes);
7104
			lstNodes.DelAll();
7105
		}
7106
		pObj->WndEdges(lstEdges);
7107

    
7108
		lstEdges.DelAll();
7109

    
7110
		CBaseObjArray &ObjStaticArray = GetFeatureObjects(OS_RECT);
7111
		for (j = 0; j < ObjStaticArray.GetSize(); j++)
7112
		{
7113
			CRectObj *pStaticObj = (CRectObj *)ObjStaticArray[j];
7114
			lstStatic.AddLast(pStaticObj);			
7115
		}
7116
		pObj->WndPlatForms(lstStatic);
7117
		lstStatic.DelAll();
7118
			
7119
		CRdbSqlAccess cli;	
7120
		cli.OptTbl("ats");	
7121
		cli.SelectCol("TrainNo");	
7122
		cli.SelectCol("TrainID");	
7123
		cli.SelectCol("Dir");		
7124
		cli.SelectCol("ParentEdge");
7125
		cli.SelectCol("Offset");
7126
		cli.SelectCol("Status");
7127
		cli.SelectCol("HeadCode");
7128
		cli.SelectCol("TDN");
7129
		cli.SetUserPwd("guest", "");
7130
		SRDB_PARAINFO *para = NULL;
7131
		ST_VISITRDB *data = NULL;
7132
		int nRcdcnt = 0;
7133
		if (cli.ExecSelect() == REALDB_TRUE)
7134
		{
7135
			nRcdcnt = cli.GetRcdCount();
7136
			CFeatureLayer *pTrainLayer = NULL;
7137
			char *szTrainLayer = "TRAIN";
7138
			m_map.AddLayer(szTrainLayer, FEATURELAYER, FT_OTHER, TRUE);
7139
			pTrainLayer = m_map.GetFeatureLayer(FT_OTHER);
7140
			
7141
			for (int j = 0; j < nRcdcnt; j++)
7142
			{
7143
				STRUCT_ATSDATA atsdata;
7144
				memset(&atsdata, 0, sizeof(STRUCT_ATSDATA));
7145
				strcpy(atsdata.TrainNo, cli.GetString(j, 0));	
7146
				atsdata.TrainID = cli.GetUIntVal(j, 1);	
7147
				atsdata.Dir = cli.GetIntVal(j, 2);			
7148
				atsdata.ParentEdge = cli.GetIntVal(j, 3);
7149
				atsdata.Offset = cli.GetFloatVal(j, 4);
7150
				atsdata.Status = cli.GetIntVal(j, 5);	
7151
				atsdata.HeadCode = cli.GetIntVal(j, 6);
7152
				atsdata.TDN = cli.GetUIntVal(j, 7);
7153
				size_t nOffset = offsetof(STRUCT_ATSDATA, ATS);
7154
				memcpy(atsdata.ATS, &atsdata, nOffset);
7155

    
7156
				CAtsTrain *pTrain = new CAtsTrain(pObj, atsdata);
7157
				pTrainLayer->AddAObject(pTrain);
7158
					
7159
				para = (SRDB_PARAINFO *)m_rdbpara.GetNextUnit();
7160
				data = (ST_VISITRDB *)m_rdbdata.GetNextUnit();
7161
				strcpy(para->tbl, _T("ats"));
7162
				strcpy(para->obj, atsdata.TrainNo);
7163
				strcpy(para->field, "ATS");
7164
				data->sval.m_type = REALDB_STRING;
7165
				data->sval.m_strlen = 256;
7166
				data->sval.m_val.uintval = 0;						
7167
				data->obj = pTrain;
7168
				data->valide = 1;		
7169
				data->flag = ehmi_FRESH_ATSTRAIN;
7170
				data->userdata1 = TV_STRUCT;			
7171
			}			
7172
		}			
7173
	}	
7174
}
7175

    
7176
BOOL CGWnd::GetLogicDataSet(CPointItemArray &aryPointItem)
7177
{
7178
	BOOL bLogic = FALSE;
7179
	int nDllType;
7180
	if (m_pObjSelect)
7181
	{
7182
		nDllType = ((CPointObj *)m_pObjSelect)->GetDllType();
7183
		if (nDllType > 0)
7184
		{
7185
			int nIndex;
7186
			if (!m_logicObj.Lookup(m_pObjSelect, nIndex))
7187
			{
7188
				return bLogic;
7189
			}
7190
			
7191
			int nNo = nIndex & 0xffff;
7192
			int nParaNums = nIndex >> 16;
7193
			for (int i = 0; i < nParaNums; i++)
7194
			{
7195
				SRDB_PARAINFO *para = (SRDB_PARAINFO *)m_rdbpara.GetUnit(m_logicNo[nNo + i]);
7196
				if (para)
7197
				{
7198
					POINTITEM ptItem;
7199
					memset(&ptItem, 0, sizeof(POINTITEM));
7200
					char devDesc[DEF_OBJDESC_LEN];
7201
					memset(&devDesc,0,DEF_OBJDESC_LEN);
7202

    
7203
					strncpy(ptItem.PointCode, para->obj, DEF_OBJCODE_LEN - 1);
7204

    
7205
					if (strcmp(para->tbl, ANA_RDB_TBLNAME) == 0)
7206
					{
7207
						ptItem.nDevType = DEF_YC_SIMILARDEV;
7208
						bLogic = GetPointDescByPointCode(ptItem.PointCode,devDesc,FALSE);
7209
					}
7210
					else if (strcmp(para->tbl, DIGITAL_RDB_TBLNAME) == 0)
7211
					{
7212
						ptItem.nDevType = DEF_YX_SIMILARDEV;
7213
						bLogic = GetPointDescByPointCode(ptItem.PointCode,devDesc,TRUE);
7214
					}
7215

    
7216
					strncpy(ptItem.PointDesc,devDesc,DEF_OBJDESC_LEN);
7217
					aryPointItem.Add(ptItem);
7218
					//bLogic = TRUE;
7219
				}								
7220
			}
7221
		}
7222
	}
7223
	return bLogic;
7224
}
7225

    
7226
bool CGWnd::GetPointDescByPointCode(char* PointCode, char devDesc[DEF_OBJDESC_LEN], bool bYX)
7227
{
7228
	//???ݵ?????ö?Ӧ?ĵ?????
7229
    if(strcmp(PointCode,"") == 0)
7230
		return false;
7231
	
7232
	CSE_DBOption dboption;
7233
	SEDB_CMDINFO cmdinfo;
7234
	SEDB_DATAFMT *datafmt=NULL;
7235
	char cmdbuf[1024];
7236
	int i,count;
7237
	char * Field[1]={""};
7238

    
7239
	//?????????????ȡ?豸????
7240
	if(bYX)
7241
	{
7242
		sprintf(cmdinfo.table,"%s.dbo.%s",SCADA_PARALIB,YX_PARA_TBLNAME);
7243
		strcpy(Field[0],"F4009_POINTDESC");
7244
	}
7245
	else//AI
7246
	{
7247
		sprintf(cmdinfo.table,"%s.dbo.%s",SCADA_PARALIB,YC_PARA_TBLNAME);
7248
		strcpy(Field[0],"F4007_POINTDESC");
7249
	}
7250
	
7251
	//char * Field[] = {"F4009_POINTDESC"};
7252
	
7253
	strcpy(cmdbuf,"select ");
7254
	for(i=0;i<sizeof(Field)/sizeof(char *);i++){
7255
		strcat(cmdbuf,Field[i]);
7256
		if(i<(sizeof(Field)/sizeof(char *)-1))strcat(cmdbuf,",");
7257
	}
7258
	strcat(cmdbuf," from ");
7259
	strcat(cmdbuf,cmdinfo.table);
7260
	if(bYX)
7261
	{
7262
		strcat(cmdbuf," where F4009_POINTCODE='");
7263
	}else
7264
	{
7265
		strcat(cmdbuf," where F4007_POINTCODE='");
7266
	}
7267
	strcat(cmdbuf, PointCode);
7268
	strcat(cmdbuf,"'");
7269
	
7270
	dboption.BeginSelectRcdSet(cmdbuf);
7271
	count = dboption.GetRcdCount();
7272
	if(count <=0){
7273
		//AfxMessageBox("???󲻴???????????豸????!");
7274
		dboption.EndSelectRcdSet();
7275
		strcpy(devDesc,"???޴˵?");
7276
		return false;
7277
	}
7278

    
7279
	strcpy(devDesc,dboption.GetStringVal(0,0));
7280
	dboption.EndSelectRcdSet();	
7281
	return true;
7282
}
7283

    
7284
void CGWnd::UpdateMetaStatus(CVGRegion &region)
7285
{
7286
	BOOL flag;
7287
	COLORREF clr;
7288

    
7289
	CMap<CBaseObj *, CBaseObj *, int, int>  objMap;
7290
	for (int i=0; i < m_metaSta.GetSize(); i++)
7291
	{
7292
		flag = m_metaSta[i].obj->GetRealSetColor(clr);
7293
		if (flag != m_metaSta[i].val)
7294
		{
7295
			m_metaSta[i].val = flag;
7296
			m_metaSta[i].chg = 1;
7297
		}
7298
		if (m_metaSta[i].chg)
7299
		{
7300
			objMap[m_metaSta[i].sobj] = 1;
7301
			//+++wyf 2010.03.11 ???ӹ??㴦??
7302
			m_metaSta[i].chg = 0;
7303
		}
7304
	}
7305

    
7306
	POSITION pos = objMap.GetStartPosition();
7307
	CBaseObj *pObj;
7308
	int val;
7309
	while (pos != NULL)
7310
	{
7311
		objMap.GetNextAssoc( pos, pObj, val );
7312

    
7313
		FreshScriptLinkData(pObj);
7314

    
7315
		region.Add(pObj);
7316
	}
7317
}
7318

    
7319
void CGWnd::AddDrawFrameObj(CBaseObj *pObj, BOOL bAdd)
7320
{
7321
	if (bAdd)
7322
		m_frmObj[pObj] = 1;
7323
	else
7324
		m_frmObj.RemoveKey(pObj);
7325
}
7326

    
7327
void CGWnd::CheckDataSrc(BOOL bTip)
7328
{
7329
	m_disp = !m_disp;
7330

    
7331
	if (m_disp)
7332
	{
7333
		m_tip = "????Դ???????У????Ժ?...";
7334

    
7335
		// ???豸????Դ???
7336
		CBaseObjArray objAry;
7337
		GetAllObjects(OS_POINTDEV, objAry);
7338

    
7339
		CMap<CString, LPCTSTR, int, int>  objMap;
7340
		CSE_DBOption dbo;
7341

    
7342
		CString sql = "select t.f4009_pointcode from semodel.tb4009_digpoint t where t.f4009_pointcode in (";
7343
		CString code;
7344

    
7345
		int i = 0;
7346
		for ( i=0; i < objAry.GetSize(); i++)
7347
		{
7348
			CPointDevice *pDev = (CPointDevice *)objAry[i];
7349

    
7350
			if (pDev->GetDllType() == 0)
7351
			{
7352
				STRUCT_DEVBASEINFO dev;
7353
				pDev->GetDevInfo(dev);
7354

    
7355
				code.Format("'%s', ", dev.sYXCode);
7356
				sql += code;
7357
			}
7358
			else
7359
			{
7360
				int len = pDev->GetParamLen();
7361
				if (len > 0)
7362
				{
7363
					CString str;
7364
					TrimString(str, (const char *)pDev->m_pParamData, len);
7365

    
7366
					char *p1 = str.GetBuffer(0);
7367
					char *p2;
7368
					while (p1)
7369
					{
7370
						if ((p2 = strchr(p1, ';')))
7371
							*p2++ = 0;
7372

    
7373
						if (*p1)
7374
						{
7375
							code.Format("'%s', ", p1);
7376
							sql += code;
7377
						}
7378
						p1 = p2;
7379
					}
7380
				}
7381
			}
7382

    
7383
			if (i + 1 == objAry.GetSize() || sql.GetLength() >= SE_SQLSTR_MAXLEN / 2)
7384
			{
7385
				sql += "'')";
7386

    
7387
				dbo.BeginSelectRcdSet(sql.GetBuffer(0));
7388

    
7389
				int count = dbo.GetRcdCount();
7390
				for (int j=0; j < count; j++)
7391
				{
7392
					objMap[dbo.GetStringVal(j, 0)] = 1;
7393
				}
7394

    
7395
				dbo.EndSelectRcdSet();
7396

    
7397
				sql = "select t.f4009_pointcode from semodel.tb4009_digpoint t where t.f4009_pointcode in (";
7398
			}
7399
		}
7400

    
7401
		for (i=0; i < objAry.GetSize(); i++)
7402
		{
7403
			CPointDevice *pDev = (CPointDevice *)objAry[i];
7404
			BOOL bDisp = FALSE;
7405

    
7406
			if (pDev->GetDllType() == 0)
7407
			{
7408
				STRUCT_DEVBASEINFO dev;
7409
				pDev->GetDevInfo(dev);
7410

    
7411
				code = dev.sYXCode;
7412

    
7413
				if (code == "")
7414
				{
7415
					m_objAry2.Add(pDev);
7416
					continue;
7417
				}
7418

    
7419
				int val;
7420
				if (!objMap.Lookup(code, val))
7421
				{
7422
					m_objAry.Add(pDev);
7423
					bDisp = TRUE;
7424
				}
7425
			}
7426
			else
7427
			{
7428
				int len = pDev->GetParamLen();
7429
				if (len > 0)
7430
				{
7431
					CString str;
7432
					TrimString(str, (const char *)pDev->m_pParamData, len);
7433

    
7434
					if (str == "")
7435
					{
7436
						m_objAry2.Add(pDev);
7437
						continue;
7438
					}
7439

    
7440
					char *p1 = str.GetBuffer(0);
7441
					char *p2;
7442
					while (p1)
7443
					{
7444
						if ((p2 = strchr(p1, ';')))
7445
							*p2++ = 0;
7446

    
7447
						if (*p1)
7448
						{
7449
							code = p1;
7450
							int val;
7451
							if (!objMap.Lookup(code, val))
7452
							{
7453
								m_objAry.Add(pDev);
7454
								bDisp = TRUE;
7455
								memcpy(code.GetBuffer(len), pDev->m_pParamData, len);
7456
								code.ReleaseBuffer();
7457
								break;
7458
							}
7459
						}
7460
						p1 = p2;
7461
					}
7462
				}
7463
			}
7464

    
7465
			if (bTip && bDisp)
7466
			{
7467
				CFRect fRect = pDev->GetObjectRect();
7468

    
7469
				CRect rc;
7470
				m_GraphGUI.MapToClient(&fRect, &rc);
7471
				ClientToScreen(rc);
7472
				CPoint point = rc.CenterPoint();
7473
				
7474
				CXInfoTip *pTip = new CXInfoTip();
7475
				pTip->Create(this,GetTipFrameColor(),GetTipTextColor());
7476
				pTip->EnableTimer(FALSE);
7477
				pTip->Show(code, &point);
7478

    
7479
				m_tipAry.Add(pTip);
7480
			}
7481
		}
7482

    
7483
		// ң???????Դ???
7484
		objAry.RemoveAll();
7485
		objMap.RemoveAll();
7486
		GetAllObjects(OS_ANALOG, objAry);
7487

    
7488
		sql = "select t.f4007_pointcode from semodel.tb4007_anapoint t where t.f4007_pointcode in (";
7489

    
7490
		for (i=0; i < objAry.GetSize(); i++)
7491
		{
7492
			CYaoCeObj *pDev = (CYaoCeObj *)objAry[i];
7493

    
7494
			if (pDev->GetTypeID() == 0)
7495
			{
7496
				code.Format("'%s', ", pDev->GetYCCode());
7497
				sql += code;
7498
			}
7499

    
7500
			if (i + 1 == objAry.GetSize() || sql.GetLength() >= SE_SQLSTR_MAXLEN / 2)
7501
			{
7502
				sql += "'')";
7503

    
7504
				dbo.BeginSelectRcdSet(sql.GetBuffer(0));
7505

    
7506
				int count = dbo.GetRcdCount();
7507
				for (int j=0; j < count; j++)
7508
				{
7509
					objMap[dbo.GetStringVal(j, 0)] = 1;
7510
				}
7511

    
7512
				dbo.EndSelectRcdSet();
7513

    
7514
				sql = "select t.f4007_pointcode from semodel.tb4007_anapoint t where t.f4007_pointcode in (";
7515
			}
7516
		}
7517

    
7518
		for (i=0; i < objAry.GetSize(); i++)
7519
		{
7520
			CYaoCeObj *pDev = (CYaoCeObj *)objAry[i];
7521
			BOOL bDisp = FALSE;
7522

    
7523
			if (pDev->GetTypeID() == 0)
7524
			{
7525
				code = pDev->GetYCCode();
7526

    
7527
				if (code == "")
7528
				{
7529
					m_aiAry2.Add(pDev);
7530
					continue;
7531
				}
7532

    
7533
				int val;
7534
				if (!objMap.Lookup(code, val))
7535
				{
7536
					m_aiAry.Add(pDev);
7537
					bDisp = TRUE;
7538
				}
7539
			}
7540

    
7541
			if (bTip && bDisp)
7542
			{
7543
				CFRect fRect = pDev->GetObjectRect();
7544

    
7545
				CRect rc;
7546
				m_GraphGUI.MapToClient(&fRect, &rc);
7547
				ClientToScreen(rc);
7548
				CPoint point = rc.CenterPoint();
7549

    
7550
				CXInfoTip *pTip = new CXInfoTip();
7551
				pTip->Create(this,GetTipFrameColor(),GetTipTextColor());
7552
				pTip->EnableTimer(FALSE);
7553
				pTip->Show(code, &point);
7554

    
7555
				m_tipAry.Add(pTip);
7556
			}
7557
		}
7558

    
7559
		// ??ȵ?????Դ???
7560
		objMap.RemoveAll();
7561

    
7562
		sql = "select t.f4014_pointcode from semodel.tb4014_accpoint t where t.f4014_pointcode in (";
7563

    
7564
		for (i=0; i < objAry.GetSize(); i++)
7565
		{
7566
			CYaoCeObj *pDev = (CYaoCeObj *)objAry[i];
7567

    
7568
			if (pDev->GetTypeID() == 1)
7569
			{
7570
				code.Format("'%s', ", pDev->GetYCCode());
7571
				sql += code;
7572
			}
7573

    
7574
			if (i + 1 == objAry.GetSize() || sql.GetLength() >= SE_SQLSTR_MAXLEN / 2)
7575
			{
7576
				sql += "'')";
7577

    
7578
				dbo.BeginSelectRcdSet(sql.GetBuffer(0));
7579

    
7580
				int count = dbo.GetRcdCount();
7581
				for (int j=0; j < count; j++)
7582
				{
7583
					objMap[dbo.GetStringVal(j, 0)] = 1;
7584
				}
7585

    
7586
				dbo.EndSelectRcdSet();
7587

    
7588
				sql = "select t.f4014_pointcode from semodel.tb4014_accpoint t where t.f4014_pointcode in (";
7589
			}
7590
		}
7591

    
7592
		for (i=0; i < objAry.GetSize(); i++)
7593
		{
7594
			CYaoCeObj *pDev = (CYaoCeObj *)objAry[i];
7595
			BOOL bDisp = FALSE;
7596

    
7597
			if (pDev->GetTypeID() == 1)
7598
			{
7599
				code = pDev->GetYCCode();
7600

    
7601
				if (code == "")
7602
				{
7603
					m_aiAry2.Add(pDev);
7604
					continue;
7605
				}
7606

    
7607
				int val;
7608
				if (!objMap.Lookup(code, val))
7609
				{
7610
					m_aiAry.Add(pDev);
7611
					bDisp = TRUE;
7612
				}
7613
			}
7614

    
7615
			if (bTip && bDisp)
7616
			{
7617
				CFRect fRect = pDev->GetObjectRect();
7618

    
7619
				CRect rc;
7620
				m_GraphGUI.MapToClient(&fRect, &rc);
7621
				ClientToScreen(rc);
7622
				CPoint point = rc.CenterPoint();
7623

    
7624
				CXInfoTip *pTip = new CXInfoTip();
7625
				pTip->Create(this,GetTipFrameColor(),GetTipTextColor());
7626
				pTip->EnableTimer(FALSE);
7627
				pTip->Show(code, &point);
7628

    
7629
				m_tipAry.Add(pTip);
7630
			}
7631
		}
7632

    
7633
		m_flash = TRUE;
7634
	}
7635
	else
7636
	{
7637
		CVGRegion region;
7638
		int i = 0;
7639
		for ( i=0; i < m_objAry.GetSize(); i++)
7640
		{
7641
			CPointDevice *pDev = (CPointDevice *)m_objAry[i];
7642
			pDev->SetUserControl(FALSE);
7643
			region.Add(pDev);
7644
		}
7645

    
7646
		for (i=0; i < m_objAry2.GetSize(); i++)
7647
		{
7648
			CPointDevice *pDev = (CPointDevice *)m_objAry2[i];
7649
			pDev->SetUserControl(FALSE);
7650
			region.Add(pDev);
7651
		}
7652

    
7653
		for (i=0; i < m_aiAry.GetSize(); i++)
7654
		{
7655
			CYaoCeObj *pDev = (CYaoCeObj *)m_aiAry[i];
7656
			pDev->SetUserColor(FALSE);
7657
			region.Add(pDev);
7658
		}
7659

    
7660
		for (i=0; i < m_aiAry2.GetSize(); i++)
7661
		{
7662
			CYaoCeObj *pDev = (CYaoCeObj *)m_aiAry2[i];
7663
			pDev->SetUserColor(FALSE);
7664
			region.Add(pDev);
7665
		}
7666

    
7667
		if (m_objAry.GetSize() == 0 && m_objAry2.GetSize() == 0 &&
7668
			m_aiAry. GetSize() == 0 && m_aiAry2. GetSize() == 0)
7669
			region.Add(CFRect(0, 0, 1, 1));
7670

    
7671
		if (region.GetRectCount() > 0)
7672
			m_map.RefreshRegion(region, &m_GraphGUI);
7673

    
7674
		FreeObjAry();
7675
	}
7676
}
7677

    
7678
void CGWnd::GetAllObjects(OBJECT_SHAPE shape, CBaseObjArray &objAry)
7679
{
7680
	CEasyList *pLayList = m_map.GetAllFeatureLayers();
7681

    
7682
	for (int i=0; i < pLayList->GetListLen(); i++)
7683
	{
7684
		CFeatureLayer *pFLayer = (CFeatureLayer *)pLayList->GetNth(i);
7685
		if (pFLayer->IsClosed())
7686
			continue;
7687

    
7688
		CEasyList *pObjLst = pFLayer->GetObjects();
7689
		if (pObjLst == NULL)
7690
			continue;
7691

    
7692
		for (int j=0; j < pObjLst->GetListLen(); j++)
7693
		{
7694
			CBaseObj *pObj = (CBaseObj *)pObjLst->GetNth(j);
7695

    
7696
			if (pObj && pObj->GetObjectShape() == shape)
7697
			{
7698
				objAry.Add(pObj);
7699
			}
7700
		}
7701
	}
7702
}
7703

    
7704
void CGWnd::UpdateDataSrc()
7705
{
7706
	CVGRegion region;
7707

    
7708
	int i = 0;
7709
	for ( i=0; i < m_objAry.GetSize(); i++)
7710
	{
7711
		CPointDevice *pDev = (CPointDevice *)m_objAry[i];
7712

    
7713
		if (m_flash)
7714
			pDev->SetUserColor(RGB(255, 0, 0));
7715
		else
7716
			pDev->SetUserControl(FALSE);
7717

    
7718
		region.Add(pDev);
7719
	}
7720

    
7721
	for (i=0; i < m_objAry2.GetSize(); i++)
7722
	{
7723
		CPointDevice *pDev = (CPointDevice *)m_objAry2[i];
7724

    
7725
		if (m_flash)
7726
			pDev->SetUserColor(RGB(255, 255, 255));
7727
		else
7728
			pDev->SetUserControl(FALSE);
7729

    
7730
		region.Add(pDev);
7731
	}
7732

    
7733
	for (i=0; i < m_aiAry.GetSize(); i++)
7734
	{
7735
		CYaoCeObj *pDev = (CYaoCeObj *)m_aiAry[i];
7736

    
7737
		if (m_flash)
7738
			pDev->SetUserColor(TRUE, RGB(255, 0, 0));
7739
		else
7740
			pDev->SetUserColor(FALSE);
7741

    
7742
		region.Add(pDev);
7743
	}
7744

    
7745
	for (i=0; i < m_aiAry2.GetSize(); i++)
7746
	{
7747
		CYaoCeObj *pDev = (CYaoCeObj *)m_aiAry2[i];
7748

    
7749
		if (m_flash)
7750
			pDev->SetUserColor(TRUE, RGB(255, 255, 255));
7751
		else
7752
			pDev->SetUserColor(FALSE);
7753

    
7754
		region.Add(pDev);
7755
	}
7756

    
7757
	if (m_objAry.GetSize() == 0 && m_objAry2.GetSize() == 0 &&
7758
		m_aiAry. GetSize() == 0 && m_aiAry2. GetSize() == 0)
7759
		region.Add(CFRect(0, 0, 1, 1));
7760

    
7761
	if (region.GetRectCount() > 0)
7762
		m_map.RefreshRegion(region, &m_GraphGUI);
7763

    
7764
	if (m_flash)
7765
		m_tip = "??ǰ????????Դ??????״̬??";
7766
	else
7767
		m_tip.Format("DI???????%d????δ???壺%d???? AI???????%d????δ???壺%d????",
7768
		m_objAry.GetSize(), m_objAry2.GetSize(),
7769
		m_aiAry.GetSize(), m_aiAry2.GetSize());
7770

    
7771
	m_flash = !m_flash;
7772
}
7773

    
7774
void CGWnd::TrimString(CString &str, const char *s, int len)
7775
{
7776
	str = "";
7777
	for (int i=0; i < len; i++)
7778
	{
7779
		if (isascii(s[i]) && isspace(s[i]))
7780
			continue;
7781
		if (s[i] == '\r' || s[i] == '\n')
7782
		{
7783
			int n = 0;
7784
		}
7785
		str += s[i];
7786
	}
7787
}
7788

    
7789
void CGWnd::FreeObjAry()
7790
{
7791
	for (int i=0; i < m_tipAry.GetSize(); i++)
7792
	{
7793
		CXInfoTip *pTip = (CXInfoTip *)m_tipAry[i];
7794
		pTip->DestroyWindow();
7795
		delete pTip;
7796
	}
7797

    
7798
	m_objAry. RemoveAll();
7799
	m_objAry2.RemoveAll();
7800
	m_aiAry.  RemoveAll();
7801
	m_aiAry2. RemoveAll();
7802
	m_tipAry. RemoveAll();
7803
}
7804

    
7805
///////////////////////
7806
//Add by Yansx 2019-05-06 ??????ʾ??ʱ??,Ĭ?ϵ?PrintBox????λ???д???,
7807
//ͨ???ӹ??ӵķ?ʽ???޸?ϵͳ??ӡ?Ի???ĵ???λ??
7808
bool bPrintBoxShow1 = false;
7809
HHOOK hPrintBoxHook1; 
7810
LRESULT CALLBACK CBTProc2(int nCode, WPARAM wParam, LPARAM lParam) 
7811
{ 	
7812
	if(nCode < 0) 
7813
	{
7814
		return CallNextHookEx(hPrintBoxHook1, nCode, wParam, lParam); 
7815
	}
7816
	
7817
	switch(nCode) 
7818
	{ 
7819
	case HCBT_ACTIVATE: 
7820
		// customize the MessageBox
7821
		if(bPrintBoxShow1)
7822
		{
7823
			HWND hWnd = (HWND)wParam;//PrintBox handle
7824
			RECT rect;
7825
			HDC hDC =  ::GetDC(HWND(NULL));//??ȡ??????Ļ?Ĵ?С,????Ĭ??ÿ???????Ĵ?С????һ????
7826
			rect.left = 0;
7827
			rect.top = 0;
7828
			rect.right  =  ::GetDeviceCaps(hDC,HORZRES);
7829
			rect.bottom  =  ::GetDeviceCaps(hDC,VERTRES);
7830
			::ReleaseDC(HWND(NULL),hDC);
7831
			
7832
			int nOffset = 0;//Ĭ??????ڵ?һ????Ļ
7833
			POINT p;
7834
			GetCursorPos(&p);//??ȡ??굱ǰ????(???????Ļ???Ͻ?)
7835
			int nScrrenWidth = rect.right;
7836
			nOffset = (p.x+nScrrenWidth-1)/nScrrenWidth-1;
7837
			
7838
			int nMsgBoxXPoint;
7839
			int nMsgBoxYPoint = rect.bottom/2-(430/2);//Ҫ??ȥ?Ի????һ??߶?  ϵͳ??ӡ?Ի??? 610*430
7840
			nMsgBoxYPoint= nMsgBoxYPoint <=0 ? 0 : nMsgBoxYPoint;
7841
			
7842
			float fMiddle = (float)(nScrrenWidth/2.0-(610/2));//Ҫ??ȥ?Ի????һ?????  
7843
			nMsgBoxXPoint = nScrrenWidth*nOffset + (int)fMiddle;    
7844
			nMsgBoxXPoint= nMsgBoxXPoint <=0 ? 0 : nMsgBoxXPoint;
7845
			SetWindowPos(hWnd,HWND_TOP,nMsgBoxXPoint, nMsgBoxYPoint,0,0,SWP_NOSIZE);
7846
			bPrintBoxShow1 = false;
7847
			return 0; 		
7848
		}
7849
	} 	
7850
	return CallNextHookEx(hPrintBoxHook1, nCode, wParam, lParam); 
7851
} 
7852

    
7853
void CGWnd::OnBtnPrint(UINT nPrintType)
7854
{
7855
	HINSTANCE hInstance = (HINSTANCE)::GetWindowLong(m_hWnd,GWL_HINSTANCE);
7856
	bPrintBoxShow1 = true;
7857
	// Install a window hook, so we can intercept the system print-box  
7858
	hPrintBoxHook1 = SetWindowsHookEx( 
7859
		WH_CBT, 
7860
		CBTProc2, 
7861
		hInstance, 
7862
		GetCurrentThreadId()   // Only install for THIS thread!!! 
7863
		); 
7864
	
7865
	
7866
	AfxGetApp()->OnCmdMsg(nPrintType, 0, NULL, NULL);
7867
	
7868
	// remove the window hook 
7869
	UnhookWindowsHookEx(hPrintBoxHook1); 
7870
}
7871

    
7872
COLORREF CGWnd::GetTipFrameColor()
7873
{
7874
	char str[MAX_PATH];
7875
	int r, g, b;
7876
				
7877
	GetPrivateProfileString("????????", "Tip?߿???ɫ",
7878
		"255,255,255", str, MAX_PATH, g_ehmiMainFrame->GetCfgPath());
7879
				
7880
	sscanf(str, "%d,%d,%d", &r, &g, &b);
7881
	return RGB(r, g, b);
7882
}
7883

    
7884
COLORREF CGWnd::GetTipTextColor()
7885
{
7886
	char str[MAX_PATH];
7887
	int r, g, b;
7888
				
7889
	GetPrivateProfileString("????????", "Tip??????ɫ",
7890
		"0,0,0", str, MAX_PATH, g_ehmiMainFrame->GetCfgPath());
7891
				
7892
	sscanf(str, "%d,%d,%d", &r, &g, &b);
7893
	return RGB(r, g, b);
7894
}
(8-8/9)