Jump to content
The simFlight Network Forums

Paul Henty

Members
  • Posts

    1,653
  • Joined

  • Days Won

    74

Posts posted by Paul Henty

  1. EDIT: Pete is also up late and beat me to it!

    My code at top of page:

        Dim hour As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H238) ' Hour - For total hour caculation
        Dim minute As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H239) ' Minutes - For total hour caculation
        Dim second As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H23A) ' Seconds - For total hour caculation

    Mitch

    Hi Mitch,

    These three offsets are only 1 byte long (as specified in the FSUIPC programmer's guide). You have declared them as type Integer which is 4 bytes long.

    My documentation supplied with the DLL (UserGuide.htm) tells you that for 1 byte offsets you need to use type 'Byte' in Visual Basic , e.g.

        Dim hour As Offset(Of Byte) = New FSUIPC.Offset(Of Byte)(&H238) ' Hour - For total hour caculation

    Let me know if you have more questions about this.

    Paul

  2. Those are a preview of what i get with that exact code.

    The data you're getting from FSUIPC is 100% correct.

    The two values represent the same lon/latitude, they are just in a different format.

    The data from FSUIPC is decimal degrees, the display in FS is in Degrees and Minutes. Just as 1 hour and 15 minutes isn't 1.15 hours - it's 1.25 (1 and a quarter hours), so 47 degrees and 25.89 minutes isn't 47.2589 - it's 47.431507.

    To convert your decimal degrees into the degrees and minutes you need to take the decimal portion (in the case of your latitude 0.431507) and multiply by 60. (60 minutes in a degree).

    If you do that you'll get 25.89 which is what FS is showing.

    Paul

  3. BTW, do statements like

    latHi = "0"

    really work, and give no compilation error? You declared "latHi" as a Double yet you appear to be assigning a string to it!

    Yeah they do work. VB is not a strongly-typed language so no type checking is performed by a vb compiler. You don't even need to declare variables. If there is a type-mismatch in the code, as in the above example, the vb runtime attempts a conversion. If it can't do it it'll give a runtime error. If it can convert then everything continues normally and the programmer is none-the-wiser.

    If a variable is used without having been declared it gets declared on-the-fly by the vb runtime as a 'Variant' type.

    It certainly makes it easy for beginners to get a program working without learning about types and casts; but I rather tend to view that it does more harm than good in the long run.

    Paul

  4. Hi javiercuellar,

    Each Process() call you make has an impact on performance because of the overheads involved in getting the data from FSUIPC. The amount of data you read in each process is not that significant in terms of speed. So getting 30 offsets in one process() is always going to be faster than making 2 process() calls of 15 offsets each.

    The grouping is good if you have groups of offsets that need to be updated at different rates, or updated conditionally like your example.

    In the 1.3 version of the DLL you need to call each group in a separate Process() call, so updating 3 groups would need 3 process() calls. This was a slight drawback in terms of performance.

    I've since added a feature (for the poster above you) that allows you to process multiple groups in one process call. The DLL bundles them into a single FSUIPC call.

    I'll PM you the beta 1.4 version in a few minutes so you can try it out.

    If anyone else wants this feature, PM me and I'll send you the beta also.

    Paul

  5. To get to my question, basically based on those bools i am calling a Process({group_name} but in my timer_tick event handler, i might call Process 4 times (i have 4 groups).

    Is that much more resource consuming then rather calling Process() without any group name (when all the groups must be processed) ?

    Hi,

    Firstly, calling Process() without a group doesn't process all the groups. It only processes offsets that are not assigned to any group.

    Calling 4 Process()'s is not very efficient and will probably take about 4 times longer than calling the same number of offsets in one Process().

    At the moment the DLL does not allow you to process multiple groups in 1 Process() so you've no choice but to call Process() 4 times.

    I can add another overload to Process() that will take an array of groups. This will then bundle all the offsets in the given groups into 1 process call. I think this would be a very useful feature.

    I'll send you a beta version via PM for you to test when I've implemented it.

    Paul

  6. Hi,

    I can't see anything obviously wrong with your code.

    is this a) issue caused by my FSUIPC dll,

    You can easily tell if my DLL (or your code) is causing the problem by looking at FSInterogate. If FSInterogate is reporting 1s as well then it's very unlikely the problem lies with your or my code.

    i've tried with cessna, feelthere airbus A318, B777, PMDG MD-11 and so forth

    But surely all those aircraft have autopilots installed? Are you sure you've tried it with a plane without an autopilot? Maybe a glider (sailplane)?

    Paul

  7. Finally, my altitude is not working at all,

         int dwResult = -1;
    

    The altitude is marked in the SDK documentation as being 8 bytes. The same goes for the Lon and Lat. You must read these offsets into a variable large enough (8 bytes). An int in c# (on a 32 bit OS) is 4 bytes. You need a Long.

         long dwResult = -1;
    

    Obviously you can't then use the same dwResult variable for other offsets that are different lengths. You should really be defining specific variables to hold each bit of data you get back from FSUIPC, and typing them according to the specific FSUIPC offset.

    If you're not too far into development you might want to look at my FSUIPC Client DLL for .NET. It's far easier to use and more suited to .NET programming patterns than the old C# SDK that you are currently using.

    http://forums.simflight.com/viewtopic.php?f=54&t=53255

    It also has good documentation explaining how to access different types of offsets and whhich C# (or VB) data types you need to use.

    Paul

  8. I'm pretty sure that .BAS file will be for Visual Basic version 6.

    Visual Studio 2008 uses a different version of Visual Basic called VB.NET. It's a different language (although the syntax is very similar). That's why you're getting the errors.

    If you want to wirte FSUIPC apps in VB.NET using Visual Studio 2008 then go to this thread and download my .NET Client DLL.

    http://forums.simflight.com/viewtopic.php?f=54&t=53255

    It has extensive documentation and example applications to help you on your way.

    Paul

  9. Any errors in the code above?

    Can't see anything obviously wrong. As Pete says, there is no data being requested from FSUIPC. I can only imagine the Timer_Tick() isn't actually getting called.

    Try putting a breakpoint on one of the lines in Timer_Tick() to make sure it's being run.

    If it's not getting run then:

    Go to the form design view

    At the bottom, click on the Timer control.

    Go to the properties pane and put it into Event view by pressing the events button at the top of the pane.

    Make sure the Tick event has "Timer1_Tick()" as its value. I suspect this is blank at the moment.

    If this isn't the problem, and you are sure the Timer_Tick() sub is getting called, then let me know and I'll think about it some more.

    Paul

  10. 1. The data (heading, speed etc.) will not update with FS....its just 0

    Does the included sample VB.NET application work for you? If not there maybe something wrong with your FSUIPC install. If my app works then I'd need to see some code to see why yours isn't working. You can also use the FSUIPC logging features to see what values are being read from FSUIPC (if any).

    2. Dumb question, where do i get the codes e.g &H290 for the offsets? (i know &H means 'Hex')

    From the document "FSUIPC for Programmers.pdf" (FS9) or "FSUIPC4 Offsets status.pdf" (FSX) found in the FSUIPC SDK. Download it here:

    http://www.schiratti.com/dowson.html

    Paul

  11. Hi Werner,

    Looking at your code you don't seem to be doing the maths to get the Lattitude into the correct value.

    In the documentation is says:

    If your compiler supports long long (64-bit) integers then use such a variable to simply copy this 64-bit value

    into a double floating point variable and multiply by 90.0/(10001750.0 * 65536.0 * 65536.0).

    This tells you how to get the value out of that offset. You load it into a 64 bit integer (Long in VB.NET on a 32bit OS). Then you have to multiply the Long by 90.0/(10001750.0 * 65536.0 * 65536.0) to get the units right. The result of this calculation should be put into a Double.

    If you haven't gone too far with the old VB.NET SDK that you are using, I suggest you take a look at my FSUIPC Client DLL for .NET. It comes with extensive documentation and an example project in VB.NET. It is much easer to use than the SDK you are currently using.

    For example, if you use my DLL this is all the code you need to get the Lattitude and Longitude:

        Private latFS As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H560)
        Private lonFS As Offset(Of Long) = New FSUIPC.Offset(Of Long)(&H568)

        ' Convert Lat and Lon from FS Units into degrees (as a double).
        FSUIPCConnection.Process()
        Dim lat As Double = latFS.Value * 90D / (10001750D * 65536D * 65536D)
        Dim lon As Double = lonFS.Value * 360D / (65536D * 65536D * 65536D * 65536D)

    You can find it in the sticky at the top of this forum:

    http://forums.simflight.com/viewtopic.php?f=54&t=53255

    Paul

  12. Firstly, I made a small error in the above post, which I have now corrected. Pete's document says the data in the level offset is a percentage but it's actually a fraction. I've corrected the above post by scaling the data in the level offset by 100.

    Anyway - here is some code which will read the data from the two offsets I mentioned and calculate the remaining fuel in US Gallons for the Left tank:

    This code uses three text boxes to display the data. They are called:

    txtLeftTankCapacity

    txtLeftTankLevelPercent

    txtLeftTankLevelGallons

    You need to declare the two offsets:

        Dim leftTankCapacity As Offset(Of Integer) = New Offset(Of Integer)(&HB80)
        Dim leftTankLevel As Offset(Of Integer) = New Offset(Of Integer)(&HB7C)

    Here is a method (fired from a button) that will read the data and work out the amount of fuel left. The data is displayed in the text boxes.

        Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
            FSUIPCConnection.Process()
    
            ' 1. Display the capacity of the left tank in a text box (number of US Gallons when full)
            Me.txtLeftTankCapacity.Text = leftTankCapacity.Value.ToString()
    
            ' 2. Get the level of the left tank as a percentage (i.e. how full it is)
            Dim dblLeftTankLevelPercentage As Double = leftTankLevel.Value / 128D / 65535D * 100D
    
            ' 3. Display this in a text box
            Me.txtLeftTankLevelPercent.Text = dblLeftTankLevelPercentage.ToString("f2") & "%"
    
            ' 4. Work out how many gallons are left
            Dim dblLeftTankLevelGallons As Double = leftTankCapacity.Value * dblLeftTankLevelPercentage / 100
            ' Or, if you can also do it like this:
            'Dim dblLeftTankLevelGallons As Double = leftTankCapacity.Value * (leftTankLevel.Value / 128D / 65535D)
    
            ' 5. Display the amount left in the left tank in gallons
            Me.txtLeftTankLevelGallons.Text = dblLeftTankLevelGallons.ToString("f2")
        End Sub
    

    Regards,

    Paul

  13. is there anyway to read what is in that engine say the capasicty is 2500 and its at 1500 how can I get that 1500?

    The offset before it (0B7C) tell you how full the tank is as a percentage. So if the tank holds 2500 and there is 1500 left, this offset will give you back 60%.

    If this offset says 25% then the tank only has 625 US gallons left.

    Offset 0B7C is an Integer (4 bytes). The documentation says: "% * 128 * 65536" which means it's a percentage but it's been multiplied by 128 and then 65536 before being stored here. To get the percentage back you need to divide the integer in this offset by these numbers:

    Fuel left (%) = Offset value / 128 / 65536 * 100

    You can then work out the amount of fuel by using the capacity:

    Fuel left (us gallons) = Capacity * Fuel left (%) / 100

    Or you can do the whole lot in one go:

    Fuel left (us gallons) = Capacity offset * (fuel left offset / 128 / 65536)

    Paul

  14. Nicholas ,

    I ran your code here.

    It looks OK to me. I assume we're still talking about the fuel here.

    Your 'label26' is being regularly updated with the value of offset 0x090C - the amount of fuel used by Engine 1 in pounds. These looked sensible to me (I'm no expert on fuel use). As I increased the throttle this value increased at a faster rate as I would expect. When I shut down to engine this offset stopped changing.

    When you say it "doesn't work", what do you mean? Are you getting no values? The wrong values? If so, what are they?

    Also, do you realise this offset only works on FSX? It won't work on earlier versions like FS9.

    Paul

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

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