Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,654
  • Joined

  • Days Won

    74

Posts posted by Paul Henty

  1. Hi,

    I looks like you're using my .NET Client DLL. In the ZIP there are some comprehensive documents that explain how to use the offsets. This includes a very helpful table showing you what VB type to use depending on the length and type of the Offset.

    Also the sample VB program shows exactly how to use read and write offsets.

    Please do read the documentation and help that I've already provided.

    H90C is the offset 090C

    That's not quite correct. The hex number is in VB is 90C not H90C. The H bit is not part of the number - it just tells VB that the number following is in Hex and not decimal.

    When you see a C hex number like 0x090C then in VB you just take off the 0x and add &H. So 0x090C becomes &H090C. VB may remove the leading 0 because it's redundent giving &H90C.

    As Pete said offset 0x090C is a 4 Byte (32-Bit) floating point offset. My documentation clearly states that this should be declared as 'Single' in VB.NET.

    Also you need a Process() call to actually read the data. This is also explained in documentation and the sample code.

    So your code should look something more like this.

    Dim Fuel As Offset(Of Single) = New FSUIPC.Offset(Of Single)(&H90C)
    
    Public Sub MySub()
        FSUIPCConnection.Process()
        Dim fuelleft As Single = (Fuel.Value)
        Label26.Text = fuelleft.ToString("f1")
    End Sub
    

    Paul

  2. Hi Pete,

    Here's the WideClient log with the 2 AI Plane writes to 0x1f80:

    ********* WideClient Log [version 6.78] Class=FS98MAIN *********
    Date (dmy): 18/09/09, Time 13:02:01.746: Client name is PJHLAPTOP
          109 Timing Thread Started
          141 SendReq Thread Started
          468 Trying TCP/IP host "FSVisuals" port 8002 ...
          468Okay, IP Address = 192.168.0.1
        61839 Trying TCP/IP host "FSVisuals" port 8002 ...
        61839Okay, IP Address = 192.168.0.1
       123600 Trying TCP/IP host "FSVisuals" port 8002 ...
       123600Okay, IP Address = 192.168.0.1
       184861 Trying TCP/IP host "FSVisuals" port 8002 ...
       184861Okay, IP Address = 192.168.0.1
       206140 Sending computer name and requesting base data ...
       206140 Button Thread Started
       282393 New Client Application: "TestApp" (Id=4492)
       282393    0 ReadLocal: Offset=3304, Size=0004
                00 00 34 45 
       282393    0 ReadLocal: Offset=3308, Size=0004
                08 00 DE FA 
       287666      Write: Offset=1F80, Size=0028
                01 00 00 00 90 B1 44 42 38 AF EE BF CD 50 FA 45 
                7C 49 64 00 03 00 50 41 55 4C 31 00 00 00 00 00 
                00 00 00 00 00 8C 45 23 
       287666      Write: Offset=1F80, Size=0028
                02 00 00 00 A1 C2 44 42 16 8D EC BF 66 86 7C 44 
                E4 4A 65 00 03 00 50 41 55 4C 32 00 00 00 00 00 
                00 00 00 00 00 8C 45 24 
       299054 Timing Thread Terminated
       299054 Button Thread Terminated
       299054 SendReq Thread Terminated
    
       299054 ****** End of session performance summary ******
       299054 Total time connected = 93 seconds
       299054 Reception maximum:  31 frames/sec, 846 bytes/sec
       299054 Reception average whilst connected:  24 frames/sec, 621 bytes/sec
       299054 Transmission maximum:  1 frames/sec, 79 bytes/sec
       299054 Transmission average whilst connected:  0 frames/sec, 22 bytes/sec
       299054 Max receive buffer = 595, Max send depth = 1, Send frames lost = 0
    
       299054 **************** Individual client application activity ****************
       299054 Client 4492 requests: 2 (Ave 0/sec), Data: 144 bytes (1/sec), Average 72 bytes/Process
    
       299054 ********* Log file closed (Buffers: MaxUsed 2, Alloc 2244 Freed 2244 Refused 0) *********
    

    There's no hurry on my part - I'm just adding a feature into my .NET client dll to make it easier for .net programmers to read/write AI traffic.

    Thanks,

    Paul

  3. Hi Pete,

    There seems to be a problem writing AI traffic in FSUIPC 4 (currently installed version 4.534) using offset 0x1F80.

    The FSX Status document says it's OK but it's doing some weird stuff.

    If I run the code on my FS9 setup it's OK. Here's a pic of TrafficLook with my 2 injected planes at the top - Paul1 and Paul2:

    If switch the wideclient to my FSX machine and run the same code I get this:

    G-TEXR was one of the AI generated by FSX.

    After this happens FSUIPC4 also stops responding to any IPC requests.

    Can you have a look at this please?

    Thanks,

    Paul

    post-6881-128689695583_thumb.jpg

    post-6881-12868969559_thumb.jpg

  4. There's nothing in my DLL that will add any delay or jerkyness to the data. The exchange of data between the DLL and FSUIPC follows exactly the C SDK and is mostly done with unmanaged code.

    I think Pete is right about the need for interpolation code. Many years ago I did some work on an external panel that I wrote in DirectX. It too was visibly 'stepping' until I added some smoothing code to it. The problem you've got is that the values from FS only come at a fixed interval which is generally not small enough to make a gauge look really smooth. You need to update the gauge state more often than you get the data back. That way you can fill in the gaps between the data points making your gauge look smooth.

    Paul

  5. Hi Andi,

    I'm Paul - I wrote the .NET client DLL.

    There is no 'connected' property you can check. There isn't much to be gained by adding one in either.

    The only way you can get an 'open connection' is by calling FSUIPCConnection.Open() and your code must make this call. Therefore, you can keep track of if you've opened the connection or not yourself. The same goes for the Close() method.

    If you're looking for a way to tell if Flight Sim has been shut down after you've called Open() then the correct way to do this by catching the exception thrown from the read. This is how things are done correctly in .NET programming.

    The only way my DLL could tell if the connection is still established is by doing a 'fake' read and catching the exception, so there's not much to be gained by building this into a 'connected' property.

    I hope this explains why there isn't anything like a 'connected' property you can check. If you need any more info just ask...

    Paul

  6. Hi Pete,

    I've been trying to use the FSUIPC facilities for 'Reading full AI Traffic identity strings' at 0xD000. This is for FSX, using FSUIPC version 4.520.

    I can't get this to work. I keep getting back 48 zeros.

    I'm think I'm doing everything right as described in the documentation, although I note it says this is untested in FSX and requires feedback. Maybe this isn't working?

    Here is the log of an attempt in case I'm doing something daft:

    ********* FSUIPC4, Version 4.520 by Pete Dowson *********
    User Name="Paul Henty"
    User Addr="paul.henty@"
    FSUIPC4 Key is provided
    WideFS7 Key is provided
    [Continuation log requested by user]
    Running inside FSX (using SimConnect Acc/SP2 Oct07)
    Module base=61000000
    Wind smoothing fix is fully installed
       536828 System time = 23:24:25, Simulator time = 17:27:56 (16:27Z)
       536828 LogOptions changed, now 00000000 0000000D
       546891 WRITE0  D004,   4 bytes: 01 00 00 00                                      ....
       546891  READ0  D008,   4 bytes: E9 FB E9 01                                      ....
       546891 WRITE0  D00C,   4 bytes: 0E FE FF FF                                      ....
       546891 WRITE0  D000,   4 bytes: 10 10 00 00                                      ....
       546891  READ0  D008,   4 bytes: D6 D9 EA 01                                      ....
       546891  READ0  D010,  48 bytes: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
       546891                           00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
       546891                           00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
       702781 Sim stopped: average frame rate for last 166 secs = 18.4 fps
       708969 LogOptions changed, now 00000000 00000001

    Also, I had to generate this log by running my app on the FS computer. I usually develop on a different machine via WideClient, but the log wouldn't record any IPC reads I made via WideClient. It did log the IPC writes OK though. I'm using WideClient.exe version 6.7.8.0.

    Thanks for your help,

    Paul

  7. Hi Corry,

    You were on the right track with the Byte[]. In a nutshell you need:

    Read the housekeeping headers to find the number of slots in use and which have changed.

    For each slot that's changed, work out the offset of the slot in the two large AI data tables.

    Read the slot data into a byte array.

    Decode the raw bytes in the byte array into usable .NET variable types.

    The last stage requires decoding the relevant bytes in the Byte array using the BitConverter class and some ASCII string decoder classes for the string types.

    It's all pretty complicated to be honest. However...

    I have an unreleased 1.4 version of the DLL that lets you get access to all the AI in a really easy .NET way. The AI traffic is presented as a collection of AIPlaneInfo classes. You can just access each plane as a class and get its properties. There are also properties that aren't provided by FSUIPC like distance and bearing from the player. You can also filter the traffic tables to ignore planes over a certain distance or altitude etc.

    The reason it's unreleased is I've not done the documentation yet and no one has tested it (except me). I'll be happy to PM you the 1.4 version with some example code if you want to try it and let me know how it goes.

    If you prefer to do it yourself I can help you some more, but be warned that the AI code in the DLL runs to nearly 500 lines. ;-) Let me know what you want to do.

    BTW, if there is anyone else reading this who wants to try the new AI traffic features, just send me a PM.

    Paul

  8. If the gauges are for your use only, then you can use the 64 byte 'General Use' block from 66C0. (See SDK documentation).

    If other people are going to use your gauges (Freeware or Payware) then you should apply to Pete to allocate you the number of offsets you require. He's away until June 30th though.

    Paul

  9. Hi Rullysimo

    Have you tried specifying the server (FS computer) in the WideClient.ini files of your client PCs? Set either Server= or ServerIPAddr=, see the documentation for details.

    Sometimes the automatic discovery doesn't work. I think when the computers are in different windows workgroup is the main cause of this.

    I recommend you also look at the wideserver.log in the FS modules folder and the WideClient.log files on the client PCs. These may tell you what's wrong. You could also paste them in this thread - someone might be able to spot the problem.

    Paul

  10.   Dim altitude As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H570)

    Pete and I have tried to explain that 570 is the FRACTIONAL part of the altitude - i.e. AFTER the decimal place.

    I've told you to how to fix this:

     Dim altitude As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H574)

    And you've not changed your code. Your code still says 570. All you need to do is change your offset from 570 to 574.

    Also note that the number you will get is in Metres. If you want Feet you'll need to convert it - (Multiply by 3.2808399).

    If Pete and I are going to help you please read what we're saying to you and make the changes we suggest. Otherwise we're all wasting our time.

    Paul

  11. So can I get an example please of the timer thing

    You already have an example of the timer. The example VB.NET application I supplied with the DLL has a timer in it. Everything you need is there.

    Your problem maybe that you've not added the timer component to the form. You need to drag it from the toolbox (where you get buttons and textboxes from) onto your form. Then add the Tick() event code by double clicking it.

        Dim Heading As New FSUIPC.Offset(Of Double)("indh", &H2CC)

    I have already group it.

    I know. That's the problem. You have grouped it, but you're never processing that group.

    As I said in the last message, you need to process the group:

    FSUIPCConnection.Process("indh")

    Did you add that line?

    The best thing for you to do at the moment is remove all the grouping:

    Just declare the heading like this:

    Dim Heading As New FSUIPC.Offset(Of Double)(&H2CC)

    That should give you a value for the heading.

    If you're really stuck on getting the timer to work then send me the form code (cut and paste) via private message on the forum. It's difficult to help without the code. I'll make the timer work and send it back to you with comments showing what I did.

    Paul

  12. Hi Topdog,

    How can I keep looping that just put that in the timer function thing

    The timer loops for you. It keeps calling the Tick() event at the interval that you set. Make sure that you set Timer1.Enabled = True to turn it on and set Timer1.Interval to the number of milliseconds you want between ticks. e.g to update 10 times per second:

    Timer1.Interval = 100
    Timer1.Enabled = True

    Also the following code above is giving me 000 when my current heading 197

    From looking at your code I can see that the heading is not being updated from FSUIPC. You have defined it to be in a 'group' called "indh", but then you never process that group, only the default group. Somewhere in you code you need:

    FSUIPCConnection.Process("indh")

    The grouping feature is explained in the UserGuide.htm. Please read this if you haven't already.

    Paul

  13. How come when I got the heading info it came out to a big number with the actual heading to the left of the decimal.

    Because FSUIPC gives you a precise value for the heading, that is, values in-between each degree.

    how can I just have it just show 050

    This is nothing to do with FSUIPC or the DLL, you just use normal programming techniques to format the number to how you want it. In the case of VB.NET you can use one of the overloads of the ToString() method on the Double class:

    Me.myTextBox.Text = Heading.Value.ToString("000")

    Also how can I have the numbers update automatically for it to change

    You need to call Process() again and then get the new values from the offsets and display them on the form again. To do this at regular intervals you need to add a timer to the form and put the update code in the Tick() event. This is clearly demonstrated in the sample application.

    Paul

  14. Can somebody please give an example of how I can get like the aircraft speed or altitude from the FS into visual basic?

    Hi Topdog,

    There is an example VB.NET application supplied with my DLL. It displays various types of data on a form.

    In summary though, you need to call the FSUIPCConnection.Process() method to read the data from FS. Then you read the values from the .Value property on the offsets. e.g.

    Me.txtMyTextBox.Text = AirSpeed.Value.ToString()

    Please have a look at the sample application as it explains everything in detail and also shows you how to setup a timer loop to keep everything updating on a regular basis. If you still need help, feel free to post more questions.

    Paul

  15. I've changed your posted code to use a Byte type instead of a BitArray:

        ' Declare our interest in offset 310A, which is a byte in length (and write only) 
        Dim RudderDisable As Offset(Of Byte) = New FSUIPC.Offset(Of Byte)(&H310A, True)
    
        Private Sub Rudder_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Rudder.CheckedChanged
            ' If the checkbox is checked we write 4 to this offset to set bit 2, else we write 0 to clear bit 2.
            Me.RudderDisable.Value = IIf(Me.Rudder.Checked, 4, 0)
        End Sub
    

    You do need to write to this offset regularly or it will 'time out' after 10 seconds. I suggest you move the line in the checkbox change event to your normal process loop, or setup another timer to handle this every 5 seconds or so. If you want to do it properly I suggest putting this offset in it's own group, the you can process this group independently of the other offsets. Here is the code to do this with another Timer called Timer2 (you'll need to adjust the interval on Timer2):

        ' Declare our interest in offset 310A, which is a byte in length (and write only)
        ' and put it in it's own group so we can deal with it seperately.
        Dim RudderDisable As Offset(Of Byte) = New FSUIPC.Offset(Of Byte)("Rudder", &H310A, True)
    
        Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
            ' If the checkbox is checked we write 4 to this offset to set bit 2, else we write 0 to clear bit 2.
            Me.RudderDisable.Value = IIf(Me.Rudder.Checked, 4, 0)
            ' Now process the group with the Rudder control in
            FSUIPCConnection.Process("Rudder")
        End Sub
    

    If you need any more help just ask...

    Paul

  16. Hi,

    I think you've run into a problem with the way my DLL handles BitArrays. The write only happens when the data in the BitArray is changed from the last value written or read.

    I'll investigate this in more detail using your example and I'll come up with a way of making the DLL work properly with these type of offsets. (Those where you have to keep writing the same value and you are using a 'reference' data type like a BitArray).

    For now, if you declare this offset as a 'Byte' instead of a BitArray, make it readonly (very important), and just assign 4 (or whatever other values you need) then it should work as you expect. ('Value' types like Byte won't have the same problem because they write when assigned to (even if you assign the same value)).

    Let me know if you still cannot make it work using Byte.

    Paul

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