2016-02-17 21:25:53 -04:00
|
|
|
#pragma once
|
2015-08-06 09:18:28 -03:00
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
#include "AP_Logger_Backend.h"
|
2015-08-06 09:18:28 -03:00
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
class LoggerMessageWriter {
|
2015-08-06 09:18:28 -03:00
|
|
|
public:
|
|
|
|
|
|
|
|
virtual void reset() = 0;
|
|
|
|
virtual void process() = 0;
|
2016-07-01 02:35:45 -03:00
|
|
|
virtual bool finished() { return _finished; }
|
2015-08-06 09:18:28 -03:00
|
|
|
|
2019-02-11 04:38:01 -04:00
|
|
|
virtual void set_logger_backend(class AP_Logger_Backend *backend) {
|
|
|
|
_logger_backend = backend;
|
2015-11-09 18:14:22 -04:00
|
|
|
}
|
|
|
|
|
2020-11-05 19:28:26 -04:00
|
|
|
bool out_of_time_for_writing_messages() const;
|
|
|
|
|
2015-08-06 09:18:28 -03:00
|
|
|
protected:
|
2015-09-17 07:28:50 -03:00
|
|
|
bool _finished = false;
|
2019-02-11 04:38:01 -04:00
|
|
|
AP_Logger_Backend *_logger_backend = nullptr;
|
2015-08-06 09:18:28 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
class LoggerMessageWriter_WriteSysInfo : public LoggerMessageWriter {
|
2015-08-06 09:18:28 -03:00
|
|
|
public:
|
|
|
|
|
2018-11-07 07:26:49 -04:00
|
|
|
void reset() override;
|
|
|
|
void process() override;
|
2015-08-06 09:18:28 -03:00
|
|
|
|
|
|
|
private:
|
2019-10-04 18:33:07 -03:00
|
|
|
enum class Stage : uint8_t {
|
2020-04-12 23:26:12 -03:00
|
|
|
FIRMWARE_STRING = 0,
|
2019-10-04 18:33:07 -03:00
|
|
|
GIT_VERSIONS,
|
|
|
|
SYSTEM_ID,
|
|
|
|
PARAM_SPACE_USED,
|
|
|
|
RC_PROTOCOL
|
2015-08-06 09:18:28 -03:00
|
|
|
};
|
2019-10-04 18:33:07 -03:00
|
|
|
Stage stage;
|
2015-08-06 09:18:28 -03:00
|
|
|
};
|
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
class LoggerMessageWriter_WriteEntireMission : public LoggerMessageWriter {
|
2015-08-06 09:18:28 -03:00
|
|
|
public:
|
2015-11-09 18:14:22 -04:00
|
|
|
|
2018-11-07 07:26:49 -04:00
|
|
|
void reset() override;
|
|
|
|
void process() override;
|
2015-08-06 09:18:28 -03:00
|
|
|
|
|
|
|
private:
|
2019-10-04 18:33:07 -03:00
|
|
|
enum Stage {
|
|
|
|
WRITE_NEW_MISSION_MESSAGE = 0,
|
|
|
|
WRITE_MISSION_ITEMS,
|
|
|
|
DONE
|
2015-08-06 09:18:28 -03:00
|
|
|
};
|
|
|
|
|
2019-02-22 18:46:59 -04:00
|
|
|
uint16_t _mission_number_to_send;
|
2019-10-04 18:33:07 -03:00
|
|
|
Stage stage;
|
2015-08-06 09:18:28 -03:00
|
|
|
};
|
|
|
|
|
2018-12-29 00:01:46 -04:00
|
|
|
class LoggerMessageWriter_WriteAllRallyPoints : public LoggerMessageWriter {
|
|
|
|
public:
|
|
|
|
|
|
|
|
void reset() override;
|
|
|
|
void process() override;
|
|
|
|
|
|
|
|
private:
|
2019-10-04 18:33:07 -03:00
|
|
|
enum Stage {
|
|
|
|
WRITE_NEW_RALLY_MESSAGE = 0,
|
|
|
|
WRITE_ALL_RALLY_POINTS,
|
|
|
|
DONE
|
2018-12-29 00:01:46 -04:00
|
|
|
};
|
|
|
|
|
2019-02-22 18:46:59 -04:00
|
|
|
uint16_t _rally_number_to_send;
|
2019-10-04 18:33:07 -03:00
|
|
|
Stage stage = Stage::WRITE_NEW_RALLY_MESSAGE;
|
2018-12-29 00:01:46 -04:00
|
|
|
};
|
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
class LoggerMessageWriter_DFLogStart : public LoggerMessageWriter {
|
2015-08-06 09:18:28 -03:00
|
|
|
public:
|
2019-01-18 00:23:42 -04:00
|
|
|
LoggerMessageWriter_DFLogStart() :
|
2021-05-19 23:34:13 -03:00
|
|
|
_writesysinfo()
|
|
|
|
#if HAL_MISSION_ENABLED
|
|
|
|
, _writeentiremission()
|
|
|
|
#endif
|
|
|
|
#if HAL_RALLY_ENABLED
|
|
|
|
, _writeallrallypoints()
|
|
|
|
#endif
|
2015-08-06 09:18:28 -03:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-02-11 04:38:01 -04:00
|
|
|
virtual void set_logger_backend(class AP_Logger_Backend *backend) override {
|
|
|
|
LoggerMessageWriter::set_logger_backend(backend);
|
|
|
|
_writesysinfo.set_logger_backend(backend);
|
2021-05-19 23:34:13 -03:00
|
|
|
#if HAL_MISSION_ENABLED
|
2019-02-11 04:38:01 -04:00
|
|
|
_writeentiremission.set_logger_backend(backend);
|
2021-05-19 23:34:13 -03:00
|
|
|
#endif
|
|
|
|
#if HAL_RALLY_ENABLED
|
2019-02-11 04:38:01 -04:00
|
|
|
_writeallrallypoints.set_logger_backend(backend);
|
2021-05-19 23:34:13 -03:00
|
|
|
#endif
|
2015-11-09 18:14:22 -04:00
|
|
|
}
|
|
|
|
|
2020-11-05 19:28:26 -04:00
|
|
|
bool out_of_time_for_writing_messages() const;
|
|
|
|
|
2018-11-07 07:26:49 -04:00
|
|
|
void reset() override;
|
|
|
|
void process() override;
|
2021-02-01 12:26:29 -04:00
|
|
|
bool fmt_done() const { return _fmt_done; }
|
|
|
|
bool params_done() const { return _params_done; }
|
2015-08-06 09:18:28 -03:00
|
|
|
|
2020-04-13 01:20:30 -03:00
|
|
|
// reset some writers so we push stuff out to logs again. Will
|
|
|
|
// only work if we are in state DONE!
|
2021-05-19 23:34:13 -03:00
|
|
|
#if HAL_MISSION_ENABLED
|
2020-04-13 01:20:30 -03:00
|
|
|
bool writeentiremission();
|
2021-05-19 23:34:13 -03:00
|
|
|
#endif
|
|
|
|
#if HAL_RALLY_ENABLED
|
2020-04-13 01:20:30 -03:00
|
|
|
bool writeallrallypoints();
|
2021-05-19 23:34:13 -03:00
|
|
|
#endif
|
2020-04-13 01:20:30 -03:00
|
|
|
|
2015-08-06 09:18:28 -03:00
|
|
|
private:
|
|
|
|
|
2019-10-04 18:33:07 -03:00
|
|
|
enum Stage {
|
|
|
|
FORMATS = 0,
|
|
|
|
UNITS,
|
|
|
|
MULTIPLIERS,
|
|
|
|
FORMAT_UNITS,
|
|
|
|
PARMS,
|
|
|
|
VEHICLE_MESSAGES,
|
2020-04-13 01:20:30 -03:00
|
|
|
RUNNING_SUBWRITERS, // must be last thing to run as we can redo bits of these
|
2019-10-04 18:33:07 -03:00
|
|
|
DONE,
|
2015-08-06 09:18:28 -03:00
|
|
|
};
|
|
|
|
|
2019-02-22 18:46:59 -04:00
|
|
|
bool _fmt_done;
|
2020-11-05 19:28:26 -04:00
|
|
|
bool _params_done;
|
2015-09-17 07:28:50 -03:00
|
|
|
|
2019-10-04 18:33:07 -03:00
|
|
|
Stage stage;
|
2015-08-06 09:18:28 -03:00
|
|
|
|
|
|
|
uint16_t next_format_to_send;
|
2015-12-07 20:51:46 -04:00
|
|
|
|
|
|
|
uint8_t _next_unit_to_send;
|
|
|
|
uint8_t _next_format_unit_to_send;
|
|
|
|
uint8_t _next_multiplier_to_send;
|
|
|
|
|
2015-08-06 09:18:28 -03:00
|
|
|
AP_Param::ParamToken token;
|
|
|
|
AP_Param *ap;
|
|
|
|
enum ap_var_type type;
|
|
|
|
|
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
LoggerMessageWriter_WriteSysInfo _writesysinfo;
|
2021-05-19 23:34:13 -03:00
|
|
|
#if HAL_MISSION_ENABLED
|
2019-01-18 00:23:42 -04:00
|
|
|
LoggerMessageWriter_WriteEntireMission _writeentiremission;
|
2021-05-19 23:34:13 -03:00
|
|
|
#endif
|
|
|
|
#if HAL_RALLY_ENABLED
|
2018-12-29 00:01:46 -04:00
|
|
|
LoggerMessageWriter_WriteAllRallyPoints _writeallrallypoints;
|
2021-05-19 23:34:13 -03:00
|
|
|
#endif
|
2015-08-06 09:18:28 -03:00
|
|
|
};
|