DriverThread.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #pragma once
  2. // 下列 ifdef 块是创建使从 DLL 导出更简单的
  3. // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 DRIVERTHREAD_EXPORTS
  4. // 符号编译的。在使用此 DLL 的
  5. // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
  6. // DRIVERTHREAD_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
  7. // 符号视为是被导出的。
  8. #ifndef DRIVERTHREAD_EXPORTS
  9. #ifdef _WIN64
  10. #ifdef _DEBUG
  11. #pragma comment(lib, "DriverThreadX64D.lib")
  12. #else
  13. #pragma comment(lib, "DriverThreadX64.lib")
  14. #endif
  15. #else
  16. #ifdef _DEBUG
  17. #pragma comment(lib, "DriverThreadD.lib")
  18. #else
  19. #pragma comment(lib, "DriverThread.lib")
  20. #endif
  21. #endif
  22. #endif
  23. #ifdef DRIVERTHREAD_EXPORTS
  24. #define DRIVERTHREAD_API __declspec(dllexport)
  25. #else
  26. #define DRIVERTHREAD_API __declspec(dllimport)
  27. #endif
  28. #include "MsgMap.h"
  29. #include "MsgVector.h"
  30. #include "DiosThread.h"
  31. #include "LogicDevice.h"
  32. class DRIVERTHREAD_API Driver_Thread : public Work_Thread
  33. {
  34. protected:
  35. bool HandleClientRequest();
  36. bool HandleDeviceNotify();
  37. MsgMap<UINT64, LogicDeviceSysIF*> *m_pDeviceSysIFMap;
  38. MsgVector<LogicDeviceSysIF*> *m_pDeviceSysIFVec;
  39. virtual bool Exec();
  40. virtual bool OnEndThread();
  41. virtual bool OnStartThread();
  42. public:
  43. Driver_Thread(void);
  44. virtual ~Driver_Thread(void);
  45. //work
  46. //IF
  47. void RegistSysIFObject(LogicDeviceSysIF* pobj);
  48. bool UnRegistSysIFObject(LogicDeviceSysIF* pobj);
  49. };
  50. class DRIVERTHREAD_API Notify_Driver_Thread : public Driver_Thread
  51. {
  52. public:
  53. Notify_Driver_Thread(void);
  54. virtual ~Notify_Driver_Thread(void);
  55. protected:
  56. int WaitForEvent();//Req,NotifyPacket,NotifyEvt
  57. virtual bool Exec();
  58. bool ProcessDeviceEvent(size_t Idx);
  59. };
  60. class DRIVERTHREAD_API Dual_Driver_Thread
  61. {
  62. Driver_Thread *m_pReqThread;
  63. Driver_Thread *m_pResThread;
  64. public:
  65. Dual_Driver_Thread(void);
  66. virtual ~Dual_Driver_Thread(void);
  67. //IF
  68. void InitDriverThread(Driver_Thread *pReq, Driver_Thread *pRes);
  69. bool HasThread(DWORD Tid);
  70. bool StartThread(bool Sync = true, bool Inherit = true);
  71. bool StopThread(DWORD timeperiod = 10000);
  72. bool PushReqDataObject(ResDataObject &obj);
  73. bool PushResDataObject(ResDataObject &obj);
  74. void RegistSysIFObject(LogicDeviceSysIF* pobj);
  75. bool UnRegistSysIFObject(LogicDeviceSysIF* pobj);
  76. void SetLogger(PVOID pLogger);
  77. };