// DialogADCalibrationMain.cpp : 实现文件 // #include "stdafx.h" #include "DIOS_3DDR_MechCal.h" #include "DialogADCalibrationMain.h" #include "afxdialogex.h" #include "DialogPhysicalInput.h" static std::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); DDX_Control(pDX, IDC_COMBO_LINE_SELECTION, m_comboTubeLineSelection); DDX_Control(pDX, IDC_COMBO_DETECTOR_SELECTION, m_comboDetectorSelection); DDX_Control(pDX, IDC_RADIO_WALL, m_radioWSWall); DDX_Control(pDX, IDC_RADIO_TABLE, m_radioWSTable); } 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) ON_BN_CLICKED(IDC_RADIO_WALL, &CDialogADCalibrationMain::OnBnClickedRadioWall) ON_BN_CLICKED(IDC_RADIO_TABLE, &CDialogADCalibrationMain::OnBnClickedRadioTable) ON_BN_CLICKED(IDC_BUTTON_RESET_TUBE_ANGLE_SAVEVALUE, &CDialogADCalibrationMain::OnBnClickedButtonResetTubeAngleSavevalue) ON_BN_CLICKED(IDC_BUTTON_RESET_TUBE_ANGLE_ENCODERZERO_SAVEVALUE, &CDialogADCalibrationMain::OnBnClickedButtonResetTubeAngleEncoderzeroSavevalue) ON_BN_CLICKED(IDC_BUTTON_TUBE_LINE_SAVE_MINPOS, &CDialogADCalibrationMain::OnBnClickedButtonTubeLineSaveMinpos) ON_BN_CLICKED(IDC_BUTTON_TUBE_LINE_SAVE_ENCODERZERO, &CDialogADCalibrationMain::OnBnClickedButtonTubeLineSaveEncoderzero) ON_CBN_SELCHANGE(IDC_COMBO_LINE_SELECTION, &CDialogADCalibrationMain::OnCbnSelchangeComboLineSelection) ON_CBN_SELENDOK(IDC_COMBO_LINE_SELECTION, &CDialogADCalibrationMain::OnCbnSelendokComboLineSelection) 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("MachineryCalMotionTubeAngleRotate", 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); int sel = m_comboTubeLineSelection.GetCurSel(); if (sel == 0) { g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeLineV", Request, Result, 3000); } else if (sel == 1) { g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeLineH", Request, Result, 3000); } } void CDialogADCalibrationMain::OnBnClickedButtonReadAdTubeAngle() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryCalGetADofTubeAngle", 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); dios_result res = RET_SUCCEED; int sel = m_comboTubeLineSelection.GetCurSel(); if (sel == 0) { res = g_DiosAPIServer.ExecuteAction("MachineryCalGetADofTubeLineV", Request, Result, 30000); } else if (sel == 1) { res = g_DiosAPIServer.ExecuteAction("MachineryCalGetADofTubeLineH", Request, Result, 30000); } if (res == 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); dios_result res = RET_SUCCEED; int sel = m_comboDetectorSelection.GetCurSel(); if (sel == 0) { res = g_DiosAPIServer.ExecuteAction("MachineryCalGetADofDetector", Request, Result, 30000); } else if (sel == 1) { res = g_DiosAPIServer.ExecuteAction("MachineryCalGetADofHorizontalDetector", Request, Result, 30000); } if (res == 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("MachineryCalGetEncoderOfTubeAngle", 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); dios_result res = RET_SUCCEED; int sel = m_comboTubeLineSelection.GetCurSel(); if (sel == 0) { res = g_DiosAPIServer.ExecuteAction("MachineryCalGetEncoderofTubeLineV", Request, Result, 30000); } else if (sel == 1) { res = g_DiosAPIServer.ExecuteAction("MachineryCalGetEncoderofTubeLineH", Request, Result, 30000); } if (res == 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("MachineryCalSaveParamsofTubeAngle", 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); int sel = m_comboTubeLineSelection.GetCurSel(); if (sel == 0) { g_DiosAPIServer.ExecuteAction("MachineryCalSaveParamsofTubeLiveV", Request, Result, 30000); } else if (sel == 1) { g_DiosAPIServer.ExecuteAction("MachineryCalSaveParamsofTubeLiveH", Request, Result, 30000); } } 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); int sel = m_comboDetectorSelection.GetCurSel(); if (sel == 0) { g_DiosAPIServer.ExecuteAction("MachineryCalSaveParamsofDetector", Request, Result, 30000); } else if (sel == 1) { g_DiosAPIServer.ExecuteAction("MachineryCalSaveParamsofDetectorHorizontal", Request, Result, 30000); } } void CDialogADCalibrationMain::OnBnClickedButtonEnterCalibration() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryEnterCalibration", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonExitCalibration() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryExitCalibration", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonResetSystem() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryRESET", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonCenteradjust() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryCenterAdjust", 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("MachineryParkingTo", 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("MachineryParkingTo", 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("MachineryParkingTo", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonEnterSelftest() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryEnterMechnicalSelfTest", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonExitSelftest() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryExitMechnicalSelfTest", 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("MachineryStartMechnicalSelfTest", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonActiveTubeAngleZClear() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryActiveTubeAngleZAxisClear", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonCancelTubeAngleZClear() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryCancelTubeAngleZAxisClear", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonActiveTubeHeightZClear() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryActiveTubeHeightZAxisClear", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonCancelTubeHeightZClear() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryCancelTubeHeightZAxisClear", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonRotateToTubeAngleZAxis() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryTubeAngleRotateToZAxis", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonMoveToTubeHeightZAxis() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryTubeHeightMoveToZAxis", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::OnBnClickedButtonEmStop() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryForceStopAllMotion", Request, Result, 3000) == RET_SUCCEED) { } } void CDialogADCalibrationMain::SetExamMode(int mode) { ResDataObject Request; ResDataObject Result; if (mode == 0) { Request.add("P0", "Single"); } else if (mode == 1) { Request.add("P0", "TOMO"); } else if (mode == 2) { Request.add("P0", "CBCT"); } if (g_DiosAPIServer.ExecuteAction("MachinerySetExpMode", Request, Result, 30000)) { printf("MachinerySetExpMode Action Failed\n"); } else { printf("MachinerySetExpMode Action Succeed\n"); } //ResDataObject ExamDR; //ResDataObject ExamTomo; //ResDataObject ExamCBCT; //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("MachinerySetExamInfo", 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("MachinerySelectExamMode", Request, Result, 30000) < RET_SUCCEED) //{ // printf("SelectExamMode Action Failed\n"); //} //else //{ // printf("SelectExamMode Action Succeed\n"); //} } void CDialogADCalibrationMain::OnBnClickedButtonSetPcodeParam() { int nCurSel = 1; SetWorkstation(); nCurSel = m_examMode.GetCurSel(); if (nCurSel < 0) { nCurSel = 1; } SetExamMode(nCurSel); ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString strPositionCode; m_pcode.GetWindowText(strPositionCode); Request.clear(); Result.clear(); if (g_DiosAPIServer.ExecuteAction("MachineryFrameAcq", Request, Result, 30000) < RET_SUCCEED) { printf("FrameAcq Action Failed\n"); } else { printf("FrameAcq Action Succeed\n"); } oTemp.add("SID", "1.20"); oTemp.add("PositionNumber", strPositionCode); Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachinerySetTechParamsInfo", Request, Result, 30000) < RET_SUCCEED) { } } 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("MachineryCalMotionTubeAngleRotate", 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); int sel = m_comboTubeLineSelection.GetCurSel(); if (sel == 0) { g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeLineV", Request, Result, 3000); } else if (sel == 1) { g_DiosAPIServer.ExecuteAction("MachineryCalMotionTubeLineH", 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; m_comboTubeLineSelection.AddString("Vertical"); m_comboTubeLineSelection.AddString("Horizontal"); m_comboTubeLineSelection.SetCurSel(0); m_comboDetectorSelection.AddString("Wall"); m_comboDetectorSelection.AddString("Table"); m_comboDetectorSelection.SetCurSel(0); if (g_DiosAPIServer.OpenMachinery() == DR_OK) { Sleep(3000); OnBnClickedButtonEnterCalibration(); GetResetPos(0); } return TRUE; } void CDialogADCalibrationMain::OnClose() { CDialogEx::OnClose(); } void CDialogADCalibrationMain::OnBnClickedButtonInsertTubeAngle() { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; Request.add("P0", oTemp); if (g_DiosAPIServer.ExecuteAction("MachineryCalGetADofTubeAngle", 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("MachineryCalGetADofTubeLineV", 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("MachineryCalGetADofDetector", 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("MachineryAutoADCalibration", 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("MachineryAutoADCalibration", 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("MachinerySetSvoStatus", 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); int sel = m_comboTubeLineSelection.GetCurSel(); if (sel == 0) { g_DiosAPIServer.ExecuteAction("MachinerySetSvoStatus", Request, Result, 3000); } else if (sel == 1) { g_DiosAPIServer.ExecuteAction("MachinerySetSvoStatusTubeH", Request, Result, 3000); } } void CDialogADCalibrationMain::OnBnClickedRadioWall() { // TODO: 在此添加控件通知处理程序代码 //ResDataObject Request; //ResDataObject Result; //Request.add("P0", "Wall"); //g_DiosAPIServer.ExecuteAction("MachinerySetWorkstation", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedRadioTable() { // TODO: 在此添加控件通知处理程序代码 //ResDataObject Request; //ResDataObject Result; //Request.add("P0", "Table"); //g_DiosAPIServer.ExecuteAction("MachinerySetWorkstation", Request, Result, 3000); } void CDialogADCalibrationMain::SetWorkstation() { ResDataObject Request; ResDataObject Result; if (m_radioWSWall.GetCheck() == 1) { Request.add("P0", "Wall"); } else if (m_radioWSTable.GetCheck() == 1) { Request.add("P0", "Table"); } g_DiosAPIServer.ExecuteAction("MachinerySetWorkstation", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedButtonResetTubeAngleSavevalue() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString strLowpos; GetDlgItem(IDC_EDIT_RESET_TUBE_ANGLE_MIN)->GetWindowText(strLowpos); oTemp.add("MotionUnit", "TubeAngle"); oTemp.add("LowPosition", strLowpos); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MachineryCalSaveResetLowPosition", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedButtonResetTubeAngleEncoderzeroSavevalue() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString strEncoderZeroPos; GetDlgItem(IDC_EDIT_RESET_TUBE_ANGLE_ENCODERZERO)->GetWindowText(strEncoderZeroPos); oTemp.add("MotionUnit", "TubeAngle"); oTemp.add("EncoderZeroPosition", strEncoderZeroPos); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MachineryCalSaveResetEcoderZeroPosition", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedButtonTubeLineSaveMinpos() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString strLowpos; GetDlgItem(IDC_EDIT_TUBE_LINE_POS_MIN)->GetWindowText(strLowpos); int sel = m_comboTubeLineSelection.GetCurSel(); if (sel == 0) { oTemp.add("MotionUnit", "TubeVertical"); } else if (sel == 1) { oTemp.add("MotionUnit", "TubeHorizontal"); } oTemp.add("LowPosition", strLowpos); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MachineryCalSaveResetLowPosition", Request, Result, 3000); } void CDialogADCalibrationMain::OnBnClickedButtonTubeLineSaveEncoderzero() { // TODO: 在此添加控件通知处理程序代码 ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString strEncoderZeroPos; GetDlgItem(IDC_EDIT_TUBE_LINE_POS_ENCODER_ZERO)->GetWindowText(strEncoderZeroPos); int sel = m_comboTubeLineSelection.GetCurSel(); if (sel == 0) { oTemp.add("MotionUnit", "TubeVertical"); } else if (sel == 1) { oTemp.add("MotionUnit", "TubeHorizontal"); } oTemp.add("EncoderZeroPosition", strEncoderZeroPos); Request.add("P0", oTemp); g_DiosAPIServer.ExecuteAction("MachineryCalSaveResetEcoderZeroPosition", Request, Result, 3000); } void CDialogADCalibrationMain::GetResetPos(int nTubeOrientation) { ResDataObject Request; ResDataObject oTemp; ResDataObject Result; CString strlog; if (g_DiosAPIServer.ExecuteAction("MachineryCalGetResetPosParam", Request, Result, 30000) == RET_SUCCEED) { CString strlog = Result.encode(); OutputDebugString(strlog); ResDataObject obj1; try { obj1 = Result["P0"]; CString strTextLow, strTextZero; strlog.Format("select sel = %d", nTubeOrientation); OutputDebugString(strlog); if (nTubeOrientation == 0) { OutputDebugString("enter 0"); ResDataObject objTubeHeight = obj1["TubeHeight"]; m_fTubeHeightLowPos = atof(objTubeHeight["LowPosition"]); m_fTubeHeightZeroPos = atof(objTubeHeight["EncoderZeroPosition"]); strTextLow.Format("%0.3f", m_fTubeHeightLowPos); strTextZero.Format("%0.3f", m_fTubeHeightZeroPos); strlog.Format("TubeHeight, low pos=%s, zero pos=%s", strTextLow, strTextZero); OutputDebugString(strlog); } else { ResDataObject objTubeHorizontal = obj1["TubeHorizontal"]; m_fTubeHorizontalLowPos = atof(objTubeHorizontal["LowPosition"]); m_fTubeHorizontalZeroPos = atof(objTubeHorizontal["EncoderZeroPosition"]); strTextLow.Format("%0.3f", m_fTubeHorizontalLowPos); strTextZero.Format("%0.3f", m_fTubeHorizontalZeroPos); strlog.Format("TubeHorizontal, low pos=%s, zero pos=%s", strTextLow, strTextZero); OutputDebugString(strlog); } GetDlgItem(IDC_EDIT_TUBE_LINE_POS_MIN)->SetWindowText(strTextLow); GetDlgItem(IDC_EDIT_TUBE_LINE_POS_ENCODER_ZERO)->SetWindowText(strTextZero); } catch (ResDataObjectExption& exp) { strlog.Format("GetResetPos catch, %s", exp.what()); OutputDebugString(strlog); TPRINTA_ERROR(exp.what()); } } } void CDialogADCalibrationMain::OnCbnSelchangeComboLineSelection() { // TODO: 在此添加控件通知处理程序代码 } void CDialogADCalibrationMain::OnCbnSelendokComboLineSelection() { // TODO: 在此添加控件通知处理程序代码 int nsel = m_comboTubeLineSelection.GetCurSel(); GetResetPos(nsel); }