From 1e8e3473cb124f9e51dfc1ca35e5cb13b1668bdc Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期六, 10 五月 2025 10:46:19 +0800
Subject: [PATCH] 1.重命名类名称和文件名;

---
 SourceCode/Bond/Servo/CPageGraph2.cpp |  284 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 265 insertions(+), 19 deletions(-)

diff --git a/SourceCode/Bond/Servo/CPageGraph2.cpp b/SourceCode/Bond/Servo/CPageGraph2.cpp
index aa1cd73..dfef13f 100644
--- a/SourceCode/Bond/Servo/CPageGraph2.cpp
+++ b/SourceCode/Bond/Servo/CPageGraph2.cpp
@@ -5,6 +5,11 @@
 #include "Servo.h"
 #include "CPageGraph2.h"
 #include "afxdialogex.h"
+#include "CHMPropertyDlg.h"
+#include "CEquipmentPage1.h"
+#include "CEquipmentPage2.h"
+#include "CPagePortProperty.h"
+#include "CPageCassetteCtrlCmd.h"
 
 
 // CPageGraph2 瀵硅瘽妗�
@@ -17,6 +22,7 @@
 	m_pEqsGraphWnd = nullptr;
 	m_crBkgnd = PAGE_GRPAH2_BACKGROUND_COLOR;
 	m_hbrBkgnd = nullptr;
+	m_pObserver = nullptr;
 }
 
 CPageGraph2::~CPageGraph2()
@@ -40,6 +46,40 @@
 // CPageGraph2 娑堟伅澶勭悊绋嬪簭
 
 
+void CPageGraph2::InitRxWindows()
+{
+	/* code */
+	// 璁㈤槄鏁版嵁
+	IRxWindows* pRxWindows = RX_GetRxWindows();
+	pRxWindows->enableLog(5);
+	if (m_pObserver == NULL) {
+		m_pObserver = pRxWindows->allocObserver([&](IAny* pAny) -> void {
+			// onNext
+			pAny->addRef();
+			int code = pAny->getCode();
+			if (RX_CODE_EQ_DATA_CHANGED == code) {
+				// 閫氱煡璁惧鐘舵��
+				SERVO::CEquipment* pEquipment = nullptr;
+				if (pAny->getPtrValue("ptr", (void*&)pEquipment)) {
+					if (pEquipment != nullptr) {
+						m_pEqsGraphWnd->ShowItemIndicator((DWORD_PTR)pEquipment, !pEquipment->isGlassListEmpty());
+					}
+				}
+			}
+
+			pAny->release();
+			}, [&]() -> void {
+				// onComplete
+			}, [&](IThrowable* pThrowable) -> void {
+				// onErrorm
+				pThrowable->printf();
+			});
+
+		theApp.m_model.getObservable()->observeOn(pRxWindows->mainThread())
+			->subscribe(m_pObserver);
+	}
+}
+
 BOOL CPageGraph2::OnInitDialog()
 {
 	CDialogEx::OnInitDialog();
@@ -54,11 +94,6 @@
 		ASSERT(pPin1->pData);
 		ASSERT(pPin2->pData);
 
-		//int nRet = ((IPin*)pPin1->pData)->checkConnectPin((IPin*)pPin2->pData);
-		//if (nRet >= 0) {
-		//	return true;
-		//}
-
 		return false;
 	};
 	listener.onConnectPin = [](PIN* pPin1, PIN* pPin2) -> bool {
@@ -67,39 +102,194 @@
 		ASSERT(pPin1->pData);
 		ASSERT(pPin2->pData);
 
-		//int nRet = ((IPin*)pPin1->pData)->connectPin((IPin*)pPin2->pData);
-		//if (nRet >= 0) {
-		//	return true;
-		//}
-
 		return false;
 	};
 	listener.onDisconnectPin = [](PIN* pPin) -> bool {
 		ASSERT(pPin);
 		ASSERT(pPin->pData);
 
-		//int nRet = ((IPin*)pPin->pData)->disconnect();
-		//if (nRet >= 0) {
-		//	return true;
-		//}
-
 		return false;
 	};
 	listener.onDeleteEqItem = [&](EQITEM* pItem) -> bool {
 		ASSERT(pItem);
 		ASSERT(pItem->pData);
-		return true;
-		// return _filterManager.unload((CFilter*)pFilter->pData) >= 0;
+		return false;
 	};
 	listener.onEqItemPosChanged = [&](EQITEM* pItem, int x, int y) -> void {
 		ASSERT(pItem);
 	};
 	listener.onDblckEqItem = [&](EQITEM* pItem) -> bool {
 		ASSERT(pItem);
+		SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
+
+		CHMPropertyDlg dlg(pEquipment->getName().c_str(), 600, 680);
+
+		if (_strcmpi(pEquipment->getClassName(), "CLoadPort") == 0) {
+			CPagePortProperty* pPage1 = new CPagePortProperty();
+			pPage1->setLoadPort((SERVO::CLoadPort*)pEquipment);
+			pPage1->Create(IDD_PAGE_PORT_PROPERTY);
+			dlg.addPage(pPage1, "灞炴��");
+		}
+
+		CEquipmentPage2* pPage2 = new CEquipmentPage2();
+		pPage2->setEquipment(pEquipment);
+		pPage2->Create(IDD_PAGE_EQUIPMENT2);
+		dlg.addPage(pPage2, "Glass");
+
+		if (pEquipment->getID() == EQ_ID_LOADPORT1
+			|| pEquipment->getID() == EQ_ID_LOADPORT2) {
+			CPageCassetteCtrlCmd* pPage = new CPageCassetteCtrlCmd();
+			pPage->setEquipment(pEquipment);
+			pPage->Create(IDD_PAGE_CASSETTE_CTRL_CMD);
+			dlg.addPage(pPage, "Cassette control command");
+		}
+
+		dlg.DoModal();
 		return true;
 	};
 	listener.onRclickEqItem = [&](EQITEM* pItem) -> bool {
 		ASSERT(pItem);
+
+		CMenu menu, menuCommand;
+		CMenu* pPopupMenu;
+		menu.LoadMenu(IDR_MENU_EQSGRAPH_ITEM);
+		pPopupMenu = menu.GetSubMenu(0);
+
+
+		// 鏄剧ず妯″紡
+		pPopupMenu->EnableMenuItem(ID_EQSGRAPHITEM_SMALL, MF_DISABLED | MF_GRAYED);
+		pPopupMenu->EnableMenuItem(ID_EQSGRAPHITEM_NORMAL, MF_DISABLED | MF_GRAYED);
+		pPopupMenu->EnableMenuItem(ID_EQSGRAPHITEM_LARGE, MF_DISABLED | MF_GRAYED);
+		if (pItem->nShowType == ITEM_SMALL) {
+			pPopupMenu->CheckMenuRadioItem(ID_EQSGRAPHITEM_SMALL, ID_EQSGRAPHITEM_LARGE, ID_EQSGRAPHITEM_SMALL, MF_CHECKED);
+		}
+		else if (pItem->nShowType == ITEM_LARGE) {
+			pPopupMenu->CheckMenuRadioItem(ID_EQSGRAPHITEM_SMALL, ID_EQSGRAPHITEM_LARGE, ID_EQSGRAPHITEM_LARGE, MF_CHECKED);
+		}
+		else {
+			pPopupMenu->CheckMenuRadioItem(ID_EQSGRAPHITEM_SMALL, ID_EQSGRAPHITEM_LARGE, ID_EQSGRAPHITEM_NORMAL, MF_CHECKED);
+		}
+
+
+
+		POINT pt;
+		GetCursorPos(&pt);
+		int nCmd = pPopupMenu->TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN | TPM_TOPALIGN, pt.x, pt.y, this, NULL);
+		if (nCmd == ID_EQSGRAPHITEM_SMALL) {
+			m_pEqsGraphWnd->SetItemType(pItem, ITEM_SMALL);
+		}
+		else if (nCmd == ID_EQSGRAPHITEM_NORMAL) {
+			m_pEqsGraphWnd->SetItemType(pItem, ITEM_NORMAL);
+		}
+		else if (nCmd == ID_EQSGRAPHITEM_LARGE) {
+			m_pEqsGraphWnd->SetItemType(pItem, ITEM_LARGE);
+		}
+
+
+		// 娴嬭瘯
+		else if (nCmd == ID_EQSGRAPHITEM_TEST1) {
+			SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
+			if (pEquipment->getID() == EQ_ID_LOADPORT1) {
+				pEquipment->outputGlass(1);
+			}
+			pEquipment->fetchedOut("P20250320A1A2");
+		}
+		else if (nCmd == ID_EQSGRAPHITEM_TEST2) {
+			SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
+			pEquipment->storeJob("P20250320A1A2");
+		}
+		else if (nCmd == ID_EQSGRAPHITEM_TEST3) {
+			SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
+
+			// 娴嬭瘯涓嬪彂Cim Message
+			/*
+			if (pEquipment->getID() == EQ_ID_Bonder1
+				|| pEquipment->getID() == EQ_ID_Bonder2) {
+				static int msgId = 0; msgId++;
+				if (msgId % 2 == 0) {
+					pEquipment->setCimMessage("Hello!", msgId, 1);
+				}
+				else {
+					pEquipment->setCimMessage("ABC0123456789", msgId, 2);
+				}
+			}
+			*/
+
+
+			// 娴嬭瘯娓呴櫎Cim Message
+			/*
+			if (pEquipment->getID() == EQ_ID_Bonder1
+				|| pEquipment->getID() == EQ_ID_Bonder2) {
+				static int msgId = 0; msgId++;
+				if (msgId % 2 == 0) {
+					pEquipment->clearCimMessage(msgId, 1);
+				}
+				else {
+					pEquipment->clearCimMessage(msgId, 2);
+				}
+			}
+			*/
+
+			// 娴嬭瘯璁剧疆鏃堕棿
+			/*
+			if (pEquipment->getID() == EQ_ID_Bonder1
+				|| pEquipment->getID() == EQ_ID_Bonder2) {
+				CTime time = CTime::GetCurrentTime();
+				pEquipment->setDateTime((short)time.GetYear(),
+					(short)time.GetMonth(),
+					(short)time.GetDay(),
+					(short)time.GetHour(),
+					(short)time.GetMinute(),
+					(short)time.GetSecond());
+			}
+			*/
+
+			
+			// 娴嬭瘯璁剧疆cim mode
+			/*
+			if (pEquipment->getID() == EQ_ID_Bonder1
+				|| pEquipment->getID() == EQ_ID_Bonder2) {
+				static int ii = 0; ii++;
+				pEquipment->setCimMode(ii % 2 == 0);
+			}
+			*/
+			
+			
+			if (pEquipment->getID() == EQ_ID_Bonder1
+				|| pEquipment->getID() == EQ_ID_Bonder2) {
+				static int ii = 0; ii++;
+				pEquipment->setEqMode((ii % 5) + 1);
+			}
+			
+
+			/*
+			SERVO::CGlass* pGlass = pEquipment->getFrontGlass();
+			if (pGlass != nullptr) {
+				std::string strDescription;
+				SERVO::CPath* pPath = pGlass->getPath();
+				while (pPath != nullptr) {
+					pPath->getDescription(strDescription);
+					AfxMessageBox(strDescription.c_str());
+					pPath = pPath->getNext();
+				}
+			}
+			*/
+
+
+			// 璇锋眰涓婚厤鏂瑰垪琛�
+			if (pEquipment != nullptr) {
+				pEquipment->masterRecipeListRequest(0);
+			}			
+		}
+
+
+		return true;
+	};
+	listener.onSelectEqItem = [&](EQITEM* pItem) -> bool {
+		ASSERT(pItem);
+		SERVO::CEquipment* pEquipment = (SERVO::CEquipment*)pItem->pData;
+		theApp.m_model.notifyPtr(RX_CODE_SELECT_EQUIPMENT, pEquipment);
+
 		return true;
 	};
 
@@ -133,9 +323,15 @@
 void CPageGraph2::OnDestroy()
 {
 	CDialogEx::OnDestroy();
+	SaveEqsGraphData();
 
 	if (m_hbrBkgnd != nullptr) {
 		::DeleteObject(m_hbrBkgnd);
+	}
+
+	if (m_pObserver != nullptr) {
+		m_pObserver->unsubscribe();
+		m_pObserver = NULL;
 	}
 }
 
@@ -154,8 +350,15 @@
 #define OUTPIN		2
 void CPageGraph2::AddEqToGraphWnd(SERVO::CEquipment* pEquipment)
 {
+	int x, y;
+	GetItemDataFormIni(pEquipment->getName().c_str(), x, y);
+
 	EQITEM* pItem = m_pEqsGraphWnd->AddItem(0, pEquipment->getName().c_str(), (DWORD_PTR)pEquipment);
 	m_pEqsGraphWnd->SetItemType(pItem, ITEM_SMALL);
+	if (x > 0 && y > 0) {
+		m_pEqsGraphWnd->SetItemPos(pItem, x, y);
+	}
+
 	std::vector<SERVO::CPin*>& inPins = pEquipment->getInputPins();
 	for (auto inPin : inPins) {
 		m_pEqsGraphWnd->AddPin(pItem, INPIN, inPin->getName().c_str(), (DWORD_PTR)inPin);
@@ -165,17 +368,60 @@
 	for (auto outPin : outPins) {
 		m_pEqsGraphWnd->AddPin(pItem, OUTPIN, outPin->getName().c_str(), (DWORD_PTR)outPin);
 	}
+
+	m_pEqsGraphWnd->ShowItemIndicator((DWORD_PTR)pEquipment, !pEquipment->isGlassListEmpty());
 }
 
 void CPageGraph2::OnTimer(UINT_PTR nIDEvent)
 {
 	if (1 == nIDEvent) {
+		InitRxWindows();
 		KillTimer(1);
 		std::list<SERVO::CEquipment*>& eqs = theApp.m_model.m_master.getEquipmentList();
-		for (auto item : eqs) {
-			AddEqToGraphWnd(item);
+		for (auto eq : eqs) {
+			AddEqToGraphWnd(eq);
+		}
+
+		for (auto eq : eqs) {
+			auto& pins = eq->getOutputPins();
+			for (auto pin : pins) {
+				SERVO::CPin* pPin2 = pin->getConnectedPin();
+				if (pPin2 != nullptr) {
+					m_pEqsGraphWnd->ConnectPin((DWORD_PTR)eq, (DWORD_PTR)pin, (DWORD_PTR)pPin2->getEquipment(), (DWORD_PTR)pPin2);
+				}
+			}
 		}
 	}
 
 	CDialogEx::OnTimer(nIDEvent);
 }
+
+void CPageGraph2::SaveEqsGraphData()
+{
+	char szFilepath[MAX_PATH];
+	CString strValue;
+	sprintf_s(szFilepath, MAX_PATH, "%s\\EqsGraph.ini", (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	std::list<SERVO::CEquipment*>& eqs = theApp.m_model.m_master.getEquipmentList();
+	for (auto item : eqs) {
+		EQITEM* pEqItem = m_pEqsGraphWnd->GetItem((DWORD_PTR)item);
+		if (nullptr == pEqItem) {
+			continue;
+		}
+
+		strValue.Format(_T("%d"), pEqItem->rect.left);
+		WritePrivateProfileString(item->getName().c_str(), _T("Left"),
+			(LPTSTR)(LPCTSTR)strValue, szFilepath);
+		strValue.Format(_T("%d"), pEqItem->rect.top);
+		WritePrivateProfileString(item->getName().c_str(), _T("Top"),
+			(LPTSTR)(LPCTSTR)strValue, szFilepath);
+	}
+}
+
+void CPageGraph2::GetItemDataFormIni(const char* pszItemName, int& left, int& top)
+{
+	char szFilepath[MAX_PATH];
+	CString strValue;
+	sprintf_s(szFilepath, MAX_PATH, "%s\\EqsGraph.ini", (LPTSTR)(LPCTSTR)theApp.m_strAppDir);
+	left = GetPrivateProfileInt(pszItemName, _T("Left"), 0, szFilepath);
+	top = GetPrivateProfileInt(pszItemName, _T("Top"), 0, szFilepath);
+}
\ No newline at end of file

--
Gitblit v1.9.3