SourceCode/Bond/Servo/CMaster.h
@@ -12,14 +12,16 @@
#include "CArm.h"
#include "CArmTray.h"
#include "CCLinkIEControl.h"
#include "CRobotTask.h"
namespace SERVO {
    enum MASTERSTATE {
    enum class MASTERSTATE {
        READY = 0,
        STARTING,
        RUNNING,
        STOPPING
        STOPPING,
        MSERROR
    };
    typedef std::function<void(void* pMaster, MASTERSTATE state)> ONMASTERSTATECHANGED;
@@ -28,6 +30,7 @@
    typedef std::function<void(void* pMaster, CEquipment* pEquipment, int state, int alarmId, int unitId, int level)> ONEQALARM;
    typedef std::function<void(void* pMaster, CEquipment* pEquipment, CVcrEventReport* pReport)> ONEQVCREVENTREPORT;
    typedef std::function<void(void* pMaster, CEquipment* pEquipment, int code)> ONEQDATACHANGED;
    typedef std::function<void(void* pMaster, CRobotTask* pTask, int code)> ONROBOTTASKEVENT;
    typedef struct _MasterListener
    {
        ONMASTERSTATECHANGED    onMasterStateChanged;
@@ -36,21 +39,24 @@
        ONEQALARM               onEqAlarm;
        ONEQVCREVENTREPORT       onEqVcrEventReport;
        ONEQDATACHANGED         onEqDataChanged;
        ONROBOTTASKEVENT        onRobotTaskEvent;
    } MasterListener;
    class CMaster
    {
    public:
        CMaster();
        ~CMaster();
        virtual ~CMaster();
    public:
        void setListener(MasterListener listener);
        CRobotTask* getActiveRobotTask();
        int init();
        int term();
        int start();
        int stop();
        void clearError();
        ULONGLONG getRunTime();
        MASTERSTATE getState();
        unsigned DispatchProc();
@@ -59,6 +65,10 @@
        std::list<CEquipment*>& getEquipmentList();
        CEquipment* getEquipment(int id);
        void setCacheFilepath(const char* pszFilepath);
        int abortCurrentTask();
        int restoreCurrentTask();
        void setPortType(unsigned int index, BOOL enable, int type, int mode,
            int cassetteType, int transferMode, BOOL autoChangeEnable);
    private:
        inline void lock() { EnterCriticalSection(&m_criticalSection); }
@@ -80,7 +90,14 @@
        int readCache();
        void serialize(CArchive& ar);
        void setState(MASTERSTATE state);
        CRobotTask* createTransferTask(CEquipment* pSrcEq, CEquipment* pTarEq,
            MaterialsType primaryType = MaterialsType::G1, MaterialsType secondaryType = MaterialsType::G2,
            int armNo = 1);
        CRobotTask* createTransferTask_bonder_to_bakecooling(CEquipment* pSrcEq, CEquipment* pTarEq);
        CRobotTask* createTransferTask_bake_to_cooling(CEquipment* pSrcEq);
        CRobotTask* createTransferTask_bakecooling_to_measurement(CEquipment* pSrcEq, CEquipment* pTarEq);
        CRobotTask* createTransferTask_restore(CEquipment* pEqSrc, CLoadPort** pPorts);
    private:
        CRITICAL_SECTION m_criticalSection;
        MasterListener m_listener;
@@ -105,6 +122,14 @@
        ULONGLONG m_ullStartTime;
        ULONGLONG m_ullRunTime;
        MASTERSTATE m_state;
        // 当前任务和已完成任务列表
        CRobotTask* m_pActiveRobotTask;
        std::list< CRobotTask* > m_listTask;
        // 错误代码
        int m_nLastError;
        std::string m_strLastError;
    };
}