www.pudn.com > PressMonitor_q.zip > MonitorView.cpp


// MonitorView.cpp : implementation of the CMonitorView class 
// 
 
#include "stdafx.h" 
#include "Monitor.h" 
 
#include "MonitorDoc.h" 
#include "MonitorView.h" 
#include "Hint.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
///////////////////////////////////////////////////////////////////////////// 
// CMonitorView 
 
IMPLEMENT_DYNCREATE(CMonitorView, CFormView) 
 
BEGIN_MESSAGE_MAP(CMonitorView, CFormView) 
	//{{AFX_MSG_MAP(CMonitorView) 
		// NOTE - the ClassWizard will add and remove mapping macros here. 
		//    DO NOT EDIT what you see in these blocks of generated code! 
	//}}AFX_MSG_MAP 
	// Standard printing commands 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CMonitorView construction/destruction 
 
CMonitorView::CMonitorView() 
	: CFormView(CMonitorView::IDD) 
{ 
	//{{AFX_DATA_INIT(CMonitorView) 
	//}}AFX_DATA_INIT 
	// TODO: add construction code here 
 
} 
 
CMonitorView::~CMonitorView() 
{ 
} 
 
void CMonitorView::DoDataExchange(CDataExchange* pDX) 
{ 
	CFormView::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CMonitorView) 
	DDX_Control(pDX, IDC_STATICMETER6, m_3DMeter6); 
	DDX_Control(pDX, IDC_STATICMETER5, m_3DTemp1); 
	DDX_Control(pDX, IDC_SLIDER2, m_3DSlider2); 
	DDX_Control(pDX, IDC_STATICMETER4, m_3DMeter4); 
	DDX_Control(pDX, IDC_STATICMETER3, m_3DMeter3); 
	DDX_Control(pDX, IDC_STATICMETER2, m_3DMeter2); 
	DDX_Control(pDX, IDC_STATICMETER1, m_3DMeter1); 
	DDX_Control(pDX, IDC_SLIDER1, m_3DSlider1); 
	DDX_Control(pDX, IDC_BARCHART, m_3DBarCtrl); 
	//}}AFX_DATA_MAP 
} 
 
BOOL CMonitorView::PreCreateWindow(CREATESTRUCT& cs) 
{ 
	// TODO: Modify the Window class or styles here by modifying 
	//  the CREATESTRUCT cs 
 
	return CFormView::PreCreateWindow(cs); 
} 
 
void CMonitorView::OnInitialUpdate() 
{ 
	CFormView::OnInitialUpdate(); 
//	GetParentFrame()->RecalcLayout(); 
//	ResizeParentToFit(); 
	CMonitorDoc	*pDoc = (CMonitorDoc*) GetDocument(); 
	pDoc->m_bUpdateView=true; 
 
	if(!m_3DMeter1.Initialize()) 
		return ; 
	if(!m_3DMeter2.Initialize()) 
		return ; 
	if(!m_3DMeter3.Initialize()) 
		return ; 
	if(!m_3DMeter4.Initialize()) 
		return ; 
	m_3DTemp1.SetBackground(IDB_BITMAP_TEMP01); 
	m_3DTemp1.SetRange(1600,600); 
 
	if(!m_3DMeter6.Initialize()) 
		return ; 
 
	m_3DMeter4.SetRange(0,1); 
	m_3DMeter4.SetScaleDecimals(1); 
	m_3DMeter4.SetValueDecimals(2); 
 
	m_3DMeter6.SetRange(0,100); 
	CString strUnits; 
	strUnits.Format("¡æ"); 
	m_3DMeter6.SetUnits(strUnits); 
	 
    if(!m_3DSlider1.Initialize()) 
        return ; 
    if(!m_3DSlider2.Initialize()) 
        return ; 
 
    if(!m_3DBarCtrl.Initialize()) 
        return ; 
 
//	UpdateControl(); 
 
} 
 
///////////////////////////////////////////////////////////////////////////// 
// CMonitorView printing 
 
 
///////////////////////////////////////////////////////////////////////////// 
// CMonitorView diagnostics 
 
#ifdef _DEBUG 
void CMonitorView::AssertValid() const 
{ 
	CFormView::AssertValid(); 
} 
 
void CMonitorView::Dump(CDumpContext& dc) const 
{ 
	CFormView::Dump(dc); 
} 
 
CMonitorDoc* CMonitorView::GetDocument() // non-debug version is inline 
{ 
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMonitorDoc))); 
	return (CMonitorDoc*)m_pDocument; 
} 
 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CMonitorView message handlers 
 
void CMonitorView::UpdateControl() 
{ 
	CMonitorDoc* pDoc = (CMonitorDoc*)GetDocument(); 
	ASSERT_VALID(pDoc); 
	CMonitorDataReal* pDataReal=&pDoc->m_DataReal; 
	m_3DMeter1.UpdateNeedle(pDataReal->Data_Real[SYS_PRE]) ; 
	m_3DMeter2.UpdateNeedle(pDataReal->Data_Real[MAINCYLINDER_PRE]) ; 
	m_3DMeter3.UpdateNeedle(pDataReal->Data_Real[RETURNCYLINDER_PRE]) ; 
	m_3DMeter4.UpdateNeedle(pDataReal->Data_Real[KETTLE_PRE]) ; 
	m_3DTemp1.SetValue(pDataReal->Data_Real[FORGING_TEMP]); 
	m_3DMeter6.UpdateNeedle(pDataReal->Data_Real[KETTLE_TEMP]) ; 
 
    m_3DBarCtrl.SetItemValue(0,pDataReal->Data_Real[PUMP1_PRE]); 
    m_3DBarCtrl.SetItemValue(1,pDataReal->Data_Real[PUMP2_PRE]); 
    m_3DBarCtrl.SetItemValue(2,pDataReal->Data_Real[PUMP3_PRE]); 
    m_3DBarCtrl.SetItemValue(3,pDataReal->Data_Real[PUMP4_PRE]); 
    m_3DBarCtrl.SetItemValue(4,pDataReal->Data_Real[SYS_PRE]); 
    m_3DBarCtrl.SetItemValue(5,pDataReal->Data_Real[MAINCYLINDER_PRE]); 
    m_3DBarCtrl.SetItemValue(6,pDataReal->Data_Real[RETURNCYLINDER_PRE]); 
	m_3DBarCtrl.RefreshWindow(); 
 
	m_3DSlider1.SetValue(pDataReal->Data_Real[ROBOT_PEEL]); 
	m_3DSlider1.RefreshWindow(); 
	m_3DSlider2.SetValue(pDataReal->Data_Real[ROBOT2_PEEL]); 
	m_3DSlider2.RefreshWindow(); 
 
} 
 
void CMonitorView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)  
{ 
	switch(lHint) 
	{ 
	case HINT_DATA_RENEW: 
		UpdateControl(); 
		break; 
	} 
	 
}