#pragma once #include #include "CEquipment.h" #include "CEFEM.h" #include "CBonder.h" #include "CLoadPort.h" #include "CFliper.h" #include "CAligner.h" #include "CVacuumBake.h" #include "CBakeCooling.h" #include "CMeasurement.h" #include "CArm.h" #include "CArmTray.h" #include "CCLinkIEControl.h" namespace SERVO { enum MASTERSTATE { READY = 0, STARTING, RUNNING, STOPPING }; typedef std::function ONMASTERSTATECHANGED; typedef std::function ONEQALIVE; typedef std::function ONEQSTEPEVENT; typedef std::function ONEQALARM; typedef std::function ONEQVCREVENTREPORT; typedef std::function ONEQDATACHANGED; typedef struct _MasterListener { ONMASTERSTATECHANGED onMasterStateChanged; ONEQALIVE onEqAlive; ONEQALIVE onEqCimStateChanged; ONEQALARM onEqAlarm; ONEQVCREVENTREPORT onEqVcrEventReport; ONEQDATACHANGED onEqDataChanged; } MasterListener; class CMaster { public: CMaster(); ~CMaster(); public: void setListener(MasterListener listener); int init(); int term(); int start(); int stop(); ULONGLONG getRunTime(); MASTERSTATE getState(); unsigned DispatchProc(); unsigned ReadBitsProc(); void onTimer(UINT nTimerid); std::list& getEquipmentList(); CEquipment* getEquipment(int id); void setCacheFilepath(const char* pszFilepath); private: inline void lock() { EnterCriticalSection(&m_criticalSection); } inline void unlock() { LeaveCriticalSection(&m_criticalSection); } int addToEquipmentList(CEquipment* pEquipment); CLoadPort* addLoadPort(int index); CFliper* addFliper(); CVacuumBake* addVacuumBake(); CAligner* addAligner(); CEFEM* addEFEM(); CArm* addArm(); CArmTray* addArmTray(int index); CBonder* addBonder(int index); CBakeCooling* addBakeCooling(); CMeasurement* addMeasurement(); void connectEquipments(); int saveCache(); int saveCacheAndBackups(); int readCache(); void serialize(CArchive& ar); void setState(MASTERSTATE state); private: CRITICAL_SECTION m_criticalSection; MasterListener m_listener; CCCLinkIEControl m_cclink; std::list m_listEquipment; std::string m_strFilepath; BOOL m_bDataModify; private: /* ¼à¿Ø±ÈÌØÎ»µÄÏß³Ì*/ HANDLE m_hEventReadBitsThreadExit[2]; HANDLE m_hReadBitsThreadHandle; unsigned m_nReadBitsThreadAddr; // µ÷¶ÈÏß³Ì HANDLE m_hDispatchEvent; HANDLE m_hEventDispatchThreadExit[2]; HANDLE m_hDispatchThreadHandle; unsigned m_nDispatchThreadAddr; // Æô¶¯Ê±¼ä£¬ÔËÐÐʱ¼ä£¬×´Ì¬ ULONGLONG m_ullStartTime; ULONGLONG m_ullRunTime; MASTERSTATE m_state; }; }