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

📄 plcmemdlg.cpp

📁 工业强度的PLC模拟程序
💻 CPP
字号:
// @dlg
//
// @module		PlcMemDlg.cpp
//
//
// Maintenance:
//	
// Version		Date		Who		What
// -------		--------	---		-------------------------------------
// 7.0			06/10/97	jra		Created
//
//

// PlcMemDlg.cpp : implementation file
//

#include "stdafx.h"
#include "itkplc.h"
#include "PlcMemDlg.h"
#include "ItkProtocol.h"

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

/////////////////////////////////////////////////////////////////////////////
// CPlcMemDlg dialog



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | CPlcMemDlg |
//
// Constructor 
//
CPlcMemDlg::CPlcMemDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CPlcMemDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CPlcMemDlg)
	m_plc_mem0 = 0;
	m_plc_mem1 = 0;
	m_plc_mem2 = 0;
	m_plc_mem3 = 0;
	m_plc_mem4 = 0;
	m_plc_mem5 = 0;
	m_plc_mem6 = 0;
	m_plc_mem7 = 0;
	m_plc_mem8 = 0;
	m_plc_mem9 = 0;
	//}}AFX_DATA_INIT
}


void CPlcMemDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPlcMemDlg)
	DDX_Control(pDX, IDC_PLC_MEM9, m_PlcMem9);
	DDX_Control(pDX, IDC_PLC_MEM8, m_PlcMem8);
	DDX_Control(pDX, IDC_PLC_MEM7, m_PlcMem7);
	DDX_Control(pDX, IDC_PLC_MEM6, m_PlcMem6);
	DDX_Control(pDX, IDC_PLC_MEM5, m_PlcMem5);
	DDX_Control(pDX, IDC_PLC_MEM4, m_PlcMem4);
	DDX_Control(pDX, IDC_PLC_MEM3, m_PlcMem3);
	DDX_Control(pDX, IDC_PLC_MEM2, m_PlcMem2);
	DDX_Control(pDX, IDC_PLC_MEM1, m_PlcMem1);
	DDX_Control(pDX, IDC_PLC_MEM0, m_PlcMem0);
	DDX_Text(pDX, IDC_PLC_MEM0, m_plc_mem0);
	DDX_Text(pDX, IDC_PLC_MEM1, m_plc_mem1);
	DDX_Text(pDX, IDC_PLC_MEM2, m_plc_mem2);
	DDX_Text(pDX, IDC_PLC_MEM3, m_plc_mem3);
	DDX_Text(pDX, IDC_PLC_MEM4, m_plc_mem4);
	DDX_Text(pDX, IDC_PLC_MEM5, m_plc_mem5);
	DDX_Text(pDX, IDC_PLC_MEM6, m_plc_mem6);
	DDX_Text(pDX, IDC_PLC_MEM7, m_plc_mem7);
	DDX_Text(pDX, IDC_PLC_MEM8, m_plc_mem8);
	DDX_Text(pDX, IDC_PLC_MEM9, m_plc_mem9);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPlcMemDlg, CDialog)
	//{{AFX_MSG_MAP(CPlcMemDlg)
	ON_EN_CHANGE(IDC_PLC_MEM0, OnChangePlcMem0)
	ON_EN_CHANGE(IDC_PLC_MEM1, OnChangePlcMem1)
	ON_EN_CHANGE(IDC_PLC_MEM2, OnChangePlcMem2)
	ON_EN_CHANGE(IDC_PLC_MEM3, OnChangePlcMem3)
	ON_EN_CHANGE(IDC_PLC_MEM4, OnChangePlcMem4)
	ON_EN_CHANGE(IDC_PLC_MEM5, OnChangePlcMem5)
	ON_EN_CHANGE(IDC_PLC_MEM6, OnChangePlcMem6)
	ON_EN_CHANGE(IDC_PLC_MEM7, OnChangePlcMem7)
	ON_EN_CHANGE(IDC_PLC_MEM8, OnChangePlcMem8)
	ON_EN_CHANGE(IDC_PLC_MEM9, OnChangePlcMem9)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPlcMemDlg message handlers



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | CPlcMemDlg |
//
// Default OnOK() handler.
// Add any specific code here to validate any data entered by the user when
// the Ok button is clicked. 
//
void CPlcMemDlg::OnOK() 
{
	//
	// Call the default handler
	//
	CDialog::OnOK();
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnCancel |
//
// Default OnCancel() handler. This will reinitialize the Changed Values map
// back to FALSE because we don;t want to change anything if the user clicks
// the Cancel button .
// Add and specific code here to further clean up when Cancel is clicked.
//
void CPlcMemDlg::OnCancel() 
{
	//
	// Set the Changed Values map back to FALSE
	//
	for (int i = 0; i < 10; i++)
	{
		this->m_edited_memory_map[i].bChanged = FALSE;
		this->m_edited_memory_map[i].nNewVal = 0;
	}

	//
	// Call the default handler
	//
	CDialog::OnCancel();
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc BOOL | CPlcMemDlg | OnInitDialog |
//
// Responsible for initializing the dialog box class members. 
// Add any specific code here to initialize any additional class members.
// This function must return FALSE because we are setting the focus to 
// an edit box control. If you do not do this, then return TRUE. 
//
BOOL CPlcMemDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	CString		csDlgText;
	char		pszTempBuf[10];
	int			i,
				nDlgVal;
	

	//
	// Build a string and set the text in the dialog box to display
	// what registers will be edited.
	//
	csDlgText = "Enter the PLC Memory values for registers ";
	itoa((this->m_location*10), pszTempBuf, 10);
	csDlgText += pszTempBuf;
	csDlgText += " through ";
	itoa((this->m_location*10 + 9), pszTempBuf, 10);
	csDlgText += pszTempBuf;
	csDlgText += " below:";

	//
	// Set the text in the dialogs static text box.
	//
	this->SetDlgItemText(IDC_ENTER_TEXT, csDlgText);

	//
	// Set the text to let the user know what edit box goes with
	// which register.
	//
	for (nDlgVal = IDC_OFFSET0, i = 0; nDlgVal <= IDC_OFFSET9; nDlgVal++, i++)
	{
		csDlgText = "Register ";
		itoa((this->m_location*10 + i), pszTempBuf, 10);
		csDlgText += pszTempBuf;
		csDlgText += ":";

		this->SetDlgItemText(nDlgVal, csDlgText);
	}

	//
	// Set the focus to the first edit box. We must return FALSE to do this.
	//
	m_PlcMem0.SetFocus();

	//
	// Initialize the Changed Values map
	//
	for (i = 0; i < 10; i++)
	{
		this->m_edited_memory_map[i].bChanged = FALSE;
		this->m_edited_memory_map[i].nNewVal = 0;
	}

	//
	// Let's see if they selected the last row, which only goes through 
	// register value 1023
	//
	if (this->m_location == nLastRow)
	{
		m_PlcMem4.EnableWindow(FALSE);
		m_PlcMem5.EnableWindow(FALSE);
		m_PlcMem6.EnableWindow(FALSE);
		m_PlcMem7.EnableWindow(FALSE);
		m_PlcMem8.EnableWindow(FALSE);
		m_PlcMem9.EnableWindow(FALSE);
	}
	
	return FALSE; 
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem0 |
//
// Responsible for updating the editied memory map for edit box 0. 
//
void CPlcMemDlg::OnChangePlcMem0() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[0].nNewVal = this->m_plc_mem0;
	this->m_edited_memory_map[0].bChanged = TRUE;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem1 |
//
// Responsible for updating the editied memory map for edit box 1. 
//
void CPlcMemDlg::OnChangePlcMem1() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[1].nNewVal = this->m_plc_mem1;
	this->m_edited_memory_map[1].bChanged = TRUE;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem2 |
//
// Responsible for updating the editied memory map for edit box 2. 
//
void CPlcMemDlg::OnChangePlcMem2() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[2].nNewVal = this->m_plc_mem2;
	this->m_edited_memory_map[2].bChanged = TRUE;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem3 |
//
// Responsible for updating the editied memory map for edit box 3. 
//
void CPlcMemDlg::OnChangePlcMem3() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[3].nNewVal = this->m_plc_mem3;
	this->m_edited_memory_map[3].bChanged = TRUE;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem4 |
//
// Responsible for updating the editied memory map for edit box 4. 
//
void CPlcMemDlg::OnChangePlcMem4() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[4].nNewVal = this->m_plc_mem4;
	this->m_edited_memory_map[4].bChanged = TRUE;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem5 |
//
// Responsible for updating the editied memory map for edit box 5. 
//
void CPlcMemDlg::OnChangePlcMem5() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[5].nNewVal = this->m_plc_mem5;
	this->m_edited_memory_map[5].bChanged = TRUE;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem6 |
//
// Responsible for updating the editied memory map for edit box 6. 
//
void CPlcMemDlg::OnChangePlcMem6() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[6].nNewVal = this->m_plc_mem6;
	this->m_edited_memory_map[6].bChanged = TRUE;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem7 |
//
// Responsible for updating the editied memory map for edit box 7. 
//
void CPlcMemDlg::OnChangePlcMem7() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[7].nNewVal = this->m_plc_mem7;
	this->m_edited_memory_map[7].bChanged = TRUE;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem8 |
//
// Responsible for updating the editied memory map for edit box 8. 
//
void CPlcMemDlg::OnChangePlcMem8() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[8].nNewVal = this->m_plc_mem8;
	this->m_edited_memory_map[8].bChanged = TRUE;
}



//----(Member Function)-------------------------------------------------------
//
// @mfunc void | CPlcMemDlg | OnChangePlcMem9 |
//
// Responsible for updating the editied memory map for edit box 9. 
//
void CPlcMemDlg::OnChangePlcMem9() 
{
	UpdateData(TRUE);
	this->m_edited_memory_map[9].nNewVal = this->m_plc_mem9;
	this->m_edited_memory_map[9].bChanged = TRUE;
}

⌨️ 快捷键说明

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