mrDarker
2025-07-22 2246e85e7241fe910ed5e819c659fbf139b82054
SourceCode/Bond/Servo/PortConfigurationDlg.cpp
@@ -50,39 +50,24 @@
    SetDlgItemText(IDC_EDIT_OPERATIONID, "");
    m_comboMaterialsType.SetCurSel(0);
    bool bJobInfoSet = false;
    for (int i = 0; i < SLOT_MAX; ++i) {
        SERVO::CSlot* pSlot = pPort->getSlot(i);
        if (!pSlot) {
            continue;
    SERVO::CSlot* pSlot = pPort->getSlot(0);
    if (pSlot == nullptr) {
        return;
        }
        SERVO::CGlass* pGlass = dynamic_cast<SERVO::CGlass*>(pSlot->getContext());
        int nRow = i + 1;
        // 设置 Panel ID 和勾选框
        CGridCellCheck* pCheck = static_cast<CGridCellCheck*>(m_wndGrid.GetCell(nRow, 1));
        if (pCheck && pGlass) {
            pCheck->SetCheck(pSlot->isEnable() ? TRUE : FALSE);
            pCheck->SetText(pGlass ? pGlass->getID().c_str() : _T(""));
        }
      else {
         pCheck->SetCheck(FALSE);
         pCheck->SetText(_T(""));
      }
        // 回填 Job 信息(只取第一个有效 Glass)
        if (!bJobInfoSet && pGlass) {
    if (pGlass != nullptr) {
            SERVO::CJobDataS* pJS = pGlass->getJobDataS();
            if (pJS) {
                SetDlgItemText(IDC_EDIT_LOTID, CString(pJS->getLotId().c_str()));
                SetDlgItemText(IDC_EDIT_PRODUCTID, CString(pJS->getProductId().c_str()));
                SetDlgItemText(IDC_EDIT_OPERATIONID, CString(pJS->getOperationId().c_str()));
                m_comboMaterialsType.SetCurSel(pJS->getMaterialsType() - 1);
                bJobInfoSet = true;
            }
        }
    }
   // 填充 Grid
   FillGrid(pSlot, pGlass);
}
void CPortConfigurationDlg::InitGrid()
@@ -138,28 +123,41 @@
    for (int i = 0; i < nRows; ++i) {
        m_wndGrid.SetRowHeight(i, nEachRowHeight);
    }
    FillGrid();
}
void CPortConfigurationDlg::FillGrid()
void CPortConfigurationDlg::FillGrid(SERVO::CSlot* pSlot, SERVO::CGlass* pGlass)
{
    //CStringArray recipeOptions;
    //recipeOptions.Add(_T("Recipe A"));
    //recipeOptions.Add(_T("Recipe B"));
    //recipeOptions.Add(_T("Recipe C"));
    for (int i = 1; i < 9; ++i) {
   // 去除表头,从第2行开始填充数据
    for (int i = 1; i < SLOT_MAX + 1; ++i) {
        CString strIndex;
        strIndex.Format(_T("%d"), i);
        m_wndGrid.SetItemText(i, 0, strIndex);
        m_wndGrid.SetItemState(i, 0, GVIS_READONLY);
        if (i != 3) {
        // Checkbox
        m_wndGrid.SetCellType(i, 1, RUNTIME_CLASS(CGridCellCheck));
        CGridCellCheck* pCheck = static_cast<CGridCellCheck*>(m_wndGrid.GetCell(i, 1));
        if (pCheck) {
                // 设置 Panel ID 和勾选框
                CGridCellCheck* pCheck = static_cast<CGridCellCheck*>(m_wndGrid.GetCell(i, 1));
                if (pCheck && pSlot && pGlass) {
                    pCheck->SetCheck(pSlot->isEnable() ? TRUE : FALSE);
                    pCheck->SetText(pGlass ? pGlass->getID().c_str() : _T(""));
                }
                else {
            pCheck->SetCheck(FALSE);
                    pCheck->SetText(_T(""));
                }
            }
        }
        else {
            m_wndGrid.SetItemState(i, 1, GVIS_READONLY);
        }
    }