Jump to content
The simFlight Network Forums

request simple c# demo script

Recommended Posts

paul can u check whit me pls? for some reason i get only false i tripple checked this.

i get false on all these even tought they should be mixed be true and false.
(i  seem to get the same error in (windowheat and hydraulics.)   i am confused because i got  other bit arrays working  same line of codes

        private Offset<BitArray> fuelcen = new Offset<BitArray>("fuelcen", 0x646E, 1);
        private Offset<BitArray> fuelfwd = new Offset<BitArray>("fuelfwd", 0x646A, 1);
        private Offset<BitArray> fuelaft = new Offset<BitArray>("fuelaft", 0x646C, 1);


                string fuelcenl = this.fuelcen.Value[0].ToString();
                string fuelcenr = this.fuelcen.Value[1].ToString();
                string fuelfwdl = this.fuelfwd.Value[0].ToString();
                string fuelfwdr = this.fuelfwd.Value[1].ToString();
                string fuelaftl = this.fuelaft.Value[0].ToString();
                string fuelaftr = this.fuelaft.Value[1].ToString();



646A 2 BYTE x 2 FUEL_annunLOWPRESS_Fwd[2] Boolean 
646C 2 BYTE x 2 FUEL_annunLOWPRESS_Aft[2] Boolean 
646E 2 BYTE x 2 FUEL_annunLOWPRESS_Ctr[2] Boolean


Share this post

Link to post
Share on other sites

These are not BitArrays, they are Byte Arrays. Two bytes long. Each byte is either 0 or 1.

The BitArray type offsets list what each bit represents. These offsets don't say that, they say 'boolean' which is a single value: 1 or 0.

The best way to handle these is to declare two offsets as bytes. Each byte offset will be one of the lights. You will need two offset addresses, one will be the address as stated, the next one will be that address + 1.

For example for the FUEL_annunLOWPRESS_Fwd:

private Offset<byte> fuelfwdL = new Offset<byte>("fuelfwd", 0x646A);
private Offset<byte> fuelfwdR = new Offset<byte>("fuelfwd", 0x646B); 

The fuelFwdR offset the address is 0x646B which is (0x064A + 1).

Then test for 1 or 0:

string fuelfwdl = (this.fuelfwdL.Value == 1) ? "On" : "Off";
string fuelfwdr = (this.fuelfwdR.Value == 1) ? "On" : "Off";


Share this post

Link to post
Share on other sites

sorry for the late answer 🙂
i read it from phone.  offline  got so excited that it finished  the next 90 cmds
between homeschooling the kid due to corona school closings here in my country 😄

by now i managed to get out working. its not realy fast yet 🙂 but in crude its working tweaking the software step for step 😄



  • Like 1

Share this post

Link to post
Share on other sites

paul quick question.

do u know if ure .net would have trouble running 2x  whitin one aplication?
i am considering running the app in 2 threads to get data not delayed because of the other software.

read: i dont ask how. i just wondered if u know its been tried 🙂
and deemend inposseble before i bite my self into it and find out its imposseble 😛



Share this post

Link to post
Share on other sites

You can't run two connections in the same application. It's not designed like that. It wouldn't help much as I think FSUIPC can only serve one client at a time anyway.

The DLL is thread-safe however. So you can use it in a multi-threaded application. For example you can call Process() methods on a background worker thread. This is useful for not blocking the GUI thread and making it feel unresponsive. It's also useful if you have other processing that might slow down the Process() calls - you can put the other processing on its own thread too.

Theoretically, you can call Process() and access Offsets from multiple parallel threads. However, I'd advise against this for two reasons:

  1. It's complicated to debug
  2. Only one Process() call can be communicating with FSUIPC at a time. If you call Process() on thread B before Process() on thread A is finished, thread B will be blocked until thread A completes.

So, yes, you can have the Process() calls being made in their own thread, but keep it simple; don't have multiple threads firing off requests to FSUIPC all over the place unless you really know what you're doing.

You only need to create the offsets and open the connection once (on any thread). The offsets and that connection can be accessed by any other thread you create.


Share this post

Link to post
Share on other sites

wel that is super to hear

because one thread is realy just to read offset data 🙂
while the other thread is having delays
example 7,9 seconds  delay after requesting stairs to the plane before a door gets openen another 2 seconds before door open etc 🙂


Share this post

Link to post
Share on other sites

found a simple bypass 🙂

Thread 1 =  fast reading data;
last thing it does is read a form value. if form is 1
it wil change it to R
and it wil pause itself til form is back to 0 🙂

Thread 2 = slow progress  does the opposite.
if it wants to write it change form value to 1
and waits on R.

it processes  fsuipc commands
 turns form back to 0

Share this post

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.

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.


  • 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.