123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- // DialogCalTubeAngle.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "DIOS_3DDR_MechCal.h"
- #include "DialogCalTubeAngle.h"
- #include "afxdialogex.h"
- // CDialogCalTubeAngle 对话框
- IMPLEMENT_DYNAMIC(CDialogCalTubeAngle, CDialogEx)
- CDialogCalTubeAngle::CDialogCalTubeAngle(CWnd* pParent /*=NULL*/)
- : CDialogEx(CDialogCalTubeAngle::IDD, pParent)
- {
- }
- CDialogCalTubeAngle::~CDialogCalTubeAngle()
- {
- }
- void CDialogCalTubeAngle::DoDataExchange(CDataExchange* pDX)
- {
- CDialogEx::DoDataExchange(pDX);
- }
- BEGIN_MESSAGE_MAP(CDialogCalTubeAngle, CDialogEx)
- ON_BN_CLICKED(IDOK, &CDialogCalTubeAngle::OnBnClickedOk)
- ON_BN_CLICKED(IDC_BUTTON_STARTMOTION, &CDialogCalTubeAngle::OnBnClickedButtonStartmotion)
- ON_BN_CLICKED(IDC_BUTTON_READAD, &CDialogCalTubeAngle::OnBnClickedButtonReadad)
- ON_BN_CLICKED(IDC_BUTTON_FINDAXISZ, &CDialogCalTubeAngle::OnBnClickedButtonFindaxisz)
- END_MESSAGE_MAP()
- // CDialogCalTubeAngle 消息处理程序
- void CDialogCalTubeAngle::OnBnClickedOk()
- {
- // TODO: 在此添加控件通知处理程序代码
- ResDataObject Request;
- ResDataObject oTemp;
- ResDataObject Result;
- CString strKeyAngle;
- CString strKeyAD;
- CString strValueAngle;
- CString strValueAD;
- int nPointCount = 12;
- oTemp.add("PointCount", nPointCount);
- for (int i = 0; i < nPointCount; i++)
- {
- strKeyAngle.Format("Angle%d", i);
- strKeyAD.Format("AD%d", i);
- GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->GetWindowText(strValueAngle);
- GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->GetWindowText(strValueAD);
- int nAD = atoi(strValueAD);
- oTemp.add(strKeyAngle, strValueAngle);
- oTemp.add(strKeyAD, nAD);
- }
- Request.add("P0", oTemp);
- if (g_DiosAPIServer.ExecuteAction("CalSaveParamsofTubeAngle", Request, Result, 3000) == RET_SUCCEED)
- {
- string str = Result.encode();
- ResDataObject obj1;
- try
- {
- obj1 = Result["P0"];
- CString strSlope((const char*)obj1["Slope"]);
- CString strIntercept((const char*)obj1["Intercept"]);
- CString strText;
- strText.Format("Calibration succeed, Y = %s * X + (%s)", strSlope, strIntercept);
- AfxMessageBox(strText);
- }
- catch (ResDataObjectExption &exp)
- {
- printf("%s%s", exp.what(), "\\n");
- TPRINTA_ERROR(exp.what());
- }
- }
- }
- BOOL CDialogCalTubeAngle::OnInitDialog()
- {
- CDialogEx::OnInitDialog();
- // TODO: 在此添加额外的初始化
- CString str;
- for (int i = 0; i < 12; i++)
- {
- str.Format("角度 %d", i + 1);
- GetDlgItem(IDC_STATIC_HEIGHT1 + i)->SetWindowText(str);
- str.Format("A/D %d", i + 1);
- GetDlgItem(IDC_STATIC_AD1 + i)->SetWindowText(str);
- str.Format("%.2f", i * 2.5);
- GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->SetWindowText(str);
- str.Format("%d", (i + 1) * 1000);
- GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->SetWindowText(str);
- }
- ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBEANGLE_ORG)))->AddString("逆时针");
- ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBEANGLE_ORG)))->AddString("顺时针");
- ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBEANGLE_ORG)))->SetCurSel(0);
-
- return TRUE; // return TRUE unless you set the focus to a control
- // 异常: OCX 属性页应返回 FALSE
- }
- void CDialogCalTubeAngle::OnBnClickedButtonStartmotion()
- {
- // TODO: 在此添加控件通知处理程序代码
- int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBEANGLE_ORG)))->GetCurSel();
- CString strAngle;
- GetDlgItem(IDC_EDIT_TUBE_ANGLE)->GetWindowText(strAngle);
- float nAngle = (float)atof(strAngle);
- if (nAngle < 0.01f || nAngle > 20.0f)
- {
- AfxMessageBox("旋转角度范围应在0.01度至20度之间,请重新设置");
- return;
- }
- ResDataObject Request;
- ResDataObject oTemp;
- ResDataObject Result;
- oTemp.add("Orientation", nCurSel);
- oTemp.add("Angle", strAngle);
- Request.add("P0", oTemp);
- g_DiosAPIServer.ExecuteAction("CalMotionTubeAngleRotate", Request, Result, 3000);
- }
- void CDialogCalTubeAngle::OnBnClickedButtonReadad()
- {
- // TODO: 在此添加控件通知处理程序代码
- ResDataObject Request;
- ResDataObject oTemp;
- ResDataObject Result;
- Request.add("P0", oTemp);
- if (g_DiosAPIServer.ExecuteAction("CalGetADofTubeAngle", Request, Result, 3000) == RET_SUCCEED)
- {
- ResDataObject obj1;
- try
- {
- obj1 = Result["P0"];
- CString strText((const char*)obj1["ADTubeAngle"]);
- GetDlgItem(IDC_EDIT_TUBEANGLE_VALUEAD)->SetWindowText(strText);
- }
- catch (ResDataObjectExption &exp)
- {
- printf("%s%s", exp.what(), "\\n");
- TPRINTA_ERROR(exp.what());
- }
- }
- }
- void CDialogCalTubeAngle::OnBnClickedButtonFindaxisz()
- {
- // TODO: 在此添加控件通知处理程序代码
- ResDataObject Request;
- ResDataObject oTemp;
- ResDataObject Result;
- Request.add("P0", oTemp);
- g_DiosAPIServer.ExecuteAction("CalMotionTubeAngleFindeAxisZ", Request, Result, 30000);
- }
|