mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-21 23:33:57 -04:00
AP_ADSB: create frontend/backend split
This commit is contained in:
parent
fd9068de8a
commit
f784fc7c5c
@ -23,6 +23,7 @@
|
||||
#include "AP_ADSB.h"
|
||||
|
||||
#if HAL_ADSB_ENABLED
|
||||
#include "AP_ADSB_uAvionix_MAVLink.h"
|
||||
#include <GCS_MAVLink/GCS_MAVLink.h>
|
||||
#include <stdio.h> // for sprintf
|
||||
#include <limits.h>
|
||||
@ -203,6 +204,16 @@ void AP_ADSB::init(void)
|
||||
}
|
||||
in_state.list_size_allocated = in_state.list_size_param;
|
||||
}
|
||||
|
||||
if (_backend == nullptr) {
|
||||
_backend = new AP_ADSB_uAvionix_MAVLink(*this);
|
||||
|
||||
if (_backend == nullptr) {
|
||||
_init_failed = true;
|
||||
gcs().send_text(MAV_SEVERITY_CRITICAL, "ADSB: Unable to initialize ADSB driver");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -34,8 +34,13 @@
|
||||
#include <AP_Common/Location.h>
|
||||
#include <GCS_MAVLink/GCS_MAVLink.h>
|
||||
|
||||
class AP_ADSB_Backend;
|
||||
|
||||
class AP_ADSB {
|
||||
public:
|
||||
friend class AP_ADSB_Backend;
|
||||
friend class AP_ADSB_uAvionix_MAVLink;
|
||||
|
||||
// constructor
|
||||
AP_ADSB();
|
||||
|
||||
@ -235,6 +240,8 @@ private:
|
||||
|
||||
void update_uavionix();
|
||||
|
||||
// reference to backend
|
||||
AP_ADSB_Backend *_backend;
|
||||
};
|
||||
|
||||
namespace AP {
|
||||
|
29
libraries/AP_ADSB/AP_ADSB_Backend.cpp
Normal file
29
libraries/AP_ADSB/AP_ADSB_Backend.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "AP_ADSB_Backend.h"
|
||||
|
||||
#if HAL_ADSB_ENABLED
|
||||
|
||||
/*
|
||||
base class constructor.
|
||||
*/
|
||||
AP_ADSB_Backend::AP_ADSB_Backend(AP_ADSB &frontend) :
|
||||
_frontend(frontend)
|
||||
{
|
||||
}
|
||||
|
||||
#endif // HAL_ADSB_ENABLED
|
||||
|
36
libraries/AP_ADSB/AP_ADSB_Backend.h
Normal file
36
libraries/AP_ADSB/AP_ADSB_Backend.h
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "AP_ADSB.h"
|
||||
|
||||
#if HAL_ADSB_ENABLED
|
||||
class AP_ADSB_Backend
|
||||
{
|
||||
public:
|
||||
// constructor.
|
||||
AP_ADSB_Backend(AP_ADSB &frontend);
|
||||
|
||||
|
||||
virtual void update() = 0;
|
||||
protected:
|
||||
|
||||
// references
|
||||
AP_ADSB &_frontend;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
#endif // HAL_ADSB_ENABLED
|
27
libraries/AP_ADSB/AP_ADSB_uAvionix_MAVLink.cpp
Normal file
27
libraries/AP_ADSB/AP_ADSB_uAvionix_MAVLink.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "AP_ADSB_uAvionix_MAVLink.h"
|
||||
|
||||
#if HAL_ADSB_ENABLED
|
||||
|
||||
extern const AP_HAL::HAL& hal;
|
||||
|
||||
void AP_ADSB_uAvionix_MAVLink::update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif // HAL_ADSB_ENABLED
|
31
libraries/AP_ADSB/AP_ADSB_uAvionix_MAVLink.h
Normal file
31
libraries/AP_ADSB/AP_ADSB_uAvionix_MAVLink.h
Normal file
@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "AP_ADSB_Backend.h"
|
||||
|
||||
#if HAL_ADSB_ENABLED
|
||||
class AP_ADSB_uAvionix_MAVLink : public AP_ADSB_Backend {
|
||||
public:
|
||||
using AP_ADSB_Backend::AP_ADSB_Backend;
|
||||
|
||||
void update() override;
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
#endif // HAL_ADSB_ENABLED
|
||||
|
Loading…
Reference in New Issue
Block a user