Jump to content
The simFlight Network Forums
michielsweb

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";

Paul

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.

Paul

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

OKE oke,  real life has been a little keep me to busy.  together whit a little programming block in the head.

but i am back in busniss. but i found some issue. whit a offset 🙂

whitch has me surprised, maybe someone can tell me the offsets for:

private Offset<ushort> com2 = new Offset<ushort>(0x034F);

 

no code 🙂 just offset.   and yes the export to the dll. has a delay. because i found it more reliable to have arduino do it.

i just had to make 2 nanos friends whit c# 🙂

Share this post


Link to post
Share on other sites

The offset for COM2 is:

private Offset<ushort> com2 = new Offset<ushort>(0x3118); 

This can be found in the "FSUIPCX Offset Status.pdf" in the "Modules/FSUIPC Documents" folder.

If you haven't already seen it, please look at the Example Application -> "Advanced Concepts" -> "AC001_RadioFrequencies". This shows you how to use these BCD type offsets.

Also note that offsets 0x034E and 0x3118 are for FSX and earlier and won't show the narrower frequency spacing allowed in P3D and later. For the newer COM frequencies see offsets from 0x05C4. These are not BCD format however, just a floating point number.

Paul

Share this post


Link to post
Share on other sites
On 17/02/2020 at 10:23, Paul Henty said:

Eu preferiria não. Já passei muitos meses escrevendo extensos códigos de exemplo e modelos de aplicativos. Está tudo disponível aqui:

http://fsuipc.paulhenty.com/#downloads

O aplicativo de exemplo contém todos os exemplos que você solicita.

Quando você cria um novo projeto a partir de um modelo, não haverá documentos abertos. Você precisa selecionar algo no gerenciador de soluções.

Ou o seu explorador de soluções também está vazio?

Paulo

Nao consigo executar os exemplos devido a estes erros. Podem me ajudar?

Gravidade    Código    Descrição    Projeto    Caminho    Arquivo    Linha    Estado de Supressão
Erro        não foi possível processar o arquivo ctlAbout.resx porque ele está na Internet ou na zona restrita ou tem a marca da Web no arquivo. Remova a marca da Web se você quiser processar esses arquivos.    FSUIPCExampleCode_CS                
Gravidade    Código    Descrição    Projeto    Caminho    Arquivo    Linha    Estado de Supressão
Erro        não foi possível processar o arquivo ctlDonations.resx porque ele está na Internet ou na zona restrita ou tem a marca da Web no arquivo. Remova a marca da Web se você quiser processar esses arquivos.    FSUIPCExampleCode_CS                
Gravidade    Código    Descrição    Projeto    Caminho    Arquivo    Linha    Estado de Supressão
Erro        não foi possível processar o arquivo ctlExample.resx porque ele está na Internet ou na zona restrita ou tem a marca da Web no arquivo. Remova a marca da Web se você quiser processar esses arquivos.    FSUIPCExampleCode_CS                
Gravidade    Código    Descrição    Projeto    Caminho    Arquivo    Linha    Estado de Supressão
Erro        não foi possível processar o arquivo LonLatHelperClasses\LL003_UsingLatLonAreas.resx porque ele está na Internet ou na zona restrita ou tem a marca da Web no arquivo. Remova a marca da Web se você quiser processar esses arquivos.    FSUIPCExampleCode_CS                
 

Share this post


Link to post
Share on other sites

Não consigo executar os exemplos devido a esses erros. Podem me ajudar?

Gravidade Código Descrição Projeto Caminho Arquivo Linha Estado de Supressão O
erro não foi possível processar o arquivo ctlAbout.resx porque ele está na Internet ou na zona restrita ou tem uma marca da Web no arquivo. Remova uma marca da Web se você desejar processar esses arquivos. FSUIPCExampleCode_CS                
Gravidade Código Descrição Projeto Caminho Arquivo Linha Estado de Supressão O
erro não foi possível processar o arquivo ctlDonations.resx porque ele está na Internet ou na zona restrita ou tem uma marca da Web no arquivo. Remova uma marca da Web se você desejar processar esses arquivos. FSUIPCExampleCode_CS                
Gravidade Código Descrição Projeto Caminho Arquivo Linha Estado de Supressão O
erro não foi possível processar o arquivo ctlExample.resx porque ele está na Internet ou na zona restrita ou tem uma marca da Web no arquivo. Remova uma marca da Web se você desejar processar esses arquivos. FSUIPCExampleCode_CS                
Gravidade Código Descrição Projeto Caminho Arquivo Linha Estado de Supressão O
erro não foi possível processar o arquivo LonLatHelperClasses \ LL003_UsingLatLonAreas.resx porque ele está na Internet ou em uma zona restrita ou tem uma marca da Web no arquivo. Remova uma marca da Web se você desejar processar esses arquivos. FSUIPCExampleCode_CS   

Share this post


Link to post
Share on other sites

Hi Luis,

The error is because the files are not being trusted by your PC.

Here are some things you can try:

1. Go to the properties of the .ZIP file (Right-Click -> Properties). If it says the file is blocked, Check the box to Unblock it. Then unzip it again. Here is a example.

image.png.f1096eb9769ebc38c32a4d084f1cd9f6.png

 

2. If you're opening the example application from a network drive, or from a cloud drive, copy the solution to your local disk.

3. Try adding the folder where your example application is stored to the trusted folders in Visual Studio:

Tools -> Options -> Environment -> Trust Settings -> Configure Trust Settings:

image.png.0e7bf127d25763bb8b9891453e20cf54.png

Paul

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.

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.