Jump to content
The simFlight Network Forums

FSUIPC WASM module + client-side API + lvar/hvar discussion topic


Recommended Posts

  • Replies 146
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Will be a while coming...I'm going to take the weekend off (bar support) and start on this next week...

Thank you sir! Much appreciated. I'm planning on some further development to make it possible to save the cockpit state of other models as well. I will include your WASM module and give you the c

I have just released version 0.4.3. This supports of to 1022 lvars. There is also a minor change to the CDAType enum that may require code changes to anyone implemeting their own client.

7 hours ago, John Dowson said:

Thats interesting...even the list functions?

 

7 hours ago, jaxx said:

Could you share how you are using the DLL from C#? Because I still cannot read or log data via the DLL...

So, first I rebuilt the FSUIPC_WDLL with the latest WAPI lib (that's not necessary now that John have done it for you 🙂). Then I have the DLL functions declared like this (the ones I'm using in my app):

[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_init(IntPtr hWnd);

[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_start();

[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_end();

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void lvarValueRecvFunc(string lvarName, double value);

[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_getLvarValues(lvarValueRecvFunc callback);

[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void lvarIDRecvFunc(string lvarName, int id);

[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)] 
private static extern void fsuipcw_getLvarList(lvarIDRecvFunc callback);


[DllImport("FSUIPC_WAPID.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern void fsuipcw_setLvarAsShort(int id, int value);

Calling the functions fsuipcw_init, fsuipcw_getLvarValues and fsuipcw_getLvarList with:

fsuipcw_init(this.Handle);

var result = new Dictionary<string, double>();
fsuipcw_getLvarValues(result.Add);

var lvars = new Dictionary<string, int>();
fsuipcw_getLvarList(lvars.Add);

NOTE:
I modified the code for fsuipcw_getLvarList so that it takes (const char*, int) instead of (int, const char*). Since there's no function to set an Lvar by name I use this function to get the Lvar ID for the fsuipcw_setLvarAs...(). Having a Dictionary/map with the name as key and id as value serves that purpose much better.

 

Hope this helps. It's my first C# application ever so I had to google it all up, but if it seems to work 🙂

 

6 hours ago, John Dowson said:

If you can't access let me know and I'll PM you the details.

I'm not part of the VIP cabal with access to that part of the forum 🙂, so it would be super appreciated if you could do that.

Link to post
Share on other sites
51 minutes ago, John Dowson said:

Yes, but you can just use fsuipcw_getLvarNameFromId first to get the name.

My application is based around an .ini file with the names of the variables the user like to save/load, so I guess I'm using your API in the opposite direction from what you intended 🙂

Link to post
Share on other sites
13 hours ago, andhog said:
14 hours ago, John Dowson said:

Yes, but you can just use fsuipcw_getLvarNameFromId first to get the name.

My application is based around an .ini file with the names of the variables the user like to save/load, so I guess I'm using your API in the opposite direction from what you intended 🙂

Sorry, I meant that you can use fsuipcw_getLvarIdFromName first to get the id.

You should be able to use the API either on name or id really. I think I'll also add some convenience methods to let you use the name directly.

 

Link to post
Share on other sites
12 minutes ago, Helibrewer said:

Should the "Create Aircraft LVAR file" be functional yet in the test client? It is the only thing that doesn't seem to generate an output.

Yes its working - although I don't know why you would want to use this function. Its a hangover from a previous implementation. The files are created under your AppData\Roaming\Microsoft Flight Simulator\Packages\fsuipc-lvar-module\work folder (which is the WASM persistent storage area for the FSUIPC WASM module).

Link to post
Share on other sites
11 minutes ago, John Dowson said:

Yes its working - although I don't know why you would want to use this function. Its a hangover from a previous implementation. The files are created under your AppData\Roaming\Microsoft Flight Simulator\Packages\fsuipc-lvar-module\work folder (which is the WASM persistent storage area for the FSUIPC WASM module).

Found it, yes, it's an incomplete list compared to the "List  LVARS". The main reason I was interested is because I thought it would be easier than trimming the values out of the listing windows to create my file of LVAR names.

Thanks for pointing me in the right direction, found it here:

C:\Users\MyUserName\AppData\Local\Packages\Microsoft.FlightSimulator_8wekyb3d8bbwe\LocalState\packages\fsuipc-lvar-module

 

Link to post
Share on other sites
4 minutes ago, Helibrewer said:

Found it, yes, it's an incomplete list compared to the "List  LVARS". The main reason I was interested is because I thought it would be easier than trimming the values out of the listing windows to create my file of LVAR names.

There are (or should be) multiple files there - only 146 lvars per file, which is how many each Client Data Area created can hold, again a hangover from a previous implementation.

You usually actually get more lvars when you create lvar files, as it re-scans for lvars when doing this so you can get more than the initial scan. If you find that you get more, you can issue a reload command to the WASM to reload all the current lvars back to the client/WAPI.

Link to post
Share on other sites
18 minutes ago, John Dowson said:

There are (or should be) multiple files there - only 146 lvars per file, which is how many each Client Data Area created can hold, again a hangover from a previous implementation.

You usually actually get more lvars when you create lvar files, as it re-scans for lvars when doing this so you can get more than the initial scan. If you find that you get more, you can issue a reload command to the WASM to reload all the current lvars back to the client/WAPI.

Ah, I see that now, thanks again and thanks for all the work on this. Looking forward to figuring out how to utilize this in lua scripts in the future.

Link to post
Share on other sites
1 minute ago, andhog said:

but you can only set them by ID.

At the moment, yes, but as I said, you can do:
     setLvar(getHvarIdFromName("My lvar"), myLvarValue);
(or similar if using the dll). And, as I also said, I will add some convenience functions (at some point, low priority) to do this directly, i.e.
     setLvar("MyLvar", my/lvarValue);

(overloaded in the WAPI, I will have to give different names in the dll, eg setLvarByName).

 

Link to post
Share on other sites

I've added hvar support via lua and macros in the attached version (v7.1.0e)
Note that the hvar name argument for the new lua function activateHvar must be preceded by 'H:'.
For Lvars, no 'L:'. This is due to the fact that the internal hvars are stored with the H:, but lvars are not stored with the L:.
I may change this - it was done so I could easily tell the difference between L and H variables while developing.

For using lvars/havrs in macros, they are always proceeded by L:/H:. 

FSUIPC7.exe

 

Link to post
Share on other sites
22 minutes ago, andhog said:

Unfortunately there's apparently something seriously wrong with the latest world update. Having a standalone WASM module in your community folder causes CTD when starting MSFS 😕

I can confirm this also.

Link to post
Share on other sites
Quote
11 hours ago, andhog said:

Unfortunately there's apparently something seriously wrong with the latest world update. Having a standalone WASM module in your community folder causes CTD when starting MSFS 😕

I can confirm this also.

So do I.

I have installed the updated SDK, SimConnect.dll and SimConnect.h have not changed. Maybe WASM?

Link to post
Share on other sites
12 minutes ago, d147 said:

Maybe WASM?

Asobo seems to have broken the WASM module facility.

https://forums.flightsimulator.com/t/standalone-wasm-modules-crash-the-simulator-after-latest-1-15-7-0-update/390552/4

https://forums.flightsimulator.com/t/wasm-module-connection-broken-after-wu4/390841

We're stuck until this is fixed I'm afraid.

Pete

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use. Guidelines Privacy Policy We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.