// DialogMotionTest.cpp : 实现文件 // #include "stdafx.h" #include "DIOS_3DDR_MechCal.h" #include "DialogMotionTest.h" #include "afxdialogex.h" #define EBUS_TIMEOUT 30000 // CDialogMotionTest 对话框 IMPLEMENT_DYNAMIC(CDialogMotionTest, CDialogEx) CDialogMotionTest::CDialogMotionTest(CWnd* pParent /*=NULL*/) : CDialogEx(CDialogMotionTest::IDD, pParent) { } CDialogMotionTest::~CDialogMotionTest() { } void CDialogMotionTest::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CDialogMotionTest, CDialogEx) ON_BN_CLICKED(IDC_BUTTON_STARTLINEMOTION, &CDialogMotionTest::OnBnClickedButtonStartlinemotion) ON_BN_CLICKED(IDC_BUTTON_TUBE_STOPLINEMOTION, &CDialogMotionTest::OnBnClickedButtonTubeStoplinemotion) ON_BN_CLICKED(IDC_BUTTON_TUBE_ROTATE, &CDialogMotionTest::OnBnClickedButtonTubeRotate) ON_BN_CLICKED(IDC_BUTTON_TUBE_STOPROTATION, &CDialogMotionTest::OnBnClickedButtonTubeStoprotation) ON_BN_CLICKED(IDC_BUTTON_TUBE_ENCODER, &CDialogMotionTest::OnBnClickedButtonTubeEncoder) ON_BN_CLICKED(IDC_BUTTON_TUBE_ENCODER_UNBIND, &CDialogMotionTest::OnBnClickedButtonTubeEncoderUnbind) ON_BN_CLICKED(IDC_BUTTON_RESET, &CDialogMotionTest::OnBnClickedButtonReset) ON_BN_CLICKED(IDC_BUTTON_CENTER_ALIGN, &CDialogMotionTest::OnBnClickedButtonCenterAlign) ON_BN_CLICKED(IDC_BUTTON_STOPMOTION, &CDialogMotionTest::OnBnClickedButtonStopmotion) ON_BN_CLICKED(IDC_BUTTON_SET_PARAMS, &CDialogMotionTest::OnBnClickedButtonSetParams) ON_BN_CLICKED(IDC_BUTTON_MOVE2PARKINGPOSITION, &CDialogMotionTest::OnBnClickedButtonMove2parkingposition) END_MESSAGE_MAP() // CDialogMotionTest 消息处理程序 BOOL CDialogMotionTest::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 在此添加额外的初始化 ((CComboBox*)(GetDlgItem(IDC_COMBO_EXAM_MODE)))->AddString("DR"); ((CComboBox*)(GetDlgItem(IDC_COMBO_EXAM_MODE)))->AddString("TOMO"); ((CComboBox*)(GetDlgItem(IDC_COMBO_EXAM_MODE)))->SetCurSel(0); ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("10000"); ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("11000"); ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("20001"); ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("20003"); ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("20005"); ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->SetCurSel(0); ((CEdit*)GetDlgItem(IDC_EDIT_SID))->SetWindowText("120"); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CDialogMotionTest::OnBnClickedButtonStartlinemotion() { // TODO: 在此添加控件通知处理程序代码 //int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG2)))->GetCurSel(); CString strTargetHeight; GetDlgItem(IDC_EDIT_TUBELINEV_TARGETHEIGHT)->GetWindowText(strTargetHeight); //float fTargetHeight = atof(strTargetHeight); ResDataObject Request; ResDataObject oTemp; ResDataObject Result; //oTemp.add("Orientation", nCurSel); oTemp.add("TargeHeight", strTargetHeight); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MotionTest_StartTubeLineVMotion2Target", Request, Result, EBUS_TIMEOUT); } void CDialogMotionTest::OnBnClickedButtonTubeStoplinemotion() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MotionTest_StopLineVMotion", Request, Result, EBUS_TIMEOUT); } void CDialogMotionTest::OnBnClickedButtonTubeRotate() { // TODO: 在此添加控件通知处理程序代码 //int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBEANGLE_ORG)))->GetCurSel(); CString strAngle; GetDlgItem(IDC_EDIT_TUBE_TARGETANGLE)->GetWindowText(strAngle); float nAngle = (float)atof(strAngle); if (nAngle < -90.0 || nAngle > 60.0) { AfxMessageBox("旋转角度范围应在-90度至+60度之间,请重新设置"); return; } ResDataObject Request; ResDataObject oTemp; ResDataObject Result; //oTemp.add("Orientation", nCurSel); oTemp.add("TargetAngle", strAngle); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MotionTest_TubeAngleRotate2Target", Request, Result, EBUS_TIMEOUT); } void CDialogMotionTest::OnBnClickedButtonTubeStoprotation() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MotionTest_StopRotation", Request, Result, EBUS_TIMEOUT); } void CDialogMotionTest::OnBnClickedButtonTubeEncoder() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MotionTest_BindRotationEncoder", Request, Result, EBUS_TIMEOUT); } void CDialogMotionTest::OnBnClickedButtonTubeEncoderUnbind() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MotionTest_UnbindRotationEncoder", Request, Result, EBUS_TIMEOUT); } void CDialogMotionTest::OnBnClickedButtonReset() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MotionTest_SystemInitial", Request, Result, EBUS_TIMEOUT); } void CDialogMotionTest::OnBnClickedButtonCenterAlign() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MotionTest_TubeCenterAlign", Request, Result, EBUS_TIMEOUT); } void CDialogMotionTest::OnBnClickedButtonStopmotion() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("StopMech", Request, Result, EBUS_TIMEOUT); } void CDialogMotionTest::SetExamMode(int nMode) { ResDataObject Request; ResDataObject Result; ResDataObject ExamDR; ResDataObject ExamTomo; //"RF":"Tomo" : "1" ResDataObject ExamInfo; ExamDR.add("Single", "1"); ExamTomo.add("TOMO", "1"); if (nMode == 0) { ExamInfo.add("DX", ExamDR); } else if (nMode == 1) { ExamInfo.add("DX", ExamTomo); } Request.add("P0", ExamInfo); if (g_DiosAPIServer.ExecuteAction("SetExamInfo", Request, Result, EBUS_TIMEOUT)) { printf("SetExamInfo Action Failed\n"); } else { printf("SetExamInfo Action Succeed\n"); } Request.clear(); Result.clear(); Request.add("P0", "DX"); if (g_DiosAPIServer.ExecuteAction("SelectExamMode", Request, Result, 30000) < RET_SUCCEED) { printf("SelectExamMode Action Failed\n"); } else { printf("SelectExamMode Action Succeed\n"); } //Request.clear(); Result.clear(); //if (g_DiosAPIServer.ExecuteAction("FramePrep", Request, Result, 30000) < RET_SUCCEED) //{ // printf("FramePrep Action Failed\n"); //} //else //{ // printf("FramePrep Action Succeed\n"); //} //Request.clear(); Result.clear(); //if (g_DiosAPIServer.ExecuteAction("FrameReady", Request, Result, 30000) < RET_SUCCEED) //{ // printf("FrameReady Action Failed\n"); //} //else //{ // printf("FrameReady Action Succeed\n"); //} } //void CDialogMotionTest::OnBnClickedButtonTomo() //{ // // TODO: 在此添加控件通知处理程序代码 // SetExamMode(1); //} // // //void CDialogMotionTest::OnBnClickedButton2d() //{ // // TODO: 在此添加控件通知处理程序代码 // SetExamMode(0); //} void CDialogMotionTest::OnBnClickedButtonSetParams() { // TODO: 在此添加控件通知处理程序代码 int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_EXAM_MODE)))->GetCurSel(); SetExamMode(nCurSel); ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString strPositionCode; nCurSel = ((CComboBox*)GetDlgItem(IDC_COMBO_POSITIONCODE))->GetCurSel(); ((CComboBox*)GetDlgItem(IDC_COMBO_POSITIONCODE))->GetLBText(nCurSel, strPositionCode); CString strSID; ((CEdit*)GetDlgItem(IDC_EDIT_SID))->GetWindowText(strSID); oTemp.add("SID", strSID); oTemp.add("PositionNumber", strPositionCode); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("SetTechParamsInfo", Request, Result, EBUS_TIMEOUT); Request.clear(); Result.clear(); if (g_DiosAPIServer.ExecuteAction("FramePrep", Request, Result, 30000) < RET_SUCCEED) { printf("FramePrep Action Failed\n"); } else { printf("FramePrep Action Succeed\n"); } Request.clear(); Result.clear(); if (g_DiosAPIServer.ExecuteAction("FrameReady", Request, Result, 30000) < RET_SUCCEED) { printf("FrameReady Action Failed\n"); } else { printf("FrameReady Action Succeed\n"); } } void CDialogMotionTest::OnBnClickedButtonMove2parkingposition() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("TargetAngle", "0.8"); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MotionTest_Move2ParkingPosition", Request, Result, EBUS_TIMEOUT); }