
// CrdMoveDlg.cpp: 实现文件
//

#include "pch.h"
#include "framework.h"
#include "插补运动.h"
#include "CrdMoveDlg.h"
#include "afxdialogex.h"
#include"MC_dll.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// 用于应用程序“关于”菜单项的 CAboutDlg 对话框

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

// 对话框数据
#ifdef AFX_DESIGN_TIME
	enum { IDD = IDD_ABOUTBOX };
#endif

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

// 实现
protected:
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialogEx(IDD_ABOUTBOX)
{
}

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

BEGIN_MESSAGE_MAP(CAboutDlg, CDialogEx)
END_MESSAGE_MAP()


// CCrdMoveDlg 对话框



CCrdMoveDlg::CCrdMoveDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_MY_DIALOG, pParent)
{
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
	StartVel = 500;
	MaxVel = 2000;
	StopVel = 500;
	TAcc = 0.1;
	TDec = 0.1;
	STime = 0;

	xAxisTargetPos = 10000;
	yAxisTargetPos = 0;
	zAxisTargetPos = 0;

	xAxisCenPos = 5000;
	yAxisCenPos = 0;
	zAxisCenPos = 0;

	ArcCCircle = 1;
	ArcRCircle = 1;
	ArcRRadius = 500;
	Arc3PXAxis = 5000;
	Arc3PYAxis = 5000;
	Arc3PZAxis = 0;
	Arc3PCircle = 1;

	SpaceArcCCircle = 1;
	SpaceArc3PXAxis = 5000;
	SpaceArc3PYAxis = 5000;
	SpaceArc3PZAxis = 0;
	SpaceArc3PCircle = 1;
	ellipseLongLen = 10000;
	ellipseShortLen = 6000;
	ellipseCircle = 1;
}

void CCrdMoveDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
	DDX_Text(pDX, IDC_EDIT1, StartVel);
	DDX_Text(pDX, IDC_EDIT2, MaxVel);
	DDX_Text(pDX, IDC_EDIT3, StopVel);
	DDX_Text(pDX, IDC_EDIT4, TAcc);
	DDX_Text(pDX, IDC_EDIT5, TDec);
	DDX_Text(pDX, IDC_EDIT6, STime);
	DDX_Control(pDX, IDC_COMBO1, Crd_CB);
	DDX_Control(pDX, IDC_COMBO2, xAxis);
	DDX_Control(pDX, IDC_COMBO3, yAxis);
	DDX_Control(pDX, IDC_COMBO4, zAxis);
	DDX_Text(pDX, IDC_EDIT7, xAxisTargetPos);
	DDX_Text(pDX, IDC_EDIT8, yAxisTargetPos);
	DDX_Text(pDX, IDC_EDIT9, zAxisTargetPos);
	DDX_Text(pDX, IDC_EDIT10, xAxisCenPos);
	DDX_Text(pDX, IDC_EDIT11, yAxisCenPos);
	DDX_Text(pDX, IDC_EDIT12, zAxisCenPos);
	DDX_Text(pDX, IDC_EDIT22, ArcCCircle);
	DDX_Text(pDX, IDC_EDIT23, ArcRCircle);
	DDX_Text(pDX, IDC_EDIT24, ArcRRadius);
	DDX_Text(pDX, IDC_EDIT25, Arc3PXAxis);
	DDX_Text(pDX, IDC_EDIT26, Arc3PYAxis);
	DDX_Text(pDX, IDC_EDIT27, Arc3PZAxis);
	DDX_Text(pDX, IDC_EDIT28, Arc3PCircle);
	DDX_Text(pDX, IDC_EDIT29, SpaceArcCCircle);
	DDX_Text(pDX, IDC_EDIT30, SpaceArc3PXAxis);
	DDX_Text(pDX, IDC_EDIT31, SpaceArc3PYAxis);
	DDX_Text(pDX, IDC_EDIT32, SpaceArc3PZAxis);
	DDX_Text(pDX, IDC_EDIT33, SpaceArc3PCircle);
	DDX_Text(pDX, IDC_EDIT35, ellipseLongLen);
	DDX_Text(pDX, IDC_EDIT36, ellipseShortLen);
	DDX_Text(pDX, IDC_EDIT34, ellipseCircle);
	DDX_Control(pDX, IDC_STATIC_AXISGB, axis0GroupBox);
	DDX_Control(pDX, IDC_STATIC_AXISGB2, axis1GroupBox);
	DDX_Control(pDX, IDC_STATIC_AXISGB3, axis2GroupBox);
}

BEGIN_MESSAGE_MAP(CCrdMoveDlg, CDialogEx)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_DESTROY()
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON1, &CCrdMoveDlg::OnBnClickedButton1)
	ON_BN_CLICKED(IDC_BUTTON2, &CCrdMoveDlg::OnBnClickedButton2)
	ON_BN_CLICKED(IDC_BUTTON3, &CCrdMoveDlg::OnBnClickedButton3)
	ON_BN_CLICKED(IDC_BUTTON4, &CCrdMoveDlg::OnBnClickedButton4)
	ON_BN_CLICKED(IDC_BUTTON5, &CCrdMoveDlg::OnBnClickedButton5)
	ON_BN_CLICKED(IDC_BUTTON6, &CCrdMoveDlg::OnBnClickedButton6)
	ON_BN_CLICKED(IDC_BUTTON7, &CCrdMoveDlg::OnBnClickedButton7)
	ON_BN_CLICKED(IDC_BUTTON8, &CCrdMoveDlg::OnBnClickedButton8)
	ON_BN_CLICKED(IDC_BUTTON9, &CCrdMoveDlg::OnBnClickedButton9)
	ON_BN_CLICKED(IDC_BUTTON10, &CCrdMoveDlg::OnBnClickedButton10)
END_MESSAGE_MAP()


// CCrdMoveDlg 消息处理程序

BOOL CCrdMoveDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// 将“关于...”菜单项添加到系统菜单中。

	// IDM_ABOUTBOX 必须在系统命令范围内。
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

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

	// 设置此对话框的图标。  当应用程序主窗口不是对话框时，框架将自动
	//  执行此操作
	SetIcon(m_hIcon, TRUE);			// 设置大图标
	SetIcon(m_hIcon, FALSE);		// 设置小图标

	// TODO: 在此添加额外的初始化代码
	FormInit();

#pragma region 开卡
	WORD pciNum = 0; //用于接收开卡成功的卡数
	WORD pcieIndex[12];
	DWORD functionReturn = 0; //函数返回值

	functionReturn = MC_Open(0, CONNECTION_PCI, "", &pciNum, pcieIndex);
	if (functionReturn == 0)//函数成功执行
	{
		if (pciNum > 0)//至少一张卡被成功开卡
		{
			cardConnectNo = pcieIndex[0]; //如果有多卡的情况下这里也只用卡1演示

#pragma region 获取卡信息
			//--------------------------获取卡信息------------------------------------------------------------------------
			WORD totalAxisNum = 0; //用于获取卡的轴数
			WORD linerNum = 0;//用于获取卡的插补系个数
			WORD totalInNum = 0;//用于获取卡的输入口数量
			WORD totalOutNum = 0;//用于获取卡的输出口数量
			WORD totalPWMNum = 0;//用于获取卡的PWM通道数量
			functionReturn = MC_GetTotalAxesAndIONum(cardConnectNo, &totalAxisNum, &linerNum, &totalInNum, &totalOutNum, &totalPWMNum);

			//------------------------------------------------------------------------------------------------------------
#pragma endregion


			SetTimer(1, 200, NULL);//启动界面监控定时器

		}
		else
		{
			MessageBox(L"未找到卡!");
		}
	}
	else
	{
		MessageBox(L"开卡失败!");
	}
#pragma endregion

	return TRUE;  // 除非将焦点设置到控件，否则返回 TRUE
}

/// <summary>
/// 窗体界面初始化
/// </summary>
void CCrdMoveDlg::FormInit()
{
	Crd_CB.InsertString(0,L"0");
	Crd_CB.InsertString(1, L"1");
	Crd_CB.InsertString(2, L"2");
	Crd_CB.InsertString(3, L"3");
	Crd_CB.SetCurSel(0); //插补系

	for (int _axisNo = 0; _axisNo < 12; _axisNo++)
	{
		CString str;
		str.Format(_T("轴%d"), _axisNo);
		xAxis.InsertString(_axisNo, str);
		yAxis.InsertString(_axisNo, str);
		zAxis.InsertString(_axisNo, str);
	}
	xAxis.SetCurSel(0);
	yAxis.SetCurSel(1);
	zAxis.SetCurSel(2); //轴号

	((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(TRUE);//运动模式的相对运动默认选择
	((CButton*)GetDlgItem(IDC_RADIO3))->SetCheck(TRUE);//终点圆心的圆弧插补圆弧插补方向顺时针默认选择
	((CButton*)GetDlgItem(IDC_RADIO5))->SetCheck(TRUE);//终点半径的圆弧插补优弧默认选择
	((CButton*)GetDlgItem(IDC_RADIO7))->SetCheck(TRUE);//终点圆心的空间圆弧插补插补方向顺时针默认选择
	((CButton*)GetDlgItem(IDC_RADIO9))->SetCheck(TRUE);//椭圆插补的插补方向顺时针默认选择


}

/// <summary>
/// 根据界面数据设置运动参数
/// </summary>
/// <param name="_crdNo"></param>
void CCrdMoveDlg::SetMotionPrm(WORD _crdNo)
{
	//运动轴运动前要使能
	UpdateData(true);

	WORD axis0 = xAxis.GetCurSel();
	WORD axis1 = yAxis.GetCurSel();
	WORD axis2 = zAxis.GetCurSel();	

	CString str;
	str.Format(L"轴%d", axis0);
	axis0GroupBox.SetWindowTextW(str);

	str.Format(L"轴%d", axis1);
	axis1GroupBox.SetWindowTextW(str);

	str.Format(L"轴%d", axis2);
	axis2GroupBox.SetWindowTextW(str);

	MC_Power(cardConnectNo, axis0, 1); //使能运动轴
	MC_Power(cardConnectNo, axis1, 1);
	MC_Power(cardConnectNo, axis2, 1);

	MC_SetCrdMotionPrm(cardConnectNo, //设置运动参数
		_crdNo,
		StartVel,
		MaxVel,
		StopVel,
		TAcc,
		TDec,
		STime,
		10000000);
}

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

// 如果向对话框添加最小化按钮，则需要下面的代码
//  来绘制该图标。  对于使用文档/视图模型的 MFC 应用程序，
//  这将由框架自动完成。

void CCrdMoveDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // 用于绘制的设备上下文

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

		// 使图标在工作区矩形中居中
		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;

		// 绘制图标
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialogEx::OnPaint();
	}
}

//当用户拖动最小化窗口时系统调用此函数取得光标
//显示。
HCURSOR CCrdMoveDlg::OnQueryDragIcon()
{
	return static_cast<HCURSOR>(m_hIcon);
}


/// <summary>
/// 界面销毁时执行
/// </summary>
void CCrdMoveDlg::OnDestroy()
{
	CDialogEx::OnDestroy();

	// TODO: 在此处添加消息处理程序代码
	KillTimer(1);
	MC_Close(cardConnectNo); //关卡释放资源
}


/// <summary>
/// 用于更新界面的定时器
/// </summary>
/// <param name="nIDEvent"></param>
void CCrdMoveDlg::OnTimer(UINT_PTR nIDEvent)
{
	// TODO: 在此添加消息处理程序代码和/或调用默认值

	WORD _axis0 = xAxis.GetCurSel();
	double cmdPos = 0;
	MC_GetAxisCmdPos(cardConnectNo, _axis0, &cmdPos);//获取当前指令位置
	CString cmdPosStr;
	cmdPosStr.Format(_T("%f"), cmdPos);
	GetDlgItem(IDC_EDIT14)->SetWindowTextW(cmdPosStr);

	double cmdSpeed = 0;
	MC_GetAxisCmdSpeed(cardConnectNo, _axis0, &cmdSpeed); //获取当前指令速度
	CString cmdSpeedStr;
	cmdSpeedStr.Format(_T("%f"), cmdSpeed);
	GetDlgItem(IDC_EDIT13)->SetWindowTextW(cmdSpeedStr);

	WORD checkDone = 1;
	MC_GetAxisCheckDone(cardConnectNo, _axis0, &checkDone);//获取轴运动状态
	switch (checkDone)
	{
	case 0:
		GetDlgItem(IDC_EDIT15)->SetWindowTextW(L"运动中");
		break;
	case 1:
		GetDlgItem(IDC_EDIT15)->SetWindowTextW(L"空闲");
		break;
	default:
		CString checkDoneStr;
		checkDoneStr.Format(_T("%d"), checkDone);
		GetDlgItem(IDC_EDIT15)->SetWindowTextW(checkDoneStr);
		break;
	}

	WORD _axis1 = yAxis.GetCurSel();
	MC_GetAxisCmdPos(cardConnectNo, _axis1, &cmdPos);//获取当前指令位置
	cmdPosStr.Format(_T("%f"), cmdPos);
	GetDlgItem(IDC_EDIT17)->SetWindowTextW(cmdPosStr);

	MC_GetAxisCmdSpeed(cardConnectNo, _axis1, &cmdSpeed); //获取当前指令速度
	cmdSpeedStr.Format(_T("%f"), cmdSpeed);
	GetDlgItem(IDC_EDIT16)->SetWindowTextW(cmdSpeedStr);

	MC_GetAxisCheckDone(cardConnectNo, _axis1, &checkDone);//获取轴运动状态
	switch (checkDone)
	{
	case 0:
		GetDlgItem(IDC_EDIT18)->SetWindowTextW(L"运动中");
		break;
	case 1:
		GetDlgItem(IDC_EDIT18)->SetWindowTextW(L"空闲");
		break;
	default:
		CString checkDoneStr;
		checkDoneStr.Format(_T("%d"), checkDone);
		GetDlgItem(IDC_EDIT18)->SetWindowTextW(checkDoneStr);
		break;
	}

	WORD _axis2 = zAxis.GetCurSel();
	MC_GetAxisCmdPos(cardConnectNo, _axis2, &cmdPos);//获取当前指令位置
	cmdPosStr.Format(_T("%f"), cmdPos);
	GetDlgItem(IDC_EDIT20)->SetWindowTextW(cmdPosStr);

	MC_GetAxisCmdSpeed(cardConnectNo, _axis2, &cmdSpeed); //获取当前指令速度
	cmdSpeedStr.Format(_T("%f"), cmdSpeed);
	GetDlgItem(IDC_EDIT19)->SetWindowTextW(cmdSpeedStr);

	MC_GetAxisCheckDone(cardConnectNo, _axis2, &checkDone);//获取轴运动状态
	switch (checkDone)
	{
	case 0:
		GetDlgItem(IDC_EDIT21)->SetWindowTextW(L"运动中");
		break;
	case 1:
		GetDlgItem(IDC_EDIT21)->SetWindowTextW(L"空闲");
		break;
	default:
		CString checkDoneStr;
		checkDoneStr.Format(_T("%d"), checkDone);
		GetDlgItem(IDC_EDIT21)->SetWindowTextW(checkDoneStr);
		break;
	}

	CDialogEx::OnTimer(nIDEvent);
}

/// <summary>
/// 位置清除按钮点击
/// </summary>
void CCrdMoveDlg::OnBnClickedButton1()
{
	// TODO: 在此添加控件通知处理程序代码
	WORD axis0 = xAxis.GetCurSel();
	WORD axis1 = yAxis.GetCurSel();
	WORD axis2 = zAxis.GetCurSel();

	//指令位置清零
	MC_SetAxisCmdPos(cardConnectNo, axis0, 0);
	MC_SetAxisCmdPos(cardConnectNo, axis1, 0);
	MC_SetAxisCmdPos(cardConnectNo, axis2, 0);
}

/// <summary>
/// 直线插补运动启动
/// </summary>
void CCrdMoveDlg::OnBnClickedButton2()
{
	// TODO: 在此添加控件通知处理程序代码
	WORD CrdNo = Crd_CB.GetCurSel();
	SetMotionPrm(CrdNo);
	WORD crdMode = 0; //相对运动
	if (((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck() == 1) crdMode = 1; //绝对运动

	WORD axisList[3] = {xAxis.GetCurSel(),
	yAxis.GetCurSel(),
	zAxis.GetCurSel() };

	double distList[3] = { xAxisTargetPos,
		yAxisTargetPos,
		zAxisTargetPos };

	MC_MoveLinear(cardConnectNo, CrdNo, 3, axisList, distList, crdMode); //启动运动
}

/// <summary>
/// 终点圆心的圆弧插补
/// </summary>
void CCrdMoveDlg::OnBnClickedButton3()
{
	// TODO: 在此添加控件通知处理程序代码
	WORD CrdNo = Crd_CB.GetCurSel();
	SetMotionPrm(CrdNo);
	WORD crdMode = 0; //相对运动
	if (((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck() == 1) crdMode = 1; //绝对运动

	WORD arcDir = 0; //圆弧插补方向，顺时针
	if (((CButton*)GetDlgItem(IDC_RADIO4))->GetCheck() == 1) arcDir = 1;

	DWORD cirCle = ArcCCircle;

	WORD axisList[3] = { xAxis.GetCurSel(),
	yAxis.GetCurSel(),
	zAxis.GetCurSel() };

	double distList[3] = { xAxisTargetPos,
		yAxisTargetPos,
		zAxisTargetPos };

	double cenList[3] = { xAxisCenPos,
		yAxisCenPos,
		zAxisCenPos };

	//启动运动
	MC_MovePlaneArcC(cardConnectNo, CrdNo, 3, axisList, distList, cenList, arcDir, cirCle, crdMode);
}

/// <summary>
/// 终点半径的圆弧插补
/// </summary>
void CCrdMoveDlg::OnBnClickedButton4()
{
	// TODO: 在此添加控件通知处理程序代码
	WORD CrdNo = Crd_CB.GetCurSel();
	SetMotionPrm(CrdNo);
	WORD crdMode = 0; //相对运动
	if (((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck() == 1) crdMode = 1; //绝对运动

	WORD arcDir = 0; //圆弧，0 = 劣弧
	if (((CButton*)GetDlgItem(IDC_RADIO6))->GetCheck() == 1) arcDir = 1; //优弧

	double arcRadius = ArcRRadius;

	DWORD cirCle = ArcRCircle;

	WORD axisList[3] = { xAxis.GetCurSel(),
	yAxis.GetCurSel(),
	zAxis.GetCurSel() };

	double distList[3] = { xAxisTargetPos,
		yAxisTargetPos,
		zAxisTargetPos };

	MC_MovePlaneArcR(cardConnectNo, CrdNo, 3, axisList, distList, arcRadius, arcDir, cirCle, crdMode);
}

/// <summary>
/// 三点圆弧插补
/// </summary>
void CCrdMoveDlg::OnBnClickedButton5()
{
	// TODO: 在此添加控件通知处理程序代码
	WORD CrdNo = Crd_CB.GetCurSel();
	SetMotionPrm(CrdNo);
	WORD crdMode = 0; //相对运动
	if (((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck() == 1) crdMode = 1; //绝对运动

	DWORD cirCle = Arc3PCircle; //插补圈数

	WORD axisList[3] = { xAxis.GetCurSel(),
	yAxis.GetCurSel(),
	zAxis.GetCurSel() };

	double distList[3] = { xAxisTargetPos,
		yAxisTargetPos,
		zAxisTargetPos };

	double midPos[3] = { Arc3PXAxis,
		Arc3PYAxis,
		Arc3PZAxis };

	//三点圆弧插补
	MC_MovePlaneArc3P(cardConnectNo, CrdNo, 3, axisList, distList, midPos, cirCle, crdMode);
}

/// <summary>
/// 终点圆心的空间圆弧插补
/// </summary>
void CCrdMoveDlg::OnBnClickedButton6()
{
	// TODO: 在此添加控件通知处理程序代码
	WORD CrdNo = Crd_CB.GetCurSel();
	SetMotionPrm(CrdNo);
	WORD crdMode = 0; //相对运动
	if (((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck() == 1) crdMode = 1; //绝对运动

	DWORD cirCle = SpaceArcCCircle; //插补圈数

	WORD arcDir = 0; //默认方向为顺时针
	if (((CButton*)GetDlgItem(IDC_RADIO8))->GetCheck() == 1) arcDir = 1;

	WORD axisList[3] = { xAxis.GetCurSel(),
	yAxis.GetCurSel(),
	zAxis.GetCurSel() };

	double distList[3] = { xAxisTargetPos,
		yAxisTargetPos,
		zAxisTargetPos };

	double cenList[3] = { xAxisCenPos,
		yAxisCenPos,
		zAxisCenPos };

	MC_MoveSpaceArcC(cardConnectNo, CrdNo, 3, axisList, distList, cenList, arcDir, cirCle, crdMode);
}

/// <summary>
/// 三点圆弧空间插补
/// </summary>
void CCrdMoveDlg::OnBnClickedButton7()
{
	// TODO: 在此添加控件通知处理程序代码
	WORD CrdNo = Crd_CB.GetCurSel();
	SetMotionPrm(CrdNo);
	WORD crdMode = 0; //相对运动
	if (((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck() == 1) crdMode = 1; //绝对运动

	DWORD cirCle = SpaceArc3PCircle; //插补圈数

	WORD axisList[3] = { xAxis.GetCurSel(),
	yAxis.GetCurSel(),
	zAxis.GetCurSel() };

	double distList[3] = { xAxisTargetPos,
		yAxisTargetPos,
		zAxisTargetPos };

	double midposList[3] = { SpaceArc3PXAxis,
		SpaceArc3PYAxis,
		SpaceArc3PZAxis };

	MC_MoveSpaceArc3P(cardConnectNo, CrdNo, 3, axisList, distList, midposList, cirCle, crdMode);
}

/// <summary>
/// 椭圆插补
/// </summary>
void CCrdMoveDlg::OnBnClickedButton8()
{
	// TODO: 在此添加控件通知处理程序代码
	WORD CrdNo = Crd_CB.GetCurSel();
	SetMotionPrm(CrdNo);
	WORD crdMode = 0; //相对运动
	if (((CButton*)GetDlgItem(IDC_RADIO2))->GetCheck() == 1) crdMode = 1; //绝对运动

	DWORD cirCle = ellipseCircle; //插补圈数

	WORD arcDir = 0; //插补方向默认为顺时针
	if (((CButton*)GetDlgItem(IDC_RADIO10))->GetCheck() == 1) arcDir = 1;

	WORD axisList[3] = { xAxis.GetCurSel(),
	yAxis.GetCurSel(),
	zAxis.GetCurSel() };

	double distList[3] = { xAxisTargetPos,
		yAxisTargetPos,
		zAxisTargetPos };

	double cenList[3] = { xAxisCenPos,
		yAxisCenPos,
		zAxisCenPos };

	double longLength = ellipseLongLen; //椭圆长轴
	double shortLength = ellipseShortLen; //椭圆短轴

	MC_MovePlaneEllipse(cardConnectNo, CrdNo, 3, axisList, distList, cenList, shortLength, longLength, arcDir, cirCle, crdMode);
}

/// <summary>
/// 停止插补系的运动，减速停止
/// </summary>
void CCrdMoveDlg::OnBnClickedButton9()
{
	// TODO: 在此添加控件通知处理程序代码
	WORD CrdNo = Crd_CB.GetCurSel();

	//减速停
	MC_StopCrd(cardConnectNo,
		CrdNo,
		0,
		TDec);
}

/// <summary>
/// 急停所有轴的运动
/// </summary>
void CCrdMoveDlg::OnBnClickedButton10()
{
	// TODO: 在此添加控件通知处理程序代码
	//所有轴急停
	MC_StopEmgImd(cardConnectNo);
}
