Hi,
I decided to share the code that I created for the third NAV Radio with the help of the wealth of information on the fsdeveloper forums.
Hopefully it helps anybody searching for a code sample
I decided to share the code that I created for the third NAV Radio with the help of the wealth of information on the fsdeveloper forums.
Code:
(L:AB_RD_SCH_CMP, bool) 1 ==
if{
(C:fs9gps:NearestVorItemsNumber, number) (> L:AB_RD_SCH_Max, number)
:01
(L:AB_RD_SCH_Item, number) (>C:fs9gps:NearestVorCurrentLine, enum)
(L:AB_RD_SCH_Item, number) (>C:fs9gps:NearestVorSelectedVor, enum)
(C:fs9gps:NearestVorCurrentFrequency, mhz) (L:YOUR_VOR2fq, number) - abs 0.01 <
if{
(C:fs9gps:NearestVorSelectedVorType) (> L:AB_RD_VOR2_Type, number)
(A:PLANE LATITUDE, degrees) (>C:fs9gps:GeoCalcLatitude1, degrees)
(A:PLANE LONGITUDE, degrees) (>C:fs9gps:GeoCalcLongitude1, degrees)
(C:fs9gps:NearestVorSelectedVorLatitude, degrees) (>L:AB_RD_VOR2Lat, degrees)
(C:fs9gps:NearestVorSelectedVorLongitude, degrees) (>L:AB_RD_VOR2Lon, degrees)
(L:AB_RD_VOR2Lat, degrees) (>C:fs9gps:GeoCalcLatitude2, degrees)
(L:AB_RD_VOR2Lon, degrees) (>C:fs9gps:GeoCalcLongitude2, degrees)
(C:fs9gps:NearestVorCurrentIdent, string) 0 symb ord (> L:AB_RD_VOR2_0, number)
(C:fs9gps:NearestVorCurrentIdent, string) 1 symb ord (> L:AB_RD_VOR2_1, number)
(C:fs9gps:NearestVorCurrentIdent, string) 2 symb ord (> L:AB_RD_VOR2_2, number)
(L:AB_RD_SCH_Max, number) 1 + (> L:AB_RD_SCH_Item, number)
0 (> L:AB_RD_VOR2_INVL, bool)
}
els{
(L:AB_RD_SCH_Item, number) 1 + (> L:AB_RD_SCH_Item, number)
(L:AB_RD_SCH_Item, number) (L:AB_RD_SCH_Max, number) <
if{
g01 }
els{
1 (> L:AB_RD_VOR2_INVL, bool)
0 (> L:AB_RD_VOR2_DIST, number)
0 (> L:AB_RD_VOR2_BRG, number)
0 (> L:AB_RD_VOR2_0, number)
0 (> L:AB_RD_VOR2_1, number)
0 (> L:AB_RD_VOR2_2, number) }
}
0 (> L:AB_RD_SCH_Item, number)
0 (> L:AB_RD_SCH_CMP, bool)
}
els{
50 (>C:fs9gps:NearestVorMaximumItems, enum)
(A:PLANE ALTITUDE, feet) 100 / 25 * 195 min (>C:fs9gps:NearestVorMaximumDistance, nmiles)
(A:PLANE LATITUDE, degrees) (>C:fs9gps:NearestVorCurrentLatitude, degrees)
(A:PLANE LONGITUDE, degrees) (>C:fs9gps:NearestVorCurrentLongitude, degrees)
(L:AB_RD_VOR2_INVL, bool) 0 ==
if{
(C:fs9gps:GeoCalcDistance, nmiles) (> L:AB_RD_VOR2_DIST, number)
(C:fs9gps:GeoCalcBearing, degrees) (> L:AB_RD_VOR2_BRG, number) }
(L:AB_RD_CN, number) 1 + (> L:AB_RD_CN, number)
(L:AB_RD_CN, number) 19 >=
(C:fs9gps:NearestVorItemsNumber, number) 0 != &&
if{
1 (> L:AB_RD_SCH_CMP, bool)
0 (> L:AB_RD_CN, number) }
}
Code:
[B][U]INPUTS[/U][/B]
VOR2 Frequency Input: L:YOUR_VOR2fq, number
[B][U]OUTPUTS[/U][/B]
Coordinates:
L:AB_RD_VOR2Lat, degrees
L:AB_RD_VOR2Lon, degrees
3 LETTER VOR IDENT - ASCII CHARACTER CODING:
L:AB_RD_VOR2_0, number
L:AB_RD_VOR2_1, number
L:AB_RD_VOR2_2, number
Distance to VOR2:
L:AB_RD_VOR2_DIST, number
Bearing to VOR2:
L:AB_RD_VOR2_BRG, number
VOR2 Invalid/No Signal (VOR2 Invalid = 1, VOR2 Reciving Normal = 0) :
L:AB_RD_VOR2_INVL, bool
VOR2 Type (UNKNOWN = 0, VOR = 1, VOR_DME = 2, DME = 3, TACAN = 4, VORTAC = 5, ILS = 6, VOT = 7):
L:AB_RD_VOR2_Type, number
Code:
Notes:
1. There is a timer counter combined with a FS9GPS wait for response to ensure the GPS Module have all the time it needs to scan the VOR.
2. The VOR Reciving distance varies with altitude using data that I collected. 195nm is roughly the absolute Max Distance (at any height) a VOR Receiver can receive according to my data.
3. Three letter Code IDENT is specifically adaptated to transfer to C++ the string. I know there are modules out there that parse a String Value for storage to access into C++ Module, I prefer to keep it simple here. If you only use XML for displays, search FSDeveloper Forums for XML String Storing and Loading.
Hopefully it helps anybody searching for a code sample
Last edited: