layerdisplay
layerdisplay copied to clipboard
Layer use data['progress']['completion'] instead of recompute from "filepos"
Hi,
I'm currently writing a plugin that changes the "completion" in data progress to a "completion" based on time. https://github.com/celogeek/OctoPrint-ProgressBasedOnTime/blob/master/octoprint_ProgressBasedOnTime/init.py
The completion here = Print Time / (Print Time + Time Left)
I have added "file_completion" to keep track of the previous value here.
It would be safer if possible to recompute the file progression based on the "filepos" information and the size of the file you may have kept somewhere.
Or is it possible to use the "file_completion" if it exists instead of completion ?
something like this: https://github.com/celogeek/layerdisplay/commit/67d933a2abf477340d0c716aab73ce9a3a028e34
From what I understand you are looking for compliance from other plugins to not rely on data from the completion field to track file position because your plugin will change its value. If that is the case, I'm not sure I can support that. What if plugin devs don't get the memo and OctoPrint users are left chasing the ghost in the machine when things are not working because of the introduced conflict.
I agree that completion percentage based on file position is not the most useful data to the end user. For instance, if your GCode for some reason 90% comments, the results look odd to the user. Have you thought in about an opt in route instead of ripping out the original functionality? I'm sure there is a good way to accomplish your goal without creating conflicts in the plugin ecosystem :)
What are your thoughts?
I'll change it tomorrow if you want. I'm just a little concerned about the long term impact it could have on the plugin ecosystem. I imagine @foosel would agree. There is no way for other plugin authors to know that your plugin could possibly break theirs. My plugin is not the only one that uses 'completion' in the same manner mine does. I saw at least one other when looking at other projects as reference when learning how to author octoprint plugins.
yeah. in fact it would be better to patch octoprint. for example add 2 new thing: file_completion, time_completion.
Then let "completion" untouch, or may be deprecate it.