mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-28 10:46:33 +08:00
refactor(modeCheck): inline checkArmingRequirement() function
This commit is contained in:
@@ -36,7 +36,15 @@
|
|||||||
void ModeChecks::checkAndReport(const Context &context, Report &reporter)
|
void ModeChecks::checkAndReport(const Context &context, Report &reporter)
|
||||||
{
|
{
|
||||||
if (!context.isArmed()) {
|
if (!context.isArmed()) {
|
||||||
checkArmingRequirement(context, reporter);
|
if (reporter.failsafeFlags().mode_req_prevent_arming & (1u << context.status().nav_state)) {
|
||||||
|
/* EVENT
|
||||||
|
* @description
|
||||||
|
* Switch to another mode first.
|
||||||
|
*/
|
||||||
|
reporter.armingCheckFailure((NavModes)reporter.failsafeFlags().mode_req_prevent_arming, health_component_t::system,
|
||||||
|
events::ID("check_modes_cannot_takeoff"),
|
||||||
|
events::Log::Info, "Mode not suitable for arming");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Failing mode requirements generally also clear the can_run bits which prevents mode switching and
|
// Failing mode requirements generally also clear the can_run bits which prevents mode switching and
|
||||||
@@ -181,16 +189,3 @@ void ModeChecks::checkAndReport(const Context &context, Report &reporter)
|
|||||||
reporter.clearCanRunBits((NavModes)reporter.failsafeFlags().mode_req_wind_and_flight_time_compliance);
|
reporter.clearCanRunBits((NavModes)reporter.failsafeFlags().mode_req_wind_and_flight_time_compliance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ModeChecks::checkArmingRequirement(const Context &context, Report &reporter)
|
|
||||||
{
|
|
||||||
if (reporter.failsafeFlags().mode_req_prevent_arming & (1u << context.status().nav_state)) {
|
|
||||||
/* EVENT
|
|
||||||
* @description
|
|
||||||
* Switch to another mode first.
|
|
||||||
*/
|
|
||||||
reporter.armingCheckFailure((NavModes)reporter.failsafeFlags().mode_req_prevent_arming, health_component_t::system,
|
|
||||||
events::ID("check_modes_cannot_takeoff"),
|
|
||||||
events::Log::Info, "Mode not suitable for arming");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -46,8 +46,6 @@ public:
|
|||||||
void checkAndReport(const Context &context, Report &reporter) override;
|
void checkAndReport(const Context &context, Report &reporter) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkArmingRequirement(const Context &context, Report &reporter);
|
|
||||||
|
|
||||||
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
|
DEFINE_PARAMETERS_CUSTOM_PARENT(HealthAndArmingCheckBase,
|
||||||
(ParamBool<px4::params::COM_ARM_MIS_REQ>) _param_com_arm_mis_req,
|
(ParamBool<px4::params::COM_ARM_MIS_REQ>) _param_com_arm_mis_req,
|
||||||
(ParamInt<px4::params::COM_RC_IN_MODE>) _param_com_rc_in_mode
|
(ParamInt<px4::params::COM_RC_IN_MODE>) _param_com_rc_in_mode
|
||||||
|
|||||||
Reference in New Issue
Block a user