123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- // 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());
- }
- }
- }
|