Skip to content

Commit

Permalink
refactor commander: remove unused argument is_armed in Report class
Browse files Browse the repository at this point in the history
  • Loading branch information
bkueng committed Nov 20, 2024
1 parent cad4d14 commit 921cd8a
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions src/modules/commander/HealthAndArmingChecks/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ bool Report::finalize()
return _results_changed;
}

bool Report::report(bool is_armed, bool force)
bool Report::report(bool force)
{
const hrt_abstime now = hrt_absolute_time();
const bool has_difference = _had_unreported_difference || _results_changed;
Expand Down Expand Up @@ -318,10 +318,10 @@ bool Report::report(bool is_armed, bool force)
return true;
}

bool Report::reportIfUnreportedDifferences(bool is_armed)
bool Report::reportIfUnreportedDifferences()
{
if (_had_unreported_difference) {
return report(is_armed, true);
return report(true);
}

return false;
Expand Down
4 changes: 2 additions & 2 deletions src/modules/commander/HealthAndArmingChecks/Common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,12 +337,12 @@ class Report
*/
bool finalize();

bool report(bool is_armed, bool force);
bool report(bool force);

/**
* Send out any unreported changes if there are any
*/
bool reportIfUnreportedDifferences(bool is_armed);
bool reportIfUnreportedDifferences();

const hrt_abstime _min_reporting_interval;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ bool HealthAndArmingChecks::update(bool force_reporting, bool is_arming_request)
}

const bool results_changed = _reporter.finalize();
const bool reported = _reporter.report(_context.isArmed(), force_reporting);
const bool reported = _reporter.report(force_reporting);

if (reported) {

Expand All @@ -89,7 +89,7 @@ bool HealthAndArmingChecks::update(bool force_reporting, bool is_arming_request)
}

_reporter.finalize();
_reporter.report(_context.isArmed(), false);
_reporter.report(false);
_reporter._mavlink_log_pub = nullptr;
// LEGACY end

Expand Down Expand Up @@ -123,5 +123,5 @@ void HealthAndArmingChecks::updateParams()

bool HealthAndArmingChecks::reportIfUnreportedDifferences()
{
return _reporter.reportIfUnreportedDifferences(_context.isArmed());
return _reporter.reportIfUnreportedDifferences();
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ TEST_F(ReporterTest, basic_no_checks)

reporter.reset();
reporter.finalize();
reporter.report(false, false);
reporter.report(false);

ASSERT_TRUE(reporter.canArm(vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION));
ASSERT_EQ((uint8_t)reporter.armingCheckResults().can_arm, 0xff);
Expand All @@ -92,7 +92,7 @@ TEST_F(ReporterTest, basic_fail_all_modes)
reporter.armingCheckFailure(NavModes::All, health_component_t::remote_control,
events::ID("arming_test_basic_fail_all_modes_fail1"), events::Log::Info, "");
reporter.finalize();
reporter.report(false, false);
reporter.report(false);

ASSERT_FALSE(reporter.canArm(nav_state));
ASSERT_TRUE(reporter.canRun(nav_state));
Expand All @@ -113,7 +113,7 @@ TEST_F(ReporterTest, arming_checks_mode_category)
events::ID("arming_test_arming_checks_mode_category_fail2"), events::Log::Info, "");
reporter.setIsPresent(health_component_t::battery);
reporter.finalize();
reporter.report(false, false);
reporter.report(false);

ASSERT_TRUE(reporter.canArm(vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION));
ASSERT_TRUE(reporter.canRun(vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION));
Expand All @@ -138,7 +138,7 @@ TEST_F(ReporterTest, arming_checks_mode_category2)
reporter.healthFailure(NavModes::Mission, health_component_t::remote_control,
events::ID("arming_test_arming_checks_mode_category2_fail1"), events::Log::Warning, "");
reporter.finalize();
reporter.report(false, false);
reporter.report(false);

ASSERT_FALSE(reporter.canArm(vehicle_status_s::NAVIGATION_STATE_AUTO_MISSION));

Expand Down Expand Up @@ -178,7 +178,7 @@ TEST_F(ReporterTest, reporting)
}

reporter.finalize();
reporter.report(false, false);
reporter.report(false);
ASSERT_FALSE(reporter.canArm(vehicle_status_s::NAVIGATION_STATE_POSCTL));

if (i == 0) {
Expand Down Expand Up @@ -219,7 +219,7 @@ TEST_F(ReporterTest, reporting)
}

reporter.finalize();
reporter.report(false, false);
reporter.report(false);
ASSERT_FALSE(reporter.canArm(vehicle_status_s::NAVIGATION_STATE_POSCTL));

if (i == 0) {
Expand Down Expand Up @@ -265,7 +265,7 @@ TEST_F(ReporterTest, reporting_multiple)
reporter.armingCheckFailure<uint8_t>(NavModes::All, health_component_t::remote_control,
events::ID("arming_test_reporting_multiple_fail3"), events::Log::Warning, "", 55);
reporter.finalize();
reporter.report(false, false);
reporter.report(false);
ASSERT_FALSE(reporter.canArm(vehicle_status_s::NAVIGATION_STATE_POSCTL));

if (i == 0) {
Expand Down

0 comments on commit 921cd8a

Please sign in to comment.