From df190d1e86fcdd2dda6c3dcfd3f866c78d12c665 Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 27 May 2016 23:14:08 +1000 Subject: [PATCH] Tracker: subclass GCS_MAVLink in place of defining its functions for it --- AntennaTracker/GCS_Mavlink.cpp | 14 ++++++++------ AntennaTracker/GCS_Mavlink.h | 22 ++++++++++++++++++++++ AntennaTracker/Tracker.h | 7 +++---- 3 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 AntennaTracker/GCS_Mavlink.h diff --git a/AntennaTracker/GCS_Mavlink.cpp b/AntennaTracker/GCS_Mavlink.cpp index edc3329732..6938567f88 100644 --- a/AntennaTracker/GCS_Mavlink.cpp +++ b/AntennaTracker/GCS_Mavlink.cpp @@ -1,5 +1,7 @@ // -*- tab-width: 4; Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- +#include "GCS_Mavlink.h" + #include "Tracker.h" #include "version.h" @@ -150,19 +152,19 @@ void Tracker::send_simstate(mavlink_channel_t chan) #endif } -bool GCS_MAVLINK::handle_guided_request(AP_Mission::Mission_Command&) +bool GCS_MAVLINK_Tracker::handle_guided_request(AP_Mission::Mission_Command&) { // do nothing return false; } -void GCS_MAVLINK::handle_change_alt_request(AP_Mission::Mission_Command&) +void GCS_MAVLINK_Tracker::handle_change_alt_request(AP_Mission::Mission_Command&) { // do nothing } // try to send a message, return false if it won't fit in the serial tx buffer -bool GCS_MAVLINK::try_send_message(enum ap_message id) +bool GCS_MAVLINK_Tracker::try_send_message(enum ap_message id) { switch (id) { case MSG_HEARTBEAT: @@ -375,7 +377,7 @@ const AP_Param::GroupInfo GCS_MAVLINK::var_info[] = { AP_GROUPEND }; -float GCS_MAVLINK::adjust_rate_for_stream_trigger(enum streams stream_num) +float GCS_MAVLINK_Tracker::adjust_rate_for_stream_trigger(enum streams stream_num) { if (_queued_parameter != nullptr) { return 0.25f; @@ -385,7 +387,7 @@ float GCS_MAVLINK::adjust_rate_for_stream_trigger(enum streams stream_num) } void -GCS_MAVLINK::data_stream_send(void) +GCS_MAVLINK_Tracker::data_stream_send(void) { if (_queued_parameter != NULL) { if (streamRates[STREAM_PARAMS].get() <= 0) { @@ -535,7 +537,7 @@ void Tracker::mavlink_check_target(const mavlink_message_t* msg) target_set = true; } -void GCS_MAVLINK::handleMessage(mavlink_message_t* msg) +void GCS_MAVLINK_Tracker::handleMessage(mavlink_message_t* msg) { switch (msg->msgid) { diff --git a/AntennaTracker/GCS_Mavlink.h b/AntennaTracker/GCS_Mavlink.h new file mode 100644 index 0000000000..9343016dca --- /dev/null +++ b/AntennaTracker/GCS_Mavlink.h @@ -0,0 +1,22 @@ +#pragma once + +#include + +class GCS_MAVLINK_Tracker : public GCS_MAVLINK +{ + +public: + + void data_stream_send(void) override; + +protected: + +private: + + float adjust_rate_for_stream_trigger(enum streams stream_num) override; + void handleMessage(mavlink_message_t * msg) override; + bool handle_guided_request(AP_Mission::Mission_Command &cmd) override; + void handle_change_alt_request(AP_Mission::Mission_Command &cmd) override; + bool try_send_message(enum ap_message id) override; + +}; diff --git a/AntennaTracker/Tracker.h b/AntennaTracker/Tracker.h index 1462d22ce6..61bdc54a6b 100644 --- a/AntennaTracker/Tracker.h +++ b/AntennaTracker/Tracker.h @@ -43,7 +43,6 @@ #include // Filter library #include // APM FIFO Buffer -#include // MAVLink GCS definitions #include // Serial manager library #include // ArduPilot Mega Declination Helper Library #include @@ -69,7 +68,7 @@ #include "defines.h" #include "Parameters.h" -#include +#include "GCS_Mavlink.h" #if CONFIG_HAL_BOARD == HAL_BOARD_SITL #include @@ -77,7 +76,7 @@ class Tracker : public AP_HAL::HAL::Callbacks { public: - friend class GCS_MAVLINK; + friend class GCS_MAVLINK_Tracker; friend class Parameters; Tracker(void); @@ -135,7 +134,7 @@ private: AP_SerialManager serial_manager; const uint8_t num_gcs = MAVLINK_COMM_NUM_BUFFERS; - GCS_MAVLINK gcs[MAVLINK_COMM_NUM_BUFFERS]; + GCS_MAVLINK_Tracker gcs[MAVLINK_COMM_NUM_BUFFERS]; AP_BoardConfig BoardConfig;