control_sensor.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #pragma once
  2. #include "../common/comm.h"
  3. #include "../common/notifier.h"
  4. #include "../common/sensor_socket.h"
  5. #include <thread>
  6. #include <mutex>
  7. class CEgoWindow;
  8. class CMessageQueue;
  9. enum Sensor_Collection
  10. {
  11. Sensor_None = 0x0,
  12. Sensor_ER = 0x1, //0x181
  13. Sensor_Steer = 0x2, //0x185
  14. Sensor_Signal = 0x4, //0x281
  15. Sensor_Drive = 0x8, //0x381
  16. Sensor_Arm =0x10 ,//0x481
  17. //Sensor_Switch=0x20,
  18. Sensor_All = 0x1F
  19. };
  20. enum OpSide
  21. {
  22. Empty,
  23. Arm,
  24. Bucket
  25. };
  26. class CControlSensor
  27. {
  28. public:
  29. CControlSensor(CMessageQueue * window);
  30. bool Start();
  31. void Stop();
  32. void Notify(TPCANMsg& canmsg,uint64_t timestamp);
  33. void SetEngineRPM(int32_t rpm);
  34. ControlStatus CheckStatus();
  35. private:
  36. void Run();
  37. TPCANStatus ReadMessage();
  38. //TPCANStatus ReadMessageFD();
  39. void ReadMessages();
  40. private:
  41. CEgoWindow* _window;
  42. Sensor_Collection _collection;
  43. TPCANHandle _handle=-1;
  44. bool _isFD;
  45. std::thread _thread;
  46. bool _run;
  47. int16_t _last_speed = 0xF000;
  48. int64_t _startup = 0;
  49. int32_t _rpm = 0;
  50. //bool _automous = false;
  51. /*
  52. bool _er_enabling = false;
  53. bool _er_motoring = false;
  54. bool _er_gear = false;
  55. bool _er_turnl = false;
  56. bool _er_turnr = false;
  57. bool _F1 = false;
  58. bool _F2 = false;
  59. bool _F3 = false;
  60. bool _F4 = false;
  61. bool _R1 = false;
  62. bool _R2 = false;
  63. bool _R3 = false;
  64. bool _R4 = false;
  65. bool _N1 = false;
  66. bool _N2 = false;
  67. bool _N3 = false;
  68. bool _N4 = false;
  69. bool _keycc = false;
  70. bool _keyC = false;
  71. bool _keyR = false;
  72. bool _switchF = false;
  73. bool _switchR = false;
  74. bool _startup=false;
  75. bool _horn = false; //喇叭
  76. bool _emergeny=false; //急停
  77. bool _colddown = false; //冷却
  78. bool _firewarning = false;
  79. bool _hyp = false; //液压使能
  80. bool _flight = false;
  81. bool _blight = false;
  82. bool _beamlight = false;
  83. bool _nearlight = false;
  84. bool _smalllight = false;
  85. bool _leftturn = false;
  86. bool _rightturn = false;
  87. bool _louver_open = false;
  88. bool _louver_close = false;
  89. bool _lock_on_off = false; //锁销
  90. bool _jar_on_off = false; //敲罐
  91. bool _park_lift = false;
  92. bool _chain_lift = false;
  93. bool _enabling = false;
  94. bool _emergency = false;
  95. bool _resume=false;
  96. int16_t _gear = 1;
  97. int16_t _accel = 0;
  98. int16_t _steer = 0;
  99. int16_t _flip = 0;
  100. int16_t _armL = 0;
  101. int16_t _armR = 0;
  102. */
  103. cannet_frame frames[6];
  104. int32_t _old_steer = 0;
  105. uint64_t _old_timestamp = 0;
  106. bool isFront = false;
  107. bool isSliping = false;
  108. bool _remote_active = false;
  109. uint64_t _active_tick = 0;
  110. };