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

📄 inverterdlg.cpp

📁 Control the 24 pulse inverter module dsp based
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// inverterDlg.cpp : implementation file
//

#include "stdafx.h"
#include "inverter.h"
#include "inverterDlg.h"
#include ".\inverterdlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	enum { IDD = IDD_ABOUTBOX };

	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

// Implementation
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
END_MESSAGE_MAP()


// CinverterDlg dialog



CinverterDlg::CinverterDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CinverterDlg::IDD, pParent)
	, m_txcounter(_T(""))
	, m_stcchk(_T(""))
	, startTransmit(false)
	, txCounter(0)
	, rxCounter(0)	
	, m_serial1(0)
	, m_serial2(0)
	, m_serial3(0)
	, m_seial4(0)
	, m_serial4(0)
	, m_serial5(0)
	, m_serial6(0)
	, m_rxcounter(_T(""))
	, nonPreceiseTimer(0)
	, m_q10(_T(""))
	, m_q11(_T(""))
	, m_q12(_T(""))
	, m_q13(_T(""))
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CinverterDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_STC_TXCOUNTER, m_txcounter);
	DDX_Control(pDX, IDC_EDT_HEADER0, m_edtq0);
	DDX_Control(pDX, IDC_EDT_HEADER2, m_edtq1);
	DDX_Control(pDX, IDC_EDT_CMD, m_edtq2);
	DDX_Control(pDX, IDC_EDT_RETUNIT, m_edtq3);
	DDX_Control(pDX, IDC_EDT_PHASE, m_edtq4);
	DDX_Text(pDX, IDC_STC_CHKSUM, m_stcchk);
	DDX_Text(pDX, IDC_STC_RXCOUNTER, m_rxcounter);
	DDX_Text(pDX, IDC_STC_HEADER0, m_q10);
	DDX_Text(pDX, IDC_STC_HEADER1, m_q11);
	DDX_Text(pDX, IDC_STC_PERIOD, m_q12);
	DDX_Text(pDX, IDC_STC_UNITID, m_q13);
}

BEGIN_MESSAGE_MAP(CinverterDlg, CDialog)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	//}}AFX_MSG_MAP
	ON_BN_CLICKED(IDC_BTN_START, OnBnClickedBtnStart)
	ON_EN_CHANGE(IDC_EDT_HEADER0, OnEnChangeEdtHeader0)
	ON_EN_CHANGE(IDC_EDT_HEADER2, OnEnChangeEdtHeader2)
	ON_EN_CHANGE(IDC_EDT_CMD, OnEnChangeEdtCmd)
	ON_EN_CHANGE(IDC_EDT_RETUNIT, OnEnChangeEdtRetunit)
	ON_EN_CHANGE(IDC_EDT_PHASE, OnEnChangeEdtPhase)
	ON_WM_CREATE()
	ON_WM_TIMER()
	ON_WM_DESTROY()
END_MESSAGE_MAP()


// CinverterDlg message handlers

BOOL CinverterDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	// TODO: Add extra initialization here
	CString temp1;
	temp1.Format("%X",m_serial0);GetDlgItem(IDC_EDT_HEADER0)->SetWindowText(temp1);
	temp1.Format("%X",m_serial1);GetDlgItem(IDC_EDT_HEADER2)->SetWindowText(temp1);
	temp1.Format("%X",m_serial2);GetDlgItem(IDC_EDT_CMD)->SetWindowText(temp1);
	temp1.Format("%X",m_serial3);GetDlgItem(IDC_EDT_RETUNIT)->SetWindowText(temp1);
	temp1.Format("%X",m_serial4);GetDlgItem(IDC_EDT_PHASE)->SetWindowText(temp1);
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CinverterDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CinverterDlg::OnPaint() 


{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this function to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CinverterDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}

void CinverterDlg::OnBnClickedBtnStart()
{
	// TODO: Add your control notification handler code here
	//m_edtq0.GetWindowText(a);

	CWnd *m_label;
	CString c_label;
	m_label=GetDlgItem(IDC_BTN_START);
	m_label->GetWindowText(c_label);
	if(c_label=="&Start")
	{
		m_label->SetWindowText("&Stop");		
		startTransmit=TRUE;
		txCounter=rxCounter=0;
	}
	else if(c_label=="&Stop")
	{
		m_label->SetWindowText("&Start");
		startTransmit=FALSE;
	}	
}

void CinverterDlg::OnEnChangeEdtHeader0()
{
	// TODO:  If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
	//UpdateData(1);
	CString a;
	unsigned char h,l,chk;
	m_edtq0.GetWindowText(a);		
	
	if(a.GetLength()==2)
	{
		h=a.GetAt(0);
		l=a.GetAt(1);
		m_serial0=(BYTE)(convert2num(h)*16)+convert2num(l);
	}
	if(a.GetLength()==1)
	{
		h=a.GetAt(0);
		m_serial0=(BYTE)convert2num(h);
	}
	else if(a.GetLength()==0)
	{
		m_serial0=0;
	}
	chk=0;	
	chk=(unsigned char)((UINT)m_serial0+(UINT)m_serial1+(UINT)m_serial2+(UINT)m_serial3+(UINT)m_serial5);
	m_stcchk.Format("%x",chk);
	//UpdateData(0);
}

void CinverterDlg::OnEnChangeEdtHeader2()
{
	//UpdateData(1);
	// TODO:  If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
	CString a;
	unsigned char h,l,chk;
	m_edtq1.GetWindowText(a);		
	
	if(a.GetLength()==2)
	{
		h=a.GetAt(0);
		l=a.GetAt(1);
		m_serial1=(BYTE)(convert2num(h)*16)+convert2num(l);
	}
	if(a.GetLength()==1)
	{
		h=a.GetAt(0);
		m_serial1=(BYTE)convert2num(h);
	}
	else if(a.GetLength()==0)
	{
		m_serial1=0;
	}
	chk=0;	
	chk=(unsigned char)((UINT)m_serial0+(UINT)m_serial1+(UINT)m_serial2+(UINT)m_serial3+(UINT)m_serial5);
	m_stcchk.Format("%x",chk);
	//UpdateData(0);
}

void CinverterDlg::OnEnChangeEdtCmd()
{
	// TODO:  If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.

	// TODO:  Add your control notification handler code here
	//UpdateData(1);
	CString a;
	unsigned char h,l,chk;
	m_edtq2.GetWindowText(a);
	
	if(a.GetLength()==2)
	{
		h=a.GetAt(0);
		l=a.GetAt(1);
		m_serial2=(BYTE)(convert2num(h)*16)+convert2num(l);
	}
	if(a.GetLength()==1)
	{
		h=a.GetAt(0);
		m_serial2=(BYTE)convert2num(h);
	}
	else if(a.GetLength()==0)
	{
		m_serial2=0;
	}
	chk=0;	
	chk=(unsigned char)((UINT)m_serial0+(UINT)m_serial1+(UINT)m_serial2+(UINT)m_serial3+(UINT)m_serial5);
	m_stcchk.Format("%x",chk);
	//UpdateData(0);

⌨️ 快捷键说明

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