123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- #pragma once
- #define MONITOR_NOTIFY_EVENT_MAX 64
- namespace DIOS::Dev::Detail::MachineryECOM
- {
- const std::string MONITOR_EVENT_WAIT_BEGIN_MONITOR = "MONITOR_EVENT_WAIT_BEGIN_MONITOR";
- const std::string MONITOR_EVENT_WAIT_END_MONITOR = "MONITOR_EVENT_WAIT_END_MONITOR";
- const std::string MONITOR_EVENT_TUBEANGLE_MOVE_STOP = "MONITOR_EVENT_TUBEANGLE_MOVE_STOP";
- const std::string MONITOR_EVENT_TUBEHEIGHT_MOVE_STOP = "MONITOR_EVENT_TUBEHEIGHT_MOVE_STOP";
- const std::string MONITOR_EVENT_TUBEHORIZONTAL_MOVE_STOP = "MONITOR_EVENT_TUBEHORIZONTAL_MOVE_STOP";
- enum MONITOR_OFFSET
- {
- MO_ALL,
- MO_TUBE_ANGLE,
- MO_TUBE_HEIGHT,
- MO_TUBE_HORIZONTAL,
- };
- class MotionMonitorThread;
- class IMotionEventReceiver;
- class MotionMonitorWorkThread;
- class IPositionManager;
- class MechnicalMonitor
- {
- public:
- MechnicalMonitor();
- ~MechnicalMonitor();
- public:
- static MechnicalMonitor *Instance();
- void Initialize(IPositionManager *coordinates,int dofTubeAngleAxis,int dofTubeHeightAxis);
- void BeginMonitor(IMotionEventReceiver *receiver, int offset = MO_ALL);
- void EndMonitor();
- void ReceiveEvent(const std::string &name);
- public:
- //以下函数的代码在 MotionMonitorThread 线程中执行
- bool OnMotionMonitorThreadExecute();
- bool OnMotionMonitorWorkThreadExecute();
- private:
- //以下函数的代码在 MotionMonitorThread 线程中执行
- void OnStartMonitorInThread();
- void OnStopMonitorInThread();
- private:
- void AddThreadWaitEventHandle(const std::string &name,HANDLE eventHandle);
- void AddThreadNotifyEventHandle(const std::string &name, HANDLE eventHandle);
- private:
- static MechnicalMonitor *m_instance;
- IPositionManager *m_positionManager;
- IMotionEventReceiver *m_eventReceiver;
- MotionMonitorThread *m_monitorThread;
- MotionMonitorWorkThread *m_monitorworkThread;
- std::map<int, std::string> m_notifyEventsIndexNameMap;
- std::map<int, std::string> m_waitEventsIndexNameMap;
- DWORD m_notifyEventHandleCount;
- HANDLE m_notifyEventHandles[MONITOR_NOTIFY_EVENT_MAX];
- DWORD m_waitEventHandleCount;
- HANDLE m_waitEventHandles[MONITOR_NOTIFY_EVENT_MAX];
- BOOL m_isMonitorStoped;
- int m_angleStopedNotifyTime;
- int m_heightStopedNotifyTime;
- int m_horizontalStopedNotifyTime;
- int m_dofTubeAngleAxis;
- int m_dofTubeHeightAxis;
- int m_dofTubeHorizontalAxis;
- };
- class MotionMonitorThread : public Thread_Base,public DiosLock
- {
- public:
- MotionMonitorThread() :m_monitor(nullptr){}
- ~MotionMonitorThread(){}
- void Initialize(MechnicalMonitor *monitor);
- protected:
- virtual bool Exec() override;
- private:
- MechnicalMonitor *m_monitor;
- };
- class MotionMonitorWorkThread : public Thread_Base
- {
- public:
- MotionMonitorWorkThread() :m_monitor(nullptr){}
- ~MotionMonitorWorkThread(){}
- void Initialize(MechnicalMonitor *monitor);
- protected:
- virtual bool Exec() override;
- private:
- MechnicalMonitor *m_monitor;
- };
- }
|