📄 motordlgover.cpp
字号:
// MotorDlgOver.cpp : implementation file
//
#include "stdafx.h"
#include "TestForm.h"
#include "MotorDlgOver.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// MotorDlgOver dialog
MotorDlgOver::MotorDlgOver(CWnd* pParent /*=NULL*/)
: CDialog(MotorDlgOver::IDD, pParent)
{
//{{AFX_DATA_INIT(MotorDlgOver)
m_dModlgoveSpeed = 100.0;
//}}AFX_DATA_INIT
m_nModlgovePti = 0;
m_nModlgoveSti = 0;
m_nModlgoveTti = 0;
m_bSelfchekflag =FALSE;//设备自检未完成
}
void MotorDlgOver::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(MotorDlgOver)
DDX_Control(pDX, IDC_RAMODLGOVE_PTI, m_cModlgovePti);
DDX_Control(pDX, IDC_RAMODLGOVE_STI, m_cModlgoveSti);
DDX_Control(pDX, IDC_RAMODLGOVE_TTI, m_cModlgoveTti);
DDX_Control(pDX, IDC_COMODLGOVE_DIRECT, m_cModlgoveDirect);
DDX_Text(pDX, IDC_EDMODLGOVE_SPEED, m_dModlgoveSpeed);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(MotorDlgOver, CDialog)
//{{AFX_MSG_MAP(MotorDlgOver)
ON_BN_CLICKED(IDC_BUMODLGOVE_INIT, OnBumodlgoveInit)
ON_BN_CLICKED(IDC_BUMODLGOVE_START, OnBumodlgoveStart)
ON_BN_CLICKED(IDC_BUMODLGOVE_STOP, OnBumodlgoveStop)
ON_BN_CLICKED(IDC_BUMODLGOVE_FINISH, OnBumodlgoveFinish)
ON_MESSAGE(WM_CODERDAQ_ONE,OnCoderDaqOne)
ON_MESSAGE(WM_OPENDATA,OnOpendata)
ON_BN_CLICKED(IDC_RAMODLGOVE_PTI, OnRamodlgovePti)
ON_BN_CLICKED(IDC_RAMODLGOVE_STI, OnRamodlgoveSti)
ON_BN_CLICKED(IDC_RAMODLGOVE_TTI, OnRamodlgoveTti)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// MotorDlgOver message handlers
/////////////////////////////////
//设备自检
void MotorDlgOver::OnBumodlgoveInit()
{
// TODO: Add your control notification handler code here
motoroverDlg.initBoard();
m_bSelfchekflag =TRUE;//设备自检完成
}
BOOL MotorDlgOver::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_cModlgovePti.SetCheck(1);//显示曲线为效率-时间曲线
m_cModlgoveDirect.SetCurSel(0);//初始化为正转
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
//开始试验
void MotorDlgOver::OnBumodlgoveStart()
{
// TODO: Add your control notification handler code here
if (m_bSelfchekflag)
{
//读取控制面板参数
UpdateData(TRUE);
int radionumber=0;
CTestFormApp *pApp=(CTestFormApp *)AfxGetApp();
motoroverDlg.m_dMotorSpeed = m_dModlgoveSpeed;
motoroverDlg.m_dMotorTangle = 10;
motoroverDlg.m_nMotorDirectTem=m_cModlgoveDirect.GetCurSel();
//获取Radio Button 状态(即图形显示类型)
m_nModlgovePti = m_cModlgovePti.GetCheck();
//MessageBox("1");
m_nModlgoveSti = m_cModlgoveSti.GetCheck();
//MessageBox("1");
m_nModlgoveTti = m_cModlgoveTti.GetCheck();
if (m_nModlgovePti==1)
// MessageBox("1");
radionumber=1;
if (m_nModlgoveSti==1)
// MessageBox("2");
radionumber=2;
if (m_nModlgoveTti==1)
// MessageBox("3");
radionumber=3;
//MessageBox("1");
//向画图窗口发送消息
pApp->pCTestFormView->overDrawDlg.SendMessage(WM_MOTDLGOVERSTART_HIT,radionumber,1);
//发送消息给效率仪控制窗口
pApp->pPeDialogBase->powerDlg.SendMessage(WM_MOTDLGOVERSTART_HIT,0,0);
motoroverDlg.MotorRun();
}
else
MessageBox("请先进行设备自检和效率仪的串口设置操作");
}
//中止试验
void MotorDlgOver::OnBumodlgoveStop()
{
// TODO: Add your control notification handler code here
motoroverDlg.MotorStop();
}
//完成试验
void MotorDlgOver::OnBumodlgoveFinish()
{
// TODO: Add your control notification handler code here
motoroverDlg.MotorStop();
}
//编码器采集到了一个数据
void MotorDlgOver::OnCoderDaqOne(WPARAM wParam, LPARAM lParam)
{
motoroverDlg.MotorStop();
}
//打开数据响应函数
void MotorDlgOver::OnOpendata(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your control notification handler code here
//MessageBox("123");
CTestFormApp *pApp=(CTestFormApp *)AfxGetApp();
m_dModlgoveSpeed=pApp->pCTestFormDoc->motorRate; //获得转速
int direct=pApp->pCTestFormDoc->motorDirect; //获得转向
if(direct==-1)
m_cModlgoveDirect.SetCurSel(1); //初始化为反转
else
m_cModlgoveDirect.SetCurSel(0); //初始化为正转
UpdateData(FALSE); //更新主控窗口中的显示
//OnBumodlgpowInit();
//OnBumodlgpowStart();
}
//选择试验件效率-时间曲线
void MotorDlgOver::OnRamodlgovePti()
{
// TODO: Add your control notification handler code here
CTestFormApp *pApp=(CTestFormApp *)AfxGetApp();
//曲线类型为1
pApp->pCTestFormView->overDrawDlg.SendMessage(WM_DRAWTYPE_SELECT,1,0);
}
//选择试验件输出转速-时间曲线
void MotorDlgOver::OnRamodlgoveSti()
{
// TODO: Add your control notification handler code here
CTestFormApp *pApp=(CTestFormApp *)AfxGetApp();
//曲线类型为2
pApp->pCTestFormView->overDrawDlg.SendMessage(WM_DRAWTYPE_SELECT,2,0);
}
//选择试验件输出端所受扭矩-时间曲线
void MotorDlgOver::OnRamodlgoveTti()
{
// TODO: Add your control notification handler code here
CTestFormApp *pApp=(CTestFormApp *)AfxGetApp();
//曲线类型为3
pApp->pCTestFormView->overDrawDlg.SendMessage(WM_DRAWTYPE_SELECT,3,0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -