event_log.h 560 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #include <thread>
  3. #include <fstream>
  4. #include <string>
  5. #include <mutex>
  6. enum EventType
  7. {
  8. NORMAL,
  9. OFFLINE,
  10. EMERGENCY,
  11. LOW_RPM,
  12. };
  13. class CEventLog
  14. {
  15. public:
  16. void Start();
  17. void Stop();
  18. void SetEvent( EventType type,int32_t steer,int32_t accel,int32_t brake);
  19. private:
  20. void Run();
  21. std::string GetLocalTime();
  22. EventType _type=EventType::NORMAL;
  23. int32_t _steer=0;
  24. int32_t _accel=0;
  25. int32_t _brake=0;
  26. bool _run;
  27. std::mutex _mutex;
  28. std::thread _thread;
  29. std::ofstream _ofile;
  30. };