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

Hi!

Sorry for refreshing old topic but I can’t find solution for my problem.

On 2/23/2020 at 5:02 PM, michielsweb said:

                FSUIPCConnection.SendControlToFS(PMDG_737_NGX_Control.EVT_CDU_L_RTE, 0x20000000);
                Thread.Sleep(400);
                this.CDU0.RefreshData();
                string fmcrow = this.CDU0.Rows[2].ToString();
                string[] words = fmcrow.Split(' ');

                List<string> y = words.ToList<string>();
                y.RemoveAll(p => string.IsNullOrEmpty(p));
                words = y.ToArray();
                string dep = words[0];
                string arr = words[1];

 

 

I want to press CDU keys from my C# apps . I was trying to use FSUIPCConnection.SendControlToFS as described below, but this function is not available.

cdu_s.jpg.08cc56af940bd5d3fba2f12db893bbcf.jpg

What I missed?

 

Best regards
Piotr

 

Edited by piotr66

Share this post


Link to post
Share on other sites

Hi Piotr,

A few things that could cause this:

  • You don't have my client DLL added as a reference.
  • You don't have using FSUIPC; at the top of the class.
  • You must be using version 3 of my DLL (version 2 doesn't have SendControlToFS).

Please see my website for instructions on how to install the DLL or update from version 2 to the latest version (3.1.21)

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

Paul

Share this post


Link to post
Share on other sites

Hi!

Thank You very much for help.

Yes, this is a cause. I wasn’t use Yours version of client DLL. I was using version from FSUIPC_SDK.
So I remove previews version and add Yours version as You described. But one problem appears – after installation a NuGet package FSUIPCClientDLL I’ve got error: “CS1056 C# Unexpected character '\'”.
packages. Config look like:

 

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="FSUIPCClientDLL" version="3.1.21" targetFramework="net472" />
</packages>

Wat I did wrong?

Share this post


Link to post
Share on other sites

The packages.config look fine to me. Does Visual Studio say the error is in Packages.config or somewhere else? If you double-click it it should take you to the file and line with the problem.

Paul

Share this post


Link to post
Share on other sites

Ups! Sorry for bothering. Solution was so simple that I’m blushing.

The error was in my code. Accidentally I put character '\' between functions.

Sorry one more time and thank You for help.

Share this post


Link to post
Share on other sites

After last  screw-up I’m afraid to ask another question, but after few hours digging internet up, I haven’t find any solution and no choice.

Why I’m getting:

image.jpeg.938ce83253bcab31f3f853d0c8ae9b52.jpeg

Share this post


Link to post
Share on other sites

Hi Piotr,

It looks like you've used some example code written in Visual Basic.NET. 

C# uses [] to access array elements, not () like VB, so it would be:

string row3Text = cdu.Rows[2].ToString();
char R3C1Char = cdu.Rows[2].Cells[0].Symbol;

Paul

Share this post


Link to post
Share on other sites

Eh.. So simple and trivial.

And as always You right. I was trying to adopt code written in Visual Basic.NET from this topic. A dozen  times I was looking at FSUIPC Client DLL Documentation and name space members and didn’t notices difference. Eh..

For the future I will try do not asking forum to fast and look at problem one more time on the next day.

Thank You for help!

Share this post


Link to post
Share on other sites
5 hours ago, piotr66 said:

I was trying to adopt code written in Visual Basic.NET from this topic.

It may be worth checking out https://converter.telerik.com/ which is a rather useful C# -> VB.Net and the reverse converter.

It can quickly show you the structure of something you already have such as the examples you may be looking at.

Share this post


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

Interesting. I wil try, for sure. Thank You!

I've a 15,000+ line vb.net project (ACARS) that I'm converting to C# and it's helping immensely.

Share this post


Link to post
Share on other sites

ok small  update (hijakcing back my topic ;-))

currently i have the first sim info finaly displaying

and changing on the arduino mcp /radiopanel.

believe it or not but i managed to shrink a full radiopanel and mcp encoders on a saitek panel size whit 2 screens.
 

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.