control.cpp

来自「上次我传的倒立摆的控制程序,不是我的最终的程序,本程序采用VC++编程,定时器为」· C++ 代码 · 共 70 行

CPP
70
字号
// Control.cpp : implementation file
//

#include "stdafx.h"
#include "Pend.h"
#include "Control.h"

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

/////////////////////////////////////////////////////////////////////////////
// CControl dialog


CControl::CControl(CWnd* pParent /*=NULL*/)
	: CDialog(CControl::IDD, pParent)
{
	//{{AFX_DATA_INIT(CControl)
	m_jiaodu = 0.0;
	m_sudu = 0.0;
	m_weizhi = 0.0;
	m_jiaosudu = 0.0;
	posdot=0.0;
    angledot=0.0;
	pos=0.0;
	angle=0.0;
	pos0=0.0;
	angle0=0.0;
	angle1=0.0;
	v=0;
	v_ctrl=0.0;
	//}}AFX_DATA_INIT
}


void CControl::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CControl)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CControl, CDialog)
	//{{AFX_MSG_MAP(CControl)
	ON_BN_CLICKED(IDC_BUTTON_MOVE, OnButtonMove)
	ON_BN_CLICKED(IDC_BUTTON_STOP, OnButtonStop)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CControl message handlers

void CControl::OnButtonMove() 
{
	   SetTimer(1,100,NULL);// TODO: Add your control notification handler code here
	
}

void CControl::OnButtonStop() 
{
		GT_AxisOff();
		GT_Close();	// TODO: Add your control notification handler code here
	
}

⌨️ 快捷键说明

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