DialogMotionTest.cpp 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. // DialogMotionTest.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "DIOS_3DDR_MechCal.h"
  5. #include "DialogMotionTest.h"
  6. #include "afxdialogex.h"
  7. #define EBUS_TIMEOUT 30000
  8. // CDialogMotionTest 对话框
  9. IMPLEMENT_DYNAMIC(CDialogMotionTest, CDialogEx)
  10. CDialogMotionTest::CDialogMotionTest(CWnd* pParent /*=NULL*/)
  11. : CDialogEx(CDialogMotionTest::IDD, pParent)
  12. {
  13. }
  14. CDialogMotionTest::~CDialogMotionTest()
  15. {
  16. }
  17. void CDialogMotionTest::DoDataExchange(CDataExchange* pDX)
  18. {
  19. CDialogEx::DoDataExchange(pDX);
  20. }
  21. BEGIN_MESSAGE_MAP(CDialogMotionTest, CDialogEx)
  22. ON_BN_CLICKED(IDC_BUTTON_STARTLINEMOTION, &CDialogMotionTest::OnBnClickedButtonStartlinemotion)
  23. ON_BN_CLICKED(IDC_BUTTON_TUBE_STOPLINEMOTION, &CDialogMotionTest::OnBnClickedButtonTubeStoplinemotion)
  24. ON_BN_CLICKED(IDC_BUTTON_TUBE_ROTATE, &CDialogMotionTest::OnBnClickedButtonTubeRotate)
  25. ON_BN_CLICKED(IDC_BUTTON_TUBE_STOPROTATION, &CDialogMotionTest::OnBnClickedButtonTubeStoprotation)
  26. ON_BN_CLICKED(IDC_BUTTON_TUBE_ENCODER, &CDialogMotionTest::OnBnClickedButtonTubeEncoder)
  27. ON_BN_CLICKED(IDC_BUTTON_TUBE_ENCODER_UNBIND, &CDialogMotionTest::OnBnClickedButtonTubeEncoderUnbind)
  28. ON_BN_CLICKED(IDC_BUTTON_RESET, &CDialogMotionTest::OnBnClickedButtonReset)
  29. ON_BN_CLICKED(IDC_BUTTON_CENTER_ALIGN, &CDialogMotionTest::OnBnClickedButtonCenterAlign)
  30. ON_BN_CLICKED(IDC_BUTTON_STOPMOTION, &CDialogMotionTest::OnBnClickedButtonStopmotion)
  31. ON_BN_CLICKED(IDC_BUTTON_SET_PARAMS, &CDialogMotionTest::OnBnClickedButtonSetParams)
  32. ON_BN_CLICKED(IDC_BUTTON_MOVE2PARKINGPOSITION, &CDialogMotionTest::OnBnClickedButtonMove2parkingposition)
  33. END_MESSAGE_MAP()
  34. // CDialogMotionTest 消息处理程序
  35. BOOL CDialogMotionTest::OnInitDialog()
  36. {
  37. CDialogEx::OnInitDialog();
  38. // TODO: 在此添加额外的初始化
  39. ((CComboBox*)(GetDlgItem(IDC_COMBO_EXAM_MODE)))->AddString("DR");
  40. ((CComboBox*)(GetDlgItem(IDC_COMBO_EXAM_MODE)))->AddString("TOMO");
  41. ((CComboBox*)(GetDlgItem(IDC_COMBO_EXAM_MODE)))->SetCurSel(0);
  42. ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("10000");
  43. ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("11000");
  44. ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("20001");
  45. ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("20003");
  46. ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->AddString("20005");
  47. ((CComboBox*)(GetDlgItem(IDC_COMBO_POSITIONCODE)))->SetCurSel(0);
  48. ((CEdit*)GetDlgItem(IDC_EDIT_SID))->SetWindowText("120");
  49. return TRUE; // return TRUE unless you set the focus to a control
  50. // 异常: OCX 属性页应返回 FALSE
  51. }
  52. void CDialogMotionTest::OnBnClickedButtonStartlinemotion()
  53. {
  54. // TODO: 在此添加控件通知处理程序代码
  55. //int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG2)))->GetCurSel();
  56. CString strTargetHeight;
  57. GetDlgItem(IDC_EDIT_TUBELINEV_TARGETHEIGHT)->GetWindowText(strTargetHeight);
  58. //float fTargetHeight = atof(strTargetHeight);
  59. ResDataObject Request;
  60. ResDataObject oTemp;
  61. ResDataObject Result;
  62. //oTemp.add("Orientation", nCurSel);
  63. oTemp.add("TargeHeight", strTargetHeight);
  64. Request.add("P0", oTemp);
  65. g_DiosAPIServer.ExecuteAction("MotionTest_StartTubeLineVMotion2Target", Request, Result, EBUS_TIMEOUT);
  66. }
  67. void CDialogMotionTest::OnBnClickedButtonTubeStoplinemotion()
  68. {
  69. // TODO: 在此添加控件通知处理程序代码
  70. ResDataObject Request;
  71. ResDataObject oTemp;
  72. ResDataObject Result;
  73. Request.add("P0", oTemp);
  74. g_DiosAPIServer.ExecuteAction("MotionTest_StopLineVMotion", Request, Result, EBUS_TIMEOUT);
  75. }
  76. void CDialogMotionTest::OnBnClickedButtonTubeRotate()
  77. {
  78. // TODO: 在此添加控件通知处理程序代码
  79. //int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBEANGLE_ORG)))->GetCurSel();
  80. CString strAngle;
  81. GetDlgItem(IDC_EDIT_TUBE_TARGETANGLE)->GetWindowText(strAngle);
  82. float nAngle = (float)atof(strAngle);
  83. if (nAngle < -90.0 || nAngle > 60.0)
  84. {
  85. AfxMessageBox("旋转角度范围应在-90度至+60度之间,请重新设置");
  86. return;
  87. }
  88. ResDataObject Request;
  89. ResDataObject oTemp;
  90. ResDataObject Result;
  91. //oTemp.add("Orientation", nCurSel);
  92. oTemp.add("TargetAngle", strAngle);
  93. Request.add("P0", oTemp);
  94. g_DiosAPIServer.ExecuteAction("MotionTest_TubeAngleRotate2Target", Request, Result, EBUS_TIMEOUT);
  95. }
  96. void CDialogMotionTest::OnBnClickedButtonTubeStoprotation()
  97. {
  98. // TODO: 在此添加控件通知处理程序代码
  99. ResDataObject Request;
  100. ResDataObject oTemp;
  101. ResDataObject Result;
  102. Request.add("P0", oTemp);
  103. g_DiosAPIServer.ExecuteAction("MotionTest_StopRotation", Request, Result, EBUS_TIMEOUT);
  104. }
  105. void CDialogMotionTest::OnBnClickedButtonTubeEncoder()
  106. {
  107. // TODO: 在此添加控件通知处理程序代码
  108. ResDataObject Request;
  109. ResDataObject oTemp;
  110. ResDataObject Result;
  111. Request.add("P0", oTemp);
  112. g_DiosAPIServer.ExecuteAction("MotionTest_BindRotationEncoder", Request, Result, EBUS_TIMEOUT);
  113. }
  114. void CDialogMotionTest::OnBnClickedButtonTubeEncoderUnbind()
  115. {
  116. // TODO: 在此添加控件通知处理程序代码
  117. ResDataObject Request;
  118. ResDataObject oTemp;
  119. ResDataObject Result;
  120. Request.add("P0", oTemp);
  121. g_DiosAPIServer.ExecuteAction("MotionTest_UnbindRotationEncoder", Request, Result, EBUS_TIMEOUT);
  122. }
  123. void CDialogMotionTest::OnBnClickedButtonReset()
  124. {
  125. // TODO: 在此添加控件通知处理程序代码
  126. ResDataObject Request;
  127. ResDataObject oTemp;
  128. ResDataObject Result;
  129. Request.add("P0", oTemp);
  130. g_DiosAPIServer.ExecuteAction("MotionTest_SystemInitial", Request, Result, EBUS_TIMEOUT);
  131. }
  132. void CDialogMotionTest::OnBnClickedButtonCenterAlign()
  133. {
  134. // TODO: 在此添加控件通知处理程序代码
  135. ResDataObject Request;
  136. ResDataObject oTemp;
  137. ResDataObject Result;
  138. Request.add("P0", oTemp);
  139. g_DiosAPIServer.ExecuteAction("MotionTest_TubeCenterAlign", Request, Result, EBUS_TIMEOUT);
  140. }
  141. void CDialogMotionTest::OnBnClickedButtonStopmotion()
  142. {
  143. // TODO: 在此添加控件通知处理程序代码
  144. ResDataObject Request;
  145. ResDataObject oTemp;
  146. ResDataObject Result;
  147. Request.add("P0", oTemp);
  148. g_DiosAPIServer.ExecuteAction("StopMech", Request, Result, EBUS_TIMEOUT);
  149. }
  150. void CDialogMotionTest::SetExamMode(int nMode)
  151. {
  152. ResDataObject Request;
  153. ResDataObject Result;
  154. ResDataObject ExamDR;
  155. ResDataObject ExamTomo;
  156. //"RF":"Tomo" : "1"
  157. ResDataObject ExamInfo;
  158. ExamDR.add("Single", "1");
  159. ExamTomo.add("TOMO", "1");
  160. if (nMode == 0)
  161. {
  162. ExamInfo.add("DX", ExamDR);
  163. }
  164. else if (nMode == 1)
  165. {
  166. ExamInfo.add("DX", ExamTomo);
  167. }
  168. Request.add("P0", ExamInfo);
  169. if (g_DiosAPIServer.ExecuteAction("SetExamInfo", Request, Result, EBUS_TIMEOUT))
  170. {
  171. printf("SetExamInfo Action Failed\n");
  172. }
  173. else
  174. {
  175. printf("SetExamInfo Action Succeed\n");
  176. }
  177. Request.clear(); Result.clear();
  178. Request.add("P0", "DX");
  179. if (g_DiosAPIServer.ExecuteAction("SelectExamMode", Request, Result, 30000) < RET_SUCCEED)
  180. {
  181. printf("SelectExamMode Action Failed\n");
  182. }
  183. else
  184. {
  185. printf("SelectExamMode Action Succeed\n");
  186. }
  187. //Request.clear(); Result.clear();
  188. //if (g_DiosAPIServer.ExecuteAction("FramePrep", Request, Result, 30000) < RET_SUCCEED)
  189. //{
  190. // printf("FramePrep Action Failed\n");
  191. //}
  192. //else
  193. //{
  194. // printf("FramePrep Action Succeed\n");
  195. //}
  196. //Request.clear(); Result.clear();
  197. //if (g_DiosAPIServer.ExecuteAction("FrameReady", Request, Result, 30000) < RET_SUCCEED)
  198. //{
  199. // printf("FrameReady Action Failed\n");
  200. //}
  201. //else
  202. //{
  203. // printf("FrameReady Action Succeed\n");
  204. //}
  205. }
  206. //void CDialogMotionTest::OnBnClickedButtonTomo()
  207. //{
  208. // // TODO: 在此添加控件通知处理程序代码
  209. // SetExamMode(1);
  210. //}
  211. //
  212. //
  213. //void CDialogMotionTest::OnBnClickedButton2d()
  214. //{
  215. // // TODO: 在此添加控件通知处理程序代码
  216. // SetExamMode(0);
  217. //}
  218. void CDialogMotionTest::OnBnClickedButtonSetParams()
  219. {
  220. // TODO: 在此添加控件通知处理程序代码
  221. int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_EXAM_MODE)))->GetCurSel();
  222. SetExamMode(nCurSel);
  223. ResDataObject Request;
  224. ResDataObject oTemp;
  225. ResDataObject Result;
  226. CString strPositionCode;
  227. nCurSel = ((CComboBox*)GetDlgItem(IDC_COMBO_POSITIONCODE))->GetCurSel();
  228. ((CComboBox*)GetDlgItem(IDC_COMBO_POSITIONCODE))->GetLBText(nCurSel, strPositionCode);
  229. CString strSID;
  230. ((CEdit*)GetDlgItem(IDC_EDIT_SID))->GetWindowText(strSID);
  231. oTemp.add("SID", strSID);
  232. oTemp.add("PositionNumber", strPositionCode);
  233. Request.add("P0", oTemp);
  234. g_DiosAPIServer.ExecuteAction("SetTechParamsInfo", Request, Result, EBUS_TIMEOUT);
  235. Request.clear(); Result.clear();
  236. if (g_DiosAPIServer.ExecuteAction("FramePrep", Request, Result, 30000) < RET_SUCCEED)
  237. {
  238. printf("FramePrep Action Failed\n");
  239. }
  240. else
  241. {
  242. printf("FramePrep Action Succeed\n");
  243. }
  244. Request.clear(); Result.clear();
  245. if (g_DiosAPIServer.ExecuteAction("FrameReady", Request, Result, 30000) < RET_SUCCEED)
  246. {
  247. printf("FrameReady Action Failed\n");
  248. }
  249. else
  250. {
  251. printf("FrameReady Action Succeed\n");
  252. }
  253. }
  254. void CDialogMotionTest::OnBnClickedButtonMove2parkingposition()
  255. {
  256. // TODO: 在此添加控件通知处理程序代码
  257. ResDataObject Request;
  258. ResDataObject oTemp;
  259. ResDataObject Result;
  260. oTemp.add("TargetAngle", "0.8");
  261. Request.add("P0", oTemp);
  262. g_DiosAPIServer.ExecuteAction("MotionTest_Move2ParkingPosition", Request, Result, EBUS_TIMEOUT);
  263. }