// DialogADCalibrationMain.cpp : 实现文件 // #include "stdafx.h" #include "DIOS_3DDR_MechCal.h" #include "DialogADCalibrationMain.h" #include "afxdialogex.h" #include "DialogPhysicalInput.h" static vector SplitCString(CString strSource, CString ch) { vector vecString; int iPos = 0; CString strTmp; strTmp = strSource.Tokenize(ch, iPos); while (strTmp.Trim() != _T("")) { vecString.push_back(strTmp); strTmp = strSource.Tokenize(ch, iPos); } return vecString; } // CDialogADCalibrationMain 对话框 IMPLEMENT_DYNAMIC(CDialogADCalibrationMain, CDialogEx) CDialogADCalibrationMain::CDialogADCalibrationMain(CWnd* pParent /*=NULL*/) : CDialogEx(CDialogADCalibrationMain::IDD, pParent) { } CDialogADCalibrationMain::~CDialogADCalibrationMain() { } void CDialogADCalibrationMain::DoDataExchange(CDataExchange* pDX) { CDialogEx::DoDataExchange(pDX); DDX_Control(pDX, IDC_COMBO_ROTATE_DIRECTION, m_rotateDirection); DDX_Control(pDX, IDC_EDIT_ROTATE_TUBE_ANGLE_STEP, m_rotateStep); DDX_Control(pDX, IDC_COMBO_MOVE_DIRECTION, m_tubeHeightDirection); DDX_Control(pDX, IDC_EDIT_MOVE_TUBE_HEIGHT_STEP, m_tubeHeightStep); DDX_Control(pDX, IDC_EDIT_AD_VALUE_TUBE_ANGLE, m_tubeAngleAD); DDX_Control(pDX, IDC_EDIT_TUBE_ANGLE_ADS, m_tubeAngleCalADs); DDX_Control(pDX, IDC_EDIT_TUBE_ANGLE_PHYSICALS, m_tubeAngleCalPhysicals); DDX_Control(pDX, IDC_EDIT_AD_VALUE_TUBE_HEIGHT, m_tubeHeightAD); DDX_Control(pDX, IDC_EDIT_TUBE_HEIGHT_ADS, m_tubHeightCalADs); DDX_Control(pDX, IDC_EDIT_TUBE_HEIGHT_PHYSICALS, m_tubeHeightCalPhysicals); DDX_Control(pDX, IDC_EDIT_AD_VALUE_DET_HEIGHT, m_detectorAD); DDX_Control(pDX, IDC_EDIT_DET_HEIGHT_ADS, m_detectorCalAds); DDX_Control(pDX, IDC_EDIT_DET_HEIGHT_PHYSICALS, m_detectorHeightCalPhysicals); DDX_Control(pDX, IDC_EDIT_ENCODER_VALUE_TUBE_ANGLE, m_tubeAngleEncoder); DDX_Control(pDX, IDC_EDIT_ENCODER_VALUE_TUBE_HEIGHT, m_tubeHeightEncoder); DDX_Control(pDX, IDC_EDIT_PCODE, m_pcode); DDX_Control(pDX, IDC_COMBO_EX_MODE, m_examMode); DDX_Control(pDX, IDC_EDIT_C_TUBE_ANGLE, m_autoadTubeAngleCurrent); DDX_Control(pDX, IDC_EDIT_H_TUBE_ANGLE, m_autoadTubeAngleHighlimit); DDX_Control(pDX, IDC_EDIT_L_TUBEANGLE, m_autoadTubeAngleLowlimit); DDX_Control(pDX, IDC_EDIT_C_TUBE_HEIGHT, m_autoadTubeHeightCurrent); DDX_Control(pDX, IDC_EDIT_H_TUBE_HEIGHT, m_autoadTubeHeightHighlimit); DDX_Control(pDX, IDC_EDIT_L_TUBEHEIGHT, m_autoadTubeHeightLowlimit); DDX_Control(pDX, IDC_COMBO_SELFT_DOF, m_selftestDOF); DDX_Control(pDX, IDC_EDIT_SELFT_HIGH_LIMIT, m_selftestHighlimit); DDX_Control(pDX, IDC_EDIT_SELFT_LOW_LIMIT, m_selftestlowlimit); DDX_Control(pDX, IDC_EDIT_SELFT_PERIOD, m_selftestperiod); DDX_Control(pDX, IDC_EDIT_SELFT_DUTYCYCLE, m_selftestdutycycle); DDX_Control(pDX, IDC_EDIT2, m_selftestRepeatTime); } BEGIN_MESSAGE_MAP(CDialogADCalibrationMain, CDialogEx) ON_BN_CLICKED(IDC_BUTTON_ROTATE_TUBE_ANGLE, &CDialogADCalibrationMain::OnBnClickedButtonRotateTubeAngle) ON_BN_CLICKED(IDC_BUTTON_MOVE_TUBE_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonMoveTubeHeight) ON_BN_CLICKED(IDC_BUTTON_READ_AD_TUBE_ANGLE, &CDialogADCalibrationMain::OnBnClickedButtonReadAdTubeAngle) ON_BN_CLICKED(IDC_BUTTON_READ_AD_TUBE_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonReadAdTubeHeight) ON_BN_CLICKED(IDC_BUTTON_READ_AD_DET_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonReadAdDetHeight) ON_BN_CLICKED(IDC_BUTTON_CAL_TUBE_ANGLE_AD, &CDialogADCalibrationMain::OnBnClickedButtonCalTubeAngleAd) ON_BN_CLICKED(IDC_BUTTON_CAL_TUBE_HEIGHT_AD, &CDialogADCalibrationMain::OnBnClickedButtonCalTubeHeightAd) ON_BN_CLICKED(IDC_BUTTON_CAL_DET_HEIGHT_AD, &CDialogADCalibrationMain::OnBnClickedButtonCalDetHeightAd) ON_WM_CLOSE() ON_BN_CLICKED(IDC_BUTTON_READ_ENCODER_TUBE_ANGLE, &CDialogADCalibrationMain::OnBnClickedButtonReadEncoderTubeAngle) ON_BN_CLICKED(IDC_BUTTON_READ_ENCODER_TUBE_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonReadEncoderTubeHeight) ON_BN_CLICKED(IDC_BUTTON_ENTER_CALIBRATION, &CDialogADCalibrationMain::OnBnClickedButtonEnterCalibration) ON_BN_CLICKED(IDC_BUTTON_EXIT_CALIBRATION, &CDialogADCalibrationMain::OnBnClickedButtonExitCalibration) ON_BN_CLICKED(IDC_BUTTON_RESET_SYSTEM, &CDialogADCalibrationMain::OnBnClickedButtonResetSystem) ON_BN_CLICKED(ID_BUTTON_CENTERADJUST, &CDialogADCalibrationMain::OnBnClickedButtonCenteradjust) ON_BN_CLICKED(ID_BUTTON_PARKING, &CDialogADCalibrationMain::OnBnClickedButtonParking) ON_BN_CLICKED(ID_BUTTON_TUBE_ANGLE_LOW_LIMIT, &CDialogADCalibrationMain::OnBnClickedButtonTubeAngleLowLimit) ON_BN_CLICKED(ID_BUTTON_TUBE_HEIGHT_LOW_LIMIT, &CDialogADCalibrationMain::OnBnClickedButtonTubeHeightLowLimit) ON_BN_CLICKED(IDC_BUTTON_ENTER_SELFTEST, &CDialogADCalibrationMain::OnBnClickedButtonEnterSelftest) ON_BN_CLICKED(IDC_BUTTON_EXIT_SELFTEST, &CDialogADCalibrationMain::OnBnClickedButtonExitSelftest) ON_BN_CLICKED(IDC_BUTTON_START_SELFTEST, &CDialogADCalibrationMain::OnBnClickedButtonStartSelftest) ON_BN_CLICKED(IDC_BUTTON_ACTIVE_TUBE_ANGLE_Z_CLEAR, &CDialogADCalibrationMain::OnBnClickedButtonActiveTubeAngleZClear) ON_BN_CLICKED(IDC_BUTTON_CANCEL_TUBE_ANGLE_Z_CLEAR, &CDialogADCalibrationMain::OnBnClickedButtonCancelTubeAngleZClear) ON_BN_CLICKED(IDC_BUTTON_ACTIVE_TUBE_HEIGHT_Z_CLEAR, &CDialogADCalibrationMain::OnBnClickedButtonActiveTubeHeightZClear) ON_BN_CLICKED(IDC_BUTTON_CANCEL_TUBE_HEIGHT_Z_CLEAR, &CDialogADCalibrationMain::OnBnClickedButtonCancelTubeHeightZClear) ON_BN_CLICKED(IDC_BUTTON_ROTATE_TO_TUBE_ANGLE_Z_AXIS, &CDialogADCalibrationMain::OnBnClickedButtonRotateToTubeAngleZAxis) ON_BN_CLICKED(IDC_BUTTON_MOVE_TO_TUBE_HEIGHT_Z_AXIS, &CDialogADCalibrationMain::OnBnClickedButtonMoveToTubeHeightZAxis) ON_BN_CLICKED(IDC_BUTTON_EM_STOP, &CDialogADCalibrationMain::OnBnClickedButtonEmStop) ON_BN_CLICKED(IDC_BUTTON_SET_PCODE_PARAM, &CDialogADCalibrationMain::OnBnClickedButtonSetPcodeParam) ON_BN_CLICKED(IDC_BUTTON_ROTATE_TUBE_ANGLE_PHY, &CDialogADCalibrationMain::OnBnClickedButtonRotateTubeAnglePhy) ON_BN_CLICKED(IDC_BUTTON_MOVE_TUBE_HEIGHT_PHY, &CDialogADCalibrationMain::OnBnClickedButtonMoveTubeHeightPhy) ON_BN_CLICKED(IDC_BUTTON_INSERT_TUBE_ANGLE, &CDialogADCalibrationMain::OnBnClickedButtonInsertTubeAngle) ON_BN_CLICKED(IDC_BUTTON_INSERT_TUBE_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonInsertTubeHeight) ON_BN_CLICKED(IDC_BUTTON_INSERT_Detector_HEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonInsertDetectorHeight) ON_BN_CLICKED(IDC_BUTTON_AUTO_CALAD_TUBEANGLE, &CDialogADCalibrationMain::OnBnClickedButtonAutoCaladTubeangle) ON_BN_CLICKED(IDC_BUTTON_AUTO_CALAD_TUBEHEIGHT, &CDialogADCalibrationMain::OnBnClickedButtonAutoCaladTubeheight) ON_BN_CLICKED(IDC_TUBE_ANGLE_SVO, &CDialogADCalibrationMain::OnBnClickedTubeAngleSvo) ON_BN_CLICKED(IDC_BUTTON_TUBEHEIGHT_SVO, &CDialogADCalibrationMain::OnBnClickedButtonTubeheightSvo) END_MESSAGE_MAP() // CDialogADCalibrationMain 消息处理程序 void CDialogADCalibrationMain::OnBnClickedButtonRotateTubeAngle() { auto direction = m_rotateDirection.GetCurSel(); CString strSteps; m_rotateStep.GetWindowText(strSteps); auto steps = atoi(strSteps.GetString()); ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("Orientation", direction); oTemp.add("StepNumber", steps); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("CalMotionTubeAngleRotate", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedButtonMoveTubeHeight() { auto direction = m_tubeHeightDirection.GetCurSel(); CString strSteps; m_tubeHeightStep.GetWindowText(strSteps); auto steps = atoi(strSteps.GetString()); ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("Orientation", direction); oTemp.add("StepNumber", steps); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("CalMotionTubeLineV", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedButtonReadAdTubeAngle() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetADofTubeAngle", Request, Result, 3000) == RET_SUCCEED) { ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["ADTubeAngle"]); m_tubeAngleAD.SetWindowText(strText); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogADCalibrationMain::OnBnClickedButtonReadAdTubeHeight() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetADofTubeLineV", Request, Result, 30000) == RET_SUCCEED) { string str = Result.encode(); ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["ADTubeHeight"]); m_tubeHeightAD.SetWindowText(strText); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogADCalibrationMain::OnBnClickedButtonReadAdDetHeight() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetADofDetector", Request, Result, 3000) == RET_SUCCEED) { ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["ADDetectorHeight"]); m_detectorAD.SetWindowText(strText); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogADCalibrationMain::OnBnClickedButtonReadEncoderTubeAngle() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetEncoderOfTubeAngle", Request, Result, 3000) == RET_SUCCEED) { ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["EncoderTubeAngle"]); m_tubeAngleEncoder.SetWindowText(strText); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogADCalibrationMain::OnBnClickedButtonReadEncoderTubeHeight() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetEncoderofTubeLineV", Request, Result, 30000) == RET_SUCCEED) { string str = Result.encode(); ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["EncoderTubeHeight"]); m_tubeHeightEncoder.SetWindowText(strText); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogADCalibrationMain::OnBnClickedButtonCalTubeAngleAd() { ResDataObject Request; ResDataObject Result; CString physicals; CString ads; ResDataObject params; m_tubeAngleCalPhysicals.GetWindowText(physicals); m_tubeAngleCalADs.GetWindowText(ads); auto vphs = SplitCString(physicals, "#"); for (int i = 0; i < vphs.size();++i) { char tmp[64] = { 0 }; sprintf_s(tmp, "Physical%d", i); params.add(tmp, vphs[i].GetString()); } auto vads = SplitCString(ads,"#"); for (int i = 0; i < vads.size();++i) { char tmp[64] = { 0 }; sprintf_s(tmp, "AD%d", i); params.add(tmp, vads[i].GetString()); } params.add("PointCount", (int)vphs.size()); Request.add("P0", params); if (g_DiosAPIServer.ExecuteAction("CalSaveParamsofTubeAngle", Request, Result, 30000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonCalTubeHeightAd() { ResDataObject Request; ResDataObject Result; CString physicals; CString ads; ResDataObject params; m_tubeHeightCalPhysicals.GetWindowText(physicals); m_tubHeightCalADs.GetWindowText(ads); auto vphs = SplitCString(physicals, "#"); for (int i = 0; i < vphs.size(); ++i) { char tmp[64] = { 0 }; sprintf_s(tmp, "Physical%d", i); params.add(tmp, vphs[i].GetString()); } auto vads = SplitCString(ads, "#"); for (int i = 0; i < vads.size(); ++i) { char tmp[64] = { 0 }; sprintf_s(tmp, "AD%d", i); params.add(tmp, vads[i].GetString()); } params.add("PointCount", (int)vphs.size()); Request.add("P0", params); if (g_DiosAPIServer.ExecuteAction("CalSaveParamsofTubeLiveV", Request, Result, 30000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonCalDetHeightAd() { ResDataObject Request; ResDataObject Result; CString physicals; CString ads; ResDataObject params; m_detectorHeightCalPhysicals.GetWindowText(physicals); m_detectorCalAds.GetWindowText(ads); auto vphs = SplitCString(physicals, "#"); for (int i = 0; i < vphs.size(); ++i) { char tmp[64] = { 0 }; sprintf_s(tmp, "Physical%d", i); params.add(tmp, vphs[i].GetString()); } auto vads = SplitCString(ads, "#"); for (int i = 0; i < vads.size(); ++i) { char tmp[64] = { 0 }; sprintf_s(tmp, "AD%d", i); params.add(tmp, vads[i].GetString()); } params.add("PointCount", (int)vphs.size()); Request.add("P0", params); if (g_DiosAPIServer.ExecuteAction("CalSaveParamsofDetector", Request, Result, 30000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonEnterCalibration() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("EnterCalibration", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonExitCalibration() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("ExitCalibration", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonResetSystem() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("RESET", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonCenteradjust() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("ParkingMode", 0); Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("ParkingTo", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonParking() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("ParkingMode", 1); Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("ParkingTo", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonTubeAngleLowLimit() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("ParkingMode", 2); Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("ParkingTo", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonTubeHeightLowLimit() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("ParkingMode", 3); Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("ParkingTo", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonEnterSelftest() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("EnterMechnicalSelfTest", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonExitSelftest() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("ExitMechnicalSelfTest", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonStartSelftest() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString highlimit, lowlimit, period, dutyCycle,repeatTime; m_selftestHighlimit.GetWindowText(highlimit); m_selftestlowlimit.GetWindowText(lowlimit); m_selftestperiod.GetWindowText(period); m_selftestdutycycle.GetWindowText(dutyCycle); m_selftestRepeatTime.GetWindowText(repeatTime); oTemp.add("DOF", m_selftestDOF.GetCurSel()); oTemp.add("HighLimit", highlimit.GetString()); oTemp.add("LowLimit", lowlimit.GetString()); oTemp.add("Period", atoi(period.GetString())); oTemp.add("DutyCycle", dutyCycle.GetString()); oTemp.add("RepeatTime", atoi(repeatTime.GetString())); Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("StartMechnicalSelfTest", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonActiveTubeAngleZClear() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("ActiveTubeAngleZAxisClear", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonCancelTubeAngleZClear() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CancelTubeAngleZAxisClear", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonActiveTubeHeightZClear() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("ActiveTubeHeightZAxisClear", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonCancelTubeHeightZClear() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CancelTubeHeightZAxisClear", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonRotateToTubeAngleZAxis() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("TubeAngleRotateToZAxis", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonMoveToTubeHeightZAxis() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("TubeHeightMoveToZAxis", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonEmStop() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("ForceStopAllMotion", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::SetExamMode(int mode) { ResDataObject Request; ResDataObject Result; ResDataObject ExamDR; ResDataObject ExamTomo; ResDataObject ExamCBCT; //"RF":"Tomo" : "1" ResDataObject ExamInfo; ExamDR.add("Single", "1"); ExamTomo.add("TOMO", "1"); ExamCBCT.add("CBCT","1"); if (mode == 0) { ExamInfo.add("DX", ExamDR); } else if (mode == 1) { ExamInfo.add("DX", ExamTomo); } else if (mode == 2) { ExamInfo.add("DX", ExamCBCT); } Request.add("P0", ExamInfo); if (g_DiosAPIServer.ExecuteAction("SetExamInfo", Request, Result, 30000)) { printf("SetExamInfo Action Failed\n"); } else { printf("SetExamInfo Action Succeed\n"); } Request.clear(); Result.clear(); Request.add("P0", "DX"); if (g_DiosAPIServer.ExecuteAction("SelectExamMode", Request, Result, 30000) < RET_SUCCEED) { printf("SelectExamMode Action Failed\n"); } else { printf("SelectExamMode Action Succeed\n"); } } void CDialogADCalibrationMain::OnBnClickedButtonSetPcodeParam() { int nCurSel = 1; nCurSel = m_examMode.GetCurSel(); if (nCurSel < 0) { nCurSel = 1; } SetExamMode(nCurSel); ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString strPositionCode; m_pcode.GetWindowText(strPositionCode); oTemp.add("SID", "1.20"); oTemp.add("PositionNumber", strPositionCode); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("SetTechParamsInfo", Request, Result, 30000); Request.clear(); Result.clear(); if (g_DiosAPIServer.ExecuteAction("FramePrep", Request, Result, 30000) < RET_SUCCEED) { printf("FramePrep Action Failed\n"); } else { printf("FramePrep Action Succeed\n"); } Request.clear(); Result.clear(); if (g_DiosAPIServer.ExecuteAction("FrameReady", Request, Result, 30000) < RET_SUCCEED) { printf("FrameReady Action Failed\n"); } else { printf("FrameReady Action Succeed\n"); } Request.clear(); Result.clear(); if (g_DiosAPIServer.ExecuteAction("FrameAcq", Request, Result, 30000) < RET_SUCCEED) { printf("FrameAcq Action Failed\n"); } else { printf("FrameAcq Action Succeed\n"); } } void CDialogADCalibrationMain::OnBnClickedButtonRotateTubeAnglePhy() { auto direction = m_rotateDirection.GetCurSel(); CString strSteps; m_rotateStep.GetWindowText(strSteps); ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("AsPhysical",1); oTemp.add("Orientation", direction); oTemp.add("StepNumber", strSteps.GetString()); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("CalMotionTubeAngleRotate", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedButtonMoveTubeHeightPhy() { auto direction = m_tubeHeightDirection.GetCurSel(); CString strSteps; m_tubeHeightStep.GetWindowText(strSteps); ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("AsPhysical", 1); oTemp.add("Orientation", direction); oTemp.add("StepNumber", strSteps.GetString()); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("CalMotionTubeLineV", Request, Result, 3000); } BOOL CDialogADCalibrationMain::OnInitDialog() { CDialogEx::OnInitDialog(); m_examMode.AddString("RAD"); m_examMode.AddString("TOMO"); m_examMode.AddString("CBCT"); ResDataObject obj1; obj1.add("sdsd",2996); CString strText((const char*)obj1["sdsd"]); m_rotateDirection.AddString("AntiClockwise"); m_rotateDirection.AddString("Clockwise"); m_tubeHeightDirection.AddString("Up"); m_tubeHeightDirection.AddString("Down"); m_selftestDOF.AddString("TubeAngle"); m_selftestDOF.AddString("TubeHeight"); m_rotateDirection.SetCurSel(0); m_tubeHeightDirection.SetCurSel(0); m_selftestDOF.SetCurSel(0); m_tubeAngleSvoStatus = 0; m_tubeHeightSvoStatus = 0; if (g_DiosAPIServer.OpenMachinery() == DR_OK) { Sleep(2000); OnBnClickedButtonEnterCalibration(); } return TRUE; } void CDialogADCalibrationMain::OnClose() { CDialogEx::OnClose(); } void CDialogADCalibrationMain::OnBnClickedButtonInsertTubeAngle() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetADofTubeAngle", Request, Result, 3000) == RET_SUCCEED) { ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["ADTubeAngle"]); m_tubeAngleAD.SetWindowText(strText); CString physicals; CString ads; m_tubeAngleCalPhysicals.GetWindowText(physicals); m_tubeAngleCalADs.GetWindowText(ads); if (ads != "") { ads = ads + "#" + strText; } else { ads = ads + strText; } m_tubeAngleCalADs.SetWindowText(ads); CDialogPhysicalInput ph; ph.DoModal(); CString phy = ph.GetInput(); if (physicals != "") { physicals = physicals + "#" + phy.Trim(); } else { physicals = physicals + phy.Trim(); } m_tubeAngleCalPhysicals.SetWindowText(physicals); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogADCalibrationMain::OnBnClickedButtonInsertTubeHeight() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetADofTubeLineV", Request, Result, 30000) == RET_SUCCEED) { string str = Result.encode(); ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["ADTubeHeight"]); m_tubeHeightAD.SetWindowText(strText); CString physicals; CString ads; m_tubeHeightCalPhysicals.GetWindowText(physicals); m_tubHeightCalADs.GetWindowText(ads); if (ads != "") { ads = ads + "#" + strText; } else { ads = ads + strText; } m_tubHeightCalADs.SetWindowText(ads); CDialogPhysicalInput ph; ph.DoModal(); CString phy = ph.GetInput(); if (physicals != "") { physicals = physicals + "#" + phy.Trim(); } else { physicals = physicals + phy.Trim(); } m_tubeHeightCalPhysicals.SetWindowText(physicals); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogADCalibrationMain::OnBnClickedButtonInsertDetectorHeight() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("CalGetADofDetector", Request, Result, 3000) == RET_SUCCEED) { ResDataObject obj1; try { obj1 = Result["P0"]; CString strText((const char*)obj1["ADDetectorHeight"]); m_detectorAD.SetWindowText(strText); CString physicals; CString ads; m_detectorHeightCalPhysicals.GetWindowText(physicals); m_detectorCalAds.GetWindowText(ads); if (ads != "") { ads = ads + "#" + strText; } else { ads = ads + strText; } m_detectorCalAds.SetWindowText(ads); CDialogPhysicalInput ph; ph.DoModal(); CString phy = ph.GetInput(); if (physicals != "") { physicals = physicals + "#" + phy.Trim(); } else { physicals = physicals + phy.Trim(); } m_detectorHeightCalPhysicals.SetWindowText(physicals); } catch (ResDataObjectExption &exp) { printf("%s%s", exp.what(), "\\n"); TPRINTA_ERROR(exp.what()); } } } void CDialogADCalibrationMain::OnBnClickedButtonAutoCaladTubeangle() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString current; m_autoadTubeAngleCurrent.GetWindowText(current); CString high; m_autoadTubeAngleHighlimit.GetWindowText(high); CString low; m_autoadTubeAngleLowlimit.GetWindowText(low); oTemp.add("DOF", 0); oTemp.add("CurrentHeight", current.GetString()); oTemp.add("HighLimit", high.GetString()); oTemp.add("LowLimit", low.GetString()); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("AutoADCalibration", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedButtonAutoCaladTubeheight() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString current; m_autoadTubeHeightCurrent.GetWindowText(current); CString high; m_autoadTubeHeightHighlimit.GetWindowText(high); CString low; m_autoadTubeHeightLowlimit.GetWindowText(low); oTemp.add("DOF", 1); oTemp.add("CurrentHeight", current.GetString()); oTemp.add("HighLimit", high.GetString()); oTemp.add("LowLimit", low.GetString()); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("AutoADCalibration", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedTubeAngleSvo() { if (m_tubeAngleSvoStatus == 0) { m_tubeAngleSvoStatus = 1; } else { m_tubeAngleSvoStatus = 0; } ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("DOF", 0); oTemp.add("SvoStatus", m_tubeAngleSvoStatus); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("SetSvoStatus", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedButtonTubeheightSvo() { if (m_tubeHeightSvoStatus == 0) { m_tubeHeightSvoStatus = 1; } else { m_tubeHeightSvoStatus = 0; } ResDataObject Request; ResDataObject oTemp; ResDataObject Result; oTemp.add("DOF", 1); oTemp.add("SvoStatus", m_tubeHeightSvoStatus); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("SetSvoStatus", Request, Result, 3000); }