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"
|
2022-07-14 02:48:35 -03:00
|
|
|
#include <AP_Rally/AP_Rally.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,
|
2022-02-01 20:46:06 -04:00
|
|
|
VER, // i.e. the "VER" message
|
2019-10-04 18:33:07 -03:00
|
|
|
SYSTEM_ID,
|
|
|
|
PARAM_SPACE_USED,
|
2022-10-17 09:53:20 -03:00
|
|
|
RC_PROTOCOL,
|
|
|
|
RC_OUTPUT,
|
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:
|
2022-08-08 16:45:14 -03:00
|
|
|
enum class Stage {
|
2019-10-04 18:33:07 -03:00
|
|
|
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:
|
2022-08-08 16:45:14 -03:00
|
|
|
enum class Stage {
|
2019-10-04 18:33:07 -03:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2021-11-13 09:58:48 -04:00
|
|
|
#if HAL_LOGGER_FENCE_ENABLED
|
|
|
|
class LoggerMessageWriter_Write_Polyfence : public LoggerMessageWriter {
|
|
|
|
public:
|
|
|
|
|
|
|
|
void reset() override;
|
|
|
|
void process() override;
|
|
|
|
|
|
|
|
private:
|
2022-08-08 16:45:14 -03:00
|
|
|
enum class Stage {
|
2021-11-13 09:58:48 -04:00
|
|
|
WRITE_NEW_FENCE_MESSAGE = 0,
|
|
|
|
WRITE_FENCE_ITEMS,
|
|
|
|
DONE
|
|
|
|
};
|
|
|
|
|
|
|
|
uint16_t _fence_number_to_send;
|
|
|
|
Stage stage;
|
|
|
|
};
|
|
|
|
#endif // HAL_LOGGER_FENCE_ENABLED
|
|
|
|
|
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()
|
2022-08-14 20:08:16 -03:00
|
|
|
#if AP_MISSION_ENABLED
|
2021-05-19 23:34:13 -03:00
|
|
|
, _writeentiremission()
|
|
|
|
#endif
|
|
|
|
#if HAL_RALLY_ENABLED
|
|
|
|
, _writeallrallypoints()
|
2021-11-13 09:58:48 -04:00
|
|
|
#endif
|
|
|
|
#if HAL_LOGGER_FENCE_ENABLED
|
|
|
|
, _writeallpolyfence()
|
2021-05-19 23:34:13 -03:00
|
|
|
#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);
|
2022-08-14 20:08:16 -03:00
|
|
|
#if AP_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-11-13 09:58:48 -04:00
|
|
|
#endif
|
|
|
|
#if HAL_LOGGER_FENCE_ENABLED
|
|
|
|
_writeallpolyfence.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!
|
2022-08-14 20:08:16 -03:00
|
|
|
#if AP_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
|
2021-11-13 09:58:48 -04:00
|
|
|
#if HAL_LOGGER_FENCE_ENABLED
|
|
|
|
bool writeallfence();
|
|
|
|
#endif
|
2020-04-13 01:20:30 -03:00
|
|
|
|
2015-08-06 09:18:28 -03:00
|
|
|
private:
|
|
|
|
|
2022-12-03 18:55:23 -04:00
|
|
|
// check for using too much time
|
|
|
|
static bool check_process_limit(uint32_t start_us);
|
|
|
|
|
2022-08-08 16:45:14 -03:00
|
|
|
enum class Stage {
|
2019-10-04 18:33:07 -03:00
|
|
|
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;
|
2022-06-13 16:02:15 -03:00
|
|
|
float param_default;
|
2015-08-06 09:18:28 -03:00
|
|
|
enum ap_var_type type;
|
|
|
|
|
|
|
|
|
2019-01-18 00:23:42 -04:00
|
|
|
LoggerMessageWriter_WriteSysInfo _writesysinfo;
|
2022-08-14 20:08:16 -03:00
|
|
|
#if AP_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
|
2021-11-13 09:58:48 -04:00
|
|
|
#if HAL_LOGGER_FENCE_ENABLED
|
|
|
|
LoggerMessageWriter_Write_Polyfence _writeallpolyfence;
|
|
|
|
#endif
|
2015-08-06 09:18:28 -03:00
|
|
|
};
|