chenluhua1980
7 天以前 ceb64b6612309fe384e096dcdc8b5a5e0dfe6cce
SourceCode/Bond/Servo/CCjPage2.cpp
@@ -8,6 +8,45 @@
#include "RecipeManager.h"
UINT btnID[] = { IDC_BUTTON_PORT1_PROCESS_START,
    IDC_BUTTON_PORT2_PROCESS_START,
    IDC_BUTTON_PORT3_PROCESS_START,
    IDC_BUTTON_PORT4_PROCESS_START };
namespace {
    void BuildCassetteCtrlMaps(SERVO::CLoadPort* pPort, short (&jobExistence)[12], short& slotProcess)
    {
        slotProcess = 0;
        bool anyScheduled = false;
        // Prefer hardware scan map for job existence (first 16 slots).
        const short scanMap = pPort->getScanCassetteMap();
        if (scanMap != 0) {
            jobExistence[0] = scanMap;
        }
        const int maxSlots = 12 * 16;
        const int totalSlots = (SLOT_MAX < maxSlots) ? SLOT_MAX : maxSlots;
        for (int slot = 1; slot <= totalSlots; ++slot) {
            SERVO::CGlass* pGlass = pPort->getGlassFromSlot(slot);
            if (pGlass == nullptr) continue;
            const int wordIndex = (slot - 1) / 16;
            const int bitIndex = (slot - 1) % 16;
            jobExistence[wordIndex] = (short)(jobExistence[wordIndex] | (1 << bitIndex));
            if (slot <= 16 && pGlass->isScheduledForProcessing()) {
                slotProcess = (short)(slotProcess | (1 << bitIndex));
                anyScheduled = true;
            }
        }
        if (!anyScheduled) {
            slotProcess = jobExistence[0];
        }
    }
}
// CPjPage1 对话框
IMPLEMENT_DYNAMIC(CCjPage2, CCjPageBase)
@@ -38,6 +77,10 @@
    ON_BN_CLICKED(IDC_RADIO4, &CCjPage2::OnBnClickedRadio4)
    ON_NOTIFY(CSGN_SEL_CHANGED, IDC_GRID1, &CCjPage2::OnGridSelChanged)
    ON_NOTIFY(CSGN_MAT_CHANGED, IDC_GRID1, &CCjPage2::OnGridMatChanged)
    ON_BN_CLICKED(IDC_BUTTON_PORT1_PROCESS_START, &CCjPage2::OnBnClickedButtonPort1ProcessStart)
    ON_BN_CLICKED(IDC_BUTTON_PORT2_PROCESS_START, &CCjPage2::OnBnClickedButtonPort2ProcessStart)
    ON_BN_CLICKED(IDC_BUTTON_PORT3_PROCESS_START, &CCjPage2::OnBnClickedButtonPort3ProcessStart)
    ON_BN_CLICKED(IDC_BUTTON_PORT4_PROCESS_START, &CCjPage2::OnBnClickedButtonPort4ProcessStart)
END_MESSAGE_MAP()
@@ -103,12 +146,41 @@
    pItem->GetWindowRect(&rcItem);
    ScreenToClient(rcItem);
    int x = rcItem.left + 100 + 18;
    int y = 100;
    // 让控件窗口尺寸自动匹配当前列宽/行数(不出现滚动条)
    if (::IsWindow(m_grid.m_hWnd)) {
        CSize best = m_grid.CalcBestWindowSize(TRUE, -1, 2, 2);
        pItem->MoveWindow(rcItem.left, rcItem.top, best.cx, best.cy);
        pItem->Invalidate();
        pItem->GetWindowRect(&rcItem);
        ScreenToClient(rcItem);
        y = rcItem.bottom;
        y += 18;
    }
    pItem = GetDlgItem(IDC_BUTTON_PORT1_PROCESS_START);
    pItem->GetWindowRect(&rcItem);
    pItem->MoveWindow(x, y, rcItem.Width(), rcItem.Height());
    x += 220;
    pItem = GetDlgItem(IDC_BUTTON_PORT2_PROCESS_START);
    pItem->GetWindowRect(&rcItem);
    pItem->MoveWindow(x, y, rcItem.Width(), rcItem.Height());
    x += 220;
    pItem = GetDlgItem(IDC_BUTTON_PORT3_PROCESS_START);
    pItem->GetWindowRect(&rcItem);
    pItem->MoveWindow(x, y, rcItem.Width(), rcItem.Height());
    x += 220;
    pItem = GetDlgItem(IDC_BUTTON_PORT4_PROCESS_START);
    pItem->GetWindowRect(&rcItem);
    pItem->MoveWindow(x, y, rcItem.Width(), rcItem.Height());
    x += 220;
}
int CCjPage2::OnApply() 
@@ -225,6 +297,7 @@
        pButton->EnableWindow(enable[i]);
        m_grid.SetPortAllocated(i, !checked[i], _T(""));
        GetDlgItem(btnID[i])->EnableWindow(checked[i]);
    }
@@ -262,7 +335,6 @@
    if (portIndex != -1) {
        for (int i = 0; i < 8; i++) {
            m_grid.SetSlotChecked(portIndex, i, ((PJWarp*)m_pContext)->checkSlot[i]);
            // m_grid.SetSlotMaterialType(portIndex, i, ((PJWarp*)m_pContext)->material[i]);
        }
    }
@@ -294,6 +366,7 @@
    for (int i = 0; i < 4; i++) {
        m_grid.SetPortAllocated(i, lock[i], _T(""));
        GetDlgItem(btnID[i])->EnableWindow(!lock[i]);
    }
    ContentChanged(0);
@@ -314,6 +387,7 @@
    for (int i = 0; i < 4; i++) {
        m_grid.SetPortAllocated(i, lock[i], _T(""));
        GetDlgItem(btnID[i])->EnableWindow(!lock[i]);
    }
    ContentChanged(0);
@@ -334,6 +408,7 @@
    for (int i = 0; i < 4; i++) {
        m_grid.SetPortAllocated(i, lock[i], _T(""));
        GetDlgItem(btnID[i])->EnableWindow(!lock[i]);
    }
    ContentChanged(0);
@@ -354,6 +429,7 @@
    for (int i = 0; i < 4; i++) {
        m_grid.SetPortAllocated(i, lock[i], _T(""));
        GetDlgItem(btnID[i])->EnableWindow(!lock[i]);
    }
    ContentChanged(0);
@@ -405,3 +481,50 @@
    *pResult = 0;
}
void CCjPage2::OnBnClickedButtonPort1ProcessStart()
{
    auto& master = theApp.m_model.getMaster();
    auto port = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT1);
    if (port == nullptr) return;
    short jobExistence[12] = { 0 };
    short slotProcess = 0;
    BuildCassetteCtrlMaps(port, jobExistence, slotProcess);
    port->sendCassetteCtrlCmd(CCC_PROCESS_START, jobExistence, 12, slotProcess, 0, nullptr, nullptr);
}
void CCjPage2::OnBnClickedButtonPort2ProcessStart()
{
    auto& master = theApp.m_model.getMaster();
    auto port = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT2);
    if (port == nullptr) return;
    short jobExistence[12] = { 0 };
    short slotProcess = 0;
    BuildCassetteCtrlMaps(port, jobExistence, slotProcess);
    port->sendCassetteCtrlCmd(CCC_PROCESS_START, jobExistence, 12, slotProcess, 0, nullptr, nullptr);
}
void CCjPage2::OnBnClickedButtonPort3ProcessStart()
{
    auto& master = theApp.m_model.getMaster();
    auto port = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT3);
    if (port == nullptr) return;
    short jobExistence[12] = { 0 };
    short slotProcess = 0;
    BuildCassetteCtrlMaps(port, jobExistence, slotProcess);
    port->sendCassetteCtrlCmd(CCC_PROCESS_START, jobExistence, 12, slotProcess, 0, nullptr, nullptr);
}
void CCjPage2::OnBnClickedButtonPort4ProcessStart()
{
    auto& master = theApp.m_model.getMaster();
    auto port = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT4);
    if (port == nullptr) return;
    short jobExistence[12] = { 0 };
    short slotProcess = 0;
    BuildCassetteCtrlMaps(port, jobExistence, slotProcess);
    port->sendCassetteCtrlCmd(CCC_PROCESS_START, jobExistence, 12, slotProcess, 0, nullptr, nullptr);
}