-
-
Notifications
You must be signed in to change notification settings - Fork 640
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
Fix custom update #220
Fix custom update #220
Conversation
Hi, I will review this as soon as possible and merge it ASAP. |
I am not sure I understand how the changes in CustomFunction::calculate fix the issues. Applying only the change in MainWindow::updateDataAndReplot seems to be sufficinet to fix the error |
The bug is hiding in the fact that when time is reset, in this loop: PlotJuggler/plotter_gui/transforms/custom_function.cpp Lines 197 to 206 in 1cd6efd
the time index _last_updated_timestamp is not reset and cannot be less than source time. As the buffer is reset, dst_data is empty and _last_updated_timestamp is not updated. I have changed from time constraint to index as it seems more clear to me to keep the transform progression this way. Maybe I miss something, I can reword the pull request without changing the way the indexing is done if you prefer. |
Ok, so what about this code? if (dst_data->size() == 0){
_last_updated_timestamp = - std::numeric_limits<double>::max();
}
else{
_last_updated_timestamp = dst_data->back().x;
}
for(size_t i=0; i < src_data.size(); ++i)
{
if( src_data.at(i).x > _last_updated_timestamp)
{
dst_data->pushBack( calculatePoint(calcFct, src_data, channel_data, chan_values, i ) );
}
} Based on what you said, it might make more sense to move the update of _last_updated_timestamp before the for-loop |
actually I am realizing that based on the fact that timestamp must be monotonic, I don't even need to remember _last_updated_timestamp... i can write this code instead: for(size_t i=0; i < src_data.size(); ++i)
{
if( dst_data->size == 0 || src_data.at(i).x >= dst_data->back().x)
{
dst_data->pushBack( calculatePoint(calcFct, src_data, channel_data, chan_values, i ) );
}
} |
Ok, this one is better. I am a bit bothered by the monotonic assumption on time as it is not true for time-series but the original code rely on it so.... if (dst_data->size > src_data.size())
dst_data->clear()
for(size_t i=0; i < src_data.size(); ++i)
{
if( dst_data->size == 0 || src_data.at(i).x >= dst_data->back().x)
{
dst_data->pushBack( calculatePoint(calcFct, src_data, channel_data, chan_values, i ) );
}
}
|
Unfortunately this condition is triggered spuriously...
With the latest changes, both the original timeseries and the custom one need a "Clear Points" reset when you "rewind time". I am going to push the changes myself and close this PR. |
Sorry for long time delay in answering your questions and testing the new changes:
I think your solution still not reset the custom data. As it is still good to have only partial reset and not silently clean other data source: I have made a proposal(0a6ad3a) in the updated branch to force clean of custom transform when reset time is detected.
|
I applied your changes. I think this should do. Thanks again!!! |
This PR fix two different problems related to custom function update.
=== When streaming (eda7c54) ===
If custom function is used, when streaming time is reset, the custom function is not updated anymore.
Step by step to make the problem happend :
=== During data loading (e8649d7) ===
If data are loaded after custom function is defined, the custom function is not updated.
Step by Step: