From 2a6b8de3ee1ed419bbe54213dcb8428d2c436a69 Mon Sep 17 00:00:00 2001
From: LAPTOP-SNT8I5JK\Boounion <Chenluhua@qq.com>
Date: 星期一, 13 一月 2025 08:56:24 +0800
Subject: [PATCH] 1.PLC调机程序,警告和其它完善;

---
 SourceCode/Bond/BoounionPLC/PLC.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/SourceCode/Bond/BoounionPLC/PLC.h b/SourceCode/Bond/BoounionPLC/PLC.h
index 2bfc39e..e69e54c 100644
--- a/SourceCode/Bond/BoounionPLC/PLC.h
+++ b/SourceCode/Bond/BoounionPLC/PLC.h
@@ -5,6 +5,8 @@
 #pragma comment(lib,"winmm")
 
 
+#define ALARM_MONITOR		_T("警告信息")
+
 typedef std::function<void(void* pFrom, int)> ONPLCSTATECHANGED;
 typedef std::function<void(void* pFrom, int)> ONPLCMONITORDATA;
 typedef std::function<void(void* pFrom, CAlarm*, int)> ONALARM;
@@ -42,6 +44,7 @@
 	~CPLC();
 
 public:
+	void setListener(PLCListener& listener);
 	void setWorkDir(const char* pszDir);
 	void init();
 	void term();
@@ -66,15 +69,24 @@
 	int writeDWord(MC::SOFT_COMPONENT softComponent, unsigned int addr, int value, ONWRITE funOnWrite);
 	int writeBit(MC::SOFT_COMPONENT softComponent, unsigned int addr, BOOL bValue, ONWRITE funOnWrite);
 	int writeData(MC::SOFT_COMPONENT softComponent, unsigned int addr, const char* pszData, unsigned int length, ONWRITE funOnWrite);
+	void readPLCDataRegularly();
 
+public:
+	int getVelocityRatio();
+	double getTackTime();
+	int getDayShiftCapacity();
+	int getNightShiftCapacity();
 
 public:
 	HANDLE m_hTimeEvent;
 
 private:
+	inline void Lock() { EnterCriticalSection(&m_criticalSection); }
+	inline void Unlock() { LeaveCriticalSection(&m_criticalSection); }
 	void setState(PLCSTATE state);
 	void monitorReadData(MONITOR& monitor);
 	CString& dataToHexString(const char* pData, const int size, CString& strOut);
+	int onMonitorData(MONITOR& monitor);
 
 private:
 	std::string m_strWorkDir;
@@ -87,13 +99,22 @@
 	unsigned int m_nActionInterval;
 	unsigned int m_nUnHeartBeat;
 	std::vector<CComponent*> m_components;
+	char* m_pPlcData;
 
 private:
+	CRITICAL_SECTION m_criticalSection;
 	std::vector<MONITOR> m_monitors;
 	HANDLE m_hMcMonitorStop;
 	HANDLE m_hMcMonitorThreadHandle;
 	unsigned m_mcMonitorThrdaddr;
 	MMRESULT m_nTimerId;
 	bool m_bMute;
+
+private:
+	int m_nVelocityRatio;		// 速度比
+	double m_dTactTime;			// 周期时间
+	int m_nDayShiftCapacity;	// 白班产能
+	int m_nNightShiftCapacity;	// 夜班产能
+	bool m_bBlBtnsStates[7];	// PLC View按钮状态
 };
 

--
Gitblit v1.9.3