123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- // DialogTubeLineVEncoder.cpp : 实现文件
- //
- #include "stdafx.h"
- #include "DIOS_3DDR_MechCal.h"
- #include "DialogTubeLineVEncoder.h"
- #include "afxdialogex.h"
- // CDialogTubeLineVEncoder 对话框
- IMPLEMENT_DYNAMIC(CDialogTubeLineVEncoder, CDialogEx)
- CDialogTubeLineVEncoder::CDialogTubeLineVEncoder(CWnd* pParent /*=NULL*/)
- : CDialogEx(CDialogTubeLineVEncoder::IDD, pParent)
- {
- }
- CDialogTubeLineVEncoder::~CDialogTubeLineVEncoder()
- {
- }
- void CDialogTubeLineVEncoder::DoDataExchange(CDataExchange* pDX)
- {
- CDialogEx::DoDataExchange(pDX);
- }
- BEGIN_MESSAGE_MAP(CDialogTubeLineVEncoder, CDialogEx)
- ON_BN_CLICKED(IDC_BUTTON_STARTMOTION, &CDialogTubeLineVEncoder::OnBnClickedButtonStartmotion)
- ON_BN_CLICKED(IDC_BUTTON_READENCODER, &CDialogTubeLineVEncoder::OnBnClickedButtonReadencoder)
- ON_BN_CLICKED(IDOK, &CDialogTubeLineVEncoder::OnBnClickedOk)
- ON_BN_CLICKED(IDC_BUTTON_READAD, &CDialogTubeLineVEncoder::OnBnClickedButtonReadad)
- ON_BN_CLICKED(IDC_BUTTON_AXISZ_BIND, &CDialogTubeLineVEncoder::OnBnClickedButtonAxiszBind)
- END_MESSAGE_MAP()
- // CDialogTubeLineVEncoder 消息处理程序
- BOOL CDialogTubeLineVEncoder::OnInitDialog()
- {
- CDialogEx::OnInitDialog();
- // TODO: 在此添加额外的初始化
- //CString strHeight[12] = { "0.895", "0.796", "0.697", "0.997", "1.09", "1.159", "1.222", "1.287", "1.357", "1.422", "1.492", "1.555" };
- //CString strAD[12] = { "1540", "1350", "1158", "1731", "1919", "2044", "2169", "2259", "2421", "2545", "2672", "2798" };
- CString str;
- for (int i = 0; i < 12; i++)
- {
- str.Format("高度 %d", i + 1);
- GetDlgItem(IDC_STATIC_HEIGHT1 + i)->SetWindowText(str);
- str.Format("Encoder %d", i + 1);
- GetDlgItem(IDC_STATIC_AD1 + i)->SetWindowText(str);
- //str.Format("%d", i + 1);
- //GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->SetWindowText(strHeight[i]);
- //str.Format("%d", (i + 1) * 1000);
- //GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->SetWindowText(strAD[i]);
- }
- ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->AddString("下");
- ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->AddString("上");
- ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->SetCurSel(0);
- return TRUE; // return TRUE unless you set the focus to a control
- // 异常: OCX 属性页应返回 FALSE
- }
- void CDialogTubeLineVEncoder::OnBnClickedButtonStartmotion()
- {
- // TODO: 在此添加控件通知处理程序代码
- int nCurSel = ((CComboBox*)(GetDlgItem(IDC_COMBO_TUBELINEV_ORG)))->GetCurSel();
- CString strStep;
- GetDlgItem(IDC_EDIT_TUBELINEV_STEP)->GetWindowText(strStep);
- int nStep = atoi(strStep);
- ResDataObject Request;
- ResDataObject oTemp;
- ResDataObject Result;
- oTemp.add("Orientation", nCurSel);
- oTemp.add("StepNumber", nStep);
- Request.add("P0", oTemp);
- g_DiosAPIServer.ExecuteAction("CalMotionTubeLineV", Request, Result, 3000);
- }
- void CDialogTubeLineVEncoder::OnBnClickedButtonReadencoder()
- {
- // TODO: 在此添加控件通知处理程序代码
- 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["EncoderTubeLineV"]);
- GetDlgItem(IDC_EDIT_TUBELINEV_VALUE_ENCODER)->SetWindowText(strText);
- }
- catch (ResDataObjectExption &exp)
- {
- printf("%s%s", exp.what(), "\\n");
- TPRINTA_ERROR(exp.what());
- }
- }
- }
- void CDialogTubeLineVEncoder::OnBnClickedOk()
- {
- // TODO: 在此添加控件通知处理程序代码
- ResDataObject Request;
- ResDataObject oTemp;
- ResDataObject Result;
- CString strKeyHeight;
- CString strKeyAD;
- CString strValueHeight;
- CString strValueAD;
- int nPointCount = 12;
- oTemp.add("PointCount", nPointCount);
- for (int i = 0; i < nPointCount; i++)
- {
- strKeyHeight.Format("Height%d", i);
- strKeyAD.Format("Encoder%d", i);
- GetDlgItem(IDC_EDIT_TUBELINEV_HEIGHT1 + i)->GetWindowText(strValueHeight);
- GetDlgItem(IDC_EDIT_TUBELINEV_AD1 + i)->GetWindowText(strValueAD);
- int nAD = atoi(strValueAD);
- oTemp.add(strKeyHeight, strValueHeight);
- oTemp.add(strKeyAD, nAD);
- }
- Request.add("P0", oTemp);
- if (g_DiosAPIServer.ExecuteAction("CalSaveEncoderCorrectonofTubeLiveV", Request, Result, 3000) == RET_SUCCEED)
- {
- string str = Result.encode();
- ResDataObject obj1;
- try
- {
- obj1 = Result["P0"];
- CString strSlope((const char*)obj1["Slope"]);
- CString strIntercept((const char*)obj1["Intercept"]);
- CString strText;
- strText.Format("Calibration succeed, Y = %s * X + (%s)", strSlope, strIntercept);
- AfxMessageBox(strText);
- }
- catch (ResDataObjectExption &exp)
- {
- printf("%s%s", exp.what(), "\\n");
- TPRINTA_ERROR(exp.what());
- }
- }
- }
- void CDialogTubeLineVEncoder::OnBnClickedButtonReadad()
- {
- // TODO: 在此添加控件通知处理程序代码
- 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["ADTubeLineV"]);
- GetDlgItem(IDC_EDIT_TUBELINEV_VALUEAD)->SetWindowText(strText);
- }
- catch (ResDataObjectExption &exp)
- {
- printf("%s%s", exp.what(), "\\n");
- TPRINTA_ERROR(exp.what());
- }
- }
- }
- void CDialogTubeLineVEncoder::OnBnClickedButtonAxiszBind()
- {
- // TODO: 在此添加控件通知处理程序代码
- ResDataObject Request;
- ResDataObject oTemp;
- ResDataObject Result;
- CString strEncoderLimitationADUp;
- CString strEncoderLimitationADDown;
- GetDlgItem(IDC_EDIT_TUBELINEV_ENCODER_UP)->GetWindowText(strEncoderLimitationADUp);
- GetDlgItem(IDC_EDIT_TUBELINEV_ENCODER_DOWN)->GetWindowText(strEncoderLimitationADDown);
- oTemp.add("EncoderLimitationADUp", strEncoderLimitationADUp);
- oTemp.add("EncoderLimitationADDown", strEncoderLimitationADDown);
- Request.add("P0", oTemp);
- if (g_DiosAPIServer.ExecuteAction("CalSetADLimitationofEncoder", Request, Result, 30000) == RET_SUCCEED)
- {
- }
- }
|