DialogCalDetector.cpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // DialogCalDetector.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "DIOS_3DDR_MechCal.h"
  5. #include "DialogCalDetector.h"
  6. #include "afxdialogex.h"
  7. // CDialogCalDetector 对话框
  8. IMPLEMENT_DYNAMIC(CDialogCalDetector, CDialogEx)
  9. CDialogCalDetector::CDialogCalDetector(CWnd* pParent /*=NULL*/)
  10. : CDialogEx(CDialogCalDetector::IDD, pParent)
  11. {
  12. }
  13. CDialogCalDetector::~CDialogCalDetector()
  14. {
  15. }
  16. void CDialogCalDetector::DoDataExchange(CDataExchange* pDX)
  17. {
  18. CDialogEx::DoDataExchange(pDX);
  19. }
  20. BEGIN_MESSAGE_MAP(CDialogCalDetector, CDialogEx)
  21. ON_BN_CLICKED(IDOK, &CDialogCalDetector::OnBnClickedOk)
  22. ON_BN_CLICKED(IDC_BUTTON_READAD, &CDialogCalDetector::OnBnClickedButtonReadad)
  23. END_MESSAGE_MAP()
  24. // CDialogCalDetector 消息处理程序
  25. BOOL CDialogCalDetector::OnInitDialog()
  26. {
  27. CDialogEx::OnInitDialog();
  28. // TODO: 在此添加额外的初始化
  29. CString str;
  30. for (int i = 0; i < 12; i++)
  31. {
  32. str.Format("高度 %d", i + 1);
  33. GetDlgItem(IDC_STATIC_HEIGHT1 + i)->SetWindowText(str);
  34. str.Format("A/D %d", i + 1);
  35. GetDlgItem(IDC_STATIC_AD1 + i)->SetWindowText(str);
  36. str.Format("%.2f", i * 1.5);
  37. GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->SetWindowText(str);
  38. str.Format("%d", (i + 1) * 1000);
  39. GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->SetWindowText(str);
  40. }
  41. return TRUE; // return TRUE unless you set the focus to a control
  42. // 异常: OCX 属性页应返回 FALSE
  43. }
  44. void CDialogCalDetector::OnBnClickedButtonReadad()
  45. {
  46. // TODO: 在此添加控件通知处理程序代码
  47. ResDataObject Request;
  48. ResDataObject oTemp;
  49. ResDataObject Result;
  50. Request.add("P0", oTemp);
  51. if (g_DiosAPIServer.ExecuteAction("CalGetADofDetector", Request, Result, 3000) == RET_SUCCEED)
  52. {
  53. ResDataObject obj1;
  54. try
  55. {
  56. obj1 = Result["P0"];
  57. CString strText((const char*)obj1["ADDetector"]);
  58. GetDlgItem(IDC_EDIT_DETECTOR_VALUEAD)->SetWindowText(strText);
  59. }
  60. catch (ResDataObjectExption &exp)
  61. {
  62. printf("%s%s", exp.what(), "\\n");
  63. TPRINTA_ERROR(exp.what());
  64. }
  65. }
  66. }
  67. void CDialogCalDetector::OnBnClickedOk()
  68. {
  69. // TODO: 在此添加控件通知处理程序代码
  70. ResDataObject Request;
  71. ResDataObject oTemp;
  72. ResDataObject Result;
  73. CString strKeyHeight;
  74. CString strKeyAD;
  75. CString strValueHeight;
  76. CString strValueAD;
  77. int nPointCount = 12;
  78. oTemp.add("PointCount", nPointCount);
  79. for (int i = 0; i < nPointCount; i++)
  80. {
  81. strKeyHeight.Format("Height%d", i);
  82. strKeyAD.Format("AD%d", i);
  83. GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->GetWindowText(strValueHeight);
  84. GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->GetWindowText(strValueAD);
  85. int nAD = atoi(strValueAD);
  86. oTemp.add(strKeyHeight, strValueHeight);
  87. oTemp.add(strKeyAD, nAD);
  88. }
  89. Request.add("P0", oTemp);
  90. if (g_DiosAPIServer.ExecuteAction("CalSaveParamsofDetector", Request, Result, 3000) == RET_SUCCEED)
  91. {
  92. string str = Result.encode();
  93. ResDataObject obj1;
  94. try
  95. {
  96. obj1 = Result["P0"];
  97. CString strSlope((const char*)obj1["Slope"]);
  98. CString strIntercept((const char*)obj1["Intercept"]);
  99. CString strText;
  100. strText.Format("Calibration succeed, Y = %s * X + (%s)", strSlope, strIntercept);
  101. AfxMessageBox(strText);
  102. }
  103. catch (ResDataObjectExption &exp)
  104. {
  105. printf("%s%s", exp.what(), "\\n");
  106. TPRINTA_ERROR(exp.what());
  107. }
  108. }
  109. }