Jump to content
The simFlight Network Forums

FSUIPC Requesting Data Best Practice


CXA001

Recommended Posts

I have a question regarding grouping and / or requesting data from FSUIPC and performance.

Lets say I have a timer that every 5 seconds queries FSUIPC. As far as performance, is it better to request all the information at the begining of my process:

FSUIPCConnection.Process(new string[] { "FSUIPCParkingBrake", "FSUIPCOnGround", "FSUIPCGroundAltitude", "etc..." });

or would it be better to request it as needed through out my code:

FSUIPCConnection.Process(new string[] { "FSUIPCParkingBrake" });

Some code...
FSUIPCConnection.Process(new string[] { "FSUIPCPOnGround" });

Some code...
FSUIPCConnection.Process(new string[] { "FSUIPCGroundAltitude" });

Normally with a database, I would query everything at once as you need to create the connection, run the query, then close the connection, etc. As FSUIPC is always connected, I am curious as to what is the most efficient way to do this.

Marc

Link to comment
Share on other sites

Since calling FSUIPC via the Process request involves your program's process being suspended, and FS effectively "interrupted" (well, another message to process, which gets passed on to FSUIPC), and then another action by the operating system to resuscitate your process, it is generally much more efficient to group your data requirements so that there's only one batch to process. Unless your Process call includes Writes to Offsets which invoke some sort of action in FS, the processing of a batch takes almost no more time for more data or less. It's pretty much just memory copying.

Anyway, with only a 5 second polling rate, such performance considerations are negligible. There are programs which request hundreds of data items at a time every 20 milliseconds or even more often -- then it becomes much more significant!

You can test these sorts of performance things yourself using the supplied FSInterrogate2 utility (in the FSUIPC SDK). You can batch select a large number of items and have it retrieve them continuously in quite a tight loop. See how much data can be continually requested this way before the affect on FS performance becomes noticeable.

And in performance terms it doesn't matter whether you leave it connected or not -- but always leave it connected if you expect to make another request: only disconnect when you no longer need any more updates for your current session -- OR when you get a timeout and need to keep trying to reconnect (eg over an FS crash, or some inordinately long delay in FS).

Pete

 

Link to comment
Share on other sites

  • 4 weeks later...

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
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.