aua668 Posted July 19, 2012 Report Posted July 19, 2012 Dear Pete, I kindly ask you, if a function event.Lvar(LvarName, interval, function name) could be implemented in a future release of FSUIPC. This event function should register a Lvar for tracking of changes. Whenever the Lvar changes, the named function should be triggered. The check interval should be configurable for performance reasons. Why would this be useful? Today a lof of panels work with Lvars to expose states to the outside world. So typically this is fine for accessing them with LUA scripts. But as the pattern is always the same for all cockpit freaks, to react on these variables, it would be nice to have a generic implemention which could be called with one simple function call. So what are we typically doing for every single Lvar at the moment: We define a function, which we are calling by an event.timer. This function checks, if the state since the last call has changed for this Lvar. And if so: We are doing something. So a generic solution following this pattern, would be great. Many things today could be solved by monitoring offsets, but a lot of more complex aircrafts (like the DA Fokker) often use their own logic to implement certain functionality. Then typically you might have the chance to react on the Lvars used. And at the moment you have to implement this mechanism for every Lvar you want to monitor. By having one single event function to register the Lvar checking on a timer base would be a great reduction in code necessary to interface with cockpit hardware to such airplanes. Just an idea and maybe my wish for this year's Xmas ;-) Best regards Reinhard
Pete Dowson Posted July 20, 2012 Report Posted July 20, 2012 I kindly ask you, if a function event.Lvar(LvarName, interval, function name) could be implemented in a future release of FSUIPC. This event function should register a Lvar for tracking of changes. Whenever the Lvar changes, the named function should be triggered. The check interval should be configurable for performance reasons. Hmmm. Interesting idea. I never implemented a normal event on LVar chages because of the performance problem when continuously reading them, but having a polling interval could solve that. I'd like to impose a minimum interval though. What do you think would be the longest minimum which could be tolerated? Regards Pete
aua668 Posted July 22, 2012 Author Report Posted July 22, 2012 Hi, In my code pieces I typically set the timer between 250 and 500 msec. That's normally enough and reduces load. A minimum could be set to 100 msec for example. Rgds Reinhard
Graham Pollitt Posted July 22, 2012 Report Posted July 22, 2012 My app uses a timer of 125ms. Each event that uses different intervals just adds each timer tick until it matches the required time.
Pete Dowson Posted July 22, 2012 Report Posted July 22, 2012 In my code pieces I typically set the timer between 250 and 500 msec. That's normally enough and reduces load. A minimum could be set to 100 msec for example. Okay. I thought 50 or 100 mSecs as a minimum. I'll see if I can add it before my upcoming August holidays. Pete
aua668 Posted July 22, 2012 Author Report Posted July 22, 2012 Wow - if you rare eally able to do it so quickly, then Xmas is already in August this year :-) Rgds Reinhard
Pete Dowson Posted July 27, 2012 Report Posted July 27, 2012 Wow - if you rare eally able to do it so quickly, then Xmas is already in August this year :smile: Just got it in before August ;-). download FSUIPC 4.841 or 3.999t as appropriate. The Lua documentation is also updated -- see its own thread in Download Links. Regards Pete
aua668 Posted July 27, 2012 Author Report Posted July 27, 2012 Hi, Merry Xmas. It works perfectly !!! I have just done a first test. I reduced my code and modified it to the new event.Lvar function. And immediately this did work. Now your August vacation is near ;-) Best regards Reinhard
Pete Dowson Posted July 28, 2012 Report Posted July 28, 2012 Merry Xmas. It works perfectly !!! I have just done a first test. I reduced my code and modified it to the new event.Lvar function. And immediately this did work. Good! Enjoy! ;-) Pete
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now