Sign in to follow this  
Guest ayk

Simconnect - periodically read data?

Recommended Posts

Hi,can I use simconnect to periodically read data from FSX? Need a function, which i'll call in a while-loop. It must return the elevator position. Need to export this function into a DLL.Anyone can help?thx a lot

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

>can I use simconnect to periodically read data from FSX? Need>a function, which i'll call in a while-loop. It must return>the elevator position. Need to export this function into a>DLL.SimConnect doesn't work that way. It sends you values but not on return of a request. It is asynchronous. You can ask it to send you values when they change, or at intervals. The intervals are from a fixed set, once of: SIMCONNECT_PERIOD_VISUAL_FRAME, SIMCONNECT_PERIOD_SIM_FRAME, SIMCONNECT_PERIOD_SECOND,If you wanted to impose your own polling period on that you'd have to program a routine to receive and store the values at one of the above periods (and you might as well set the "when changed" flag too, else it's wasteful). Then, in your while-loop (uh? which hopefully has a Sleep or something in it to avoid wastefully hogging the processor), just retrieve the last stored value.Really, you shouldn't use a while loop at all even for regular polling, but a timer event or callback. You could use SimConnect for that too if one of its periods were suitable. It has system events for every Frame, 6 times per second, every 1 second and every 4 seconds. Otherwise you'd use the Windows SetTimer facilities.RegardsPete

Share this post


Link to post
Share on other sites

Hi !i have the same problem polling informations from FSX, regarding gear position.I did a loop calling the function onrecvsimobjectdata or something like that...but there are no result at all...i can get the information clicking regularly a button calling the function and displaying the information, but not in a while loop...why it doesn't work ?are there any examples or tutorial in VB.net to understand how it really works ?thank's for your helpFred

Share this post


Link to post
Share on other sites

>I did a loop calling the function onrecvsimobjectdata or>something like that...>but there are no result at all...>i can get the information clicking regularly a button calling>the function and displaying the information, but not in a>while loop...>why it doesn't work ?I've no idea what you are doing in your 2while" loop, but two things occur to me:1. If you are not releasing control to other processes in your loop, how do you expect other things to happen?2. The data from SimConnect is supplied asynchronously, via a CallBack -- not as a return to some call from you. So how are you expecting it to arrive in your "while loop"?Pete

Share this post


Link to post
Share on other sites

Thank you for your answer Pete...i'm sure i haven't understand the philosophy of VB.net programming and simconnect workings...well, in a do...while loop i call the simconnect function as i can do thru a button...but even after the button click i have the result in a textfield of my form because the event is fired in simconnect (for example, the gear position which varie from 0 to 1 when the gear toggle is fired), i have not the same result in my loop....it seems that i have the result only when the control which have the loop ends...it's very amazing for me and very new to program in VB.net and also with events...Where can i find good tutorials to understand how simconnect works ?i've read the tutorials from NotASenator at http://www.notasenator.com/blog/ and i'm waiting for the following lessons...

Share this post


Link to post
Share on other sites

hi again !i'm happy today because i succeeded to make my program work !how ? well, keeping on reading, thinking and trying things, i understood i was doing wrong. Event programming is not as difficult as i thought, but as different as i used to practice. So i left the loop programming away and used the event OnRecvSimobjectData with parameters SIMCONNECT_PERIOD.SIM_FRAME for the period and SIMCONNECT_DATA_REQUEST_FLAG.CHANGED for the data request flag. Then i included the things i wanted to do when this event received the massage.In fact it's a new way of thinking but easy to understand and use when you've found itThank's for your help

Share this post


Link to post
Share on other sites

Hi, apologies if this is the wrong forum to ask this. I trying to build a Cessna radio stack. I would like to use vb and simconnect to get the data from fsx. However I'm struggling; is there some example code that I could use to get started?

 

Many thanks

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this