Dear all,
This is more a design question - or “how to best use the SimConnect API” - rather than a specific question for some specific function.
I intend to record the flight (for playback). I receive the aircraft position (longitude, latitude, altitude) and attitude (pitch, bank, roll) “whenever data has changed”, naturally as simulation variables (with SimConnect_RequestDataOnSimObject(…, ::SIMCONNECT_DATA_REQUEST_FLAG_CHANGED).
That works well, as all of those variables are expected to change most of the time (whenever the aircraft is moving).
Now I understand I could record the aircraft main controls (flaps, rudder, ailerons, …) in the same way, as simulation variables.
But could we do better? Most of those variables (specifically flaps) are expected to change only rarely (compared to the entire flight), so I could also capture the events.
The SimConnect SDK example provides an example for receiving “brakes” events:
hr = SimConnect_MapClientEventToSimEvent(hSimConnect, EVENT_BRAKES, "brakes");
So instead of constantly recording whether “brakes” (or in our example: “flap position”) are set or not (via the corresponding simulation variables) we could simply record the actual events, and during playback simply send the events (question to myself: with SimConnect_TransmitClientEvent?).
Advantage: minimisation of data that both needs to be stored and transmitted
Disadvantage:
- for events that happen “frequently” (e.g. yoke position) sending events on top of the simulation variables might actually increase the traffic between client and FS 2020 (at least as far as the amount of request messages is concerned) → solution: record those events which happen frequently (e.g. for the yoke) as simulation variables instead
- Added complexity when randomly selecting the “replay position”: the latest events that have happened just prior to the current timestamp need to be found and sent, in order to restore “the current state of the aircraft” → solution: a bit of algorithmic wizardry
- Specifically for affecting the “flap position” there might be several events which affect it, e.g.
- KEY_FLAPS_UP
- KEY_FLAPS_1 … KEY_FLAPS_3
- KEY_FLAPS_DOWN
- (And possibly more events)
so we would need to identify and record/playback all of those events (and we still might miss “custom events” that some hardware controllers might be using to alter the flap position → solution: try and error
Any other disadvantages of recording / sending events instead of simulation variables? Or is it simply not worth the effort?
Oh, and the use case here is merely that “it looks good”, that is, that when the aircraft is “played back” that it “visually behaves” just as the recorded one, so same flap/ailerons/rudder/gear/… positions. There is no need to “analyse the flight” (as in “when exactly were the flaps lowered” etc.)
Any thoughts or even experience to share here?