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

📄 keyfuntionview.cpp

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

#include "stdafx.h"
#include "mbpc.h"
#include "KEYFuntionView.h"

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

/////////////////////////////////////////////////////////////////////////////
// CKEYFuntionView

IMPLEMENT_DYNCREATE(CKEYFuntionView, CFormView)

CKEYFuntionView::CKEYFuntionView()
	: CFormView(CKEYFuntionView::IDD)
{
	//{{AFX_DATA_INIT(CKEYFuntionView)
	m_nPLength = 0;
	m_nPAddr = 0;
	m_nPComb = -1;
	m_nCombM = -1;
	m_nMKey = 0;
	m_nMAddr = 0;
	m_nTestComb = -1;
	//}}AFX_DATA_INIT
}

CKEYFuntionView::~CKEYFuntionView()
{
}

void CKEYFuntionView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CKEYFuntionView)
	DDX_Control(pDX, IDC_TESTCOMBO, m_CombTest);
	DDX_Control(pDX, IDC_MCOMBO, m_CombM);
	DDX_Control(pDX, IDC_PCOMBO, m_CombP);
	DDX_Control(pDX, IDC_PKEYLST, m_List);
	DDX_Text(pDX, IDC_PKEYLENGTH, m_nPLength);
	DDX_Text(pDX, IDC_PKEYADDR, m_nPAddr);
	DDX_CBIndex(pDX, IDC_PCOMBO, m_nPComb);
	DDX_CBIndex(pDX, IDC_MCOMBO, m_nCombM);
	DDX_Text(pDX, IDC_MKEYVALUE, m_nMKey);
	DDX_Text(pDX, IDC_MKEYADDR, m_nMAddr);
	DDX_CBIndex(pDX, IDC_TESTCOMBO, m_nTestComb);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CKEYFuntionView, CFormView)
	//{{AFX_MSG_MAP(CKEYFuntionView)
	ON_BN_CLICKED(IDC_MCALL, OnMcall)
	ON_BN_CLICKED(IDC_PCALL, OnPcall)
	ON_WM_DESTROY()
	ON_BN_CLICKED(IDC_DEVICE, OnDevice)
	ON_BN_CLICKED(IDC_ANALOG, OnAnalog)
	ON_BN_CLICKED(IDC_METER, OnMeter)
	ON_BN_CLICKED(IDC_DI, OnDi)
	ON_BN_CLICKED(IDC_DO, OnDo)
	ON_BN_CLICKED(IDC_ENABLE, OnEnable)
	ON_BN_CLICKED(IDC_SETTING, OnSetting)
	ON_BN_CLICKED(IDC_ALARM, OnAlarm)
	ON_BN_CLICKED(IDC_RECORD, OnRecord)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CKEYFuntionView diagnostics

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

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

/////////////////////////////////////////////////////////////////////////////
// CKEYFuntionView message handlers

void CKEYFuntionView::OnMcall() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(GetDocument()->m_bSetuped)
	{
		if(this->m_nCombM == 1)
		{
			if(GetDocument()->ReqKEY_M(this->m_nMAddr,0,this->m_nCombM))
			{
				Sleep(1000);
				this->m_nMKey = GetDocument()->m_nKEY_M;
				UpdateData(FALSE);
			}
		}
		if(this->m_nCombM == 0)
		{
			if(GetDocument()->ReqKEY_M(this->m_nMAddr,this->m_nMKey,this->m_nCombM))
			{
				Sleep(1000);
				this->m_nMKey = GetDocument()->m_nKEY_M;
				UpdateData(FALSE);
			}
		}
	}
}

void CKEYFuntionView::OnPcall() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(GetDocument()->m_bSetuped)
	{	
		GetDocument()->ReqKEY_P(this->m_nPAddr,this->m_nPLength);
		Sleep(5000);
		/*if(this->m_nPComb == 0)
		{
			int a[50];
			memset(a,0,sizeof(a));
			memcpy(&a, &GetDocument()->m_nKEY_P, sizeof(a));

			for(int i = 0; i < (m_nPLength/2); i++)
			{
				CString str;
				str.Format("%d",a[i]);
				m_List.SetItemText(i,1,str);
			}
		}
		if(this->m_nPComb == 1)
		{
			WORD b[100];
			memset(b,0,sizeof(b));
			memcpy(&b, &GetDocument()->m_nKEY_P, sizeof(b));

			for(int i = 0; i < m_nPLength; i++)
			{
				CString str;
				str.Format("%d",b[i]);
				m_List.SetItemText(i,1,str);
			}
		}
		if(this->m_nPComb == 2)
		{
			float c[50];
			memset(c,0,sizeof(c));
			memcpy(&c, &GetDocument()->m_nKEY_P, sizeof(c));

			for(int i = 0; i < (m_nPLength/2); i++)
			{
				CString str;
				str.Format("%f", c[i]);
				m_List.SetItemText(i,1,str);
			}
		}*/
		for(int i = 0; i < 200; i++)
		{
			CString str;
			str.Format("%d", GetDocument()->m_nKEY_P[i]);
			m_List.SetItemText(i, 1, str);
		}
		UpdateData(FALSE);
	}
}

void CKEYFuntionView::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
	this->m_CombM.AddString("写");
	this->m_CombM.AddString("读");
	
	this->m_CombP.AddString("长整型");
	this->m_CombP.AddString("短整型");
	this->m_CombP.AddString("浮点型");

	LONG lStyle;
	lStyle = GetWindowLong(m_List.m_hWnd, GWL_STYLE);//获取当前窗口style
	lStyle &= ~LVS_TYPEMASK; //清除显示方式位
	lStyle |= LVS_REPORT; //设置style
	SetWindowLong(m_List.m_hWnd, GWL_STYLE, lStyle);//设置style

	DWORD dwStyle = m_List.GetExtendedStyle();
	dwStyle |= LVS_EX_FULLROWSELECT;//选中某行使整行高亮(只适用与report风格的listctrl)
	dwStyle |= LVS_EX_GRIDLINES;//网格线(只适用与report风格的listctrl)
	m_List.SetExtendedStyle(dwStyle); //设置扩展风格

	this->m_List.InsertColumn(0,"序号",LVCFMT_LEFT,40);
	this->m_List.InsertColumn(1,"值",LVCFMT_LEFT,100);
	
	for(int i = 0; i < 200; i++)
	{	
		CString str;
		str.Format("%d",i);
		m_List.InsertItem(i,str);
	}
	for(int j = 0; j < 256; j++)
	{
		CString str;
		str.Format("%d",j+1);
		this->m_CombTest.AddString(str);
	}
	UpdateData(FALSE);
}

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

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


//DEL void CKEYFuntionView::OnEditchangeMcombo() 
//DEL {
//DEL 	// TODO: Add your control notification handler code here
//DEL 
//DEL }



void CKEYFuntionView::OnDevice() 
{
	// TODO: Add your control notification handler code here
	GetDocument()->ReqDeviceinfo();
}

void CKEYFuntionView::OnAnalog() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	GetDocument()->ReqAnaInfo(this->m_nTestComb);
}

void CKEYFuntionView::OnMeter() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	GetDocument()->ReqSingleMeterInfo(this->m_nTestComb);
}

void CKEYFuntionView::OnDi() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	GetDocument()->ReqSingleDiInfo(this->m_nTestComb);
}

void CKEYFuntionView::OnDo() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	GetDocument()->ReqSingleDoInfo(this->m_nTestComb);
}

void CKEYFuntionView::OnEnable() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	GetDocument()->ReqSingleEnableInfo(this->m_nTestComb);
}

void CKEYFuntionView::OnSetting() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	GetDocument()->ReqSingleSettingInfo(this->m_nTestComb);
}

void CKEYFuntionView::OnAlarm() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	GetDocument()->ReqSingleAlarmInfo(this->m_nTestComb);
}

void CKEYFuntionView::OnRecord() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	GetDocument()->ReqSingleRecordInfo(this->m_nTestComb);
}

⌨️ 快捷键说明

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