| | |
| | | {_T("MEASUREMENT"), 1} |
| | | }; |
| | | |
| | | static const std::map < SERVO:: RCMD, RCMDFieldMask > g_cmdFieldMap = { |
| | | { SERVO::RCMD::Robot_home, { false, false, false, false, false, false } }, |
| | | { SERVO::RCMD::Transfer, { true, true, true, true, true, false } }, |
| | | { SERVO::RCMD::Move, { true, true, true, true, true, true } }, |
| | | { SERVO::RCMD::Get, { true, true, false, true, false, false } }, |
| | | { SERVO::RCMD::Put, { true, false, true, false, true, false } }, |
| | | { SERVO::RCMD::One_Action_Exchange, { true, true, true, true, true, false } }, |
| | | }; |
| | | |
| | | IMPLEMENT_DYNAMIC(CPageRobotCmd, CDialogEx) |
| | | |
| | | CPageRobotCmd::CPageRobotCmd(CWnd* pParent /*=nullptr*/) |
| | |
| | | } |
| | | } |
| | | |
| | | SERVO::ROBOT_CMD_PARAM CPageRobotCmd::GetRobotCmdParam() |
| | | BOOL CPageRobotCmd::SetControlsEnabled(BOOL bEnable) |
| | | { |
| | | // 窗口销毁时不可用 |
| | | if (IsWindow(m_hWnd)) { |
| | | UpdateData(TRUE); // 同步成员变量到界面 |
| | | if (!IsWindow(m_hWnd)) { |
| | | return FALSE; |
| | | } |
| | | |
| | | SERVO::ROBOT_CMD_PARAM param; |
| | | if (bEnable) { |
| | | UpdateData(TRUE); |
| | | UpdateInputUI(static_cast<SERVO::RCMD>(m_nRcmd + 1)); |
| | | } |
| | | else { |
| | | // 遍历所有子控件并设置状态 |
| | | CWnd* pChild = GetWindow(GW_CHILD); |
| | | while (pChild) { |
| | | pChild->EnableWindow(bEnable); |
| | | pChild = pChild->GetNextWindow(); |
| | | } |
| | | } |
| | | |
| | | return CDialogEx::EnableWindow(bEnable); |
| | | } |
| | | |
| | | SERVO::ROBOT_CMD_PARAM CPageRobotCmd::GetRobotCmdParam() |
| | | { |
| | | if (!IsWindow(m_hWnd)) { |
| | | return {}; |
| | | } |
| | | UpdateData(TRUE); // 同步 UI 到变量 |
| | | |
| | | SERVO::ROBOT_CMD_PARAM param = {}; |
| | | param.sequenceNo = static_cast<short>(m_nSequenceNo); |
| | | param.rcmd = static_cast<short>(m_nRcmd + 1); |
| | | param.armNo = static_cast<short>(m_nArmNo); |
| | | param.getPosition = static_cast<short>(m_nGetPosition + 1); |
| | | param.putPosition = static_cast<short>(m_nPutPosition + 1); |
| | | param.getSlotNo = static_cast<short>(m_nGetSlotNo + 1); |
| | | param.putSlotNo = static_cast<short>(m_nPutSlotNo + 1); |
| | | param.subCmd = static_cast<short>(m_nSubCmd + 1); |
| | | |
| | | const auto it = g_cmdFieldMap.find(static_cast<SERVO::RCMD>(param.rcmd)); |
| | | if (it == g_cmdFieldMap.end()) { |
| | | return {}; |
| | | } |
| | | |
| | | const RCMDFieldMask& mask = it->second; |
| | | if (mask.useArm) param.armNo = static_cast<short>(m_nArmNo); |
| | | if (mask.useGetPos) param.getPosition = static_cast<short>(m_nGetPosition + 1); |
| | | if (mask.usePutPos) param.putPosition = static_cast<short>(m_nPutPosition + 1); |
| | | if (mask.useGetSlot) param.getSlotNo = static_cast<short>(m_nGetSlotNo + 1); |
| | | if (mask.usePutSlot) param.putSlotNo = static_cast<short>(m_nPutSlotNo + 1); |
| | | if (mask.useSubCmd) param.subCmd = static_cast<short>(m_nSubCmd + 1); |
| | | |
| | | if (param.rcmd == static_cast<short>(SERVO::RCMD::Move)) { |
| | | if (m_nSubCmd == 0) { |
| | | param.putPosition = 0; |
| | | param.putSlotNo = 0; |
| | | } |
| | | else if (m_nSubCmd == 1) { |
| | | param.getPosition = 0; |
| | | param.getSlotNo = 0; |
| | | } |
| | | } |
| | | |
| | | return param; |
| | | } |
| | |
| | | |
| | | |
| | | BEGIN_MESSAGE_MAP(CPageRobotCmd, CDialogEx) |
| | | ON_CBN_SELCHANGE(IDC_COMBO_RCMD, &CPageRobotCmd::OnCbnSelchangeComboRcmd) |
| | | ON_CBN_SELCHANGE(IDC_COMBO_GET_POS, &CPageRobotCmd::OnCbnSelchangeComboGetPos) |
| | | ON_CBN_SELCHANGE(IDC_COMBO_PUT_POS, &CPageRobotCmd::OnCbnSelchangeComboPutPos) |
| | | ON_CBN_SELCHANGE(IDC_COMBO_SUB_CMD, &CPageRobotCmd::OnCbnSelchangeComboSubCmd) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | |
| | | pComboSubCmd->AddString(_T("2: Put Ready")); |
| | | pComboSubCmd->SetCurSel(0); |
| | | |
| | | // 初始化单选框 |
| | | // 初始化 ARM 单选框 |
| | | CButton* pRadioArmA = (CButton*)GetDlgItem(IDC_RADIO_ARM_A); |
| | | CButton* pRadioArmB = (CButton*)GetDlgItem(IDC_RADIO_ARM_B); |
| | | pRadioArmA->SetCheck(BST_CHECKED); |
| | | pRadioArmB->SetCheck(BST_UNCHECKED); |
| | | |
| | | // 初始化输入控件状态 |
| | | UpdateInputUI(SERVO::RCMD::Robot_home); |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | | // 异常: OCX 属性页应返回 FALSE |
| | | } |
| | | |
| | | |
| | | void CPageRobotCmd::UpdateSlotList(CComboBox* pComboDevice, CComboBox* pComboSlot) |
| | | { |
| | |
| | | pComboSlot->SetCurSel(0); |
| | | } |
| | | |
| | | void CPageRobotCmd::UpdateMoveSubFields() |
| | | { |
| | | UpdateData(TRUE); |
| | | if (SERVO::RCMD::Move == static_cast<SERVO::RCMD>(m_nRcmd + 1)) { |
| | | const bool bMoveToGet = (m_nSubCmd == 0); // Move to Get |
| | | const bool bMoveToPut = (m_nSubCmd == 1); // Move to Put |
| | | |
| | | GetDlgItem(IDC_COMBO_GET_POS)->EnableWindow(bMoveToGet); |
| | | GetDlgItem(IDC_COMBO_GET_SLOT)->EnableWindow(bMoveToGet); |
| | | GetDlgItem(IDC_COMBO_PUT_POS)->EnableWindow(bMoveToPut); |
| | | GetDlgItem(IDC_COMBO_PUT_SLOT)->EnableWindow(bMoveToPut); |
| | | } |
| | | } |
| | | |
| | | void CPageRobotCmd::UpdateInputUI(SERVO::RCMD cmd) |
| | | { |
| | | const auto it = g_cmdFieldMap.find(cmd); |
| | | if (it == g_cmdFieldMap.end()) { |
| | | return; |
| | | } |
| | | |
| | | const RCMDFieldMask& mask = it->second; |
| | | GetDlgItem(IDC_EDIT_SEQ_NO)->EnableWindow(TRUE); |
| | | GetDlgItem(IDC_COMBO_RCMD)->EnableWindow(TRUE); |
| | | GetDlgItem(IDC_RADIO_ARM_A)->EnableWindow(mask.useArm); |
| | | GetDlgItem(IDC_RADIO_ARM_B)->EnableWindow(mask.useArm); |
| | | GetDlgItem(IDC_COMBO_GET_POS)->EnableWindow(mask.useGetPos); |
| | | GetDlgItem(IDC_COMBO_PUT_POS)->EnableWindow(mask.usePutPos); |
| | | GetDlgItem(IDC_COMBO_GET_SLOT)->EnableWindow(mask.useGetSlot); |
| | | GetDlgItem(IDC_COMBO_PUT_SLOT)->EnableWindow(mask.usePutSlot); |
| | | GetDlgItem(IDC_COMBO_SUB_CMD)->EnableWindow(mask.useSubCmd); |
| | | |
| | | // 特殊处理 Move 类型 |
| | | UpdateMoveSubFields(); |
| | | } |
| | | |
| | | void CPageRobotCmd::OnCbnSelchangeComboRcmd() |
| | | { |
| | | UpdateData(TRUE); |
| | | UpdateInputUI(static_cast<SERVO::RCMD>(m_nRcmd + 1)); |
| | | } |
| | | |
| | | void CPageRobotCmd::OnCbnSelchangeComboGetPos() |
| | | { |
| | | CComboBox* pDevice = (CComboBox*)GetDlgItem(IDC_COMBO_GET_POS); |
| | |
| | | CComboBox* pDevice = (CComboBox*)GetDlgItem(IDC_COMBO_PUT_POS); |
| | | CComboBox* pSlot = (CComboBox*)GetDlgItem(IDC_COMBO_PUT_SLOT); |
| | | UpdateSlotList(pDevice, pSlot); |
| | | } |
| | | |
| | | void CPageRobotCmd::OnCbnSelchangeComboSubCmd() |
| | | { |
| | | UpdateMoveSubFields(); |
| | | } |