Jump to content
The simFlight Network Forums

Recommended Posts

Posted
11 minutes ago, Frédéric-O DUCHEMIN said:

Dim db As AirportsDatabase = FSUIPCConnection.AirportsDatabase

Dim surfaceType As FsSurface = db.Airports(lblArrival.Text).Runways(Getrunaway(lblDeparture.Text)).Surface

Surface = surfaceType.ToString()

The code looks okay.

Please check the following:

a. The airport code must be all upper case. So maybe use this:

Dim surfaceType As FsSurface = db.Airports(lblArrival.Text.ToUpper()).Runways(Getrunaway(lblDeparture.Text)).Surface 

b. The runway code must be two digits e.g. "09". "9" will not work. Plus an optional suffix of L, C or R (capitals). e.g. 09L. No spaces.

These will NOT work:

  • 9 (only one digit)
  • 9L (only one digit)
  • 09 L (space between 9 and L)
  • 09l (Lower case L)

These WILL work

  • 09
  • 36
  • 27L
  • 09R

If you can't get it working I'll need to know more information:

1. What is the problem? Is there an error? Does it return the wrong surface, or nothing?

2. Which airport and runway are you trying?

3. What's being returned from the GetRunway() function?

4. Maybe show me the GetRunway() function.

 

Quote

I can't really help any more with that. I can write code for something that complicated that you can just paste directly into your application.

The code I wrote there is just an example or how it could be done. It shows you a strategy for achieving what you want.

I've no idea how to integrate it into your application because I don't know your application.

I can give general advice but you need to write your own code.

Paul

Posted

Hi Paul,

1 hour ago, Paul Henty said:

1. What is the problem? Is there an error? Does it return the wrong surface, or nothing?

2. Which airport and runway are you trying?

3. What's being returned from the GetRunway() function?

4. Maybe show me the GetRunway() function.

1) No error just Disconnect Fsuipc when I takeoff

2) EHAM

3) Runway by wind

Output:

[18:03] Taxiing to Runway
[18:03] Taking Off with 119 passengers on board
[18:03] Taking Off from Runway 36C

 

Public Function GetActiveRunway(ByVal ICAOcode As String, ByVal WindDirection As Double) As String
        Dim runwayReturn As String = ""
        ' Now get the runways at the airport
        ' For each one we test how far they are from the wind direction
        ' We keep the closest one.
        Dim pathto As String = My.Application.Info.DirectoryPath
        Using MyReader As New FileIO.TextFieldParser(pathto & "\runways.csv")
            MyReader.TextFieldType = FileIO.FieldType.Delimited
            MyReader.SetDelimiters(",")
            Dim runwayst As String
            Dim runwaynum As String
            Dim runwaydes1 As String
            Dim runwaydes2 As String = ""
            Dim currentRow As String()
            Dim smallestDifference As Double = 360
            While Not MyReader.EndOfData
                Try
                    currentRow = MyReader.ReadFields()
                    If currentRow(0) = ICAOcode Then
                        runwayst = currentRow(1)
                        runwaynum = runwayst.Substring(1, 2)
                        runwaydes1 = runwayst.Substring(3, 1)
                        If runwaydes1 = "0" Then runwaydes2 = ""
                        If runwaydes1 = "1" Then runwaydes2 = "L"
                        If runwaydes1 = "2" Then runwaydes2 = "R"
                        If runwaydes1 = "3" Then runwaydes2 = "C"
                        If runwaydes1 = "4" Then runwaydes2 = "W"
                        Dim rwyMagHeading As Double = CDbl(currentRow(5))
                        Dim rwyMagVariation As Double = 0

                        ' I think winds are magnetic. If not we must use true heading instead (second line)
                        Dim rwyHeading As Double = rwyMagHeading
                        ' Dim rwyHeading As Double = rwyMagHeading + rwyMagVariation

                        ' Calculate the difference between the wind heading and the runway heading
                        ' You might need to expand this to ignore short runways
                        Dim difference As Double = 180D - Math.Abs(Math.Abs(WindDirection - rwyHeading) - 180D)
                        If difference < smallestDifference Then
                            smallestDifference = difference
                            runwayReturn = runwaynum & runwaydes2
                        End If
                    End If
                Catch ex As FileIO.MalformedLineException
                    'MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
                End Try
            End While
            MyReader.Close()
            MyReader.Dispose()
        End Using
        Return runwayReturn
    End Function
Public Function Getrunaway(ByVal icaocode As String) As String
        Dim lon As FsLongitude = New FsLongitude(playerLongitude.Value)
        Dim lat As FsLatitude = New FsLatitude(playerLatitude.Value)
        ' Get the point for the current plane position
        Dim currentPosition As FsLatLonPoint = New FsLatLonPoint(lat, lon)
        Dim pathto As String = My.Application.Info.DirectoryPath
        Using MyReader As New FileIO.TextFieldParser(pathto & "\runways.csv")
            MyReader.TextFieldType = FileIO.FieldType.Delimited
            MyReader.SetDelimiters(",")
            Dim runawayst As String
            Dim runawaynum As String
            Dim runawaydes1 As String
            Dim runawaydes2 As String = ""
            Dim runawayreturn As String
            Dim currentRow As String()
            While Not MyReader.EndOfData
                Try
                    currentRow = MyReader.ReadFields()
                    If currentRow(0) = icaocode Then
                        runawayst = currentRow(1)
                        runawaynum = runawayst.Substring(1, 2)
                        runawaydes1 = runawayst.Substring(3, 1)
                        If runawaydes1 = "0" Then runawaydes2 = ""
                        If runawaydes1 = "1" Then runawaydes2 = "L"
                        If runawaydes1 = "2" Then runawaydes2 = "R"
                        If runawaydes1 = "3" Then runawaydes2 = "C"
                        If runawaydes1 = "4" Then runawaydes2 = "W"
                        Dim aaa As String = currentRow(2)
                        Dim bbb As String = currentRow(3)
                        Dim aaaa As Double
                        Dim bbbb As Double
                        aaaa = System.Convert.ToDouble(aaa)
                        bbbb = System.Convert.ToDouble(bbb)
                        Dim rwyThresholdLat As FsLatitude = New FsLatitude(aaaa)
                        Dim rwyThresholdLon As FsLongitude = New FsLongitude(bbbb)
                        Dim rwyMagHeading As Double = CDbl(currentRow(5))
                        Dim rwyMagVariation As Double = 0
                        Dim rwyLength As Double = CDbl(currentRow(6)) / 2
                        Dim rwyWidth As Double = 254D

                        Dim thresholdCentre As FsLatLonPoint = New FsLatLonPoint(rwyThresholdLat, rwyThresholdLon)
                        Dim trueHeading As Double = rwyMagHeading + rwyMagVariation
                        runwayQuad = FsLatLonQuadrilateral.ForRunway(thresholdCentre, trueHeading, rwyWidth, rwyLength)
                        If runwayQuad.ContainsPoint(currentPosition) = True Then
                            runawayreturn = runawaynum & runawaydes2
                            Return runawayreturn
                            MyReader.Close()
                            MyReader.Dispose()
                            Exit Function
                        End If
                    End If
                Catch ex As FileIO.MalformedLineException
                    'MsgBox("Line " & ex.Message & "is not valid and will be skipped.")
                End Try
            End While
            MyReader.Close()
            MyReader.Dispose()
        End Using

        Return ""
    End Function

 

1 hour ago, Paul Henty said:

I can give general advice but you need to write your own code.

I know Paul

Posted
Quote

1) No error just Disconnect Fsuipc when I takeoff

I can't see how the disconnection would be related to reading the surface for the runway.

You'll need to trace the code and set break points to see how and why the disconnection is happening.

Paul

Posted
5 minutes ago, Paul Henty said:

I can't see how the disconnection would be related to reading the surface for the runway.

Maybe this part of code is on wrong place in my app

FSUIPCConnection.Open()
FSUIPCConnection.AirportsDatabase.Load()

Fred

Posted

There should only be one place where you call Open(). It should be when your application starts.

If you have added these two lines somewhere else then you should remove them.

Find the original place where you call Open() and add the Load() after it.

Paul

Posted

I know,

I have seen your sample code in vb.net easy to understand. But you have seen the project, and fsuipc is  open and call too many time.
I think the first person write the code need to catch datas in real-time before track data with start button.

On the top real-time flight information is given before the flight is started means (fsuipc connection is open).

Try to remove this part of code to use to good way but it's an other story !!!

26168589_2040629325947554_1004082741811615514_n.jpg.e35d0e2fc328483ad747513c83e82b8b.jpg

Disconnect FSUIPC even it's harcoded

Private Sub CbOver70_CheckStateChanged(sender As Object, e As EventArgs) Handles cbOver70.CheckStateChanged
        If cbOver70.Checked = True And chkonground.Checked = True And cbTakeOff.Checked = False Then
            runaway = Getrunaway(lblDeparture.Text)
            Dim db As AirportsDatabase = FSUIPCConnection.AirportsDatabase
            Dim surfaceType As FsSurface = db.Airports("EHAM").Runways("22").Surface
            Surface = surfaceType.ToString()
            Dim flightypeSchedules As Boolean = Me.lblFlightNumber.Text Like "SDC?*"
            If Label19.Text = "Cargo:" Then
                Dim vt As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Taking Off with " & lblPAX.Text & " lbs Cargo on board" & vbCrLf
                My.Computer.FileSystem.WriteAllText(Logname, vt, True)
                Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Taking Off with " & lblPAX.Text & " lbs Cargo on board" & "*"
                My.Computer.FileSystem.WriteAllText(Reportname, xml, True)



                Dim vt1 As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Taking Off from Runway " & runaway & vbCrLf
                My.Computer.FileSystem.WriteAllText(Logname, vt1, True)
                Dim xml1 As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Taking Off from Runway " & runaway & "*"
                My.Computer.FileSystem.WriteAllText(Reportname, xml1, True)
                cbTakeOff.Checked = True
                stopwatch.Start()
                startTime = DateTime.UtcNow()
            Else
                Dim vt As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Taking Off with " & lblPAX.Text & " passengers on board" & vbCrLf
                My.Computer.FileSystem.WriteAllText(Logname, vt, True)
                Dim xml As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Taking Off with " & lblPAX.Text & " passengers on board" & "*"
                My.Computer.FileSystem.WriteAllText(Reportname, xml, True)
                runaway = Getrunaway(lblDeparture.Text)
                Dim vt1 As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Taking Off from Runway " & runaway & Surface & vbCrLf
                My.Computer.FileSystem.WriteAllText(Logname, vt1, True)
                Dim xml1 As String = DateTime.UtcNow.ToString("[HH:mm]") & Chr(32) & "Taking Off from Runway " & runaway & Surface & "*"
                My.Computer.FileSystem.WriteAllText(Reportname, xml1, True)
                cbTakeOff.Checked = True
                stopwatch.Start()
                startTime = DateTime.UtcNow()
                'stopwatch.Reset()
                'stopwatch.Start()
            End If
        End If
    End Sub

Fred

  • 2 weeks later...
Posted

Hi Paul,

I have take your sample from SDK with your Latest dll and have error with :

1) FSInstallationPath return nothing

2) getActiveRunwayForNearbyAirport() return nothing

3) FSUIPCConnection.AirportsDatabase.Load() just after FSUIPCConnection.Open() return me Exception can't connect

5a717d2a817a1_2018-01-3109_23_43-FSUIPCClientExampleSimconnect_VB.png.05c907218898268006fb54e99228c6d3.png

 


Imports FSUIPC
Imports System
Imports System.Collections
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Imports LockheedMartin.Prepar3D.SimConnect.SimConnect
Imports Microsoft.FlightSimulator.SimConnect.SimConnect
Imports System.Collections.Generic

Public Class Form1
    ' Constants
    Private Const AppTitle As String = "FSUIPCClientExample & Simconnect_VB"

    ' Register the Offsets we're interesing in for this application
    ' Dim airSpeed As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H2BC) ' Basic integer read example
    ' Dim avionics As Offset(Of Integer) = New FSUIPC.Offset(Of Integer)(&H2E80) ' Basic integer read and write example
    Dim fsLocalDateTime As Offset(Of Byte()) = New FSUIPC.Offset(Of Byte())(&H238, 10) ' Example of reading an arbitary set of bytes.
    Dim aircraftType As Offset(Of String) = New FSUIPC.Offset(Of String)("AircraftInfo", &H3160, 24) ' Example of string and use of a group
    Dim lights As Offset(Of BitArray) = New FSUIPC.Offset(Of BitArray)(&HD0C, 2) ' Example of BitArray used to manage a bit field type offset.
    Dim compass As Offset(Of Double) = New FSUIPC.Offset(Of Double)(&H2CC) ' Example for disconnecting/reconnecting
    Dim pause As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H262, True) ' Example of a write only offset.
    Dim com2bcd As Offset(Of Short) = New FSUIPC.Offset(Of Short)(&H3118) ' Example of reading a frequency coded in Binary Coded Decimal
    Dim playerLatitude As Offset(Of Long) = New Offset(Of Long)(&H560) ' Offset for Lat/Lon features
    Dim playerLongitude As Offset(Of Long) = New Offset(Of Long)(&H568) ' Offset for Lat/Lon features
    Dim onGround As Offset(Of Short) = New Offset(Of Short)(&H366) ' Offset for Lat/Lon features
    Dim magVar As Offset(Of Short) = New Offset(Of Short)(&H2A0) ' Offset for Lat/Lon features
    ' Dim playerHeadingTrue As Offset(Of UInteger) = New Offset(Of UInteger)(&H580) ' Offset for moving the plane
    Dim playerAltitude As Offset(Of Long) = New Offset(Of Long)(&H570) ' Offset for moving the plane
    Dim slewMode As Offset(Of Short) = New Offset(Of Short)(&H5DC, True) ' Offset for moving the plane
    'Dim sendControl As Offset(Of Integer) = New Offset(Of Integer)(&H3110, True) ' Offset for moving the plane
    'Dim AI As AITrafficServices ' Holds a reference to the AI Traffic Services object
    'Dim FSInstallationPath As Offset(Of String) = New Offset(Of String)(&H3E00, 256)

    ' Initialise some of the variables we will need later
    Public Sub New()
        InitializeComponent()
    End Sub

    ' Application started so try to open the connection to FSUIPC
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        OpenFSUIPC()
    End Sub

    ' User pressed connect button so try again...
    Private Sub Button1_Click(sender As Object, e As System.EventArgs) Handles Button1.Click
        OpenFSUIPC()
    End Sub

    ' Opens FSUIPC - if all goes well then starts the 
    ' timer to drive start the main application cycle.
    ' If can't open display the error message.
    Private Sub OpenFSUIPC()
        Try
            ' Attempt to open a connection to FSUIPC (running on any version of Flight Sim)
            FSUIPCConnection.Open()
            FSUIPCConnection.AirportsDatabase.Load()
            getActiveRunwayForNearbyAirport()
            'FSUIPCConnection.AirportsDatabase.IsLoaded.ToString()
            ' Opened OK so disable the Connect button
            Me.Button1.Enabled = False
            Me.Label2.Text = "FSuipc V: " & FSUIPCConnection.FSUIPCVersion.ToString()
            Me.Label2.ForeColor = System.Drawing.Color.Green
            Me.Label1.Text = "Connected to " & FSUIPCConnection.FlightSimVersionConnected.ToString()
            Me.Label1.ForeColor = System.Drawing.Color.Green
            'Me.Label4.Text = FSInstallationPath.Value
            ' and start the timer ticking to drive the rest of the application
            Me.Timer1.Interval = 200
            Me.Timer1.Enabled = True
            ' Set the AI object
            'AI = FSUIPCConnection.AITrafficServices
        Catch ex As Exception
            ' Badness occurred - show the error message
            MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

    ' Application is unloading so call close to cleanup the 
    ' UNMANAGED memory used by FSUIPC. 
    Private Sub Form1_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        FSUIPCConnection.Close()
    End Sub
    Private Sub getActiveRunwayForNearbyAirport()
        ' Clear current items in results listbox
        Me.lstActiveRunways.Items.Clear()
        ' Refresh the AI traffic
        FSUIPCConnection.AITrafficServices.RefreshAITrafficInformation()
        ' get the closest airport using the database
        Dim db As AirportsDatabase = FSUIPCConnection.AirportsDatabase
        ' Set the reference position to the current player position
        ' This will calculate the distance from the player to the airports
        db.SetReferencePosition()
        ' Find the airports within 40nm (Closest will be first in the list)
        Dim within40 As FsAirportCollection = db.Airports.InRangeOfNauticalMiles(40)
        If within40.Count > 0 Then
            ' Loop through each airport
            For Each ap As FsAirport In within40
                ' find the active arrival runway for this airport
                Dim runways As List(Of FsRunwayID) = FSUIPCConnection.AITrafficServices.GetArrivalRunwaysInUse(ap.ICAO)
                If runways.Count > 0 Then
                    Me.lstActiveRunways.Items.Add(ap.ICAO & " (" & ap.DistanceNauticalMiles.ToString("F0") & "nm): " & runways(0).ToString())
                Else
                    Me.lstActiveRunways.Items.Add(ap.ICAO & " (" & ap.DistanceNauticalMiles.ToString("F0") & "nm): No active runway")
                End If
            Next
        Else
            Me.lstActiveRunways.Items.Add("No airports within 40nm")
        End If
    End Sub
    ' The timer handles the real-time updating of the Form.
    ' The default group (ie, no group specified) is 
    ' Processed and every Offset in the default group is updated.
    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        Try

            ' Process the default group
            FSUIPCConnection.Process()

            ' Advanced Concept: Reading Raw Blocks of Data.
            ' FS Local Date and Time
            ' This demonstrates getting back an arbitrary number of bytes from an offset.
            ' Here we're getting 10 back from Offset 0x0328 which contain info about the 
            ' local date and time in FS.
            ' Because it's returned as a byte array we need to handle everything ourselves...
            ' 1. Year (starts at Byte 8) for 2 bytes. (Int16)
            '    Use the BitConverter class to get it into a native Int16 variable
            Dim year As Short = BitConverter.ToInt16(fsLocalDateTime.Value, 8)
            '    You could also do it manually if you know about such things...
            '    Dim year As Short = (fsLocalDateTime.Value(8) + (fsLocalDateTime.Value(9) * &H100))
            ' 2. Make new datetime with the the time value at 01/01 of the year...
            '    Time - in bytes 0,1 and 2. (Hour, Minute, Second):
            Dim fsTime As DateTime = New DateTime(year, 1, 1, fsLocalDateTime.Value(0), fsLocalDateTime.Value(1), fsLocalDateTime.Value(2))
            ' 3. Get the Day of the Year back (not given as Day and Month) 
            '    and add this on to the Jan 1 date we created above 
            '    to give the final date:
            Dim dayNo As Short = BitConverter.ToInt16(fsLocalDateTime.Value, 6)
            fsTime = fsTime.Add(New TimeSpan(dayNo - 1, 0, 0, 0))
            ' Now print it out
            Me.txtFSDateTime.Text = fsTime.ToString("dddd, MMMM dd yyyy hh:mm:ss")

        Catch exFSUIPC As FSUIPCException

            If exFSUIPC.FSUIPCErrorCode = FSUIPCError.FSUIPC_ERR_SENDMSG Then
                ' Send message error - connection to FSUIPC lost.
                ' Show message, disable the main timer loop and relight the 
                ' connection button:
                ' Also Close the broken connection.
                Me.Timer1.Enabled = False

                Me.Button3.Enabled = False
                Me.Button1.Enabled = True
                FSUIPCConnection.Close()
                MessageBox.Show("The connection to Flight Sim has been lost.", AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
            Else
                ' not the disonnect error so some other baddness occured.
                ' just rethrow to halt the application
                Throw exFSUIPC
            End If


        Catch ex As Exception
            ' Sometime when the connection is lost, bad data gets returned 
            ' and causes problems with some of the other lines.  
            ' This catch block just makes sure the user doesn't see any
            ' other Exceptions apart from FSUIPCExceptions.
        End Try


    End Sub

    ' This demonstrates disconnecting an individual Offset.
    ' After it's disconnected it doesn't get updated from FSUIPC
    ' and changed to the value of this Offset do not get written
    ' when Process() is called.
    Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
        ' Stop the timer
        Me.Timer1.Stop()
        ' Close the connection
        'FSInstallationPath.Disconnect()
        FSUIPCConnection.Close()
    End Sub

    '
    Private Enum LightType
        Navigation
        Beacon
        Landing
        Taxi
        Strobes
        Instruments
        Recognition
        Wing
        Logo
        Cabin
    End Enum


End Class

Regards Fred

Posted

Hi Fred,

That code runs fine here. No problems.

I can't really see what's going wrong without the exception details and the call stack.

In the openFSUIPC() method, can you comment out the lines:
 

Try

Catch
    messagebox(...
End Try

Then run it again. You need to get the exception details and show me the call stack. Use the 'Copy Details' link and paste it here.

Paul

 

Posted

 

Hi Paul,

P3Dv4.1 64 bits

Visual Studio 2017 Entreprise

FSUIPCConnection.AirportsDatabase.Load()
System.OverflowException
  HResult=0x80131516
  Message=La valeur était trop grande ou trop petite pour un UInt16.
  Source=FSUIPCClient
  Arborescence des appels de procédure :
   à FSUIPC.AirportsDatabase.Load(String Folder, HashSet`1 AirportList)
   à FSUIPC.AirportsDatabase.Load(HashSet`1 AirportList)
   à FSUIPC.AirportsDatabase.Load()
   à Acars_Sky.Form1.OpenFSUIPC() dans M:\Projet ACARS\Applications_2018\Acars_Sky\Acars Sky\Acars Sky\Form1.vb :ligne 57
   à Acars_Sky.Form1.Form1_Load(Object sender, EventArgs e) dans M:\Projet ACARS\Applications_2018\Acars_Sky\Acars Sky\Acars Sky\Form1.vb :ligne 42
   à System.EventHandler.Invoke(Object sender, EventArgs e)
   à System.Windows.Forms.Form.OnLoad(EventArgs e)
   à MetroFramework.Forms.MetroForm.OnLoad(EventArgs e)
   à System.Windows.Forms.Form.OnCreateControl()
   à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   à System.Windows.Forms.Control.CreateControl()
   à System.Windows.Forms.Control.WmShowWindow(Message& m)
   à System.Windows.Forms.Control.WndProc(Message& m)
   à System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   à System.Windows.Forms.Form.WmShowWindow(Message& m)
   à System.Windows.Forms.Form.WndProc(Message& m)
   à MetroFramework.Forms.MetroForm.WndProc(Message& m)
   à System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   à System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   à System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

Posted

Thanks I will

But how use your.pdb no different message Paul

5a71e03275254_2018-01-3116_25_55-AcarsSky(Dbogage)-MicrosoftVisualStudio.png.94193e3c66e0bac29b8f96bc601928e8.png

 

System.OverflowException
  HResult=0x80131516
  Message=La valeur était trop grande ou trop petite pour un UInt16.
  Source=FSUIPCClient
  Arborescence des appels de procédure :
   at FSUIPC.AirportsDatabase.Load(String Folder, HashSet`1 AirportList) in C:\Dev\FsuipcClient\fsuipcClient\fsuipcClient\AirportsDatabase.cs:line 642
   at FSUIPC.AirportsDatabase.Load() in C:\Dev\FsuipcClient\fsuipcClient\fsuipcClient\AirportsDatabase.cs:line 59
   at Acars_Sky.Form1.OpenFSUIPC() in M:\Projet ACARS\Applications_2018\Acars_Sky\Acars Sky\Acars Sky\Form1.vb:line 57
   at Acars_Sky.Form1.Form1_Load(Object sender, EventArgs e) in M:\Projet ACARS\Applications_2018\Acars_Sky\Acars Sky\Acars Sky\Form1.vb:line 42
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at MetroFramework.Forms.MetroForm.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at MetroFramework.Forms.MetroForm.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

 

  • 3 weeks later...
Posted

Sorry Fred, I didn't see your reply. I think you edited the post. I don't get notified of edits, only new posts.

Yes the message will be the same, but this time the stack trace has line numbers.

However, my source code has changed a lot since I sent that .pdb.

Can you please use the current version attached, get the error and show me the full exception as above.

There might be a few changes to the DLL that break your code. I have renamed a few properties and methods. Let me know if you get any errors and I'll tell you the new names.

Thanks,

Paul

FSUIPCClient3.0_RC8.zip

  • Like 1
Posted

Hi Paul,

 

37 minutes ago, Paul Henty said:

Sorry Fred, I didn't see your reply. I think you edited the post. I don't get notified of edits, only new posts.

No problem

 ' This will calculate the distance from the player to the airports
        db.SetReferencePosition()
Gravité	Code	Description	Projet	Fichier	Ligne	État de la suppression
Erreur	BC30456	'SetReferencePosition' n'est pas un membre de 'AirportsDatabase'.	SDA13-09-14	M:\Projet ACARS\CAVacars Custom SKYDREAM-2.0.1.4\Forms\FrmMain.vb	515	Actif
db.SetReferenceLocation()

 

Posted

I have seen look my post

The same error :

 Message=La valeur était trop grande ou trop petite pour un UInt16.

and when this message occurs  

Me.Version.Text = String.Format("SkyDream Tracker {0}", My.Application.Info.Version.ToString) & " | " & "FSUIPC: " & FSUIPCConnection.FSUIPCVersion.ToString

Doesn't work but my app doesn't crash

 

   Private Sub FrmMain_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Application.CurrentCulture = New Globalization.CultureInfo("en-US")

        Try
            Delete_acars_position()
            Delete_phpvms_acarsdata()
            FSUIPCConnection.Open()
            ' add database
            FSUIPCConnection.AirportsDatabase.Load()
            fsconectionstatus = 1
            DisconnectToolStripMenuItem.Enabled = True
            ConnectToolStripMenuItem.Enabled = False
            Me.Version.Text = String.Format("SkyDream Tracker {0}", My.Application.Info.Version.ToString) & " | " & "FSUIPC: " & FSUIPCConnection.FSUIPCVersion.ToString
        Catch ex As Exception
            MessageBox.Show(ex.Message)
        End Try
        'FrmWeather.NotifyIcon1.Visible = True
        'Dim limit As String = "06/30/2014"
        'Dim danas As DateTime = DateTime.Now.ToShortDateString
        'If danas > limit Then
        '    MsgBox("This preview version is expired! Program will close now!", MsgBoxStyle.Critical)
        '    Me.Dispose()
        'End If
        FSUIPCConnection.Close()
        'TmrGetDataFromFs.Stop()
        DisconnectToolStripMenuItem.Enabled = False
        FsUipcStatuslbl.Text = "FSUIPC Disconn."
        FsUipcStatuslbl.BackColor = Color.Red
        ConnectToolStripMenuItem.Enabled = True
        Createfolder("reports")
        Createfolder("messages")
        Startup()
        If Checkrunaways() = 0 Then
            Createrunaways()
        End If
        If My.Settings.VaWebSite = vbNullString Then
            FrmSettings.Show()
            Exit Sub
        End If
        Createverify()
        Sendlogin()
        Sendmessage()
        Dim loginstat As String = ""
        Try
            Dim document As XmlReader = New XmlTextReader(path & "\SDAacars\messages\receive.xml")
            While (document.Read())
                Dim type = document.NodeType
                If (type = XmlNodeType.Element) Then
                    If (document.Name = "loginStatus") Then
                        loginstat = document.ReadInnerXml.ToString()
                    End If
                    If (document.Name = "showLights") Then
                        showLights = document.ReadInnerXml.ToString()
                    End If
                    If (document.Name = "charter") Then
                        allowCharter = document.ReadInnerXml.ToString()
                        If allowCharter = "0" Then cbCharter.Enabled = False
                    End If
                    If (document.Name = "logPause") Then
                        logPause = document.ReadInnerXml.ToString()
                    End If
                    If (document.Name = "logEngines") Then
                        logEngines = document.ReadInnerXml.ToString()
                    End If
                    If (document.Name = "selectAircraft") Then
                        allowAircraft = document.ReadInnerXml.ToString()
                    End If
                    If (document.Name = "logFuelUnit") Then
                        logFuelUnit = document.ReadInnerXml.ToString()
                    End If
                End If
            End While
            document.Close()
        Catch ex As Exception
            MsgBox("No file has been selected", vbInformation, "Warning")
        End Try
        If loginstat = "0" Then
            StatusLblPilotId.Text = My.Settings.PilotId
            StatusLblPilotId.BackColor = Color.Red
            ToolStripStatusLabel2.BackColor = Color.Red
            FrmSettings.Show()
            Exit Sub
        End If
        If loginstat = "1" Then
            StatusLblPilotId.Text = My.Settings.PilotId
            StatusLblPilotId.BackColor = Color.GreenYellow
            ToolStripStatusLabel2.BackColor = Color.GreenYellow
            StatusLblPilotId.Font = New Font(StatusLblPilotId.Font, FontStyle.Bold)
        End If
        If allowAircraft = "1" Then
            cbCharter.Checked = True
            cbCharter.Checked = False
            comboCaircraft.Enabled = True
        End If
        'UiFunctions.Startup()
    End Sub

 

Posted

Try your conversion table

60EC 8 GPS: Distance to next waypoint, floating point double, in metres

8 (Specified as FLOAT64)System.Double Double Double

I Have convert to :

 Dim gps_distance As Offset(Of Double) = New Offset(Of Double)(&H60EC)

So now conversion in NM rounded ?

Posted
44 minutes ago, Paul Henty said:

Okay - So does your project compile with the new DLL now?

If so, I just need the exception details.

Paul

System.OverflowException
  HResult=0x80131516
  Message=La valeur était trop grande ou trop petite pour un UInt16.
  Source=FSUIPCClient
  Arborescence des appels de procédure :
   at FSUIPC.AirportsDatabase.Load(String Folder, HashSet`1 AirportList) in C:\Dev\FsuipcClient\fsuipcClient\fsuipcClient\AirportsDatabase.cs:line 674
   at FSUIPC.AirportsDatabase.Load() in C:\Dev\FsuipcClient\fsuipcClient\fsuipcClient\AirportsDatabase.cs:line 77
   at Acars_Sky.Form1.OpenFSUIPC() in M:\Projet ACARS\Applications_2018\Acars_Sky\Acars Sky\Acars Sky\Form1.vb:line 57
   at Acars_Sky.Form1.Button1_Click(Object sender, EventArgs e) in M:\Projet ACARS\Applications_2018\Acars_Sky\Acars Sky\Acars Sky\Form1.vb:line 47
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at Acars_Sky.My.MyApplication.Main(String[] Args) in :line 81
>	FSUIPCClient.dll!FSUIPC.AirportsDatabase.Load(string Folder, System.Collections.Generic.HashSet<string> AirportList) Ligne 674	C#	Les symboles ont été chargés.
 	FSUIPCClient.dll!FSUIPC.AirportsDatabase.Load() Ligne 77	C#	Les symboles ont été chargés.
 	Acars Sky.exe!Acars_Sky.Form1.OpenFSUIPC() Ligne 57	Basic	Les symboles ont été chargés.
 	Acars Sky.exe!Acars_Sky.Form1.Button1_Click(Object sender, System.EventArgs e) Ligne 47	Basic	Les symboles ont été chargés.
 	[Code externe]		Frame annoté

 

Posted
10 minutes ago, Frédéric-O DUCHEMIN said:

 

So now conversion in NM rounded ?

1 NM is 1852 metres. Divide gps_distance by 1852 to convert metres to nautical miles.

Use the Math.Round() function to round to however many decimal places you need.

Paul

Posted

This code works fine for me:

    Dim gps_distance As Offset(Of Double) = New Offset(Of Double)(&H60EC)
    Dim gps_nextWaypoint As Offset(Of String) = New Offset(Of String)(&H60A4, 6)

 

        FSUIPCConnection.Process()
        Dim distanceNM As Double = Math.Round(gps_distance.Value / 1852, 0)
        Me.TextBox1.Text = gps_nextWaypoint.Value.ToString() & ": " & distanceNM.ToString() + "NM"

First check unconverted (metres) value in gps_distance.Value. Is that 0 as well?

These offsets are only active when you have a flight plan active in Flight Sim. Are you sure you have one loaded? Are there waypoints defined in the flight plan?

If you load the default Cessna with the G1000 GPS do you see the route on the GPS in the cockpit? It should be a magenta line.

For the AirportsDatabase error - it seems there is a problem with one of the coms frequencies at an airport.

As you have different scenery to me, I can't reproduce this.

Could you zip these two files from your main flight sim install folder and attach them here please?

  • F5.csv
  • Runways.xml

Thanks,

Paul

Posted

Thanks for the file. I will investigate...

I see you're using P3DV4. I know there are some things that don't work with V4. Maybe this is one of them.

I would ask Pete in the main forum about this distance offset in P3dV4. I think he's back from holiday tomorrow.

I have FSX and it works okay. I don't have P3D so I can't test it there.

Paul

Posted
Quote

Distance not good maybe try an other offset?

You could try 60AC and 60B4 (Lon/Lat of next waypoint).

If those are okay you can make a FsLatLonPoint with them. Then make another from the Player's Lat/Lon. Then you can get distance between both points (FsLatLonPoint.DistanceFromInNauticalMiles()).

Quote

Have you a way to avoid negative number to distance ?

You can use Math.Abs() to make a number positive.

  • Math.Abs(5) = 5.
  • Math.Abs(-5) = 5.

Paul

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • 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.