Jump to content
The simFlight Network Forums

Recommended Posts

Hello Paul,


I would like to know how to display the closest NAVAIDS that the aircraft is crossing either by reading a SQlite database or by comparing a flight plan loaded in the tracker.
Always comparing the position of the aircraft to the beacon.

Second point you gave me code to find the runway in service against the wind.
But in the latest version of your dll you have also implemented AI traffic from IVAO.

How to find either according to the Metar or according to the AI traffic.

Sincerely Fred

 

Share this post


Link to post
Share on other sites

Hi Fred,

Quote

I would like to know how to display the closest NAVAIDS that the aircraft is crossing either by reading a SQlite database or by comparing a flight plan loaded in the tracker. Always comparing the position of the aircraft to the beacon.

The distance between the aircraft and the navaid can be calculated using two FsLatLonPoint classes. One for the aircraft and one for the NAVAID.

Something like:

beaconLocation.DistanceFromInMetres(aircraftLocation)

The aircraftLocation you can get from offsets 0560/0568 or 6010/6018

The location of the navaid is more of a problem.

If you have a flight plan with the locations of the navaids then just check against all of them to see which is the closest. Or, you can just test them in the order they come in the flight plan. Start with the first navaid, then when the player has crossed that one, move on to the next one. You might consider that the aircraft has 'crossed' a navaid when it comes within a set distance (e.g. 1km).

If you just have a database of navaids and no set route to follow then it's more difficult. It's probably not practical to measure the distance to every navaid in the database. So first you'll need to filter those navaids which are in a set range of latitude and longitude. For example you might first select navaids from the database which are 0.5 degree of latitude and longitude either side of the aircraft. This way you have fewer navaids to calculate the distance for.

Quote

Second point you gave me code to find the runway in service against the wind. But in the latest version of your dll you have also implemented AI traffic from IVAO. How to find either according to the Metar or according to the AI traffic.

You can find the active runways used by the AI Traffic by passing the ICAO code of the airport to GetArrivalRunwaysInUse() or GetDepartureRunwaysInUse().

            AITrafficServices ts = FSUIPCConnection.AITrafficServices;
            ts.RefreshAITrafficInformation();
            List<FsRunwayID> arrivalRunways = ts.GetArrivalRunwaysInUse("EGLL");
            if (arrivalRunways.Count > 0)
            {
                MessageBox.Show("Arrival runway for EGLL is " + arrivalRunways[0].ToString());
            }
            else
            {
                // No information available
            }

This only works for airports in range of the player because it needs active AI traffic at that airport, or inbound to the airport.

For departure runways, ground AI is required. The player must be at the airport.

For arrival runways, airborne AI is required. The player must be within 40nm of the airport.

HOWEVER: As far as I know, IVAO traffic does not have assigned runways filled in. So the result is only for the normal AI Traffic. If IVAO traffic is using a different runway than the AI Traffic then there is no way to tell this.

Paul

Share this post


Link to post
Share on other sites

Hi Paul,

Can you help me please in Vb.NET?

1) I use the DB from Little Navmap or Navdatareader from Albert in SQLite

2) Maybe catch frequencies tuned by ADF NAV (I have not idea how to work GPS or FMS in virtual life) and compare with the DB ?

3) For Arrival runways maybe find the closest in range of 40NM around airplane.

Private Sub getActiveRunways()
' Get a reference to the AITrafficServices class (saves typing)
Dim AI As AITrafficServices = FSUIPCConnection.AITrafficServices
' Refresh the traffic information AI.RefreshAITrafficInformation()
' Get the arrival runways in use 
Dim runways As List(Of FSRunway) = AI.GetArrivalRunwaysInUse("EGLL")
' Display in the listbox 
Me.lstArrival.Items.Clear()
For Each rw As FSRunway In runways
Me.lstArrival.Items.Add(rw.ToString())
Next rw 
' same for departure runways 
runways = AI.GetDepartureRunwaysInUse("EGLL") 
Me.lstDeparture.Items.Clear() 
For Each rw As FSRunway In runways
Me.lstDeparture.Items.Add(rw.ToString())
Next rw
End Sub

But no idea howto do that (Again)

Have examples fro the latest version of DLL in Vb.NET ? please

Regards Fred

Share this post


Link to post
Share on other sites
Quote

1) I use the DB from Little Navmap or Navdatareader from Albert in SQLite

I can't really help with that specifically. I don't know those databases and I don't know SQLite. I can only give you a general method of how it's done. I can't write the code for this, sorry.

Quote

2) Maybe catch frequencies tuned by ADF NAV (I have not idea how to work GPS or FMS in virtual life) and compare with the DB ?

Yes, that's a good way of doing it. FSUIPC has offsets that give you the Lat/Lon of the ADF and VOR beacons tuned to the radios.

Here is an example of getting the Lat/Lon of the beacons on the ADF1 and VOR1 radios:

    Dim adf1Lat As Offset(Of FsLatitude) = New Offset(Of FsLatitude)("beacons", &H1124, 4)
    Dim adf1Lon As Offset(Of FsLongitude) = New Offset(Of FsLongitude)("beacons", &H1128, 4)
    Dim vor1Lat As Offset(Of FsLatitude) = New Offset(Of FsLatitude)("beacons", &H85C, 4)
    Dim vor1Lon As Offset(Of FsLongitude) = New Offset(Of FsLongitude)("beacons", &H864, 4)
        FSUIPCConnection.Process("beacons")
        ' get FsLatLonPoint for the beacon tuned on ADF1
        Dim adf1Location As FsLatLonPoint = New FsLatLonPoint(Me.adf1Lat.Value, Me.adf1Lon.Value)
        ' get FsLatLonPoint for the beacon tuned on VOR1
        Dim vor1Location As FsLatLonPoint = New FsLatLonPoint(Me.vor1Lat.Value, Me.vor1Lon.Value)
        Me.TextBox1.Text = adf1Location.ToString()
        Me.TextBox2.Text = vor1Location.ToString()
Quote

3) For Arrival runways maybe find the closest in range of 40NM around airplane.

Here is a VB example of using the new Airports Database to do this.

You must have the makerunways.exe files in the main Flight Sim folder.

After making the connection to FSUIPC you must load the database using:

        FSUIPCConnection.AirportsDatabase.Load()

Then you can use this code to get the airports within 40nm and find the active runways according to the AI Traffic.

The results are displayed in a listbox called lstActiveRunways.

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
Quote

Have examples fro the latest version of DLL in Vb.NET ? please

Not at the moment. I'm writing the examples for the proper release of 3.0. It's all in C# as the project is very large. Writing it twice would be too much work. I'm hoping to automatically translate it to VB when it's finished. It will take a long time to do it manually.

I've attached the latest DLL.

Paul

FSUIPCClient3.0_RC7.zip

Share this post


Link to post
Share on other sites
2 hours ago, Paul Henty said:

Yes, that's a good way of doing it. FSUIPC has offsets that give you the Lat/Lon of the ADF and VOR beacons tuned to the radios.

Here is an example of getting the Lat/Lon of the beacons on the ADF1 and VOR1 radios:

Thanks  but without db is Lat/Lon can't help me. Maybe use name and distance.

Like:

NIC (12NM) --> STP (15NM) --> MTG (23NM)

Holding the first nearest in the array lock to a value take the second lock to a value etc.. (tree)

And put all to the form.

2 hours ago, Paul Henty said:

After making the connection to FSUIPC you must load the database using:


        FSUIPCConnection.AirportsDatabase.Load()

Ok need a timer to loop but at what frequency I do  that ? please.

Thanks Paul

Fred

 

 

Share this post


Link to post
Share on other sites
Quote

Like:

NIC (12NM) --> STP (15NM) --> MTG (23NM)

I'm not sure what you are trying to do. It looks like you want to show the distances to way points (beacons) in a flight plan. Does your software have a flight plan? Or do your users load a flight plan in Flight Sim?

Quote

Ok need a timer to loop but at what frequency I do  that ? please.

No need for a timer. You only need to call this once, just after the connection is open. It takes about 2-3 seconds. You don't need to call this again.

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

Paul

Share this post


Link to post
Share on other sites
10 hours ago, Paul Henty said:

I'm not sure what you are trying to do. It looks like you want to show the distances to way points (beacons) in a flight plan. Does your software have a flight plan? Or do your users load a flight plan in Flight Sim?

Yes my software have a flight plan.

 

10 hours ago, Paul Henty said:

No need for a timer. You only need to call this once, just after the connection is open. It takes about 2-3 seconds. You don't need to call this again.

I'm talking about the function you give me.

Fred

Share this post


Link to post
Share on other sites
Quote

Yes my software have a flight plan.

Okay. What information does it have for each navaid? Does it have the Lon/Lat for the navaid? Or just frequency and name?

Quote

I'm talking about the function you give me.

It doesn't need to be quick. I would think every 10 seconds would be fine.

Paul

Share this post


Link to post
Share on other sites
27 minutes ago, Paul Henty said:

What information does it have for each navaid? Does it have the Lon/Lat for the navaid? Or just frequency and name?

All information needed include lat/lon

28 minutes ago, Paul Henty said:

It doesn't need to be quick. I would think every 10 seconds would be fine.

ticker set to ?

Share this post


Link to post
Share on other sites
Quote

All information needed include lat/lon

Yes, but what information is already in the flight plan?

I don't think I understand what you want to do. Can you confirm the following is correct?

  • Your software has a flight plan loaded.
  • The flight plan has a list of navaids to follow
  • While flying, you want to show the user the next navaid and the distance to it.

If that's wrong please explain what you need.

Quote

ticker set to ?

Do mean mean the millisecond value? 10000

Paul

Share this post


Link to post
Share on other sites
20 minutes ago, Paul Henty said:
  • Your software has a flight plan loaded.
  • The flight plan has a list of navaids to follow
  • While flying, you want to show the user the next navaid and the distance to it.

Correct

Share this post


Link to post
Share on other sites

The Tracker pass the route into php and plot the result to a map.

I mean in Route form point are read and looking to the db to plot route

 

5a537d13d0279_2018-01-0815_13_50-skydream_skydrea1_skydream_phpvms_phpvms_navdata_-HeidiSQLPortable9.5.0_5209.png.305a79bf470af3ce507e291b5a3b2eff.png

Lat/Lon frequency type (FIX, VOR, VOR-DME) Region

[{"id":"5","pilotid":"SDA0001","flightnum":"SDA8127","pilotname":"Frederic Duchemin","aircraft":"B-77D6","lat":"45.724445851774","lng":"5.0830752739348","heading":"180","alt":"0","gs":"0","depicao":"LFLL","depapt":"Lyon-Saint-Exup\u00e9ry","arricao":"CYYZ","arrapt":"Toronto Pearson Int\\'L. Ont.","deptime":"00:00:00","timeremaining":"00:00","arrtime":"14:26:06","route":"BUSIL UT133 AMORO UT140 PIBAT UM976 OKRIX UH10 AMODO UM729 RESMI UN491 LGL UN502 JSY UN160 NAKID UN83 LEDGO DOGAL . NATD55 . PORTI N112C ALLEX Q822 CAM Q84 PAYGE V490 UCA V2 BUF","route_details":{"BUSIL":{"id":"195475","name":"BUSIL","title":"BUSIL","airway":null,"airway_type":null,"seq":"0","loc":"EUR","lat":"46.293610","lng":"4.721944","freq":"","type":"5"},"AMORO":{"id":"322179","name":"AMORO","title":"AMORO","airway":"UT140","airway_type":"H","seq":"1","loc":"EUR","lat":"46.500000","lng":"4.538056","freq":"","type":"5"},"PIBAT":{"id":"316922","name":"PIBAT","title":"PIBAT","airway":"UM976","airway_type":"H","seq":"9","loc":"EUR","lat":"46.805832","lng":"4.259167","freq":"","type":"5"},"CACHI":{"id":"316923","name":"CACHI","title":"CACHI","airway":"UM976","airway_type":"H","seq":"10","loc":"EUR","lat":"47.066666","lng":"4.106667","freq":"","type":"5"},"AVLON":{"id":"316924","name":"AVLON","title":"AVLON","airway":"UM976","airway_type":"H","seq":"11","loc":"EUR","lat":"47.560001","lng":"3.813333","freq":"","type":"5"},"OKRIX":{"id":"309424","name":"OKRIX","title":"OKRIX","airway":"UH10","airway_type":"H","seq":"14","loc":"EUR","lat":"47.966110","lng":"3.567500","freq":"","type":"5"},"AMODO":{"id":"316015","name":"AMODO","title":"AMODO","airway":"UM729","airway_type":"H","seq":"2","loc":"EUR","lat":"48.419445","lng":"2.980278","freq":"","type":"5"},"RESMI":{"id":"317861","name":"RESMI","title":"RESMI","airway":"UN491","airway_type":"H","seq":"15","loc":"EUR","lat":"48.568611","lng":"2.191944","freq":"","type":"5"},"LGL":{"id":"317883","name":"LGL","title":"LAIGLE","airway":"UN502","airway_type":"H","seq":"8","loc":"EUR","lat":"48.790611","lng":"0.530278","freq":"115.00","type":"5"},"JSY":{"id":"317433","name":"JSY","title":"JERSEY","airway":"UN160","airway_type":"H","seq":"7","loc":"EUR","lat":"49.221104","lng":"-2.046153","freq":"112.20","type":"5"},"NAKID":{"id":"318531","name":"NAKID","title":"NAKID","airway":"UN83","airway_type":"H","seq":"2","loc":"EUR","lat":"49.715000","lng":"-4.623056","freq":"","type":"5"},"LEDGO":{"id":"318530","name":"LEDGO","title":"LEDGO","airway":"UN83","airway_type":"H","seq":"1","loc":"EUR","lat":"51.240002","lng":"-7.568056","freq":"","type":"5"},"DOGAL":{"id":"225471","name":"DOGAL","title":"DOGAL","airway":null,"airway_type":null,"seq":"0","loc":"NAT","lat":"54.000000","lng":"-15.000000","freq":"","type":"5"},"PORTI":{"id":"196243","name":"PORTI","title":"PORTI","airway":null,"airway_type":null,"seq":"0","loc":"NAT","lat":"46.500000","lng":"-52.000000","freq":"","type":"5"},"ALLEX":{"id":"186769","name":"ALLEX","title":"ALLEX","airway":null,"airway_type":null,"seq":"0","loc":"NAM","lat":"44.416668","lng":"-67.000000","freq":"","type":"5"},"CAM":{"id":"297907","name":"CAM","title":"CAMBRIDGE","airway":"Q84","airway_type":"H","seq":"5","loc":"NAM","lat":"42.994289","lng":"-73.344017","freq":"115.00","type":"5"},"PAYGE":{"id":"340995","name":"PAYGE","title":"PAYGE","airway":"V490","airway_type":"L","seq":"3","loc":"NAM","lat":"43.014023","lng":"-74.253548","freq":"","type":"5"},"UCA":{"id":"333083","name":"UCA","title":"UTICA","airway":"V2","airway_type":"L","seq":"128","loc":"NAM","lat":"43.026512","lng":"-75.164520","freq":"111.20","type":"5"},"BUF":{"id":"333071","name":"BUF","title":"BUFFALO","airway":"V2","airway_type":"L","seq":"116","loc":"NAM","lat":"42.928997","lng":"-78.646339","freq":"116.40","type":"5"}},"distremain":"3441","phasedetail":"Boarding","online":"","lastupdate":"2018-01-08 14:26:06","client":"SDAcars","network":"0","aircraftname":"B77L","registration":"B-77D6","code":"SDA","firstname":"Frederic","lastname":"Duchemin","depname":"Lyon-Saint-Exup\u00e9ry","deplat":"45.7204","deplng":"5.07951","arrname":"Toronto Pearson Int'L. Ont.","arrlat":"43.6772","arrlng":"-79.6306","distremaining":"3441"}] 

5a537fbf6f026_2018-01-0815_25_49-SKYDreamTracker.png.95481384370b8e0b6d14aeb731d32a47.png

Share this post


Link to post
Share on other sites

Okay, I understand.

You need to just keep track of which navaid is next. Then monitor the distance and show the user.

When the distance is under a certain number (maybe 0.5nm) then move to the next navaid.

I can't write the exact code because I don't know about your flight plans.

But this is a framework that you can adapt:
 

Form level variables:

    Public playerLatitude As Offset(Of FsLatitude) = New Offset(Of FsLatitude)("playerPos", &H560, 8)
    Public playerLongitude As Offset(Of FsLongitude) = New Offset(Of FsLongitude)("playerPos", &H568, 8)

    Dim nextNavaidIndex As Integer = -1
    Dim numberOfNavaids As Integer ' SET THIS WHEN THE FLIGHT PLAN IS LOADED
    Dim nextNavaidLocation As FsLatLonPoint
    Dim nextNavaidID As String

Subs:
 

Private Sub displayNextNavaid()
        If nextNavaidIndex = -1 Then
            getNextNavaid()
        End If
        If nextNavaidIndex < numberOfNavaids Then
            FSUIPCConnection.Process("playerPos")
            Dim playerPos As FsLatLonPoint = New FsLatLonPoint(playerLatitude.Value, playerLongitude.Value)
            Dim distanceNM = playerPos.DistanceFromInNauticalMiles(nextNavaidLocation)
            ' display on the form
            Me.txtNextNavaid.Text = nextNavaidID
            Me.txtNextNavaidDistance.Text = distanceNM.ToString("F2")
            ' check is player is overhead
            If distanceNM < 0.5 Then ' You might need to adjust this distance
                ' player is overhead, move to the next navaid
                getNextNavaid()
            End If
        Else
            ' No more navaids left
        End If

    End Sub

    Private Sub getNextNavaid()
        nextNavaidIndex = nextNavaidIndex + 1

        ' REPLACE NEXT THREE LINES - I don't know how your flight plan is stored
        ' You need to get the ID and Lon/Lat of the navaid from your flight plan.
        ' You should use the nextNavAidIndex to tell you which navaid to get.
        nextNavaidID = "ID" '
        Dim navaidLat As Double = "45.123456"
        Dim navaidLon As Double = "-2.123456"

        nextNavaidLocation = New FsLatLonPoint(navaidLat, navaidLon)
    End Sub

You need to call displayNextNavaid whenever you want this information to be updated.  Every 1 second (1000ms) should be fine.

Paul

 

Share this post


Link to post
Share on other sites

Thanks Paul,

So the flight plan is not loaded in Simulator the NAVAIDS pilot put into the route are send to the website.

20 minutes ago, Paul Henty said:

Dim numberOfNavaids As Integer ' SET THIS WHEN THE FLIGHT PLAN IS LOADED

You mean when the route field is not empty || NULL ?

 

Regards Fred

Share this post


Link to post
Share on other sites
Quote

So the flight plan is not loaded in Simulator the NAVAIDS pilot put into the route are send to the website.

The flight plan does not need to be loaded into the simulator.

Does your program have access to the lat/lat for the Navaids? Or are they are only on the server? If so, you'll need to rely on the radios being tuned and get the lat/lon from offsets 1124/1128 etc. See post #4 earlier in this thread. Otherwise just take them directly from the flight plan.

 

Quote

You mean when the route field is not empty || NULL ?

Any time between the user entering the flight plan and starting the flight. If you send the flight plan to a server then that would be a good time to count the number of waypoints and set this variable.

Paul

Share this post


Link to post
Share on other sites
4 minutes ago, Paul Henty said:

Does your program have access to the lat/lat for the Navaids? Or are they are only on the server?

Only on the server. No way to have a better or simple method to do this even I need a pln ? if yes how to adapt your code ?

Forget one thing sorry for that need to catch also the status of the runways in realtime.

Thanks again

Fred

 

Share this post


Link to post
Share on other sites
Quote

Only on the server. No way to have a better or simple method to do this even I need a pln ? if yes how to adapt your code ?

If you make your users load a flight plan (pln) in FS it will be much easier. There is lots of data available from the 'GPS' offsets starting at 0x6000. See the offsets list. e.g. there is distance to next way point (0x60EC).

In this case there is no need to track the offsets yourself, it's all done by the Flight Sim. So just access the required offsets directly and display the result.

Quote

Forget one thing sorry for that need to catch also the status of the runways in realtime.

What do you mean by the 'status' of a runway?

Paul

Share this post


Link to post
Share on other sites

You can get the surface type (asphalt, grass etc) from the airports database:

example is for Runway 09 at EGJJ.

        Dim db As AirportsDatabase = FSUIPCConnection.AirportsDatabase
        Dim surfaceType As FsSurface = db.Airports("EGJJ").Runways("09").Surface
        Me.txtSurface.Text = surfaceType.ToString()

        Dim db As AirportsDatabase = FSUIPCConnection.AirportsDatabase
        Dim surfaceType As FsSurface = db.Airports("EGJJ").Runways("09").Surface
        Me.txtSurface.Text = surfaceType.ToString()

The surface wet/dry/icy/snow is available from offset 0x346, BUT it only updates when on the runway. Not in the air.

Paul

Share this post


Link to post
Share on other sites

Hello Paul,

Big problem most of my add-ons I have doesn't use GPS to follow a flight plan or a flightpath.ex:  PMDG DASH-8  Majestic GTN .

For PMDG I have seen offsets to give NAVAID ID and distance somewhere

Majestic Software use NAV 1&2

GTN 750& 650 no idea

So have you an idea to know the nearest Navaid with an other method. Or have you a sample somewhere to share ?

Thanks

Fred

Share this post


Link to post
Share on other sites

Hi Fred,

I can't think of any other ways than those I've already suggested:

1. Get back the Lon/Lat of the navaids in the flight plan from your server.

2. Get the Lon/Lat of the navaids from a database.

3. Get the Lon/Lat of the vor/adf beacon tuned on the radios.

4. Get the distance to the next navaid from the GPS offsets (but this requires a flight plan loaded).

 

Paul

Share this post


Link to post
Share on other sites

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


×