MainView.cpp
上传用户:lvjun8202
上传日期:2013-04-30
资源大小:797k
文件大小:7k
- // MainView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "oam.h"
- #include "MainView.h"
- #include "MainFrm.h"
- //#include "cmdTreeSetup.h"
- #include "GlobalVariable.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMainView
- IMPLEMENT_DYNCREATE(CMainView, CFormView)
- CMainView::CMainView()
- : CFormView(CMainView::IDD)
- {
- //{{AFX_DATA_INIT(CMainView)
- m_IP = _T("");
- //}}AFX_DATA_INIT
- /* id[12][4]={{IDC_00,IDC_01,IDC_02,IDC_BOARD1},{IDC_10,IDC_11,IDC_12,IDC_BOARD2},
- {IDC_20,IDC_21,IDC_22,IDC_BOARD3},
- {IDC_30,IDC_31,IDC_32,IDC_BOARD4},
- {IDC_40,IDC_41,IDC_42,IDC_BOARD5},
- {IDC_50,IDC_51,IDC_52,IDC_BOARD6},
- {IDC_60,IDC_61,IDC_62,IDC_BOARD7},
- {IDC_70,IDC_71,IDC_72,IDC_BOARD8},
- {IDC_80,IDC_81,IDC_82,IDC_BOARD9},
- {IDC_90,IDC_91,IDC_92,IDC_BOARD10},
- {IDC_100,IDC_101,IDC_102,IDC_BOARD11},
- {IDC_110,IDC_111,IDC_112,IDC_BOARD12}};*/
- /*将各个板中对应的id保存*/
- //
- id[0][0]=IDC_00;id[0][1]=IDC_01;id[0][2]=IDC_02;id[0][3]=IDC_BOARD1;
- id[1][0]=IDC_10;id[1][1]=IDC_11;id[1][2]=IDC_12;id[1][3]=IDC_BOARD2;
- id[2][0]=IDC_20;id[2][1]=IDC_21;id[2][2]=IDC_22;id[2][3]=IDC_BOARD3;
- id[3][0]=IDC_30;id[3][1]=IDC_31;id[3][2]=IDC_32;id[3][3]=IDC_BOARD4;
- id[4][0]=IDC_40;id[4][1]=IDC_41;id[4][2]=IDC_42;id[4][3]=IDC_BOARD5;
- id[5][0]=IDC_50;id[5][1]=IDC_51;id[5][2]=IDC_52;id[5][3]=IDC_BOARD6;
- id[6][0]=IDC_60;id[6][1]=IDC_61;id[6][2]=IDC_62;id[6][3]=IDC_BOARD7;
- id[7][0]=IDC_70;id[7][1]=IDC_71;id[7][2]=IDC_72;id[7][3]=IDC_BOARD8;
- id[8][0]=IDC_80;id[8][1]=IDC_81;id[8][2]=IDC_82;id[8][3]=IDC_BOARD9;
- id[9][0]=IDC_90;id[9][1]=IDC_91;id[9][2]=IDC_92;id[9][3]=IDC_BOARD10;
- id[10][0]=IDC_100;id[10][1]=IDC_101;id[10][2]=IDC_102;id[10][3]=IDC_BOARD11;
- id[11][0]=IDC_110;id[11][1]=IDC_111;id[11][2]=IDC_112;id[11][3]=IDC_BOARD12;
- id[12][0]=IDC_120;id[12][1]=IDC_121;id[12][2]=IDC_122;id[12][3]=IDC_BOARD13;
- id[13][0]=IDC_130;id[13][1]=IDC_131;id[13][2]=IDC_132;id[13][3]=IDC_BOARD14;
- id[14][0]=IDC_140;id[14][1]=IDC_141;id[14][2]=IDC_142;id[14][3]=IDC_BOARD15;
- id[15][0]=IDC_150;id[15][1]=IDC_151;id[15][2]=IDC_152;id[15][3]=IDC_BOARD16;
-
-
-
- }
- CMainView::~CMainView()
- {
- }
- void CMainView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CMainView)
- DDX_Control(pDX, IDC_NEWIP, m_cIP);
- DDX_Text(pDX, IDC_NEWIP, m_IP);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CMainView, CFormView)
- //{{AFX_MSG_MAP(CMainView)
- ON_BN_CLICKED(IDC_CLICK, OnClick)
- ON_BN_CLICKED(IDC_REFRESH, OnRefresh)
- ON_WM_TIMER()
- ON_EN_CHANGE(IDC_NEWIP, OnChangeNewip)
- ON_WM_SIZE()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMainView diagnostics
- #ifdef _DEBUG
- void CMainView::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void CMainView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMainView message handlers
- BOOL CMainView::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
- {
-
-
- return CFormView::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
- }
- void CMainView::OnDraw(CDC* pDC)
- {
- // SetTimer(1, 15000, NULL);/*设置定时器*/
- CWnd* pStatic = GetDlgItem(IDC_IP);
- pStatic->SetWindowText(CGlobalVariable::m_pMainFrame->m_agent);
-
- // GetStatus(CGlobalVariable::m_pMainFrame->test);
-
-
- }
- void CMainView::GetStatus(int status[16][4])
- {
- /****************************************/
- CRect rect;
- CBrush brush2((RGB(255,0,0)));
- CBrush brush1((RGB(255,255,0)));
- CBrush brush3((RGB(192,192,192)));
- CBrush brush;
- CWnd* pStatic;
-
- int i,j;
- for(i=0;i<16;i++)
- {
- if (status[i][3]==1)//表示不在位
- {
- pStatic = GetDlgItem(id[i][3]);
- pStatic->GetWindowRect(&rect);
- pStatic->ScreenToClient(&rect);
- brush.CreateStockObject(GRAY_BRUSH);
- ResizeFill(rect,0);
- pStatic->GetDC ()->FillRect(rect, &brush);
- }
- else
- {
- pStatic = GetDlgItem(id[i][3]);
- pStatic->GetWindowRect(&rect);
- pStatic->ScreenToClient(&rect);
- ResizeFill(rect,0);
- pStatic->GetDC ()->FillRect(rect, &brush3);
- for (j=0;j<3;j++)
- {
- pStatic = GetDlgItem(id[i][j]);
- pStatic->GetWindowRect(&rect);
- pStatic->ScreenToClient(&rect);
- ResizeFill(rect,1);
- if (status[i][j]==0)
- pStatic->GetDC ()->FillRect(rect, &brush1);
- else
- pStatic->GetDC ()->FillRect(rect, &brush2);
- }// end for 2
- }// end else
- }// end for1
- /****************************************/
-
- /*判断电源的状态*/
- pStatic = GetDlgItem(IDC_POWER1);
- pStatic->GetWindowRect(&rect);
- pStatic->ScreenToClient(&rect);
- ResizeFill(rect,1);
- if (power[0]==1)
- pStatic->GetDC ()->FillRect(rect, &brush1);
- else
- pStatic->GetDC ()->FillRect(rect, &brush2);
- pStatic = GetDlgItem(IDC_POWER2);
- pStatic->GetWindowRect(&rect);
- pStatic->ScreenToClient(&rect);
- ResizeFill(rect,1);
- if (power[1]==1)
- pStatic->GetDC ()->FillRect(rect, &brush1);
- else
- pStatic->GetDC ()->FillRect(rect, &brush2);
- }
- void CMainView::OnRefresh()
- {
-
- CString str1;
- str1="1.3.6.1.4.1.26.5.1.5.1";
- CGlobalVariable::m_pMainFrame->Start(5);
- int i;
- for(i=0;i<20000;i++)
- ;
- // GetStatus(CGlobalVariable::m_pMainFrame->test);
-
- this->UpdateWindow();
- this->PostMessage(WM_SIZE);
- GetStatus(CGlobalVariable::m_pMainFrame->test);
-
- }
- void CMainView::OnClick()
- {
- // TODO: Add your control notification handler code here
- GetStatus(CGlobalVariable::m_pMainFrame->test);
- }
- void CMainView::ResizeFill(CRect& rect,int flag)
- {
- if (flag==0)
- {
- rect.left+=2;
- rect.right-=4;
- rect.top+=4;
- rect.bottom-=4;
- }
- else
- {
- rect.left+=0.25;
- rect.right-=0.5;
- rect.top+=0.5;
- rect.bottom-=0.5;
- }
- }
- void CMainView::OnTimer(UINT nIDEvent)
- {
- CFormView::OnTimer(nIDEvent);
- CGlobalVariable::m_pMainFrame->m_wndReportBar.WriteReportLine("----定时器-----", 0);
- OnRefresh();
- // CFormView::OnTimer(nIDEvent);
- }
- void CMainView::OnChangeNewip()
- {
- // TODO: If this is a RICHEDIT control, the control will not
- // send this notification unless you override the CFormView::OnInitDialog()
- // function and call CRichEditCtrl().SetEventMask()
- // with the ENM_CHANGE flag ORed into the mask.
-
- // TODO: Add your control notification handler code here
- UpdateData(TRUE);
-
- }