From 498b8e781603ae007f41d0056b616f95140dd273 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期三, 28 一月 2026 10:04:51 +0800
Subject: [PATCH] 1.新增出入料事件

---
 SourceCode/Bond/Servo/CEquipment.h |  121 +++++++++++++++++++++++++++++-----------
 1 files changed, 88 insertions(+), 33 deletions(-)

diff --git a/SourceCode/Bond/Servo/CEquipment.h b/SourceCode/Bond/Servo/CEquipment.h
index 1aa5abd..0ed9452 100644
--- a/SourceCode/Bond/Servo/CEquipment.h
+++ b/SourceCode/Bond/Servo/CEquipment.h
@@ -1,4 +1,4 @@
-#pragma once
+锘�#pragma once
 #include "Log.h"
 #include "ServoCommo.h"
 #include "CCLinkIEControl.h"
@@ -35,6 +35,8 @@
 #include "CProcessData.h"
 #include "CPortStatusReport.h"
 #include "CSlot.h"
+#include "CParam.h"
+#include "CSVData.h"
 
 
 namespace SERVO {
@@ -51,9 +53,15 @@
 	typedef std::function<void(void* pEiuipment, int code)> ONDATACHANGED;
 	typedef std::function<void(void* pEiuipment, int state, int alarmId, int unitId, int level)> ONALARM;
 	typedef std::function<void(void* pEiuipment, void* pReport)> ONVCREVENTREPORT;
-	typedef std::function<BOOL(void* pEiuipment, CJobDataB* pJobDataB)> ONPREFETCHEDOUTJOB;
-	typedef std::function<BOOL(void* pEiuipment, CJobDataB* pJobDataB, short& putSlot)> ONPRESTOREDJOB;
-	typedef std::function<void(void* pEiuipment, PROCESS_STATE state)> ONPROCESSSTATE;
+	typedef std::function<BOOL(void* pEiuipment, int port, CJobDataB* pJobDataB)> ONPREFETCHEDOUTJOB;
+	typedef std::function<BOOL(void* pEiuipment, int port, CJobDataB* pJobDataB, short& putSlot)> ONPRESTOREDJOB;
+	typedef std::function<void(void* pEiuipment, int nSlotNo, PROCESS_STATE prevState, PROCESS_STATE state)> ONPROCESSSTATE;
+	typedef std::function<void(void* pEiuipment, short scanMap, short downMap)> ONMAPMISMATCH;
+	typedef std::function<void(void* pEiuipment, short status, __int64 data)> ONPORTSTATUSCHANGED;
+	typedef std::function<void(void* pEiuipment, const std::vector<CParam>& params)> ONPROCESSDATAREPORT;
+	typedef std::function<void(void* pEiuipment, int port, CJobDataS* pJobDataS)> ONRECEIVEDJOB;
+	typedef std::function<void(void* pEiuipment, int port, CJobDataS* pJobDataS)> ONSENTOUTJOB;
+	
 	typedef struct _EquipmentListener
 	{
 		ONALIVE				onAlive;
@@ -64,6 +72,13 @@
 		ONPREFETCHEDOUTJOB	onPreFethedOutJob;
 		ONPRESTOREDJOB		onPreStoredJob;
 		ONPROCESSSTATE		onProcessStateChanged;
+		ONMAPMISMATCH		onMapMismatch;
+		ONPORTSTATUSCHANGED	onPortStatusChanged;
+		ONVCREVENTREPORT	onSVDataReport;
+		ONVCREVENTREPORT	onPanelDataReport;
+		ONPROCESSDATAREPORT	onProcessDataReport;
+		ONRECEIVEDJOB		onReceivedJob;
+		ONSENTOUTJOB		onSentOutJob;
 	} EquipmentListener;
 
 
@@ -74,6 +89,8 @@
 		virtual ~CEquipment();
 
 	public:
+		void SetEnable(BOOL bEnable);
+		BOOL IsEnabled() const;
 		virtual const char* getClassName() = 0;
 		virtual void setListener(EquipmentListener listener);
 		void setCcLink(CCCLinkIEControl* pCcLink);
@@ -88,6 +105,8 @@
 		std::string& getName();
 		void setDescription(const char* pszDescription);
 		std::string& getDescription();
+		void setCurrentRecipe(const std::string& recipe);
+		std::string getCurrentRecipe();
 		void setStation(int network, int station);
 		const StationIdentifier& getStation();
 		virtual void getAttributeVector(CAttributeVector& attrubutes);
@@ -110,14 +129,16 @@
 		virtual void onReceiveLBData(const char* pszData, size_t size);
 		virtual int onStepEvent(CStep* pStep, int code);
 		virtual CPin* addPin(PinType type, char* pszName);
-		virtual short getSlotUnit(short slot) { return 0; };
+		virtual short getSlotUnit(short slotNo) { return 0; };
 		CPin* getPin(char* pszName);
 		std::vector<CPin*>& CEquipment::getInputPins();
 		std::vector<CPin*>& CEquipment::getOutputPins();
 		CRecipeList* getRecipeList(int unitNo);
+		bool saveRecipeList(int unitNo, std::string& strFilepath);
+		bool readRecipeList(int unitNo, std::string& strFilepath);
 		virtual int recvIntent(CPin* pPin, CIntent* pIntent);
-		virtual int fetchedOutJob(CJobDataB* pJobDataB);
-		virtual int storedJob(CJobDataB* pJobDataB, short putSlot);
+		virtual int fetchedOutJob(int port, CJobDataB* pJobDataB);
+		virtual int storedJob(int port, CJobDataB* pJobDataB, short putSlot);
 		virtual int onReceivedJob(int port, CJobDataS* pJobDataS);
 		virtual int onSentOutJob(int port, CJobDataS* pJobDataS);
 		virtual BOOL onPreFetchedOutJob(int port, CJobDataB* pJobDataB);
@@ -125,10 +146,11 @@
 		virtual BOOL onPreStoredJob(int port, CJobDataB* pJobDataB, short& putSlot);
 		virtual int onStoredJob(int port, CJobDataB* pJobDataB);
 		virtual int onProcessData(CProcessData* pProcessData);
-		virtual int onSendAble();
-		virtual int onReceiveAble();
-		virtual int onProcessStateChanged(PROCESS_STATE state);
+		virtual int onSendAble(int port);
+		virtual int onReceiveAble(int port);
+		virtual int onProcessStateChanged(int nSlotNo, PROCESS_STATE prevState, PROCESS_STATE state);
 		virtual int getIndexerOperationModeBaseValue();
+		virtual bool isSlotProcessed(int slot) { return true; };
 		bool isAlarmStep(SERVO::CStep* pStep);
 		bool isVcrEventStep(SERVO::CStep* pStep);
 		bool isCassetteTransferStateStep(SERVO::CStep* pStep);
@@ -147,58 +169,77 @@
 		int setDispatchingMode(DISPATCHING_MODE mode, ONWRITED onWritedBlock = nullptr);
 		int indexerOperationModeChange(IDNEXER_OPERATION_MODE mode, ONWRITEDRET onWritedRetBlock);
 		void printDebugString001();
+		std::vector<SERVO::CSVData>& getSVDatas();
 
-
-		// 请求主配方列表
+		// 璇锋眰涓婚厤鏂瑰垪琛�
 		// unitNo: 0:local; Others:unit No
 		int masterRecipeListRequest(short unitNo, ONSYNCINGSTATECHANGED block);
 
-		// 请求配方参数
-		// masterRecipeId: 主配方id
-		// localRecipeId: 本地配方id
+		// 璇锋眰閰嶆柟鍙傛暟
+		// masterRecipeId: 涓婚厤鏂筰d
+		// localRecipeId: 鏈湴閰嶆柟id
 		// unitNo: 0:local; Others:unit No
-		int recipeParameterRequest(short masterRecipeId, short localRecipeId, short unitNo);
+		int recipeParameterRequest(short masterRecipeId, short localRecipeId, short unitNo, ONSYNCINGSTATECHANGED block);
 
-		// 获取指定的Slot
+		// 瑙f瀽閰嶆柟鍙傛暟鍒楄〃
+		virtual int parsingParams(const char* pszData, size_t size, std::vector<CParam>& params) { return 0;  };
+		virtual int parsingParams(const char* pszData, size_t size, std::string& strOut);
+		virtual int parsingProcessData(const char* pszData, size_t size, std::vector<CParam>& params) { return 0; };
+		virtual int parsingSVData(const char* pszData, size_t size, std::vector<CParam>& params) { return 0; };
+
+		// 鑾峰彇鎸囧畾鐨凷lot
 		CSlot* getSlot(int index);
+		CSlot* getSlotWithNo(int slotNo);
 
-		// 获取一个可用的槽位
+		// 鑾峰彇涓�涓彲鐢ㄧ殑妲戒綅
 		CSlot* getAvailableSlot();
 
-		// 获取一个指定物料类型(G1,G2,G1&G2)的空槽位
+		// 鑾峰彇涓�涓寚瀹氱墿鏂欑被鍨�(G1,G2,G1&G2)鐨勭┖妲戒綅
 		CSlot* getAvailableSlotForGlass(MaterialsType type);
 		CSlot* getAvailableSlotForGlassExcludeSignal(MaterialsType type);
+		CSlot* isSlotAvailable(unsigned int slot);
 
-		// 在指定的槽列表中,获取一个指定物料类型(G1,G2,G1&G2)的空槽位
+		// 鍦ㄦ寚瀹氱殑妲藉垪琛ㄤ腑锛岃幏鍙栦竴涓寚瀹氱墿鏂欑被鍨�(G1,G2,G1&G2)鐨勭┖妲戒綅
 		CSlot* getAvailableSlotForGlass2(MaterialsType type, const std::vector<int>& candidates);
 
-		// 获取一个指定物料类型(G1,G2,G1&G2)的非空槽位
+		// 鑾峰彇涓�涓寚瀹氱墿鏂欑被鍨�(G1,G2,G1&G2)鐨勯潪绌烘Ы浣�
 		CSlot* getNonEmptySlot(MaterialsType type);
 
-		// 获取一个指定物料类型(G1,G2,G1&G2)的且已经加工处理的槽位
-		CSlot* getProcessedSlot(MaterialsType putSlotType);
+		// 鑾峰彇涓�涓寚瀹氱墿鏂欑被鍨�(G1,G2,G1&G2)鐨勪笖宸茬粡鍔犲伐澶勭悊鐨勬Ы浣�
+		CSlot* getProcessedSlot(MaterialsType putSlotType, BOOL bJobMode = FALSE);
 		CSlot* getProcessedSlot2(MaterialsType putSlotType, const std::vector<int>& candidates);
+		CSlot* getInspFailSlot();
+		CSlot* getProcessedSlotCt(unsigned int slot);
 
-		// 获取玻璃物料
+		// 鑾峰彇鐜荤拑鐗╂枡
 		CGlass* getGlassFromSlot(int slotNo);
 		CGlass* getGlassWithCassette(int cassetteSequenceNo, int jobSequenceNo);
 		CGlass* getAnyGlass();
 		CGlass* getGlass(const char* pszGlassId);
+		int getAllGlass(std::vector<CGlass*>& glasses);
 		CJobDataS* getJobDataSWithCassette(int cassetteSequenceNo, int jobSequenceNo);
 
-		// 验证玻璃和槽是否匹配
+		// 楠岃瘉鐜荤拑鍜屾Ы鏄惁鍖归厤
 		BOOL ValidateGlassSlotMatch();
 
-		// 是否有玻璃
+		// 鏄惁鏈夌幓鐠�
 		BOOL hasGlass();
+		BOOL slotHasGlass(int slotIndex = 0);
 
-		// 指定槽位是否可以放置玻璃
+		// 鎸囧畾妲戒綅鏄惁鍙互鏀剧疆鐜荤拑
 		BOOL canPlaceGlassInSlot(const short slotIndex);
 
-		// 手动移除物料
+		// 鎵嬪姩绉婚櫎鐗╂枡
 		int removeGlass(int slotNo);
 
-	// 以下为从CC-Link读取到的Bit标志位检测函数
+		// 瀛楃涓叉娴嬬粨鏋滆浆鎹�
+		InspResult judgeStringToInspResult(std::string& strJudge);
+
+		// for test
+		void fireSetProcessState(int nSlotNo, PROCESS_STATE state) { return setProcessState(nSlotNo, state); }
+
+
+	// 浠ヤ笅涓轰粠CC-Link璇诲彇鍒扮殑Bit鏍囧織浣嶆娴嬪嚱鏁�
 	public:
 		BOOL isAlive();
 		BOOL isCimOn();
@@ -210,7 +251,7 @@
 		BOOL isLinkSignalUpstreamOn(unsigned int path, unsigned int signal);
 		BOOL isLinkSignalDownstreamOn(unsigned int path, unsigned int signal);
 
-		// 只在模拟测试时使用的函数,用于模拟信号
+		// 鍙湪妯℃嫙娴嬭瘯鏃朵娇鐢ㄧ殑鍑芥暟锛岀敤浜庢ā鎷熶俊鍙�
 		void setLinkSignalUpstream(unsigned int path, unsigned int signal, BOOL bOn);
 		void setLinkSignalUpstreamBlock(unsigned int path, BOOL* pSignal);
 		void setLinkSignalDownstream(unsigned int path, unsigned int signal, BOOL bOn);
@@ -232,14 +273,24 @@
 		int decodePanelDataReport(CStep* pStep, const char* pszData, size_t size);
 		int decodeFacDataReport(CStep* pStep, const char* pszData, size_t size);
 		int decodeJobDataRequest(CStep* pStep, const char* pszData, size_t size);
+		int decodeJobProcessStartReport(CStep* pStep, const char* pszData, size_t size);
+		int decodeJobProcessEndReport(CStep* pStep, const char* pszData, size_t size);
 		BOOL compareJobData(CJobDataB* pJobDataB, CJobDataS* pJobDataS);
-		void setProcessState(PROCESS_STATE state);
+		void setProcessState(int nSlotNo, PROCESS_STATE state);
+		float toFloat(const char* pszAddr);
 
 	protected:
+		// 閮ㄥ垎浼樺寲/绠�鍖栦唬鐮併�佹殏瀹炵幇閮ㄥ垎锛屽埌鏃跺钩閾哄紑
+		void addFacDataReportStep(int dataDev, int writeSignalDev, int port);
+
+
+	protected:
+		BOOL m_bEnable;
 		EquipmentListener m_listener;
 		int m_nID;
 		std::string m_strName;
 		std::string m_strDescription;
+		std::string m_currentRecipe;
 		CRITICAL_SECTION m_criticalSection;
 		StationIdentifier m_station;
 		MemoryBlock m_blockReadBit;
@@ -248,7 +299,7 @@
 		std::vector<CPin*> m_outputPins;
 
 
-		// 以下为从CC-Link读取到的Bit标志位
+		// 浠ヤ笅涓轰粠CC-Link璇诲彇鍒扮殑Bit鏍囧織浣�
 	protected:
 		ALIVE m_alive;
 		BOOL m_bCimState;			// ON/OFF
@@ -266,10 +317,14 @@
 		int m_nBaseAlarmId;
 		CRecipesManager m_recipesManager;
 		CSlot m_slot[SLOT_MAX];
-		PROCESS_STATE m_processState;
+		PROCESS_STATE m_processState[SLOT_MAX] = { PROCESS_STATE::Ready };
+		std::vector<SERVO::CSVData> m_svDatas;
 
 	private:
 		CEquipment* m_pArm;
+
+	public:
+		int m_nTestFlag;
 	};
 }
 

--
Gitblit v1.9.3