DialogCalTubeLineV.cpp 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. // CalTubeLineV.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "DIOS_3DDR_MechCal.h"
  5. #include "DialogCalTubeLineV.h"
  6. #include "afxdialogex.h"
  7. // CDialogCalTubeLineV 对话框
  8. IMPLEMENT_DYNAMIC(CDialogCalTubeLineV, CDialogEx)
  9. CDialogCalTubeLineV::CDialogCalTubeLineV(CWnd* pParent /*=NULL*/)
  10. : CDialogEx(CDialogCalTubeLineV::IDD, pParent)
  11. {
  12. }
  13. CDialogCalTubeLineV::~CDialogCalTubeLineV()
  14. {
  15. }
  16. void CDialogCalTubeLineV::DoDataExchange(CDataExchange* pDX)
  17. {
  18. CDialogEx::DoDataExchange(pDX);
  19. }
  20. BEGIN_MESSAGE_MAP(CDialogCalTubeLineV, CDialogEx)
  21. ON_BN_CLICKED(IDOK, &CDialogCalTubeLineV::OnBnClickedOk)
  22. ON_BN_CLICKED(IDC_BUTTON_STARTMOTION, &CDialogCalTubeLineV::OnBnClickedButtonStartmotion)
  23. ON_BN_CLICKED(IDC_BUTTON_READAD, &CDialogCalTubeLineV::OnBnClickedButtonReadad)
  24. END_MESSAGE_MAP()
  25. // CDialogCalTubeLineV 消息处理程序
  26. BOOL CDialogCalTubeLineV::OnInitDialog()
  27. {
  28. CDialogEx::OnInitDialog();
  29. // TODO: 在此添加额外的初始化
  30. 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" };
  31. CString strAD[12] = { "1540", "1350", "1158", "1731", "1919", "2044", "2169", "2259", "2421", "2545", "2672", "2798" };
  32. CString str;
  33. for (int i = 0; i < 12; i++)
  34. {
  35. str.Format("高度 %d", i+1);
  36. GetDlgItem(IDC_STATIC_HEIGHT1 + i)->SetWindowText(str);
  37. str.Format("A/D %d", i + 1);
  38. GetDlgItem(IDC_STATIC_AD1 + i)->SetWindowText(str);
  39. str.Format("%d", i+1);
  40. GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->SetWindowText(strHeight[i]);
  41. str.Format("%d", (i + 1) * 1000);
  42. GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->SetWindowText(strAD[i]);
  43. }
  44. ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->AddString("下");
  45. ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->AddString("上");
  46. ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->SetCurSel(0);
  47. return TRUE; // return TRUE unless you set the focus to a control
  48. // 异常: OCX 属性页应返回 FALSE
  49. }
  50. void CDialogCalTubeLineV::OnBnClickedButtonStartmotion()
  51. {
  52. // TODO: 在此添加控件通知处理程序代码
  53. int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->GetCurSel();
  54. CString strStep;
  55. GetDlgItem(IDC_EDIT_TUBELINEV_STEP)->GetWindowText(strStep);
  56. int nStep = atoi(strStep);
  57. ResDataObject Request;
  58. ResDataObject oTemp;
  59. ResDataObject Result;
  60. oTemp.add("Orientation", nCurSel);
  61. oTemp.add("StepNumber", nStep);
  62. Request.add("P0", oTemp);
  63. g_DiosAPIServer.ExecuteAction("CalMotionTubeLineV", Request, Result, 3000);
  64. }
  65. void CDialogCalTubeLineV::OnBnClickedButtonReadad()
  66. {
  67. // TODO: 在此添加控件通知处理程序代码
  68. ResDataObject Request;
  69. ResDataObject oTemp;
  70. ResDataObject Result;
  71. Request.add("P0", oTemp);
  72. if (g_DiosAPIServer.ExecuteAction("CalGetADofTubeLineV", Request, Result, 30000) == RET_SUCCEED)
  73. {
  74. string str = Result.encode();
  75. ResDataObject obj1;
  76. try
  77. {
  78. obj1 = Result["P0"];
  79. CString strText((const char*)obj1["ADTubeLineV"]);
  80. GetDlgItem(IDC_EDIT_TUBELINEV_VALUEAD)->SetWindowText(strText);
  81. }
  82. catch (ResDataObjectExption &exp)
  83. {
  84. printf("%s%s", exp.what(), "\\n");
  85. TPRINTA_ERROR(exp.what());
  86. }
  87. }
  88. }
  89. void CDialogCalTubeLineV::OnBnClickedOk()
  90. {
  91. // TODO: 在此添加控件通知处理程序代码
  92. ResDataObject Request;
  93. ResDataObject oTemp;
  94. ResDataObject Result;
  95. CString strKeyHeight;
  96. CString strKeyAD;
  97. CString strValueHeight;
  98. CString strValueAD;
  99. int nPointCount = 12;
  100. oTemp.add("PointCount", nPointCount);
  101. for (int i = 0; i < nPointCount; i++)
  102. {
  103. strKeyHeight.Format("Height%d", i);
  104. strKeyAD.Format("AD%d", i);
  105. GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->GetWindowText(strValueHeight);
  106. GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->GetWindowText(strValueAD);
  107. int nAD = atoi(strValueAD);
  108. oTemp.add(strKeyHeight, strValueHeight);
  109. oTemp.add(strKeyAD, nAD);
  110. }
  111. Request.add("P0", oTemp);
  112. if (g_DiosAPIServer.ExecuteAction("CalSaveParamsofTubeLiveV", Request, Result, 3000) == RET_SUCCEED)
  113. {
  114. string str = Result.encode();
  115. ResDataObject obj1;
  116. try
  117. {
  118. obj1 = Result["P0"];
  119. CString strSlope((const char*)obj1["Slope"]);
  120. CString strIntercept((const char*)obj1["Intercept"]);
  121. CString strText;
  122. strText.Format("Calibration succeed, Y = %s * X + (%s)", strSlope, strIntercept);
  123. AfxMessageBox(strText);
  124. }
  125. catch (ResDataObjectExption &exp)
  126. {
  127. printf("%s%s", exp.what(), "\\n");
  128. TPRINTA_ERROR(exp.what());
  129. }
  130. }
  131. }