c-true / FsConnect

Wrapper for Flight Simulator 2020 SimConnect library
59 stars 20 forks source link

RequestData(Enum requestId) ... multiple requestIds? #9

Closed sushiat closed 3 years ago

sushiat commented 3 years ago

I'm currently developing an application that tracks a lot of simvars and I have grouped them into two separate structs based on the sampling rate required. I initially thought I would just create

But that created some weird results:

The only way I was able to work around it was to create two FsConnect instances with only the one registered struct each, and since both are requesting data quite often and need to be running anyways I was ok with that.

But now I'm developing a "plane ground operations" step that requires a few more variables, but only for a limited amount of time, so I would be looking at a third connection to the sim - not sure if I'm still comfortable with that. Did I do/understand something wrong about the struct registrations? Or is this a limitation of SimConnect that it only supports one?

TimianHeber commented 3 years ago

There may be a limitation in FsConnect, that I have fixed in a separate branch. I'll release this this evening, hopefully this will resolve your issue, as it should definitely work. Here I have added external managers as an example of what you describe, where one manager polls aircraft data and the other polls SimObject data using separate requests.

sushiat commented 3 years ago

Awesome thank you, looking forward to testing it out and simplifying the connection management.

TimianHeber commented 3 years ago

I've done the release now and hopefully your issue have been resolved. Please let me know if you still have any issues or requests and good luck!

sushiat commented 3 years ago

Thank you again, just updated to the new version and requesting different struct types is now working perfectly with a single connection. Still have to develop further before I can test setting some values back into the sim. The only thing that I'm not sure your library can do yet that I still need to get working is setting the time in sim. From what I read so far that can only be done by sending in an event, the simvars are read only. If I get the rest implemented and you don't have time I will check if I can get that working and send you a pull request if I do.

TimianHeber commented 3 years ago

Great! Regarding setting the time, pull requests are great, but even if you only figure out the preferred way to do it and drop me a line, I can do the rest.

sushiat commented 3 years ago

I was just going to copy+paste the event id's I found for set zulu time, when I noticed your dev branch on which it looks like you already have it implemented. Nice job. I'm still one or two steps away from implementing this, currently trying to figure out a way to detect pausing in the sim and before I open an issue I thought I just quickly ask:

1) I know from reading and monitoring the simvars for time etc. that pausing from the sim is a bit of a nightmare when it comes to detecting it from simconnect (especially active pause, from what I read there isn't a really a way to detect it). 2) But I read on an fsuipc7 discussion thread that they managed to detect the ESC menu, any chance you happen to know how? 3) I experimented with the Paused property/Pause method and also subscribing to the PauseStateChanged event, and I might implement a "proper" pause from my app (I read though that the time will jump forward once you unpause (not true, utc time isn't jumping in my tests), but at least I can detect it, record it and subtract the time paused from the fligh time), problem is that I can't ensure that no user will just hit ESC and think it's paused anyway

Any and all help would be greatly appreciated and I will make sure we properly give credit to your library once we make our code public.