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
Enhancement: Variable autotimer #161
Comments
Changing the items I would change the way the autotimer is configured the item code. So Maybe it would also be a good idea to introduce a new setting (like
Splitting the value and time configuration into two settings could also be helpful to make clear what is the time expression and what the value expression. |
100% agree. My focus was to find a quick solution that is downwards compatible and doesn't require a complete code rewrite (which will probably happen one day, considering the ongoing discussions about autotimer). If I read the code right, a current call autotimer = sh.item() = sh.item() would trigger an error, so the suggested way shouldn't impact the mentioned 'other places' at all. I built a quick&dirty sh/sV test configuration and found the beforementioned error in my log, as expected. Only conflict I can see at the moment is the definition of autotimer as quoted in your comment - these places would probably need to have the same evalutations, too - so 4 more lines of code by using copy/paste. As said above - my approach for solving this was following the principle of least effort. Professional programmers will find for sure better and more elegant ways to do it. Amendment: Putting it into timer() was on purpose, so the evaluation takes place in the moment the timer is called, not when the item is defined. This ensures that the time/value can be changed during runtime, too. |
we should merge this with #160. Same idea but without solution draft - which Tom has now proposed here. |
#160 is not only about autotimer. I think we should sort it out. In #160 @ohinckel laid out some ways to handle I think fixing the casting issue only for autotimer ist fine for the moment. The other cases could folllow later on. If no one opposes, I would start implementing for autotimer:
By fixing the casting issue we could introduce some incompatibilities. So my question: Should the implementation be done in autotimer or should I introduce something like autotimer_eval (as ohinkel proposed)? Instead of implementing an
The third parameter could be:
We could use better names vor 'newcasting' and 'oldcasting' Is it necessary to be able to specify a time like '5m30s' ? |
Either way (autotimer_eval or new-/oldcasting) is fine for me, as long as it will be possible to set the autotimer time/value by an item reference, which is evaluated in the moment before the autotimer is casted. In my personal opinion it won't be necessary to set '5m30s' as this corresponds to a value of 330. Most time values are handled as seconds anyways, so the only advantage I can see in '5m30s' is a minor one - slightly better readybility. Taking into account that it will probably take some significant programming and testing, I would recommend to put your time into other/more important features. (just my 2 cents) Just curious - what led you to the decision to not do it the 'easy way' by adding eval()'s as recommended above? It doesn't interfere, is downwards compatible and takes only a couple of minutes to implement. Is there something I didn't consider/see? Anyways Martin, thank you a lot for your time and efforts!!! :) |
I wanted it done for the next release. And going the eval() way look like beeing the way with far more decissions and compatibility issues (look at ohinkels comment in issue #160. I am going to put in the item.__update routine to avoid interference with other calls to timer(). That way, the evaluation takes place every time the timer is set. The other part, the handling for relative item references has to be done someplace else. The conversion from relative to absolute references is done at the time the config is loaded. |
Thanks for all the work and the pull request - we just came across an issue that might be connected to this, could you have a look into this thread? If you feel it's not relevant, just disregard it. Thanks! :) |
How about just evaluating the |
Won't work |
Implemented for Version 1.3 and documented in wiki. |
For the time being, autotimer on an item is defined as follows: autotimer = time = value. Both time and value are fixed, no change possible during runtime.
I would like to recommend an amendment to item.py, so both can be read from another item (e.g. visu slider connector item) instead. The following amendment should work; however, there are possibly other ways how to solve this more elegant:
Old / as is:
New / recommended changes (add 4 lines in order to identify item references and get the corresponding value):
I am particularly interested in a flexible time, but changing value might be of use for other folks, too. Thats why I put both here.
Thanks for all your work, and for considering this!
The text was updated successfully, but these errors were encountered: