SimConnect + WASM combined project using VS2019

Hello @AthenaGrey1,

I will control Events in a later chapter, but in Chapter4: Variables I also referred to a good explanation given by @Umberto67 that you can find in this post.

Sometimes you can use a variable or an event to achieve the same goal. Let’s take an example.

If we look at the FCU Panel documentation of FlyByWire, scrolling down to the “ALT knob”, we see the following:

The first one is an “MSFS Variable” and can be controlled directly with SimConnect. In my explanation above, I call this “native MSFS variables”, or “A-Type”. If you use my application, you can add the variable as “A:AUTOPILOT ALTITUDE LOCK VAR:3,feet,FLOAT64”, and then you can read from it, and even write to it. Makes sense, because if we look in the SimConnect SDK Documentation and search for the variable “AUTOPILOT ALTITUDE LOCK VAR” here, we see the green tickmark on the right indicating that this is a writeable variable (in fact, ALL variables are readable, some of them are writeable).

But the FlyByWire documentation also gives us 2 "Custom EVENT"s that can be used to Increase and Decrease the ALT. In my explanation above, I call this “custom variables”, which in case of Events are “K-Type”. If you use my application, you can add them as “K:A32NX.FCU_ALT_INC” and “K:A32NX.FCU_ALT_DEC”. If you then use the button “Set Value” in my application (the value is even irrelevant) you will see that the ALT is increasing and decreasing.

So when do you use the variable, and when do you use the event? That really depends on the implementation. In case of ALT, using the events has some advantages. In the A320, you can only increase or decrease with steps of 100 or 1000 (depending on the selection you made on the FCU). But if you use the variable, you seem even to be able to give a value like “12345”, which is normally not possible in the A320. I think there is even no guarantee that this couldn’t cause any unpredictable effects. So if you use the variable directly, you might need to build some logic yourself to avoid giving wrong values. So in my opinion, it’s safer to use the event in this case.

Probably a bit off-topic here, but I do have a reason to use the variable directly. If you use the INC/DEC Events with a rotary encoder in your cockpit hardware, there might be some “lag” when you turn the knob fast. Reason is that for each tick, you have to send an INC/DEC event. In my cockpit hardware (in the past, using JeeHell A320 FMGS with FSX), I used a different approach in which my encoder is driving the 7-Segment display directly, which means that it goes very fast and shows all the ticks. This gives a very reactive feel. And I only send the value to the simulator every 200 msec controlling the variable directly, which reduces the communication a lot. Although, you still have to build some extra “synchronization logic” to make sure that, if the simulation changes the ALT value itself, that this is also displayed correctly (without turning the encoder). I might explain this method later in the Cockpit Builder section on this forum.

3 Likes