• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

Correlating messages

Messages
15
Country
us-washington
Is there any way to correlate data as it comes back from FSX? My scenario is this: I have several definitions, or groupings if you will, and they are all set to the same update frequency (sim frame). Now, I am wondering if there is a sanctioned way to see if two packets (with different data) originated in the same sim frame.

I saw that GetLastSentPacketID should not be used in production, so I am wondering if it is possible to do this.

Thanks,
 
I saw that GetLastSentPacketID should not be used in production, so I am wondering if it is possible to do this.

It only says that it is intended for debugging (presumably on the assumption that there'd be no need except when reporting exceptions), but I've never noticed any problems or overhead using it all the time. FSUIPC uses it so that it can not only log the problems which may occur but also carry out suitable recovery. In my software I never assume everything works all the time ... comes from my early training as a test programmer I think! ;-0

Regards

Pete
 
GetLastSentPacketID is only going to tell you the last packet number (ie packet count) that you sent to FS which has nothing to do with the data coming back from FS to your client. There is no way to tell if two data packets are from the same periodic period (same frame, same second, etc).

Do you have various groupings of data all related to the same SimObject, or is each grouping related to a different SimObject? A little more info about what you are trying to do will allow us to suggest alternatives or workarounds.
 
Do you have various groupings of data all related to the same SimObject, or is each grouping related to a different SimObject?

Right now, all the groupings are on the same object (that is, user aircraft). I guess the reason I did so was to enable me to cut down on the packets that needs to be sent from FS to me. For instance: I really don't need fuel data more than once per second where as positional data would be appreciated more frequently. I am easily imagine a scenario where I would want the less frequent data to be correlated to the more frequent data. Another scenario is correlating tagged values to non-tagged values. Does this make sense?
 
With regards to data groupings, I've grouped data by function (ie, panel switches, directinput, control surfaces, etc...) and am using tagged data and ask simconnect only to send data if it actually changes (you can set the threshold for each data point). The returned data will only contain the items that have changed (must exceed the threshold you've specified), and each data point is identified by its tag which makes mapping relatively easy.

I will tend to group data by the type of data and by what usually changes the most frequently. The goal is to reduce the amount of work simconnect has to do, as this directly impacts the user's FPS.

There are some periodic "tick" functions you can use to poll data from simconnect as well (frame, tick18, etc...) as well, but I found that it is far easier to get update data from simconnect at data's rate of change's own pace (meaning, totally asynchronous), and do your processing on another thread. Simconnect is designed to be asynchronous, and you easily get in a pickle if you attempt synchronous operations. Of course it is possible to do in logic, but the updates will always be when simconnect sends you data, not when you want simconnect to send you data (I hope that makes sense).

If you need something to happen on a regular basis, a need I had for a PID controller for some autopilot type function which requires a set loop update frequency to operate properly, I used a timer on a separate thread, leaving the simconnect update thread update whenever it needed to.

I'm not sure what you need to accomplish, hopefully the above helps.

Etienne
 
If an epoch value based off of the visual frame is sufficient, you could use the SimConnect_SubscribeToSystemEvent function with a SystemEventName = "Frame", and then in your OnRecvEvent handler you can increment an epoch value and in your OnRecvSimObjectData handlers, you can use that epoch value to tag your data for later correlation.
 
With regards to data groupings, I've grouped data by function (ie, panel switches, directinput, control surfaces, etc...) and am using tagged data and ask simconnect only to send data if it actually changes (you can set the threshold for each data point). The returned data will only contain the items that have changed (must exceed the threshold you've specified), and each data point is identified by its tag which makes mapping relatively easy.

I will tend to group data by the type of data and by what usually changes the most frequently. The goal is to reduce the amount of work simconnect has to do, as this directly impacts the user's FPS.

If you need something to happen on a regular basis, a need I had for a PID controller for some autopilot type function which requires a set loop update frequency to operate properly, I used a timer on a separate thread, leaving the simconnect update thread update whenever it needed to.

I'm not sure what you need to accomplish, hopefully the above helps.

Etienne

Thanks for the reply, Etienne! Let me try to explain what I am trying to do and what I am currently doing -- I think it is very close to what you indicated that you are doing. I have, like you, grouped data by the type of the data (controls, engine parameters etc). Because of this, SimConnect will call me twice, say, for the same frame (I set these values up for frame frequency) -- once for control parameters and once for engine parameters. I would like to know that these two calls actually are related to the same frame.

Certainly, some things I read tagged for the reasons that you specify. And, I do understand your point about getting into trouble if attempt synchronous operations with SimConnect -- I am totally comfortable with async operations :)
 
Back
Top