mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-22 07:44:03 -04:00
AP_AIS: add singleton
This commit is contained in:
parent
6b06e2eb9b
commit
b94e1c5027
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "AP_AIS.h"
|
#include "AP_AIS.h"
|
||||||
|
|
||||||
#if HAL_AIS_ENABLED
|
#if AP_AIS_ENABLED
|
||||||
|
|
||||||
#include <AP_Logger/AP_Logger.h>
|
#include <AP_Logger/AP_Logger.h>
|
||||||
#include <GCS_MAVLink/GCS_MAVLink.h>
|
#include <GCS_MAVLink/GCS_MAVLink.h>
|
||||||
@ -63,6 +63,11 @@ const AP_Param::GroupInfo AP_AIS::var_info[] = {
|
|||||||
// constructor
|
// constructor
|
||||||
AP_AIS::AP_AIS()
|
AP_AIS::AP_AIS()
|
||||||
{
|
{
|
||||||
|
if (_singleton != nullptr) {
|
||||||
|
AP_HAL::panic("AIS must be singleton");
|
||||||
|
}
|
||||||
|
_singleton = this;
|
||||||
|
|
||||||
AP_Param::setup_object_defaults(this, var_info);
|
AP_Param::setup_object_defaults(this, var_info);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -804,4 +809,6 @@ bool AP_AIS::decode_latest_term()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAL_AIS_ENABLED
|
AP_AIS *AP_AIS::_singleton;
|
||||||
|
|
||||||
|
#endif // AP_AIS_ENABLED
|
||||||
|
@ -14,16 +14,18 @@
|
|||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AP_HAL/AP_HAL_Boards.h>
|
||||||
|
|
||||||
|
#ifndef AP_AIS_ENABLED
|
||||||
|
#define AP_AIS_ENABLED !HAL_MINIMIZE_FEATURES
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if AP_AIS_ENABLED
|
||||||
|
|
||||||
#include <AP_Param/AP_Param.h>
|
#include <AP_Param/AP_Param.h>
|
||||||
#include <AP_SerialManager/AP_SerialManager.h>
|
#include <AP_SerialManager/AP_SerialManager.h>
|
||||||
#include <AP_Common/AP_ExpandingArray.h>
|
#include <AP_Common/AP_ExpandingArray.h>
|
||||||
|
|
||||||
#ifndef HAL_AIS_ENABLED
|
|
||||||
#define HAL_AIS_ENABLED !HAL_MINIMIZE_FEATURES
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if HAL_AIS_ENABLED
|
|
||||||
|
|
||||||
#define AIVDM_BUFFER_SIZE 10
|
#define AIVDM_BUFFER_SIZE 10
|
||||||
#define AIVDM_PAYLOAD_SIZE 65
|
#define AIVDM_PAYLOAD_SIZE 65
|
||||||
|
|
||||||
@ -36,6 +38,11 @@ public:
|
|||||||
AP_AIS(const AP_AIS &other) = delete;
|
AP_AIS(const AP_AIS &other) = delete;
|
||||||
AP_AIS &operator=(const AP_AIS&) = delete;
|
AP_AIS &operator=(const AP_AIS&) = delete;
|
||||||
|
|
||||||
|
// get singleton instance
|
||||||
|
static AP_AIS *get_singleton() {
|
||||||
|
return _singleton;
|
||||||
|
}
|
||||||
|
|
||||||
// return true if AIS is enabled
|
// return true if AIS is enabled
|
||||||
bool enabled() const { return AISType(_type.get()) != AISType::NONE; }
|
bool enabled() const { return AISType(_type.get()) != AISType::NONE; }
|
||||||
|
|
||||||
@ -131,6 +138,8 @@ private:
|
|||||||
bool _term_is_checksum; // current term is the checksum
|
bool _term_is_checksum; // current term is the checksum
|
||||||
bool _sentence_valid; // is current sentence valid so far
|
bool _sentence_valid; // is current sentence valid so far
|
||||||
bool _sentence_done; // true if this sentence has already been decoded
|
bool _sentence_done; // true if this sentence has already been decoded
|
||||||
|
|
||||||
|
static AP_AIS *_singleton;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HAL_AIS_ENABLED
|
#endif // AP_AIS_ENABLED
|
||||||
|
Loading…
Reference in New Issue
Block a user