From e8a27bb203fe2aff70390a5eca002d7438da9b0f Mon Sep 17 00:00:00 2001
From: mrDarker <mr.darker@163.com>
Date: 星期三, 22 十月 2025 14:24:34 +0800
Subject: [PATCH] Merge branch 'clh' into liuyang
---
SourceCode/Bond/Servo/CCjPage2.cpp | 480 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 480 insertions(+), 0 deletions(-)
diff --git a/SourceCode/Bond/Servo/CCjPage2.cpp b/SourceCode/Bond/Servo/CCjPage2.cpp
new file mode 100644
index 0000000..2f4d559
--- /dev/null
+++ b/SourceCode/Bond/Servo/CCjPage2.cpp
@@ -0,0 +1,480 @@
+锘�// CPjPage1.cpp: 瀹炵幇鏂囦欢
+//
+
+#include "stdafx.h"
+#include "Servo.h"
+#include "CCjPage2.h"
+#include "afxdialogex.h"
+#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 };
+
+// CPjPage1 瀵硅瘽妗�
+
+IMPLEMENT_DYNAMIC(CCjPage2, CCjPageBase)
+
+CCjPage2::CCjPage2(CWnd* pParent /*=nullptr*/)
+ : CCjPageBase(IDD_CJ_PAGE2, pParent)
+{
+ m_nSelRadioId = 0;
+}
+
+CCjPage2::~CCjPage2()
+{
+}
+
+void CCjPage2::DoDataExchange(CDataExchange* pDX)
+{
+ CCjPageBase::DoDataExchange(pDX);
+}
+
+
+BEGIN_MESSAGE_MAP(CCjPage2, CCjPageBase)
+ ON_WM_DESTROY()
+ ON_EN_CHANGE(IDC_EDIT_PJ_ID, &CCjPage2::OnEnChangeEditPjId)
+ ON_CBN_SELCHANGE(IDC_COMBO_RECIPE, &CCjPage2::OnCbnSelchangeComboRecipe)
+ ON_BN_CLICKED(IDC_RADIO1, &CCjPage2::OnBnClickedRadio1)
+ ON_BN_CLICKED(IDC_RADIO2, &CCjPage2::OnBnClickedRadio2)
+ ON_BN_CLICKED(IDC_RADIO3, &CCjPage2::OnBnClickedRadio3)
+ 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()
+
+
+// CPjPage1 娑堟伅澶勭悊绋嬪簭
+
+
+void CCjPage2::OnSetContext(void* pContext)
+{
+ UpdatePjData();
+}
+
+void CCjPage2::SetPjWarps(std::vector<PJWarp>& pjs)
+{
+ m_pjWarps = pjs;
+}
+
+BOOL CCjPage2::OnInitDialog()
+{
+ CCjPageBase::OnInitDialog();
+
+
+ m_grid.SubclassDlgItem(IDC_GRID1, this);
+ m_grid.InitGrid(4, 8);
+ m_grid.SetColumnWidths(100, 220);
+ m_grid.SetRowHeight(32);
+ m_grid.SetHeaderHeight(36);
+ m_grid.EnableColumnResize(FALSE); // 绂佹鎷栧姩鍒楀
+ m_grid.SetShowMaterialToggle(TRUE);
+ m_grid.DisableSystemScrollbars();
+ m_grid.ResizeWindowToFitAll(TRUE); // TRUE=鍖呭惈闈炲鎴峰尯锛堣竟妗嗐�佹爣棰樻爮锛�
+ m_grid.SetNoScrollbarsMode(TRUE); // 褰诲簳绂佺敤婊氬姩鏉�
+ m_grid.FitWindowToContentNoScroll(TRUE); // 绐楀彛灏哄鍒氬ソ瀹圭撼鍏ㄩ儴鍐呭锛堜笉鍑虹幇婊氬姩鏉★級
+
+ m_grid.SetPortInfo(0, _T("Port 1"), _T(""));
+ m_grid.SetPortInfo(1, _T("Port 2"), _T(""));
+ m_grid.SetPortInfo(2, _T("Port 3"), _T(""));
+ m_grid.SetPortInfo(3, _T("Port 4"), _T(""));
+
+
+ UpdatePjData();
+
+
+ return TRUE; // return TRUE unless you set the focus to a control
+ // 寮傚父: OCX 灞炴�ч〉搴旇繑鍥� FALSE
+}
+
+void CCjPage2::OnDestroy()
+{
+ CCjPageBase::OnDestroy();
+
+ // TODO: 鍦ㄦ澶勬坊鍔犳秷鎭鐞嗙▼搴忎唬鐮�
+}
+
+void CCjPage2::Resize()
+{
+ CCjPageBase::Resize();
+
+
+ CWnd* pItem;
+ CRect rcClient, rcItem;
+ GetClientRect(&rcClient);
+ pItem = GetDlgItem(IDC_GRID1);
+ pItem->GetWindowRect(&rcItem);
+ ScreenToClient(rcItem);
+
+
+ int x = rcItem.left + 100 + 18;
+ int y = 100;
+
+
+ // 璁╂帶浠剁獥鍙e昂瀵歌嚜鍔ㄥ尮閰嶅綋鍓嶅垪瀹�/琛屾暟锛堜笉鍑虹幇婊氬姩鏉★級
+ 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()
+{
+ //SERVO::CProcessJob*
+ if (m_pContext == nullptr) return -1;
+ PJWarp* pPjWarp = (PJWarp*)m_pContext;
+ SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)pPjWarp->pj;
+
+ // 鏇存柊鍚嶇О
+ BOOL bOkName = TRUE;
+ char szBuffer[256];
+ GetDlgItemText(IDC_EDIT_PJ_ID, szBuffer, 256);
+ for (auto item : m_pjWarps) {
+ if (item.pj != pProcessJob) {
+ SERVO::CProcessJob* temp = (SERVO::CProcessJob*)item.pj;
+ if (temp->id().compare(std::string(szBuffer)) == 0) {
+ bOkName = FALSE;
+ break;
+ }
+ }
+ }
+ if (!bOkName) {
+ AfxMessageBox("涓嶈兘浣跨敤鍜屽叾瀹働rocess Job鐩稿悓鐨処D");
+ return -1;
+ }
+
+
+ pProcessJob->setId(std::string(szBuffer));
+
+ // 鏇存柊閰嶆柟
+ CString strRecipe;
+ CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_RECIPE);
+ int idx = pComboBox->GetCurSel();
+ if (idx >= 0) {
+ pComboBox->GetLBText(idx, strRecipe);
+#ifdef UNICODE
+ CT2A utf8Str(strRecipe, CP_UTF8);
+ std::string recipe(utf8Str);
+#else
+ std::string recipe(strRecipe.GetString());
+#endif
+
+ pProcessJob->setRecipe(SERVO::RecipeMethod::NoTuning, recipe);
+ }
+
+
+ // 鏇存柊Port
+ int port = -1;
+ static int ids[] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4 };
+ for (int i = 0; i < 4; i++) {
+ int state = ((CButton*)GetDlgItem(ids[i]))->GetCheck();
+ if (state == BST_CHECKED) port = i;
+ }
+ pPjWarp->port = port;
+
+ if (pPjWarp->port != -1) {
+ for (int i = 0; i < 8; i++) {
+ pPjWarp->checkSlot[i] = m_grid.GetSlotChecked(pPjWarp->port, i);
+ pPjWarp->material[i] = m_grid.GetSlotMaterialType(pPjWarp->port, i);
+ }
+ }
+
+
+ ContentChanged(1);
+ return 0;
+}
+
+void CCjPage2::UpdatePjData()
+{
+ if (m_pContext == nullptr) return;
+
+ m_bContentChangedLock = TRUE;
+
+ CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_RECIPE);
+ pComboBox->ResetContent();
+ std::vector<std::string> vecRecipe = RecipeManager::getInstance().getAllPPID();
+ for (const auto& recipe : vecRecipe) {
+ pComboBox->AddString(CString(recipe.c_str()));
+ }
+
+
+ // ComboBox
+ PJWarp* pPjWarp = (PJWarp*)m_pContext;
+ SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)pPjWarp->pj;
+ SetDlgItemText(IDC_EDIT_PJ_ID, pProcessJob->id().c_str());
+ int idx = pComboBox->FindStringExact(-1, pProcessJob->recipeSpec().c_str());
+ if (idx != CB_ERR) pComboBox->SetCurSel(idx);
+
+
+ // 4涓猚heckbox
+ static int ids[] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4};
+ static char* pszUsed[] = { "Port1(宸插崰鐢�)", "Port2(宸插崰鐢�)", "Port3(宸插崰鐢�)", "Port4(宸插崰鐢�)" };
+ static char* pszUnUsed[] = { "Port1(鍙敤)", "Port2(鍙敤)", "Port3(鍙敤)", "Port4(鍙敤)" };
+
+ int portIndex = -1;
+ bool enable[] = {true, true, true, true};
+ bool checked[] = { false, false, false, false };
+ for (auto item : m_pjWarps) {
+ if (0 <= item.port && item.port <= 4 && item.pj != ((PJWarp*)m_pContext)->pj) {
+ enable[item.port] = false;
+ }
+ }
+ if (0 <= ((PJWarp*)m_pContext)->port && ((PJWarp*)m_pContext)->port <= 3) {
+ checked[((PJWarp*)m_pContext)->port] = true;
+ portIndex = ((PJWarp*)m_pContext)->port;
+ m_nSelRadioId = ids[((PJWarp*)m_pContext)->port];
+ }
+
+ for (int i = 0; i < 4; i++) {
+ CButton* pButton = (CButton*)GetDlgItem(ids[i]);
+ pButton->SetCheck(checked[i] ? BST_CHECKED : BST_UNCHECKED);
+ pButton->SetWindowText(enable[i] ? pszUnUsed[i] : pszUsed[i]);
+ pButton->EnableWindow(enable[i]);
+
+ m_grid.SetPortAllocated(i, !checked[i], _T(""));
+ GetDlgItem(btnID[i])->EnableWindow(checked[i]);
+ }
+
+
+ // 璇诲彇鍑虹湡瀹炴暟鎹�
+ auto& master = theApp.m_model.getMaster();
+ int EQID[] = {EQ_ID_LOADPORT1, EQ_ID_LOADPORT2, EQ_ID_LOADPORT3, EQ_ID_LOADPORT4};
+ for (int p = 0; p < 4; p++) {
+ SERVO::CLoadPort* pPort = (SERVO::CLoadPort*)master.getEquipment(EQID[p]);
+ m_grid.SetPortInfo(p,
+ (std::string("Port ") + std::to_string(p+1)).c_str(),
+ pPort->getCassetteId().c_str()
+ );
+ for (int i = 0; i < SLOT_MAX; ++i) {
+ SERVO::CSlot* pSlot = pPort->getSlot(i);
+ if (!pSlot) {
+ continue;
+ }
+
+ // 璁剧疆 Panel ID
+ SERVO::CGlass* pGlass = dynamic_cast<SERVO::CGlass*>(pSlot->getContext());
+ SERVO::CJobDataS* pJobDataS = pGlass->getJobDataS();
+ if (pGlass != nullptr && pJobDataS != nullptr) {
+ m_grid.SetSlotGlass(p, i, TRUE,
+ pGlass->getID().c_str(),
+ m_pjWarps[p].material[i]);
+ }
+ else {
+ m_grid.SetSlotGlass(p, i, FALSE, nullptr, CCarrierSlotGrid::MAT_G1);
+ }
+ }
+ }
+
+
+ // 璁剧疆鍕鹃�夋暟鎹�
+ if (portIndex != -1) {
+ for (int i = 0; i < 8; i++) {
+ m_grid.SetSlotChecked(portIndex, i, ((PJWarp*)m_pContext)->checkSlot[i]);
+ }
+ }
+
+ m_bContentChangedLock = FALSE;
+}
+
+void CCjPage2::OnEnChangeEditPjId()
+{
+ ContentChanged(0);
+}
+
+void CCjPage2::OnCbnSelchangeComboRecipe()
+{
+ ContentChanged(0);
+}
+
+void CCjPage2::OnBnClickedRadio1()
+{
+ BOOL lock[] = {TRUE, TRUE, TRUE, TRUE};
+ if (IDC_RADIO1 == m_nSelRadioId) {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0);
+ m_nSelRadioId = 0;
+ }
+ else {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO1);
+ m_nSelRadioId = IDC_RADIO1;
+ lock[0] = FALSE;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ m_grid.SetPortAllocated(i, lock[i], _T(""));
+ GetDlgItem(btnID[i])->EnableWindow(!lock[i]);
+ }
+
+ ContentChanged(0);
+}
+
+void CCjPage2::OnBnClickedRadio2()
+{
+ BOOL lock[] = { TRUE, TRUE, TRUE, TRUE };
+ if (IDC_RADIO2 == m_nSelRadioId) {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0);
+ m_nSelRadioId = 0;
+ }
+ else {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO2);
+ m_nSelRadioId = IDC_RADIO2;
+ lock[1] = FALSE;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ m_grid.SetPortAllocated(i, lock[i], _T(""));
+ GetDlgItem(btnID[i])->EnableWindow(!lock[i]);
+ }
+
+ ContentChanged(0);
+}
+
+void CCjPage2::OnBnClickedRadio3()
+{
+ BOOL lock[] = { TRUE, TRUE, TRUE, TRUE };
+ if (IDC_RADIO3 == m_nSelRadioId) {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0);
+ m_nSelRadioId = 0;
+ }
+ else {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO3);
+ m_nSelRadioId = IDC_RADIO3;
+ lock[2] = FALSE;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ m_grid.SetPortAllocated(i, lock[i], _T(""));
+ GetDlgItem(btnID[i])->EnableWindow(!lock[i]);
+ }
+
+ ContentChanged(0);
+}
+
+void CCjPage2::OnBnClickedRadio4()
+{
+ BOOL lock[] = { TRUE, TRUE, TRUE, TRUE };
+ if (IDC_RADIO4 == m_nSelRadioId) {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0);
+ m_nSelRadioId = 0;
+ }
+ else {
+ CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO4);
+ m_nSelRadioId = IDC_RADIO4;
+ lock[3] = FALSE;
+ }
+
+ for (int i = 0; i < 4; i++) {
+ m_grid.SetPortAllocated(i, lock[i], _T(""));
+ GetDlgItem(btnID[i])->EnableWindow(!lock[i]);
+ }
+
+ ContentChanged(0);
+}
+
+void CCjPage2::OnGridSelChanged(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ auto* nm = reinterpret_cast<CSG_SEL_CHANGE*>(pNMHDR);
+ const int port = nm->port;
+ const int slot = nm->slot;
+ const BOOL chk = nm->checked;
+
+ // 杩欓噷鍐欎綘鐨勪笟鍔¢�昏緫
+ // 渚嬪锛氭洿鏂扮姸鎬佹爮 / 鍚屾鍏跺畠鎺т欢 / 缁熻鏁伴噺
+ ContentChanged(0);
+
+ /*
+ if (m_pContext != nullptr) {
+ PJWarp* pjWarp = (PJWarp*)m_pContext;
+ for (int i = 0; i < 8; i++) {
+ pjWarp->checkSlot[i] = m_grid.GetSlotChecked(port, i);
+ pjWarp->material[i] = m_grid.GetSlotMaterialType(port, i);
+ }
+ }
+ */
+
+ *pResult = 0;
+}
+
+void CCjPage2::OnGridMatChanged(NMHDR* pNMHDR, LRESULT* pResult)
+{
+ auto* nm = reinterpret_cast<CSG_MAT_CHANGE*>(pNMHDR);
+ const int port = nm->port;
+ const int slot = nm->slot;
+ const int mat = nm->material; // 1/2
+
+ // 渚嬪锛氬嵆鍒诲埛鏂板彸渚ч瑙�/璁板綍鏃ュ織绛�
+ ContentChanged(0);
+
+ /*
+ if (m_pContext != nullptr) {
+ PJWarp* pjWarp = (PJWarp*)m_pContext;
+ for (int i = 0; i < 8; i++) {
+ pjWarp->checkSlot[i] = m_grid.GetSlotChecked(port, i);
+ pjWarp->material[i] = m_grid.GetSlotMaterialType(port, i);
+ }
+ }
+ */
+
+ *pResult = 0;
+}
+
+void CCjPage2::OnBnClickedButtonPort1ProcessStart()
+{
+ auto& master = theApp.m_model.getMaster();
+ auto port = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT1);
+ port->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
+
+}
+
+void CCjPage2::OnBnClickedButtonPort2ProcessStart()
+{
+ auto& master = theApp.m_model.getMaster();
+ auto port = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT2);
+ port->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
+}
+
+void CCjPage2::OnBnClickedButtonPort3ProcessStart()
+{
+ auto& master = theApp.m_model.getMaster();
+ auto port = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT3);
+ port->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
+}
+
+void CCjPage2::OnBnClickedButtonPort4ProcessStart()
+{
+ auto& master = theApp.m_model.getMaster();
+ auto port = (SERVO::CLoadPort*)master.getEquipment(EQ_ID_LOADPORT4);
+ port->sendCassetteCtrlCmd(CCC_PROCESS_START, nullptr, 0, 0, 0, nullptr, nullptr);
+}
+
+
--
Gitblit v1.9.3