From f0f5854c1c32543aba129f0114a9bdd9e758e220 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期五, 12 九月 2025 17:26:27 +0800
Subject: [PATCH] 1.为调机方便,增加物料账单转移的功能;

---
 SourceCode/Bond/Servo/resource.h          |    0 
 SourceCode/Bond/Servo/CEquipmentPage2.cpp |   28 ++++++++++++-
 SourceCode/Bond/Servo/CEquipment.cpp      |   19 ++++++++-
 SourceCode/Bond/Servo/Servo.rc            |    0 
 SourceCode/Bond/Servo/CMaster.cpp         |   46 ++++++++++++++++++++++
 SourceCode/Bond/Servo/CMaster.h           |    3 +
 SourceCode/Bond/Servo/Model.cpp           |    4 ++
 SourceCode/Bond/Servo/CEquipment.h        |    1 
 SourceCode/Bond/Servo/CEquipmentPage2.h   |    1 
 SourceCode/Bond/Servo/ServoDlg.cpp        |    2 +
 10 files changed, 98 insertions(+), 6 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.cpp b/SourceCode/Bond/Servo/CEquipment.cpp
index aa339b2..6a3b56d 100644
--- a/SourceCode/Bond/Servo/CEquipment.cpp
+++ b/SourceCode/Bond/Servo/CEquipment.cpp
@@ -1497,6 +1497,19 @@
 		return &m_slot[index];
 	}
 
+	CSlot* CEquipment::getSlotWithNo(int slotNo)
+	{
+		CSlot* pSlot = nullptr;
+		for (int i = 0; i < SLOT_MAX; i++) {
+			if (!m_slot[i].isEnable()) continue;
+			if (m_slot[i].getNo() != slotNo) continue;
+			pSlot = &m_slot[i];
+			break;
+		}
+
+		return pSlot;
+	}
+
 	CGlass* CEquipment::getAnyGlass()
 	{
 		CSlot* pSlot = nullptr;
@@ -1581,8 +1594,10 @@
 		}
 
 		auto rawData = processData.getParamsRawData();
-		std::vector<CParam> params;
-		this->parsingParams((const char*)rawData.data(), rawData.size(), params);
+		std::vector<CParam> tempParams;
+		this->parsingParams((const char*)rawData.data(), rawData.size(), tempParams);
+		int n = processData.getTotalParameter();
+		std::vector<CParam> params(tempParams.begin(), tempParams.begin() + min(n, (int)tempParams.size()));
 		pGlass->addParams(params);
 		
 		// 关联的Glass也要更新
diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index a469408..ff16693 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -181,6 +181,7 @@
 
 		// 获取指定的Slot
 		CSlot* getSlot(int index);
+		CSlot* getSlotWithNo(int slotNo);
 
 		// 获取一个可用的槽位
 		CSlot* getAvailableSlot();
diff --git a/SourceCode/Bond/Servo/CEquipmentPage2.cpp b/SourceCode/Bond/Servo/CEquipmentPage2.cpp
index 984fa26..aef0b77 100644
--- a/SourceCode/Bond/Servo/CEquipmentPage2.cpp
+++ b/SourceCode/Bond/Servo/CEquipmentPage2.cpp
@@ -34,6 +34,7 @@
 	ON_WM_SIZE()
 	ON_NOTIFY(LVN_ITEMCHANGED, IDC_LIST1, &CEquipmentPage2::OnLvnItemchangedList1)
 	ON_BN_CLICKED(IDC_BUTTON_REMOVE, &CEquipmentPage2::OnBnClickedButtonRemove)
+	ON_BN_CLICKED(IDC_BUTTON_PUT, &CEquipmentPage2::OnBnClickedButtonPut)
 END_MESSAGE_MAP()
 
 
@@ -125,10 +126,17 @@
 	GetClientRect(&rcClient);
 
 	int x = 12;
+	int x1 = x;
 	int y2 = rcClient.bottom - 12;
 	pItem = GetDlgItem(IDC_BUTTON_REMOVE);
 	pItem->GetWindowRect(&rcItem);
 	pItem->MoveWindow(x, y2 - rcItem.Height(), rcItem.Width(), rcItem.Height());
+	x1 += rcItem.Width();
+	x1 += 12;
+
+	pItem = GetDlgItem(IDC_BUTTON_PUT);
+	pItem->GetWindowRect(&rcItem);
+	pItem->MoveWindow(x1, y2 - rcItem.Height(), rcItem.Width(), rcItem.Height());
 	y2 -= rcItem.Height();
 	y2 -= 8;
 
@@ -160,9 +168,24 @@
 	if (index >= 0) {
 		SERVO::CSlot* pSlot = (SERVO::CSlot*)m_listCtrl.GetItemData(index);
 		ASSERT(pSlot);
-		int bRet = m_pEquipment->removeGlass(pSlot->getNo());
-		if (bRet == 0) {
+		if (theApp.m_model.getMaster().moveGlassToBuf(m_pEquipment->getID(),
+			pSlot->getNo())) {
 			UpdateSlots();
+			AfxMessageBox("鐗╂枡宸插彇鍑哄埌Buffer涓紒");
+		}
+	}
+}
+
+void CEquipmentPage2::OnBnClickedButtonPut()
+{
+	int index = GetSelectedItemIndex();
+	if (index >= 0) {
+		SERVO::CSlot* pSlot = (SERVO::CSlot*)m_listCtrl.GetItemData(index);
+		ASSERT(pSlot);
+		if (theApp.m_model.getMaster().moveGlassToSlot(m_pEquipment->getID(),
+			pSlot->getNo())) {
+			UpdateSlots();
+			AfxMessageBox("鐗╂枡宸叉斁鍏ユ寚瀹氫綅缃紒");
 		}
 	}
 }
@@ -199,4 +222,3 @@
 		}
 	}
 }
-
diff --git a/SourceCode/Bond/Servo/CEquipmentPage2.h b/SourceCode/Bond/Servo/CEquipmentPage2.h
index c20331a..6257ec9 100644
--- a/SourceCode/Bond/Servo/CEquipmentPage2.h
+++ b/SourceCode/Bond/Servo/CEquipmentPage2.h
@@ -41,4 +41,5 @@
 	afx_msg void OnSize(UINT nType, int cx, int cy);
 	afx_msg void OnLvnItemchangedList1(NMHDR* pNMHDR, LRESULT* pResult);
 	afx_msg void OnBnClickedButtonRemove();
+	afx_msg void OnBnClickedButtonPut();
 };
diff --git a/SourceCode/Bond/Servo/CMaster.cpp b/SourceCode/Bond/Servo/CMaster.cpp
index e93c06e..0925933 100644
--- a/SourceCode/Bond/Servo/CMaster.cpp
+++ b/SourceCode/Bond/Servo/CMaster.cpp
@@ -2076,7 +2076,7 @@
 		pTarSlot = pTarEq->getAvailableSlotForGlass(primaryType);
 		pSrcSlot = pSrcEq->getProcessedSlot(primaryType, bJobMode);
 		if (m_nTestFlag == 1) LOGD("createTransferTask 003 %x, %x", pTarSlot, pSrcSlot);
-		if (pSrcSlot == nullptr || nullptr == pTarSlot && secondaryType != SERVO::MaterialsType::G0) {
+		if ((pSrcSlot == nullptr || nullptr == pTarSlot) && secondaryType != SERVO::MaterialsType::G0) {
 			pTarSlot = pTarEq->getAvailableSlotForGlass(secondaryType);
 			pSrcSlot = pSrcEq->getProcessedSlot(secondaryType, bJobMode);
 		}
@@ -2782,4 +2782,48 @@
 			m_strLastError = "AOI检测未通过.";
 		}
 	}
+
+	bool CMaster::moveGlassToBuf(int eqid, int slotNo)
+	{
+		CEquipment* pEquipment = getEquipment(eqid);
+		if (pEquipment == nullptr) return false;
+
+		CSlot* pSlot = pEquipment->getSlotWithNo(slotNo);
+		if (pSlot == nullptr) return false;
+
+		CGlass* pGlass = (CGlass*)pSlot->getContext();
+		m_bufGlass.push_back(pGlass);
+		pGlass->addRef();
+		pSlot->setContext(nullptr);
+
+		m_bDataModify = TRUE;
+		if (m_listener.onEqDataChanged != nullptr) {
+			m_listener.onEqDataChanged(this, pEquipment, 0);
+		}
+
+		return true;
+	}
+
+	bool CMaster::moveGlassToSlot(int eqid, int slotNo)
+	{
+		CEquipment* pEquipment = getEquipment(eqid);
+		if (pEquipment == nullptr) return false;
+
+		CSlot* pSlot = pEquipment->getSlotWithNo(slotNo);
+		if (pSlot == nullptr) return false;
+		if (m_bufGlass.empty()) return false;
+
+		CGlass* pGlass = m_bufGlass.front();
+		m_bufGlass.pop_front();
+		if (pGlass == nullptr) return false;
+		pSlot->setContext(pGlass);
+		pGlass->release();
+
+		m_bDataModify = TRUE;
+		if (m_listener.onEqDataChanged != nullptr) {
+			m_listener.onEqDataChanged(this, pEquipment, 0);
+		}
+
+		return true;
+	}
 }
diff --git a/SourceCode/Bond/Servo/CMaster.h b/SourceCode/Bond/Servo/CMaster.h
index 8536ab2..ebca19b 100644
--- a/SourceCode/Bond/Servo/CMaster.h
+++ b/SourceCode/Bond/Servo/CMaster.h
@@ -131,6 +131,8 @@
         bool loadState(const std::string& path);
         int getWipGlasses(std::vector<CGlass*>& glasses);
         void test();
+        bool moveGlassToBuf(int eqid, int slotNo);
+        bool moveGlassToSlot(int eqid, int slotNo);
         int getPortCassetteSnSeed(int port);
         void setPortCassetteSnSeed(int port, int seed);
 
@@ -249,6 +251,7 @@
         std::string m_strStatePath;
 
         int m_nTestFlag;
+        std::list<CGlass*> m_bufGlass;
     };
 }
 
diff --git a/SourceCode/Bond/Servo/Model.cpp b/SourceCode/Bond/Servo/Model.cpp
index b100f14..a518901 100644
--- a/SourceCode/Bond/Servo/Model.cpp
+++ b/SourceCode/Bond/Servo/Model.cpp
@@ -482,6 +482,10 @@
 
 int CModel::term()
 {
+	m_configuration.setPortCassetteSnSeed(1, m_master.getPortCassetteSnSeed(1));
+	m_configuration.setPortCassetteSnSeed(2, m_master.getPortCassetteSnSeed(2));
+	m_configuration.setPortCassetteSnSeed(3, m_master.getPortCassetteSnSeed(3));
+	m_configuration.setPortCassetteSnSeed(4, m_master.getPortCassetteSnSeed(4));
 	m_hsmsPassive.saveCache();
 	m_hsmsPassive.term();
 	CLog::GetLog()->SetOnLogCallback(nullptr);
diff --git a/SourceCode/Bond/Servo/Servo.rc b/SourceCode/Bond/Servo/Servo.rc
index 4672018..85262f2 100644
--- a/SourceCode/Bond/Servo/Servo.rc
+++ b/SourceCode/Bond/Servo/Servo.rc
Binary files differ
diff --git a/SourceCode/Bond/Servo/ServoDlg.cpp b/SourceCode/Bond/Servo/ServoDlg.cpp
index 0924c6c..74f8607 100644
--- a/SourceCode/Bond/Servo/ServoDlg.cpp
+++ b/SourceCode/Bond/Servo/ServoDlg.cpp
@@ -218,6 +218,7 @@
 					m_pMyStatusbar->setForegroundColor(RGB(0, 0, 0));
 					m_pMyStatusbar->setRunTimeText("启动失败.");
 					m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(TRUE);
+					KillTimer(TIMER_ID_UPDATE_RUMTIME);
 				}
 				else if (state == SERVO::MASTERSTATE::ATHERERROR) {
 					m_pTopToolbar->GetBtn(IDC_BUTTON_RUN)->EnableWindow(TRUE);
@@ -231,6 +232,7 @@
 						AfxMessageBox(_T("AOI检测失败,请操作员介入解决问题!"));
 					}
 					m_pTopToolbar->GetBtn(IDC_BUTTON_ALARM)->EnableWindow(TRUE);
+					KillTimer(TIMER_ID_UPDATE_RUMTIME);
 				}
 				else if (state == SERVO::MASTERSTATE::RUNNING || state == SERVO::MASTERSTATE::RUNNING_CONTINUOUS_TRANSFER
 					|| state == SERVO::MASTERSTATE::RUNNING_BATCH) {
diff --git a/SourceCode/Bond/Servo/resource.h b/SourceCode/Bond/Servo/resource.h
index c5bbd31..73f852c 100644
--- a/SourceCode/Bond/Servo/resource.h
+++ b/SourceCode/Bond/Servo/resource.h
Binary files differ

--
Gitblit v1.9.3