⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 analoginfoview.cpp

📁 保护装置的mbpc软件
💻 CPP
字号:
// AnalogInfoView.cpp : implementation file
//

#include "stdafx.h"
#include "mbpc.h"
#include "AnalogInfoView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAnalogInfoView

IMPLEMENT_DYNCREATE(CAnalogInfoView, CFormView)

CAnalogInfoView::CAnalogInfoView()
	: CFormView(CAnalogInfoView::IDD)
{
	//{{AFX_DATA_INIT(CAnalogInfoView)
	m_nAnalogId = 0;
	m_nDiId = 0;
	m_nDoId = 0;
	m_nEnableId = 0;
	m_nEnergyId = 0;
	m_nSetId = 0;
	m_nAlarmId = 0;
	m_nTimerFlag = 0;
	m_nRecordId = 0;
	//}}AFX_DATA_INIT
}

CAnalogInfoView::~CAnalogInfoView()
{
}

void CAnalogInfoView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAnalogInfoView)
	DDX_Control(pDX, IDC_RECORDNAME, m_EditRecordName);
	DDX_Control(pDX, IDC_RECORDIDNUM, m_EditRecordId);
	DDX_Control(pDX, IDC_RECORDID, m_CombRecordId);
	DDX_Control(pDX, IDC_ALARMNAME, m_EditAlarmName);
	DDX_Control(pDX, IDC_ALARMIDNUM, m_EditAlarmId);
	DDX_Control(pDX, IDC_ALARMID, m_CombAlarmId);
	DDX_Control(pDX, IDC_SETTINGUPPER, m_SetUpper);
	DDX_Control(pDX, IDC_SETTINGUNIT, m_SetUnit);
	DDX_Control(pDX, IDC_SETTINGNAME, m_SetName);
	DDX_Control(pDX, IDC_SETTINGLOWER, m_SetLower);
	DDX_Control(pDX, IDC_SETTINGIDNUM, m_SetNum);
	DDX_Control(pDX, IDC_SETTINGDTTP, m_SetDatetype);
	DDX_Control(pDX, IDC_SETTINGID, m_CombSetId);
	DDX_Control(pDX, IDC_ENERGYSUNIT, m_EnergySunit);
	DDX_Control(pDX, IDC_ENERGYSRATIO, m_EnergySratio);
	DDX_Control(pDX, IDC_ENERGYPUNIT, m_EnergyPunit);
	DDX_Control(pDX, IDC_ENERGYPRATIO, m_EnergyPratio);
	DDX_Control(pDX, IDC_ENERGYNAME, m_EnergyName);
	DDX_Control(pDX, IDC_ENERGYIDNUM, m_EnergyNum);
	DDX_Control(pDX, IDC_ENERGYID, m_CombEnergyId);
	DDX_Control(pDX, IDC_ENABLEONNAME, m_EnableOnname);
	DDX_Control(pDX, IDC_ENABLEOFFNAME, m_EnableOffname);
	DDX_Control(pDX, IDC_ENABLENAME, m_EnableName);
	DDX_Control(pDX, IDC_ENABLEIDNUM, m_EnableNum);
	DDX_Control(pDX, IDC_ENABLEID, m_CombEnableId);
	DDX_Control(pDX, IDC_DOONNAME, m_DoOnname);
	DDX_Control(pDX, IDC_DOOFFNAME, m_DoOffName);
	DDX_Control(pDX, IDC_DONAME, m_DoName);
	DDX_Control(pDX, IDC_DOIDNUM, m_DoIdNum);
	DDX_Control(pDX, IDC_DOID, m_CombDoId);
	DDX_Control(pDX, IDC_DIONNAME, m_DiOnname);
	DDX_Control(pDX, IDC_DIOFFNAME, m_DiOffname);
	DDX_Control(pDX, IDC_DINAME, m_DiName);
	DDX_Control(pDX, IDC_DIIDNUM, m_DiNum);
	DDX_Control(pDX, IDC_DIID, m_CombDiId);
	DDX_Control(pDX, IDC_ZERODEV, m_EditZeroDev);
	DDX_Control(pDX, IDC_SUNIT, m_EditSunit);
	DDX_Control(pDX, IDC_SRATIO, m_EditSratio);
	DDX_Control(pDX, IDC_PUNIT, m_EditPunit);
	DDX_Control(pDX, IDC_PRATIO, m_EditPratio);
	DDX_Control(pDX, IDC_NAME, m_EditName);
	DDX_Control(pDX, IDC_IDNUM, m_EditIdNum);
	DDX_Control(pDX, IDC_ANALOGID, m_CombAnaId);		
	DDX_CBIndex(pDX, IDC_ANALOGID, m_nAnalogId);
	DDX_CBIndex(pDX, IDC_DIID, m_nDiId);
	DDX_CBIndex(pDX, IDC_DOID, m_nDoId);
	DDX_CBIndex(pDX, IDC_ENABLEID, m_nEnableId);
	DDX_CBIndex(pDX, IDC_ENERGYID, m_nEnergyId);
	DDX_CBIndex(pDX, IDC_SETTINGID, m_nSetId);
	DDX_CBIndex(pDX, IDC_ALARMID, m_nAlarmId);
	DDX_CBIndex(pDX, IDC_RECORDID, m_nRecordId);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CAnalogInfoView, CFormView)
	//{{AFX_MSG_MAP(CAnalogInfoView)
	ON_WM_CREATE()
	ON_WM_TIMER()
	ON_WM_DESTROY()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAnalogInfoView diagnostics

#ifdef _DEBUG
void CAnalogInfoView::AssertValid() const
{
	CFormView::AssertValid();
}

void CAnalogInfoView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CAnalogInfoView message handlers

CMbpcDoc* CAnalogInfoView::GetDocument()
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMbpcDoc)));
	return (CMbpcDoc*)m_pDocument;
}

int CAnalogInfoView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFormView::OnCreate(lpCreateStruct) == -1)
		return -1;
	// TODO: Add your specialized creation code here
	SetTimer(1,500,NULL);
	return 0;
}



void CAnalogInfoView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	// TODO: Add your specialized code here and/or call the base class
	int i = 0;

	for(i = 0; i < 300; i++)
	{
		m_CombAnaId.DeleteString(0);
		m_CombEnergyId.DeleteString(0);
		m_CombDiId.DeleteString(0);
		m_CombEnableId.DeleteString(0);
		m_CombDoId.DeleteString(0);
		m_CombSetId.DeleteString(0);
		m_CombAlarmId.DeleteString(0);
		m_CombRecordId.DeleteString(0);
	}
	for(i = 0; i < GetDocument()->m_device_info.analog_count; i++)
	{
		CString str;
		str.Format("%d",i + 1);
		this->m_CombAnaId.AddString(str);
	}
	for(i = 0; i < GetDocument()->m_device_info.energy_count; i++)
	{
		CString str;
		str.Format("%d",i + 1);
		this->m_CombEnergyId.AddString(str);
	}
	for(i = 0; i < GetDocument()->m_device_info.di_count; i++)
	{
		CString str;
		str.Format("%d",i + 1);
		this->m_CombDiId.AddString(str);
	}
	for(i = 0; i < GetDocument()->m_device_info.enable_count; i++)
	{
		CString str;
		str.Format("%d",i + 1);
		this->m_CombEnableId.AddString(str);
	}
	for(i = 0; i < GetDocument()->m_device_info.do_count; i++)
	{
		CString str;
		str.Format("%d",i + 1);
		this->m_CombDoId.AddString(str);
	}
	for(i = 0; i < GetDocument()->m_device_info.item_in_sect; i++)
	{
		CString str;
		str.Format("%d",i + 1);
		this->m_CombSetId.AddString(str);
	}
	for(i = 0; i < GetDocument()->m_device_info.alarm_count; i++)
	{
		CString str;
		str.Format("%d",i + 1);
		this->m_CombAlarmId.AddString(str);
	}
	for(i = 0; i < GetDocument()->m_device_info.act_count; i++)
	{
		CString str;
		str.Format("%d",i + 1);
		this->m_CombRecordId.AddString(str);
	}

	UpdateData(FALSE);
}

void CAnalogInfoView::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	char szBuf[1024],szBuf1[1024];
	CString str;
	UpdateData(TRUE);
	memset(szBuf,0,sizeof(szBuf));
	memset(szBuf1,0,sizeof(szBuf1));
	if(1 == nIDEvent)
	{
		m_nTimerFlag++;
		
		if(m_nTimerFlag > 1)
		{
			m_nTimerFlag --;
		}
		else
		{
			if(GetDocument()->m_bSetuped)
			{	
				//模拟量
				itoa(m_nAnalogId + 1,szBuf,10);
				this->m_EditIdNum.SetWindowText(szBuf);
				memset(szBuf,0,sizeof(szBuf));
				
				this->m_EditName.SetWindowText((CString)GetDocument()->m_analog_info[m_nAnalogId].analog_name);
				
				str.Format("%f",GetDocument()->m_analog_info[m_nAnalogId].primary_ratio);
				this->m_EditPratio.SetWindowText(str);

				str.Format("%f",GetDocument()->m_analog_info[m_nAnalogId].secondary_ratio);
				this->m_EditSratio.SetWindowText(str);

				this->m_EditPunit.SetWindowText((CString)GetDocument()->m_analog_info[m_nAnalogId].primary_unit);

				this->m_EditSunit.SetWindowText((CString)GetDocument()->m_analog_info[m_nAnalogId].secondary_unit);
				
				str.Format("%d",GetDocument()->m_analog_info[m_nAnalogId].nZeroDeviation);
				this->m_EditZeroDev.SetWindowText(str);

				//电度量
				itoa(this->m_nEnergyId + 1, szBuf, 10);
				this->m_EnergyNum.SetWindowText(szBuf);
				memset(szBuf,0,sizeof(szBuf));

				this->m_EnergyName.SetWindowText((CString)GetDocument()->m_energy_info[m_nEnergyId].energy_name);
			
				str.Format("%f",GetDocument()->m_energy_info[m_nEnergyId].primary_ratio);
				this->m_EnergyPratio.SetWindowText(str);

				str.Format("%f", GetDocument()->m_energy_info[m_nEnergyId].secondary_ratio);
				this->m_EnergySratio.SetWindowText(str);

				this->m_EnergyPunit.SetWindowText((CString)GetDocument()->m_energy_info[m_nEnergyId].primary_unit);

				this->m_EnergySunit.SetWindowText((CString)GetDocument()->m_energy_info[m_nEnergyId].secondary_unit);
				
				//开入量
				itoa(this->m_nDiId + 1, szBuf, 10);
				this->m_DiNum.SetWindowText(szBuf);
				memset(szBuf,0,sizeof(szBuf));

				this->m_DiName.SetWindowText((CString)GetDocument()->m_DiInfo[m_nDiId].digital_name);

				this->m_DiOffname.SetWindowText((CString)GetDocument()->m_DiInfo[m_nDiId].off_name);

				this->m_DiOnname.SetWindowText((CString)GetDocument()->m_DiInfo[m_nDiId].on_name);

				//开出量
				itoa(this->m_nDoId + 1, szBuf, 10);
				this->m_DoIdNum.SetWindowText(szBuf);
				memset(szBuf,0,sizeof(szBuf));

				this->m_DoName.SetWindowText((CString)GetDocument()->m_DoInfo[m_nDoId].digital_name);

				this->m_DoOffName.SetWindowText((CString)GetDocument()->m_DoInfo[m_nDoId].off_name);

				this->m_DoOnname.SetWindowText((CString)GetDocument()->m_DoInfo[m_nDoId].on_name);

				//压板
				itoa(this->m_nEnableId + 1, szBuf, 10);
				this->m_EnableNum.SetWindowText(szBuf);
				memset(szBuf,0,sizeof(szBuf));

				this->m_EnableName.SetWindowText((CString)GetDocument()->m_EnableInfo[m_nEnableId].digital_name);

				this->m_EnableOffname.SetWindowText((CString)GetDocument()->m_EnableInfo[m_nEnableId].off_name);

				this->m_EnableOnname.SetWindowText((CString)GetDocument()->m_EnableInfo[m_nEnableId].on_name);

				//定值
				itoa(this->m_nSetId + 1, szBuf, 10);
				this->m_SetNum.SetWindowText(szBuf);
				memset(szBuf, 0, sizeof(szBuf));

				this->m_SetName.SetWindowText((CString)GetDocument()->m_SettingInfo[m_nSetId].setting_name);

				this->m_SetUnit.SetWindowText((CString)GetDocument()->m_SettingInfo[m_nSetId].setting_unit);
				
				if(GetDocument()->m_SettingInfo[m_nSetId].data_type == 0)
				{
					this->m_SetDatetype.SetWindowText("布尔型");
					this->m_SetUpper.SetWindowText((CString)GetDocument()->m_SettingInfo[m_nSetId].upper.bValue);
					this->m_SetLower.SetWindowText((CString)GetDocument()->m_SettingInfo[m_nSetId].lowwer.bValue);
				}

				if(GetDocument()->m_SettingInfo[m_nSetId].data_type == 1)
				{
					this->m_SetDatetype.SetWindowText("整型");

					str.Format("%d",GetDocument()->m_SettingInfo[m_nSetId].upper.nValue);
					this->m_SetUpper.SetWindowText(str);

					str.Format("%d",GetDocument()->m_SettingInfo[m_nSetId].lowwer.nValue);
					this->m_SetLower.SetWindowText(str);
				}

				if(GetDocument()->m_SettingInfo[m_nSetId].data_type == 2)
				{
					this->m_SetDatetype.SetWindowText("浮点型");

					str.Format("%f",GetDocument()->m_SettingInfo[m_nSetId].upper.fValue);
					this->m_SetUpper.SetWindowText(str);

					str.Format("%f",GetDocument()->m_SettingInfo[m_nSetId].lowwer.fValue);
					this->m_SetLower.SetWindowText(str);
				}
				
				//告警
				itoa(this->m_nAlarmId + 1, szBuf, 10);
				this->m_EditAlarmId.SetWindowText(szBuf);
				memset(szBuf,0,sizeof(szBuf));

				this->m_EditAlarmName.SetWindowText((CString)GetDocument()->m_AlarmInfo[m_nAlarmId].digital_name);

				//事件
				itoa(this->m_nRecordId + 1, szBuf, 10);
				this->m_EditRecordId.SetWindowText(szBuf);
				memset(szBuf,0,sizeof(szBuf));

				this->m_EditRecordName.SetWindowText((CString)GetDocument()->m_RecordInfo[m_nRecordId].digital_name);
				//UpdateData(FALSE);
			}
			
		}
		m_nTimerFlag--;
	}
	CFormView::OnTimer(nIDEvent);
}

void CAnalogInfoView::OnDestroy() 
{
	CFormView::OnDestroy();
	
	// TODO: Add your message handler code here
	KillTimer(1);
}

void CAnalogInfoView::OnActivateView(BOOL bActivate, CView* pActivateView, CView* pDeactiveView) 
{
	// TODO: Add your specialized code here and/or call the base class
	UpdateData();
	if(bActivate == FALSE)
	{
		KillTimer(1);
	}
	else
	{
		OnInitialUpdate();
		SetTimer(1,500,NULL);
	}
	//CFormView::Invalidate();
	
	CFormView::OnActivateView(bActivate, pActivateView, pDeactiveView);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -