LoggerMessageWriter.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #pragma once
  2. #include "AP_Logger_Backend.h"
  3. class LoggerMessageWriter {
  4. public:
  5. virtual void reset() = 0;
  6. virtual void process() = 0;
  7. virtual bool finished() { return _finished; }
  8. virtual void set_logger_backend(class AP_Logger_Backend *backend) {
  9. _logger_backend = backend;
  10. }
  11. protected:
  12. bool _finished = false;
  13. AP_Logger_Backend *_logger_backend = nullptr;
  14. };
  15. class LoggerMessageWriter_WriteSysInfo : public LoggerMessageWriter {
  16. public:
  17. void reset() override;
  18. void process() override;
  19. private:
  20. enum write_sysinfo_blockwriter_stage : uint8_t {
  21. ws_blockwriter_stage_formats = 0,
  22. ws_blockwriter_stage_firmware_string,
  23. ws_blockwriter_stage_git_versions,
  24. ws_blockwriter_stage_system_id,
  25. ws_blockwriter_stage_param_space_used,
  26. ws_blockwriter_stage_rc_protocol
  27. };
  28. write_sysinfo_blockwriter_stage stage;
  29. };
  30. class LoggerMessageWriter_WriteEntireMission : public LoggerMessageWriter {
  31. public:
  32. void reset() override;
  33. void process() override;
  34. private:
  35. enum entire_mission_blockwriter_stage {
  36. em_blockwriter_stage_write_new_mission_message = 0,
  37. em_blockwriter_stage_write_mission_items,
  38. em_blockwriter_stage_done
  39. };
  40. uint16_t _mission_number_to_send;
  41. entire_mission_blockwriter_stage stage;
  42. };
  43. class LoggerMessageWriter_WriteAllRallyPoints : public LoggerMessageWriter {
  44. public:
  45. void reset() override;
  46. void process() override;
  47. private:
  48. enum all_rally_points_blockwriter_stage {
  49. ar_blockwriter_stage_write_new_rally_message = 0,
  50. ar_blockwriter_stage_write_all_rally_points,
  51. ar_blockwriter_stage_done
  52. };
  53. uint16_t _rally_number_to_send;
  54. all_rally_points_blockwriter_stage stage;
  55. };
  56. class LoggerMessageWriter_DFLogStart : public LoggerMessageWriter {
  57. public:
  58. LoggerMessageWriter_DFLogStart() :
  59. _writesysinfo(),
  60. _writeentiremission(),
  61. _writeallrallypoints()
  62. {
  63. }
  64. virtual void set_logger_backend(class AP_Logger_Backend *backend) override {
  65. LoggerMessageWriter::set_logger_backend(backend);
  66. _writesysinfo.set_logger_backend(backend);
  67. _writeentiremission.set_logger_backend(backend);
  68. _writeallrallypoints.set_logger_backend(backend);
  69. }
  70. void reset() override;
  71. void process() override;
  72. bool fmt_done() { return _fmt_done; }
  73. private:
  74. enum log_start_blockwriter_stage {
  75. ls_blockwriter_stage_formats = 0,
  76. ls_blockwriter_stage_units,
  77. ls_blockwriter_stage_multipliers,
  78. ls_blockwriter_stage_format_units,
  79. ls_blockwriter_stage_parms,
  80. ls_blockwriter_stage_sysinfo,
  81. ls_blockwriter_stage_write_entire_mission,
  82. ls_blockwriter_stage_write_all_rally_points,
  83. ls_blockwriter_stage_vehicle_messages,
  84. ls_blockwriter_stage_done,
  85. };
  86. bool _fmt_done;
  87. log_start_blockwriter_stage stage;
  88. uint16_t next_format_to_send;
  89. uint8_t _next_unit_to_send;
  90. uint8_t _next_format_unit_to_send;
  91. uint8_t _next_multiplier_to_send;
  92. AP_Param::ParamToken token;
  93. AP_Param *ap;
  94. enum ap_var_type type;
  95. LoggerMessageWriter_WriteSysInfo _writesysinfo;
  96. LoggerMessageWriter_WriteEntireMission _writeentiremission;
  97. LoggerMessageWriter_WriteAllRallyPoints _writeallrallypoints;
  98. };