DialogADCalibrationMain.cpp 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416
  1. // DialogADCalibrationMain.cpp : 实现文件
  2. //
  3. #include "stdafx.h"
  4. #include "DIOS_3DDR_MechCal.h"
  5. #include "DialogADCalibrationMain.h"
  6. #include "afxdialogex.h"
  7. #include "DialogPhysicalInput.h"
  8. static std::vector<CString> SplitCString(CString strSource, CString ch)
  9. {
  10. vector<CString> vecString;
  11. int iPos = 0;
  12. CString strTmp;
  13. strTmp = strSource.Tokenize(ch, iPos);
  14. while (strTmp.Trim() != _T(""))
  15. {
  16. vecString.push_back(strTmp);
  17. strTmp = strSource.Tokenize(ch, iPos);
  18. }
  19. return vecString;
  20. }
  21. // CDialogADCalibrationMain 对话框
  22. IMPLEMENT_DYNAMIC(CDialogADCalibrationMain, CDialogEx)
  23. CDialogADCalibrationMain::CDialogADCalibrationMain(CWnd* pParent /*=NULL*/)
  24. : CDialogEx(CDialogADCalibrationMain::IDD, pParent)
  25. {
  26. }
  27. CDialogADCalibrationMain::~CDialogADCalibrationMain()
  28. {
  29. }
  30. void CDialogADCalibrationMain::DoDataExchange(CDataExchange* pDX)
  31. {
  32. CDialogEx::DoDataExchange(pDX);
  33. DDX_Control(pDX, IDC_COMBO_ROTATE_DIRECTION, m_rotateDirection);
  34. DDX_Control(pDX, IDC_EDIT_ROTATE_TUBE_ANGLE_STEP, m_rotateStep);
  35. DDX_Control(pDX, IDC_COMBO_MOVE_DIRECTION, m_tubeHeightDirection);
  36. DDX_Control(pDX, IDC_EDIT_MOVE_TUBE_HEIGHT_STEP, m_tubeHeightStep);
  37. DDX_Control(pDX, IDC_EDIT_AD_VALUE_TUBE_ANGLE, m_tubeAngleAD);
  38. DDX_Control(pDX, IDC_EDIT_TUBE_ANGLE_ADS, m_tubeAngleCalADs);
  39. DDX_Control(pDX, IDC_EDIT_TUBE_ANGLE_PHYSICALS, m_tubeAngleCalPhysicals);
  40. DDX_Control(pDX, IDC_EDIT_AD_VALUE_TUBE_HEIGHT, m_tubeHeightAD);
  41. DDX_Control(pDX, IDC_EDIT_TUBE_HEIGHT_ADS, m_tubHeightCalADs);
  42. DDX_Control(pDX, IDC_EDIT_TUBE_HEIGHT_PHYSICALS, m_tubeHeightCalPhysicals);
  43. DDX_Control(pDX, IDC_EDIT_AD_VALUE_DET_HEIGHT, m_detectorAD);
  44. DDX_Control(pDX, IDC_EDIT_DET_HEIGHT_ADS, m_detectorCalAds);
  45. DDX_Control(pDX, IDC_EDIT_DET_HEIGHT_PHYSICALS, m_detectorHeightCalPhysicals);
  46. DDX_Control(pDX, IDC_EDIT_ENCODER_VALUE_TUBE_ANGLE, m_tubeAngleEncoder);
  47. DDX_Control(pDX, IDC_EDIT_ENCODER_VALUE_TUBE_HEIGHT, m_tubeHeightEncoder);
  48. DDX_Control(pDX, IDC_EDIT_PCODE, m_pcode);
  49. DDX_Control(pDX, IDC_COMBO_EX_MODE, m_examMode);
  50. DDX_Control(pDX, IDC_EDIT_C_TUBE_ANGLE, m_autoadTubeAngleCurrent);
  51. DDX_Control(pDX, IDC_EDIT_H_TUBE_ANGLE, m_autoadTubeAngleHighlimit);
  52. DDX_Control(pDX, IDC_EDIT_L_TUBEANGLE, m_autoadTubeAngleLowlimit);
  53. DDX_Control(pDX, IDC_EDIT_C_TUBE_HEIGHT, m_autoadTubeHeightCurrent);
  54. DDX_Control(pDX, IDC_EDIT_H_TUBE_HEIGHT, m_autoadTubeHeightHighlimit);
  55. DDX_Control(pDX, IDC_EDIT_L_TUBEHEIGHT, m_autoadTubeHeightLowlimit);
  56. DDX_Control(pDX, IDC_COMBO_SELFT_DOF, m_selftestDOF);
  57. DDX_Control(pDX, IDC_EDIT_SELFT_HIGH_LIMIT, m_selftestHighlimit);
  58. DDX_Control(pDX, IDC_EDIT_SELFT_LOW_LIMIT, m_selftestlowlimit);
  59. DDX_Control(pDX, IDC_EDIT_SELFT_PERIOD, m_selftestperiod);
  60. DDX_Control(pDX, IDC_EDIT_SELFT_DUTYCYCLE, m_selftestdutycycle);
  61. DDX_Control(pDX, IDC_EDIT2, m_selftestRepeatTime);
  62. DDX_Control(pDX, IDC_COMBO_LINE_SELECTION, m_comboTubeLineSelection);
  63. DDX_Control(pDX, IDC_COMBO_DETECTOR_SELECTION, m_comboDetectorSelection);
  64. DDX_Control(pDX, IDC_RADIO_WALL, m_radioWSWall);
  65. DDX_Control(pDX, IDC_RADIO_TABLE, m_radioWSTable);
  66. }
  67. BEGIN_MESSAGE_MAP(CDialogADCalibrationMain, CDialogEx)
  68. ON_BN_CLICKED(IDC_BUTTON_ROTATE_TUBE_ANGLE, &CDialogADCalibrationMain::OnBnClickedButtonRotateTubeAngle)
  69. ON_BN_CLICKED(IDC_BUTTON_MOVE_TUBE_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonMoveTubeHeight)
  70. ON_BN_CLICKED(IDC_BUTTON_READ_AD_TUBE_ANGLE, &CDialogADCalibrationMain::OnBnClickedButtonReadAdTubeAngle)
  71. ON_BN_CLICKED(IDC_BUTTON_READ_AD_TUBE_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonReadAdTubeHeight)
  72. ON_BN_CLICKED(IDC_BUTTON_READ_AD_DET_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonReadAdDetHeight)
  73. ON_BN_CLICKED(IDC_BUTTON_CAL_TUBE_ANGLE_AD, &CDialogADCalibrationMain::OnBnClickedButtonCalTubeAngleAd)
  74. ON_BN_CLICKED(IDC_BUTTON_CAL_TUBE_HEIGHT_AD, &CDialogADCalibrationMain::OnBnClickedButtonCalTubeHeightAd)
  75. ON_BN_CLICKED(IDC_BUTTON_CAL_DET_HEIGHT_AD, &CDialogADCalibrationMain::OnBnClickedButtonCalDetHeightAd)
  76. ON_WM_CLOSE()
  77. ON_BN_CLICKED(IDC_BUTTON_READ_ENCODER_TUBE_ANGLE, &CDialogADCalibrationMain::OnBnClickedButtonReadEncoderTubeAngle)
  78. ON_BN_CLICKED(IDC_BUTTON_READ_ENCODER_TUBE_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonReadEncoderTubeHeight)
  79. ON_BN_CLICKED(IDC_BUTTON_ENTER_CALIBRATION, &CDialogADCalibrationMain::OnBnClickedButtonEnterCalibration)
  80. ON_BN_CLICKED(IDC_BUTTON_EXIT_CALIBRATION, &CDialogADCalibrationMain::OnBnClickedButtonExitCalibration)
  81. ON_BN_CLICKED(IDC_BUTTON_RESET_SYSTEM, &CDialogADCalibrationMain::OnBnClickedButtonResetSystem)
  82. ON_BN_CLICKED(ID_BUTTON_CENTERADJUST, &CDialogADCalibrationMain::OnBnClickedButtonCenteradjust)
  83. ON_BN_CLICKED(ID_BUTTON_PARKING, &CDialogADCalibrationMain::OnBnClickedButtonParking)
  84. ON_BN_CLICKED(ID_BUTTON_TUBE_ANGLE_LOW_LIMIT, &CDialogADCalibrationMain::OnBnClickedButtonTubeAngleLowLimit)
  85. ON_BN_CLICKED(ID_BUTTON_TUBE_HEIGHT_LOW_LIMIT, &CDialogADCalibrationMain::OnBnClickedButtonTubeHeightLowLimit)
  86. ON_BN_CLICKED(IDC_BUTTON_ENTER_SELFTEST, &CDialogADCalibrationMain::OnBnClickedButtonEnterSelftest)
  87. ON_BN_CLICKED(IDC_BUTTON_EXIT_SELFTEST, &CDialogADCalibrationMain::OnBnClickedButtonExitSelftest)
  88. ON_BN_CLICKED(IDC_BUTTON_START_SELFTEST, &CDialogADCalibrationMain::OnBnClickedButtonStartSelftest)
  89. ON_BN_CLICKED(IDC_BUTTON_ACTIVE_TUBE_ANGLE_Z_CLEAR, &CDialogADCalibrationMain::OnBnClickedButtonActiveTubeAngleZClear)
  90. ON_BN_CLICKED(IDC_BUTTON_CANCEL_TUBE_ANGLE_Z_CLEAR, &CDialogADCalibrationMain::OnBnClickedButtonCancelTubeAngleZClear)
  91. ON_BN_CLICKED(IDC_BUTTON_ACTIVE_TUBE_HEIGHT_Z_CLEAR, &CDialogADCalibrationMain::OnBnClickedButtonActiveTubeHeightZClear)
  92. ON_BN_CLICKED(IDC_BUTTON_CANCEL_TUBE_HEIGHT_Z_CLEAR, &CDialogADCalibrationMain::OnBnClickedButtonCancelTubeHeightZClear)
  93. ON_BN_CLICKED(IDC_BUTTON_ROTATE_TO_TUBE_ANGLE_Z_AXIS, &CDialogADCalibrationMain::OnBnClickedButtonRotateToTubeAngleZAxis)
  94. ON_BN_CLICKED(IDC_BUTTON_MOVE_TO_TUBE_HEIGHT_Z_AXIS, &CDialogADCalibrationMain::OnBnClickedButtonMoveToTubeHeightZAxis)
  95. ON_BN_CLICKED(IDC_BUTTON_EM_STOP, &CDialogADCalibrationMain::OnBnClickedButtonEmStop)
  96. ON_BN_CLICKED(IDC_BUTTON_SET_PCODE_PARAM, &CDialogADCalibrationMain::OnBnClickedButtonSetPcodeParam)
  97. ON_BN_CLICKED(IDC_BUTTON_ROTATE_TUBE_ANGLE_PHY, &CDialogADCalibrationMain::OnBnClickedButtonRotateTubeAnglePhy)
  98. ON_BN_CLICKED(IDC_BUTTON_MOVE_TUBE_HEIGHT_PHY, &CDialogADCalibrationMain::OnBnClickedButtonMoveTubeHeightPhy)
  99. ON_BN_CLICKED(IDC_BUTTON_INSERT_TUBE_ANGLE, &CDialogADCalibrationMain::OnBnClickedButtonInsertTubeAngle)
  100. ON_BN_CLICKED(IDC_BUTTON_INSERT_TUBE_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonInsertTubeHeight)
  101. ON_BN_CLICKED(IDC_BUTTON_INSERT_Detector_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonInsertDetectorHeight)
  102. ON_BN_CLICKED(IDC_BUTTON_AUTO_CALAD_TUBEANGLE, &CDialogADCalibrationMain::OnBnClickedButtonAutoCaladTubeangle)
  103. ON_BN_CLICKED(IDC_BUTTON_AUTO_CALAD_TUBEHEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonAutoCaladTubeheight)
  104. ON_BN_CLICKED(IDC_TUBE_ANGLE_SVO, &CDialogADCalibrationMain::OnBnClickedTubeAngleSvo)
  105. ON_BN_CLICKED(IDC_BUTTON_TUBEHEIGHT_SVO, &CDialogADCalibrationMain::OnBnClickedButtonTubeheightSvo)
  106. ON_BN_CLICKED(IDC_RADIO_WALL, &CDialogADCalibrationMain::OnBnClickedRadioWall)
  107. ON_BN_CLICKED(IDC_RADIO_TABLE, &CDialogADCalibrationMain::OnBnClickedRadioTable)
  108. ON_BN_CLICKED(IDC_BUTTON_RESET_TUBE_ANGLE_SAVEVALUE, &CDialogADCalibrationMain::OnBnClickedButtonResetTubeAngleSavevalue)
  109. ON_BN_CLICKED(IDC_BUTTON_RESET_TUBE_ANGLE_ENCODERZERO_SAVEVALUE, &CDialogADCalibrationMain::OnBnClickedButtonResetTubeAngleEncoderzeroSavevalue)
  110. ON_BN_CLICKED(IDC_BUTTON_TUBE_LINE_SAVE_MINPOS, &CDialogADCalibrationMain::OnBnClickedButtonTubeLineSaveMinpos)
  111. ON_BN_CLICKED(IDC_BUTTON_TUBE_LINE_SAVE_ENCODERZERO, &CDialogADCalibrationMain::OnBnClickedButtonTubeLineSaveEncoderzero)
  112. ON_CBN_SELCHANGE(IDC_COMBO_LINE_SELECTION, &CDialogADCalibrationMain::OnCbnSelchangeComboLineSelection)
  113. ON_CBN_SELENDOK(IDC_COMBO_LINE_SELECTION, &CDialogADCalibrationMain::OnCbnSelendokComboLineSelection)
  114. END_MESSAGE_MAP()
  115. // CDialogADCalibrationMain 消息处理程序
  116. void CDialogADCalibrationMain::OnBnClickedButtonRotateTubeAngle()
  117. {
  118. auto direction = m_rotateDirection.GetCurSel();
  119. CString strSteps;
  120. m_rotateStep.GetWindowText(strSteps);
  121. auto steps = atoi(strSteps.GetString());
  122. ResDataObject Request;
  123. ResDataObject oTemp;
  124. ResDataObject Result;
  125. oTemp.add("Orientation", direction);
  126. oTemp.add("StepNumber", steps);
  127. Request.add("P0", oTemp);
  128. g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeAngleRotate", Request, Result, 3000);
  129. }
  130. void CDialogADCalibrationMain::OnBnClickedButtonMoveTubeHeight()
  131. {
  132. auto direction = m_tubeHeightDirection.GetCurSel();
  133. CString strSteps;
  134. m_tubeHeightStep.GetWindowText(strSteps);
  135. auto steps = atoi(strSteps.GetString());
  136. ResDataObject Request;
  137. ResDataObject oTemp;
  138. ResDataObject Result;
  139. oTemp.add("Orientation", direction);
  140. oTemp.add("StepNumber", steps);
  141. Request.add("P0", oTemp);
  142. int sel = m_comboTubeLineSelection.GetCurSel();
  143. if (sel == 0)
  144. {
  145. g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeLineV", Request, Result, 3000);
  146. }
  147. else if (sel == 1)
  148. {
  149. g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeLineH", Request, Result, 3000);
  150. }
  151. }
  152. void CDialogADCalibrationMain::OnBnClickedButtonReadAdTubeAngle()
  153. {
  154. ResDataObject Request;
  155. ResDataObject oTemp;
  156. ResDataObject Result;
  157. Request.add("P0", oTemp);
  158. if (g_DiosAPIServer.ExecuteAction("MachineryCalGetADofTubeAngle", Request, Result, 3000) == RET_SUCCEED)
  159. {
  160. ResDataObject obj1;
  161. try
  162. {
  163. obj1 = Result["P0"];
  164. CString strText((const char*)obj1["ADTubeAngle"]);
  165. m_tubeAngleAD.SetWindowText(strText);
  166. }
  167. catch (ResDataObjectExption &exp)
  168. {
  169. printf("%s%s", exp.what(), "\\n");
  170. TPRINTA_ERROR(exp.what());
  171. }
  172. }
  173. }
  174. void CDialogADCalibrationMain::OnBnClickedButtonReadAdTubeHeight()
  175. {
  176. ResDataObject Request;
  177. ResDataObject oTemp;
  178. ResDataObject Result;
  179. Request.add("P0", oTemp);
  180. dios_result res = RET_SUCCEED;
  181. int sel = m_comboTubeLineSelection.GetCurSel();
  182. if (sel == 0)
  183. {
  184. res = g_DiosAPIServer.ExecuteAction("MachineryCalGetADofTubeLineV", Request, Result, 30000);
  185. }
  186. else if (sel == 1)
  187. {
  188. res = g_DiosAPIServer.ExecuteAction("MachineryCalGetADofTubeLineH", Request, Result, 30000);
  189. }
  190. if (res == RET_SUCCEED)
  191. {
  192. string str = Result.encode();
  193. ResDataObject obj1;
  194. try
  195. {
  196. obj1 = Result["P0"];
  197. CString strText((const char*)obj1["ADTubeHeight"]);
  198. m_tubeHeightAD.SetWindowText(strText);
  199. }
  200. catch (ResDataObjectExption &exp)
  201. {
  202. printf("%s%s", exp.what(), "\\n");
  203. TPRINTA_ERROR(exp.what());
  204. }
  205. }
  206. }
  207. void CDialogADCalibrationMain::OnBnClickedButtonReadAdDetHeight()
  208. {
  209. ResDataObject Request;
  210. ResDataObject oTemp;
  211. ResDataObject Result;
  212. Request.add("P0", oTemp);
  213. dios_result res = RET_SUCCEED;
  214. int sel = m_comboDetectorSelection.GetCurSel();
  215. if (sel == 0)
  216. {
  217. res = g_DiosAPIServer.ExecuteAction("MachineryCalGetADofDetector", Request, Result, 30000);
  218. }
  219. else if (sel == 1)
  220. {
  221. res = g_DiosAPIServer.ExecuteAction("MachineryCalGetADofHorizontalDetector", Request, Result, 30000);
  222. }
  223. if (res == RET_SUCCEED)
  224. {
  225. ResDataObject obj1;
  226. try
  227. {
  228. obj1 = Result["P0"];
  229. CString strText((const char*)obj1["ADDetectorHeight"]);
  230. m_detectorAD.SetWindowText(strText);
  231. }
  232. catch (ResDataObjectExption &exp)
  233. {
  234. printf("%s%s", exp.what(), "\\n");
  235. TPRINTA_ERROR(exp.what());
  236. }
  237. }
  238. }
  239. void CDialogADCalibrationMain::OnBnClickedButtonReadEncoderTubeAngle()
  240. {
  241. ResDataObject Request;
  242. ResDataObject oTemp;
  243. ResDataObject Result;
  244. Request.add("P0", oTemp);
  245. if (g_DiosAPIServer.ExecuteAction("MachineryCalGetEncoderOfTubeAngle", Request, Result, 3000) == RET_SUCCEED)
  246. {
  247. ResDataObject obj1;
  248. try
  249. {
  250. obj1 = Result["P0"];
  251. CString strText((const char*)obj1["EncoderTubeAngle"]);
  252. m_tubeAngleEncoder.SetWindowText(strText);
  253. }
  254. catch (ResDataObjectExption &exp)
  255. {
  256. printf("%s%s", exp.what(), "\\n");
  257. TPRINTA_ERROR(exp.what());
  258. }
  259. }
  260. }
  261. void CDialogADCalibrationMain::OnBnClickedButtonReadEncoderTubeHeight()
  262. {
  263. ResDataObject Request;
  264. ResDataObject oTemp;
  265. ResDataObject Result;
  266. Request.add("P0", oTemp);
  267. dios_result res = RET_SUCCEED;
  268. int sel = m_comboTubeLineSelection.GetCurSel();
  269. if (sel == 0)
  270. {
  271. res = g_DiosAPIServer.ExecuteAction("MachineryCalGetEncoderofTubeLineV", Request, Result, 30000);
  272. }
  273. else if (sel == 1)
  274. {
  275. res = g_DiosAPIServer.ExecuteAction("MachineryCalGetEncoderofTubeLineH", Request, Result, 30000);
  276. }
  277. if (res == RET_SUCCEED)
  278. {
  279. string str = Result.encode();
  280. ResDataObject obj1;
  281. try
  282. {
  283. obj1 = Result["P0"];
  284. CString strText((const char*)obj1["EncoderTubeHeight"]);
  285. m_tubeHeightEncoder.SetWindowText(strText);
  286. }
  287. catch (ResDataObjectExption &exp)
  288. {
  289. printf("%s%s", exp.what(), "\\n");
  290. TPRINTA_ERROR(exp.what());
  291. }
  292. }
  293. }
  294. void CDialogADCalibrationMain::OnBnClickedButtonCalTubeAngleAd()
  295. {
  296. ResDataObject Request;
  297. ResDataObject Result;
  298. CString physicals;
  299. CString ads;
  300. ResDataObject params;
  301. m_tubeAngleCalPhysicals.GetWindowText(physicals);
  302. m_tubeAngleCalADs.GetWindowText(ads);
  303. auto vphs = SplitCString(physicals, "#");
  304. for (int i = 0; i < vphs.size();++i)
  305. {
  306. char tmp[64] = { 0 };
  307. sprintf_s(tmp, "Physical%d", i);
  308. params.add(tmp, vphs[i].GetString());
  309. }
  310. auto vads = SplitCString(ads,"#");
  311. for (int i = 0; i < vads.size();++i)
  312. {
  313. char tmp[64] = { 0 };
  314. sprintf_s(tmp, "AD%d", i);
  315. params.add(tmp, vads[i].GetString());
  316. }
  317. params.add("PointCount", (int)vphs.size());
  318. Request.add("P0", params);
  319. if (g_DiosAPIServer.ExecuteAction("MachineryCalSaveParamsofTubeAngle", Request, Result, 30000) == RET_SUCCEED)
  320. {
  321. }
  322. }
  323. void CDialogADCalibrationMain::OnBnClickedButtonCalTubeHeightAd()
  324. {
  325. ResDataObject Request;
  326. ResDataObject Result;
  327. CString physicals;
  328. CString ads;
  329. ResDataObject params;
  330. m_tubeHeightCalPhysicals.GetWindowText(physicals);
  331. m_tubHeightCalADs.GetWindowText(ads);
  332. auto vphs = SplitCString(physicals, "#");
  333. for (int i = 0; i < vphs.size(); ++i)
  334. {
  335. char tmp[64] = { 0 };
  336. sprintf_s(tmp, "Physical%d", i);
  337. params.add(tmp, vphs[i].GetString());
  338. }
  339. auto vads = SplitCString(ads, "#");
  340. for (int i = 0; i < vads.size(); ++i)
  341. {
  342. char tmp[64] = { 0 };
  343. sprintf_s(tmp, "AD%d", i);
  344. params.add(tmp, vads[i].GetString());
  345. }
  346. params.add("PointCount", (int)vphs.size());
  347. Request.add("P0", params);
  348. int sel = m_comboTubeLineSelection.GetCurSel();
  349. if (sel == 0)
  350. {
  351. g_DiosAPIServer.ExecuteAction("MachineryCalSaveParamsofTubeLiveV", Request, Result, 30000);
  352. }
  353. else if (sel == 1)
  354. {
  355. g_DiosAPIServer.ExecuteAction("MachineryCalSaveParamsofTubeLiveH", Request, Result, 30000);
  356. }
  357. }
  358. void CDialogADCalibrationMain::OnBnClickedButtonCalDetHeightAd()
  359. {
  360. ResDataObject Request;
  361. ResDataObject Result;
  362. CString physicals;
  363. CString ads;
  364. ResDataObject params;
  365. m_detectorHeightCalPhysicals.GetWindowText(physicals);
  366. m_detectorCalAds.GetWindowText(ads);
  367. auto vphs = SplitCString(physicals, "#");
  368. for (int i = 0; i < vphs.size(); ++i)
  369. {
  370. char tmp[64] = { 0 };
  371. sprintf_s(tmp, "Physical%d", i);
  372. params.add(tmp, vphs[i].GetString());
  373. }
  374. auto vads = SplitCString(ads, "#");
  375. for (int i = 0; i < vads.size(); ++i)
  376. {
  377. char tmp[64] = { 0 };
  378. sprintf_s(tmp, "AD%d", i);
  379. params.add(tmp, vads[i].GetString());
  380. }
  381. params.add("PointCount", (int)vphs.size());
  382. Request.add("P0", params);
  383. int sel = m_comboDetectorSelection.GetCurSel();
  384. if (sel == 0)
  385. {
  386. g_DiosAPIServer.ExecuteAction("MachineryCalSaveParamsofDetector", Request, Result, 30000);
  387. }
  388. else if (sel == 1)
  389. {
  390. g_DiosAPIServer.ExecuteAction("MachineryCalSaveParamsofDetectorHorizontal", Request, Result, 30000);
  391. }
  392. }
  393. void CDialogADCalibrationMain::OnBnClickedButtonEnterCalibration()
  394. {
  395. ResDataObject Request;
  396. ResDataObject oTemp;
  397. ResDataObject Result;
  398. Request.add("P0", oTemp);
  399. if (g_DiosAPIServer.ExecuteAction("MachineryEnterCalibration", Request, Result, 3000) == RET_SUCCEED)
  400. {
  401. }
  402. }
  403. void CDialogADCalibrationMain::OnBnClickedButtonExitCalibration()
  404. {
  405. ResDataObject Request;
  406. ResDataObject oTemp;
  407. ResDataObject Result;
  408. Request.add("P0", oTemp);
  409. if (g_DiosAPIServer.ExecuteAction("MachineryExitCalibration", Request, Result, 3000) == RET_SUCCEED)
  410. {
  411. }
  412. }
  413. void CDialogADCalibrationMain::OnBnClickedButtonResetSystem()
  414. {
  415. ResDataObject Request;
  416. ResDataObject oTemp;
  417. ResDataObject Result;
  418. Request.add("P0", oTemp);
  419. if (g_DiosAPIServer.ExecuteAction("MachineryRESET", Request, Result, 3000) == RET_SUCCEED)
  420. {
  421. }
  422. }
  423. void CDialogADCalibrationMain::OnBnClickedButtonCenteradjust()
  424. {
  425. ResDataObject Request;
  426. ResDataObject oTemp;
  427. ResDataObject Result;
  428. Request.add("P0", oTemp);
  429. if (g_DiosAPIServer.ExecuteAction("MachineryCenterAdjust", Request, Result, 3000) == RET_SUCCEED)
  430. {
  431. }
  432. }
  433. void CDialogADCalibrationMain::OnBnClickedButtonParking()
  434. {
  435. ResDataObject Request;
  436. ResDataObject oTemp;
  437. ResDataObject Result;
  438. oTemp.add("ParkingMode", 1);
  439. Request.add("P0", oTemp);
  440. if (g_DiosAPIServer.ExecuteAction("MachineryParkingTo", Request, Result, 3000) == RET_SUCCEED)
  441. {
  442. }
  443. }
  444. void CDialogADCalibrationMain::OnBnClickedButtonTubeAngleLowLimit()
  445. {
  446. ResDataObject Request;
  447. ResDataObject oTemp;
  448. ResDataObject Result;
  449. oTemp.add("ParkingMode", 2);
  450. Request.add("P0", oTemp);
  451. if (g_DiosAPIServer.ExecuteAction("MachineryParkingTo", Request, Result, 3000) == RET_SUCCEED)
  452. {
  453. }
  454. }
  455. void CDialogADCalibrationMain::OnBnClickedButtonTubeHeightLowLimit()
  456. {
  457. ResDataObject Request;
  458. ResDataObject oTemp;
  459. ResDataObject Result;
  460. oTemp.add("ParkingMode", 3);
  461. Request.add("P0", oTemp);
  462. if (g_DiosAPIServer.ExecuteAction("MachineryParkingTo", Request, Result, 3000) == RET_SUCCEED)
  463. {
  464. }
  465. }
  466. void CDialogADCalibrationMain::OnBnClickedButtonEnterSelftest()
  467. {
  468. ResDataObject Request;
  469. ResDataObject oTemp;
  470. ResDataObject Result;
  471. Request.add("P0", oTemp);
  472. if (g_DiosAPIServer.ExecuteAction("MachineryEnterMechnicalSelfTest", Request, Result, 3000) == RET_SUCCEED)
  473. {
  474. }
  475. }
  476. void CDialogADCalibrationMain::OnBnClickedButtonExitSelftest()
  477. {
  478. ResDataObject Request;
  479. ResDataObject oTemp;
  480. ResDataObject Result;
  481. Request.add("P0", oTemp);
  482. if (g_DiosAPIServer.ExecuteAction("MachineryExitMechnicalSelfTest", Request, Result, 3000) == RET_SUCCEED)
  483. {
  484. }
  485. }
  486. void CDialogADCalibrationMain::OnBnClickedButtonStartSelftest()
  487. {
  488. ResDataObject Request;
  489. ResDataObject oTemp;
  490. ResDataObject Result;
  491. CString highlimit, lowlimit, period, dutyCycle,repeatTime;
  492. m_selftestHighlimit.GetWindowText(highlimit);
  493. m_selftestlowlimit.GetWindowText(lowlimit);
  494. m_selftestperiod.GetWindowText(period);
  495. m_selftestdutycycle.GetWindowText(dutyCycle);
  496. m_selftestRepeatTime.GetWindowText(repeatTime);
  497. oTemp.add("DOF", m_selftestDOF.GetCurSel());
  498. oTemp.add("HighLimit", highlimit.GetString());
  499. oTemp.add("LowLimit", lowlimit.GetString());
  500. oTemp.add("Period", atoi(period.GetString()));
  501. oTemp.add("DutyCycle", dutyCycle.GetString());
  502. oTemp.add("RepeatTime", atoi(repeatTime.GetString()));
  503. Request.add("P0", oTemp);
  504. if (g_DiosAPIServer.ExecuteAction("MachineryStartMechnicalSelfTest", Request, Result, 3000) == RET_SUCCEED)
  505. {
  506. }
  507. }
  508. void CDialogADCalibrationMain::OnBnClickedButtonActiveTubeAngleZClear()
  509. {
  510. ResDataObject Request;
  511. ResDataObject oTemp;
  512. ResDataObject Result;
  513. Request.add("P0", oTemp);
  514. if (g_DiosAPIServer.ExecuteAction("MachineryActiveTubeAngleZAxisClear", Request, Result, 3000) == RET_SUCCEED)
  515. {
  516. }
  517. }
  518. void CDialogADCalibrationMain::OnBnClickedButtonCancelTubeAngleZClear()
  519. {
  520. ResDataObject Request;
  521. ResDataObject oTemp;
  522. ResDataObject Result;
  523. Request.add("P0", oTemp);
  524. if (g_DiosAPIServer.ExecuteAction("MachineryCancelTubeAngleZAxisClear", Request, Result, 3000) == RET_SUCCEED)
  525. {
  526. }
  527. }
  528. void CDialogADCalibrationMain::OnBnClickedButtonActiveTubeHeightZClear()
  529. {
  530. ResDataObject Request;
  531. ResDataObject oTemp;
  532. ResDataObject Result;
  533. Request.add("P0", oTemp);
  534. if (g_DiosAPIServer.ExecuteAction("MachineryActiveTubeHeightZAxisClear", Request, Result, 3000) == RET_SUCCEED)
  535. {
  536. }
  537. }
  538. void CDialogADCalibrationMain::OnBnClickedButtonCancelTubeHeightZClear()
  539. {
  540. ResDataObject Request;
  541. ResDataObject oTemp;
  542. ResDataObject Result;
  543. Request.add("P0", oTemp);
  544. if (g_DiosAPIServer.ExecuteAction("MachineryCancelTubeHeightZAxisClear", Request, Result, 3000) == RET_SUCCEED)
  545. {
  546. }
  547. }
  548. void CDialogADCalibrationMain::OnBnClickedButtonRotateToTubeAngleZAxis()
  549. {
  550. ResDataObject Request;
  551. ResDataObject oTemp;
  552. ResDataObject Result;
  553. Request.add("P0", oTemp);
  554. if (g_DiosAPIServer.ExecuteAction("MachineryTubeAngleRotateToZAxis", Request, Result, 3000) == RET_SUCCEED)
  555. {
  556. }
  557. }
  558. void CDialogADCalibrationMain::OnBnClickedButtonMoveToTubeHeightZAxis()
  559. {
  560. ResDataObject Request;
  561. ResDataObject oTemp;
  562. ResDataObject Result;
  563. Request.add("P0", oTemp);
  564. if (g_DiosAPIServer.ExecuteAction("MachineryTubeHeightMoveToZAxis", Request, Result, 3000) == RET_SUCCEED)
  565. {
  566. }
  567. }
  568. void CDialogADCalibrationMain::OnBnClickedButtonEmStop()
  569. {
  570. ResDataObject Request;
  571. ResDataObject oTemp;
  572. ResDataObject Result;
  573. Request.add("P0", oTemp);
  574. if (g_DiosAPIServer.ExecuteAction("MachineryForceStopAllMotion", Request, Result, 3000) == RET_SUCCEED)
  575. {
  576. }
  577. }
  578. void CDialogADCalibrationMain::SetExamMode(int mode)
  579. {
  580. ResDataObject Request;
  581. ResDataObject Result;
  582. if (mode == 0)
  583. {
  584. Request.add("P0", "Single");
  585. }
  586. else if (mode == 1)
  587. {
  588. Request.add("P0", "TOMO");
  589. }
  590. else if (mode == 2)
  591. {
  592. Request.add("P0", "CBCT");
  593. }
  594. if (g_DiosAPIServer.ExecuteAction("MachinerySetExpMode", Request, Result, 30000))
  595. {
  596. printf("MachinerySetExpMode Action Failed\n");
  597. }
  598. else
  599. {
  600. printf("MachinerySetExpMode Action Succeed\n");
  601. }
  602. //ResDataObject ExamDR;
  603. //ResDataObject ExamTomo;
  604. //ResDataObject ExamCBCT;
  605. //ResDataObject ExamInfo;
  606. //ExamDR.add("Single", "1");
  607. //ExamTomo.add("TOMO", "1");
  608. //ExamCBCT.add("CBCT", "1");
  609. //if (mode == 0)
  610. //{
  611. // ExamInfo.add("DX", ExamDR);
  612. //}
  613. //else if (mode == 1)
  614. //{
  615. // ExamInfo.add("DX", ExamTomo);
  616. //}
  617. //else if (mode == 2)
  618. //{
  619. // ExamInfo.add("DX", ExamCBCT);
  620. //}
  621. //Request.add("P0", ExamInfo);
  622. //if (g_DiosAPIServer.ExecuteAction("MachinerySetExamInfo", Request, Result, 30000))
  623. //{
  624. // printf("SetExamInfo Action Failed\n");
  625. //}
  626. //else
  627. //{
  628. // printf("SetExamInfo Action Succeed\n");
  629. //}
  630. //Request.clear(); Result.clear();
  631. //Request.add("P0", "DX");
  632. //if (g_DiosAPIServer.ExecuteAction("MachinerySelectExamMode", Request, Result, 30000) < RET_SUCCEED)
  633. //{
  634. // printf("SelectExamMode Action Failed\n");
  635. //}
  636. //else
  637. //{
  638. // printf("SelectExamMode Action Succeed\n");
  639. //}
  640. }
  641. void CDialogADCalibrationMain::OnBnClickedButtonSetPcodeParam()
  642. {
  643. int nCurSel = 1;
  644. SetWorkstation();
  645. nCurSel = m_examMode.GetCurSel();
  646. if (nCurSel < 0)
  647. {
  648. nCurSel = 1;
  649. }
  650. SetExamMode(nCurSel);
  651. ResDataObject Request;
  652. ResDataObject oTemp;
  653. ResDataObject Result;
  654. CString strPositionCode;
  655. m_pcode.GetWindowText(strPositionCode);
  656. Request.clear(); Result.clear();
  657. if (g_DiosAPIServer.ExecuteAction("MachineryFrameAcq", Request, Result, 30000) < RET_SUCCEED)
  658. {
  659. printf("FrameAcq Action Failed\n");
  660. }
  661. else
  662. {
  663. printf("FrameAcq Action Succeed\n");
  664. }
  665. oTemp.add("SID", "1.20");
  666. oTemp.add("PositionNumber", strPositionCode);
  667. Request.add("P0", oTemp);
  668. if (g_DiosAPIServer.ExecuteAction("MachinerySetTechParamsInfo", Request, Result, 30000) < RET_SUCCEED)
  669. {
  670. }
  671. }
  672. void CDialogADCalibrationMain::OnBnClickedButtonRotateTubeAnglePhy()
  673. {
  674. auto direction = m_rotateDirection.GetCurSel();
  675. CString strSteps;
  676. m_rotateStep.GetWindowText(strSteps);
  677. ResDataObject Request;
  678. ResDataObject oTemp;
  679. ResDataObject Result;
  680. oTemp.add("AsPhysical",1);
  681. oTemp.add("Orientation", direction);
  682. oTemp.add("StepNumber", strSteps.GetString());
  683. Request.add("P0", oTemp);
  684. g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeAngleRotate", Request, Result, 3000);
  685. }
  686. void CDialogADCalibrationMain::OnBnClickedButtonMoveTubeHeightPhy()
  687. {
  688. auto direction = m_tubeHeightDirection.GetCurSel();
  689. CString strSteps;
  690. m_tubeHeightStep.GetWindowText(strSteps);
  691. ResDataObject Request;
  692. ResDataObject oTemp;
  693. ResDataObject Result;
  694. oTemp.add("AsPhysical", 1);
  695. oTemp.add("Orientation", direction);
  696. oTemp.add("StepNumber", strSteps.GetString());
  697. Request.add("P0", oTemp);
  698. int sel = m_comboTubeLineSelection.GetCurSel();
  699. if (sel == 0)
  700. {
  701. g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeLineV", Request, Result, 3000);
  702. }
  703. else if (sel == 1)
  704. {
  705. g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeLineH", Request, Result, 3000);
  706. }
  707. }
  708. BOOL CDialogADCalibrationMain::OnInitDialog()
  709. {
  710. CDialogEx::OnInitDialog();
  711. m_examMode.AddString("RAD");
  712. m_examMode.AddString("TOMO");
  713. m_examMode.AddString("CBCT");
  714. ResDataObject obj1;
  715. obj1.add("sdsd",2996);
  716. CString strText((const char*)obj1["sdsd"]);
  717. m_rotateDirection.AddString("AntiClockwise");
  718. m_rotateDirection.AddString("Clockwise");
  719. m_tubeHeightDirection.AddString("Up");
  720. m_tubeHeightDirection.AddString("Down");
  721. m_selftestDOF.AddString("TubeAngle");
  722. m_selftestDOF.AddString("TubeHeight");
  723. m_rotateDirection.SetCurSel(0);
  724. m_tubeHeightDirection.SetCurSel(0);
  725. m_selftestDOF.SetCurSel(0);
  726. m_tubeAngleSvoStatus = 0;
  727. m_tubeHeightSvoStatus = 0;
  728. m_comboTubeLineSelection.AddString("Vertical");
  729. m_comboTubeLineSelection.AddString("Horizontal");
  730. m_comboTubeLineSelection.SetCurSel(0);
  731. m_comboDetectorSelection.AddString("Wall");
  732. m_comboDetectorSelection.AddString("Table");
  733. m_comboDetectorSelection.SetCurSel(0);
  734. if (g_DiosAPIServer.OpenMachinery() == DR_OK)
  735. {
  736. Sleep(3000);
  737. OnBnClickedButtonEnterCalibration();
  738. GetResetPos(0);
  739. }
  740. return TRUE;
  741. }
  742. void CDialogADCalibrationMain::OnClose()
  743. {
  744. CDialogEx::OnClose();
  745. }
  746. void CDialogADCalibrationMain::OnBnClickedButtonInsertTubeAngle()
  747. {
  748. ResDataObject Request;
  749. ResDataObject oTemp;
  750. ResDataObject Result;
  751. Request.add("P0", oTemp);
  752. if (g_DiosAPIServer.ExecuteAction("MachineryCalGetADofTubeAngle", Request, Result, 3000) == RET_SUCCEED)
  753. {
  754. ResDataObject obj1;
  755. try
  756. {
  757. obj1 = Result["P0"];
  758. CString strText((const char*)obj1["ADTubeAngle"]);
  759. m_tubeAngleAD.SetWindowText(strText);
  760. CString physicals;
  761. CString ads;
  762. m_tubeAngleCalPhysicals.GetWindowText(physicals);
  763. m_tubeAngleCalADs.GetWindowText(ads);
  764. if (ads != "")
  765. {
  766. ads = ads + "#" + strText;
  767. }
  768. else
  769. {
  770. ads = ads + strText;
  771. }
  772. m_tubeAngleCalADs.SetWindowText(ads);
  773. CDialogPhysicalInput ph;
  774. ph.DoModal();
  775. CString phy = ph.GetInput();
  776. if (physicals != "")
  777. {
  778. physicals = physicals + "#" + phy.Trim();
  779. }
  780. else
  781. {
  782. physicals = physicals + phy.Trim();
  783. }
  784. m_tubeAngleCalPhysicals.SetWindowText(physicals);
  785. }
  786. catch (ResDataObjectExption &exp)
  787. {
  788. printf("%s%s", exp.what(), "\\n");
  789. TPRINTA_ERROR(exp.what());
  790. }
  791. }
  792. }
  793. void CDialogADCalibrationMain::OnBnClickedButtonInsertTubeHeight()
  794. {
  795. ResDataObject Request;
  796. ResDataObject oTemp;
  797. ResDataObject Result;
  798. Request.add("P0", oTemp);
  799. if (g_DiosAPIServer.ExecuteAction("MachineryCalGetADofTubeLineV", Request, Result, 30000) == RET_SUCCEED)
  800. {
  801. string str = Result.encode();
  802. ResDataObject obj1;
  803. try
  804. {
  805. obj1 = Result["P0"];
  806. CString strText((const char*)obj1["ADTubeHeight"]);
  807. m_tubeHeightAD.SetWindowText(strText);
  808. CString physicals;
  809. CString ads;
  810. m_tubeHeightCalPhysicals.GetWindowText(physicals);
  811. m_tubHeightCalADs.GetWindowText(ads);
  812. if (ads != "")
  813. {
  814. ads = ads + "#" + strText;
  815. }
  816. else
  817. {
  818. ads = ads + strText;
  819. }
  820. m_tubHeightCalADs.SetWindowText(ads);
  821. CDialogPhysicalInput ph;
  822. ph.DoModal();
  823. CString phy = ph.GetInput();
  824. if (physicals != "")
  825. {
  826. physicals = physicals + "#" + phy.Trim();
  827. }
  828. else
  829. {
  830. physicals = physicals + phy.Trim();
  831. }
  832. m_tubeHeightCalPhysicals.SetWindowText(physicals);
  833. }
  834. catch (ResDataObjectExption &exp)
  835. {
  836. printf("%s%s", exp.what(), "\\n");
  837. TPRINTA_ERROR(exp.what());
  838. }
  839. }
  840. }
  841. void CDialogADCalibrationMain::OnBnClickedButtonInsertDetectorHeight()
  842. {
  843. ResDataObject Request;
  844. ResDataObject oTemp;
  845. ResDataObject Result;
  846. Request.add("P0", oTemp);
  847. if (g_DiosAPIServer.ExecuteAction("MachineryCalGetADofDetector", Request, Result, 3000) == RET_SUCCEED)
  848. {
  849. ResDataObject obj1;
  850. try
  851. {
  852. obj1 = Result["P0"];
  853. CString strText((const char*)obj1["ADDetectorHeight"]);
  854. m_detectorAD.SetWindowText(strText);
  855. CString physicals;
  856. CString ads;
  857. m_detectorHeightCalPhysicals.GetWindowText(physicals);
  858. m_detectorCalAds.GetWindowText(ads);
  859. if (ads != "")
  860. {
  861. ads = ads + "#" + strText;
  862. }
  863. else
  864. {
  865. ads = ads + strText;
  866. }
  867. m_detectorCalAds.SetWindowText(ads);
  868. CDialogPhysicalInput ph;
  869. ph.DoModal();
  870. CString phy = ph.GetInput();
  871. if (physicals != "")
  872. {
  873. physicals = physicals + "#" + phy.Trim();
  874. }
  875. else
  876. {
  877. physicals = physicals + phy.Trim();
  878. }
  879. m_detectorHeightCalPhysicals.SetWindowText(physicals);
  880. }
  881. catch (ResDataObjectExption &exp)
  882. {
  883. printf("%s%s", exp.what(), "\\n");
  884. TPRINTA_ERROR(exp.what());
  885. }
  886. }
  887. }
  888. void CDialogADCalibrationMain::OnBnClickedButtonAutoCaladTubeangle()
  889. {
  890. ResDataObject Request;
  891. ResDataObject oTemp;
  892. ResDataObject Result;
  893. CString current;
  894. m_autoadTubeAngleCurrent.GetWindowText(current);
  895. CString high;
  896. m_autoadTubeAngleHighlimit.GetWindowText(high);
  897. CString low;
  898. m_autoadTubeAngleLowlimit.GetWindowText(low);
  899. oTemp.add("DOF", 0);
  900. oTemp.add("CurrentHeight", current.GetString());
  901. oTemp.add("HighLimit", high.GetString());
  902. oTemp.add("LowLimit", low.GetString());
  903. Request.add("P0", oTemp);
  904. g_DiosAPIServer.ExecuteAction("MachineryAutoADCalibration", Request, Result, 3000);
  905. }
  906. void CDialogADCalibrationMain::OnBnClickedButtonAutoCaladTubeheight()
  907. {
  908. ResDataObject Request;
  909. ResDataObject oTemp;
  910. ResDataObject Result;
  911. CString current;
  912. m_autoadTubeHeightCurrent.GetWindowText(current);
  913. CString high;
  914. m_autoadTubeHeightHighlimit.GetWindowText(high);
  915. CString low;
  916. m_autoadTubeHeightLowlimit.GetWindowText(low);
  917. oTemp.add("DOF", 1);
  918. oTemp.add("CurrentHeight", current.GetString());
  919. oTemp.add("HighLimit", high.GetString());
  920. oTemp.add("LowLimit", low.GetString());
  921. Request.add("P0", oTemp);
  922. g_DiosAPIServer.ExecuteAction("MachineryAutoADCalibration", Request, Result, 3000);
  923. }
  924. void CDialogADCalibrationMain::OnBnClickedTubeAngleSvo()
  925. {
  926. if (m_tubeAngleSvoStatus == 0)
  927. {
  928. m_tubeAngleSvoStatus = 1;
  929. }
  930. else
  931. {
  932. m_tubeAngleSvoStatus = 0;
  933. }
  934. ResDataObject Request;
  935. ResDataObject oTemp;
  936. ResDataObject Result;
  937. oTemp.add("DOF", 0);
  938. oTemp.add("SvoStatus", m_tubeAngleSvoStatus);
  939. Request.add("P0", oTemp);
  940. g_DiosAPIServer.ExecuteAction("MachinerySetSvoStatus", Request, Result, 3000);
  941. }
  942. void CDialogADCalibrationMain::OnBnClickedButtonTubeheightSvo()
  943. {
  944. if (m_tubeHeightSvoStatus == 0)
  945. {
  946. m_tubeHeightSvoStatus = 1;
  947. }
  948. else
  949. {
  950. m_tubeHeightSvoStatus = 0;
  951. }
  952. ResDataObject Request;
  953. ResDataObject oTemp;
  954. ResDataObject Result;
  955. oTemp.add("DOF", 1);
  956. oTemp.add("SvoStatus", m_tubeHeightSvoStatus);
  957. Request.add("P0", oTemp);
  958. int sel = m_comboTubeLineSelection.GetCurSel();
  959. if (sel == 0)
  960. {
  961. g_DiosAPIServer.ExecuteAction("MachinerySetSvoStatus", Request, Result, 3000);
  962. }
  963. else if (sel == 1)
  964. {
  965. g_DiosAPIServer.ExecuteAction("MachinerySetSvoStatusTubeH", Request, Result, 3000);
  966. }
  967. }
  968. void CDialogADCalibrationMain::OnBnClickedRadioWall()
  969. {
  970. // TODO: 在此添加控件通知处理程序代码
  971. //ResDataObject Request;
  972. //ResDataObject Result;
  973. //Request.add("P0", "Wall");
  974. //g_DiosAPIServer.ExecuteAction("MachinerySetWorkstation", Request, Result, 3000);
  975. }
  976. void CDialogADCalibrationMain::OnBnClickedRadioTable()
  977. {
  978. // TODO: 在此添加控件通知处理程序代码
  979. //ResDataObject Request;
  980. //ResDataObject Result;
  981. //Request.add("P0", "Table");
  982. //g_DiosAPIServer.ExecuteAction("MachinerySetWorkstation", Request, Result, 3000);
  983. }
  984. void CDialogADCalibrationMain::SetWorkstation()
  985. {
  986. ResDataObject Request;
  987. ResDataObject Result;
  988. if (m_radioWSWall.GetCheck() == 1)
  989. {
  990. Request.add("P0", "Wall");
  991. }
  992. else if (m_radioWSTable.GetCheck() == 1)
  993. {
  994. Request.add("P0", "Table");
  995. }
  996. g_DiosAPIServer.ExecuteAction("MachinerySetWorkstation", Request, Result, 3000);
  997. }
  998. void CDialogADCalibrationMain::OnBnClickedButtonResetTubeAngleSavevalue()
  999. {
  1000. // TODO: 在此添加控件通知处理程序代码
  1001. ResDataObject Request;
  1002. ResDataObject oTemp;
  1003. ResDataObject Result;
  1004. CString strLowpos;
  1005. GetDlgItem(IDC_EDIT_RESET_TUBE_ANGLE_MIN)->GetWindowText(strLowpos);
  1006. oTemp.add("MotionUnit", "TubeAngle");
  1007. oTemp.add("LowPosition", strLowpos);
  1008. Request.add("P0", oTemp);
  1009. g_DiosAPIServer.ExecuteAction("MachineryCalSaveResetLowPosition", Request, Result, 3000);
  1010. }
  1011. void CDialogADCalibrationMain::OnBnClickedButtonResetTubeAngleEncoderzeroSavevalue()
  1012. {
  1013. // TODO: 在此添加控件通知处理程序代码
  1014. ResDataObject Request;
  1015. ResDataObject oTemp;
  1016. ResDataObject Result;
  1017. CString strEncoderZeroPos;
  1018. GetDlgItem(IDC_EDIT_RESET_TUBE_ANGLE_ENCODERZERO)->GetWindowText(strEncoderZeroPos);
  1019. oTemp.add("MotionUnit", "TubeAngle");
  1020. oTemp.add("EncoderZeroPosition", strEncoderZeroPos);
  1021. Request.add("P0", oTemp);
  1022. g_DiosAPIServer.ExecuteAction("MachineryCalSaveResetEcoderZeroPosition", Request, Result, 3000);
  1023. }
  1024. void CDialogADCalibrationMain::OnBnClickedButtonTubeLineSaveMinpos()
  1025. {
  1026. // TODO: 在此添加控件通知处理程序代码
  1027. ResDataObject Request;
  1028. ResDataObject oTemp;
  1029. ResDataObject Result;
  1030. CString strLowpos;
  1031. GetDlgItem(IDC_EDIT_TUBE_LINE_POS_MIN)->GetWindowText(strLowpos);
  1032. int sel = m_comboTubeLineSelection.GetCurSel();
  1033. if (sel == 0)
  1034. {
  1035. oTemp.add("MotionUnit", "TubeVertical");
  1036. }
  1037. else if (sel == 1)
  1038. {
  1039. oTemp.add("MotionUnit", "TubeHorizontal");
  1040. }
  1041. oTemp.add("LowPosition", strLowpos);
  1042. Request.add("P0", oTemp);
  1043. g_DiosAPIServer.ExecuteAction("MachineryCalSaveResetLowPosition", Request, Result, 3000);
  1044. }
  1045. void CDialogADCalibrationMain::OnBnClickedButtonTubeLineSaveEncoderzero()
  1046. {
  1047. // TODO: 在此添加控件通知处理程序代码
  1048. ResDataObject Request;
  1049. ResDataObject oTemp;
  1050. ResDataObject Result;
  1051. CString strEncoderZeroPos;
  1052. GetDlgItem(IDC_EDIT_TUBE_LINE_POS_ENCODER_ZERO)->GetWindowText(strEncoderZeroPos);
  1053. int sel = m_comboTubeLineSelection.GetCurSel();
  1054. if (sel == 0)
  1055. {
  1056. oTemp.add("MotionUnit", "TubeVertical");
  1057. }
  1058. else if (sel == 1)
  1059. {
  1060. oTemp.add("MotionUnit", "TubeHorizontal");
  1061. }
  1062. oTemp.add("EncoderZeroPosition", strEncoderZeroPos);
  1063. Request.add("P0", oTemp);
  1064. g_DiosAPIServer.ExecuteAction("MachineryCalSaveResetEcoderZeroPosition", Request, Result, 3000);
  1065. }
  1066. void CDialogADCalibrationMain::GetResetPos(int nTubeOrientation)
  1067. {
  1068. ResDataObject Request;
  1069. ResDataObject oTemp;
  1070. ResDataObject Result;
  1071. CString strlog;
  1072. if (g_DiosAPIServer.ExecuteAction("MachineryCalGetResetPosParam", Request, Result, 30000) == RET_SUCCEED)
  1073. {
  1074. CString strlog = Result.encode();
  1075. OutputDebugString(strlog);
  1076. ResDataObject obj1;
  1077. try
  1078. {
  1079. obj1 = Result["P0"];
  1080. CString strTextLow, strTextZero;
  1081. strlog.Format("select sel = %d", nTubeOrientation);
  1082. OutputDebugString(strlog);
  1083. if (nTubeOrientation == 0)
  1084. {
  1085. OutputDebugString("enter 0");
  1086. ResDataObject objTubeHeight = obj1["TubeHeight"];
  1087. m_fTubeHeightLowPos = atof(objTubeHeight["LowPosition"]);
  1088. m_fTubeHeightZeroPos = atof(objTubeHeight["EncoderZeroPosition"]);
  1089. strTextLow.Format("%0.3f", m_fTubeHeightLowPos);
  1090. strTextZero.Format("%0.3f", m_fTubeHeightZeroPos);
  1091. strlog.Format("TubeHeight, low pos=%s, zero pos=%s", strTextLow, strTextZero);
  1092. OutputDebugString(strlog);
  1093. }
  1094. else
  1095. {
  1096. ResDataObject objTubeHorizontal = obj1["TubeHorizontal"];
  1097. m_fTubeHorizontalLowPos = atof(objTubeHorizontal["LowPosition"]);
  1098. m_fTubeHorizontalZeroPos = atof(objTubeHorizontal["EncoderZeroPosition"]);
  1099. strTextLow.Format("%0.3f", m_fTubeHorizontalLowPos);
  1100. strTextZero.Format("%0.3f", m_fTubeHorizontalZeroPos);
  1101. strlog.Format("TubeHorizontal, low pos=%s, zero pos=%s", strTextLow, strTextZero);
  1102. OutputDebugString(strlog);
  1103. }
  1104. GetDlgItem(IDC_EDIT_TUBE_LINE_POS_MIN)->SetWindowText(strTextLow);
  1105. GetDlgItem(IDC_EDIT_TUBE_LINE_POS_ENCODER_ZERO)->SetWindowText(strTextZero);
  1106. }
  1107. catch (ResDataObjectExption& exp)
  1108. {
  1109. strlog.Format("GetResetPos catch, %s", exp.what());
  1110. OutputDebugString(strlog);
  1111. TPRINTA_ERROR(exp.what());
  1112. }
  1113. }
  1114. }
  1115. void CDialogADCalibrationMain::OnCbnSelchangeComboLineSelection()
  1116. {
  1117. // TODO: 在此添加控件通知处理程序代码
  1118. }
  1119. void CDialogADCalibrationMain::OnCbnSelendokComboLineSelection()
  1120. {
  1121. // TODO: 在此添加控件通知处理程序代码
  1122. int nsel = m_comboTubeLineSelection.GetCurSel();
  1123. GetResetPos(nsel);
  1124. }