// DialogCalDetector.cpp : 实现文件 // #include "stdafx.h" #include "DIOS_3DDR_MechCal.h" #include "DialogCalDetector.h" #include "afxdialogex.h" // CDialogCalDetector 对话框 IMPLEMENT_DYNAMIC(CDialogCalDetector, CDialogEx) CDialogCalDetector::CDialogCalDetector(CWnd* pParent /*=NULL*/) : CDialogEx(CDialogCalDetector::IDD, pParent) { } CDialogCalDetector::~CDialogCalDetector() { } void CDialogCalDetector::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); } BEGIN_MESSAGE_MAP(CDialogCalDetector, CDialogEx) ON_BN_CLICKED(IDOK, &CDialogCalDetector::OnBnClickedOk) ON_BN_CLICKED(IDC_BUTTON_READAD, &CDialogCalDetector::OnBnClickedButtonReadad) END_MESSAGE_MAP() // CDialogCalDetector 消息处理程序 BOOL CDialogCalDetector::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 * 1.5); GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->SetWindowText(str); str.Format("%d", (i + 1) * 1000); GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->SetWindowText(str); } return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE } void CDialogCalDetector::OnBnClickedButtonReadad() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetADofDetector", Request, Result, 3000) == RET_SUCCEED) { ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["ADDetector"]); GetDlgItem(IDC_EDIT_DETECTOR_VALUEAD)->SetWindowText(strText); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogCalDetector::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("CalSaveParamsofDetector", 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()); } } }