sImWatcher what tech. to set variables?

Recently I’ve been using the simwatcher app and found it very useful that I can set the value of many variables (a small subset) with it (or I get an error message if not success).
how doees this set variables without WASM?

SetDataOnSimObject is the answer

First of all, „WASM“ is not a set of functionality - aka API = application programming interface - like the SimConnect API is: WASM stands for „Web Assembly“ and is merely a „bytecode format definition“ plus the corresponding „typed stack machine“ model which is able to execute this bytecode - simplified.

Or in other words: WASM is a hardware-independent format which allows to load and execute code in a „controlled environment“ (a „sandbox“), mostly in the context of a web browser, but also useful in other scenarios where such (generally untrusted) „bytecode“ needs to be executed in a safe manner - e.g. in the same process as MSFS itself.

Think of the WASM typed stack machine as the Java Virtual Machine and the WASM bytecode as the compiled Java bytecode (which can be executed on the JVM).

How do you get „WASM bytecode“? There exist a number of „WASM compulers“ for most languages, including C++.

Scenario: you implement some gauge / display logic of some cockpit element in C++ (as an example), compile that into WASM bytecode and ship that WASM module with, say, your aircraft (or custom airport perhaps, too). That code then gets executed within the same process which „runs your aircraft“, or in other words: „in process“ (within MSFS - note that MSFS/the WASM stack machine may actually spawn a separate process to run the bytecode - but let‘s consider this an implementation detail for now ;)).

So what APIs are available for such WASM modules? I am not very familiar with the SDK in general (only the SimConnect API specifically), but I believe there is something called the „Gauge API“. People with actual aircraft building experience may add more here.

So back to your actual question, how does the SimvarWatcher example app set simulation variables? We have mentioned the API already: via SimConnect API. It is essentially a C API (easily incorporated into C++ apps, an official .NET wrapper API and numerous other language wrappers such as for Java or Python exist, too) which communicated with MSFS via local sockets (or pipes, can‘t remember right now).

Or simply put: the SimConnect API allows external applications read/write access to various „simulation variables“ (e.g. latitude/longitude, gear up, thrust lever position etc.) as well as subscribe to and sending „events“.

As most „simulation variables“ (but not all) are „writeable“ you can change their value also via the SimvarWatcher. Try e.g. lowering the gear while airborne.

1 Like

thanks for the great information on this… I wrote a rather large MSFS C# App that is a co-pilot that helps fly the aircraft … it uses simconnect VARS and EVENTS to control much of the aircraft … but it has many holes where I couldn’t reach some functions , buttons, data in the FS.

I’m ready to rewrite it , or start over with the experience /knowledge I have now … do I start over with WASM or add a WASM module to my current C# code and use it to reach the missing functions? (is that even possible?) thanks

That decision is up to you :wink: But it has been done, and discussed in several threads. This one includes links to the (at least) other two (large) threas about WASM + SimConnect + “client events”:

Note that - by nature - such a WASM module is most likely going to be aircraft specific, needs to be installed in the Community folder (of course) and the “client event IDs” that you have to define (in order to report back/receive to/from your client application) may collide with other such WASM modules - or so I understand (roughly).

Also, if the aircraft changes its “local variables” (L:vars) names you need to “keep up” and adapt your WASM module accordingly.

But all has been discussed in great detail in those threads.

1 Like

Also have a look at this thread here:

It even includes a “UML diagram designed with MS Paint” :wink: , and it even contains a “Hello, WASM World!” example code!

1 Like

And if you want to have the full details, have a look at this tutorial I wrote. And if that isn’t enough, have a look at the second tutorial here.

1 Like