| 1 |
## garmin 196 functions |
| 2 |
var last_time = 0.0; |
| 3 |
var last_bearing = -1; |
| 4 |
var tab_chiffres_lettres = ["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]; |
| 5 |
var old_status = -1; |
| 6 |
|
| 7 |
var init_variables = func{ |
| 8 |
##version |
| 9 |
props.globals.getNode("/instrumentation/garmin196/version",1).setValue("JeeP v. 18/03/2012"); |
| 10 |
|
| 11 |
##routes |
| 12 |
props.globals.getNode("/instrumentation/garmin196/menu_routes/search/x_char",1).setIntValue(0); |
| 13 |
props.globals.getNode("/instrumentation/garmin196/menu_routes/search/y_char",1).setIntValue(0); |
| 14 |
props.globals.getNode("/instrumentation/garmin196/menu_routes/fpl-loaded",1).setBoolValue(0); |
| 15 |
props.globals.getNode("/instrumentation/garmin196/menu_routes/waypoint-jump",1).setBoolValue(0); |
| 16 |
|
| 17 |
##points |
| 18 |
props.globals.getNode("/instrumentation/garmin196/menu_points/x_char",1).setIntValue(0); |
| 19 |
props.globals.getNode("/instrumentation/garmin196/menu_points/y_char",1).setIntValue(0); |
| 20 |
|
| 21 |
##aircrafts |
| 22 |
props.globals.getNode("/instrumentation/garmin196/menu_aircraft/x_char",1).setIntValue(0); |
| 23 |
props.globals.getNode("/instrumentation/garmin196/menu_aircraft/y_char",1).setIntValue(0); |
| 24 |
|
| 25 |
##init waypoint system |
| 26 |
props.globals.getNode("/instrumentation/garmin196/panel-wpt-bearing",1).setDoubleValue(0); |
| 27 |
props.globals.getNode("/instrumentation/garmin196/position-wpt-bearing",1).setDoubleValue(0); |
| 28 |
props.globals.getNode("/instrumentation/garmin196/panel-wpt-id",1).setValue("------"); |
| 29 |
props.globals.getNode("/instrumentation/gps/config/drive-autopilot",1).setBoolValue(0); ##pour ne pas interferer avec l'autopilot |
| 30 |
|
| 31 |
##init map system |
| 32 |
props.globals.getNode("/instrumentation/garmin196/map-range",1).setDoubleValue(0.125); |
| 33 |
|
| 34 |
##init dto system |
| 35 |
props.globals.getNode("/instrumentation/garmin196/dto_display/x_char",1).setIntValue(0); |
| 36 |
props.globals.getNode("/instrumentation/garmin196/dto_display/y_char",1).setIntValue(0); |
| 37 |
|
| 38 |
##init saveable variables |
| 39 |
props.globals.getNode("/instrumentation/garmin196/antenne-deg",1).setDoubleValue(30); |
| 40 |
props.globals.getNode("/instrumentation/garmin196/light",1).setDoubleValue(30); |
| 41 |
props.globals.getNode("/instrumentation/garmin196/max-speed",1).setDoubleValue(150); |
| 42 |
props.globals.getNode("/instrumentation/garmin196/cruise-speed",1).setDoubleValue(120); |
| 43 |
props.globals.getNode("/instrumentation/garmin196/fuel-flow",1).setDoubleValue(5); |
| 44 |
props.globals.getNode("/instrumentation/garmin196/no_aircraft",1).setIntValue(0); |
| 45 |
props.globals.getNode("/instrumentation/garmin196/symbols/params/airport",1).setBoolValue(1); |
| 46 |
props.globals.getNode("/instrumentation/garmin196/symbols/params/vor",1).setBoolValue(1); |
| 47 |
props.globals.getNode("/instrumentation/garmin196/symbols/params/ndb",1).setBoolValue(1); |
| 48 |
props.globals.getNode("/instrumentation/garmin196/symbols/params/fix",1).setBoolValue(1); |
| 49 |
props.globals.getNode("/instrumentation/garmin196/symbols/params/twn",1).setBoolValue(1); |
| 50 |
props.globals.getNode("/instrumentation/garmin196/symbols/params/wpt",1).setBoolValue(1); |
| 51 |
|
| 52 |
props.globals.getNode("/instrumentation/garmin196/params/units/distance",1).setIntValue(1); |
| 53 |
props.globals.getNode("/instrumentation/garmin196/params/units/speed",1).setIntValue(1); |
| 54 |
props.globals.getNode("/instrumentation/garmin196/params/units/vert-speed",1).setIntValue(1); |
| 55 |
props.globals.getNode("/instrumentation/garmin196/params/units/altitude",1).setIntValue(1); |
| 56 |
props.globals.getNode("/instrumentation/garmin196/params/units/pressure",1).setIntValue(1); |
| 57 |
props.globals.getNode("/instrumentation/garmin196/params/units/temperature",1).setIntValue(1); |
| 58 |
|
| 59 |
props.globals.getNode("/instrumentation/garmin196/params/filtrage",1).setBoolValue(0); |
| 60 |
props.globals.getNode("/instrumentation/garmin196/params/vnav-indicator",1).setBoolValue(1); |
| 61 |
|
| 62 |
##status du gps |
| 63 |
#0 eteint |
| 64 |
#1 startup page |
| 65 |
#1x map page |
| 66 |
#2x panel page |
| 67 |
#3x position page |
| 68 |
#50 coffee page |
| 69 |
#menus |
| 70 |
#100 = menu gps |
| 71 |
#110 = menu flights |
| 72 |
#120 = menu route |
| 73 |
#130 = menu points |
| 74 |
#140 = menu aircraft |
| 75 |
#150 = menu e6b |
| 76 |
#160 = menu map |
| 77 |
#170 = menu setup |
| 78 |
props.globals.getNode("/instrumentation/garmin196/status",1).setIntValue(0); |
| 79 |
|
| 80 |
##popup windows |
| 81 |
#0 = pas de popup |
| 82 |
#1 = affichage du reglage de la lumiere |
| 83 |
#10,11,12 = dto aviation |
| 84 |
#20 = dto recent |
| 85 |
#30 = dto user |
| 86 |
#40 = nrst airport |
| 87 |
#50 = nrst vor |
| 88 |
#60 = nrst ndb |
| 89 |
#70 = nrst fix |
| 90 |
#80 = nrst cities |
| 91 |
|
| 92 |
props.globals.getNode("/instrumentation/garmin196/popup_status",1).setIntValue(0); |
| 93 |
|
| 94 |
props.globals.getNode("/instrumentation/garmin196/serviceable",1).setBoolValue(0); |
| 95 |
props.globals.getNode("/instrumentation/garmin196/light",1).setDoubleValue(0); |
| 96 |
props.globals.getNode("/instrumentation/garmin196/coffee",1).setIntValue(0); |
| 97 |
|
| 98 |
load_cities(); |
| 99 |
main_loop(); |
| 100 |
} |
| 101 |
#setlistener("/sim/signals/fdm-initialized",,0,0); |
| 102 |
|
| 103 |
var nasalInit = setlistener("/sim/signals/fdm-initialized", func{ |
| 104 |
settimer(init_variables, 2); |
| 105 |
removelistener(nasalInit); |
| 106 |
}); |
| 107 |
|
| 108 |
var load_parameters = func{ |
| 109 |
fgcommand("loadxml", props.Node.new({ filename: getprop("/sim/fg-home")~"/aircraft-data/garmin196.xml", targetnode: "/instrumentation/garmin196/save" })); |
| 110 |
|
| 111 |
if(getprop("/instrumentation/garmin196/save/antenne-deg")!=nil){ |
| 112 |
setprop("/instrumentation/garmin196/antenne-deg",getprop("/instrumentation/garmin196/save/antenne-deg")); |
| 113 |
} |
| 114 |
if(getprop("/instrumentation/garmin196/save/light")!=nil){ |
| 115 |
setprop("/instrumentation/garmin196/light",getprop("/instrumentation/garmin196/save/light")); |
| 116 |
} |
| 117 |
if(getprop("/instrumentation/garmin196/save/max-speed")!=nil){ |
| 118 |
setprop("/instrumentation/garmin196/max-speed",getprop("/instrumentation/garmin196/save/max-speed")); |
| 119 |
} |
| 120 |
if(getprop("/instrumentation/garmin196/save/cruise-speed")!=nil){ |
| 121 |
setprop("/instrumentation/garmin196/cruise-speed",getprop("/instrumentation/garmin196/save/cruise-speed")); |
| 122 |
} |
| 123 |
if(getprop("/instrumentation/garmin196/save/fuel-flow")!=nil){ |
| 124 |
setprop("/instrumentation/garmin196/fuel-flow",getprop("/instrumentation/garmin196/save/fuel-flow")); |
| 125 |
} |
| 126 |
if(getprop("/instrumentation/garmin196/save/no_aircraft")!=nil){ |
| 127 |
setprop("/instrumentation/garmin196/no_aircraft",getprop("/instrumentation/garmin196/save/no_aircraft")); |
| 128 |
} |
| 129 |
if(getprop("/instrumentation/garmin196/save/symbols/params/airport")!=nil){ |
| 130 |
setprop("/instrumentation/garmin196/symbols/params/airport",getprop("/instrumentation/garmin196/save/symbols/params/airport")); |
| 131 |
} |
| 132 |
if(getprop("/instrumentation/garmin196/save/symbols/params/vor")!=nil){ |
| 133 |
setprop("/instrumentation/garmin196/symbols/params/vor",getprop("/instrumentation/garmin196/save/symbols/params/vor")); |
| 134 |
} |
| 135 |
if(getprop("/instrumentation/garmin196/save/symbols/params/ndb")!=nil){ |
| 136 |
setprop("/instrumentation/garmin196/symbols/params/ndb",getprop("/instrumentation/garmin196/save/symbols/params/ndb")); |
| 137 |
} |
| 138 |
if(getprop("/instrumentation/garmin196/save/symbols/params/fix")!=nil){ |
| 139 |
setprop("/instrumentation/garmin196/symbols/params/fix",getprop("/instrumentation/garmin196/save/symbols/params/fix")); |
| 140 |
} |
| 141 |
if(getprop("/instrumentation/garmin196/save/symbols/params/twn")!=nil){ |
| 142 |
setprop("/instrumentation/garmin196/symbols/params/twn",getprop("/instrumentation/garmin196/save/symbols/params/twn")); |
| 143 |
} |
| 144 |
if(getprop("/instrumentation/garmin196/save/symbols/params/wpt")!=nil){ |
| 145 |
setprop("/instrumentation/garmin196/symbols/params/wpt",getprop("/instrumentation/garmin196/save/symbols/params/wpt")); |
| 146 |
} |
| 147 |
|
| 148 |
if(getprop("/instrumentation/garmin196/save/params/units/distance")!=nil){ |
| 149 |
setprop("/instrumentation/garmin196/params/units/distance",getprop("/instrumentation/garmin196/save/params/units/distance")); |
| 150 |
} |
| 151 |
if(getprop("/instrumentation/garmin196/save/params/units/speed")!=nil){ |
| 152 |
setprop("/instrumentation/garmin196/params/units/speed",getprop("/instrumentation/garmin196/save/params/units/speed")); |
| 153 |
} |
| 154 |
if(getprop("/instrumentation/garmin196/save/params/units/vert-speed")!=nil){ |
| 155 |
setprop("/instrumentation/garmin196/params/units/vert-speed",getprop("/instrumentation/garmin196/save/params/units/vert-speed")); |
| 156 |
} |
| 157 |
if(getprop("/instrumentation/garmin196/save/params/units/altitude")!=nil){ |
| 158 |
setprop("/instrumentation/garmin196/params/units/altitude",getprop("/instrumentation/garmin196/save/params/units/altitude")); |
| 159 |
} |
| 160 |
if(getprop("/instrumentation/garmin196/save/params/units/pressure")!=nil){ |
| 161 |
setprop("/instrumentation/garmin196/params/units/pressure",getprop("/instrumentation/garmin196/save/params/units/pressure")); |
| 162 |
} |
| 163 |
if(getprop("/instrumentation/garmin196/save/params/units/temperature")!=nil){ |
| 164 |
setprop("/instrumentation/garmin196/params/units/temperature",getprop("/instrumentation/garmin196/save/params/units/temperature")); |
| 165 |
} |
| 166 |
if(getprop("/instrumentation/garmin196/save/params/filtrage")!=nil){ |
| 167 |
setprop("/instrumentation/garmin196/params/filtrage",getprop("/instrumentation/garmin196/save/params/filtrage")); |
| 168 |
} |
| 169 |
if(getprop("/instrumentation/garmin196/save/params/vnav-indicator")!=nil){ |
| 170 |
setprop("/instrumentation/garmin196/params/vnav-indicator",getprop("/instrumentation/garmin196/save/params/vnav-indicator")); |
| 171 |
} |
| 172 |
|
| 173 |
for(var i=0;i<5;i=i+1){ |
| 174 |
if(getprop("/instrumentation/garmin196/save/waypoints/recent/wpt["~i~"]/id")!=nil){ |
| 175 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/id",1).setValue(getprop("/instrumentation/garmin196/save/waypoints/recent/wpt["~i~"]/id")); |
| 176 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/type",1).setValue(getprop("/instrumentation/garmin196/save/waypoints/recent/wpt["~i~"]/type")); |
| 177 |
} |
| 178 |
} |
| 179 |
|
| 180 |
for(var i=0;i<5;i=i+1){ |
| 181 |
if(getprop("/instrumentation/garmin196/save/waypoints/user/wpt["~i~"]/id")!=nil){ |
| 182 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/id",1).setValue(getprop("/instrumentation/garmin196/save/waypoints/user/wpt["~i~"]/id")); |
| 183 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/latitude",1).setDoubleValue(getprop("/instrumentation/garmin196/save/waypoints/user/wpt["~i~"]/latitude")); |
| 184 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/longitude",1).setDoubleValue(getprop("/instrumentation/garmin196/save/waypoints/user/wpt["~i~"]/longitude")); |
| 185 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/longitude")); |
| 186 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/latitude")); |
| 187 |
props.globals.getNode("/instrumentation/gps/scratch/ident",1).setValue(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/id")~"WPTUSR"); |
| 188 |
setprop("/instrumentation/gps/command","define-user-wpt"); |
| 189 |
} |
| 190 |
} |
| 191 |
|
| 192 |
for(var i=0;i<6;i=i+1){ |
| 193 |
if(getprop("/instrumentation/garmin196/save/params/aircrafts/aircraft["~i~"]/name")!=nil){ |
| 194 |
props.globals.getNode("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/name",1).setValue(getprop("/instrumentation/garmin196/save/params/aircrafts/aircraft["~i~"]/name")); |
| 195 |
props.globals.getNode("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/max-speed",1).setIntValue(getprop("/instrumentation/garmin196/save/params/aircrafts/aircraft["~i~"]/max-speed")); |
| 196 |
props.globals.getNode("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/cruise-speed",1).setIntValue(getprop("/instrumentation/garmin196/save/params/aircrafts/aircraft["~i~"]/cruise-speed")); |
| 197 |
props.globals.getNode("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/fuel-flow",1).setDoubleValue(getprop("/instrumentation/garmin196/save/params/aircrafts/aircraft["~i~"]/fuel-flow")); |
| 198 |
} |
| 199 |
} |
| 200 |
|
| 201 |
for(var i=0;i<9;i=i+1){ |
| 202 |
if(getprop("/instrumentation/garmin196/save/flights/flight["~i~"]/start")!=nil){ |
| 203 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/start",1).setValue(getprop("/instrumentation/garmin196/save/flights/flight["~i~"]/start")); |
| 204 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/end",1).setValue(getprop("/instrumentation/garmin196/save/flights/flight["~i~"]/end")); |
| 205 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/date",1).setValue(getprop("/instrumentation/garmin196/save/flights/flight["~i~"]/date")); |
| 206 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/aircraft",1).setValue(getprop("/instrumentation/garmin196/save/flights/flight["~i~"]/aircraft")); |
| 207 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/distance",1).setDoubleValue(getprop("/instrumentation/garmin196/save/flights/flight["~i~"]/distance")); |
| 208 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/duration",1).setDoubleValue(getprop("/instrumentation/garmin196/save/flights/flight["~i~"]/duration")); |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
for(var i=0;i<11;i=i+1){ |
| 213 |
if(getprop("/instrumentation/garmin196/save/routes/route["~i~"]/name")!=nil){ |
| 214 |
props.globals.getNode("/instrumentation/garmin196/routes/route["~i~"]/name",1).setValue(getprop("/instrumentation/garmin196/save/routes/route["~i~"]/name")); |
| 215 |
for(var j=0;j<10;j=j+1){ |
| 216 |
if(getprop("/instrumentation/garmin196/save/routes/route["~i~"]/wpts/wpt["~j~"]/id")!=nil){ |
| 217 |
props.globals.getNode("/instrumentation/garmin196/routes/route["~i~"]/wpts/wpt["~j~"]/id",1).setValue(getprop("/instrumentation/garmin196/save/routes/route["~i~"]/wpts/wpt["~j~"]/id")); |
| 218 |
props.globals.getNode("/instrumentation/garmin196/routes/route["~i~"]/wpts/wpt["~j~"]/type",1).setValue(getprop("/instrumentation/garmin196/save/routes/route["~i~"]/wpts/wpt["~j~"]/type")); |
| 219 |
} |
| 220 |
} |
| 221 |
} |
| 222 |
} |
| 223 |
} |
| 224 |
setlistener("/sim/signals/fdm-initialized",load_parameters); |
| 225 |
|
| 226 |
var save_parameters = func{ |
| 227 |
props.globals.getNode("/instrumentation/garmin196/save").remove(); |
| 228 |
|
| 229 |
##preparation |
| 230 |
if(getprop("/instrumentation/garmin196/antenne-deg")!=nil){ |
| 231 |
props.globals.getNode("/instrumentation/garmin196/save/antenne-deg",1).setDoubleValue(getprop("/instrumentation/garmin196/antenne-deg")); |
| 232 |
} |
| 233 |
if(getprop("/instrumentation/garmin196/light")!=nil){ |
| 234 |
props.globals.getNode("/instrumentation/garmin196/save/light",1).setDoubleValue(getprop("/instrumentation/garmin196/light")); |
| 235 |
} |
| 236 |
if(getprop("/instrumentation/garmin196/max-speed")!=nil){ |
| 237 |
props.globals.getNode("/instrumentation/garmin196/save/max-speed",1).setDoubleValue(getprop("/instrumentation/garmin196/max-speed")); |
| 238 |
} |
| 239 |
if(getprop("/instrumentation/garmin196/cruise-speed")!=nil){ |
| 240 |
props.globals.getNode("/instrumentation/garmin196/save/cruise-speed",1).setDoubleValue(getprop("/instrumentation/garmin196/cruise-speed")); |
| 241 |
} |
| 242 |
if(getprop("/instrumentation/garmin196/fuel-flow")!=nil){ |
| 243 |
props.globals.getNode("/instrumentation/garmin196/save/fuel-flow",1).setDoubleValue(getprop("/instrumentation/garmin196/fuel-flow")); |
| 244 |
} |
| 245 |
if(getprop("/instrumentation/garmin196/no_aircraft")!=nil){ |
| 246 |
props.globals.getNode("/instrumentation/garmin196/save/no_aircraft",1).setDoubleValue(getprop("/instrumentation/garmin196/no_aircraft")); |
| 247 |
} |
| 248 |
props.globals.getNode("/instrumentation/garmin196/save/symbols/params/airport",1).setDoubleValue(getprop("/instrumentation/garmin196/symbols/params/airport")); |
| 249 |
props.globals.getNode("/instrumentation/garmin196/save/symbols/params/vor",1).setBoolValue(getprop("/instrumentation/garmin196/symbols/params/vor")); |
| 250 |
props.globals.getNode("/instrumentation/garmin196/save/symbols/params/ndb",1).setBoolValue(getprop("/instrumentation/garmin196/symbols/params/ndb")); |
| 251 |
props.globals.getNode("/instrumentation/garmin196/save/symbols/params/fix",1).setBoolValue(getprop("/instrumentation/garmin196/symbols/params/fix")); |
| 252 |
props.globals.getNode("/instrumentation/garmin196/save/symbols/params/twn",1).setBoolValue(getprop("/instrumentation/garmin196/symbols/params/twn")); |
| 253 |
props.globals.getNode("/instrumentation/garmin196/save/symbols/params/wpt",1).setBoolValue(getprop("/instrumentation/garmin196/symbols/params/wpt")); |
| 254 |
|
| 255 |
props.globals.getNode("/instrumentation/garmin196/save/params/units/distance",1).setIntValue(getprop("/instrumentation/garmin196/params/units/distance")); |
| 256 |
props.globals.getNode("/instrumentation/garmin196/save/params/units/speed",1).setIntValue(getprop("/instrumentation/garmin196/params/units/speed")); |
| 257 |
props.globals.getNode("/instrumentation/garmin196/save/params/units/vert-speed",1).setIntValue(getprop("/instrumentation/garmin196/params/units/vert-speed")); |
| 258 |
props.globals.getNode("/instrumentation/garmin196/save/params/units/altitude",1).setIntValue(getprop("/instrumentation/garmin196/params/units/altitude")); |
| 259 |
props.globals.getNode("/instrumentation/garmin196/save/params/units/pressure",1).setIntValue(getprop("/instrumentation/garmin196/params/units/pressure")); |
| 260 |
props.globals.getNode("/instrumentation/garmin196/save/params/units/temperature",1).setIntValue(getprop("/instrumentation/garmin196/params/units/temperature")); |
| 261 |
props.globals.getNode("/instrumentation/garmin196/save/params/filtrage",1).setBoolValue(getprop("/instrumentation/garmin196/params/filtrage")); |
| 262 |
props.globals.getNode("/instrumentation/garmin196/save/params/vnav-indicator",1).setBoolValue(getprop("/instrumentation/garmin196/params/vnav-indicator")); |
| 263 |
|
| 264 |
for(var i=0;i<5;i=i+1){ |
| 265 |
if(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/id")!=nil){ |
| 266 |
props.globals.getNode("/instrumentation/garmin196/save/waypoints/recent/wpt["~i~"]/id",1).setValue(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/id")); |
| 267 |
props.globals.getNode("/instrumentation/garmin196/save/waypoints/recent/wpt["~i~"]/type",1).setValue(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/type")); |
| 268 |
} |
| 269 |
} |
| 270 |
|
| 271 |
for(var i=0;i<9;i=i+1){ |
| 272 |
if(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/id")!=nil){ |
| 273 |
props.globals.getNode("/instrumentation/garmin196/save/waypoints/user/wpt["~i~"]/id",1).setValue(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/id")); |
| 274 |
props.globals.getNode("/instrumentation/garmin196/save/waypoints/user/wpt["~i~"]/latitude",1).setValue(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/latitude")); |
| 275 |
props.globals.getNode("/instrumentation/garmin196/save/waypoints/user/wpt["~i~"]/longitude",1).setValue(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/longitude")); |
| 276 |
} |
| 277 |
} |
| 278 |
|
| 279 |
for(var i=0;i<6;i=i+1){ |
| 280 |
if(getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/name")!=nil){ |
| 281 |
props.globals.getNode("/instrumentation/garmin196/save/params/aircrafts/aircraft["~i~"]/name",1).setValue(getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/name")); |
| 282 |
props.globals.getNode("/instrumentation/garmin196/save/params/aircrafts/aircraft["~i~"]/max-speed",1).setIntValue(getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/max-speed")); |
| 283 |
props.globals.getNode("/instrumentation/garmin196/save/params/aircrafts/aircraft["~i~"]/cruise-speed",1).setIntValue(getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/cruise-speed")); |
| 284 |
props.globals.getNode("/instrumentation/garmin196/save/params/aircrafts/aircraft["~i~"]/fuel-flow",1).setDoubleValue(getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/fuel-flow")); |
| 285 |
} |
| 286 |
} |
| 287 |
for(var i=0;i<8;i=i+1){ |
| 288 |
if(getprop("/instrumentation/garmin196/flights/flight["~i~"]/start")!=nil){ |
| 289 |
props.globals.getNode("/instrumentation/garmin196/save/flights/flight["~i~"]/start",1).setValue(getprop("/instrumentation/garmin196/flights/flight["~i~"]/start")); |
| 290 |
props.globals.getNode("/instrumentation/garmin196/save/flights/flight["~i~"]/end",1).setValue(getprop("/instrumentation/garmin196/flights/flight["~i~"]/end")); |
| 291 |
props.globals.getNode("/instrumentation/garmin196/save/flights/flight["~i~"]/date",1).setValue(getprop("/instrumentation/garmin196/flights/flight["~i~"]/date")); |
| 292 |
props.globals.getNode("/instrumentation/garmin196/save/flights/flight["~i~"]/aircraft",1).setValue(getprop("/instrumentation/garmin196/flights/flight["~i~"]/aircraft")); |
| 293 |
props.globals.getNode("/instrumentation/garmin196/save/flights/flight["~i~"]/distance",1).setDoubleValue(getprop("/instrumentation/garmin196/flights/flight["~i~"]/distance")); |
| 294 |
props.globals.getNode("/instrumentation/garmin196/save/flights/flight["~i~"]/duration",1).setDoubleValue(getprop("/instrumentation/garmin196/flights/flight["~i~"]/duration")); |
| 295 |
} |
| 296 |
} |
| 297 |
for(var i=0;i<11;i=i+1){ |
| 298 |
if(getprop("/instrumentation/garmin196/routes/route["~i~"]/name")!=nil){ |
| 299 |
props.globals.getNode("/instrumentation/garmin196/save/routes/route["~i~"]/name",1).setValue(getprop("/instrumentation/garmin196/routes/route["~i~"]/name")); |
| 300 |
for(var j=0;j<10;j=j+1){ |
| 301 |
if(getprop("/instrumentation/garmin196/routes/route["~i~"]/wpts/wpt["~j~"]/id")!=nil){ |
| 302 |
props.globals.getNode("/instrumentation/garmin196/save/routes/route["~i~"]/wpts/wpt["~j~"]/id",1).setValue(getprop("/instrumentation/garmin196/routes/route["~i~"]/wpts/wpt["~j~"]/id")); |
| 303 |
props.globals.getNode("/instrumentation/garmin196/save/routes/route["~i~"]/wpts/wpt["~j~"]/type",1).setValue(getprop("/instrumentation/garmin196/routes/route["~i~"]/wpts/wpt["~j~"]/type")); |
| 304 |
} |
| 305 |
} |
| 306 |
} |
| 307 |
} |
| 308 |
##delete file before saving to delete keys |
| 309 |
var file = io.open(getprop("/sim/fg-home")~"/aircraft-data/garmin196.xml", mode="w"); |
| 310 |
io.write(file,""); |
| 311 |
io.close(file); |
| 312 |
fgcommand("savexml", props.Node.new({ filename: getprop("/sim/fg-home")~"/aircraft-data/garmin196.xml", sourcenode: "/instrumentation/garmin196/save" })); |
| 313 |
} |
| 314 |
|
| 315 |
var main_loop = func{ |
| 316 |
var time = getprop("/sim/time/elapsed-sec"); |
| 317 |
var dt = time - last_time; |
| 318 |
last_time = time; |
| 319 |
|
| 320 |
calcul_turn_rate(dt); |
| 321 |
change_speed_display(); |
| 322 |
change_position_wpt_bug(); |
| 323 |
update_flight(); |
| 324 |
update_e6b_menu(); |
| 325 |
|
| 326 |
settimer(main_loop, 0.3); |
| 327 |
} |
| 328 |
|
| 329 |
var nyi = func (x) { gui.popupTip(x ~ ": not yet implemented", 3); } |
| 330 |
|
| 331 |
var power = func (x){ |
| 332 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 333 |
if(x==0){ |
| 334 |
if(serviceable==1){ |
| 335 |
setprop("/instrumentation/garmin196/serviceable",0); |
| 336 |
setprop("/instrumentation/garmin196/status",0); |
| 337 |
setprop("/instrumentation/garmin196/popup_status",0); |
| 338 |
}else{ |
| 339 |
setprop("/instrumentation/garmin196/serviceable",1); |
| 340 |
setprop("/instrumentation/garmin196/status",1); |
| 341 |
} |
| 342 |
} |
| 343 |
|
| 344 |
if(x==1 and serviceable==1){ |
| 345 |
setprop("/instrumentation/garmin196/popup_status",1) |
| 346 |
} |
| 347 |
|
| 348 |
} |
| 349 |
|
| 350 |
var in = func (x){ |
| 351 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 352 |
if(serviceable==1){ |
| 353 |
var status = getprop("/instrumentation/garmin196/status"); |
| 354 |
if(x==0){ |
| 355 |
##traitement des pages |
| 356 |
if(status==10){ |
| 357 |
var range = getprop("/instrumentation/garmin196/map-range"); |
| 358 |
range = range / 2; |
| 359 |
if(range<0.125){ |
| 360 |
range = 0.125; |
| 361 |
} |
| 362 |
setprop("/instrumentation/garmin196/map-range",range); |
| 363 |
return; |
| 364 |
} |
| 365 |
}elsif(x==1){ |
| 366 |
if(getprop("/instrumentation/garmin196/coffee")==2 and status>=10){ |
| 367 |
setprop("/instrumentation/garmin196/coffee",0); |
| 368 |
setprop("/instrumentation/garmin196/status",50); |
| 369 |
} |
| 370 |
} |
| 371 |
} |
| 372 |
} |
| 373 |
|
| 374 |
var out = func (x){ |
| 375 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 376 |
if(serviceable==1){ |
| 377 |
var status = getprop("/instrumentation/garmin196/status"); |
| 378 |
if(x==0){ |
| 379 |
##traitement des pages |
| 380 |
if(status==10){ |
| 381 |
var range = getprop("/instrumentation/garmin196/map-range"); |
| 382 |
range = range * 2; |
| 383 |
if(range>32){ |
| 384 |
range = 32; |
| 385 |
} |
| 386 |
setprop("/instrumentation/garmin196/map-range",range); |
| 387 |
return; |
| 388 |
} |
| 389 |
}elsif(x==1){ |
| 390 |
if(getprop("/instrumentation/garmin196/coffee")==1 and status>=10){ |
| 391 |
setprop("/instrumentation/garmin196/coffee",2); |
| 392 |
} |
| 393 |
} |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
var page = func (x){ |
| 398 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 399 |
if(serviceable==1){ |
| 400 |
var status = getprop("/instrumentation/garmin196/status"); |
| 401 |
if(x==0){ |
| 402 |
##traitement des pages |
| 403 |
if(status==10){ |
| 404 |
setprop("/instrumentation/garmin196/status",20); |
| 405 |
return; |
| 406 |
} |
| 407 |
|
| 408 |
if(status==20){ |
| 409 |
setprop("/instrumentation/garmin196/status",30); |
| 410 |
return; |
| 411 |
} |
| 412 |
|
| 413 |
if(status==30){ |
| 414 |
setprop("/instrumentation/garmin196/status",10); |
| 415 |
update_map(); |
| 416 |
return; |
| 417 |
} |
| 418 |
|
| 419 |
if(status==50){ |
| 420 |
setprop("/instrumentation/garmin196/status",10); |
| 421 |
update_map(); |
| 422 |
return; |
| 423 |
} |
| 424 |
}elsif(x==1){ |
| 425 |
if(getprop("/instrumentation/garmin196/coffee")==0 and status>=10){ |
| 426 |
setprop("/instrumentation/garmin196/coffee",1); |
| 427 |
} |
| 428 |
} |
| 429 |
} |
| 430 |
} |
| 431 |
|
| 432 |
var quit = func (x){ |
| 433 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 434 |
if(serviceable==1){ |
| 435 |
if(x==0){ |
| 436 |
#traitement des popup |
| 437 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 438 |
if(popup_status==1){ |
| 439 |
setprop("/instrumentation/garmin196/popup_status",0); |
| 440 |
save_parameters(); |
| 441 |
return; |
| 442 |
} |
| 443 |
if(popup_status>=10 and popup_status<=99){ |
| 444 |
setprop("/instrumentation/garmin196/popup_status",0); |
| 445 |
return; |
| 446 |
} |
| 447 |
|
| 448 |
##traitement des pages |
| 449 |
var status = getprop("/instrumentation/garmin196/status"); |
| 450 |
if(status==10){ |
| 451 |
setprop("/instrumentation/garmin196/status",30); |
| 452 |
return; |
| 453 |
} |
| 454 |
|
| 455 |
if(status==20){ |
| 456 |
setprop("/instrumentation/garmin196/status",10); |
| 457 |
update_map(); |
| 458 |
return; |
| 459 |
} |
| 460 |
|
| 461 |
if(status==30){ |
| 462 |
setprop("/instrumentation/garmin196/status",20); |
| 463 |
return; |
| 464 |
} |
| 465 |
|
| 466 |
if(status==50){ |
| 467 |
setprop("/instrumentation/garmin196/status",10); |
| 468 |
update_map(); |
| 469 |
return; |
| 470 |
} |
| 471 |
|
| 472 |
if(status==111){ |
| 473 |
setprop("/instrumentation/garmin196/status",110); |
| 474 |
setprop("/instrumentation/garmin196/menu_flights/no_ligne_selected",-1); |
| 475 |
return; |
| 476 |
} |
| 477 |
|
| 478 |
if(status==112){ |
| 479 |
setprop("/instrumentation/garmin196/status",111); |
| 480 |
return; |
| 481 |
} |
| 482 |
|
| 483 |
##menu routes |
| 484 |
if(status==121){ |
| 485 |
setprop("/instrumentation/garmin196/status",120); |
| 486 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_selected",-1); |
| 487 |
return; |
| 488 |
} |
| 489 |
|
| 490 |
if(status==122){ |
| 491 |
setprop("/instrumentation/garmin196/status",121); |
| 492 |
save_parameters(); |
| 493 |
return; |
| 494 |
} |
| 495 |
|
| 496 |
if(status==123){ |
| 497 |
setprop("/instrumentation/garmin196/status",122); |
| 498 |
return; |
| 499 |
} |
| 500 |
|
| 501 |
if(status==124){ |
| 502 |
setprop("/instrumentation/garmin196/status",123); |
| 503 |
return; |
| 504 |
} |
| 505 |
|
| 506 |
##menu points |
| 507 |
if(status==131){ |
| 508 |
setprop("/instrumentation/garmin196/status",130); |
| 509 |
setprop("/instrumentation/garmin196/menu_points/no_ligne_selected",-1); |
| 510 |
init_list_points(); |
| 511 |
return; |
| 512 |
} |
| 513 |
|
| 514 |
if(status==132){ |
| 515 |
setprop("/instrumentation/garmin196/status",131); |
| 516 |
return; |
| 517 |
} |
| 518 |
|
| 519 |
if(status==133){ |
| 520 |
setprop("/instrumentation/garmin196/status",132); |
| 521 |
return; |
| 522 |
} |
| 523 |
|
| 524 |
if(status==134){ |
| 525 |
setprop("/instrumentation/garmin196/status",133); |
| 526 |
return; |
| 527 |
} |
| 528 |
|
| 529 |
if(status==135){ |
| 530 |
setprop("/instrumentation/garmin196/status",134); |
| 531 |
return; |
| 532 |
} |
| 533 |
|
| 534 |
if(status==136){ |
| 535 |
setprop("/instrumentation/garmin196/status",135); |
| 536 |
return; |
| 537 |
} |
| 538 |
|
| 539 |
##menu aircraft |
| 540 |
if(status==141){ |
| 541 |
setprop("/instrumentation/garmin196/status",140); |
| 542 |
setprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected",-1); |
| 543 |
init_list_aircraft(); |
| 544 |
display_list_aircraft(); |
| 545 |
return; |
| 546 |
} |
| 547 |
|
| 548 |
if(status==142){ |
| 549 |
setprop("/instrumentation/garmin196/status",141); |
| 550 |
display_list_aircraft(); |
| 551 |
return; |
| 552 |
} |
| 553 |
|
| 554 |
if(status==143){ |
| 555 |
setprop("/instrumentation/garmin196/status",142); |
| 556 |
return; |
| 557 |
} |
| 558 |
|
| 559 |
if(status==144){ |
| 560 |
setprop("/instrumentation/garmin196/status",143); |
| 561 |
return; |
| 562 |
} |
| 563 |
|
| 564 |
if(status==145){ |
| 565 |
setprop("/instrumentation/garmin196/status",144); |
| 566 |
return; |
| 567 |
} |
| 568 |
|
| 569 |
##menu map |
| 570 |
if(status==161){ |
| 571 |
setprop("/instrumentation/garmin196/status",160); |
| 572 |
setprop("/instrumentation/garmin196/menu_map/no_ligne_selected",-1); |
| 573 |
return; |
| 574 |
} |
| 575 |
|
| 576 |
##menu setup |
| 577 |
if(status==171){ |
| 578 |
setprop("/instrumentation/garmin196/status",170); |
| 579 |
setprop("/instrumentation/garmin196/menu_setup/no_ligne_selected",-1); |
| 580 |
return; |
| 581 |
} |
| 582 |
|
| 583 |
if(status==176){ |
| 584 |
setprop("/instrumentation/garmin196/status",175); |
| 585 |
setprop("/instrumentation/garmin196/menu_setup/no_ligne_selected",-1); |
| 586 |
return; |
| 587 |
} |
| 588 |
|
| 589 |
if(status>=100 and status <180){ |
| 590 |
if(old_status>=10){ |
| 591 |
status = old_status; |
| 592 |
}else{ |
| 593 |
status = 10; |
| 594 |
} |
| 595 |
setprop("/instrumentation/garmin196/status",status); |
| 596 |
if(status==10){ |
| 597 |
update_map(); |
| 598 |
} |
| 599 |
return; |
| 600 |
} |
| 601 |
} |
| 602 |
} |
| 603 |
} |
| 604 |
|
| 605 |
var enter = func (x){ |
| 606 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 607 |
if(serviceable==1){ |
| 608 |
if(x==0){ |
| 609 |
#traitement des popup |
| 610 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 611 |
if(popup_status==1){ |
| 612 |
setprop("/instrumentation/garmin196/popup_status",0); |
| 613 |
save_parameters(); |
| 614 |
return; |
| 615 |
} |
| 616 |
|
| 617 |
if(popup_status==10){ |
| 618 |
setprop("/instrumentation/garmin196/popup_status",11); |
| 619 |
display_dto_search(); |
| 620 |
return; |
| 621 |
} |
| 622 |
|
| 623 |
if(popup_status==11){ |
| 624 |
if(getprop("/instrumentation/garmin196/dto_display/max_ligne_selected")>=0){ |
| 625 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne[0]/selected",1).setBoolValue(1); |
| 626 |
setprop("/instrumentation/garmin196/popup_status",12); |
| 627 |
return; |
| 628 |
} |
| 629 |
} |
| 630 |
|
| 631 |
if(popup_status==12 or popup_status==30){ |
| 632 |
setprop("/instrumentation/garmin196/popup_status",0); |
| 633 |
var id = getprop("/instrumentation/garmin196/dto_display/ligne["~getprop("/instrumentation/garmin196/dto_display/no_ligne_selected")~"]/id"); |
| 634 |
var type = getprop("/instrumentation/garmin196/dto_display/ligne["~getprop("/instrumentation/garmin196/dto_display/no_ligne_selected")~"]/type"); |
| 635 |
affectation_waypoint(id); |
| 636 |
##rolling recents waypoints |
| 637 |
var existe_deja = 0; |
| 638 |
for(var i=0;i<5;i=i+1){ |
| 639 |
if(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/id")==id){ |
| 640 |
existe_deja = 1; |
| 641 |
break; |
| 642 |
} |
| 643 |
} |
| 644 |
if(existe_deja==0){ |
| 645 |
for(var i=4;i>0;i=i-1){ |
| 646 |
if(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~(i-1)~"]/id")){ |
| 647 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/id",1).setValue(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~(i-1)~"]/id")); |
| 648 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/type",1).setValue(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~(i-1)~"]/type")); |
| 649 |
} |
| 650 |
} |
| 651 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt[0]/id",1).setValue(id); |
| 652 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt[0]/type",1).setValue(type); |
| 653 |
save_parameters(); |
| 654 |
} |
| 655 |
return; |
| 656 |
} |
| 657 |
|
| 658 |
if(popup_status==20){ |
| 659 |
setprop("/instrumentation/garmin196/popup_status",0); |
| 660 |
var id = getprop("/instrumentation/garmin196/dto_display/ligne["~getprop("/instrumentation/garmin196/dto_display/no_ligne_selected")~"]/id"); |
| 661 |
var type = getprop("/instrumentation/garmin196/dto_display/ligne["~getprop("/instrumentation/garmin196/dto_display/no_ligne_selected")~"]/type"); |
| 662 |
affectation_waypoint(id); |
| 663 |
return; |
| 664 |
} |
| 665 |
|
| 666 |
if(popup_status>30 and popup_status<=89){ |
| 667 |
setprop("/instrumentation/garmin196/popup_status",0); |
| 668 |
var id = getprop("/instrumentation/garmin196/nrst_display/ligne["~getprop("/instrumentation/garmin196/nrst_display/no_ligne_selected")~"]/id"); |
| 669 |
var type = getprop("/instrumentation/garmin196/nrst_display/ligne["~getprop("/instrumentation/garmin196/nrst_display/no_ligne_selected")~"]/type"); |
| 670 |
affectation_waypoint(id); |
| 671 |
##rolling recents waypoints |
| 672 |
var existe_deja = 0; |
| 673 |
for(var i=0;i<5;i=i+1){ |
| 674 |
if(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/id")==id){ |
| 675 |
existe_deja = 1; |
| 676 |
break; |
| 677 |
} |
| 678 |
} |
| 679 |
if(existe_deja==0){ |
| 680 |
for(var i=4;i>0;i=i-1){ |
| 681 |
if(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~(i-1)~"]/id")){ |
| 682 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/id",1).setValue(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~(i-1)~"]/id")); |
| 683 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt["~i~"]/type",1).setValue(getprop("/instrumentation/garmin196/waypoints/recent/wpt["~(i-1)~"]/type")); |
| 684 |
} |
| 685 |
} |
| 686 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt[0]/id",1).setValue(id); |
| 687 |
props.globals.getNode("/instrumentation/garmin196/waypoints/recent/wpt[0]/type",1).setValue(type); |
| 688 |
save_parameters(); |
| 689 |
} |
| 690 |
return; |
| 691 |
} |
| 692 |
|
| 693 |
##validation de la startup page |
| 694 |
var status = getprop("/instrumentation/garmin196/status"); |
| 695 |
if(status==1){ |
| 696 |
setprop("/instrumentation/garmin196/status",10); |
| 697 |
update_map(); |
| 698 |
return; |
| 699 |
} |
| 700 |
|
| 701 |
if(status==110){ |
| 702 |
if(getprop("/instrumentation/garmin196/menu_flights/max_ligne_selected")>=0){ |
| 703 |
setprop("/instrumentation/garmin196/menu_flights/no_ligne_selected",0); |
| 704 |
setprop("/instrumentation/garmin196/status",111); |
| 705 |
} |
| 706 |
return; |
| 707 |
} |
| 708 |
|
| 709 |
if(status==111){ |
| 710 |
update_menu_flights_detail(); |
| 711 |
setprop("/instrumentation/garmin196/status",112); |
| 712 |
return; |
| 713 |
} |
| 714 |
|
| 715 |
if(status==112){ |
| 716 |
setprop("/instrumentation/garmin196/status",111); |
| 717 |
return; |
| 718 |
} |
| 719 |
|
| 720 |
if(status==120){ |
| 721 |
setprop("/instrumentation/garmin196/status",121); |
| 722 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_selected",0); |
| 723 |
return; |
| 724 |
} |
| 725 |
|
| 726 |
if(status==121){ |
| 727 |
setprop("/instrumentation/garmin196/status",122); |
| 728 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 729 |
if(getprop("/instrumentation/garmin196/routes/route["~no_ligne~"]/name")==nil){ |
| 730 |
init_new_route(no_ligne); |
| 731 |
} |
| 732 |
update_menu_routes_detail(); |
| 733 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_detail",0); |
| 734 |
return; |
| 735 |
} |
| 736 |
|
| 737 |
if(status==122){ |
| 738 |
setprop("/instrumentation/garmin196/status",123); |
| 739 |
var no_ligne_liste = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 740 |
var no_ligne_detail = getprop("/instrumentation/garmin196/menu_routes/no_ligne_detail"); |
| 741 |
if(getprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~no_ligne_detail~"]/id")==nil){ |
| 742 |
init_search_route("0"); |
| 743 |
}else{ |
| 744 |
init_search_route(getprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~no_ligne_detail~"]/id")); |
| 745 |
} |
| 746 |
setprop("/instrumentation/garmin196/menu_routes/search/no_ligne_selected",-1); |
| 747 |
return; |
| 748 |
} |
| 749 |
|
| 750 |
if(status==123){ |
| 751 |
if(getprop("/instrumentation/garmin196/menu_routes/search/max_ligne_selected")>=0){ |
| 752 |
setprop("/instrumentation/garmin196/status",124); |
| 753 |
setprop("/instrumentation/garmin196/menu_routes/search/no_ligne_selected",0); |
| 754 |
} |
| 755 |
return; |
| 756 |
} |
| 757 |
|
| 758 |
if(status==124){ |
| 759 |
validate_menu_search_routes(); |
| 760 |
update_menu_routes_detail(); |
| 761 |
init_menu_routes_list(); |
| 762 |
setprop("/instrumentation/garmin196/status",122); |
| 763 |
return; |
| 764 |
} |
| 765 |
|
| 766 |
if(status==130){ |
| 767 |
setprop("/instrumentation/garmin196/status",131); |
| 768 |
setprop("/instrumentation/garmin196/menu_points/no_ligne_selected",0); |
| 769 |
return; |
| 770 |
} |
| 771 |
|
| 772 |
if(status==131){ |
| 773 |
setprop("/instrumentation/garmin196/status",132); |
| 774 |
var no_ligne = getprop("/instrumentation/garmin196/menu_points/no_ligne_selected"); |
| 775 |
if(getprop("/instrumentation/garmin196/waypoints/user/wpt["~no_ligne~"]/id")==nil){ |
| 776 |
init_new_point(no_ligne); |
| 777 |
} |
| 778 |
update_menu_points(); |
| 779 |
return; |
| 780 |
} |
| 781 |
|
| 782 |
if(status==132){ |
| 783 |
setprop("/instrumentation/garmin196/status",133); |
| 784 |
return; |
| 785 |
} |
| 786 |
|
| 787 |
if(status==133){ |
| 788 |
setprop("/instrumentation/garmin196/status",134); |
| 789 |
return; |
| 790 |
} |
| 791 |
|
| 792 |
if(status==134){ |
| 793 |
setprop("/instrumentation/garmin196/status",135); |
| 794 |
return; |
| 795 |
} |
| 796 |
|
| 797 |
if(status==135){ |
| 798 |
setprop("/instrumentation/garmin196/status",136); |
| 799 |
return; |
| 800 |
} |
| 801 |
|
| 802 |
if(status==136){ |
| 803 |
setprop("/instrumentation/garmin196/status",131); |
| 804 |
validate_menu_points(); |
| 805 |
init_list_points(); |
| 806 |
return; |
| 807 |
} |
| 808 |
|
| 809 |
if(status==140){ |
| 810 |
setprop("/instrumentation/garmin196/status",141); |
| 811 |
setprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected",getprop("/instrumentation/garmin196/no_aircraft")); |
| 812 |
display_list_aircraft(); |
| 813 |
return; |
| 814 |
} |
| 815 |
|
| 816 |
if(status==141){ |
| 817 |
setprop("/instrumentation/garmin196/status",142); |
| 818 |
var no_ligne = getprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected"); |
| 819 |
if(getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/name")==nil){ |
| 820 |
init_new_aircraft(no_ligne); |
| 821 |
} |
| 822 |
init_menu_aircraft(); |
| 823 |
return; |
| 824 |
} |
| 825 |
|
| 826 |
if(status==142){ |
| 827 |
setprop("/instrumentation/garmin196/status",143); |
| 828 |
return; |
| 829 |
} |
| 830 |
|
| 831 |
if(status==143){ |
| 832 |
setprop("/instrumentation/garmin196/status",144); |
| 833 |
return; |
| 834 |
} |
| 835 |
|
| 836 |
if(status==144){ |
| 837 |
setprop("/instrumentation/garmin196/status",145); |
| 838 |
return; |
| 839 |
} |
| 840 |
|
| 841 |
if(status==145){ |
| 842 |
setprop("/instrumentation/garmin196/status",141); |
| 843 |
validate_menu_aircraft(); |
| 844 |
init_list_aircraft(); |
| 845 |
display_list_aircraft(); |
| 846 |
return; |
| 847 |
} |
| 848 |
|
| 849 |
##menu map |
| 850 |
if(status==160){ |
| 851 |
setprop("/instrumentation/garmin196/status",161); |
| 852 |
setprop("/instrumentation/garmin196/menu_map/no_ligne_selected",0); |
| 853 |
return; |
| 854 |
} |
| 855 |
|
| 856 |
if(status==161){ |
| 857 |
var no_ligne = getprop("/instrumentation/garmin196/menu_map/no_ligne_selected"); |
| 858 |
if(no_ligne==0){ |
| 859 |
setprop("/instrumentation/garmin196/symbols/params/airport",(getprop("/instrumentation/garmin196/symbols/params/airport")==1 ? 0 : 1)); |
| 860 |
} |
| 861 |
if(no_ligne==1){ |
| 862 |
setprop("/instrumentation/garmin196/symbols/params/vor",(getprop("/instrumentation/garmin196/symbols/params/vor")==1 ? 0 : 1)); |
| 863 |
} |
| 864 |
if(no_ligne==2){ |
| 865 |
setprop("/instrumentation/garmin196/symbols/params/ndb",(getprop("/instrumentation/garmin196/symbols/params/ndb")==1 ? 0 : 1)); |
| 866 |
} |
| 867 |
if(no_ligne==3){ |
| 868 |
setprop("/instrumentation/garmin196/symbols/params/fix",(getprop("/instrumentation/garmin196/symbols/params/fix")==1 ? 0 : 1)); |
| 869 |
} |
| 870 |
if(no_ligne==4){ |
| 871 |
setprop("/instrumentation/garmin196/symbols/params/twn",(getprop("/instrumentation/garmin196/symbols/params/twn")==1 ? 0 : 1)); |
| 872 |
} |
| 873 |
if(no_ligne==5){ |
| 874 |
setprop("/instrumentation/garmin196/symbols/params/wpt",(getprop("/instrumentation/garmin196/symbols/params/wpt")==1 ? 0 : 1)); |
| 875 |
} |
| 876 |
save_parameters(); |
| 877 |
return; |
| 878 |
} |
| 879 |
|
| 880 |
##menu setup |
| 881 |
if(status==170){ |
| 882 |
setprop("/instrumentation/garmin196/status",171); |
| 883 |
setprop("/instrumentation/garmin196/menu_setup/no_ligne_selected",0); |
| 884 |
return; |
| 885 |
} |
| 886 |
|
| 887 |
if(status==171){ |
| 888 |
var no_ligne = getprop("/instrumentation/garmin196/menu_setup/no_ligne_selected"); |
| 889 |
if(no_ligne==0){ |
| 890 |
setprop("/instrumentation/garmin196/params/units/distance",(getprop("/instrumentation/garmin196/params/units/distance")==1 ? 2 : 1)); |
| 891 |
} |
| 892 |
if(no_ligne==1){ |
| 893 |
setprop("/instrumentation/garmin196/params/units/speed",(getprop("/instrumentation/garmin196/params/units/speed")==1 ? 2 : 1)); |
| 894 |
} |
| 895 |
if(no_ligne==2){ |
| 896 |
setprop("/instrumentation/garmin196/params/units/vert-speed",(getprop("/instrumentation/garmin196/params/units/vert-speed")==1 ? 2 : 1)); |
| 897 |
} |
| 898 |
if(no_ligne==3){ |
| 899 |
setprop("/instrumentation/garmin196/params/units/altitude",(getprop("/instrumentation/garmin196/params/units/altitude")==1 ? 2 : 1)); |
| 900 |
} |
| 901 |
if(no_ligne==4){ |
| 902 |
setprop("/instrumentation/garmin196/params/units/pressure",(getprop("/instrumentation/garmin196/params/units/pressure")==1 ? 2 : 1)); |
| 903 |
} |
| 904 |
if(no_ligne==5){ |
| 905 |
setprop("/instrumentation/garmin196/params/units/temperature",(getprop("/instrumentation/garmin196/params/units/temperature")==1 ? 2 : 1)); |
| 906 |
} |
| 907 |
save_parameters(); |
| 908 |
return; |
| 909 |
} |
| 910 |
|
| 911 |
if(status==175){ |
| 912 |
setprop("/instrumentation/garmin196/status",176); |
| 913 |
setprop("/instrumentation/garmin196/menu_setup/no_ligne_selected",0); |
| 914 |
return; |
| 915 |
} |
| 916 |
if(status==176){ |
| 917 |
var no_ligne = getprop("/instrumentation/garmin196/menu_setup/no_ligne_selected"); |
| 918 |
if(no_ligne==0){ |
| 919 |
setprop("/instrumentation/garmin196/params/filtrage",(getprop("/instrumentation/garmin196/params/filtrage")==0 ? 1 : 0)); |
| 920 |
} |
| 921 |
if(no_ligne==1){ |
| 922 |
setprop("/instrumentation/garmin196/params/vnav-indicator",(getprop("/instrumentation/garmin196/params/vnav-indicator")==0 ? 1 : 0)); |
| 923 |
} |
| 924 |
save_parameters(); |
| 925 |
return; |
| 926 |
} |
| 927 |
|
| 928 |
}elsif(x==1){ |
| 929 |
#traitement des popup |
| 930 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 931 |
var status = getprop("/instrumentation/garmin196/status"); |
| 932 |
if(popup_status==0){##pas de popup |
| 933 |
if(status>=10 and status<=39){ |
| 934 |
old_status = status; |
| 935 |
setprop("/instrumentation/garmin196/status",132); |
| 936 |
setprop("/instrumentation/garmin196/menu_points/no_ligne_selected",0); |
| 937 |
var points = props.globals.getNode("/instrumentation/garmin196/waypoints/user/",1).getChildren("wpt"); |
| 938 |
for(var i=size(points)-1;i>=0;i=i-1){ |
| 939 |
if(i<8){ |
| 940 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~(i+1)~"]/id",1).setValue(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/id")); |
| 941 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~(i+1)~"]/latitude",1).setValue(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/latitude")); |
| 942 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~(i+1)~"]/longitude",1).setValue(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/longitude")); |
| 943 |
} |
| 944 |
} |
| 945 |
init_new_point(0); |
| 946 |
update_menu_points(); |
| 947 |
#init_list_points(); |
| 948 |
} |
| 949 |
} |
| 950 |
} |
| 951 |
} |
| 952 |
} |
| 953 |
|
| 954 |
var menu = func (x){ |
| 955 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 956 |
var status = getprop("/instrumentation/garmin196/status"); |
| 957 |
if(serviceable==1){ |
| 958 |
if(status>=10 and status<100){ |
| 959 |
old_status = status; |
| 960 |
setprop("/instrumentation/garmin196/status",100); |
| 961 |
setprop("/instrumentation/garmin196/popup_status",0); |
| 962 |
|
| 963 |
##particularite map |
| 964 |
if(status==10){ |
| 965 |
setprop("/instrumentation/garmin196/status",160); |
| 966 |
setprop("/instrumentation/garmin196/menu_map/no_ligne_selected",-1); |
| 967 |
} |
| 968 |
}elsif(status>=100){ |
| 969 |
if(old_status>=10){ |
| 970 |
status = old_status; |
| 971 |
}else{ |
| 972 |
status = 10; |
| 973 |
} |
| 974 |
setprop("/instrumentation/garmin196/status",status); |
| 975 |
} |
| 976 |
} |
| 977 |
} |
| 978 |
|
| 979 |
var nrst = func (x){ |
| 980 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 981 |
var status = getprop("/instrumentation/garmin196/status"); |
| 982 |
if(serviceable==1 and status>1 and status<100){ |
| 983 |
if(x==0){ |
| 984 |
setprop("/instrumentation/garmin196/popup_status",40); |
| 985 |
display_nrst("airport"); |
| 986 |
} |
| 987 |
} |
| 988 |
} |
| 989 |
|
| 990 |
var dto = func (x){ |
| 991 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 992 |
var status = getprop("/instrumentation/garmin196/status"); |
| 993 |
if(serviceable==1 and status>1 and status<100){ |
| 994 |
if(x==0){ |
| 995 |
setprop("/instrumentation/garmin196/popup_status",10); |
| 996 |
setprop("/instrumentation/garmin196/dto_display/ligne_select","Press Enter to search"); |
| 997 |
init_dto_display(); |
| 998 |
setprop("/instrumentation/garmin196/dto_display/x_char",0); |
| 999 |
setprop("/instrumentation/garmin196/dto_display/y_char",0); |
| 1000 |
} |
| 1001 |
} |
| 1002 |
} |
| 1003 |
|
| 1004 |
var rockerup = func (x){ |
| 1005 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 1006 |
if(serviceable==1){ |
| 1007 |
if(x==0){ |
| 1008 |
#traitement des popup |
| 1009 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 1010 |
|
| 1011 |
if(popup_status==1){ |
| 1012 |
var light_level = getprop("/instrumentation/garmin196/light"); |
| 1013 |
light_level = light_level + 0.1; |
| 1014 |
if(light_level>1){ |
| 1015 |
light_level = 1; |
| 1016 |
} |
| 1017 |
setprop("/instrumentation/garmin196/light",light_level); |
| 1018 |
return; |
| 1019 |
} |
| 1020 |
|
| 1021 |
if(popup_status==11){ |
| 1022 |
var y_char = getprop("/instrumentation/garmin196/dto_display/y_char"); |
| 1023 |
y_char = y_char + 1; |
| 1024 |
if(y_char>35){ |
| 1025 |
y_char = 0; |
| 1026 |
} |
| 1027 |
setprop("/instrumentation/garmin196/dto_display/y_char",y_char); |
| 1028 |
display_dto_search(); |
| 1029 |
return; |
| 1030 |
} |
| 1031 |
|
| 1032 |
if(popup_status==12){ |
| 1033 |
var no_ligne = getprop("/instrumentation/garmin196/dto_display/no_ligne_selected"); |
| 1034 |
var old_no_ligne = no_ligne; |
| 1035 |
no_ligne = no_ligne - 1; |
| 1036 |
if(no_ligne<0){ |
| 1037 |
no_ligne = 0; |
| 1038 |
} |
| 1039 |
setprop("/instrumentation/garmin196/dto_display/no_ligne_selected",no_ligne); |
| 1040 |
if(old_no_ligne!=no_ligne){ |
| 1041 |
setprop("/instrumentation/garmin196/dto_display/ligne["~no_ligne~"]/selected",1); |
| 1042 |
setprop("/instrumentation/garmin196/dto_display/ligne["~old_no_ligne~"]/selected",0); |
| 1043 |
} |
| 1044 |
return; |
| 1045 |
} |
| 1046 |
|
| 1047 |
if(popup_status==20 or popup_status==30){ |
| 1048 |
var no_ligne = getprop("/instrumentation/garmin196/dto_display/no_ligne_selected"); |
| 1049 |
var old_no_ligne = no_ligne; |
| 1050 |
no_ligne = no_ligne - 1; |
| 1051 |
if(no_ligne<0){ |
| 1052 |
no_ligne = 0; |
| 1053 |
} |
| 1054 |
setprop("/instrumentation/garmin196/dto_display/no_ligne_selected",no_ligne); |
| 1055 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",getprop("/instrumentation/garmin196/dto_display/ligne["~no_ligne~"]/texte")); |
| 1056 |
if(old_no_ligne!=no_ligne){ |
| 1057 |
setprop("/instrumentation/garmin196/dto_display/ligne["~no_ligne~"]/selected",1); |
| 1058 |
setprop("/instrumentation/garmin196/dto_display/ligne["~old_no_ligne~"]/selected",0); |
| 1059 |
} |
| 1060 |
return; |
| 1061 |
} |
| 1062 |
|
| 1063 |
if(popup_status>=40 and popup_status<=99){ |
| 1064 |
var no_ligne = getprop("/instrumentation/garmin196/nrst_display/no_ligne_selected"); |
| 1065 |
var old_no_ligne = no_ligne; |
| 1066 |
no_ligne = no_ligne - 1; |
| 1067 |
if(no_ligne<0){ |
| 1068 |
no_ligne = 0; |
| 1069 |
} |
| 1070 |
setprop("/instrumentation/garmin196/nrst_display/no_ligne_selected",no_ligne); |
| 1071 |
setprop("/instrumentation/garmin196/nrst_display/ligne_select",getprop("/instrumentation/garmin196/nrst_display/ligne["~no_ligne~"]/texte")); |
| 1072 |
if(old_no_ligne!=no_ligne){ |
| 1073 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~no_ligne~"]/selected",1); |
| 1074 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~old_no_ligne~"]/selected",0); |
| 1075 |
} |
| 1076 |
return; |
| 1077 |
} |
| 1078 |
|
| 1079 |
##traitement des menus |
| 1080 |
var status = getprop("/instrumentation/garmin196/status"); |
| 1081 |
if(status>=100 and status<110){ |
| 1082 |
setprop("/instrumentation/garmin196/status",170); |
| 1083 |
return; |
| 1084 |
} |
| 1085 |
|
| 1086 |
if(status==110){ |
| 1087 |
setprop("/instrumentation/garmin196/status",100); |
| 1088 |
return; |
| 1089 |
} |
| 1090 |
|
| 1091 |
if(status==111){ |
| 1092 |
if(getprop("/instrumentation/garmin196/menu_flights/max_ligne_selected")>=0){ |
| 1093 |
var no_ligne = getprop("/instrumentation/garmin196/menu_flights/no_ligne_selected"); |
| 1094 |
no_ligne = no_ligne - 1; |
| 1095 |
if(no_ligne<0){ |
| 1096 |
no_ligne = 0; |
| 1097 |
} |
| 1098 |
setprop("/instrumentation/garmin196/menu_flights/no_ligne_selected",no_ligne); |
| 1099 |
} |
| 1100 |
} |
| 1101 |
|
| 1102 |
if(status==120){ |
| 1103 |
setprop("/instrumentation/garmin196/status",110); |
| 1104 |
display_menu_flights(); |
| 1105 |
return; |
| 1106 |
} |
| 1107 |
|
| 1108 |
if(status==121){ |
| 1109 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 1110 |
no_ligne = no_ligne - 1; |
| 1111 |
if(no_ligne<0){ |
| 1112 |
no_ligne = 0; |
| 1113 |
} |
| 1114 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_selected",no_ligne); |
| 1115 |
return; |
| 1116 |
} |
| 1117 |
|
| 1118 |
if(status==122){ |
| 1119 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/no_ligne_detail"); |
| 1120 |
no_ligne = no_ligne - 1; |
| 1121 |
if(no_ligne<0){ |
| 1122 |
no_ligne = 0; |
| 1123 |
} |
| 1124 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_detail",no_ligne); |
| 1125 |
return; |
| 1126 |
} |
| 1127 |
|
| 1128 |
if(status==123){ |
| 1129 |
var y_char = getprop("/instrumentation/garmin196/menu_routes/search/y_char"); |
| 1130 |
y_char = y_char + 1; |
| 1131 |
if(y_char>35){ |
| 1132 |
y_char = 0; |
| 1133 |
} |
| 1134 |
setprop("/instrumentation/garmin196/menu_routes/search/y_char",y_char); |
| 1135 |
display_route_waypoint_search(); |
| 1136 |
return; |
| 1137 |
} |
| 1138 |
|
| 1139 |
if(status==124){ |
| 1140 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/search/no_ligne_selected"); |
| 1141 |
no_ligne = no_ligne - 1; |
| 1142 |
if(no_ligne<0){ |
| 1143 |
no_ligne = 0; |
| 1144 |
} |
| 1145 |
setprop("/instrumentation/garmin196/menu_routes/search/no_ligne_selected",no_ligne); |
| 1146 |
return; |
| 1147 |
} |
| 1148 |
|
| 1149 |
if(status==130){ |
| 1150 |
setprop("/instrumentation/garmin196/status",120); |
| 1151 |
init_menu_routes_list(); |
| 1152 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_selected",-1); |
| 1153 |
return; |
| 1154 |
} |
| 1155 |
|
| 1156 |
if(status==131){ |
| 1157 |
var no_ligne = getprop("/instrumentation/garmin196/menu_points/no_ligne_selected"); |
| 1158 |
no_ligne = no_ligne - 1; |
| 1159 |
if(no_ligne<0){ |
| 1160 |
no_ligne = 0; |
| 1161 |
} |
| 1162 |
setprop("/instrumentation/garmin196/menu_points/no_ligne_selected",no_ligne); |
| 1163 |
return; |
| 1164 |
} |
| 1165 |
|
| 1166 |
if(status==132){ |
| 1167 |
var y_char = getprop("/instrumentation/garmin196/menu_points/y_char"); |
| 1168 |
y_char = y_char + 1; |
| 1169 |
if(y_char>35){ |
| 1170 |
y_char = 0; |
| 1171 |
} |
| 1172 |
setprop("/instrumentation/garmin196/menu_points/y_char",y_char); |
| 1173 |
display_menu_points(); |
| 1174 |
return; |
| 1175 |
} |
| 1176 |
|
| 1177 |
if(status==133){ |
| 1178 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 1179 |
latitude = latitude + 1; |
| 1180 |
if(latitude>180){ |
| 1181 |
latitude = 180; |
| 1182 |
} |
| 1183 |
setprop("/instrumentation/garmin196/menu_points/latitude",latitude); |
| 1184 |
display_menu_points(); |
| 1185 |
return; |
| 1186 |
} |
| 1187 |
|
| 1188 |
if(status==134){ |
| 1189 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 1190 |
latitude = latitude + .01; |
| 1191 |
if(latitude>180){ |
| 1192 |
latitude = 180; |
| 1193 |
} |
| 1194 |
setprop("/instrumentation/garmin196/menu_points/latitude",latitude); |
| 1195 |
display_menu_points(); |
| 1196 |
return; |
| 1197 |
} |
| 1198 |
|
| 1199 |
if(status==135){ |
| 1200 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 1201 |
longitude = longitude + 1; |
| 1202 |
if(longitude>180){ |
| 1203 |
longitude = -180; |
| 1204 |
} |
| 1205 |
setprop("/instrumentation/garmin196/menu_points/longitude",longitude); |
| 1206 |
display_menu_points(); |
| 1207 |
return; |
| 1208 |
} |
| 1209 |
|
| 1210 |
if(status==136){ |
| 1211 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 1212 |
longitude = longitude + .01; |
| 1213 |
if(longitude>180){ |
| 1214 |
longitude = -180; |
| 1215 |
} |
| 1216 |
setprop("/instrumentation/garmin196/menu_points/longitude",longitude); |
| 1217 |
display_menu_points(); |
| 1218 |
return; |
| 1219 |
} |
| 1220 |
|
| 1221 |
if(status==140){ |
| 1222 |
setprop("/instrumentation/garmin196/status",130); |
| 1223 |
setprop("/instrumentation/garmin196/menu_points/no_ligne_selected",-1); |
| 1224 |
init_list_points(); |
| 1225 |
return; |
| 1226 |
} |
| 1227 |
|
| 1228 |
if(status==141){ |
| 1229 |
var no_ligne = getprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected"); |
| 1230 |
no_ligne = no_ligne - 1; |
| 1231 |
if(no_ligne<0){ |
| 1232 |
no_ligne = 0; |
| 1233 |
} |
| 1234 |
setprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected",no_ligne); |
| 1235 |
display_list_aircraft(); |
| 1236 |
return; |
| 1237 |
} |
| 1238 |
|
| 1239 |
if(status==142){ |
| 1240 |
var y_char = getprop("/instrumentation/garmin196/menu_aircraft/y_char"); |
| 1241 |
y_char = y_char + 1; |
| 1242 |
if(y_char>35){ |
| 1243 |
y_char = 0; |
| 1244 |
} |
| 1245 |
setprop("/instrumentation/garmin196/menu_aircraft/y_char",y_char); |
| 1246 |
display_menu_aircraft_name(); |
| 1247 |
return; |
| 1248 |
} |
| 1249 |
|
| 1250 |
if(status==143){ |
| 1251 |
var cruise = getprop("/instrumentation/garmin196/menu_aircraft/selected-cruise"); |
| 1252 |
cruise = cruise + 1; |
| 1253 |
if(cruise>500){ |
| 1254 |
cruise = 500; |
| 1255 |
} |
| 1256 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-cruise",cruise); |
| 1257 |
display_menu_aircraft(); |
| 1258 |
return; |
| 1259 |
} |
| 1260 |
|
| 1261 |
if(status==144){ |
| 1262 |
var max = getprop("/instrumentation/garmin196/menu_aircraft/selected-max"); |
| 1263 |
max = max + 1; |
| 1264 |
if(max>500){ |
| 1265 |
max = 500; |
| 1266 |
} |
| 1267 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-max",max); |
| 1268 |
display_menu_aircraft(); |
| 1269 |
return; |
| 1270 |
} |
| 1271 |
|
| 1272 |
if(status==145){ |
| 1273 |
var fuelflow = getprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow"); |
| 1274 |
fuelflow = fuelflow + 0.1; |
| 1275 |
if(fuelflow>100){ |
| 1276 |
fuelflow = 100; |
| 1277 |
} |
| 1278 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow",fuelflow); |
| 1279 |
return; |
| 1280 |
} |
| 1281 |
|
| 1282 |
if(status==150){ |
| 1283 |
setprop("/instrumentation/garmin196/status",140); |
| 1284 |
setprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected",-1); |
| 1285 |
init_list_aircraft(); |
| 1286 |
display_list_aircraft(); |
| 1287 |
return; |
| 1288 |
} |
| 1289 |
|
| 1290 |
if(status==160){ |
| 1291 |
setprop("/instrumentation/garmin196/status",150); |
| 1292 |
return; |
| 1293 |
} |
| 1294 |
|
| 1295 |
if(status==161){ |
| 1296 |
var no_ligne = getprop("/instrumentation/garmin196/menu_map/no_ligne_selected"); |
| 1297 |
no_ligne = no_ligne - 1; |
| 1298 |
if(no_ligne<0){ |
| 1299 |
no_ligne = 0; |
| 1300 |
} |
| 1301 |
setprop("/instrumentation/garmin196/menu_map/no_ligne_selected",no_ligne); |
| 1302 |
return; |
| 1303 |
} |
| 1304 |
|
| 1305 |
if(status==170){ |
| 1306 |
setprop("/instrumentation/garmin196/status",160); |
| 1307 |
setprop("/instrumentation/garmin196/menu_map/no_ligne_selected",-1); |
| 1308 |
return; |
| 1309 |
} |
| 1310 |
|
| 1311 |
if(status==171){ |
| 1312 |
var no_ligne = getprop("/instrumentation/garmin196/menu_setup/no_ligne_selected"); |
| 1313 |
no_ligne = no_ligne - 1; |
| 1314 |
if(no_ligne<0){ |
| 1315 |
no_ligne = 0; |
| 1316 |
} |
| 1317 |
setprop("/instrumentation/garmin196/menu_setup/no_ligne_selected",no_ligne); |
| 1318 |
return; |
| 1319 |
} |
| 1320 |
|
| 1321 |
if(status==176){ |
| 1322 |
var no_ligne = getprop("/instrumentation/garmin196/menu_setup/no_ligne_selected"); |
| 1323 |
no_ligne = no_ligne - 1; |
| 1324 |
if(no_ligne<0){ |
| 1325 |
no_ligne = 0; |
| 1326 |
} |
| 1327 |
setprop("/instrumentation/garmin196/menu_setup/no_ligne_selected",no_ligne); |
| 1328 |
return; |
| 1329 |
} |
| 1330 |
|
| 1331 |
}elsif(x==1){ |
| 1332 |
#traitement des popup |
| 1333 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 1334 |
if(popup_status==11){ |
| 1335 |
var y_char = getprop("/instrumentation/garmin196/dto_display/y_char"); |
| 1336 |
y_char = y_char + 10; |
| 1337 |
if(y_char>35){ |
| 1338 |
y_char = y_char-36; |
| 1339 |
} |
| 1340 |
setprop("/instrumentation/garmin196/dto_display/y_char",y_char); |
| 1341 |
display_dto_search(); |
| 1342 |
return; |
| 1343 |
} |
| 1344 |
|
| 1345 |
##traitement des menus |
| 1346 |
var status = getprop("/instrumentation/garmin196/status"); |
| 1347 |
|
| 1348 |
if(status==123){ |
| 1349 |
var y_char = getprop("/instrumentation/garmin196/menu_routes/search/y_char"); |
| 1350 |
y_char = y_char + 10; |
| 1351 |
if(y_char>35){ |
| 1352 |
y_char = y_char-36; |
| 1353 |
} |
| 1354 |
setprop("/instrumentation/garmin196/menu_routes/search/y_char",y_char); |
| 1355 |
display_route_waypoint_search(); |
| 1356 |
return; |
| 1357 |
} |
| 1358 |
|
| 1359 |
if(status==132){ |
| 1360 |
var y_char = getprop("/instrumentation/garmin196/menu_points/y_char"); |
| 1361 |
y_char = y_char + 10; |
| 1362 |
if(y_char>35){ |
| 1363 |
y_char = y_char-36; |
| 1364 |
} |
| 1365 |
setprop("/instrumentation/garmin196/menu_points/y_char",y_char); |
| 1366 |
display_menu_points(); |
| 1367 |
return; |
| 1368 |
} |
| 1369 |
|
| 1370 |
if(status==133){ |
| 1371 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 1372 |
latitude = latitude + 10; |
| 1373 |
if(latitude>180){ |
| 1374 |
latitude = 180; |
| 1375 |
} |
| 1376 |
setprop("/instrumentation/garmin196/menu_points/latitude",latitude); |
| 1377 |
display_menu_points(); |
| 1378 |
return; |
| 1379 |
} |
| 1380 |
|
| 1381 |
if(status==134){ |
| 1382 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 1383 |
latitude = latitude + .1; |
| 1384 |
if(latitude>180){ |
| 1385 |
latitude = 180; |
| 1386 |
} |
| 1387 |
setprop("/instrumentation/garmin196/menu_points/latitude",latitude); |
| 1388 |
display_menu_points(); |
| 1389 |
return; |
| 1390 |
} |
| 1391 |
|
| 1392 |
if(status==135){ |
| 1393 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 1394 |
longitude = longitude + 10; |
| 1395 |
if(longitude>180){ |
| 1396 |
longitude = -180; |
| 1397 |
} |
| 1398 |
setprop("/instrumentation/garmin196/menu_points/longitude",longitude); |
| 1399 |
display_menu_points(); |
| 1400 |
return; |
| 1401 |
} |
| 1402 |
|
| 1403 |
if(status==136){ |
| 1404 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 1405 |
longitude = longitude + .1; |
| 1406 |
if(longitude>180){ |
| 1407 |
longitude = -180; |
| 1408 |
} |
| 1409 |
setprop("/instrumentation/garmin196/menu_points/longitude",longitude); |
| 1410 |
display_menu_points(); |
| 1411 |
return; |
| 1412 |
} |
| 1413 |
|
| 1414 |
if(status==142){ |
| 1415 |
var y_char = getprop("/instrumentation/garmin196/menu_aircraft/y_char"); |
| 1416 |
y_char = y_char + 10; |
| 1417 |
if(y_char>35){ |
| 1418 |
y_char = y_char-36; |
| 1419 |
} |
| 1420 |
setprop("/instrumentation/garmin196/menu_aircraft/y_char",y_char); |
| 1421 |
display_menu_aircraft_name(); |
| 1422 |
return; |
| 1423 |
} |
| 1424 |
|
| 1425 |
if(status==143){ |
| 1426 |
var cruise = getprop("/instrumentation/garmin196/menu_aircraft/selected-cruise"); |
| 1427 |
cruise = cruise + 10; |
| 1428 |
if(cruise>500){ |
| 1429 |
cruise = 500; |
| 1430 |
} |
| 1431 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-cruise",cruise); |
| 1432 |
display_menu_aircraft(); |
| 1433 |
return; |
| 1434 |
} |
| 1435 |
|
| 1436 |
if(status==144){ |
| 1437 |
var max = getprop("/instrumentation/garmin196/menu_aircraft/selected-max"); |
| 1438 |
max = max + 10; |
| 1439 |
if(max>500){ |
| 1440 |
max = 500; |
| 1441 |
} |
| 1442 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-max",max); |
| 1443 |
display_menu_aircraft(); |
| 1444 |
return; |
| 1445 |
} |
| 1446 |
|
| 1447 |
if(status==145){ |
| 1448 |
var fuelflow = getprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow"); |
| 1449 |
fuelflow = fuelflow + 1; |
| 1450 |
if(fuelflow>100){ |
| 1451 |
fuelflow = 100; |
| 1452 |
} |
| 1453 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow",fuelflow); |
| 1454 |
return; |
| 1455 |
} |
| 1456 |
} |
| 1457 |
} |
| 1458 |
} |
| 1459 |
|
| 1460 |
var rockerdown = func (x){ |
| 1461 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 1462 |
if(serviceable==1){ |
| 1463 |
if(x==0){ |
| 1464 |
#traitement des popup |
| 1465 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 1466 |
if(popup_status==1){ |
| 1467 |
var light_level = getprop("/instrumentation/garmin196/light"); |
| 1468 |
light_level = light_level - 0.1; |
| 1469 |
if(light_level<0){ |
| 1470 |
light_level = 0; |
| 1471 |
} |
| 1472 |
setprop("/instrumentation/garmin196/light",light_level); |
| 1473 |
return; |
| 1474 |
} |
| 1475 |
|
| 1476 |
if(popup_status==11){ |
| 1477 |
var y_char = getprop("/instrumentation/garmin196/dto_display/y_char"); |
| 1478 |
y_char = y_char - 1; |
| 1479 |
if(y_char<0){ |
| 1480 |
y_char = 35; |
| 1481 |
} |
| 1482 |
setprop("/instrumentation/garmin196/dto_display/y_char",y_char); |
| 1483 |
display_dto_search(); |
| 1484 |
return; |
| 1485 |
} |
| 1486 |
|
| 1487 |
if(popup_status==12){ |
| 1488 |
var no_ligne = getprop("/instrumentation/garmin196/dto_display/no_ligne_selected"); |
| 1489 |
var old_no_ligne = no_ligne; |
| 1490 |
var max_ligne = getprop("/instrumentation/garmin196/dto_display/max_ligne_selected"); |
| 1491 |
no_ligne = no_ligne + 1; |
| 1492 |
if(no_ligne>max_ligne){ |
| 1493 |
no_ligne = max_ligne; |
| 1494 |
} |
| 1495 |
setprop("/instrumentation/garmin196/dto_display/no_ligne_selected",no_ligne); |
| 1496 |
if(old_no_ligne!=no_ligne){ |
| 1497 |
setprop("/instrumentation/garmin196/dto_display/ligne["~no_ligne~"]/selected",1); |
| 1498 |
setprop("/instrumentation/garmin196/dto_display/ligne["~old_no_ligne~"]/selected",0); |
| 1499 |
} |
| 1500 |
return; |
| 1501 |
} |
| 1502 |
|
| 1503 |
if(popup_status==20 or popup_status==30){ |
| 1504 |
var no_ligne = getprop("/instrumentation/garmin196/dto_display/no_ligne_selected"); |
| 1505 |
var old_no_ligne = no_ligne; |
| 1506 |
var max_ligne = getprop("/instrumentation/garmin196/dto_display/max_ligne_selected"); |
| 1507 |
no_ligne = no_ligne + 1; |
| 1508 |
if(no_ligne>max_ligne){ |
| 1509 |
no_ligne = max_ligne; |
| 1510 |
} |
| 1511 |
setprop("/instrumentation/garmin196/dto_display/no_ligne_selected",no_ligne); |
| 1512 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",getprop("/instrumentation/garmin196/dto_display/ligne["~no_ligne~"]/texte")); |
| 1513 |
if(old_no_ligne!=no_ligne){ |
| 1514 |
setprop("/instrumentation/garmin196/dto_display/ligne["~no_ligne~"]/selected",1); |
| 1515 |
setprop("/instrumentation/garmin196/dto_display/ligne["~old_no_ligne~"]/selected",0); |
| 1516 |
} |
| 1517 |
return; |
| 1518 |
} |
| 1519 |
|
| 1520 |
if(popup_status>=40 and popup_status<=99){ |
| 1521 |
var no_ligne = getprop("/instrumentation/garmin196/nrst_display/no_ligne_selected"); |
| 1522 |
var old_no_ligne = no_ligne; |
| 1523 |
var max_ligne = getprop("/instrumentation/garmin196/nrst_display/max_ligne_selected"); |
| 1524 |
no_ligne = no_ligne + 1; |
| 1525 |
if(no_ligne>max_ligne){ |
| 1526 |
no_ligne = max_ligne; |
| 1527 |
} |
| 1528 |
setprop("/instrumentation/garmin196/nrst_display/no_ligne_selected",no_ligne); |
| 1529 |
setprop("/instrumentation/garmin196/nrst_display/ligne_select",getprop("/instrumentation/garmin196/nrst_display/ligne["~no_ligne~"]/texte")); |
| 1530 |
if(old_no_ligne!=no_ligne){ |
| 1531 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~no_ligne~"]/selected",1); |
| 1532 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~old_no_ligne~"]/selected",0); |
| 1533 |
} |
| 1534 |
return; |
| 1535 |
} |
| 1536 |
|
| 1537 |
##traitement des menus |
| 1538 |
var status = getprop("/instrumentation/garmin196/status"); |
| 1539 |
if(status>=100 and status<110){ |
| 1540 |
setprop("/instrumentation/garmin196/status",110); |
| 1541 |
display_menu_flights(); |
| 1542 |
return; |
| 1543 |
} |
| 1544 |
|
| 1545 |
if(status==110){ |
| 1546 |
setprop("/instrumentation/garmin196/status",120); |
| 1547 |
init_menu_routes_list(); |
| 1548 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_selected",-1); |
| 1549 |
return; |
| 1550 |
} |
| 1551 |
|
| 1552 |
if(status==111){ |
| 1553 |
if(getprop("/instrumentation/garmin196/menu_flights/max_ligne_selected")>=0){ |
| 1554 |
var no_ligne = getprop("/instrumentation/garmin196/menu_flights/no_ligne_selected"); |
| 1555 |
no_ligne = no_ligne + 1; |
| 1556 |
if(no_ligne>getprop("/instrumentation/garmin196/menu_flights/max_ligne_selected")){ |
| 1557 |
no_ligne = getprop("/instrumentation/garmin196/menu_flights/max_ligne_selected"); |
| 1558 |
} |
| 1559 |
setprop("/instrumentation/garmin196/menu_flights/no_ligne_selected",no_ligne); |
| 1560 |
} |
| 1561 |
return; |
| 1562 |
} |
| 1563 |
|
| 1564 |
if(status==120){ |
| 1565 |
setprop("/instrumentation/garmin196/status",130); |
| 1566 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_selected",-1); |
| 1567 |
init_list_points(); |
| 1568 |
return; |
| 1569 |
} |
| 1570 |
|
| 1571 |
if(status==121){ |
| 1572 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 1573 |
var max_no_ligne = getprop("/instrumentation/garmin196/menu_routes/max_no_ligne"); |
| 1574 |
no_ligne = no_ligne + 1; |
| 1575 |
if(no_ligne>max_no_ligne){ |
| 1576 |
no_ligne = max_no_ligne; |
| 1577 |
} |
| 1578 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_selected",no_ligne); |
| 1579 |
return; |
| 1580 |
} |
| 1581 |
|
| 1582 |
if(status==122){ |
| 1583 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/no_ligne_detail"); |
| 1584 |
var max_no_ligne = getprop("/instrumentation/garmin196/menu_routes/max_no_ligne_detail"); |
| 1585 |
no_ligne = no_ligne + 1; |
| 1586 |
if(no_ligne>max_no_ligne){ |
| 1587 |
no_ligne = max_no_ligne; |
| 1588 |
} |
| 1589 |
setprop("/instrumentation/garmin196/menu_routes/no_ligne_detail",no_ligne); |
| 1590 |
return; |
| 1591 |
} |
| 1592 |
|
| 1593 |
if(status==123){ |
| 1594 |
var y_char = getprop("/instrumentation/garmin196/menu_routes/search/y_char"); |
| 1595 |
y_char = y_char - 1; |
| 1596 |
if(y_char<0){ |
| 1597 |
y_char = 35; |
| 1598 |
} |
| 1599 |
setprop("/instrumentation/garmin196/menu_routes/search/y_char",y_char); |
| 1600 |
display_route_waypoint_search(); |
| 1601 |
return; |
| 1602 |
} |
| 1603 |
|
| 1604 |
if(status==124){ |
| 1605 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/search/no_ligne_selected"); |
| 1606 |
var max_no_ligne = getprop("/instrumentation/garmin196/menu_routes/search/max_ligne_selected"); |
| 1607 |
no_ligne = no_ligne + 1; |
| 1608 |
if(no_ligne>max_no_ligne){ |
| 1609 |
no_ligne = max_no_ligne; |
| 1610 |
} |
| 1611 |
setprop("/instrumentation/garmin196/menu_routes/search/no_ligne_selected",no_ligne); |
| 1612 |
return; |
| 1613 |
} |
| 1614 |
|
| 1615 |
if(status==130){ |
| 1616 |
setprop("/instrumentation/garmin196/status",140); |
| 1617 |
setprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected",-1); |
| 1618 |
init_list_aircraft(); |
| 1619 |
display_list_aircraft(); |
| 1620 |
return; |
| 1621 |
} |
| 1622 |
|
| 1623 |
if(status==131){ |
| 1624 |
var no_ligne = getprop("/instrumentation/garmin196/menu_points/no_ligne_selected"); |
| 1625 |
no_ligne = no_ligne + 1; |
| 1626 |
if(no_ligne>getprop("/instrumentation/garmin196/menu_points/max_no_ligne")){ |
| 1627 |
no_ligne = getprop("/instrumentation/garmin196/menu_points/max_no_ligne"); |
| 1628 |
} |
| 1629 |
setprop("/instrumentation/garmin196/menu_points/no_ligne_selected",no_ligne); |
| 1630 |
return; |
| 1631 |
} |
| 1632 |
|
| 1633 |
if(status==132){ |
| 1634 |
var y_char = getprop("/instrumentation/garmin196/menu_points/y_char"); |
| 1635 |
y_char = y_char - 1; |
| 1636 |
if(y_char<0){ |
| 1637 |
y_char = 35; |
| 1638 |
} |
| 1639 |
setprop("/instrumentation/garmin196/menu_points/y_char",y_char); |
| 1640 |
display_menu_points(); |
| 1641 |
return; |
| 1642 |
} |
| 1643 |
|
| 1644 |
if(status==133){ |
| 1645 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 1646 |
latitude = latitude - 1; |
| 1647 |
if(latitude<-180){ |
| 1648 |
latitude = -180; |
| 1649 |
} |
| 1650 |
setprop("/instrumentation/garmin196/menu_points/latitude",latitude); |
| 1651 |
display_menu_points(); |
| 1652 |
return; |
| 1653 |
} |
| 1654 |
|
| 1655 |
if(status==134){ |
| 1656 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 1657 |
latitude = latitude - .01; |
| 1658 |
if(latitude<-180){ |
| 1659 |
latitude = -180; |
| 1660 |
} |
| 1661 |
setprop("/instrumentation/garmin196/menu_points/latitude",latitude); |
| 1662 |
display_menu_points(); |
| 1663 |
return; |
| 1664 |
} |
| 1665 |
|
| 1666 |
if(status==135){ |
| 1667 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 1668 |
longitude = longitude - 1; |
| 1669 |
if(longitude<-180){ |
| 1670 |
longitude = 180; |
| 1671 |
} |
| 1672 |
setprop("/instrumentation/garmin196/menu_points/longitude",longitude); |
| 1673 |
display_menu_points(); |
| 1674 |
return; |
| 1675 |
} |
| 1676 |
|
| 1677 |
if(status==136){ |
| 1678 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 1679 |
longitude = longitude - .01; |
| 1680 |
if(longitude<-180){ |
| 1681 |
longitude = 180; |
| 1682 |
} |
| 1683 |
setprop("/instrumentation/garmin196/menu_points/longitude",longitude); |
| 1684 |
display_menu_points(); |
| 1685 |
return; |
| 1686 |
} |
| 1687 |
|
| 1688 |
if(status==140){ |
| 1689 |
setprop("/instrumentation/garmin196/status",150); |
| 1690 |
return; |
| 1691 |
} |
| 1692 |
|
| 1693 |
if(status==141){ |
| 1694 |
var no_ligne = getprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected"); |
| 1695 |
no_ligne = no_ligne + 1; |
| 1696 |
if(no_ligne>getprop("/instrumentation/garmin196/menu_aircraft/max_no_ligne")){ |
| 1697 |
no_ligne = getprop("/instrumentation/garmin196/menu_aircraft/max_no_ligne"); |
| 1698 |
} |
| 1699 |
setprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected",no_ligne); |
| 1700 |
display_list_aircraft(); |
| 1701 |
return; |
| 1702 |
} |
| 1703 |
|
| 1704 |
if(status==142){ |
| 1705 |
var y_char = getprop("/instrumentation/garmin196/menu_aircraft/y_char"); |
| 1706 |
y_char = y_char - 1; |
| 1707 |
if(y_char<0){ |
| 1708 |
y_char = 35; |
| 1709 |
} |
| 1710 |
setprop("/instrumentation/garmin196/menu_aircraft/y_char",y_char); |
| 1711 |
display_menu_aircraft_name(); |
| 1712 |
return; |
| 1713 |
} |
| 1714 |
|
| 1715 |
if(status==143){ |
| 1716 |
var cruise = getprop("/instrumentation/garmin196/menu_aircraft/selected-cruise"); |
| 1717 |
cruise = cruise - 1; |
| 1718 |
if(cruise<1){ |
| 1719 |
cruise = 1; |
| 1720 |
} |
| 1721 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-cruise",cruise); |
| 1722 |
display_menu_aircraft(); |
| 1723 |
return; |
| 1724 |
} |
| 1725 |
|
| 1726 |
if(status==144){ |
| 1727 |
var max = getprop("/instrumentation/garmin196/menu_aircraft/selected-max"); |
| 1728 |
max = max - 1; |
| 1729 |
if(max<1){ |
| 1730 |
max = 1; |
| 1731 |
} |
| 1732 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-max",max); |
| 1733 |
display_menu_aircraft(); |
| 1734 |
return; |
| 1735 |
} |
| 1736 |
|
| 1737 |
if(status==145){ |
| 1738 |
var fuelflow = getprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow"); |
| 1739 |
fuelflow = fuelflow - 0.1; |
| 1740 |
if(fuelflow<1){ |
| 1741 |
fuelflow = 1; |
| 1742 |
} |
| 1743 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow",fuelflow); |
| 1744 |
return; |
| 1745 |
} |
| 1746 |
|
| 1747 |
if(status==150){ |
| 1748 |
setprop("/instrumentation/garmin196/status",160); |
| 1749 |
setprop("/instrumentation/garmin196/menu_map/no_ligne_selected",-1); |
| 1750 |
return; |
| 1751 |
} |
| 1752 |
|
| 1753 |
if(status==160){ |
| 1754 |
setprop("/instrumentation/garmin196/status",170); |
| 1755 |
return; |
| 1756 |
} |
| 1757 |
|
| 1758 |
if(status==161){ |
| 1759 |
var no_ligne = getprop("/instrumentation/garmin196/menu_map/no_ligne_selected"); |
| 1760 |
no_ligne = no_ligne + 1; |
| 1761 |
if(no_ligne>5){ |
| 1762 |
no_ligne = 5; |
| 1763 |
} |
| 1764 |
setprop("/instrumentation/garmin196/menu_map/no_ligne_selected",no_ligne); |
| 1765 |
return; |
| 1766 |
} |
| 1767 |
|
| 1768 |
if(status==170){ |
| 1769 |
setprop("/instrumentation/garmin196/status",100); |
| 1770 |
return; |
| 1771 |
} |
| 1772 |
|
| 1773 |
if(status==171){ |
| 1774 |
var no_ligne = getprop("/instrumentation/garmin196/menu_setup/no_ligne_selected"); |
| 1775 |
no_ligne = no_ligne + 1; |
| 1776 |
if(no_ligne>5){ |
| 1777 |
no_ligne = 5; |
| 1778 |
} |
| 1779 |
setprop("/instrumentation/garmin196/menu_setup/no_ligne_selected",no_ligne); |
| 1780 |
return; |
| 1781 |
} |
| 1782 |
|
| 1783 |
if(status==176){ |
| 1784 |
var no_ligne = getprop("/instrumentation/garmin196/menu_setup/no_ligne_selected"); |
| 1785 |
no_ligne = no_ligne + 1; |
| 1786 |
if(no_ligne>1){ |
| 1787 |
no_ligne = 1; |
| 1788 |
} |
| 1789 |
setprop("/instrumentation/garmin196/menu_setup/no_ligne_selected",no_ligne); |
| 1790 |
return; |
| 1791 |
} |
| 1792 |
|
| 1793 |
}elsif(x==1){ |
| 1794 |
#traitement des popup |
| 1795 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 1796 |
if(popup_status==11){ |
| 1797 |
var y_char = getprop("/instrumentation/garmin196/dto_display/y_char"); |
| 1798 |
y_char = y_char - 10; |
| 1799 |
if(y_char<0){ |
| 1800 |
y_char = y_char + 36; |
| 1801 |
} |
| 1802 |
setprop("/instrumentation/garmin196/dto_display/y_char",y_char); |
| 1803 |
display_dto_search(); |
| 1804 |
return; |
| 1805 |
} |
| 1806 |
|
| 1807 |
##traitement des menus |
| 1808 |
var status = getprop("/instrumentation/garmin196/status"); |
| 1809 |
|
| 1810 |
if(status==123){ |
| 1811 |
var y_char = getprop("/instrumentation/garmin196/menu_routes/search/y_char"); |
| 1812 |
y_char = y_char - 10; |
| 1813 |
if(y_char<0){ |
| 1814 |
y_char = y_char + 36; |
| 1815 |
} |
| 1816 |
setprop("/instrumentation/garmin196/menu_routes/search/y_char",y_char); |
| 1817 |
display_route_waypoint_search(); |
| 1818 |
return; |
| 1819 |
} |
| 1820 |
|
| 1821 |
if(status==132){ |
| 1822 |
var y_char = getprop("/instrumentation/garmin196/menu_points/y_char"); |
| 1823 |
y_char = y_char - 10; |
| 1824 |
if(y_char<0){ |
| 1825 |
y_char = y_char + 36; |
| 1826 |
} |
| 1827 |
setprop("/instrumentation/garmin196/menu_points/y_char",y_char); |
| 1828 |
display_menu_points(); |
| 1829 |
return; |
| 1830 |
} |
| 1831 |
|
| 1832 |
if(status==132){ |
| 1833 |
var y_char = getprop("/instrumentation/garmin196/menu_points/y_char"); |
| 1834 |
y_char = y_char - 1; |
| 1835 |
if(y_char<0){ |
| 1836 |
y_char = 35; |
| 1837 |
} |
| 1838 |
setprop("/instrumentation/garmin196/menu_points/y_char",y_char); |
| 1839 |
display_menu_points(); |
| 1840 |
return; |
| 1841 |
} |
| 1842 |
|
| 1843 |
if(status==133){ |
| 1844 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 1845 |
latitude = latitude - 10; |
| 1846 |
if(latitude<-180){ |
| 1847 |
latitude = -180; |
| 1848 |
} |
| 1849 |
setprop("/instrumentation/garmin196/menu_points/latitude",latitude); |
| 1850 |
display_menu_points(); |
| 1851 |
return; |
| 1852 |
} |
| 1853 |
|
| 1854 |
if(status==134){ |
| 1855 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 1856 |
latitude = latitude - .1; |
| 1857 |
if(latitude<-180){ |
| 1858 |
latitude = -180; |
| 1859 |
} |
| 1860 |
setprop("/instrumentation/garmin196/menu_points/latitude",latitude); |
| 1861 |
display_menu_points(); |
| 1862 |
return; |
| 1863 |
} |
| 1864 |
|
| 1865 |
if(status==135){ |
| 1866 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 1867 |
longitude = longitude - 10; |
| 1868 |
if(longitude<-180){ |
| 1869 |
longitude = 180; |
| 1870 |
} |
| 1871 |
setprop("/instrumentation/garmin196/menu_points/longitude",longitude); |
| 1872 |
display_menu_points(); |
| 1873 |
return; |
| 1874 |
} |
| 1875 |
|
| 1876 |
if(status==136){ |
| 1877 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 1878 |
longitude = longitude - .1; |
| 1879 |
if(longitude<-180){ |
| 1880 |
longitude = 180; |
| 1881 |
} |
| 1882 |
setprop("/instrumentation/garmin196/menu_points/longitude",longitude); |
| 1883 |
display_menu_points(); |
| 1884 |
return; |
| 1885 |
} |
| 1886 |
|
| 1887 |
if(status==142){ |
| 1888 |
var y_char = getprop("/instrumentation/garmin196/menu_aircraft/y_char"); |
| 1889 |
y_char = y_char - 10; |
| 1890 |
if(y_char<0){ |
| 1891 |
y_char = y_char + 36; |
| 1892 |
} |
| 1893 |
setprop("/instrumentation/garmin196/menu_aircraft/y_char",y_char); |
| 1894 |
display_menu_aircraft_name(); |
| 1895 |
return; |
| 1896 |
} |
| 1897 |
|
| 1898 |
if(status==143){ |
| 1899 |
var cruise = getprop("/instrumentation/garmin196/menu_aircraft/selected-cruise"); |
| 1900 |
cruise = cruise - 10; |
| 1901 |
if(cruise<1){ |
| 1902 |
cruise = 1; |
| 1903 |
} |
| 1904 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-cruise",cruise); |
| 1905 |
display_menu_aircraft(); |
| 1906 |
return; |
| 1907 |
} |
| 1908 |
|
| 1909 |
if(status==144){ |
| 1910 |
var max = getprop("/instrumentation/garmin196/menu_aircraft/selected-max"); |
| 1911 |
max = max - 10; |
| 1912 |
if(max<1){ |
| 1913 |
max = 1; |
| 1914 |
} |
| 1915 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-max",max); |
| 1916 |
display_menu_aircraft(); |
| 1917 |
return; |
| 1918 |
} |
| 1919 |
|
| 1920 |
if(status==145){ |
| 1921 |
var fuelflow = getprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow"); |
| 1922 |
fuelflow = fuelflow - 1; |
| 1923 |
if(fuelflow<1){ |
| 1924 |
fuelflow = 1; |
| 1925 |
} |
| 1926 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow",fuelflow); |
| 1927 |
return; |
| 1928 |
} |
| 1929 |
} |
| 1930 |
} |
| 1931 |
} |
| 1932 |
|
| 1933 |
var rockerleft = func (x){ |
| 1934 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 1935 |
if(serviceable==1){ |
| 1936 |
if(x==0){ |
| 1937 |
#traitement des popup |
| 1938 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 1939 |
if(popup_status==10){ |
| 1940 |
setprop("/instrumentation/garmin196/popup_status",30); |
| 1941 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",""); |
| 1942 |
init_dto_display(); |
| 1943 |
display_dto_user(); |
| 1944 |
return; |
| 1945 |
} |
| 1946 |
if(popup_status==11){ |
| 1947 |
var x_char = getprop("/instrumentation/garmin196/dto_display/x_char"); |
| 1948 |
if(x_char>0){ |
| 1949 |
setprop("/instrumentation/garmin196/dto_display/x_char",x_char-1); |
| 1950 |
setprop("/instrumentation/garmin196/dto_display/y_char",searchLastChar(getprop("/instrumentation/garmin196/dto_display/ligne_select"),getprop("/instrumentation/garmin196/dto_display/x_char"))); |
| 1951 |
display_dto_search(); |
| 1952 |
} |
| 1953 |
return; |
| 1954 |
} |
| 1955 |
if(popup_status==20){ |
| 1956 |
setprop("/instrumentation/garmin196/popup_status",10); |
| 1957 |
setprop("/instrumentation/garmin196/dto_display/x_char",0); |
| 1958 |
setprop("/instrumentation/garmin196/dto_display/y_char",0); |
| 1959 |
setprop("/instrumentation/garmin196/dto_display/ligne_select","Press Enter to search"); |
| 1960 |
init_dto_display(); |
| 1961 |
return; |
| 1962 |
} |
| 1963 |
if(popup_status==30){ |
| 1964 |
setprop("/instrumentation/garmin196/popup_status",20); |
| 1965 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",""); |
| 1966 |
init_dto_display(); |
| 1967 |
display_dto_recent(); |
| 1968 |
return; |
| 1969 |
} |
| 1970 |
|
| 1971 |
if(popup_status==40){ |
| 1972 |
setprop("/instrumentation/garmin196/popup_status",80); |
| 1973 |
display_nrst("wpt"); |
| 1974 |
return; |
| 1975 |
} |
| 1976 |
|
| 1977 |
if(popup_status==50){ |
| 1978 |
setprop("/instrumentation/garmin196/popup_status",40); |
| 1979 |
display_nrst("airport"); |
| 1980 |
return; |
| 1981 |
} |
| 1982 |
|
| 1983 |
if(popup_status==60){ |
| 1984 |
setprop("/instrumentation/garmin196/popup_status",50); |
| 1985 |
display_nrst("vor"); |
| 1986 |
return; |
| 1987 |
} |
| 1988 |
|
| 1989 |
if(popup_status==70){ |
| 1990 |
setprop("/instrumentation/garmin196/popup_status",60); |
| 1991 |
display_nrst("ndb"); |
| 1992 |
return; |
| 1993 |
} |
| 1994 |
|
| 1995 |
if(popup_status==80){ |
| 1996 |
setprop("/instrumentation/garmin196/popup_status",70); |
| 1997 |
display_nrst("fix"); |
| 1998 |
return; |
| 1999 |
} |
| 2000 |
|
| 2001 |
var status = getprop("/instrumentation/garmin196/status"); |
| 2002 |
|
| 2003 |
##menu routes |
| 2004 |
#suppression de la ligne |
| 2005 |
if(status==121){ |
| 2006 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 2007 |
delete_route(no_ligne); |
| 2008 |
init_menu_routes_list(); |
| 2009 |
} |
| 2010 |
|
| 2011 |
if(status==122){ |
| 2012 |
var no_ligne_liste = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 2013 |
var no_ligne_detail = getprop("/instrumentation/garmin196/menu_routes/no_ligne_detail"); |
| 2014 |
delete_route_detail(no_ligne_liste,no_ligne_detail); |
| 2015 |
update_menu_routes_detail(); |
| 2016 |
return; |
| 2017 |
} |
| 2018 |
|
| 2019 |
if(status==123){ |
| 2020 |
var x_char = getprop("/instrumentation/garmin196/menu_routes/search/x_char"); |
| 2021 |
if(x_char>0){ |
| 2022 |
setprop("/instrumentation/garmin196/menu_routes/search/x_char",x_char-1); |
| 2023 |
setprop("/instrumentation/garmin196/menu_routes/search/y_char",searchLastChar(getprop("/instrumentation/garmin196/menu_routes/search/ligne_select"),getprop("/instrumentation/garmin196/menu_routes/search/x_char"))); |
| 2024 |
display_route_waypoint_search(); |
| 2025 |
} |
| 2026 |
return; |
| 2027 |
} |
| 2028 |
|
| 2029 |
##menu points |
| 2030 |
#suppression de la ligne |
| 2031 |
if(status==131){ |
| 2032 |
var no_ligne = getprop("/instrumentation/garmin196/menu_points/no_ligne_selected"); |
| 2033 |
delete_point(no_ligne); |
| 2034 |
init_list_points(); |
| 2035 |
} |
| 2036 |
|
| 2037 |
if(status==132){ |
| 2038 |
var x_char = getprop("/instrumentation/garmin196/menu_points/x_char"); |
| 2039 |
if(x_char>0){ |
| 2040 |
setprop("/instrumentation/garmin196/menu_points/x_char",x_char-1); |
| 2041 |
setprop("/instrumentation/garmin196/menu_points/y_char",searchLastChar(getprop("/instrumentation/garmin196/menu_points/name"),getprop("/instrumentation/garmin196/menu_points/x_char"))); |
| 2042 |
display_menu_points(); |
| 2043 |
} |
| 2044 |
return; |
| 2045 |
} |
| 2046 |
|
| 2047 |
##menu aircraft |
| 2048 |
#suppression de la ligne |
| 2049 |
if(status==141){ |
| 2050 |
var no_ligne = getprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected"); |
| 2051 |
delete_aircraft(no_ligne); |
| 2052 |
init_list_aircraft(); |
| 2053 |
display_list_aircraft(); |
| 2054 |
} |
| 2055 |
|
| 2056 |
if(status==142){ |
| 2057 |
var x_char = getprop("/instrumentation/garmin196/menu_aircraft/x_char"); |
| 2058 |
if(x_char>0){ |
| 2059 |
setprop("/instrumentation/garmin196/menu_aircraft/x_char",x_char-1); |
| 2060 |
setprop("/instrumentation/garmin196/menu_aircraft/y_char",searchLastChar(getprop("/instrumentation/garmin196/menu_aircraft/selected-name"),getprop("/instrumentation/garmin196/menu_aircraft/x_char"))); |
| 2061 |
display_menu_aircraft_name(); |
| 2062 |
} |
| 2063 |
return; |
| 2064 |
} |
| 2065 |
|
| 2066 |
if(status==175){ |
| 2067 |
setprop("/instrumentation/garmin196/status",170); |
| 2068 |
} |
| 2069 |
|
| 2070 |
} |
| 2071 |
} |
| 2072 |
} |
| 2073 |
|
| 2074 |
var rockerright = func (x){ |
| 2075 |
var serviceable = getprop("/instrumentation/garmin196/serviceable"); |
| 2076 |
if(serviceable==1){ |
| 2077 |
if(x==0){ |
| 2078 |
#traitement des popup |
| 2079 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 2080 |
if(popup_status==10){ |
| 2081 |
setprop("/instrumentation/garmin196/popup_status",20); |
| 2082 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",""); |
| 2083 |
init_dto_display(); |
| 2084 |
display_dto_recent(); |
| 2085 |
return; |
| 2086 |
} |
| 2087 |
if(popup_status==11){ |
| 2088 |
var x_char = getprop("/instrumentation/garmin196/dto_display/x_char"); |
| 2089 |
if(x_char<20){ |
| 2090 |
setprop("/instrumentation/garmin196/dto_display/x_char",x_char+1); |
| 2091 |
display_dto_search(); |
| 2092 |
} |
| 2093 |
return; |
| 2094 |
} |
| 2095 |
if(popup_status==20){ |
| 2096 |
setprop("/instrumentation/garmin196/popup_status",30); |
| 2097 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",""); |
| 2098 |
init_dto_display(); |
| 2099 |
display_dto_user(); |
| 2100 |
return; |
| 2101 |
} |
| 2102 |
if(popup_status==30){ |
| 2103 |
setprop("/instrumentation/garmin196/popup_status",10); |
| 2104 |
setprop("/instrumentation/garmin196/dto_display/ligne_select","Press Enter to search"); |
| 2105 |
init_dto_display(); |
| 2106 |
setprop("/instrumentation/garmin196/dto_display/x_char",0); |
| 2107 |
setprop("/instrumentation/garmin196/dto_display/y_char",0); |
| 2108 |
return; |
| 2109 |
} |
| 2110 |
|
| 2111 |
if(popup_status==40){ |
| 2112 |
setprop("/instrumentation/garmin196/popup_status",50); |
| 2113 |
display_nrst("vor"); |
| 2114 |
return; |
| 2115 |
} |
| 2116 |
|
| 2117 |
if(popup_status==50){ |
| 2118 |
setprop("/instrumentation/garmin196/popup_status",60); |
| 2119 |
display_nrst("ndb"); |
| 2120 |
return; |
| 2121 |
} |
| 2122 |
|
| 2123 |
if(popup_status==60){ |
| 2124 |
setprop("/instrumentation/garmin196/popup_status",70); |
| 2125 |
display_nrst("fix"); |
| 2126 |
return; |
| 2127 |
} |
| 2128 |
|
| 2129 |
if(popup_status==70){ |
| 2130 |
setprop("/instrumentation/garmin196/popup_status",80); |
| 2131 |
display_nrst("wpt"); |
| 2132 |
return; |
| 2133 |
} |
| 2134 |
|
| 2135 |
if(popup_status==80){ |
| 2136 |
setprop("/instrumentation/garmin196/popup_status",40); |
| 2137 |
display_nrst("airport"); |
| 2138 |
return; |
| 2139 |
} |
| 2140 |
|
| 2141 |
var status = getprop("/instrumentation/garmin196/status"); |
| 2142 |
|
| 2143 |
##menu routes |
| 2144 |
if(status==121){ |
| 2145 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 2146 |
if(getprop("/instrumentation/garmin196/routes/route["~no_ligne~"]/name")!=nil){ |
| 2147 |
load_flight_plan(no_ligne); |
| 2148 |
affiche_fpl_loaded(); |
| 2149 |
} |
| 2150 |
return; |
| 2151 |
} |
| 2152 |
|
| 2153 |
if(status==122){ |
| 2154 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 2155 |
var no_ligne_detail = getprop("/instrumentation/garmin196/menu_routes/no_ligne_detail"); |
| 2156 |
if(getprop("/instrumentation/garmin196/routes/route["~no_ligne~"]/wpts/wpt["~no_ligne_detail~"]/id")!=nil){ |
| 2157 |
jump_to_waypoint(no_ligne_detail); |
| 2158 |
affiche_waypoint_jump(); |
| 2159 |
} |
| 2160 |
return; |
| 2161 |
} |
| 2162 |
|
| 2163 |
if(status==123){ |
| 2164 |
var x_char = getprop("/instrumentation/garmin196/menu_routes/search/x_char"); |
| 2165 |
if(x_char<20){ |
| 2166 |
setprop("/instrumentation/garmin196/menu_routes/search/x_char",x_char+1); |
| 2167 |
display_route_waypoint_search(); |
| 2168 |
} |
| 2169 |
return; |
| 2170 |
} |
| 2171 |
|
| 2172 |
##menu points |
| 2173 |
if(status==132){ |
| 2174 |
var x_char = getprop("/instrumentation/garmin196/menu_points/x_char"); |
| 2175 |
if(x_char<20){ |
| 2176 |
setprop("/instrumentation/garmin196/menu_points/x_char",x_char+1); |
| 2177 |
display_menu_points(); |
| 2178 |
} |
| 2179 |
return; |
| 2180 |
} |
| 2181 |
|
| 2182 |
##menu aircraft |
| 2183 |
if(status==142){ |
| 2184 |
var x_char = getprop("/instrumentation/garmin196/menu_aircraft/x_char"); |
| 2185 |
if(x_char<20){ |
| 2186 |
setprop("/instrumentation/garmin196/menu_aircraft/x_char",x_char+1); |
| 2187 |
display_menu_aircraft_name(); |
| 2188 |
} |
| 2189 |
return; |
| 2190 |
} |
| 2191 |
|
| 2192 |
if(status==170){ |
| 2193 |
setprop("/instrumentation/garmin196/status",175); |
| 2194 |
} |
| 2195 |
|
| 2196 |
} |
| 2197 |
} |
| 2198 |
} |
| 2199 |
|
| 2200 |
##recalc speed to display |
| 2201 |
var change_speed_display = func{ |
| 2202 |
var max_speed = getprop("/instrumentation/garmin196/max-speed"); |
| 2203 |
var speed = getprop("/instrumentation/gps/indicated-ground-speed-kt"); |
| 2204 |
setprop("/instrumentation/garmin196/speed-display",315*speed/max_speed); |
| 2205 |
} |
| 2206 |
|
| 2207 |
##calcul du turn rate |
| 2208 |
var calcul_turn_rate = func(dt){ |
| 2209 |
if(last_bearing==-1){ |
| 2210 |
last_bearing = getprop("/instrumentation/gps/magnetic-bug-error-deg"); |
| 2211 |
} |
| 2212 |
bearing = getprop("/instrumentation/gps/magnetic-bug-error-deg"); |
| 2213 |
|
| 2214 |
var turn_rate = abs(bearing - last_bearing); |
| 2215 |
if(turn_rate>180){ |
| 2216 |
turn_rate = 360 - turn_rate; |
| 2217 |
} |
| 2218 |
var sgn = 1; |
| 2219 |
if(bearing - last_bearing<0){ |
| 2220 |
sgn = -1; |
| 2221 |
} |
| 2222 |
turn_rate = turn_rate/dt; |
| 2223 |
if(turn_rate<10){##pour enlever les valeurs aberentes |
| 2224 |
props.globals.getNode("/instrumentation/garmin196/turn-rate",1).setDoubleValue(sgn*turn_rate); |
| 2225 |
} |
| 2226 |
last_bearing = bearing; |
| 2227 |
} |
| 2228 |
|
| 2229 |
var change_wpt_id = func{ |
| 2230 |
if(getprop("/instrumentation/gps/mode")!=nil and getprop("/autopilot/route-manager/wp[0]/id")!=""){ |
| 2231 |
props.global.getNode("/instrumentation/garmin196/panel-wpt-id").alias("/autopilot/route-manager/wp[0]/id"); |
| 2232 |
}else{ |
| 2233 |
setprop("/instrumentation/garmin196/panel-wpt-id",getprop("/instrumentation/garmin196/panel-wpt-dto-id")); |
| 2234 |
} |
| 2235 |
} |
| 2236 |
setlistener("/instrumentation/gps/mode",change_wpt_id); |
| 2237 |
|
| 2238 |
var change_position_wpt_bug = func{ |
| 2239 |
var wpt_bearing = getprop("/instrumentation/gps/wp/wp[1]/bearing-mag-deg"); |
| 2240 |
var aircraft_bearing = getprop("/instrumentation/gps/indicated-track-magnetic-deg"); |
| 2241 |
|
| 2242 |
var diff = wpt_bearing - aircraft_bearing; |
| 2243 |
setprop("/instrumentation/garmin196/position-wpt-bearing",diff); |
| 2244 |
setprop("/instrumentation/garmin196/panel-wpt-bearing",diff); |
| 2245 |
|
| 2246 |
var nb_wpt = getprop("/autopilot/route-manager/route/num"); |
| 2247 |
var no_wpt = getprop("/autopilot/route-manager/current-wp"); |
| 2248 |
var panel_course = 0; |
| 2249 |
if(no_wpt>0 and no_wpt<(nb_wpt-1)){ |
| 2250 |
panel_course = getprop("/autopilot/route-manager/route/wp["~(no_wpt-1)~"]/leg-bearing-true-deg"); |
| 2251 |
}else{ |
| 2252 |
panel_course = getprop("/instrumentation/gps/wp/wp[1]/bearing-mag-deg"); |
| 2253 |
} |
| 2254 |
panel_course = panel_course - aircraft_bearing; |
| 2255 |
var panel_deflexion = diff - panel_course; |
| 2256 |
|
| 2257 |
if(math.cos(diff*math.pi/180)>0){ |
| 2258 |
setprop("/instrumentation/garmin196/panel-neddle-to-flag",1); |
| 2259 |
}else{ |
| 2260 |
setprop("/instrumentation/garmin196/panel-neddle-to-flag",0); |
| 2261 |
} |
| 2262 |
if(panel_deflexion>10){ |
| 2263 |
panel_deflexion = 10; |
| 2264 |
} |
| 2265 |
if(panel_deflexion<-10){ |
| 2266 |
panel_deflexion = -10; |
| 2267 |
} |
| 2268 |
|
| 2269 |
setprop("/instrumentation/garmin196/panel-neddle-course",panel_course); |
| 2270 |
setprop("/instrumentation/garmin196/panel-neddle-deflexion",panel_deflexion); |
| 2271 |
|
| 2272 |
##vnav |
| 2273 |
var altitude_id = getprop("/instrumentation/garmin196/vnav/altitude-m"); |
| 2274 |
var latitude_id = getprop("/instrumentation/garmin196/vnav/latitude"); |
| 2275 |
var longitude_id = getprop("/instrumentation/garmin196/vnav/longitude"); |
| 2276 |
if(altitude_id!=nil and latitude_id!=nil and longitude_id!=nil and latitude_id!=-9999 and longitude_id!=-9999 and getprop("/instrumentation/garmin196/params/vnav-indicator")==1){ |
| 2277 |
var altitude_aircraft = getprop("/instrumentation/gps/indicated-altitude-ft") * 0.3048; |
| 2278 |
var latitude_aircraft = getprop("/instrumentation/gps/indicated-latitude-deg"); |
| 2279 |
var longitude_aircraft = getprop("/instrumentation/gps/indicated-longitude-deg"); |
| 2280 |
|
| 2281 |
var coord_id = geo.Coord.new().set_latlon(latitude_id,longitude_id); |
| 2282 |
var coord_aircraft = geo.Coord.new().set_latlon(latitude_aircraft,longitude_aircraft); |
| 2283 |
var distance = coord_aircraft.distance_to(coord_id);## en metres |
| 2284 |
var diff_altitude = altitude_aircraft - altitude_id; |
| 2285 |
var angle = math.atan2(diff_altitude,distance)*180/math.pi; |
| 2286 |
#setprop("/instrumentation/garmin196/vnav/angle",angle); |
| 2287 |
var deviation = angle - 3;#pente ideale = 3 degres |
| 2288 |
if(deviation>10){ |
| 2289 |
deviation = 10; |
| 2290 |
} |
| 2291 |
if(deviation<-10){ |
| 2292 |
deviation = -10; |
| 2293 |
} |
| 2294 |
setprop("/instrumentation/garmin196/vnav/deviation",deviation); |
| 2295 |
}else{ |
| 2296 |
setprop("/instrumentation/garmin196/vnav/deviation",0); |
| 2297 |
} |
| 2298 |
} |
| 2299 |
|
| 2300 |
var update_map = func{ |
| 2301 |
##protection, une seule recherche gps a la fois, la popup devient prioritaire |
| 2302 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 2303 |
if(popup_status<10 or popup_status>99){ |
| 2304 |
var max_plots = 25; |
| 2305 |
var offset_mul = 0.034; |
| 2306 |
var symbol_map_range = getprop("/instrumentation/garmin196/map-range") * 8; |
| 2307 |
var plots = []; |
| 2308 |
var type_symbol = [ "airport" , "vor" , "ndb" , "fix" , "twn" , "wpt"]; |
| 2309 |
|
| 2310 |
for(var i=0;i<size(type_symbol);i=i+1){ |
| 2311 |
if(getprop("/instrumentation/garmin196/symbols/params/"~type_symbol[i])==1){ |
| 2312 |
if(type_symbol[i]=="twn" or type_symbol[i]=="wpt"){ |
| 2313 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(max_plots*8 + 1); |
| 2314 |
}else{ |
| 2315 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(max_plots*4 + 1); |
| 2316 |
} |
| 2317 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 2318 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 2319 |
var type = type_symbol[i]; |
| 2320 |
if(type == "twn"){ |
| 2321 |
type = "wpt"; |
| 2322 |
} |
| 2323 |
setprop("/instrumentation/gps/scratch/type", type); |
| 2324 |
setprop("/instrumentation/gps/command", "nearest"); |
| 2325 |
|
| 2326 |
while (getprop('/instrumentation/gps/scratch/has-next')) { |
| 2327 |
var id = getprop('/instrumentation/gps/scratch/ident'); |
| 2328 |
var range = getprop('/instrumentation/gps/scratch/distance-nm') / symbol_map_range; |
| 2329 |
var bearing = 360 - getprop("/instrumentation/gps/indicated-track-magnetic-deg") + getprop('/instrumentation/gps/scratch/mag-bearing-deg'); |
| 2330 |
if(bearing<0){ |
| 2331 |
bearing = bearing + 360; |
| 2332 |
} |
| 2333 |
|
| 2334 |
if(bearing>360){ |
| 2335 |
bearing = bearing - 360; |
| 2336 |
} |
| 2337 |
|
| 2338 |
if(i==1){##vor |
| 2339 |
id = id ~ " " ~ sprintf("%2.2f",getprop('/instrumentation/gps/scratch/frequency-mhz')); |
| 2340 |
} |
| 2341 |
|
| 2342 |
if(i==2){##ndb |
| 2343 |
id = id ~ " " ~ sprintf("%2.1f",getprop('/instrumentation/gps/scratch/frequency-khz')); |
| 2344 |
} |
| 2345 |
|
| 2346 |
var plot = { id: id,bearing: bearing,type: i,range: range}; |
| 2347 |
if(range<=1){ |
| 2348 |
if(i<4){ |
| 2349 |
append(plots,plot); |
| 2350 |
}elsif(i==4 and substr(id,size(id)-6)=="WPTTWN"){ |
| 2351 |
append(plots,plot); |
| 2352 |
}elsif(i==5 and substr(id,size(id)-6)=="WPTUSR"){ |
| 2353 |
append(plots,plot); |
| 2354 |
} |
| 2355 |
}else{ |
| 2356 |
break; |
| 2357 |
} |
| 2358 |
setprop("/instrumentation/gps/command", "next"); |
| 2359 |
} |
| 2360 |
} |
| 2361 |
} |
| 2362 |
|
| 2363 |
var plots_sorted = sort (plots, func (a,b) a.range - b.range); |
| 2364 |
|
| 2365 |
##suppression des points les plus proches si il y en a de trop |
| 2366 |
var filtrage = getprop("/instrumentation/garmin196/params/filtrage"); |
| 2367 |
if(filtrage==1){ |
| 2368 |
var nb_points = 0; |
| 2369 |
for(var i=0;i<size(plots_sorted);i=i+1){ |
| 2370 |
if(plots_sorted[i].range<0.25){#un quart d'ecran |
| 2371 |
nb_points = nb_points + 1; |
| 2372 |
}else{ |
| 2373 |
break; |
| 2374 |
} |
| 2375 |
} |
| 2376 |
if(nb_points>5){ |
| 2377 |
plots_sorted = subvec(plots_sorted,nb_points); |
| 2378 |
} |
| 2379 |
} |
| 2380 |
|
| 2381 |
var nb_plots = max_plots; |
| 2382 |
if(nb_plots>size(plots_sorted)){ |
| 2383 |
nb_plots = size(plots_sorted); |
| 2384 |
} |
| 2385 |
for(var i=0;i<nb_plots;i=i+1){ |
| 2386 |
if(plots_sorted[i].type==4 or plots_sorted[i].type==5){##town or waypoint |
| 2387 |
var type_wpt = substr(plots_sorted[i].id,size(plots_sorted[i].id)-6); |
| 2388 |
if(type_wpt=="WPTTWN"){#cities |
| 2389 |
plots_sorted[i].id = substr(plots_sorted[i].id,0,size(plots_sorted[i].id)-8); |
| 2390 |
}elsif(type_wpt=="WPTUSR"){#wpt user |
| 2391 |
plots_sorted[i].id = substr(plots_sorted[i].id,0,size(plots_sorted[i].id)-6); |
| 2392 |
plots_sorted[i].type = 5; |
| 2393 |
} |
| 2394 |
} |
| 2395 |
|
| 2396 |
props.globals.getNode("/instrumentation/garmin196/symbols/symbol["~i~"]/id",1).setValue(plots_sorted[i].id); |
| 2397 |
props.globals.getNode("/instrumentation/garmin196/symbols/symbol["~i~"]/type",1).setValue(plots_sorted[i].type); |
| 2398 |
|
| 2399 |
##calcul des coordonnees |
| 2400 |
var x_wp = math.cos(plots_sorted[i].bearing*math.pi/180) * plots_sorted[i].range * offset_mul; |
| 2401 |
var y_wp = math.sin(plots_sorted[i].bearing*math.pi/180) * plots_sorted[i].range * offset_mul; |
| 2402 |
props.globals.getNode("/instrumentation/garmin196/symbols/symbol["~i~"]/x",1).setDoubleValue(x_wp); |
| 2403 |
props.globals.getNode("/instrumentation/garmin196/symbols/symbol["~i~"]/y",1).setDoubleValue(y_wp); |
| 2404 |
|
| 2405 |
if(x_wp<0.026 and x_wp>-0.026 and y_wp<0.0323 and y_wp>-0.0323){##si on est dans l'ecran, on affiche |
| 2406 |
props.globals.getNode("/instrumentation/garmin196/symbols/symbol["~i~"]/visible",1).setBoolValue(1); |
| 2407 |
}else{ |
| 2408 |
props.globals.getNode("/instrumentation/garmin196/symbols/symbol["~i~"]/visible",1).setBoolValue(0); |
| 2409 |
} |
| 2410 |
} |
| 2411 |
|
| 2412 |
for(var i=nb_plots;i<max_plots;i=i+1){ |
| 2413 |
props.globals.getNode("/instrumentation/garmin196/symbols/symbol["~i~"]/visible",1).setIntValue(0); |
| 2414 |
} |
| 2415 |
|
| 2416 |
##wpt path calculations |
| 2417 |
var offset_range_wp_direct = 0.19; |
| 2418 |
var range_wp_direct = offset_range_wp_direct * getprop("/instrumentation/gps/wp/wp[1]/distance-nm") / symbol_map_range; |
| 2419 |
|
| 2420 |
var bearing_wp_direct = getprop("/instrumentation/garmin196/panel-wpt-bearing"); |
| 2421 |
var x_range_wp_direct = math.abs(math.cos(bearing_wp_direct*math.pi/180) * range_wp_direct); #max 0.15 |
| 2422 |
if(x_range_wp_direct>0.15){ |
| 2423 |
range_wp_direct = math.abs(0.15 / math.cos(bearing_wp_direct*math.pi/180)); |
| 2424 |
} |
| 2425 |
var y_range_wp_direct = math.abs(math.sin(bearing_wp_direct*math.pi/180) * range_wp_direct); #max 0.18 |
| 2426 |
if(y_range_wp_direct>0.18){ |
| 2427 |
range_wp_direct = math.abs(0.18 / math.sin(bearing_wp_direct*math.pi/180)); |
| 2428 |
} |
| 2429 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_direct/range",range_wp_direct); |
| 2430 |
|
| 2431 |
if(getprop("/instrumentation/garmin196/panel-wpt-id")!=nil and getprop("/instrumentation/garmin196/panel-wpt-id")!="------"){ |
| 2432 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_direct/visible",1); |
| 2433 |
}else{ |
| 2434 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_direct/visible",0); |
| 2435 |
} |
| 2436 |
|
| 2437 |
##flight plan calculation |
| 2438 |
var nb_path = getprop("/autopilot/route-manager/route/num"); |
| 2439 |
if(nb_path>9){ |
| 2440 |
nb_path = 9; |
| 2441 |
} |
| 2442 |
|
| 2443 |
var aircraft_bearing = getprop("/instrumentation/gps/indicated-track-magnetic-deg"); |
| 2444 |
for(var i=0;i<(nb_path-1);i=i+1){ |
| 2445 |
var id = getprop("/autopilot/route-manager/route/wp["~i~"]/id"); |
| 2446 |
|
| 2447 |
setprop("/instrumentation/gps/scratch/max-results",1); |
| 2448 |
setprop("/instrumentation/gps/scratch/longitude-deg",-9999); |
| 2449 |
setprop("/instrumentation/gps/scratch/latitude-deg",-9999); |
| 2450 |
setprop("/instrumentation/gps/scratch/type", ""); |
| 2451 |
setprop("/instrumentation/gps/scratch/query", id); |
| 2452 |
setprop("/instrumentation/gps/command", "search"); |
| 2453 |
|
| 2454 |
if(getprop("/instrumentation/gps/scratch/valid")==0 or getprop("/instrumentation/gps/scratch/ident")!=id){ |
| 2455 |
setprop("/instrumentation/gps/scratch/type", "fix"); |
| 2456 |
setprop("/instrumentation/gps/scratch/query", id); |
| 2457 |
setprop("/instrumentation/gps/command", "search"); |
| 2458 |
} |
| 2459 |
|
| 2460 |
var distance_to_wp = getprop("/instrumentation/gps/scratch/distance-nm") / symbol_map_range; |
| 2461 |
var bearing_to_wp = 360 - getprop("/instrumentation/gps/indicated-track-magnetic-deg") + getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 2462 |
|
| 2463 |
var x_wp_fpl = math.cos(bearing_to_wp*math.pi/180) * distance_to_wp * offset_mul; |
| 2464 |
var y_wp_fpl = math.sin(bearing_to_wp*math.pi/180) * distance_to_wp * offset_mul; |
| 2465 |
|
| 2466 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_"~i~"_"~(i+1)~"/x",x_wp_fpl); |
| 2467 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_"~i~"_"~(i+1)~"/y",y_wp_fpl); |
| 2468 |
|
| 2469 |
var wp_bearing = 360 - getprop("/instrumentation/gps/indicated-track-true-deg") + getprop("/autopilot/route-manager/route/wp["~i~"]/leg-bearing-true-deg"); |
| 2470 |
var wp_distance = offset_range_wp_direct * getprop("/autopilot/route-manager/route/wp["~i~"]/leg-distance-nm") / symbol_map_range; |
| 2471 |
|
| 2472 |
var x_range_wp =(math.cos(wp_bearing*math.pi/180) * wp_distance) + ((x_wp_fpl/0.026)*0.15); #max 0.15 |
| 2473 |
if(math.abs(x_range_wp)>0.15){ |
| 2474 |
wp_distance = math.abs(((0.15*math.sgn(math.cos(wp_bearing*math.pi/180))) - ((x_wp_fpl/0.026)*0.15))/math.cos(wp_bearing*math.pi/180)); |
| 2475 |
} |
| 2476 |
|
| 2477 |
var y_range_wp =(math.sin(wp_bearing*math.pi/180) * wp_distance) + ((y_wp_fpl/0.0323)*0.18); #max 0.18 |
| 2478 |
if(math.abs(y_range_wp)>0.18){ |
| 2479 |
wp_distance = math.abs(((0.18*math.sgn(math.sin(wp_bearing*math.pi/180))) - ((y_wp_fpl/0.0323)*0.18))/math.sin(wp_bearing*math.pi/180)); |
| 2480 |
} |
| 2481 |
|
| 2482 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_"~i~"_"~(i+1)~"/range",wp_distance); |
| 2483 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_"~i~"_"~(i+1)~"/bearing",wp_bearing); |
| 2484 |
|
| 2485 |
if(x_wp_fpl<0.026 and x_wp_fpl>-0.026 and y_wp_fpl<0.0323 and y_wp_fpl>-0.0323){##si on est dans l'ecran, on affiche |
| 2486 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_"~i~"_"~(i+1)~"/visible",1); |
| 2487 |
}else{ |
| 2488 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_"~i~"_"~(i+1)~"/visible",0); |
| 2489 |
} |
| 2490 |
} |
| 2491 |
for(var i=nb_path;i<9;i=i+1){ |
| 2492 |
setprop("/instrumentation/garmin196/symbols/paths/range_wp_"~i~"_"~(i+1)~"/visible",0); |
| 2493 |
} |
| 2494 |
|
| 2495 |
} |
| 2496 |
if(getprop("/instrumentation/garmin196/serviceable")==1 and getprop("/instrumentation/garmin196/status")==10){ |
| 2497 |
settimer(update_map,1); |
| 2498 |
} |
| 2499 |
} |
| 2500 |
|
| 2501 |
var display_dto_recent = func{ |
| 2502 |
var waypoints = props.globals.getNode("/instrumentation/garmin196/waypoints/recent/",1); |
| 2503 |
var i = 0; |
| 2504 |
foreach (var e; waypoints.getChildren("wpt")) { |
| 2505 |
var id = e.getChild("id").getValue(); |
| 2506 |
var type = e.getChild("type").getValue(); |
| 2507 |
var ligne = id; |
| 2508 |
if(type=="wpt"){ |
| 2509 |
var type_wpt = substr(id,size(id)-6); |
| 2510 |
if(type_wpt=="WPTTWN"){#cities |
| 2511 |
ligne = substr(id,0,size(id)-8); |
| 2512 |
ligne = substr(ligne,0,15); |
| 2513 |
}elsif(type_wpt=="WPTUSR"){#wpt user |
| 2514 |
ligne = substr(id,0,size(id)-6); |
| 2515 |
} |
| 2516 |
} |
| 2517 |
|
| 2518 |
ligne = ligne ~ " " ~ type; |
| 2519 |
var ligne_spaces = " "; |
| 2520 |
ligne_spaces = substr(ligne_spaces,0,15-size(ligne)); |
| 2521 |
|
| 2522 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(1); |
| 2523 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 2524 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 2525 |
setprop("/instrumentation/gps/scratch/type", type); |
| 2526 |
setprop("/instrumentation/gps/scratch/query", id); |
| 2527 |
setprop("/instrumentation/gps/command", "search"); |
| 2528 |
|
| 2529 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 2530 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 2531 |
|
| 2532 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 2533 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 2534 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 2535 |
}else{ |
| 2536 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 2537 |
} |
| 2538 |
|
| 2539 |
if(i==0){ |
| 2540 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",ligne); |
| 2541 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~i~"]/selected",1).setBoolValue(1); |
| 2542 |
}else{ |
| 2543 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~i~"]/selected",1).setBoolValue(0); |
| 2544 |
} |
| 2545 |
setprop("/instrumentation/garmin196/dto_display/ligne["~i~"]/texte",ligne); |
| 2546 |
setprop("/instrumentation/garmin196/dto_display/ligne["~i~"]/id",id); |
| 2547 |
setprop("/instrumentation/garmin196/dto_display/ligne["~i~"]/type",type); |
| 2548 |
i=i+1; |
| 2549 |
} |
| 2550 |
for(var j=i;j<5;j=j+1){ |
| 2551 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/texte",""); |
| 2552 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~j~"]/selected",1).setBoolValue(0); |
| 2553 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/id",""); |
| 2554 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/type",""); |
| 2555 |
} |
| 2556 |
setprop("/instrumentation/garmin196/dto_display/no_ligne_selected",0); |
| 2557 |
setprop("/instrumentation/garmin196/dto_display/max_ligne_selected",i-1); |
| 2558 |
if(i==0){ |
| 2559 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",""); |
| 2560 |
} |
| 2561 |
} |
| 2562 |
|
| 2563 |
var display_dto_user = func{ |
| 2564 |
var waypoints = props.globals.getNode("/instrumentation/garmin196/waypoints/user/",1); |
| 2565 |
var i = 0; |
| 2566 |
foreach (var e; waypoints.getChildren("wpt")) { |
| 2567 |
var id = e.getChild("id").getValue()~"WPTUSR"; |
| 2568 |
var type = "wpt"; |
| 2569 |
var ligne = substr(id,0,size(id)-6); |
| 2570 |
ligne = substr(ligne,0,14); |
| 2571 |
|
| 2572 |
var ligne_spaces = " "; |
| 2573 |
ligne_spaces = substr(ligne_spaces,0,14-size(ligne)); |
| 2574 |
|
| 2575 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(1); |
| 2576 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 2577 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 2578 |
setprop("/instrumentation/gps/scratch/type", type); |
| 2579 |
setprop("/instrumentation/gps/scratch/query", id); |
| 2580 |
setprop("/instrumentation/gps/command", "search"); |
| 2581 |
|
| 2582 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 2583 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 2584 |
|
| 2585 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 2586 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 2587 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 2588 |
}else{ |
| 2589 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 2590 |
} |
| 2591 |
|
| 2592 |
if(i==0){ |
| 2593 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",ligne); |
| 2594 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~i~"]/selected",1).setBoolValue(1); |
| 2595 |
}else{ |
| 2596 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~i~"]/selected",1).setBoolValue(0); |
| 2597 |
} |
| 2598 |
setprop("/instrumentation/garmin196/dto_display/ligne["~i~"]/texte",ligne); |
| 2599 |
setprop("/instrumentation/garmin196/dto_display/ligne["~i~"]/id",id); |
| 2600 |
setprop("/instrumentation/garmin196/dto_display/ligne["~i~"]/type",type); |
| 2601 |
i=i+1; |
| 2602 |
} |
| 2603 |
for(var j=i;j<5;j=j+1){ |
| 2604 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/texte",""); |
| 2605 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~j~"]/selected",1).setBoolValue(0); |
| 2606 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/id",""); |
| 2607 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/type",""); |
| 2608 |
} |
| 2609 |
setprop("/instrumentation/garmin196/dto_display/no_ligne_selected",0); |
| 2610 |
setprop("/instrumentation/garmin196/dto_display/max_ligne_selected",i-1); |
| 2611 |
if(i==0){ |
| 2612 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",""); |
| 2613 |
} |
| 2614 |
} |
| 2615 |
|
| 2616 |
var affectation_waypoint = func(id){ |
| 2617 |
setprop("/autopilot/route-manager/input","@CLEAR"); |
| 2618 |
setprop("/autopilot/route-manager/input","@POP"); |
| 2619 |
setprop("/autopilot/route-manager/input","@insert0:"~id); |
| 2620 |
setprop("/autopilot/route-manager/input","@JUMP0"); |
| 2621 |
setprop("/autopilot/route-manager/input","@ACTIVATE"); |
| 2622 |
} |
| 2623 |
|
| 2624 |
var display_dto_search = func{ |
| 2625 |
var ligne_selected = getprop("/instrumentation/garmin196/dto_display/ligne_select"); |
| 2626 |
var x_char = props.globals.getNode("/instrumentation/garmin196/dto_display/x_char").getValue(); |
| 2627 |
ligne_selected = substr(ligne_selected,0,x_char); |
| 2628 |
ligne_selected = ligne_selected ~ tab_chiffres_lettres[getprop("/instrumentation/garmin196/dto_display/y_char")]; |
| 2629 |
setprop("/instrumentation/garmin196/dto_display/ligne_select",ligne_selected); |
| 2630 |
|
| 2631 |
var plots = []; |
| 2632 |
##recherche gps globale |
| 2633 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(5); |
| 2634 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 2635 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 2636 |
props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(0); |
| 2637 |
props.globals.getNode("/instrumentation/gps/scratch/query",1).setValue(ligne_selected); |
| 2638 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue(""); |
| 2639 |
|
| 2640 |
setprop("/instrumentation/gps/command", "search"); |
| 2641 |
var i=0; |
| 2642 |
var flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 2643 |
while (flag_continue and i<5) { |
| 2644 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 2645 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 2646 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 2647 |
var type = getprop("/instrumentation/gps/scratch/type"); |
| 2648 |
|
| 2649 |
var ligne = id; |
| 2650 |
if(type=="waypoint"){ |
| 2651 |
type = "wpt"; |
| 2652 |
var type_wpt = substr(id,size(id)-6); |
| 2653 |
if(type_wpt=="WPTTWN"){#cities |
| 2654 |
ligne = substr(id,0,size(id)-8); |
| 2655 |
}elsif(type_wpt=="WPTUSR"){#wpt user |
| 2656 |
ligne = substr(id,0,size(id)-6); |
| 2657 |
} |
| 2658 |
} |
| 2659 |
|
| 2660 |
ligne = ligne ~ " " ~ type; |
| 2661 |
var ligne_spaces = " "; |
| 2662 |
ligne_spaces = substr(ligne_spaces,0,16-size(ligne)); |
| 2663 |
|
| 2664 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 2665 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 2666 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 2667 |
}else{ |
| 2668 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 2669 |
} |
| 2670 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 2671 |
|
| 2672 |
|
| 2673 |
var plot = { id: id,texte: ligne,type: type}; |
| 2674 |
append(plots,plot); |
| 2675 |
|
| 2676 |
i=i+1; |
| 2677 |
setprop("/instrumentation/gps/command", "next"); |
| 2678 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 2679 |
} |
| 2680 |
|
| 2681 |
##recherche gps fix |
| 2682 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(5); |
| 2683 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 2684 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 2685 |
props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(0); |
| 2686 |
props.globals.getNode("/instrumentation/gps/scratch/query",1).setValue(ligne_selected); |
| 2687 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue("fix"); |
| 2688 |
|
| 2689 |
setprop("/instrumentation/gps/command", "search"); |
| 2690 |
i=0; |
| 2691 |
flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 2692 |
while (flag_continue and i<5) { |
| 2693 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 2694 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 2695 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 2696 |
var type = getprop("/instrumentation/gps/scratch/type"); |
| 2697 |
|
| 2698 |
var ligne = id ~ " " ~ type; |
| 2699 |
var ligne_spaces = " "; |
| 2700 |
ligne_spaces = substr(ligne_spaces,0,16-size(ligne)); |
| 2701 |
|
| 2702 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 2703 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 2704 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 2705 |
}else{ |
| 2706 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 2707 |
} |
| 2708 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 2709 |
|
| 2710 |
|
| 2711 |
var plot = { id: id,texte: ligne,type: type}; |
| 2712 |
append(plots,plot); |
| 2713 |
|
| 2714 |
i=i+1; |
| 2715 |
setprop("/instrumentation/gps/command", "next"); |
| 2716 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 2717 |
} |
| 2718 |
|
| 2719 |
##recherche gps vor |
| 2720 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(5); |
| 2721 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 2722 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 2723 |
props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(0); |
| 2724 |
props.globals.getNode("/instrumentation/gps/scratch/query",1).setValue(ligne_selected); |
| 2725 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue("vor"); |
| 2726 |
|
| 2727 |
setprop("/instrumentation/gps/command", "search"); |
| 2728 |
i=0; |
| 2729 |
flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 2730 |
while (flag_continue and i<5) { |
| 2731 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 2732 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 2733 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 2734 |
var type = getprop("/instrumentation/gps/scratch/type"); |
| 2735 |
|
| 2736 |
var ligne = id ~ " vor"; |
| 2737 |
var ligne_spaces = " "; |
| 2738 |
ligne_spaces = substr(ligne_spaces,0,16-size(ligne)); |
| 2739 |
|
| 2740 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 2741 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 2742 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 2743 |
}else{ |
| 2744 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 2745 |
} |
| 2746 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 2747 |
|
| 2748 |
|
| 2749 |
var plot = { id: id,texte: ligne,type: type}; |
| 2750 |
append(plots,plot); |
| 2751 |
|
| 2752 |
i=i+1; |
| 2753 |
setprop("/instrumentation/gps/command", "next"); |
| 2754 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 2755 |
} |
| 2756 |
|
| 2757 |
##recherche gps ndb |
| 2758 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(5); |
| 2759 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 2760 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 2761 |
props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(0); |
| 2762 |
props.globals.getNode("/instrumentation/gps/scratch/query",1).setValue(ligne_selected); |
| 2763 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue("ndb"); |
| 2764 |
|
| 2765 |
setprop("/instrumentation/gps/command", "search"); |
| 2766 |
i=0; |
| 2767 |
flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 2768 |
while (flag_continue and i<5) { |
| 2769 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 2770 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 2771 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 2772 |
var type = getprop("/instrumentation/gps/scratch/type"); |
| 2773 |
|
| 2774 |
var ligne = id ~ " ndb"; |
| 2775 |
var ligne_spaces = " "; |
| 2776 |
ligne_spaces = substr(ligne_spaces,0,16-size(ligne)); |
| 2777 |
|
| 2778 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 2779 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 2780 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 2781 |
}else{ |
| 2782 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 2783 |
} |
| 2784 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 2785 |
|
| 2786 |
|
| 2787 |
var plot = { id: id,texte: ligne,type: type}; |
| 2788 |
append(plots,plot); |
| 2789 |
|
| 2790 |
i=i+1; |
| 2791 |
setprop("/instrumentation/gps/command", "next"); |
| 2792 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 2793 |
} |
| 2794 |
|
| 2795 |
var plots_sorted = sort (plots, func (a,b) cmp (a.id, b.id)); |
| 2796 |
var nb_plots = size(plots_sorted); |
| 2797 |
if(nb_plots>5){ |
| 2798 |
nb_plots = 5; |
| 2799 |
} |
| 2800 |
for(var j=0;j<nb_plots;j=j+1){ |
| 2801 |
if(i==0 and popup_status!=10 and popup_status!=11){ |
| 2802 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~i~"]/selected",1).setBoolValue(1); |
| 2803 |
}else{ |
| 2804 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~i~"]/selected",1).setBoolValue(0); |
| 2805 |
} |
| 2806 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/texte",plots_sorted[j].texte); |
| 2807 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/id",plots_sorted[j].id); |
| 2808 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/type",plots_sorted[j].type); |
| 2809 |
} |
| 2810 |
|
| 2811 |
for(var j=nb_plots;j<5;j=j+1){ |
| 2812 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/texte",""); |
| 2813 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~j~"]/selected",1).setBoolValue(0); |
| 2814 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/id",""); |
| 2815 |
setprop("/instrumentation/garmin196/dto_display/ligne["~j~"]/type",""); |
| 2816 |
} |
| 2817 |
setprop("/instrumentation/garmin196/dto_display/no_ligne_selected",0); |
| 2818 |
setprop("/instrumentation/garmin196/dto_display/max_ligne_selected",nb_plots-1); |
| 2819 |
} |
| 2820 |
|
| 2821 |
var searchLastChar = func(chaine, char){ |
| 2822 |
var result = -1; |
| 2823 |
var char_a_tester = substr(chaine,char,1); |
| 2824 |
for(var i=0;i<size(tab_chiffres_lettres);i=i+1){ |
| 2825 |
if(tab_chiffres_lettres[i]==char_a_tester){ |
| 2826 |
result = i; |
| 2827 |
break; |
| 2828 |
} |
| 2829 |
} |
| 2830 |
return result; |
| 2831 |
} |
| 2832 |
|
| 2833 |
var init_dto_display = func{ |
| 2834 |
for(var i=0;i<5;i=i+1){ |
| 2835 |
setprop("/instrumentation/garmin196/dto_display/ligne["~i~"]/texte",""); |
| 2836 |
props.globals.getNode("/instrumentation/garmin196/dto_display/ligne["~i~"]/selected",1).setBoolValue(0); |
| 2837 |
setprop("/instrumentation/garmin196/dto_display/ligne["~i~"]/id",""); |
| 2838 |
setprop("/instrumentation/garmin196/dto_display/ligne["~i~"]/type",""); |
| 2839 |
} |
| 2840 |
} |
| 2841 |
|
| 2842 |
var init_nrst_display = func{ |
| 2843 |
for(var i=0;i<5;i=i+1){ |
| 2844 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~i~"]/texte",""); |
| 2845 |
props.globals.getNode("/instrumentation/garmin196/nrst_display/ligne["~i~"]/selected",1).setBoolValue(0); |
| 2846 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~i~"]/id",""); |
| 2847 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~i~"]/type",""); |
| 2848 |
} |
| 2849 |
} |
| 2850 |
|
| 2851 |
var display_nrst = func(type){ |
| 2852 |
if(type=="wpt"){ |
| 2853 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(25); |
| 2854 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 2855 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 2856 |
#props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(1); |
| 2857 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue(type); |
| 2858 |
setprop("/instrumentation/gps/command", "nearest"); |
| 2859 |
var i=0; |
| 2860 |
var flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 2861 |
while (flag_continue and i<5) { |
| 2862 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 2863 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 2864 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 2865 |
|
| 2866 |
var type_wpt = substr(id,size(id)-6); |
| 2867 |
if(type_wpt=="WPTTWN"){ |
| 2868 |
var ligne = substr(id,0,size(id)-8); |
| 2869 |
}elsif(type_wpt=="WPTUSR"){ |
| 2870 |
var ligne = substr(id,0,size(id)-6); |
| 2871 |
} |
| 2872 |
ligne = substr(ligne,0,18); |
| 2873 |
var ligne_spaces = " "; |
| 2874 |
ligne_spaces = substr(ligne_spaces,0,18-size(ligne)); |
| 2875 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 2876 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 2877 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 2878 |
}else{ |
| 2879 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 2880 |
} |
| 2881 |
|
| 2882 |
if(i==0){ |
| 2883 |
setprop("/instrumentation/garmin196/nrst_display/ligne_select",ligne); |
| 2884 |
props.globals.getNode("/instrumentation/garmin196/nrst_display/ligne["~i~"]/selected",1).setBoolValue(1); |
| 2885 |
}else{ |
| 2886 |
props.globals.getNode("/instrumentation/garmin196/nrst_display/ligne["~i~"]/selected",1).setBoolValue(0); |
| 2887 |
} |
| 2888 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~i~"]/texte",ligne); |
| 2889 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~i~"]/id",id); |
| 2890 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~i~"]/type",type); |
| 2891 |
i=i+1; |
| 2892 |
|
| 2893 |
setprop("/instrumentation/gps/command", "next"); |
| 2894 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 2895 |
} |
| 2896 |
setprop("/instrumentation/garmin196/nrst_display/no_ligne_selected",0); |
| 2897 |
setprop("/instrumentation/garmin196/nrst_display/max_ligne_selected",(i-1)); |
| 2898 |
|
| 2899 |
}else{ |
| 2900 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(6); |
| 2901 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 2902 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 2903 |
#props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(1); |
| 2904 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue(type); |
| 2905 |
props.globals.getNode("/instrumentation/gps/scratch").removeChildren("runways"); |
| 2906 |
setprop("/instrumentation/gps/command", "nearest"); |
| 2907 |
var i=0; |
| 2908 |
var flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 2909 |
while (flag_continue and i<5) { |
| 2910 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 2911 |
var ligne = id; |
| 2912 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 2913 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 2914 |
var ligne_spaces = " "; |
| 2915 |
ligne_spaces = substr(ligne_spaces,0,6-size(ligne)); |
| 2916 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 2917 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 2918 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 2919 |
}else{ |
| 2920 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 2921 |
} |
| 2922 |
if(type=="airport"){ |
| 2923 |
var runways = props.globals.getNode("/instrumentation/gps/scratch",1); |
| 2924 |
var max_length = 0; |
| 2925 |
foreach (var e; runways.getChildren("runways")) { |
| 2926 |
var runway_length = e.getChild("length-ft").getValue(); |
| 2927 |
if(runway_length>max_length){ |
| 2928 |
max_length = runway_length; |
| 2929 |
} |
| 2930 |
} |
| 2931 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 2932 |
ligne = ligne ~ " " ~ sprintf("%4.0fft",max_length); |
| 2933 |
}else{ |
| 2934 |
ligne = ligne ~ " " ~ sprintf("%4.0fm",max_length*0.3048); |
| 2935 |
} |
| 2936 |
|
| 2937 |
var radio = airportinfo(id).comms('ATIS'); |
| 2938 |
if(size(radio) > 0){ |
| 2939 |
ligne = ligne ~ sprintf(" %3.2f",radio[0]); |
| 2940 |
} |
| 2941 |
}elsif(type=="vor"){ |
| 2942 |
ligne = ligne ~ " " ~ sprintf("%2.2f",getprop('/instrumentation/gps/scratch/frequency-mhz')); |
| 2943 |
}elsif(type=="ndb"){ |
| 2944 |
ligne = ligne ~ " " ~ sprintf("%2.1f",getprop('/instrumentation/gps/scratch/frequency-khz')); |
| 2945 |
} |
| 2946 |
if(i==0){ |
| 2947 |
setprop("/instrumentation/garmin196/nrst_display/ligne_select",ligne); |
| 2948 |
props.globals.getNode("/instrumentation/garmin196/nrst_display/ligne["~i~"]/selected",1).setBoolValue(1); |
| 2949 |
}else{ |
| 2950 |
props.globals.getNode("/instrumentation/garmin196/nrst_display/ligne["~i~"]/selected",1).setBoolValue(0); |
| 2951 |
} |
| 2952 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~i~"]/texte",ligne); |
| 2953 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~i~"]/id",id); |
| 2954 |
setprop("/instrumentation/garmin196/nrst_display/ligne["~i~"]/type",type); |
| 2955 |
i=i+1; |
| 2956 |
|
| 2957 |
props.globals.getNode("/instrumentation/gps/scratch").removeChildren("runways"); |
| 2958 |
setprop("/instrumentation/gps/command", "next"); |
| 2959 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 2960 |
} |
| 2961 |
setprop("/instrumentation/garmin196/nrst_display/no_ligne_selected",0); |
| 2962 |
setprop("/instrumentation/garmin196/nrst_display/max_ligne_selected",(i-1)); |
| 2963 |
} |
| 2964 |
} |
| 2965 |
|
| 2966 |
var load_cities = func{ |
| 2967 |
print("Garmin 196 loading cities"); |
| 2968 |
fgcommand("loadxml", props.Node.new({ filename: getprop("/sim/fg-root")~"/Aircraft/Instruments-3d/garmin196/cities.xml", targetnode: "/instrumentation/garmin196/cities" })); |
| 2969 |
var waypoints = props.globals.getNode("/instrumentation/garmin196/cities/waypoints",1); |
| 2970 |
foreach (var e; waypoints.getChildren("waypoint")) { |
| 2971 |
var id = e.getChild("id").getValue(); |
| 2972 |
var latitude = e.getChild("latitude").getValue(); |
| 2973 |
var longitude = e.getChild("longitude").getValue(); |
| 2974 |
|
| 2975 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(longitude); |
| 2976 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(latitude); |
| 2977 |
props.globals.getNode("/instrumentation/gps/scratch/ident",1).setValue(id); |
| 2978 |
#setprop("/instrumentation/gps/command","define-user-wpt"); |
| 2979 |
} |
| 2980 |
props.globals.getNode("/instrumentation/garmin196").removeChildren("cities"); |
| 2981 |
|
| 2982 |
|
| 2983 |
print("Garmin 196 loading cities done"); |
| 2984 |
} |
| 2985 |
|
| 2986 |
var update_wp_id_display=func{ |
| 2987 |
var id=getprop("/autopilot/route-manager/wp[0]/id"); |
| 2988 |
if(size(id)>6){ |
| 2989 |
var type_wpt=substr(id,size(id)-6); |
| 2990 |
if(type_wpt=="WPTTWN"){#cities |
| 2991 |
id=substr(id,0,size(id)-8); |
| 2992 |
id=substr(id,0,13); |
| 2993 |
}elsif(type_wpt=="WPTUSR"){#wpt user |
| 2994 |
id=substr(id,0,size(id)-6); |
| 2995 |
} |
| 2996 |
} |
| 2997 |
setprop("/instrumentation/garmin196/panel-wpt-id",id); |
| 2998 |
setprop("/instrumentation/garmin196/position-wpt-id",id); |
| 2999 |
|
| 3000 |
##stockage des coordonnees pour la vnav |
| 3001 |
setprop("/instrumentation/gps/scratch/max-results",1); |
| 3002 |
setprop("/instrumentation/gps/scratch/longitude-deg",-9999); |
| 3003 |
setprop("/instrumentation/gps/scratch/latitude-deg",-9999); |
| 3004 |
setprop("/instrumentation/gps/scratch/type", ""); |
| 3005 |
setprop("/instrumentation/gps/scratch/query", id); |
| 3006 |
setprop("/instrumentation/gps/command", "search"); |
| 3007 |
|
| 3008 |
if(getprop("/instrumentation/gps/scratch/type")=="airport"){ |
| 3009 |
##stockage des coordonnees du waypoint pour vnav |
| 3010 |
props.globals.getNode("/instrumentation/garmin196/vnav/longitude",1).setDoubleValue(getprop("/instrumentation/gps/scratch/longitude-deg")); |
| 3011 |
props.globals.getNode("/instrumentation/garmin196/vnav/latitude",1).setDoubleValue(getprop("/instrumentation/gps/scratch/latitude-deg")); |
| 3012 |
props.globals.getNode("/instrumentation/garmin196/vnav/altitude-m",1).setDoubleValue(getprop("/instrumentation/gps/scratch/altitude-ft") * 0.3048); |
| 3013 |
props.globals.getNode("/instrumentation/garmin196/vnav/visible",1).setBoolValue(1); |
| 3014 |
}else{ |
| 3015 |
props.globals.getNode("/instrumentation/garmin196/vnav/visible",1).setBoolValue(0); |
| 3016 |
} |
| 3017 |
|
| 3018 |
} |
| 3019 |
setlistener("/autopilot/route-manager/wp[0]/id",update_wp_id_display); |
| 3020 |
|
| 3021 |
var init_list_aircraft = func{ |
| 3022 |
var aircrafts = props.globals.getNode("/instrumentation/garmin196/params/aircrafts",1); |
| 3023 |
var i = 0; |
| 3024 |
foreach (var e; aircrafts.getChildren("aircraft")) { |
| 3025 |
setprop("/instrumentation/garmin196/menu_aircraft/aircraft["~i~"]/texte",e.getChild("name").getValue()); |
| 3026 |
i=i+1; |
| 3027 |
} |
| 3028 |
|
| 3029 |
for(var j=i;j<6;j=j+1){ |
| 3030 |
setprop("/instrumentation/garmin196/menu_aircraft/aircraft["~j~"]/texte",""); |
| 3031 |
} |
| 3032 |
|
| 3033 |
if(i<6){ |
| 3034 |
setprop("/instrumentation/garmin196/menu_aircraft/aircraft["~i~"]/texte","ENTER TO ADD AIRCRAFT"); |
| 3035 |
}else{ |
| 3036 |
i=5; |
| 3037 |
} |
| 3038 |
setprop("/instrumentation/garmin196/menu_aircraft/max_no_ligne",i); |
| 3039 |
} |
| 3040 |
|
| 3041 |
var init_new_aircraft = func(no_aircraft){ |
| 3042 |
props.globals.getNode("/instrumentation/garmin196/params/aircrafts/aircraft["~no_aircraft~"]/name", 1).setValue("AIRCRAFT"); |
| 3043 |
props.globals.getNode("/instrumentation/garmin196/params/aircrafts/aircraft["~no_aircraft~"]/max-speed", 1).setIntValue(150); |
| 3044 |
props.globals.getNode("/instrumentation/garmin196/params/aircrafts/aircraft["~no_aircraft~"]/cruise-speed", 1).setIntValue(120); |
| 3045 |
props.globals.getNode("/instrumentation/garmin196/params/aircrafts/aircraft["~no_aircraft~"]/fuel-flow", 1).setIntValue(5); |
| 3046 |
} |
| 3047 |
|
| 3048 |
var delete_aircraft = func(no_aircraft){ |
| 3049 |
for(var i=no_aircraft+1;i<6;i=i+1){ |
| 3050 |
if(getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/name")!=nil){ |
| 3051 |
setprop("/instrumentation/garmin196/params/aircrafts/aircraft["~(i-1)~"]/name",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/name")); |
| 3052 |
setprop("/instrumentation/garmin196/params/aircrafts/aircraft["~(i-1)~"]/max-speed",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/max-speed")); |
| 3053 |
setprop("/instrumentation/garmin196/params/aircrafts/aircraft["~(i-1)~"]/cruise-speed",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/cruise-speed")); |
| 3054 |
setprop("/instrumentation/garmin196/params/aircrafts/aircraft["~(i-1)~"]/fuel-flow",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~i~"]/fuel-flow")); |
| 3055 |
} |
| 3056 |
} |
| 3057 |
var nb_aircraft = size(props.globals.getNode("/instrumentation/garmin196/params/aircrafts",1).getChildren("aircraft")); |
| 3058 |
if(getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_aircraft~"]/name")!=nil){ |
| 3059 |
props.globals.getNode("/instrumentation/garmin196/params/aircrafts/aircraft["~(nb_aircraft-1)~"]").remove(); |
| 3060 |
} |
| 3061 |
|
| 3062 |
setprop("/instrumentation/garmin196/no_aircraft",no_aircraft-1); |
| 3063 |
save_parameters(); |
| 3064 |
} |
| 3065 |
|
| 3066 |
var display_list_aircraft = func{ |
| 3067 |
var no_ligne = getprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected"); |
| 3068 |
if(no_ligne==-1){ |
| 3069 |
no_ligne = getprop("/instrumentation/garmin196/no_aircraft"); |
| 3070 |
} |
| 3071 |
var aircraft_display = ""; |
| 3072 |
if(getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/max-speed")!=nil){ |
| 3073 |
var max_speed = getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/max-speed"); |
| 3074 |
var name = getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/name"); |
| 3075 |
setprop("/instrumentation/garmin196/max-speed",max_speed); |
| 3076 |
setprop("/instrumentation/garmin196/cruise-speed",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/cruise-speed")); |
| 3077 |
setprop("/instrumentation/garmin196/fuel-flow",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/fuel-flow")); |
| 3078 |
setprop("/instrumentation/garmin196/no_aircraft",no_ligne); |
| 3079 |
|
| 3080 |
aircraft_display = name ~ " vmax="; |
| 3081 |
if(getprop("/instrumentation/garmin196/params/units/speed")==1){ |
| 3082 |
aircraft_display = aircraft_display ~ max_speed ~"kt"; |
| 3083 |
}else{ |
| 3084 |
aircraft_display = aircraft_display ~ sprintf("%3.0f",(max_speed*1.852)) ~"km/h"; |
| 3085 |
} |
| 3086 |
}else{ |
| 3087 |
aircraft_display = "NEW AIRCRAFT"; |
| 3088 |
} |
| 3089 |
setprop("/instrumentation/garmin196/menu_aircraft/text",aircraft_display); |
| 3090 |
} |
| 3091 |
|
| 3092 |
var init_menu_aircraft = func{ |
| 3093 |
var no_ligne = getprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected"); |
| 3094 |
|
| 3095 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-name",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/name")); |
| 3096 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-max",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/max-speed")); |
| 3097 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-cruise",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/cruise-speed")); |
| 3098 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow",getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/fuel-flow")); |
| 3099 |
|
| 3100 |
setprop("/instrumentation/garmin196/menu_aircraft/x_char",size(getprop("/instrumentation/garmin196/menu_aircraft/selected-name"))-1); |
| 3101 |
setprop("/instrumentation/garmin196/menu_aircraft/y_char",searchLastChar(getprop("/instrumentation/garmin196/menu_aircraft/selected-name"),getprop("/instrumentation/garmin196/menu_aircraft/x_char"))); |
| 3102 |
display_menu_aircraft(); |
| 3103 |
} |
| 3104 |
|
| 3105 |
var validate_menu_aircraft=func{ |
| 3106 |
var no_ligne = getprop("/instrumentation/garmin196/menu_aircraft/no_ligne_selected"); |
| 3107 |
|
| 3108 |
setprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/name",getprop("/instrumentation/garmin196/menu_aircraft/selected-name")); |
| 3109 |
setprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/max-speed",getprop("/instrumentation/garmin196/menu_aircraft/selected-max")); |
| 3110 |
setprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/cruise-speed",getprop("/instrumentation/garmin196/menu_aircraft/selected-cruise")); |
| 3111 |
setprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_ligne~"]/fuel-flow",getprop("/instrumentation/garmin196/menu_aircraft/selected-fuelflow")); |
| 3112 |
save_parameters(); |
| 3113 |
} |
| 3114 |
|
| 3115 |
var display_menu_aircraft=func{ |
| 3116 |
if(getprop("/instrumentation/garmin196/params/units/speed")==1){ |
| 3117 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-max-display",getprop("/instrumentation/garmin196/menu_aircraft/selected-max")~"kt"); |
| 3118 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-cruise-display",getprop("/instrumentation/garmin196/menu_aircraft/selected-cruise")~"kt"); |
| 3119 |
}else{ |
| 3120 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-max-display",sprintf("%3.0fkm/h",getprop("/instrumentation/garmin196/menu_aircraft/selected-max")*1.852)); |
| 3121 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-cruise-display",sprintf("%3.0fkm/h",getprop("/instrumentation/garmin196/menu_aircraft/selected-cruise")*1.852)); |
| 3122 |
} |
| 3123 |
} |
| 3124 |
|
| 3125 |
var display_menu_aircraft_name = func{ |
| 3126 |
var ligne_selected = getprop("/instrumentation/garmin196/menu_aircraft/selected-name"); |
| 3127 |
var x_char = props.globals.getNode("/instrumentation/garmin196/menu_aircraft/x_char").getValue(); |
| 3128 |
ligne_selected = substr(ligne_selected,0,x_char); |
| 3129 |
ligne_selected = ligne_selected ~ tab_chiffres_lettres[getprop("/instrumentation/garmin196/menu_aircraft/y_char")]; |
| 3130 |
setprop("/instrumentation/garmin196/menu_aircraft/selected-name",ligne_selected); |
| 3131 |
} |
| 3132 |
|
| 3133 |
var display_menu_flights = func{ |
| 3134 |
var flights = props.globals.getNode("/instrumentation/garmin196/flights",1); |
| 3135 |
var i = 0; |
| 3136 |
foreach (var e; flights.getChildren("flight")) { |
| 3137 |
var start = e.getChild("start").getValue(); |
| 3138 |
var end = e.getChild("end").getValue(); |
| 3139 |
var date = e.getChild("date").getValue(); |
| 3140 |
var aircraft = e.getChild("aircraft").getValue(); |
| 3141 |
var distance = e.getChild("distance").getValue(); |
| 3142 |
var duration = e.getChild("duration").getValue(); |
| 3143 |
|
| 3144 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 3145 |
distance = sprintf("%03.1fnm",distance); |
| 3146 |
}else{ |
| 3147 |
distance = sprintf("%03.1fkm",distance*1.852); |
| 3148 |
} |
| 3149 |
var ligne = sprintf("%s to %s %s",start,end,date); |
| 3150 |
|
| 3151 |
setprop("/instrumentation/garmin196/menu_flights/ligne["~i~"]/texte",ligne); |
| 3152 |
setprop("/instrumentation/garmin196/menu_flights/ligne["~i~"]/start",start); |
| 3153 |
setprop("/instrumentation/garmin196/menu_flights/ligne["~i~"]/end",end); |
| 3154 |
setprop("/instrumentation/garmin196/menu_flights/ligne["~i~"]/date",date); |
| 3155 |
setprop("/instrumentation/garmin196/menu_flights/ligne["~i~"]/aircraft",aircraft); |
| 3156 |
setprop("/instrumentation/garmin196/menu_flights/ligne["~i~"]/distance",distance); |
| 3157 |
setprop("/instrumentation/garmin196/menu_flights/ligne["~i~"]/duration",sprintf("%03.1fh",duration)); |
| 3158 |
|
| 3159 |
i=i+1; |
| 3160 |
} |
| 3161 |
for(var j=i;j<8;j=j+1){ |
| 3162 |
setprop("/instrumentation/garmin196/menu_flights/ligne["~j~"]/texte",""); |
| 3163 |
} |
| 3164 |
setprop("/instrumentation/garmin196/menu_flights/max_ligne_selected",i-1); |
| 3165 |
} |
| 3166 |
|
| 3167 |
var update_menu_flights_detail = func{ |
| 3168 |
var no_ligne = getprop("/instrumentation/garmin196/menu_flights/no_ligne_selected"); |
| 3169 |
setprop("/instrumentation/garmin196/menu_flights/ligne_selected/texte",getprop("/instrumentation/garmin196/menu_flights/ligne["~no_ligne~"]/start")~" to "~getprop("/instrumentation/garmin196/menu_flights/ligne["~no_ligne~"]/end")); |
| 3170 |
setprop("/instrumentation/garmin196/menu_flights/ligne_selected/date",getprop("/instrumentation/garmin196/menu_flights/ligne["~no_ligne~"]/date")); |
| 3171 |
setprop("/instrumentation/garmin196/menu_flights/ligne_selected/aircraft",getprop("/instrumentation/garmin196/menu_flights/ligne["~no_ligne~"]/aircraft")); |
| 3172 |
setprop("/instrumentation/garmin196/menu_flights/ligne_selected/distance",getprop("/instrumentation/garmin196/menu_flights/ligne["~no_ligne~"]/distance")); |
| 3173 |
setprop("/instrumentation/garmin196/menu_flights/ligne_selected/duration",getprop("/instrumentation/garmin196/menu_flights/ligne["~no_ligne~"]/duration")); |
| 3174 |
} |
| 3175 |
|
| 3176 |
var update_flight = func{ |
| 3177 |
if(getprop("/instrumentation/garmin196/flight/inflight")==nil){ |
| 3178 |
props.globals.getNode("/instrumentation/garmin196/flight/inflight",1).setBoolValue(0); |
| 3179 |
props.globals.getNode("/instrumentation/garmin196/flight/start",1).setValue(""); |
| 3180 |
} |
| 3181 |
|
| 3182 |
var inflight = getprop("/instrumentation/garmin196/flight/inflight"); |
| 3183 |
var speed = getprop("/instrumentation/gps/indicated-ground-speed-kt"); |
| 3184 |
if(inflight==1){ |
| 3185 |
if(speed<30){#speed<30kt, flight saved |
| 3186 |
|
| 3187 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(1); |
| 3188 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 3189 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 3190 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue("airport"); |
| 3191 |
setprop("/instrumentation/gps/command", "nearest"); |
| 3192 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 3193 |
props.globals.getNode("/instrumentation/garmin196/flight/end",1).setValue(id); |
| 3194 |
props.globals.getNode("/instrumentation/garmin196/flight/distance",1).setDoubleValue(getprop("/instrumentation/gps/trip-odometer")); |
| 3195 |
props.globals.getNode("/instrumentation/garmin196/flight/duration",1).setDoubleValue((getprop("/sim/time/elapsed-sec")-getprop("/instrumentation/garmin196/flight/start-time"))/3600); |
| 3196 |
setprop("/instrumentation/garmin196/flight/inflight",0); |
| 3197 |
|
| 3198 |
##inscription dans le carnet de vol |
| 3199 |
for(var i=7;i>0;i=i-1){ |
| 3200 |
if(getprop("/instrumentation/garmin196/flights/flight["~(i-1)~"]/start")!=nil){ |
| 3201 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/start",1).setValue(getprop("/instrumentation/garmin196/flights/flight["~(i-1)~"]/start")); |
| 3202 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/end",1).setValue(getprop("/instrumentation/garmin196/flights/flight["~(i-1)~"]/end")); |
| 3203 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/date",1).setValue(getprop("/instrumentation/garmin196/flights/flight["~(i-1)~"]/date")); |
| 3204 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/aircraft",1).setValue(getprop("/instrumentation/garmin196/flights/flight["~(i-1)~"]/aircraft")); |
| 3205 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/distance",1).setDoubleValue(getprop("/instrumentation/garmin196/flights/flight["~(i-1)~"]/distance")); |
| 3206 |
props.globals.getNode("/instrumentation/garmin196/flights/flight["~i~"]/duration",1).setDoubleValue(getprop("/instrumentation/garmin196/flights/flight["~(i-1)~"]/duration")); |
| 3207 |
} |
| 3208 |
} |
| 3209 |
props.globals.getNode("/instrumentation/garmin196/flights/flight[0]/start",1).setValue(getprop("/instrumentation/garmin196/flight/start")); |
| 3210 |
props.globals.getNode("/instrumentation/garmin196/flights/flight[0]/end",1).setValue(getprop("/instrumentation/garmin196/flight/end")); |
| 3211 |
props.globals.getNode("/instrumentation/garmin196/flights/flight[0]/date",1).setValue(getprop("/instrumentation/garmin196/flight/date")); |
| 3212 |
props.globals.getNode("/instrumentation/garmin196/flights/flight[0]/aircraft",1).setValue(getprop("/instrumentation/garmin196/flight/aircraft")); |
| 3213 |
props.globals.getNode("/instrumentation/garmin196/flights/flight[0]/distance",1).setDoubleValue(getprop("/instrumentation/garmin196/flight/distance")); |
| 3214 |
props.globals.getNode("/instrumentation/garmin196/flights/flight[0]/duration",1).setDoubleValue(getprop("/instrumentation/garmin196/flight/duration")); |
| 3215 |
display_menu_flights(); |
| 3216 |
save_parameters(); |
| 3217 |
} |
| 3218 |
}else{ |
| 3219 |
if(speed>30){#speed>30kt, flight started |
| 3220 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(1); |
| 3221 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 3222 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 3223 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue("airport"); |
| 3224 |
setprop("/instrumentation/gps/command", "nearest"); |
| 3225 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 3226 |
props.globals.getNode("/instrumentation/garmin196/flight/start",1).setValue(id); |
| 3227 |
var no_aircraft = getprop("/instrumentation/garmin196/no_aircraft"); |
| 3228 |
var aircraft = getprop("/instrumentation/garmin196/params/aircrafts/aircraft["~no_aircraft~"]/name"); |
| 3229 |
if(aircraft==nil){ |
| 3230 |
props.globals.getNode("/instrumentation/garmin196/flight/aircraft",1).setValue("NO AIRCRAFT"); |
| 3231 |
}else{ |
| 3232 |
props.globals.getNode("/instrumentation/garmin196/flight/aircraft",1).setValue(aircraft); |
| 3233 |
} |
| 3234 |
props.globals.getNode("/instrumentation/garmin196/flight/date",1).setValue(substr(getprop("/sim/time/gmt"),0,10)); |
| 3235 |
props.globals.getNode("/instrumentation/garmin196/flight/start-time",1).setDoubleValue(getprop("/sim/time/elapsed-sec")); |
| 3236 |
setprop("/instrumentation/gps/trip-odometer",0); |
| 3237 |
setprop("/instrumentation/garmin196/flight/inflight",1); |
| 3238 |
} |
| 3239 |
} |
| 3240 |
} |
| 3241 |
|
| 3242 |
var update_e6b_menu=func{ |
| 3243 |
var status = getprop("/instrumentation/garmin196/status"); |
| 3244 |
if(status==150){ |
| 3245 |
if(getprop("/instrumentation/garmin196/params/units/pressure")==1){ |
| 3246 |
setprop("/instrumentation/garmin196/menu_e6b/baro-pressure",sprintf("%2.2fInHg",getprop("/environment/pressure-sea-level-inhg"))); |
| 3247 |
}else{ |
| 3248 |
setprop("/instrumentation/garmin196/menu_e6b/baro-pressure",sprintf("%4.0fhPa",getprop("/environment/pressure-sea-level-inhg")/0.03)); |
| 3249 |
} |
| 3250 |
|
| 3251 |
var diff_speed = getprop("/instrumentation/gps/indicated-ground-speed-kt") - getprop("/velocities/airspeed-kt"); |
| 3252 |
if(getprop("/instrumentation/garmin196/params/units/speed")==1){ |
| 3253 |
setprop("/instrumentation/garmin196/menu_e6b/wind-speed",sprintf("%1.0fkt",getprop("/environment/wind-speed-kt"))); |
| 3254 |
setprop("/instrumentation/garmin196/menu_e6b/calibrated-airspeed",sprintf("%1.0fkt",getprop("/instrumentation/gps/indicated-ground-speed-kt"))); |
| 3255 |
setprop("/instrumentation/garmin196/menu_e6b/true-airspeed",sprintf("%1.0fkt",getprop("/velocities/airspeed-kt"))); |
| 3256 |
setprop("/instrumentation/garmin196/menu_e6b/head-wind",sprintf("%1.0fkt",diff_speed)); |
| 3257 |
}else{ |
| 3258 |
setprop("/instrumentation/garmin196/menu_e6b/wind-speed",sprintf("%1.0fkm/h",getprop("/environment/wind-speed-kt")*1.852)); |
| 3259 |
setprop("/instrumentation/garmin196/menu_e6b/calibrated-airspeed",sprintf("%1.0fkm/h",getprop("/instrumentation/gps/indicated-ground-speed-kt")*1.852)); |
| 3260 |
setprop("/instrumentation/garmin196/menu_e6b/true-airspeed",sprintf("%1.0fkm/h",getprop("/velocities/airspeed-kt")*1.852)); |
| 3261 |
setprop("/instrumentation/garmin196/menu_e6b/head-wind",sprintf("%1.0fkm/h",diff_speed*1.852)); |
| 3262 |
} |
| 3263 |
|
| 3264 |
if(getprop("/instrumentation/garmin196/params/units/altitude")==1){ |
| 3265 |
setprop("/instrumentation/garmin196/menu_e6b/indicated-altitude",sprintf("%1.0fft",getprop("/instrumentation/gps/indicated-altitude-ft"))); |
| 3266 |
setprop("/instrumentation/garmin196/menu_e6b/density-altitude",sprintf("%1.0fft",getprop("/position/altitude-ft"))); |
| 3267 |
}else{ |
| 3268 |
setprop("/instrumentation/garmin196/menu_e6b/indicated-altitude",sprintf("%1.0fm",getprop("/instrumentation/gps/indicated-altitude-ft")*0.1097)); |
| 3269 |
setprop("/instrumentation/garmin196/menu_e6b/density-altitude",sprintf("%1.0fm",getprop("/position/altitude-ft")*0.1097)); |
| 3270 |
} |
| 3271 |
|
| 3272 |
if(getprop("/instrumentation/garmin196/params/units/temperature")==1){ |
| 3273 |
setprop("/instrumentation/garmin196/menu_e6b/air-temp",sprintf("%1.1fC",getprop("/environment/temperature-degc"))); |
| 3274 |
}else{ |
| 3275 |
setprop("/instrumentation/garmin196/menu_e6b/air-temp",sprintf("%1.1fF",getprop("/environment/temperature-degf"))); |
| 3276 |
} |
| 3277 |
setprop("/instrumentation/garmin196/menu_e6b/wind-from",sprintf("%1.0f",getprop("/environment/wind-from-heading-deg"))); |
| 3278 |
setprop("/instrumentation/garmin196/menu_e6b/heading",sprintf("%1.0f",getprop("/orientation/heading-deg"))); |
| 3279 |
} |
| 3280 |
} |
| 3281 |
|
| 3282 |
var init_list_points = func{ |
| 3283 |
var points = props.globals.getNode("/instrumentation/garmin196/waypoints/user/",1); |
| 3284 |
var i = 0; |
| 3285 |
foreach (var e; points.getChildren("wpt")) { |
| 3286 |
setprop("/instrumentation/garmin196/menu_points/point["~i~"]/texte",e.getChild("id").getValue()); |
| 3287 |
i=i+1; |
| 3288 |
} |
| 3289 |
|
| 3290 |
for(var j=i;j<9;j=j+1){ |
| 3291 |
setprop("/instrumentation/garmin196/menu_points/point["~j~"]/texte",""); |
| 3292 |
} |
| 3293 |
|
| 3294 |
if(i<9){ |
| 3295 |
setprop("/instrumentation/garmin196/menu_points/point["~i~"]/texte","ENTER TO ADD WAYPOINT"); |
| 3296 |
}else{ |
| 3297 |
i=8; |
| 3298 |
} |
| 3299 |
setprop("/instrumentation/garmin196/menu_points/max_no_ligne",i); |
| 3300 |
} |
| 3301 |
|
| 3302 |
var init_new_point = func(no_point){ |
| 3303 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~no_point~"]/id", 1).setValue("POINT"); |
| 3304 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~no_point~"]/latitude", 1).setDoubleValue(getprop("/position/latitude-deg")); |
| 3305 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~no_point~"]/longitude", 1).setDoubleValue(getprop("/position/longitude-deg")); |
| 3306 |
} |
| 3307 |
|
| 3308 |
var delete_point = func(no_point){ |
| 3309 |
for(var i=no_point+1;i<9;i=i+1){ |
| 3310 |
if(getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/id")!=nil){ |
| 3311 |
setprop("/instrumentation/garmin196/waypoints/user/wpt["~(i-1)~"]/id",getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/id")); |
| 3312 |
setprop("/instrumentation/garmin196/waypoints/user/wpt["~(i-1)~"]/latitude",getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/latitude")); |
| 3313 |
setprop("/instrumentation/garmin196/waypoints/user/wpt["~(i-1)~"]/longitude",getprop("/instrumentation/garmin196/waypoints/user/wpt["~i~"]/longitude")); |
| 3314 |
} |
| 3315 |
} |
| 3316 |
var nb_points = size(props.globals.getNode("/instrumentation/garmin196/waypoints/user/",1).getChildren("wpt")); |
| 3317 |
if(getprop("/instrumentation/garmin196/waypoints/user/wpt["~no_point~"]/id")!=nil){ |
| 3318 |
props.globals.getNode("/instrumentation/garmin196/waypoints/user/wpt["~(nb_points-1)~"]").remove(); |
| 3319 |
} |
| 3320 |
save_parameters(); |
| 3321 |
} |
| 3322 |
|
| 3323 |
var update_menu_points = func{ |
| 3324 |
var no_ligne = getprop("/instrumentation/garmin196/menu_points/no_ligne_selected"); |
| 3325 |
var name = getprop("/instrumentation/garmin196/waypoints/user/wpt["~no_ligne~"]/id"); |
| 3326 |
var latitude = getprop("/instrumentation/garmin196/waypoints/user/wpt["~no_ligne~"]/latitude"); |
| 3327 |
var longitude = getprop("/instrumentation/garmin196/waypoints/user/wpt["~no_ligne~"]/longitude"); |
| 3328 |
|
| 3329 |
setprop("/instrumentation/garmin196/menu_points/name",name); |
| 3330 |
props.globals.getNode("/instrumentation/garmin196/menu_points/longitude", 1).setDoubleValue(longitude); |
| 3331 |
props.globals.getNode("/instrumentation/garmin196/menu_points/latitude", 1).setDoubleValue(latitude); |
| 3332 |
setprop("/instrumentation/garmin196/menu_points/x_char",size(getprop("/instrumentation/garmin196/menu_points/name"))-1); |
| 3333 |
setprop("/instrumentation/garmin196/menu_points/y_char",searchLastChar(getprop("/instrumentation/garmin196/menu_points/name"),getprop("/instrumentation/garmin196/menu_points/x_char"))); |
| 3334 |
display_menu_points(); |
| 3335 |
} |
| 3336 |
|
| 3337 |
var validate_menu_points = func{ |
| 3338 |
var no_ligne = getprop("/instrumentation/garmin196/menu_points/no_ligne_selected"); |
| 3339 |
|
| 3340 |
var id = getprop("/instrumentation/garmin196/menu_points/name"); |
| 3341 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 3342 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 3343 |
setprop("/instrumentation/garmin196/waypoints/user/wpt["~no_ligne~"]/id",id); |
| 3344 |
setprop("/instrumentation/garmin196/waypoints/user/wpt["~no_ligne~"]/latitude",latitude); |
| 3345 |
setprop("/instrumentation/garmin196/waypoints/user/wpt["~no_ligne~"]/longitude",longitude); |
| 3346 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(longitude); |
| 3347 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(latitude); |
| 3348 |
props.globals.getNode("/instrumentation/gps/scratch/ident",1).setValue(id~"WPTUSR"); |
| 3349 |
setprop("/instrumentation/gps/command","define-user-wpt"); |
| 3350 |
update_menu_points(); |
| 3351 |
save_parameters(); |
| 3352 |
} |
| 3353 |
|
| 3354 |
var display_menu_points = func{ |
| 3355 |
var ligne_selected = getprop("/instrumentation/garmin196/menu_points/name"); |
| 3356 |
var x_char = props.globals.getNode("/instrumentation/garmin196/menu_points/x_char").getValue(); |
| 3357 |
ligne_selected = substr(ligne_selected,0,x_char); |
| 3358 |
ligne_selected = ligne_selected ~ tab_chiffres_lettres[getprop("/instrumentation/garmin196/menu_points/y_char")]; |
| 3359 |
setprop("/instrumentation/garmin196/menu_points/name",ligne_selected); |
| 3360 |
|
| 3361 |
var latitude = getprop("/instrumentation/garmin196/menu_points/latitude"); |
| 3362 |
var latitude_tab = split(".",sprintf("%3.2f",math.abs(latitude))); |
| 3363 |
var latitude_text10 = latitude_tab[0]; |
| 3364 |
var latitude_text1 = "00"; |
| 3365 |
if(size(latitude_tab)>1){ |
| 3366 |
latitude_text1 = sprintf("%0.2s",latitude_tab[1]); |
| 3367 |
} |
| 3368 |
if(latitude>=0){ |
| 3369 |
latitude_text10 = "N" ~ latitude_text10; |
| 3370 |
}else{ |
| 3371 |
latitude_text10 = "S" ~ latitude_text10; |
| 3372 |
} |
| 3373 |
var longitude = getprop("/instrumentation/garmin196/menu_points/longitude"); |
| 3374 |
var longitude_tab = split(".",sprintf("%3.2f",math.abs(longitude))); |
| 3375 |
var longitude_text10 = longitude_tab[0]; |
| 3376 |
var longitude_text1 = "00"; |
| 3377 |
if(size(longitude_tab)>1){ |
| 3378 |
longitude_text1 = sprintf("%0.2s",longitude_tab[1]); |
| 3379 |
} |
| 3380 |
if(longitude>=0){ |
| 3381 |
longitude_text10 = "E" ~ longitude_text10; |
| 3382 |
}else{ |
| 3383 |
longitude_text10 = "W" ~ longitude_text10; |
| 3384 |
} |
| 3385 |
|
| 3386 |
setprop("/instrumentation/garmin196/menu_points/latitude10_text",latitude_text10); |
| 3387 |
setprop("/instrumentation/garmin196/menu_points/latitude1_text",latitude_text1); |
| 3388 |
setprop("/instrumentation/garmin196/menu_points/longitude10_text",longitude_text10); |
| 3389 |
setprop("/instrumentation/garmin196/menu_points/longitude1_text",longitude_text1); |
| 3390 |
} |
| 3391 |
|
| 3392 |
var init_menu_routes_list = func{ |
| 3393 |
var routes = props.globals.getNode("/instrumentation/garmin196/routes",1); |
| 3394 |
var i = 0; |
| 3395 |
foreach (var e; routes.getChildren("route")) { |
| 3396 |
setprop("/instrumentation/garmin196/menu_routes/route["~i~"]/texte",e.getChild("name").getValue()); |
| 3397 |
i=i+1; |
| 3398 |
} |
| 3399 |
|
| 3400 |
for(var j=i;j<11;j=j+1){ |
| 3401 |
setprop("/instrumentation/garmin196/menu_routes/route["~j~"]/texte",""); |
| 3402 |
} |
| 3403 |
|
| 3404 |
if(i<11){ |
| 3405 |
setprop("/instrumentation/garmin196/menu_routes/route["~i~"]/texte","ENTER TO ADD ROUTE"); |
| 3406 |
}else{ |
| 3407 |
i=10; |
| 3408 |
} |
| 3409 |
setprop("/instrumentation/garmin196/menu_routes/max_no_ligne",i); |
| 3410 |
} |
| 3411 |
|
| 3412 |
var init_new_route = func(no_ligne){ |
| 3413 |
setprop("/instrumentation/gps/scratch/max-results", 1); |
| 3414 |
setprop("/instrumentation/gps/scratch/longitude-deg",-9999); |
| 3415 |
setprop("/instrumentation/gps/scratch/latitude-deg",-9999); |
| 3416 |
setprop("/instrumentation/gps/scratch/type", "airport"); |
| 3417 |
setprop("/instrumentation/gps/command", "nearest"); |
| 3418 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 3419 |
|
| 3420 |
props.globals.getNode("/instrumentation/garmin196/routes/route["~no_ligne~"]/name",1).setValue(id~" to "~id); |
| 3421 |
props.globals.getNode("/instrumentation/garmin196/routes/route["~no_ligne~"]/wpts/wpt[0]/id",1).setValue(id); |
| 3422 |
props.globals.getNode("/instrumentation/garmin196/routes/route["~no_ligne~"]/wpts/wpt[0]/type",1).setValue("airport"); |
| 3423 |
} |
| 3424 |
|
| 3425 |
var update_menu_routes_detail = func{ |
| 3426 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 3427 |
|
| 3428 |
var points = props.globals.getNode("/instrumentation/garmin196/routes/route["~no_ligne~"]/wpts/",1); |
| 3429 |
var i = 0; |
| 3430 |
var last_longitude = 0; |
| 3431 |
var last_latitude = 0; |
| 3432 |
|
| 3433 |
var distance_total = 0; |
| 3434 |
var cruise_speed = getprop("/instrumentation/garmin196/cruise-speed"); |
| 3435 |
var conso_horaire = getprop("/instrumentation/garmin196/fuel-flow"); |
| 3436 |
|
| 3437 |
foreach (var e; points.getChildren("wpt")) { |
| 3438 |
var id = e.getChild("id").getValue(); |
| 3439 |
var type = e.getChild("type").getValue(); |
| 3440 |
var ligne = id; |
| 3441 |
if(substr(id,size(id)-6)=="WPTUSR"){ |
| 3442 |
ligne = substr(id,0,size(id)-6); |
| 3443 |
}elsif(substr(id,size(id)-6)=="WPTTWN"){ |
| 3444 |
ligne = substr(id,0,size(id)-8); |
| 3445 |
} |
| 3446 |
ligne = substr(ligne,0,8); |
| 3447 |
|
| 3448 |
if(i==0){ |
| 3449 |
setprop("/instrumentation/gps/scratch/max-results", 1); |
| 3450 |
setprop("/instrumentation/gps/scratch/exact", 0); |
| 3451 |
setprop("/instrumentation/gps/scratch/query", id); |
| 3452 |
setprop("/instrumentation/gps/scratch/type", type); |
| 3453 |
setprop("/instrumentation/gps/command", "search"); |
| 3454 |
last_longitude = getprop("/instrumentation/gps/scratch/longitude-deg"); |
| 3455 |
last_latitude = getprop("/instrumentation/gps/scratch/latitude-deg"); |
| 3456 |
}else{ |
| 3457 |
var ligne_spaces = " "; |
| 3458 |
ligne_spaces = substr(ligne_spaces,0,8-size(ligne)); |
| 3459 |
var coord_last_id = geo.Coord.new().set_latlon(last_latitude,last_longitude); |
| 3460 |
setprop("/instrumentation/gps/scratch/max-results", 1); |
| 3461 |
setprop("/instrumentation/gps/scratch/exact", 0); |
| 3462 |
setprop("/instrumentation/gps/scratch/query", id); |
| 3463 |
setprop("/instrumentation/gps/scratch/type", type); |
| 3464 |
setprop("/instrumentation/gps/command", "search"); |
| 3465 |
last_longitude = getprop("/instrumentation/gps/scratch/longitude-deg"); |
| 3466 |
last_latitude = getprop("/instrumentation/gps/scratch/latitude-deg"); |
| 3467 |
|
| 3468 |
var coord_id = geo.Coord.new().set_latlon(last_latitude,last_longitude); |
| 3469 |
var distance = coord_last_id.distance_to(coord_id) * 0.000539; |
| 3470 |
var bearing = coord_last_id.course_to(coord_id); |
| 3471 |
|
| 3472 |
var ete = distance / cruise_speed; |
| 3473 |
var ete_hours = int(ete); |
| 3474 |
var ete_minutes = int(ete*60-ete_hours*60); |
| 3475 |
var conso = ete * conso_horaire; |
| 3476 |
distance_total = distance_total + distance; |
| 3477 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 3478 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.0f %03.1f %02.0f:%02.0f %02.1f",bearing,distance,ete_hours,ete_minutes,conso); |
| 3479 |
}else{ |
| 3480 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.0f %03.1f %02.0f:%02.0f %02.1f",bearing,(distance*1.852),ete_hours,ete_minutes,conso); |
| 3481 |
} |
| 3482 |
} |
| 3483 |
setprop("/instrumentation/garmin196/menu_routes/point["~i~"]/texte",ligne); |
| 3484 |
i=i+1; |
| 3485 |
} |
| 3486 |
|
| 3487 |
var ete_total = distance_total / cruise_speed; |
| 3488 |
var ete_total_hours = int(ete_total); |
| 3489 |
var ete_total_minutes = int(ete_total*60-ete_total_hours*60); |
| 3490 |
var conso_total = ete_total * conso_horaire; |
| 3491 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 3492 |
setprop("/instrumentation/garmin196/menu_routes/total/texte",sprintf("%03.1f %02.0f:%02.0f %02.1f",distance_total,ete_total_hours,ete_total_minutes,conso_total)); |
| 3493 |
}else{ |
| 3494 |
setprop("/instrumentation/garmin196/menu_routes/total/texte",sprintf("%03.1f %02.0f:%02.0f %02.1f",(distance_total*1.852),ete_total_hours,ete_total_minutes,conso_total)); |
| 3495 |
} |
| 3496 |
|
| 3497 |
for(var j=i;j<10;j=j+1){ |
| 3498 |
setprop("/instrumentation/garmin196/menu_routes/point["~j~"]/texte",""); |
| 3499 |
} |
| 3500 |
if(i<10){ |
| 3501 |
setprop("/instrumentation/garmin196/menu_routes/point["~i~"]/texte","ENTER TO ADD WAYPOINT"); |
| 3502 |
}else{ |
| 3503 |
i=9; |
| 3504 |
} |
| 3505 |
setprop("/instrumentation/garmin196/menu_routes/max_no_ligne_detail",i); |
| 3506 |
} |
| 3507 |
|
| 3508 |
var init_search_route = func(start_string){ |
| 3509 |
if(substr(start_string,size(start_string)-6)=="WPTUSR"){ |
| 3510 |
start_string = substr(start_string,0,size(start_string)-6); |
| 3511 |
}elsif(substr(start_string,size(start_string)-6)=="WPTTWN"){ |
| 3512 |
start_string = substr(start_string,0,size(start_string)-8); |
| 3513 |
} |
| 3514 |
setprop("/instrumentation/garmin196/menu_routes/search/ligne_select",start_string); |
| 3515 |
setprop("/instrumentation/garmin196/menu_routes/search/x_char",size(start_string)-1); |
| 3516 |
setprop("/instrumentation/garmin196/menu_routes/search/y_char",searchLastChar(getprop("/instrumentation/garmin196/menu_routes/search/ligne_select"),getprop("/instrumentation/garmin196/menu_routes/search/x_char"))); |
| 3517 |
|
| 3518 |
display_route_waypoint_search(); |
| 3519 |
} |
| 3520 |
|
| 3521 |
var display_route_waypoint_search = func{ |
| 3522 |
var ligne_selected = getprop("/instrumentation/garmin196/menu_routes/search/ligne_select"); |
| 3523 |
var x_char = props.globals.getNode("/instrumentation/garmin196/menu_routes/search/x_char").getValue(); |
| 3524 |
ligne_selected = substr(ligne_selected,0,x_char); |
| 3525 |
ligne_selected = ligne_selected ~ tab_chiffres_lettres[getprop("/instrumentation/garmin196/menu_routes/search/y_char")]; |
| 3526 |
setprop("/instrumentation/garmin196/menu_routes/search/ligne_select",ligne_selected); |
| 3527 |
|
| 3528 |
var plots = []; |
| 3529 |
##recherche gps globale |
| 3530 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(5); |
| 3531 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 3532 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 3533 |
props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(0); |
| 3534 |
props.globals.getNode("/instrumentation/gps/scratch/query",1).setValue(ligne_selected); |
| 3535 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue(""); |
| 3536 |
|
| 3537 |
setprop("/instrumentation/gps/command", "search"); |
| 3538 |
var i=0; |
| 3539 |
var flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 3540 |
while (flag_continue and i<5) { |
| 3541 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 3542 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 3543 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 3544 |
var type = getprop("/instrumentation/gps/scratch/type"); |
| 3545 |
|
| 3546 |
var ligne = id; |
| 3547 |
if(type=="waypoint"){ |
| 3548 |
type = "wpt"; |
| 3549 |
var type_wpt = substr(id,size(id)-6); |
| 3550 |
if(type_wpt=="WPTTWN"){#cities |
| 3551 |
ligne = substr(id,0,size(id)-8); |
| 3552 |
}elsif(type_wpt=="WPTUSR"){#wpt user |
| 3553 |
ligne = substr(id,0,size(id)-6); |
| 3554 |
} |
| 3555 |
} |
| 3556 |
|
| 3557 |
ligne = ligne ~ " " ~ type; |
| 3558 |
var ligne_spaces = " "; |
| 3559 |
ligne_spaces = substr(ligne_spaces,0,16-size(ligne)); |
| 3560 |
|
| 3561 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 3562 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 3563 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 3564 |
}else{ |
| 3565 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 3566 |
} |
| 3567 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 3568 |
|
| 3569 |
|
| 3570 |
var plot = { id: id,texte: ligne,type: type}; |
| 3571 |
append(plots,plot); |
| 3572 |
|
| 3573 |
i=i+1; |
| 3574 |
setprop("/instrumentation/gps/command", "next"); |
| 3575 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 3576 |
} |
| 3577 |
|
| 3578 |
##recherche gps fix |
| 3579 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(5); |
| 3580 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 3581 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 3582 |
props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(0); |
| 3583 |
props.globals.getNode("/instrumentation/gps/scratch/query",1).setValue(ligne_selected); |
| 3584 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue("fix"); |
| 3585 |
|
| 3586 |
setprop("/instrumentation/gps/command", "search"); |
| 3587 |
i=0; |
| 3588 |
flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 3589 |
while (flag_continue and i<5) { |
| 3590 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 3591 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 3592 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 3593 |
var type = getprop("/instrumentation/gps/scratch/type"); |
| 3594 |
|
| 3595 |
var ligne = id ~ " " ~ type; |
| 3596 |
var ligne_spaces = " "; |
| 3597 |
ligne_spaces = substr(ligne_spaces,0,16-size(ligne)); |
| 3598 |
|
| 3599 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 3600 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 3601 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 3602 |
}else{ |
| 3603 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 3604 |
} |
| 3605 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 3606 |
|
| 3607 |
|
| 3608 |
var plot = { id: id,texte: ligne,type: type}; |
| 3609 |
append(plots,plot); |
| 3610 |
|
| 3611 |
i=i+1; |
| 3612 |
setprop("/instrumentation/gps/command", "next"); |
| 3613 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 3614 |
} |
| 3615 |
|
| 3616 |
##recherche gps vor |
| 3617 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(5); |
| 3618 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 3619 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 3620 |
props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(0); |
| 3621 |
props.globals.getNode("/instrumentation/gps/scratch/query",1).setValue(ligne_selected); |
| 3622 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue("vor"); |
| 3623 |
|
| 3624 |
setprop("/instrumentation/gps/command", "search"); |
| 3625 |
i=0; |
| 3626 |
flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 3627 |
while (flag_continue and i<5) { |
| 3628 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 3629 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 3630 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 3631 |
var type = getprop("/instrumentation/gps/scratch/type"); |
| 3632 |
|
| 3633 |
var ligne = id ~ " vor"; |
| 3634 |
var ligne_spaces = " "; |
| 3635 |
ligne_spaces = substr(ligne_spaces,0,16-size(ligne)); |
| 3636 |
|
| 3637 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 3638 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 3639 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 3640 |
}else{ |
| 3641 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 3642 |
} |
| 3643 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 3644 |
|
| 3645 |
|
| 3646 |
var plot = { id: id,texte: ligne,type: type}; |
| 3647 |
append(plots,plot); |
| 3648 |
|
| 3649 |
i=i+1; |
| 3650 |
setprop("/instrumentation/gps/command", "next"); |
| 3651 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 3652 |
} |
| 3653 |
|
| 3654 |
##recherche gps ndb |
| 3655 |
props.globals.getNode("/instrumentation/gps/scratch/max-results", 1).setIntValue(5); |
| 3656 |
props.globals.getNode("/instrumentation/gps/scratch/longitude-deg", 1).setDoubleValue(-9999); |
| 3657 |
props.globals.getNode("/instrumentation/gps/scratch/latitude-deg", 1).setDoubleValue(-9999); |
| 3658 |
props.globals.getNode("/instrumentation/gps/scratch/exact", 1).setBoolValue(0); |
| 3659 |
props.globals.getNode("/instrumentation/gps/scratch/query",1).setValue(ligne_selected); |
| 3660 |
props.globals.getNode("/instrumentation/gps/scratch/type",1).setValue("ndb"); |
| 3661 |
|
| 3662 |
setprop("/instrumentation/gps/command", "search"); |
| 3663 |
i=0; |
| 3664 |
flag_continue = getprop("/instrumentation/gps/scratch/valid"); |
| 3665 |
while (flag_continue and i<5) { |
| 3666 |
var id = getprop("/instrumentation/gps/scratch/ident"); |
| 3667 |
var range = getprop("/instrumentation/gps/scratch/distance-nm"); |
| 3668 |
var bearing = getprop("/instrumentation/gps/scratch/mag-bearing-deg"); |
| 3669 |
var type = getprop("/instrumentation/gps/scratch/type"); |
| 3670 |
|
| 3671 |
var ligne = id ~ " ndb"; |
| 3672 |
var ligne_spaces = " "; |
| 3673 |
ligne_spaces = substr(ligne_spaces,0,16-size(ligne)); |
| 3674 |
|
| 3675 |
ligne = ligne ~ ligne_spaces ~ sprintf(" %03.f",bearing); |
| 3676 |
if(getprop("/instrumentation/garmin196/params/units/distance")==1){ |
| 3677 |
ligne = ligne ~sprintf(" %3.1fnm",range); |
| 3678 |
}else{ |
| 3679 |
ligne = ligne ~sprintf(" %3.1fkm",range*1.852); |
| 3680 |
} |
| 3681 |
var popup_status = getprop("/instrumentation/garmin196/popup_status"); |
| 3682 |
|
| 3683 |
|
| 3684 |
var plot = { id: id,texte: ligne,type: type}; |
| 3685 |
append(plots,plot); |
| 3686 |
|
| 3687 |
i=i+1; |
| 3688 |
setprop("/instrumentation/gps/command", "next"); |
| 3689 |
flag_continue = getprop("/instrumentation/gps/scratch/has-next"); |
| 3690 |
} |
| 3691 |
|
| 3692 |
var plots_sorted = sort (plots, func (a,b) cmp (a.id, b.id)); |
| 3693 |
var nb_plots = size(plots_sorted); |
| 3694 |
if(nb_plots>9){ |
| 3695 |
nb_plots = 9; |
| 3696 |
} |
| 3697 |
for(var j=0;j<nb_plots;j=j+1){ |
| 3698 |
setprop("/instrumentation/garmin196/menu_routes/search/ligne["~j~"]/texte",plots_sorted[j].texte); |
| 3699 |
setprop("/instrumentation/garmin196/menu_routes/search/ligne["~j~"]/id",plots_sorted[j].id); |
| 3700 |
setprop("/instrumentation/garmin196/menu_routes/search/ligne["~j~"]/type",plots_sorted[j].type); |
| 3701 |
} |
| 3702 |
|
| 3703 |
for(var j=nb_plots;j<9;j=j+1){ |
| 3704 |
setprop("/instrumentation/garmin196/menu_routes/search/ligne["~j~"]/texte",""); |
| 3705 |
setprop("/instrumentation/garmin196/menu_routes/search/ligne["~j~"]/id",""); |
| 3706 |
setprop("/instrumentation/garmin196/menu_routes/search/ligne["~j~"]/type",""); |
| 3707 |
} |
| 3708 |
setprop("/instrumentation/garmin196/menu_routes/search/no_ligne_selected",-1); |
| 3709 |
setprop("/instrumentation/garmin196/menu_routes/search/max_ligne_selected",nb_plots-1); |
| 3710 |
} |
| 3711 |
|
| 3712 |
var delete_route = func(no_ligne){ |
| 3713 |
for(var i=no_ligne+1;i<11;i=i+1){ |
| 3714 |
if(getprop("/instrumentation/garmin196/routes/route["~i~"]/name")!=nil){ |
| 3715 |
setprop("/instrumentation/garmin196/routes/route["~(i-1)~"]/name",getprop("/instrumentation/garmin196/routes/route["~i~"]/name")); |
| 3716 |
for(var j=0;j<10;j=j+1){ |
| 3717 |
if(getprop("/instrumentation/garmin196/routes/route["~i~"]/wpts/wpt["~j~"]/id")!=nil){ |
| 3718 |
setprop("/instrumentation/garmin196/routes/route["~(i-1)~"]/wpts/wpt["~j~"]/id",getprop("/instrumentation/garmin196/routes/route["~i~"]/wpts/wpt["~j~"]/id")); |
| 3719 |
setprop("/instrumentation/garmin196/routes/route["~(i-1)~"]/wpts/wpt["~j~"]/type",getprop("/instrumentation/garmin196/routes/route["~i~"]/wpts/wpt["~j~"]/type")); |
| 3720 |
} |
| 3721 |
} |
| 3722 |
} |
| 3723 |
} |
| 3724 |
var nb_routes = size(props.globals.getNode("/instrumentation/garmin196/routes",1).getChildren("route")); |
| 3725 |
if(getprop("/instrumentation/garmin196/routes/route["~no_ligne~"]/name")!=nil){ |
| 3726 |
props.globals.getNode("/instrumentation/garmin196/routes/route["~(nb_routes-1)~"]").remove(); |
| 3727 |
} |
| 3728 |
|
| 3729 |
save_parameters(); |
| 3730 |
} |
| 3731 |
|
| 3732 |
var delete_route_detail = func(no_ligne_liste,no_ligne_detail){ |
| 3733 |
if(no_ligne_detail>0){ |
| 3734 |
for(var i=no_ligne_detail+1;i<10;i=i+1){ |
| 3735 |
if(getprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~i~"]/id")!=nil){ |
| 3736 |
setprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~(i-1)~"]/id",getprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~i~"]/id")); |
| 3737 |
setprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~(i-1)~"]/type",getprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~i~"]/type")); |
| 3738 |
} |
| 3739 |
} |
| 3740 |
|
| 3741 |
var nb_waypoints = size(props.globals.getNode("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts",1).getChildren("wpt")); |
| 3742 |
if(getprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~no_ligne_detail~"]/id")!=nil){ |
| 3743 |
props.globals.getNode("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~(nb_waypoints-1)~"]").remove(); |
| 3744 |
} |
| 3745 |
save_parameters(); |
| 3746 |
} |
| 3747 |
} |
| 3748 |
|
| 3749 |
var validate_menu_search_routes = func{ |
| 3750 |
var no_ligne = getprop("/instrumentation/garmin196/menu_routes/search/no_ligne_selected"); |
| 3751 |
var id = getprop("/instrumentation/garmin196/menu_routes/search/ligne["~no_ligne~"]/id"); |
| 3752 |
var type = getprop("/instrumentation/garmin196/menu_routes/search/ligne["~no_ligne~"]/type"); |
| 3753 |
var no_ligne_liste = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 3754 |
var no_ligne_detail = getprop("/instrumentation/garmin196/menu_routes/no_ligne_detail"); |
| 3755 |
setprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~no_ligne_detail~"]/id",id); |
| 3756 |
setprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~no_ligne_detail~"]/type",type); |
| 3757 |
|
| 3758 |
var name_wpt0 = getprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt[0]/id"); |
| 3759 |
if(substr(name_wpt0,size(name_wpt0)-6)=="WPTUSR"){ |
| 3760 |
name_wpt0 = substr(name_wpt0,0,size(name_wpt0)-6); |
| 3761 |
}elsif(substr(name_wpt0,size(name_wpt0)-6)=="WPTTWN"){ |
| 3762 |
name_wpt0 = substr(name_wpt0,0,size(name_wpt0)-8); |
| 3763 |
} |
| 3764 |
var name_wpt1 = name_wpt0; |
| 3765 |
var nb_points = size(props.globals.getNode("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts").getChildren("wpt")); |
| 3766 |
if(nb_points>1){ |
| 3767 |
name_wpt1 = getprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/wpts/wpt["~(nb_points-1)~"]/id"); |
| 3768 |
if(substr(name_wpt1,size(name_wpt1)-6)=="WPTUSR"){ |
| 3769 |
name_wpt1 = substr(name_wpt1,0,size(name_wpt1)-6); |
| 3770 |
}elsif(substr(name_wpt1,size(name_wpt1)-6)=="WPTTWN"){ |
| 3771 |
name_wpt1 = substr(name_wpt1,0,size(name_wpt1)-8); |
| 3772 |
} |
| 3773 |
} |
| 3774 |
|
| 3775 |
var name = name_wpt0 ~ " to " ~ name_wpt1; |
| 3776 |
setprop("/instrumentation/garmin196/routes/route["~no_ligne_liste~"]/name",name); |
| 3777 |
} |
| 3778 |
|
| 3779 |
var load_flight_plan = func(no_ligne){ |
| 3780 |
setprop("/autopilot/route-manager/input","@CLEAR"); |
| 3781 |
setprop("/autopilot/route-manager/input","@POP"); |
| 3782 |
var points = props.globals.getNode("/instrumentation/garmin196/routes/route["~no_ligne~"]/wpts/",1); |
| 3783 |
foreach (var e; points.getChildren("wpt")) { |
| 3784 |
var id = e.getChild("id").getValue(); |
| 3785 |
setprop("/autopilot/route-manager/input",id); |
| 3786 |
} |
| 3787 |
setprop("/autopilot/route-manager/input","@JUMP0"); |
| 3788 |
setprop("/autopilot/route-manager/input","@ACTIVATE"); |
| 3789 |
} |
| 3790 |
|
| 3791 |
var close_fpl_loaded = func{ |
| 3792 |
setprop("/instrumentation/garmin196/menu_routes/fpl-loaded",0); |
| 3793 |
} |
| 3794 |
var affiche_fpl_loaded = func{ |
| 3795 |
setprop("/instrumentation/garmin196/menu_routes/fpl-loaded",1); |
| 3796 |
settimer(close_fpl_loaded,3); |
| 3797 |
} |
| 3798 |
|
| 3799 |
var close_waypoint_jump = func{ |
| 3800 |
setprop("/instrumentation/garmin196/menu_routes/waypoint-jump",0); |
| 3801 |
} |
| 3802 |
var affiche_waypoint_jump = func{ |
| 3803 |
setprop("/instrumentation/garmin196/menu_routes/waypoint-jump",1); |
| 3804 |
settimer(close_waypoint_jump,3); |
| 3805 |
} |
| 3806 |
|
| 3807 |
var jump_to_waypoint = func(no_ligne){ |
| 3808 |
var no_ligne_liste = getprop("/instrumentation/garmin196/menu_routes/no_ligne_selected"); |
| 3809 |
load_flight_plan(no_ligne_liste); |
| 3810 |
setprop("/autopilot/route-manager/input","@JUMP"~no_ligne); |
| 3811 |
} |