| | |
| | | #include "ServoCommo.h" |
| | | |
| | | |
| | | |
| | | #define CHECKBOX_ALL_ID 0x1234 |
| | | |
| | | // CPortConfigurationDlg 对话框 |
| | | |
| | | IMPLEMENT_DYNAMIC(CPortConfigurationDlg, CDialogEx) |
| | |
| | | m_pPort[2] = dynamic_cast<SERVO::CLoadPort*>(theApp.m_model.m_master.getEquipment(EQ_ID_LOADPORT3)); |
| | | m_pPort[3] = dynamic_cast<SERVO::CLoadPort*>(theApp.m_model.m_master.getEquipment(EQ_ID_LOADPORT4)); |
| | | m_nCurSelPort = -1; |
| | | m_pCheckBox = nullptr; |
| | | m_bCheckedAll = FALSE; |
| | | } |
| | | |
| | | CPortConfigurationDlg::~CPortConfigurationDlg() |
| | |
| | | } |
| | | } |
| | | } |
| | | m_pCheckBox->SetCheck(IsCheckedAll() ? BST_CHECKED : BST_UNCHECKED); |
| | | } |
| | | |
| | | void CPortConfigurationDlg::InitGrid() |
| | |
| | | m_wndGrid.SetColumnWidth(nColIdx, 50); |
| | | m_wndGrid.SetItemText(0, nColIdx++, _T("Slot ID")); |
| | | m_wndGrid.SetColumnWidth(nColIdx, 60); |
| | | m_wndGrid.SetItemText(0, nColIdx++, _T("启用")); |
| | | m_wndGrid.SetItemText(0, nColIdx++, _T("Glass ID")); |
| | | |
| | | |
| | | // 设置行为样式 |
| | | m_wndGrid.SetFixedRowSelection(FALSE); |
| | |
| | | for (int i = 0; i < nRows; ++i) { |
| | | m_wndGrid.SetRowHeight(i, nEachRowHeight); |
| | | } |
| | | |
| | | CRect rect; |
| | | BOOL bOK = m_wndGrid.GetCellRect(0, 1, rect); |
| | | m_pCheckBox = new CCustomCheckBox(); |
| | | m_pCheckBox->Create(_T("选择所有"), |
| | | WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, // 自动勾选 |
| | | CRect(0, 0, 150, 32), &m_wndGrid, CHECKBOX_ALL_ID); |
| | | m_pCheckBox->SetFont(GetFont()); |
| | | m_pCheckBox->MoveWindow(rect.left + 5, rect.top + 3, 150, rect.Height() - 6); |
| | | m_pCheckBox->SetBackgroundColor(g_nGridFixCellColor); |
| | | m_pCheckBox->SetNotifyHwnd(GetSafeHwnd()); |
| | | } |
| | | |
| | | void CPortConfigurationDlg::DoDataExchange(CDataExchange* pDX) |
| | |
| | | BEGIN_MESSAGE_MAP(CPortConfigurationDlg, CDialogEx) |
| | | ON_CBN_SELCHANGE(IDC_COMBO_PORT, &CPortConfigurationDlg::OnSelchangeComboPort) |
| | | ON_BN_CLICKED(IDC_BUTTON_APPLY, &CPortConfigurationDlg::OnBnClickedButtonApply) |
| | | ON_MESSAGE(WM_CHECKBOX_STATE_CHANGED, &CPortConfigurationDlg::OnCheckAllClicked) |
| | | ON_WM_DESTROY() |
| | | ON_BN_CLICKED(IDC_BUTTON_PROCESS_START, &CPortConfigurationDlg::OnBnClickedButtonProcessStart) |
| | | ON_BN_CLICKED(IDC_BUTTON_PROCESS_CANCEL, &CPortConfigurationDlg::OnBnClickedButtonProcessCancel) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | |
| | | LoadPortConfigToUI(m_pPort[0]); // 默认加载第一个端口的配置 |
| | | |
| | | // 设置对话框标题 |
| | | if (0 <= m_nCurSelPort && m_nCurSelPort <= 3) { |
| | | BOOL bAutoPopup = 0 <= m_nCurSelPort && m_nCurSelPort <= 3; |
| | | if (bAutoPopup) { |
| | | CString strTitle; |
| | | strTitle.Format(_T("%s Configuration"), ports[m_nCurSelPort]); |
| | | SetWindowText(strTitle); |
| | |
| | | else { |
| | | SetWindowText(_T("Port Configuration")); |
| | | } |
| | | |
| | | |
| | | // Porcess Start / Process Cancel 按钮状态 |
| | | GetDlgItem(IDC_BUTTON_PROCESS_START)->EnableWindow(FALSE); |
| | | GetDlgItem(IDC_BUTTON_PROCESS_CANCEL)->EnableWindow(FALSE); |
| | | |
| | | |
| | | return TRUE; // return TRUE unless you set the focus to a control |
| | |
| | | } |
| | | |
| | | // 获取 Grid 表格中 Slot 状态(第1~8行) |
| | | for (int i = 1; i <= 8; ++i) { |
| | | for (int i = 1; i <= SLOT_MAX; ++i) { |
| | | SERVO::CGlass* pGlass = (SERVO::CGlass*)m_wndGrid.GetItemData(i, 0); |
| | | if (pGlass != nullptr) { |
| | | CGridCellCheck* pCheck = dynamic_cast<CGridCellCheck*>(m_wndGrid.GetCell(i, 1)); |
| | |
| | | } |
| | | } |
| | | |
| | | GetDlgItem(IDC_BUTTON_PROCESS_START)->EnableWindow(TRUE); |
| | | GetDlgItem(IDC_BUTTON_PROCESS_CANCEL)->EnableWindow(TRUE); |
| | | } |
| | | |
| | | OnOK(); |
| | | void CPortConfigurationDlg::OnDestroy() |
| | | { |
| | | CDialogEx::OnDestroy(); |
| | | |
| | | if (m_pCheckBox != nullptr) { |
| | | m_pCheckBox->DestroyWindow(); |
| | | delete m_pCheckBox; |
| | | m_pCheckBox = nullptr; |
| | | } |
| | | } |
| | | |
| | | LRESULT CPortConfigurationDlg::OnCheckAllClicked(WPARAM wParam, LPARAM lParam) |
| | | { |
| | | UINT ctrlID = (UINT)wParam; |
| | | BOOL bChecked = (BOOL)lParam; |
| | | for (int i = 1; i <= SLOT_MAX; ++i) { |
| | | CGridCellCheck* pCheck = dynamic_cast<CGridCellCheck*>(m_wndGrid.GetCell(i, 1)); |
| | | if (pCheck != nullptr) { |
| | | pCheck->SetCheck(bChecked); |
| | | } |
| | | } |
| | | |
| | | |
| | | return 0; |
| | | } |
| | | |
| | | BOOL CPortConfigurationDlg::IsCheckedAll() |
| | | { |
| | | for (int i = 1; i <= SLOT_MAX; ++i) { |
| | | CGridCellCheck* pCheck = dynamic_cast<CGridCellCheck*>(m_wndGrid.GetCell(i, 1)); |
| | | if (pCheck != nullptr) { |
| | | if (!pCheck->GetCheck()) return FALSE; |
| | | } |
| | | } |
| | | |
| | | return TRUE; |
| | | } |
| | | |
| | | void CPortConfigurationDlg::OnBnClickedButtonProcessStart() |
| | | { |
| | | int selPort = (0 <= m_nCurSelPort && m_nCurSelPort <= 3) ? m_nCurSelPort |
| | | : m_comboPort.GetCurSel(); |
| | | if (selPort < 0 || selPort >= 4) return; |
| | | m_pPort[selPort]->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr); |
| | | } |
| | | |
| | | void CPortConfigurationDlg::OnBnClickedButtonProcessCancel() |
| | | { |
| | | int selPort = (0 <= m_nCurSelPort && m_nCurSelPort <= 3) ? m_nCurSelPort |
| | | : m_comboPort.GetCurSel(); |
| | | if (selPort < 0 || selPort >= 4) return; |
| | | m_pPort[selPort]->sendCassetteCtrlCmd(CCC_PROCESS_CANCEL, nullptr, 0, 0, 0, nullptr, nullptr); |
| | | } |