out_sim.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #pragma once
  2. #include <thread>
  3. #include <mutex>
  4. #include <functional>
  5. #include <condition_variable>
  6. #include "../common/comm.h"
  7. #include "../common/notifier.h"
  8. class CIOBuffer;
  9. #pragma pack(1)
  10. struct OutSimPack
  11. {
  12. /*
  13. unsigned int time;
  14. float AVelocityX;
  15. float AVelocityY;
  16. float AVelocitZ;
  17. float yaw;
  18. float pitch;
  19. float roll;
  20. float accX;
  21. float accY;
  22. float accZ;
  23. float velX;
  24. float vely;
  25. float velz;
  26. int posx;
  27. int posy;
  28. int posz;
  29. */
  30. int8_t start1 = 0x55;
  31. int8_t start2 = 0xaa;
  32. int8_t start3 = 0xbb;
  33. int8_t cmd =6;
  34. float tx=0;
  35. float ty=0;
  36. float tz=0;
  37. float rx=0;
  38. float ry=0;
  39. float rz=0;
  40. float var1=0;
  41. float var2=0;
  42. float var3=0;
  43. float var4=0;
  44. float var5=0;
  45. float var6=0;
  46. int time=50;
  47. };
  48. #pragma pack()
  49. class CEgoClient;
  50. class COutSim
  51. {
  52. public:
  53. COutSim(CEgoClient* c,const char * ip,int32_t port);
  54. void Start();
  55. void Stop();
  56. void PushSimPack(CIOBuffer* pBuffer);
  57. //´¦ÀíCHANNEL_IMUͨµÀµÄÊý¾Ý
  58. void OnPeerMessage(int16_t cmd, int16_t length, const void* data);
  59. private:
  60. void Run();
  61. bool SendOutSim(CIOBuffer* pBuffer);
  62. private:
  63. SOCKET _socket;
  64. std::thread _thread;
  65. bool _run;
  66. std::mutex Mtx;
  67. std::condition_variable cv;
  68. CIOBuffer* _head;
  69. std::string _ip;
  70. int32_t _port;
  71. CEgoClient* _client;
  72. };