// CalTubeLineV.cpp : 实现文件 // #include "stdafx.h" #include "DIOS_3DDR_MechCal.h" #include "DialogCalTubeLineV.h" #include "afxdialogex.h" // CDialogCalTubeLineV 对话框 IMPLEMENT_DYNAMIC(CDialogCalTubeLineV, CDialogEx) CDialogCalTubeLineV::CDialogCalTubeLineV(CWnd* pParent /*=NULL*/) : CDialogEx(CDialogCalTubeLineV::IDD, pParent) { } CDialogCalTubeLineV::~CDialogCalTubeLineV() { } void CDialogCalTubeLineV::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CDialogCalTubeLineV, CDialogEx) ON_BN_CLICKED(IDOK, &CDialogCalTubeLineV::OnBnClickedOk) ON_BN_CLICKED(IDC_BUTTON_STARTMOTION, &CDialogCalTubeLineV::OnBnClickedButtonStartmotion) ON_BN_CLICKED(IDC_BUTTON_READAD, &CDialogCalTubeLineV::OnBnClickedButtonReadad) END_MESSAGE_MAP() // CDialogCalTubeLineV 消息处理程序 BOOL CDialogCalTubeLineV::OnInitDialog() { CDialogEx::OnInitDialog(); // TODO: 在此添加额外的初始化 CString strHeight[12] = { "0.895", "0.796", "0.697", "0.997", "1.09", "1.159", "1.222", "1.287", "1.357", "1.422", "1.492", "1.555" }; CString strAD[12] = { "1540", "1350", "1158", "1731", "1919", "2044", "2169", "2259", "2421", "2545", "2672", "2798" }; 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("%d", i+1); GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->SetWindowText(strHeight[i]); str.Format("%d", (i + 1) * 1000); GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->SetWindowText(strAD[i]); } ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->AddString("下"); ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->AddString("上"); ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->SetCurSel(0); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CDialogCalTubeLineV::OnBnClickedButtonStartmotion() { // TODO: 在此添加控件通知处理程序代码 int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->GetCurSel(); CString strStep; GetDlgItem(IDC_EDIT_TUBELINEV_STEP)->GetWindowText(strStep); int nStep = atoi(strStep); ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("Orientation", nCurSel); oTemp.add("StepNumber", nStep); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("CalMotionTubeLineV", Request, Result, 3000); } void CDialogCalTubeLineV::OnBnClickedButtonReadad() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetADofTubeLineV", Request, Result, 30000) == RET_SUCCEED) { string str = Result.encode(); ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["ADTubeLineV"]); GetDlgItem(IDC_EDIT_TUBELINEV_VALUEAD)->SetWindowText(strText); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogCalTubeLineV::OnBnClickedOk() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString strKeyHeight; CString strKeyAD; CString strValueHeight; CString strValueAD; int nPointCount = 12; oTemp.add("PointCount", nPointCount); for (int i = 0; i < nPointCount; i++) { strKeyHeight.Format("Height%d", i); strKeyAD.Format("AD%d", i); GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->GetWindowText(strValueHeight); GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->GetWindowText(strValueAD); int nAD = atoi(strValueAD); oTemp.add(strKeyHeight, strValueHeight); oTemp.add(strKeyAD, nAD); } Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalSaveParamsofTubeLiveV", 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()); } } }