ExpelPlugin.hpp 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. #ifndef __EXPELPLUGIN_HPP_
  2. #define __EXPELPLUGIN_HPP_
  3. #include <iostream>
  4. #include "UtilBase.hpp"
  5. #include "Network/Socket.h"
  6. #include <mutex>
  7. #include <condition_variable>
  8. #include <future>
  9. #include "Util/logger.h"
  10. #include "requests.hpp"
  11. #include "Expel.hpp"
  12. #include "InfineFilter.hpp"
  13. #include "PluginSubscriber.hpp"
  14. using namespace std;
  15. using namespace toolkit;
  16. namespace gsd
  17. {
  18. class ExpelPlugin: public PluginSubscriber<ExpelPlugin>, public PluginBase
  19. {
  20. private:
  21. ExpelPlugin(): PluginBase(){
  22. }
  23. public:
  24. using Ptr = std::shared_ptr<ExpelPlugin>;
  25. /**
  26. * @description: 获取Ptr
  27. * @return {*}
  28. */
  29. static std::shared_ptr<ExpelPlugin> getPtr();
  30. /**
  31. * @description: Init
  32. * @return {*}
  33. */
  34. virtual bool Init();
  35. /**
  36. * @description: StartTask
  37. * @return {*}
  38. */
  39. virtual bool StartTask();
  40. /**
  41. * @description: Alive
  42. * @return {*}
  43. */
  44. virtual bool Alive();
  45. /**
  46. * @description: UdpRecData
  47. * @param {Ptr} &buf
  48. * @return {*}
  49. */
  50. void UdpRecData(const Buffer::Ptr &buf);
  51. /**
  52. * @description: 释放资源
  53. * @return {*}
  54. */
  55. virtual void Destroy();
  56. /**
  57. * @description: makeAddr
  58. * @param {sockaddr} *out
  59. * @param {char} *ip
  60. * @param {uint16_t} port
  61. * @return {*}
  62. */
  63. static void makeAddr(struct sockaddr *out,const char *ip,uint16_t port);
  64. /**
  65. * @description: sendDeviceMsgCallback
  66. * @param {NettyServerResultMsg<RecDeviceCommand>} &nettyServerResultMsg
  67. * @param {ExpelDevice} expelDevice
  68. * @return {*}
  69. */
  70. void sendDeviceMsgCallback(NettyServerResultMsg<RecDeviceCommand> &nettyServerResultMsg, ExpelDevice expelDevice);
  71. /**
  72. * @description: getExpelSize
  73. * @return {*}
  74. */
  75. int32_t getExpelSize();
  76. /**
  77. * @description: ~ExpelPlugin
  78. * @return {*}
  79. */
  80. ~ExpelPlugin(){
  81. InfoL;
  82. this->Destroy();
  83. }
  84. /**
  85. * @description: RestPlugin
  86. * @return {*}
  87. */
  88. virtual bool RestPlugin();
  89. protected:
  90. Socket::Ptr sockerUdp = nullptr;
  91. mutex m_mutex;
  92. bool m_DevPowerState = false;
  93. Timer::Ptr timer0 = nullptr;
  94. };
  95. } // namespace gsd
  96. #endif