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


// AllParaView.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "Monitor.h" 
#include "AllParaView.h" 
#include "MonitorDoc.h" 
#include "Hint.h" 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// CAllParaView 
 
IMPLEMENT_DYNCREATE(CAllParaView, CFormView) 
 
CAllParaView::CAllParaView() 
	: CFormView(CAllParaView::IDD) 
{ 
	//{{AFX_DATA_INIT(CAllParaView) 
		// NOTE: the ClassWizard will add member initialization here 
	//}}AFX_DATA_INIT 
} 
 
CAllParaView::~CAllParaView() 
{ 
} 
 
void CAllParaView::DoDataExchange(CDataExchange* pDX) 
{ 
	CFormView::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(CAllParaView) 
	DDX_Control(pDX, IDC_LIST_BINARY, m_ListCtrlBinary); 
	DDX_Control(pDX, IDC_LIST_TESTPRJ, m_ListCtrlTestprj); 
	DDX_Control(pDX, IDC_LIST_TEMP, m_ListCtrlTemp); 
	DDX_Control(pDX, IDC_LIST_ROTATE, m_ListCtrlRotate); 
	DDX_Control(pDX, IDC_LIST_PRESS, m_ListCtrlPress); 
	DDX_Control(pDX, IDC_LIST_MOVE, m_ListCtrlMove); 
	DDX_Control(pDX, IDC_LIST_AOUT, m_ListCtrlAout); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(CAllParaView, CFormView) 
	//{{AFX_MSG_MAP(CAllParaView) 
		// NOTE - the ClassWizard will add and remove mapping macros here. 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// CAllParaView diagnostics 
 
#ifdef _DEBUG 
void CAllParaView::AssertValid() const 
{ 
	CFormView::AssertValid(); 
} 
 
void CAllParaView::Dump(CDumpContext& dc) const 
{ 
	CFormView::Dump(dc); 
} 
#endif //_DEBUG 
 
///////////////////////////////////////////////////////////////////////////// 
// CAllParaView message handlers 
 
void CAllParaView::OnInitialUpdate()  
{ 
	CFormView::OnInitialUpdate(); 
 
	CMonitorDoc	*pDoc = (CMonitorDoc*) GetDocument(); 
	pDoc->m_bUpdateView=true; 
	 
//压力列表控件初始化 
	CRect Rect; 
	m_ListCtrlPress.GetWindowRect(Rect); 
	int cx = (Rect.Width()-4)/3; 
 
	DWORD dwStyle = ListView_GetExtendedListViewStyle(m_ListCtrlPress); 
	//Add the full row select and grid line style to the existing extended styles 
	 dwStyle |=  LVS_EX_GRIDLINES; 
 
	ListView_SetExtendedListViewStyle (m_ListCtrlPress,dwStyle); 
 
	m_ListCtrlPress.InsertColumn(0, "压力", LVCFMT_LEFT, Rect.Width()-4-cx); 
	m_ListCtrlPress.InsertColumn(1, "压力值(MPa)", LVCFMT_CENTER, cx); 
 
 
	CString strPress[8]; 
	CString strValue; 
	strValue.Format("%3.1f", 0); 
 
	strPress[0] = "1#主泵压力实际值"; 
	strPress[1] = "2#主泵压力实际值"; 
	strPress[2] = "3#主泵压力实际值"; 
	strPress[3] = "4#主泵压力实际值"; 
	strPress[4] = "主系统压力实际值"; 
	strPress[5] = "充液罐压力实际值"; 
	strPress[6] = "回程缸压力实际值"; 
	strPress[7] = "主缸压力实际值"; 
 
	for(int iItem = 0;iItem<8;	iItem++) 
	{ 
		m_ListCtrlPress.InsertItem(iItem, LPSTR_TEXTCALLBACK);     
		m_ListCtrlPress.SetItemText(iItem, 0, strPress[iItem]); 
		m_ListCtrlPress.SetItemText(iItem, 1, strValue); 
	} 
//位移列表控件初始化 
	m_ListCtrlMove.GetWindowRect(Rect); 
	cx = (Rect.Width()-4)/3; 
 
	dwStyle = ListView_GetExtendedListViewStyle(m_ListCtrlMove); 
	//Add the full row select and grid line style to the existing extended styles 
	 dwStyle |=  LVS_EX_GRIDLINES; 
 
	ListView_SetExtendedListViewStyle (m_ListCtrlMove,dwStyle); 
 
	m_ListCtrlMove.InsertColumn(0, "位移", LVCFMT_LEFT, Rect.Width()-4-cx); 
	m_ListCtrlMove.InsertColumn(1, "位移值(mm)", LVCFMT_CENTER, cx); 
 
 
	CString strMove[5]; 
 
	strMove[0] = "压机实际位移"; 
	strMove[1] = "操作机Ⅰ大车行走实际位移"; 
	strMove[2] = "操作机Ⅱ大车行走实际位移"; 
	strMove[3] = "操作机Ⅰ钳杆侧移实际值"; 
	strMove[4] = "操作机Ⅱ钳杆侧移实际值"; 
 
	for(iItem = 0;iItem<5;	iItem++) 
	{ 
		m_ListCtrlMove.InsertItem(iItem, LPSTR_TEXTCALLBACK);     
		m_ListCtrlMove.SetItemText(iItem, 0, strMove[iItem]); 
		m_ListCtrlMove.SetItemText(iItem, 1, strValue); 
	} 
//角度列表控件初始化 
	m_ListCtrlRotate.GetWindowRect(Rect); 
	cx = (Rect.Width()-4)/3; 
 
	dwStyle = ListView_GetExtendedListViewStyle(m_ListCtrlRotate); 
	//Add the full row select and grid line style to the existing extended styles 
	 dwStyle |=  LVS_EX_GRIDLINES; 
 
	ListView_SetExtendedListViewStyle (m_ListCtrlRotate,dwStyle); 
 
	m_ListCtrlRotate.InsertColumn(0, "旋转角度", LVCFMT_LEFT, Rect.Width()-4-cx); 
	m_ListCtrlRotate.InsertColumn(1, "旋转角度值(°)", LVCFMT_CENTER, cx); 
 
 
	CString strRotate[2]; 
 
	strRotate[0] = "操作机Ⅰ夹钳旋转实际角度"; 
	strRotate[1] = "操作机Ⅱ夹钳旋转实际角度"; 
 
	for(iItem = 0;iItem<2;	iItem++) 
	{ 
		m_ListCtrlRotate.InsertItem(iItem, LPSTR_TEXTCALLBACK);     
		m_ListCtrlRotate.SetItemText(iItem, 0, strRotate[iItem]); 
		m_ListCtrlRotate.SetItemText(iItem, 1, strValue); 
	} 
//温度列表控件初始化 
	m_ListCtrlTemp.GetWindowRect(Rect); 
	cx = (Rect.Width()-4)/3; 
 
	dwStyle = ListView_GetExtendedListViewStyle(m_ListCtrlTemp); 
	//Add the full row select and grid line style to the existing extended styles 
	 dwStyle |=  LVS_EX_GRIDLINES; 
 
	ListView_SetExtendedListViewStyle (m_ListCtrlTemp,dwStyle); 
 
	m_ListCtrlTemp.InsertColumn(0, "温度", LVCFMT_LEFT, Rect.Width()-4-cx); 
	m_ListCtrlTemp.InsertColumn(1, "温度值(℃)", LVCFMT_CENTER, cx); 
 
 
	CString strTemp[2]; 
 
	strTemp[0] = "充液罐温度实际值"; 
	strTemp[1] = "锻件温度实际值"; 
 
	for(iItem = 0;iItem<2;	iItem++) 
	{ 
		m_ListCtrlTemp.InsertItem(iItem, LPSTR_TEXTCALLBACK);     
		m_ListCtrlTemp.SetItemText(iItem, 0, strTemp[iItem]); 
		m_ListCtrlTemp.SetItemText(iItem, 1, strValue); 
	} 
//模拟量输出列表控件初始化 
	m_ListCtrlPress.GetWindowRect(Rect); 
	cx = Rect.Width()/3; 
 
	dwStyle = ListView_GetExtendedListViewStyle(m_ListCtrlAout); 
	//Add the full row select and grid line style to the existing extended styles 
	 dwStyle |=  LVS_EX_GRIDLINES; 
 
	ListView_SetExtendedListViewStyle (m_ListCtrlAout,dwStyle); 
 
	m_ListCtrlAout.InsertColumn(0, "模拟量输出", LVCFMT_LEFT, Rect.Width()-cx-4); 
	m_ListCtrlAout.InsertColumn(1, "输出值(V)", LVCFMT_CENTER, cx); 
 
 
	CString strAout[7]; 
	strValue.Format("%d", 0); 
 
	strAout[0] = "压机比例阀A-Ya2输出"; 
	strAout[1] = "压机比例阀A-Ya3输出"; 
	strAout[2] = "压机比例阀A-Ya6输出"; 
	strAout[3] = "操作机Ⅰ旋转比例阀C-Ya9输出"; 
	strAout[4] = "操作机Ⅰ行走比例阀C-Ya10输出"; 
	strAout[5] = "操作机Ⅱ旋转比例阀D-Ya9输出"; 
	strAout[6] = "操作机Ⅱ行走比例阀D-Ya10输出"; 
 
	for(iItem = 0;iItem<7;	iItem++) 
	{ 
		m_ListCtrlAout.InsertItem(iItem, LPSTR_TEXTCALLBACK);     
		m_ListCtrlAout.SetItemText(iItem, 0, strAout[iItem]); 
		m_ListCtrlAout.SetItemText(iItem, 1, strValue); 
	} 
 
//二进制显示项目 
	m_ListCtrlBinary.GetWindowRect(Rect); 
	cx = Rect.Width()*2/3-8; 
	 
	dwStyle = ListView_GetExtendedListViewStyle(m_ListCtrlBinary); 
	//Add the full row select and grid line style to the existing extended styles 
	dwStyle |=  LVS_EX_GRIDLINES; 
	 
	ListView_SetExtendedListViewStyle (m_ListCtrlBinary,dwStyle); 
	 
	m_ListCtrlBinary.InsertColumn(0, "开关量及各状态", LVCFMT_LEFT, Rect.Width()-4-cx); 
	m_ListCtrlBinary.InsertColumn(1, "显示值", LVCFMT_CENTER, cx); 
	 
	 
	CString strBinary[6]; 
	 
	strBinary[0] = "开关量输入值"; 
	strBinary[1] = "开关量输出值"; 
	strBinary[2] = "从PLC来的状态"; 
	strBinary[3] = "到PLC的速度指示"; 
	strBinary[4] = "到PLC的状态指示"; 
	 
	for(iItem = 0;iItem<5;	iItem++) 
	{ 
		m_ListCtrlBinary.InsertItem(iItem, LPSTR_TEXTCALLBACK);     
		m_ListCtrlBinary.SetItemText(iItem, 0, strBinary[iItem]); 
	} 
 
//其他测试项目 
	m_ListCtrlTestprj.GetWindowRect(Rect); 
	cx = Rect.Width()/3; 
	 
	dwStyle = ListView_GetExtendedListViewStyle(m_ListCtrlTestprj); 
	//Add the full row select and grid line style to the existing extended styles 
	dwStyle |=  LVS_EX_GRIDLINES; 
	 
	ListView_SetExtendedListViewStyle (m_ListCtrlTestprj,dwStyle); 
	 
	m_ListCtrlTestprj.InsertColumn(0, "其它测试项目", LVCFMT_LEFT, Rect.Width()-4-cx); 
	m_ListCtrlTestprj.InsertColumn(1, "测试值", LVCFMT_CENTER, cx); 
	 
	 
	CString strTestprj[7]; 
	 
	strTestprj[0] = "压机显示位置(mm)"; 
	strTestprj[1] = "压机测试速度(mm/s)"; 
	strTestprj[2] = "压机测试频次(Hz)"; 
	strTestprj[3] = "大车Ⅰ行走速度(m/s)"; 
	strTestprj[4] = "夹钳Ⅰ旋转速度(转/分)"; 
	strTestprj[5] = "大车Ⅱ行走速度(m/s)"; 
	strTestprj[6] = "夹钳Ⅱ旋转速度(转/分)"; 
	 
	for(iItem = 0;iItem<7;	iItem++) 
	{ 
		m_ListCtrlTestprj.InsertItem(iItem, LPSTR_TEXTCALLBACK);     
		m_ListCtrlTestprj.SetItemText(iItem, 0, strTestprj[iItem]); 
	}	 
} 
 
void CAllParaView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)  
{ 
	switch(lHint) 
	{ 
	case HINT_DATA_RENEW: 
		UpdateControl(); 
		break; 
	}		 
	 
} 
 
void CAllParaView::UpdateControl() 
{ 
	CMonitorDoc* pDoc = (CMonitorDoc*)GetDocument(); 
	ASSERT_VALID(pDoc); 
	CMonitorDataReal* pDataReal=&pDoc->m_DataReal; 
 
	CString strPressValue[8]; 
 
	strPressValue[0].Format("%3.1f", pDataReal->Data_Real[PUMP1_PRE]); 
	strPressValue[1].Format("%3.1f", pDataReal->Data_Real[PUMP2_PRE]); 
	strPressValue[2].Format("%3.1f", pDataReal->Data_Real[PUMP3_PRE]); 
	strPressValue[3].Format("%3.1f", pDataReal->Data_Real[PUMP4_PRE]); 
	strPressValue[4].Format("%3.1f", pDataReal->Data_Real[SYS_PRE]); 
	strPressValue[5].Format("%3.1f", pDataReal->Data_Real[KETTLE_PRE]); 
	strPressValue[6].Format("%3.1f", pDataReal->Data_Real[RETURNCYLINDER_PRE]); 
	strPressValue[7].Format("%3.1f", pDataReal->Data_Real[MAINCYLINDER_PRE]); 
 
	for(int iItem=0;iItem<8;iItem++) 
	{ 
		m_ListCtrlPress.SetItemText(iItem, 1, strPressValue[iItem]); 
	} 
 
	CString strMoveValue[5]; 
 
	strMoveValue[0].Format("%5.1f", pDataReal->Data_Real[FORGING_POS]); 
	strMoveValue[1].Format("%6.1f", pDataReal->Data_Real[ROBOT_MOVE_POS]); 
	strMoveValue[2].Format("%6.1f", pDataReal->Data_Real[ROBOT2_MOVE_POS]); 
	strMoveValue[3].Format("%6.1f", pDataReal->Data_Real[ROBOT_PEEL]); 
	strMoveValue[4].Format("%6.1f", pDataReal->Data_Real[ROBOT2_PEEL]); 
 
	for(iItem=0;iItem<5;iItem++) 
	{ 
		m_ListCtrlMove.SetItemText(iItem, 1, strMoveValue[iItem]); 
	} 
 
	CString strRotateValue[2]; 
 
	strRotateValue[0].Format("%6.1f", pDataReal->Data_Real[ROBOT_ROTATE_POS]); 
	strRotateValue[1].Format("%6.1f", pDataReal->Data_Real[ROBOT2_ROTATE_POS]); 
 
	for(iItem=0;iItem<2;iItem++) 
	{ 
		m_ListCtrlRotate.SetItemText(iItem, 1, strRotateValue[iItem]); 
	} 
 
	CString strTempValue[2]; 
 
	strTempValue[0].Format("%6.1f", pDataReal->Data_Real[KETTLE_TEMP]); 
	strTempValue[1].Format("%6.1f", pDataReal->Data_Real[FORGING_TEMP]); 
 
	for(iItem=0;iItem<2;iItem++) 
	{ 
		m_ListCtrlTemp.SetItemText(iItem, 1, strTempValue[iItem]); 
	} 
 
	CString strAoutValue[7]; 
 
	strAoutValue[0].Format("%4.1f", pDataReal->AOut.A_Ya2); 
	strAoutValue[1].Format("%4.1f", pDataReal->AOut.A_Ya3); 
	strAoutValue[2].Format("%4.1f", pDataReal->AOut.A_Ya6); 
	strAoutValue[3].Format("%4.1f", pDataReal->AOut.C_Ya9); 
	strAoutValue[4].Format("%4.1f", pDataReal->AOut.C_Ya10); 
	strAoutValue[5].Format("%4.1f", pDataReal->AOut.D_Ya9); 
	strAoutValue[6].Format("%4.1f", pDataReal->AOut.D_Ya10); 
 
	for(iItem=0;iItem<7;iItem++) 
	{ 
		m_ListCtrlAout.SetItemText(iItem, 1, strAoutValue[iItem]); 
	} 
/////////////////////////////二进制显示项目 
	CString strBinaryValue[5]; 
 
	strBinaryValue[0].Format("%04X", pDataReal->CIn.In); 
	strBinaryValue[1].Format("%04X", pDataReal->SOut.Out); 
	strBinaryValue[2].Format("%X %x %x %x %x %x %x", pDataReal->InPlc.In[0],pDataReal->InPlc.In[1], 
		pDataReal->InPlc.In[2],pDataReal->InPlc.In[3],pDataReal->InPlc.In[4],pDataReal->InPlc.In[5],pDataReal->InPlcStatus.In); 
	strBinaryValue[3].Format("%d %d %d %d", pDataReal->OutPlc_Disp.Out_C_Ya9,pDataReal->OutPlc_Disp.Out_C_Ya10, 
		pDataReal->OutPlc_Disp.Out_D_Ya9,pDataReal->OutPlc_Disp.Out_D_Ya10); 
	strBinaryValue[4].Format("%04X %4X", pDataReal->OutPlc.Out[0],pDataReal->OutPlc.Out[1]); 
 
	for(iItem=0;iItem<5;iItem++) 
	{ 
		m_ListCtrlBinary.SetItemText(iItem, 1, strBinaryValue[iItem]); 
	}	 
	 
///////////////////////////////////////////////////////////////////////// 
	CString strTestprjValue[7]; 
	 
	strTestprjValue[0].Format("%5.1f", pDataReal->Forging_Display_Pos); 
	strTestprjValue[1].Format("%6.1f", pDataReal->Forging_Display_Speed); 
	strTestprjValue[2].Format("%4.1f", pDataReal->Forging_Display_Freq); 
	strTestprjValue[3].Format("%4.1f", pDataReal->Robot_Display_Speed); 
	strTestprjValue[4].Format("%4.1f", pDataReal->Rotate_Display_Speed); 
	strTestprjValue[5].Format("%4.1f", pDataReal->Robot2_Display_Speed); 
	strTestprjValue[6].Format("%4.1f", pDataReal->Rotate2_Display_Speed); 
	 
	for(iItem=0;iItem<7;iItem++) 
	{ 
		m_ListCtrlTestprj.SetItemText(iItem, 1, strTestprjValue[iItem]); 
	} 
 
}