Plane: allow AP_Stats to be optional

This commit is contained in:
night-ghost 2018-02-28 17:22:16 +05:00 committed by Andrew Tridgell
parent adcc309f15
commit 98b8a61ca8
6 changed files with 16 additions and 2 deletions

View File

@ -83,12 +83,15 @@ const AP_Scheduler::Task Plane::scheduler_tasks[] = {
SCHED_TASK(ins_periodic, 50, 50), SCHED_TASK(ins_periodic, 50, 50),
SCHED_TASK(avoidance_adsb_update, 10, 100), SCHED_TASK(avoidance_adsb_update, 10, 100),
SCHED_TASK(button_update, 5, 100), SCHED_TASK(button_update, 5, 100),
#if STATS_ENABLED == ENABLED
SCHED_TASK(stats_update, 1, 100), SCHED_TASK(stats_update, 1, 100),
#endif
#if GRIPPER_ENABLED == ENABLED #if GRIPPER_ENABLED == ENABLED
SCHED_TASK_CLASS(AP_Gripper, &plane.g2.gripper, update, 10, 75), SCHED_TASK_CLASS(AP_Gripper, &plane.g2.gripper, update, 10, 75),
#endif #endif
}; };
#if STATS_ENABLED == ENABLED
/* /*
update AP_Stats update AP_Stats
*/ */
@ -96,7 +99,7 @@ void Plane::stats_update(void)
{ {
g2.stats.update(); g2.stats.update();
} }
#endif
void Plane::setup() void Plane::setup()
{ {

View File

@ -1144,10 +1144,11 @@ const AP_Param::GroupInfo ParametersG2::var_info[] = {
// @Values: 0:NotEnforced,1:Enforced // @Values: 0:NotEnforced,1:Enforced
// @User: Advanced // @User: Advanced
AP_GROUPINFO("SYSID_ENFORCE", 4, ParametersG2, sysid_enforce, 0), AP_GROUPINFO("SYSID_ENFORCE", 4, ParametersG2, sysid_enforce, 0),
#if STATS_ENABLED == ENABLED
// @Group: STAT // @Group: STAT
// @Path: ../libraries/AP_Stats/AP_Stats.cpp // @Path: ../libraries/AP_Stats/AP_Stats.cpp
AP_SUBGROUPINFO(stats, "STAT", 5, ParametersG2, AP_Stats), AP_SUBGROUPINFO(stats, "STAT", 5, ParametersG2, AP_Stats),
#endif
// @Group: SERVO // @Group: SERVO
// @Path: ../libraries/SRV_Channel/SRV_Channels.cpp // @Path: ../libraries/SRV_Channel/SRV_Channels.cpp

View File

@ -518,8 +518,10 @@ public:
// button reporting library // button reporting library
AP_Button button; AP_Button button;
#if STATS_ENABLED == ENABLED
// vehicle statistics // vehicle statistics
AP_Stats stats; AP_Stats stats;
#endif
// internal combustion engine control // internal combustion engine control
AP_ICEngine ice_control; AP_ICEngine ice_control;

View File

@ -355,3 +355,7 @@
#else #else
# define HAVE_PX4_MIXER 0 # define HAVE_PX4_MIXER 0
#endif #endif
#ifndef STATS_ENABLED
# define STATS_ENABLED ENABLED
#endif

View File

@ -150,7 +150,9 @@ void Plane::update_is_flying_5Hz(void)
#if FRSKY_TELEM_ENABLED == ENABLED #if FRSKY_TELEM_ENABLED == ENABLED
frsky_telemetry.set_is_flying(new_is_flying); frsky_telemetry.set_is_flying(new_is_flying);
#endif #endif
#if STATS_ENABLED == ENABLED
g2.stats.set_flying(new_is_flying); g2.stats.set_flying(new_is_flying);
#endif
crash_detection_update(); crash_detection_update();

View File

@ -33,8 +33,10 @@ void Plane::init_ardupilot()
// //
load_parameters(); load_parameters();
#if STATS_ENABLED == ENABLED
// initialise stats module // initialise stats module
g2.stats.init(); g2.stats.init();
#endif
#if HIL_SUPPORT #if HIL_SUPPORT
if (g.hil_mode == 1) { if (g.hil_mode == 1) {