Jump to content
The simFlight Network Forums

FSUIPC Client DLL for .NET - Version 2.0


Recommended Posts

Hi Paul

I know this is a dumb question, but I am stuck. I have added three lines to your FSUIPC example, (which is wonderfull) I have dim fs1n1 as integer, with &h989 offset. next two lines are below. I put them in the timer1 as I think thats were they need to go, but I can't see any thing in the textbox1 and all code below the 2 lins don;t update. If I remove The (* 100) then the rest of the code below update and I see a large number in the textbox. I am wanting to get the eng 1 N1 value. I don't see what I am doing wrong.

could you show me the proper syntex for getting the N1 value. Ron.

Try

' Process the default group

FSUIPCConnection.Process()

' IAS - Simple integer returned so just divide as per the

' FSUIPC documentation for this offset and display the result.

Dim airpeedKnots As Double = (airSpeed.Value / 128D)

Me.txtIAS.Text = airpeedKnots.ToString("f1")

' my code ron

Dim eng1n1 As Double = (fs1n1.Value * 100 / 16384)

Me.TextBox1.Text = eng1n1.ToString("f1")

' Avionics Master Switch

Me.chkAvionics.Checked = (avionics.Value > 0) ' 0 = Off, 1 = On.

ECT............

Link to comment
Share on other sites

I know this is a dumb question, but I am stuck. I have added three lines to your FSUIPC example, (which is wonderfull) I have dim fs1n1 as integer, with &h989 offset.

Sorry to butt in, but offset &h989 is part way through the Engine 2 Turbine Temperature value, which is a 4-byte offset starting at 0x0988.

Pete

Link to comment
Share on other sites

Good catch, I ment to say offset &h898, sorry, Still, any sugestions?.

Not really. Not a language i know, nor the library. But it occurs to me that if in this line

Dim eng1n1 As Double = (fs1n1.Value * 100 / 16384)

the value of offset 0x898 is multiplied by 100 in a 16-bit word before being divided by 16384, then it would overflow. And of course, conversely, dividing first would render zero. Shouldn't the value be allowed to be read into the double before being so manipulated?

If this should happen in any case in this language, forgive me. I don't really understand it.

Regards

Pete

Link to comment
Share on other sites

the value of offset 0x898 is multiplied by 100 in a 16-bit word before being divided by 16384, then it would overflow. And of course, conversely, dividing first would render zero.

I think that's what happening here. The literals you are defining in this line are all integers because you haven't told VB otherwise:

Dim eng1n1 As Double = (fs1n1.Value * 100 / 16384)

So everything to the right of the equals is happening as integers, not double floating points.

If you set the literals to be doubles then the VB compiler will convert the integer value from fs1n1.Value to a double first. Then all the maths is done as doubles. So try this:

Dim eng1n1 As Double = (fs1n1.Value * 100D / 16384D)

Paul

Link to comment
Share on other sites

Hi Paul

Yes, that works as well, I guess the D means double, Ok BUT, I still see a very large number in the textbox. "1659200.0" with eng not running. How do I format that number to read as 0.0

Dim eng1n1 As Double = (fs1n1.Value * 100D / 16384D)

Me.TextBox1.Text = eng1n1.ToString("f1")

("#.#")???? I don't know. Ron.

Link to comment
Share on other sites

I still see a very large number in the textbox. "1659200.0" with eng not running.

OK I've just looked at the FSUIPC Programmer's guide - the problem is not with the conversion code but with your offset declaration.

You say you've declared it as an Integer (4 bytes), but the docs say it's only 2 bytes. So you need to declare it as a 2-byte integer or 'Short' in VB. See my User Guide for a table of what VB types to use for the various offset lengths and types.

At the moment you are getting data from 0x898 and the next offset as well (0x89A) all rolled into one value.

So you need this:

Dim fs1n1 As Offset(Of Short) = New Offset(Of Short)(&H898)

Paul

Link to comment
Share on other sites

Paul !!!!!

Thank you so much. You are a True wonder. You and Mr. Dawson, YES that's It, it works fine. Just to let you and pete know. I have writen several hundreds of lines of code, using you example as a templete, I am writing my own version of PM Systems,lower EICAS pages as Enrico has not. for the B777. I am well on the way, learning this NEW TO ME vb.net, I was a vb.6 users for years. I'll still have some graphic questions to come, but for now I can now start the APU and let the eng1 and eng2 gens go on line. I'll, if you don't mind, keep you posted on my progress. Again thank you and pete for doing this. yours, Ron.

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

I can't change FS time.

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim zminute As Offset(Of Byte()) = New FSUIPC.Offset(Of Byte())(&H23C, 10)

        zminute.value(0) =  zminute.value(0) - 2
        FSUIPCConnection.Process()
End Sub


Please give me sample code..

Tinsukou

Link to comment
Share on other sites

Hi,

I can't change FS time.

Please give me sample code..

Tinsukou

Example of setting the local or UTC time from VB.NET...

    Dim zmin As Offset(Of Byte) = New FSUIPC.Offset(Of Byte)("time", &H23C)
    Dim zhour As Offset(Of Byte) = New FSUIPC.Offset(Of Byte)("time", &H23B)
    Dim second As Offset(Of Byte) = New FSUIPC.Offset(Of Byte)("time", &H23A)
    Dim hour As Offset(Of Byte) = New FSUIPC.Offset(Of Byte)("time", &H238)
    Dim min As Offset(Of Byte) = New FSUIPC.Offset(Of Byte)("time", &H239)

    Private Sub btnSetTime_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetLocalTime.Click

        ' set Local time to 20:33:05
        hour.Value = 20
        min.Value = 33
        second.Value = 5
        FSUIPCConnection.Process("time")

        ' OR set UTC (zulu) time to to 20:33:05
        'zhour.Value = 20
        'zmin.Value = 33
        'second.Value = 5
        'FSUIPCConnection.Process("time")

    End Sub

Paul

Link to comment
Share on other sites

How can I delete AI traffic or send KEYs like "Traffic Tool Box"

FSUIPC has a facility at offset 0x2900 that sends FS controls to the AI traffic. The documentation describes its use, although it is not clear which FS controls work with AI traffic. You will need to experiment.

To delete an AI Plane you can send control 0xFFFF. The example code for this is below. The ID for the AI Plane can be found using the ID property of the AIPlaneInfo class using my DLL. See my documentation and the sample application for getting AI Traffic information.

Alternatively Pete's TrafficLook.exe program will show you AI traffic with the ID in the 'REF' column. Note these are shown as positive numbers when they are actually negative.

The same sample code can be used to send any other controls you want. Just change the control number and assign a parameter if required.

    Dim aiControl_ID As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)("AIControl", &H2900)
    Dim aiControl_Control As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)("AIControl", &H2904)
    Dim aiControl_Param As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)("AIControl", &H2908)

    Private Sub deleteAIPlane(ByVal aiPlaneID As Integer)
        aiControl_Control.Value = &HFFFF ' special DELETE control
        aiControl_Param.Value = 0 ' no Parameter for delete
        aiControl_ID.Value = aiPlaneID ' Always write the ID value AFTER the control and paramter
        FSUIPCConnection.Process("AIControl")
    End Sub

Paul

Link to comment
Share on other sites

Hi Pete:

I have made very good progress on my B777 overhead software and have 2 questions

1) I am using offsets 66c0-66ff. If my PGM works well, Can I keep these offset,after rights, Lic, and all, or will I need to use new offset? Can I just make up offsets?

2) How do I know what the offset type is, IE is it a BYTE, DOUBLE,SHORT, LONG, FLOAT,ARRAY ECT.....

I would like to use BitArrays for this as they are most easy to write in VB 2010.net.

Ron.

Link to comment
Share on other sites

I have made very good progress on my B777 overhead software and have 2 questions

1) I am using offsets 66c0-66ff. If my PGM works well, Can I keep these offset,after rights, Lic, and all, or will I need to use new offset? Can I just make up offsets?

2) How do I know what the offset type is, IE is it a BYTE, DOUBLE,SHORT, LONG, FLOAT,ARRAY ECT.....

I would like to use BitArrays for this as they are most easy to write in VB 2010.net.

Is this a question about "FSUIPC Client DLL for .NET - Version 2.0" (i.e. this thread)? If so I'll wait for the author to answer. If not, please re-post in a new, properly titled, thread in the Support Forum. (You are lucky i spotted the message -- I don't normally visit other folks' threads).

Regards

Pete

Link to comment
Share on other sites

    Dim aiControl_ID As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)("AIControl", &H2900)
    Dim aiControl_Control As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)("AIControl", &H2904)
    Dim aiControl_Param As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)("AIControl", &H2908)

    Private Sub deleteAIPlane(ByVal aiPlaneID As Integer)
        aiControl_Control.Value = &HFFFF ' special DELETE control
        aiControl_Param.Value = 0 ' no Parameter for delete
        aiControl_ID.Value = aiPlaneID ' Always write the ID value AFTER the control and paramter
        FSUIPCConnection.Process("AIControl")
    End Sub

Thank you Paul!!

The earthquake occurred in Japan, and it was very terrible.

I'm sorry for delaying.

Link to comment
Share on other sites

hi all.. i'm trying to see my aplication in a fligth simulator menu. do you know how to put my application inside fligth simulator menu, like fsuipc inside modules.

thank's a lot for your help

regards

demian

If you mean you want to run your application as a proper FS module, inside the FS application itself, then the short answer is you can't. You need to write modules in C or C++, I don't know anyone who has written one in C# or VB.NET. There may be a way of doing it but it would require the use of the FSX SDK if it's at all possible.

Even if you could get a module working, you cannot use my DLL to communicate with FSUIPC. My DLL uses the external FSUIPC interface. Proper modules need to use the internal FSUIPC interface.

However, if you just want to create a menu item in FS that does something then look at offset 0x2FE0.

Paul

Link to comment
Share on other sites

If you mean you want to run your application as a proper FS module, inside the FS application itself, then the short answer is you can't. You need to write modules in C or C++, I don't know anyone who has written one in C# or VB.NET. There may be a way of doing it but it would require the use of the FSX SDK if it's at all possible.

Even if you could get a module working, you cannot use my DLL to communicate with FSUIPC. My DLL uses the external FSUIPC interface. Proper modules need to use the internal FSUIPC interface.

However, if you just want to create a menu item in FS that does something then look at offset 0x2FE0.

Paul

thank's a lot paul,

Link to comment
Share on other sites

  • 2 months later...

I am trying to use this v2.0 client in a .NET 3.5 application but I keep on getting this exception:

"BadImageFormatException

Could not load file or assembly 'FSUIPCClient, Version=2.0.4008.2,Culture=neutral,PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."

I have downloaded and relinked several times just in case that was the problem but it is not. The exception keeps on happening when using your v2.0 client library.

Link to comment
Share on other sites

I am trying to use this v2.0 client in a .NET 3.5 application but I keep on getting this exception:

"BadImageFormatException

Could not load file or assembly 'FSUIPCClient, Version=2.0.4008.2,Culture=neutral,PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format."

Hi,

It sounds like you're developing on a 64bit OS and have your Visual Studio project set to target any processor type (the default setting). This is the usual cause of this error.

You must set your project to target only x86 processors. (See the Build tab in the project properties window).

My DLL is 32 bit only and cannot be linked into a 64 bit app. (It can't be compiled to run as a 64bit DLL because it will not be able to talk to FSUIPC which is running in a 32-bit program (FS)).

Paul

  • Upvote 1
Link to comment
Share on other sites

Hi,

It sounds like you're developing on a 64bit OS and have your Visual Studio project set to target any processor type (the default setting). This is the usual cause of this error.

You must set your project to target only x86 processors. (See the Build tab in the project properties window).

I made that change but was unsure so you have confirmed it. Thanks a million! It had been quite some time since I used this client (1.x) but now I am up to v2. Always liked this library, the ACARS application of my VA stopped functioning and the developer doesn't respond so I figured I would better write my own FS ACARS application.

Link to comment
Share on other sites

Paul,

First I want to compliment you for developing this fantastic DLL.

I'm a asp.net developer by profession and i'm writing my own Fokker 70/100 System software. I got started when i found your .net dll, cause there simply nothing around for a Fokker aircraft (all boeing guys i Guess)

I'm currently working on the ND and there is something i dont really understand. According to the programmers guide for FSUIPC the offsets 0C48 and 0C59 must give a value between -127 and 127.

When i dim this value : <code>Dim _nav1LocNeedle As Offset(Of Byte) = New Offset(Of Byte)(&HC48)</code> i'm getting values i don't understand, theres nothing in the negative returning ;-)

What am i doing wrong, any ideas?

I attached a screenie (offcourse its much bigger in real life) of the work in progress, and there are values on it that are debug values for me. ( The two values of 127 are the real and calculated values for the needle position)

grtz

Gert Polkerman

post-20943-0-01960300-1307657691_thumb.j

Link to comment
Share on other sites

I'm currently working on the ND and there is something i dont really understand. According to the programmers guide for FSUIPC the offsets 0C48 and 0C59 must give a value between -127 and 127.

When i dim this value : <code>Dim _nav1LocNeedle As Offset(Of Byte) = New Offset(Of Byte)(&HC48)</code> i'm getting values i don't understand, theres nothing in the negative returning ;-)

I'll have to leave it to Paul to tell you what type a signed byte is in this language (mine in C or ASM), but usually the term "Byte" used as a type refers to 8 bits treated as unsigned, so ranging from 0 to 255 inclusive. The data is the same, it's the interpretation that will be incorrect because of the type you are declaring: 255 unsigned is -1 signed, 128 unsigned is -128 signed, etc.

Regards

Pete

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • 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.