| | |
| | | m_bReady = FALSE; |
| | | m_bBusy = FALSE; |
| | | m_bErr = FALSE; |
| | | |
| | | for (int i = 0; i < BTN_MAX; i++) { |
| | | m_pBlBtns[i] = new CBlButton(); |
| | | } |
| | | |
| | | for (int i = 0; i < EDIT_MAX; i++) { |
| | | m_pRegexEdit[i] = new CRegexEdit(); |
| | | } |
| | | |
| | | for (int i = 0; i < LABEL_MAX; i++) { |
| | |
| | | |
| | | for (int i = 0; i < BTN_MAX; i++) { |
| | | delete m_pBlBtns[i]; |
| | | } |
| | | |
| | | for (int i = 0; i < EDIT_MAX; i++) { |
| | | delete m_pRegexEdit[i]; |
| | | } |
| | | |
| | | for (int i = 0; i < LABEL_MAX; i++) { |
| | |
| | | DDX_Control(pDX, IDC_STATIC_AXIS_NUMBER, m_staticAxisNO); |
| | | DDX_Control(pDX, IDC_STATIC_AXIS_DESCRIP, m_staticAxisDescription); |
| | | DDX_Control(pDX, IDC_STATIC_START_ADDRESS, m_staticStartAddress); |
| | | DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_POS, m_editManualSpeed); |
| | | DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_AUTO_SPEED, m_editAutoSpeed); |
| | | DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_ACCE_TIME, m_editAccelerationTime); |
| | | DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_DECE_TIME, m_editDecelerationTime); |
| | | DDX_Control(pDX, IDC_EDIT_AXIS_MODITFY_MICROMENTUM, m_editJogDistance); |
| | | } |
| | | |
| | | UINT CAxisSettingsDlg::FindIDByName(const CString& strControlID) |
| | |
| | | SetLabelColorBasedOnState(*m_pBlLabels[LABEL_ERR], m_bErr, COLOR_RED, COLOR_GREEN_OFF); |
| | | } |
| | | |
| | | void CAxisSettingsDlg::UpdateRegexEdit(CRegexEdit* pRegexEdit, const ValueRange& range, const CString& title) |
| | | { |
| | | auto formatDouble = [](double value) -> CString { |
| | | CString str; |
| | | str.Format(_T("%.3f"), value); |
| | | return str; |
| | | }; |
| | | |
| | | pRegexEdit->SetWindowText(formatDouble(range.currentValue)); |
| | | pRegexEdit->SetRegexType(RegexType::Decimal); |
| | | pRegexEdit->SetValueRange(range.minValue, range.maxValue); |
| | | pRegexEdit->SetInvalidInputCallback([title, range]() { |
| | | CString strError; |
| | | strError.Format(_T("%s的值必须在 %.3f 和 %.3f 之间!"), title, range.minValue, range.maxValue); |
| | | AfxMessageBox(strError); |
| | | }); |
| | | } |
| | | |
| | | void CAxisSettingsDlg::updatePageButtonStates() |
| | | { |
| | | for (int i = 0; i < AXIS_PAGE_SIZE; ++i) { |
| | |
| | | }; |
| | | |
| | | // 更新控件显示 |
| | | m_staticAxisNO.SetWindowText(CString(axisDetails.number.c_str())); // 轴编号 |
| | | m_staticAxisDescription.SetWindowText(CString(axisDetails.description.c_str())); // 轴描述 |
| | | m_staticStartAddress.SetWindowText(CString(axisDetails.startAddress.c_str())); // 起始地址 |
| | | m_editJogDistance.SetWindowText(formatDouble(axisDetails.jogDistance.currentValue)); // 微动量 |
| | | m_editManualSpeed.SetWindowText(formatDouble(axisDetails.manualSpeed.currentValue)); // 手动速度 |
| | | m_editAutoSpeed.SetWindowText(formatDouble(axisDetails.autoSpeed.currentValue)); // 自动速度 |
| | | m_editAccelerationTime.SetWindowText(formatDouble(axisDetails.accelerationTime.currentValue)); // 加速时间 |
| | | m_editDecelerationTime.SetWindowText(formatDouble(axisDetails.decelerationTime.currentValue)); // 减速时间 |
| | | m_staticAxisNO.SetWindowText(CString(axisDetails.number.c_str())); // 轴编号 |
| | | m_staticAxisDescription.SetWindowText(CString(axisDetails.description.c_str())); // 轴描述 |
| | | m_staticStartAddress.SetWindowText(CString(axisDetails.startAddress.c_str())); // 起始地址 |
| | | |
| | | UpdateRegexEdit(m_pRegexEdit[EDIT_MICROMENTUM], axisDetails.jogDistance, _T("微动量")); |
| | | UpdateRegexEdit(m_pRegexEdit[EDIT_MANUAL_SPEED], axisDetails.manualSpeed, _T("手动速度")); |
| | | UpdateRegexEdit(m_pRegexEdit[EDIT_AUTO_SPEED], axisDetails.autoSpeed, _T("自动速度")); |
| | | UpdateRegexEdit(m_pRegexEdit[EDIT_ACCE_TIME], axisDetails.accelerationTime, _T("加速时间")); |
| | | UpdateRegexEdit(m_pRegexEdit[EDIT_DECE_TIME], axisDetails.decelerationTime, _T("减速时间")); |
| | | } |
| | | |
| | | void CAxisSettingsDlg::refreshPositionDetails(int nAxisId, int pageNumber) |
| | |
| | | if (pPositionCtrl) { |
| | | pPositionCtrl->SetWindowText(value); |
| | | pPositionCtrl->EnableWindow(position.isEnable); |
| | | |
| | | if (position.isEnable) { |
| | | CString strError; |
| | | strError.Format(_T("定位点%d"), i + 1); |
| | | UpdateRegexEdit((CRegexEdit*)pPositionCtrl, position.range, strError); |
| | | } |
| | | } |
| | | } |
| | | else { |
| | |
| | | |
| | | // 获取界面上的修改参数 |
| | | CString text; |
| | | m_editManualSpeed.GetWindowText(text); |
| | | m_pRegexEdit[EDIT_MANUAL_SPEED]->GetWindowText(text); |
| | | axisData.manualSpeed.currentValue = _ttof(text); |
| | | |
| | | m_editAutoSpeed.GetWindowText(text); |
| | | m_pRegexEdit[EDIT_AUTO_SPEED]->GetWindowText(text); |
| | | axisData.autoSpeed.currentValue = _ttof(text); |
| | | |
| | | m_editAccelerationTime.GetWindowText(text); |
| | | m_pRegexEdit[EDIT_ACCE_TIME]->GetWindowText(text); |
| | | axisData.accelerationTime.currentValue = _ttof(text); |
| | | |
| | | m_editDecelerationTime.GetWindowText(text); |
| | | m_pRegexEdit[EDIT_DECE_TIME]->GetWindowText(text); |
| | | axisData.decelerationTime.currentValue = _ttof(text); |
| | | |
| | | m_editJogDistance.GetWindowText(text); |
| | | m_pRegexEdit[EDIT_MICROMENTUM]->GetWindowText(text); |
| | | axisData.jogDistance.currentValue = _ttof(text); |
| | | |
| | | // 更新定位点数据 |
| | |
| | | pLabel->SetDynamicFont(TRUE); |
| | | } |
| | | |
| | | // 初始化编辑框 |
| | | m_pRegexEdit[EDIT_MANUAL_SPEED]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_MANUAL_SPEED, this); |
| | | m_pRegexEdit[EDIT_AUTO_SPEED]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_AUTO_SPEED, this); |
| | | m_pRegexEdit[EDIT_ACCE_TIME]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_ACCE_TIME, this); |
| | | m_pRegexEdit[EDIT_DECE_TIME]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_DECE_TIME, this); |
| | | m_pRegexEdit[EDIT_MICROMENTUM]->SubclassDlgItem(IDC_EDIT_AXIS_MODITFY_MICROMENTUM, this); |
| | | m_pRegexEdit[EDIT_ANCHOR_POINT1]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT1, this); |
| | | m_pRegexEdit[EDIT_ANCHOR_POINT2]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT2, this); |
| | | m_pRegexEdit[EDIT_ANCHOR_POINT3]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT3, this); |
| | | m_pRegexEdit[EDIT_ANCHOR_POINT4]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT4, this); |
| | | m_pRegexEdit[EDIT_ANCHOR_POINT5]->SubclassDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT5, this); |
| | | |
| | | // 按钮初始化 |
| | | m_pBlBtns[BTN_PAGE1]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP1, this); |
| | | m_pBlBtns[BTN_PAGE2]->SubclassDlgItem(IDC_BUTTON_AXIS_ANCHOR_POINT_GROUP2, this); |
| | |
| | | CWnd* pWnd = CWnd::FromHandle(pMsg->hwnd); |
| | | |
| | | if (pWnd) { |
| | | if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN) { |
| | | // 阻止回车键默认处理,防止对话框关闭 |
| | | return TRUE; |
| | | } |
| | | |
| | | // 判断鼠标是否进入指定控件区域 |
| | | if (pWnd->GetSafeHwnd() == GetDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP1)->m_hWnd || |
| | | pWnd->GetSafeHwnd() == GetDlgItem(IDC_EDIT_AXIS_ANCHOR_POINT_DESCRIP2)->m_hWnd || |