Skip to content

fix(mock): quantize the wrapping fuel counter - #97

Merged
Tanchouteur merged 1 commit into
mainfrom
fix/mock-fuel-counter-warning
Aug 24, 2026
Merged

fix(mock): quantize the wrapping fuel counter#97
Tanchouteur merged 1 commit into
mainfrom
fix/mock-fuel-counter-warning

Conversation

@Tanchouteur

Copy link
Copy Markdown
Owner

This pull request improves the handling of the 8-bit fuel counter in the TripStatsService to ensure more accurate and robust fuel consumption calculations, especially in the presence of counter wraps and floating-point imprecision. The main changes include introducing a quantized tick-based delta computation, refactoring the main loop to use this logic, and adding targeted unit tests to validate the new behavior.

Fuel counter logic improvements:

  • Added _fuel_counter_steps and _fuel_counter_step_l to the constructor to represent the number of counter steps and the fuel value per step, enabling quantized tick-based calculations.
  • Introduced the _fuel_counter_delta method, which accurately computes the fuel delta by quantizing raw float values to counter ticks, properly handling counter wraps, and filtering out implausible jumps.
  • Refactored the main loop in _run to use _fuel_counter_delta instead of the previous float-based delta calculation, improving reliability and code clarity.

Testing enhancements:

  • Added unit tests to ensure that equivalent float values do not trigger false wraps, real counter wraps are handled correctly, and implausible jumps are still rejected, increasing confidence in the new logic.

CopilotAI lite review requested due to automatic review settings August 24, 2026 12:02
@TanchouteurTanchouteur self-assigned this Aug 24, 2026

CopilotAI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@TanchouteurTanchouteur added the bug Something isn't working label Aug 24, 2026
@Tanchouteur
Tanchouteur merged commit 7c43740 into mainAug 24, 2026
7 checks passed
@Tanchouteur
Tanchouteur deleted the fix/mock-fuel-counter-warning branch August 24, 2026 12:11
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugSomething isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Tanchouteur