-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[core] Fix bug in frequency calculator that will reset the frequency to 0.0 even though data is still incoming. #1650
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,6 +1,6 @@ | ||||||
/* ========================= eCAL LICENSE ================================= | ||||||
* | ||||||
* Copyright (C) 2016 - 2019 Continental Corporation | ||||||
* Copyright (C) 2016 - 2024 Continental Corporation | ||||||
* | ||||||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||||||
* you may not use this file except in compliance with the License. | ||||||
|
@@ -194,3 +194,56 @@ TEST(core_cpp_util, Freq_ResettableFrequencyCalculator) | |||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
|
||||||
struct command | ||||||
{ | ||||||
std::string command_type; | ||||||
long long time_point; | ||||||
}; | ||||||
|
||||||
std::vector<command> commands = | ||||||
{ | ||||||
command{"getting frequency", 0 }, | ||||||
command{"ticking", 500 }, | ||||||
command{"getting frequency", 1000 }, | ||||||
command{"ticking", 1500 }, | ||||||
command{"getting frequency", 2000 }, | ||||||
command{"ticking", 2500 }, | ||||||
command{"getting frequency", 3000 }, | ||||||
command{"ticking", 3998 }, | ||||||
command{"getting frequency", 4000 }, | ||||||
command{"ticking", 4002 }, | ||||||
command{"getting frequency", 5000 }, | ||||||
command{"ticking", 5998 }, | ||||||
command{"getting frequency", 6000 }, | ||||||
}; | ||||||
|
||||||
TEST(core_cpp_util, Freq_NoZeroFrequency) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: all parameters should be named in a function [readability-named-parameter]
Suggested change
|
||||||
{ | ||||||
eCAL::ResettableFrequencyCalculator<std::chrono::steady_clock> calculator(3.0f); | ||||||
int i = 0; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: variable 'i' of type 'int' can be declared 'const' [misc-const-correctness]
Suggested change
|
||||||
|
||||||
for (const auto& command : commands) | ||||||
{ | ||||||
std::chrono::steady_clock::time_point time(std::chrono::milliseconds(command.time_point)); | ||||||
|
||||||
if (command.command_type == "ticking") | ||||||
{ | ||||||
calculator.addTick(time); | ||||||
} | ||||||
else if (command.command_type == "getting frequency") | ||||||
{ | ||||||
auto frequency = calculator.getFrequency(time); | ||||||
if (i > 1) | ||||||
{ | ||||||
ASSERT_GT(frequency, 0.0) << "Iteration " << i; | ||||||
} | ||||||
|
||||||
++i; | ||||||
} | ||||||
else | ||||||
{ | ||||||
} | ||||||
} | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'commands' is non-const and globally accessible, consider making it const [cppcoreguidelines-avoid-non-const-global-variables]