DialogTubeLineVEncoder.cpp 6.1 KB

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