mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-03 06:28:27 -04:00
AP_Arming: add singleton
This commit is contained in:
parent
48ac028cd0
commit
d384827291
@ -115,6 +115,11 @@ extern AP_IOMCU iomcu;
|
||||
|
||||
AP_Arming::AP_Arming()
|
||||
{
|
||||
if (_singleton) {
|
||||
AP_HAL::panic("Too many AP_Arming instances");
|
||||
}
|
||||
_singleton = this;
|
||||
|
||||
AP_Param::setup_object_defaults(this, var_info);
|
||||
}
|
||||
|
||||
@ -894,3 +899,22 @@ bool AP_Arming::rc_checks_copter_sub(const bool display_failure, const RC_Channe
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
AP_Arming *AP_Arming::_singleton = nullptr;
|
||||
|
||||
/*
|
||||
* Get the AP_InertialSensor singleton
|
||||
*/
|
||||
AP_Arming *AP_Arming::get_singleton()
|
||||
{
|
||||
return AP_Arming::_singleton;
|
||||
}
|
||||
|
||||
namespace AP {
|
||||
|
||||
AP_Arming &arming()
|
||||
{
|
||||
return *AP_Arming::get_singleton();
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -14,6 +14,8 @@ public:
|
||||
AP_Arming(const AP_Arming &other) = delete;
|
||||
AP_Arming &operator=(const AP_Arming&) = delete;
|
||||
|
||||
static AP_Arming *get_singleton();
|
||||
|
||||
enum ArmingChecks {
|
||||
ARMING_CHECK_NONE = 0x0000,
|
||||
ARMING_CHECK_ALL = 0x0001,
|
||||
@ -133,6 +135,8 @@ protected:
|
||||
|
||||
private:
|
||||
|
||||
static AP_Arming *_singleton;
|
||||
|
||||
bool ins_accels_consistent(const AP_InertialSensor &ins);
|
||||
bool ins_gyros_consistent(const AP_InertialSensor &ins);
|
||||
|
||||
@ -146,3 +150,7 @@ private:
|
||||
MIS_ITEM_CHECK_MAX
|
||||
};
|
||||
};
|
||||
|
||||
namespace AP {
|
||||
AP_Arming &arming();
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user