123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #pragma once
- #include <AP_Common/AP_Common.h>
- #include <AP_Param/AP_Param.h>
- class AP_Stats
- {
- public:
-
- AP_Stats();
-
-
-
-
- uint32_t flttime;
- uint32_t runtime;
- uint32_t reset;
- uint32_t flttime_boot;
-
- void init();
-
- void flush();
-
-
- void update();
- void set_flying(bool b);
-
- bool get_is_flying(void) {
- return _flying_ms != 0;
- }
-
-
- uint32_t get_flight_time_s(void);
-
-
- static AP_Stats *get_singleton(void) {
- return _singleton;
- }
-
- static const struct AP_Param::GroupInfo var_info[];
- private:
- static AP_Stats *_singleton;
-
- struct {
- AP_Int16 bootcount;
- AP_Int32 flttime;
- AP_Int32 runtime;
- AP_Int32 reset;
- } params;
- void copy_variables_from_parameters();
- uint64_t last_flush_ms;
- const uint16_t flush_interval_ms = 30000;
- uint64_t _flying_ms;
- uint64_t _last_runtime_ms;
- void update_flighttime();
- void update_runtime();
- };
- namespace AP {
- AP_Stats *stats();
- };
|