| 1 |
# ============================================================================== |
| 2 |
# Boeing Navigation Display by Gijs de Rooy |
| 3 |
# See: http://wiki.flightgear.org/Canvas_ND_Framework |
| 4 |
# ============================================================================== |
| 5 |
# This file makes use of the MapStructure framework, see: http://wiki.flightgear.org/Canvas_MapStructure |
| 6 |
# |
| 7 |
# Sooner or later, some parts will be revamped by coming up with a simple animation framework: http://wiki.flightgear.org/NavDisplay#mapping_vs._SVG_animation |
| 8 |
|
| 9 |
## |
| 10 |
# pseudo DSL-ish: use these as placeholders in the config hash below |
| 11 |
var ALWAYS = func 1; |
| 12 |
var NOTHING = func nil; |
| 13 |
|
| 14 |
## |
| 15 |
# TODO: move ND-specific implementation details into this lookup hash |
| 16 |
# so that other aircraft and ND types can be more easily supported |
| 17 |
# |
| 18 |
# any aircraft-specific ND behavior should be wrapped here, |
| 19 |
# to isolate/decouple things in the generic NavDisplay class |
| 20 |
# |
| 21 |
# TODO: move this to an XML config file (maybe supporting SGCondition and/or SGStateMachine markup for the logic?) |
| 22 |
# |
| 23 |
var NDStyles = { |
| 24 |
## |
| 25 |
# this configures the 744 ND to help generalize the NavDisplay class itself |
| 26 |
'Boeing': { |
| 27 |
font_mapper: func(family, weight) { |
| 28 |
if( family == "Liberation Sans" and weight == "normal" ) |
| 29 |
return "LiberationFonts/LiberationSans-Regular.ttf"; |
| 30 |
}, |
| 31 |
|
| 32 |
# where all the symbols are stored |
| 33 |
# TODO: SVG elements should be renamed to use boeing/airbus prefix |
| 34 |
# aircraft developers should all be editing the same ND.svg image |
| 35 |
# the code can deal with the differences now |
| 36 |
svg_filename: "Nasal/canvas/map/Images/boeingND.svg", |
| 37 |
|
| 38 |
initialize_elements: func(me) { |
| 39 |
|
| 40 |
### this is the "old" method that's less flexible, we want to use the style hash instead (see above) |
| 41 |
# because things are much better configurable that way |
| 42 |
# now look up all required SVG elements and initialize member fields using the same name to have a convenient handle |
| 43 |
foreach(var element; ["dmeLDist","dmeRDist","dmeL","dmeR","vorL","vorR","vorLId","vorRId", |
| 44 |
"status.wxr","status.wpt","status.sta","status.arpt"]) |
| 45 |
me.symbols[element] = me.nd.getElementById(element); |
| 46 |
|
| 47 |
# load elements from vector image, and create instance variables using identical names, and call updateCenter() on each |
| 48 |
# anything that needs updatecenter called, should be added to the vector here |
| 49 |
# |
| 50 |
foreach(var element; ["staArrowL2","staArrowR2","staFromL2","staToL2","staFromR2","staToR2", |
| 51 |
"hdgTrk","trkInd","hdgBug","HdgBugCRT","TrkBugLCD","HdgBugLCD","curHdgPtr", |
| 52 |
"HdgBugCRT2","TrkBugLCD2","HdgBugLCD2","hdgBug2","selHdgLine","selHdgLine2","curHdgPtr2", |
| 53 |
"staArrowL","staArrowR","staToL","staFromL","staToR","staFromR"] ) |
| 54 |
me.symbols[element] = me.nd.getElementById(element).updateCenter(); |
| 55 |
|
| 56 |
}, # initialize_elements |
| 57 |
|
| 58 |
## |
| 59 |
## this loads and configures existing layers (currently, *.layer files in Nasal/canvas/map) |
| 60 |
## |
| 61 |
|
| 62 |
|
| 63 |
# TODO: phase out isMapStructure flag once map.nas & *.draw files are killed |
| 64 |
layers: [ |
| 65 |
# TODO: take z-indices from *.draw files -- now handled by MapStructure in the addLayer method. |
| 66 |
{ |
| 67 |
name:'WXR_live', |
| 68 |
isMapStructure:1, |
| 69 |
always_update: 1, |
| 70 |
update_on:[ 'toggle_range','toggle_weather','toggle_display_mode','toggle_weather_live'], |
| 71 |
predicate: func(nd, layer) { |
| 72 |
var visible = nd.get_switch('toggle_weather') and |
| 73 |
nd.get_switch('toggle_weather_live') and |
| 74 |
nd.get_switch('toggle_display_mode') != "PLAN"; |
| 75 |
layer.group.setVisible(visible); |
| 76 |
if (visible) { |
| 77 |
layer.update(); |
| 78 |
} |
| 79 |
}, # end of layer update predicate |
| 80 |
'z-index': -100, |
| 81 |
}, |
| 82 |
{ name:'FIX', isMapStructure:1, update_on:['toggle_display_mode','toggle_waypoints'], |
| 83 |
# FIXME: this is a really ugly place for controller code |
| 84 |
predicate: func(nd, layer) { |
| 85 |
# print("Running fix layer predicate"); |
| 86 |
# toggle visibility here |
| 87 |
var visible=nd.get_switch('toggle_waypoints') and nd.in_mode('toggle_display_mode', ['MAP']) and (nd.rangeNm() <= 40); |
| 88 |
layer.group.setVisible( visible ); |
| 89 |
if (visible) { |
| 90 |
#print("Updating MapStructure ND layer: FIX"); |
| 91 |
# (Hopefully) smart update |
| 92 |
layer.update(); |
| 93 |
} |
| 94 |
}, # end of layer update predicate |
| 95 |
options: { |
| 96 |
range_dependant: 1 |
| 97 |
}, |
| 98 |
'z-index': -3, |
| 99 |
}, # end of FIX layer |
| 100 |
|
| 101 |
# Should redraw every 10 seconds TODO: use new MapStructure/WXR here once that works properly (Gijs should check first!) |
| 102 |
{ |
| 103 |
name:'WXR', |
| 104 |
isMapStructure:1, |
| 105 |
update_on:[ {rate_hz: 0.1}, 'toggle_range','toggle_weather','toggle_display_mode', 'toggle_weather_live'], |
| 106 |
predicate: func(nd, layer) { |
| 107 |
#print("Running storms predicate"); |
| 108 |
var visible=nd.get_switch('toggle_weather') and |
| 109 |
!nd.get_switch('toggle_weather_live') and |
| 110 |
nd.get_switch('toggle_display_mode') != "PLAN"; |
| 111 |
layer.group.setVisible(visible); |
| 112 |
if (visible) { |
| 113 |
print("storms update requested! (timer issue when closing the dialog?)"); |
| 114 |
layer.update(); |
| 115 |
} |
| 116 |
}, # end of layer update predicate |
| 117 |
'z-index': -4, |
| 118 |
}, # end of storms/WXR layer |
| 119 |
|
| 120 |
{ name:'APS', isMapStructure:1, always_update: 1, update_on:['toggle_display_mode'], |
| 121 |
predicate: func(nd, layer) { |
| 122 |
var visible = nd.get_switch('toggle_display_mode') == "PLAN"; |
| 123 |
layer.group.setVisible( visible ); |
| 124 |
if (visible) { |
| 125 |
layer.update(); |
| 126 |
} |
| 127 |
}, |
| 128 |
}, |
| 129 |
|
| 130 |
{ name:'APT', isMapStructure:1, update_on:['toggle_airports','toggle_display_mode'], |
| 131 |
predicate: func(nd, layer) { |
| 132 |
# toggle visibility here |
| 133 |
var visible=nd.get_switch('toggle_airports') and nd.in_mode('toggle_display_mode', ['MAP']); |
| 134 |
layer.group.setVisible( visible ); |
| 135 |
if (visible) { |
| 136 |
#print("Updating MapStructure ND layer: APT"); |
| 137 |
layer.update(); |
| 138 |
} |
| 139 |
}, # end of layer update predicate |
| 140 |
options: { |
| 141 |
range_dependant: 1 |
| 142 |
}, |
| 143 |
'z-index': -1, |
| 144 |
}, # end of APT layer |
| 145 |
|
| 146 |
# Should distinct between low and high altitude navaids. Hiding above 40 NM for now, to prevent clutter/lag. |
| 147 |
{ name:'VOR', isMapStructure:1, update_on:['toggle_stations','toggle_display_mode'], |
| 148 |
# FIXME: this is a really ugly place for controller code |
| 149 |
predicate: func(nd, layer) { |
| 150 |
# toggle visibility here |
| 151 |
var visible = nd.get_switch('toggle_stations') and nd.in_mode('toggle_display_mode', ['MAP']) and (nd.rangeNm() <= 40); |
| 152 |
layer.group.setVisible( visible ); |
| 153 |
if (visible) { |
| 154 |
#print("Updating MapStructure ND layer: VOR"); |
| 155 |
layer.update(); |
| 156 |
} |
| 157 |
}, # end of layer update predicate |
| 158 |
options: { |
| 159 |
range_dependant: 1 |
| 160 |
}, |
| 161 |
'z-index': -2, |
| 162 |
}, # end of VOR layer |
| 163 |
|
| 164 |
{ name:'DME', isMapStructure:1, update_on:['toggle_display_mode','toggle_stations'], |
| 165 |
# FIXME: this is a really ugly place for controller code |
| 166 |
predicate: func(nd, layer) { |
| 167 |
var visible = nd.get_switch('toggle_stations') and nd.in_mode('toggle_display_mode', ['MAP']) and (nd.rangeNm() <= 40); |
| 168 |
# toggle visibility here |
| 169 |
layer.group.setVisible( visible ); |
| 170 |
if (visible) { |
| 171 |
#print("Updating MapStructure ND layer: DME"); |
| 172 |
layer.update(); |
| 173 |
} |
| 174 |
}, # end of layer update predicate |
| 175 |
options: { |
| 176 |
range_dependant: 1 |
| 177 |
}, |
| 178 |
'z-index': -2, |
| 179 |
}, # end of DME layer |
| 180 |
|
| 181 |
{ name:'TFC', isMapStructure:1, always_update: 1, update_on:['toggle_range','toggle_traffic'], |
| 182 |
predicate: func(nd, layer) { |
| 183 |
var visible = nd.get_switch('toggle_traffic'); |
| 184 |
layer.group.setVisible( visible ); |
| 185 |
if (visible) { |
| 186 |
#print("Updating MapStructure ND layer: TFC"); |
| 187 |
layer.update(); |
| 188 |
} |
| 189 |
}, # end of layer update predicate |
| 190 |
'z-index': 4, |
| 191 |
}, # end of traffic layer |
| 192 |
|
| 193 |
{ name:'runway-nd', update_on:['toggle_range','toggle_display_mode'], |
| 194 |
predicate: func(nd, layer) { |
| 195 |
#print("runway-nd wants to be ported to MapStructure"); |
| 196 |
var visible = (nd.rangeNm() <= 40) and getprop("autopilot/route-manager/active") and nd.in_mode('toggle_display_mode', ['MAP','PLAN']) ; |
| 197 |
if (visible) |
| 198 |
layer._model.init(); # clear & redraw |
| 199 |
layer._view.setVisible( visible ); |
| 200 |
}, # end of layer update predicate |
| 201 |
}, # end of airports-nd layer |
| 202 |
|
| 203 |
{ name:'RTE', isMapStructure:1, update_on:['toggle_range','toggle_display_mode'], |
| 204 |
predicate: func(nd, layer) { |
| 205 |
var visible= (nd.in_mode('toggle_display_mode', ['MAP','PLAN'])); |
| 206 |
layer.group.setVisible( visible ); |
| 207 |
if (visible) |
| 208 |
layer.update(); |
| 209 |
}, # end of layer update predicate |
| 210 |
'z-index': 1, |
| 211 |
}, # end of route layer |
| 212 |
{ name:'WPT', isMapStructure:1, update_on:['toggle_range','toggle_display_mode'], |
| 213 |
predicate: func(nd, layer) { |
| 214 |
var visible= (nd.in_mode('toggle_display_mode', ['MAP','PLAN'])); |
| 215 |
layer.group.setVisible( visible ); |
| 216 |
|
| 217 |
if (visible) |
| 218 |
layer.update(); |
| 219 |
}, # end of layer update predicate |
| 220 |
'z-index': 2, |
| 221 |
}, # end of waypoint layer |
| 222 |
{ name:'ALT-profile', isMapStructure:1, update_on:['toggle_range','toggle_display_mode'], |
| 223 |
predicate: func(nd, layer) { |
| 224 |
var visible= (nd.in_mode('toggle_display_mode', ['MAP','PLAN'])); |
| 225 |
layer.group.setVisible( visible ); |
| 226 |
|
| 227 |
if (visible) |
| 228 |
layer.update(); |
| 229 |
}, # end of layer update predicate |
| 230 |
'z-index': 3, |
| 231 |
}, # end of altitude profile layer |
| 232 |
|
| 233 |
## add other layers here, layer names must match the registered names as used in *.layer files for now |
| 234 |
## this will all change once we're using Philosopher's MapStructure framework |
| 235 |
|
| 236 |
], # end of vector with configured layers |
| 237 |
|
| 238 |
# This is where SVG elements are configured by providing "behavior" hashes, i.e. for animations |
| 239 |
|
| 240 |
# to animate each SVG symbol, specify behavior via callbacks (predicate, and true/false implementation) |
| 241 |
# SVG identifier, callback etc |
| 242 |
# TODO: update_on([]), update_mode (update() vs. timers/listeners) |
| 243 |
# TODO: support putting symbols on specific layers |
| 244 |
features: [ |
| 245 |
{ |
| 246 |
# TODO: taOnly doesn't need to use getprop polling in update(), use a listener instead! |
| 247 |
id: 'taOnly', # the SVG ID |
| 248 |
impl: { # implementation hash |
| 249 |
init: func(nd, symbol), # for updateCenter stuff, called during initialization in the ctor |
| 250 |
predicate: func(nd) getprop("instrumentation/tcas/inputs/mode") == 2, # the condition |
| 251 |
is_true: func(nd) nd.symbols.taOnly.show(), |
| 252 |
is_false: func(nd) nd.symbols.taOnly.hide(), |
| 253 |
}, # end of taOnly behavior/callbacks |
| 254 |
}, |
| 255 |
{ |
| 256 |
id: 'tcasOff', |
| 257 |
impl: { |
| 258 |
init: func(nd, symbol), |
| 259 |
predicate: func(nd) getprop("instrumentation/tcas/inputs/mode") == 0 and nd.get_switch('toggle_traffic') and (nd.in_mode('toggle_display_mode', ['MAP']) or (nd.in_mode('toggle_display_mode', ['APP','VOR']) and !nd.get_switch('toggle_centered'))), |
| 260 |
is_true: func(nd) nd.symbols.tcasOff.show(), |
| 261 |
is_false: func(nd) nd.symbols.tcasOff.hide(), |
| 262 |
}, |
| 263 |
}, |
| 264 |
{ |
| 265 |
id: 'tcasFail', |
| 266 |
impl: { |
| 267 |
init: func(nd, symbol), |
| 268 |
predicate: func(nd) getprop("instrumentation/tcas/inputs/mode") != 0 and getprop("instrumentation/tcas/serviceable") != 1 and nd.get_switch('toggle_traffic') and (nd.in_mode('toggle_display_mode', ['MAP']) or (nd.in_mode('toggle_display_mode', ['APP','VOR']) and !nd.get_switch('toggle_centered'))), |
| 269 |
is_true: func(nd) nd.symbols.tcasFail.show(), |
| 270 |
is_false: func(nd) nd.symbols.tcasFail.hide(), |
| 271 |
}, |
| 272 |
}, |
| 273 |
{ |
| 274 |
id: 'tcasTest', |
| 275 |
impl: { |
| 276 |
init: func(nd, symbol), |
| 277 |
predicate: func(nd) getprop("instrumentation/tcas/inputs/self-test") == 1 and getprop("instrumentation/tcas/serviceable") == 1, |
| 278 |
is_true: func(nd) nd.symbols.tcasTest.show(), |
| 279 |
is_false: func(nd) nd.symbols.tcasTest.hide(), |
| 280 |
}, |
| 281 |
}, |
| 282 |
{ |
| 283 |
id: 'tfc', |
| 284 |
impl: { |
| 285 |
init: func(nd, symbol), |
| 286 |
predicate: func(nd) getprop("instrumentation/tcas/inputs/mode") != 0 and nd.get_switch('toggle_traffic') and (nd.in_mode('toggle_display_mode', ['MAP']) or (nd.in_mode('toggle_display_mode', ['APP','VOR']) and !nd.get_switch('toggle_centered'))), |
| 287 |
is_true: func(nd) nd.symbols.tfc.show(), |
| 288 |
is_false: func(nd) nd.symbols.tfc.hide(), |
| 289 |
}, |
| 290 |
}, |
| 291 |
{ |
| 292 |
id: 'traffic', |
| 293 |
impl: { |
| 294 |
init: func(nd, symbol), |
| 295 |
predicate: func(nd) getprop("instrumentation/tcas/outputs/traffic-alert") != 0 or getprop("instrumentation/tcas/outputs/advisory-alert"), |
| 296 |
is_true: func(nd) { |
| 297 |
nd.symbols.traffic.show(); |
| 298 |
if (getprop("instrumentation/tcas/outputs/traffic-alert")) |
| 299 |
nd.symbols.traffic.setColor(1,0,0); |
| 300 |
else |
| 301 |
nd.symbols.traffic.setColor(1,0.5,0); |
| 302 |
}, |
| 303 |
is_false: func(nd) nd.symbols.traffic.hide(), |
| 304 |
}, |
| 305 |
}, |
| 306 |
{ |
| 307 |
id: 'tas', |
| 308 |
impl: { |
| 309 |
init: func(nd,symbol), |
| 310 |
predicate: func(nd) nd.aircraft_source.get_spd() > 100, |
| 311 |
is_true: func(nd) { |
| 312 |
nd.symbols.tas.setText(sprintf("%3.0f",nd.aircraft_source.get_spd() )); |
| 313 |
nd.symbols.tas.show(); |
| 314 |
}, |
| 315 |
is_false: func(nd) nd.symbols.tas.hide(), |
| 316 |
}, |
| 317 |
}, |
| 318 |
{ |
| 319 |
id: 'tasLbl', |
| 320 |
impl: { |
| 321 |
init: func(nd,symbol), |
| 322 |
predicate: func(nd) nd.aircraft_source.get_spd() > 100, |
| 323 |
is_true: func(nd) nd.symbols.tasLbl.show(), |
| 324 |
is_false: func(nd) nd.symbols.tasLbl.hide(), |
| 325 |
}, |
| 326 |
}, |
| 327 |
{ |
| 328 |
id: 'ilsFreq', |
| 329 |
impl: { |
| 330 |
init: func(nd,symbol), |
| 331 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP']), |
| 332 |
is_true: func(nd) { |
| 333 |
nd.symbols.ilsFreq.show(); |
| 334 |
if(getprop("instrumentation/nav/in-range")) |
| 335 |
nd.symbols.ilsFreq.setText(getprop("instrumentation/nav/nav-id")); |
| 336 |
else |
| 337 |
nd.symbols.ilsFreq.setText(getprop("instrumentation/nav/frequencies/selected-mhz-fmt")); |
| 338 |
}, |
| 339 |
is_false: func(nd) nd.symbols.ilsFreq.hide(), |
| 340 |
}, |
| 341 |
}, |
| 342 |
{ |
| 343 |
id: 'ilsLbl', |
| 344 |
impl: { |
| 345 |
init: func(nd,symbol), |
| 346 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP']), |
| 347 |
is_true: func(nd) { |
| 348 |
nd.symbols.ilsLbl.show(); |
| 349 |
}, |
| 350 |
is_false: func(nd) nd.symbols.ilsLbl.hide(), |
| 351 |
}, |
| 352 |
}, |
| 353 |
{ |
| 354 |
id: 'wpActiveId', |
| 355 |
impl: { |
| 356 |
init: func(nd,symbol), |
| 357 |
predicate: func(nd) getprop("/autopilot/route-manager/wp/id") != nil and getprop("autopilot/route-manager/active") |
| 358 |
and nd.in_mode('toggle_display_mode', ['MAP','PLAN']), |
| 359 |
is_true: func(nd) { |
| 360 |
nd.symbols.wpActiveId.setText(getprop("/autopilot/route-manager/wp/id")); |
| 361 |
nd.symbols.wpActiveId.show(); |
| 362 |
}, |
| 363 |
is_false: func(nd) nd.symbols.wpActiveId.hide(), |
| 364 |
}, # of wpActiveId.impl |
| 365 |
}, # of wpActiveId |
| 366 |
{ |
| 367 |
id: 'wpActiveDist', |
| 368 |
impl: { |
| 369 |
init: func(nd,symbol), |
| 370 |
predicate: func(nd) getprop("/autopilot/route-manager/wp/dist") != nil and getprop("autopilot/route-manager/active") |
| 371 |
and nd.in_mode('toggle_display_mode', ['MAP','PLAN']), |
| 372 |
is_true: func(nd) { |
| 373 |
nd.symbols.wpActiveDist.setText(sprintf("%3.01f",getprop("/autopilot/route-manager/wp/dist"))); |
| 374 |
nd.symbols.wpActiveDist.show(); |
| 375 |
}, |
| 376 |
is_false: func(nd) nd.symbols.wpActiveDist.hide(), |
| 377 |
}, |
| 378 |
}, |
| 379 |
{ |
| 380 |
id: 'wpActiveDistLbl', |
| 381 |
impl: { |
| 382 |
init: func(nd,symbol), |
| 383 |
predicate: func(nd) getprop("/autopilot/route-manager/wp/dist") != nil and getprop("autopilot/route-manager/active") |
| 384 |
and nd.in_mode('toggle_display_mode', ['MAP','PLAN']), |
| 385 |
is_true: func(nd) { |
| 386 |
nd.symbols.wpActiveDistLbl.show(); |
| 387 |
if(getprop("/autopilot/route-manager/wp/dist") > 1000) |
| 388 |
nd.symbols.wpActiveDistLbl.setText(" NM"); |
| 389 |
}, |
| 390 |
is_false: func(nd) nd.symbols.wpActiveDistLbl.hide(), |
| 391 |
}, |
| 392 |
}, |
| 393 |
{ |
| 394 |
id: 'eta', |
| 395 |
impl: { |
| 396 |
init: func(nd,symbol), |
| 397 |
predicate: func(nd) getprop("autopilot/route-manager/wp/eta") != nil and getprop("autopilot/route-manager/active") |
| 398 |
and nd.in_mode('toggle_display_mode', ['MAP','PLAN']), |
| 399 |
is_true: func(nd) { |
| 400 |
var etaSec = getprop("/sim/time/utc/day-seconds")+getprop("autopilot/route-manager/wp/eta-seconds"); |
| 401 |
var h = math.floor(etaSec/3600); |
| 402 |
etaSec=etaSec-3600*h; |
| 403 |
var m = math.floor(etaSec/60); |
| 404 |
etaSec=etaSec-60*m; |
| 405 |
var s = etaSec/10; |
| 406 |
if (h>24) h=h-24; |
| 407 |
nd.symbols.eta.setText(sprintf("%02.0f%02.0f.%01.0fz",h,m,s)); |
| 408 |
nd.symbols.eta.show(); |
| 409 |
}, |
| 410 |
is_false: func(nd) nd.symbols.eta.hide(), |
| 411 |
}, # of eta.impl |
| 412 |
}, # of eta |
| 413 |
{ |
| 414 |
id: 'gsGroup', |
| 415 |
impl: { |
| 416 |
init: func(nd,symbol), |
| 417 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP']), |
| 418 |
is_true: func(nd) { |
| 419 |
if(nd.get_switch('toggle_centered')) |
| 420 |
nd.symbols.gsGroup.setTranslation(0,0); |
| 421 |
else |
| 422 |
nd.symbols.gsGroup.setTranslation(0,150); |
| 423 |
nd.symbols.gsGroup.show(); |
| 424 |
}, |
| 425 |
is_false: func(nd) nd.symbols.gsGroup.hide(), |
| 426 |
}, |
| 427 |
}, |
| 428 |
{ |
| 429 |
id: 'compassApp', |
| 430 |
impl: { |
| 431 |
init: func(nd,symbol), |
| 432 |
predicate: func(nd) (nd.get_switch('toggle_centered') and nd.in_mode('toggle_display_mode', ['APP','VOR'])), |
| 433 |
is_true: func(nd) { |
| 434 |
if(nd.get_switch('toggle_true_north')) |
| 435 |
var hdg = nd.aircraft_source.get_trk_tru(); |
| 436 |
else |
| 437 |
var hdg = nd.aircraft_source.get_trk_mag(); |
| 438 |
nd.symbols.compassApp.setRotation(-hdg*D2R); |
| 439 |
nd.symbols.compassApp.show(); |
| 440 |
}, |
| 441 |
is_false: func(nd) nd.symbols.compassApp.hide(), |
| 442 |
}, |
| 443 |
}, |
| 444 |
{ |
| 445 |
id: 'compassMapCtr', |
| 446 |
impl: { |
| 447 |
init: func(nd,symbol), |
| 448 |
predicate: func(nd) (nd.get_switch('toggle_centered') and nd.in_mode('toggle_display_mode', ['MAP'])), |
| 449 |
is_true: func(nd) { |
| 450 |
if(nd.get_switch('toggle_true_north')) |
| 451 |
var hdg = nd.aircraft_source.get_trk_tru(); |
| 452 |
else |
| 453 |
var hdg = nd.aircraft_source.get_trk_mag(); |
| 454 |
nd.symbols.compassMapCtr.setRotation(-hdg*D2R); |
| 455 |
nd.symbols.compassMapCtr.show(); |
| 456 |
}, |
| 457 |
is_false: func(nd) nd.symbols.compassMapCtr.hide(), |
| 458 |
}, |
| 459 |
}, |
| 460 |
{ |
| 461 |
id:'hdg', |
| 462 |
impl: { |
| 463 |
init: func(nd,symbol), |
| 464 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','MAP','VOR']), |
| 465 |
is_true: func(nd) { |
| 466 |
var hdgText = ""; |
| 467 |
if((nd.in_mode('toggle_display_mode', ['MAP']) and nd.get_switch('toggle_display_type') == "CRT") |
| 468 |
or (nd.get_switch('toggle_track_heading') and nd.get_switch('toggle_display_type') == "LCD")) |
| 469 |
{ |
| 470 |
if(nd.get_switch('toggle_true_north')) |
| 471 |
hdgText = nd.aircraft_source.get_trk_tru(); |
| 472 |
else |
| 473 |
hdgText = nd.aircraft_source.get_trk_mag(); |
| 474 |
} else { |
| 475 |
if(nd.get_switch('toggle_true_north')) |
| 476 |
hdgText = nd.aircraft_source.get_hdg_tru(); |
| 477 |
else |
| 478 |
hdgText = nd.aircraft_source.get_hdg_mag(); |
| 479 |
} |
| 480 |
if(hdgText < 0.5) hdgText = 360 + hdgText; |
| 481 |
elsif(hdgText >= 360.5) hdgText = hdgText - 360; |
| 482 |
nd.symbols.hdg.setText(sprintf("%03.0f", hdgText)); |
| 483 |
}, |
| 484 |
is_false: NOTHING, |
| 485 |
}, |
| 486 |
}, |
| 487 |
{ |
| 488 |
id:'hdgGroup', |
| 489 |
impl: { |
| 490 |
init: func(nd,symbol), |
| 491 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','MAP','VOR']), |
| 492 |
is_true: func(nd) { |
| 493 |
nd.symbols.hdgGroup.show(); |
| 494 |
if(nd.get_switch('toggle_centered')) |
| 495 |
nd.symbols.hdgGroup.setTranslation(0,100); |
| 496 |
else |
| 497 |
nd.symbols.hdgGroup.setTranslation(0,0); |
| 498 |
}, |
| 499 |
is_false: func(nd) nd.symbols.hdgGroup.hide(), |
| 500 |
}, |
| 501 |
}, |
| 502 |
{ |
| 503 |
id:'gs', |
| 504 |
impl: { |
| 505 |
init: func(nd,symbol), |
| 506 |
common: func(nd) nd.symbols.gs.setText(sprintf("%3.0f",nd.aircraft_source.get_gnd_spd() )), |
| 507 |
predicate: func(nd) nd.aircraft_source.get_gnd_spd() >= 30, |
| 508 |
is_true: func(nd) { |
| 509 |
nd.symbols.gs.setFontSize(36); |
| 510 |
}, |
| 511 |
is_false: func(nd) nd.symbols.gs.setFontSize(52), |
| 512 |
}, |
| 513 |
}, |
| 514 |
{ |
| 515 |
id:'compass', |
| 516 |
impl: { |
| 517 |
init: func(nd,symbol), |
| 518 |
predicate: func(nd) ((nd.get_switch('toggle_centered') and !nd.in_mode('toggle_display_mode', ['PLAN'])) or nd.in_mode('toggle_display_mode', ['PLAN'])), |
| 519 |
is_true: func(nd) nd.symbols.compass.hide(), |
| 520 |
is_false: func(nd) { |
| 521 |
nd.symbols.compass.show(); |
| 522 |
nd.symbols.compass.setRotation(-nd.userHdgTrk*D2R); |
| 523 |
}, |
| 524 |
}, |
| 525 |
}, |
| 526 |
{ |
| 527 |
id:'truMag', |
| 528 |
impl: { |
| 529 |
init: func(nd,symbol), |
| 530 |
predicate: func(nd) nd.get_switch('toggle_true_north'), |
| 531 |
is_true: func(nd) nd.symbols.truMag.setText("TRU"), |
| 532 |
is_false: func(nd) nd.symbols.truMag.setText("MAG"), |
| 533 |
}, |
| 534 |
}, |
| 535 |
{ |
| 536 |
id:'northUp', |
| 537 |
impl: { |
| 538 |
init: func(nd,symbol), |
| 539 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['PLAN']), |
| 540 |
is_true: func(nd) nd.symbols.northUp.show(), |
| 541 |
is_false: func(nd) nd.symbols.northUp.hide(), |
| 542 |
}, |
| 543 |
}, |
| 544 |
{ |
| 545 |
id:'planArcs', |
| 546 |
impl: { |
| 547 |
init: func(nd,symbol), |
| 548 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['PLAN']), |
| 549 |
is_true: func(nd) nd.symbols.planArcs.show(), |
| 550 |
is_false: func(nd) nd.symbols.planArcs.hide(), |
| 551 |
}, |
| 552 |
}, |
| 553 |
{ |
| 554 |
id:'aplSymMap', |
| 555 |
impl: { |
| 556 |
init: func(nd,symbol), |
| 557 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','MAP','VOR']) and !nd.get_switch('toggle_centered')), |
| 558 |
is_true: func(nd) nd.symbols.aplSymMap.show(), |
| 559 |
is_false: func(nd) nd.symbols.aplSymMap.hide(), |
| 560 |
}, |
| 561 |
}, |
| 562 |
{ |
| 563 |
id:'aplSymMapCtr', |
| 564 |
impl: { |
| 565 |
init: func(nd,symbol), |
| 566 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['MAP']) and nd.get_switch('toggle_centered')), |
| 567 |
is_true: func(nd) nd.symbols.aplSymMapCtr.show(), |
| 568 |
is_false: func(nd) nd.symbols.aplSymMapCtr.hide(), |
| 569 |
}, |
| 570 |
}, |
| 571 |
{ |
| 572 |
id:'aplSymVor', |
| 573 |
impl: { |
| 574 |
init: func(nd,symbol), |
| 575 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and nd.get_switch('toggle_centered')), |
| 576 |
is_true: func(nd) nd.symbols.aplSymVor.show(), |
| 577 |
is_false: func(nd) nd.symbols.aplSymVor.hide(), |
| 578 |
}, |
| 579 |
}, |
| 580 |
{ |
| 581 |
id:'rangeArcs', |
| 582 |
impl: { |
| 583 |
init: func(nd,symbol), |
| 584 |
predicate: func(nd) !nd.get_switch('toggle_centered') and nd.get_switch('toggle_rangearc'), |
| 585 |
is_true: func(nd) nd.symbols.rangeArcs.show(), |
| 586 |
is_false: func(nd) nd.symbols.rangeArcs.hide(), |
| 587 |
}, |
| 588 |
}, |
| 589 |
{ |
| 590 |
id:'rangePln1', |
| 591 |
impl: { |
| 592 |
init: func(nd,symbol), |
| 593 |
predicate: func(nd) nd.get_switch('toggle_display_mode') == "PLAN", |
| 594 |
is_true: func(nd) { |
| 595 |
nd.symbols.rangePln1.show(); |
| 596 |
nd.symbols.rangePln1.setText(sprintf("%3.0f",nd.rangeNm())); |
| 597 |
}, |
| 598 |
is_false: func(nd) nd.symbols.rangePln1.hide(), |
| 599 |
}, |
| 600 |
}, |
| 601 |
{ |
| 602 |
id:'rangePln2', |
| 603 |
impl: { |
| 604 |
init: func(nd,symbol), |
| 605 |
predicate: func(nd) nd.get_switch('toggle_display_mode') == "PLAN", |
| 606 |
is_true: func(nd) { |
| 607 |
nd.symbols.rangePln2.show(); |
| 608 |
nd.symbols.rangePln2.setText(sprintf("%3.0f",nd.rangeNm()/2)); |
| 609 |
}, |
| 610 |
is_false: func(nd) nd.symbols.rangePln2.hide(), |
| 611 |
}, |
| 612 |
}, |
| 613 |
{ |
| 614 |
id:'rangePln3', |
| 615 |
impl: { |
| 616 |
init: func(nd,symbol), |
| 617 |
predicate: func(nd) nd.get_switch('toggle_display_mode') == "PLAN", |
| 618 |
is_true: func(nd) { |
| 619 |
nd.symbols.rangePln3.show(); |
| 620 |
nd.symbols.rangePln3.setText(sprintf("%3.0f",nd.rangeNm()/2)); |
| 621 |
}, |
| 622 |
is_false: func(nd) nd.symbols.rangePln3.hide(), |
| 623 |
}, |
| 624 |
}, |
| 625 |
{ |
| 626 |
id:'rangePln4', |
| 627 |
impl: { |
| 628 |
init: func(nd,symbol), |
| 629 |
predicate: func(nd) nd.get_switch('toggle_display_mode') == "PLAN", |
| 630 |
is_true: func(nd) { |
| 631 |
nd.symbols.rangePln4.show(); |
| 632 |
nd.symbols.rangePln4.setText(sprintf("%3.0f",nd.rangeNm())); |
| 633 |
}, |
| 634 |
is_false: func(nd) nd.symbols.rangePln4.hide(), |
| 635 |
}, |
| 636 |
}, |
| 637 |
{ |
| 638 |
id:'range', |
| 639 |
impl: { |
| 640 |
init: func(nd,symbol), |
| 641 |
predicate: func(nd) !nd.get_switch('toggle_centered'), |
| 642 |
is_true: func(nd) { |
| 643 |
nd.symbols.range.setText(sprintf("%3.0f",nd.rangeNm()/2)); |
| 644 |
}, |
| 645 |
is_false: func(nd) nd.symbols.rangePln4.hide(), |
| 646 |
}, |
| 647 |
}, |
| 648 |
{ |
| 649 |
id:'rangeCtr1', |
| 650 |
impl: { |
| 651 |
init: func(nd,symbol), |
| 652 |
predicate: func(nd) (nd.get_switch('toggle_centered') and nd.in_mode('toggle_display_mode', ['APP','MAP','VOR'])), |
| 653 |
is_true: func(nd) { |
| 654 |
nd.symbols.rangeCtr1.show(); |
| 655 |
nd.symbols.rangeCtr1.setText(sprintf("%g",nd.rangeNm()/4)); |
| 656 |
}, |
| 657 |
is_false: func(nd) nd.symbols.rangeCtr1.hide(), |
| 658 |
}, |
| 659 |
}, |
| 660 |
{ |
| 661 |
id:'rangeCtr2', |
| 662 |
impl: { |
| 663 |
init: func(nd,symbol), |
| 664 |
predicate: func(nd) (nd.get_switch('toggle_centered') and nd.in_mode('toggle_display_mode', ['APP','MAP','VOR'])), |
| 665 |
is_true: func(nd) { |
| 666 |
nd.symbols.rangeCtr2.show(); |
| 667 |
nd.symbols.rangeCtr2.setText(sprintf("%g",nd.rangeNm()/4)); |
| 668 |
}, |
| 669 |
is_false: func(nd) nd.symbols.rangeCtr2.hide(), |
| 670 |
}, |
| 671 |
}, |
| 672 |
{ |
| 673 |
id:'altArc', |
| 674 |
impl: { |
| 675 |
init: func(nd,symbol), |
| 676 |
predicate: func(nd) (!nd.get_switch('toggle_centered') and nd.in_mode('toggle_display_mode', ['MAP'])), |
| 677 |
is_true: func(nd) { |
| 678 |
var altDiff = (getprop("autopilot/settings/target-altitude-ft") or 0)-(getprop("instrumentation/altimeter/indicated-altitude-ft") or 0); |
| 679 |
if (abs(nd.aircraft_source.get_vspd()) > 1 and altDiff/nd.aircraft_source.get_vspd() > 0) { |
| 680 |
var altRangeNm = altDiff/nd.aircraft_source.get_vspd()*nd.aircraft_source.get_gnd_spd()*KT2MPS*M2NM; |
| 681 |
if(altRangeNm > 1) { |
| 682 |
var altRangePx = (350/nd.rangeNm())*altRangeNm; |
| 683 |
if (altRangePx > 700) |
| 684 |
altRangePx = 700; |
| 685 |
nd.symbols.altArc.setTranslation(0,-altRangePx); |
| 686 |
} |
| 687 |
nd.symbols.altArc.show(); |
| 688 |
} else |
| 689 |
nd.symbols.altArc.hide(); |
| 690 |
}, |
| 691 |
is_false: func(nd) nd.symbols.altArc.hide(), |
| 692 |
}, |
| 693 |
}, |
| 694 |
{ |
| 695 |
id:'altArcCtr', |
| 696 |
impl: { |
| 697 |
init: func(nd,symbol), |
| 698 |
predicate: func(nd) (nd.get_switch('toggle_centered') and nd.in_mode('toggle_display_mode', ['MAP'])), |
| 699 |
is_true: func(nd) { |
| 700 |
var altDiff = (getprop("autopilot/settings/target-altitude-ft") or 0)-(getprop("instrumentation/altimeter/indicated-altitude-ft") or 0); |
| 701 |
if (abs(nd.aircraft_source.get_vspd()) > 1 and altDiff/nd.aircraft_source.get_vspd() > 0) { |
| 702 |
var altRangeNm = altDiff/nd.aircraft_source.get_vspd()*nd.aircraft_source.get_gnd_spd()*KT2MPS*M2NM; |
| 703 |
if(altRangeNm > 1) { |
| 704 |
var altRangePx = (350/nd.rangeNm())*altRangeNm; |
| 705 |
if (altRangePx > 350) |
| 706 |
altRangePx = 350; |
| 707 |
nd.symbols.altArcCtr.setTranslation(0,-altRangePx); |
| 708 |
} |
| 709 |
nd.symbols.altArcCtr.show(); |
| 710 |
} else |
| 711 |
nd.symbols.altArcCtr.hide(); |
| 712 |
}, |
| 713 |
is_false: func(nd) nd.symbols.altArcCtr.hide(), |
| 714 |
}, |
| 715 |
}, |
| 716 |
{ |
| 717 |
id:'crsLbl', |
| 718 |
impl: { |
| 719 |
init: func(nd,symbol), |
| 720 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','VOR']), |
| 721 |
is_true: func(nd) nd.symbols.crsLbl.show(), |
| 722 |
is_false: func(nd) nd.symbols.crsLbl.hide(), |
| 723 |
}, |
| 724 |
}, |
| 725 |
{ |
| 726 |
id:'crs', |
| 727 |
impl: { |
| 728 |
init: func(nd,symbol), |
| 729 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','VOR']), |
| 730 |
is_true: func(nd) { |
| 731 |
nd.symbols.crs.show(); |
| 732 |
if(getprop("instrumentation/nav/radials/selected-deg") != nil) |
| 733 |
nd.symbols.crs.setText(sprintf("%03.0f",getprop("instrumentation/nav/radials/selected-deg"))); |
| 734 |
}, |
| 735 |
is_false: func(nd) nd.symbols.crs.hide(), |
| 736 |
}, |
| 737 |
}, |
| 738 |
{ |
| 739 |
id:'dmeLbl', |
| 740 |
impl: { |
| 741 |
init: func(nd,symbol), |
| 742 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','VOR']), |
| 743 |
is_true: func(nd) nd.symbols.dmeLbl.show(), |
| 744 |
is_false: func(nd) nd.symbols.dmeLbl.hide(), |
| 745 |
}, |
| 746 |
}, |
| 747 |
{ |
| 748 |
id:'dme', |
| 749 |
impl: { |
| 750 |
init: func(nd,symbol), |
| 751 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','VOR']), |
| 752 |
is_true: func(nd) { |
| 753 |
nd.symbols.dme.show(); |
| 754 |
if(getprop("instrumentation/dme/in-range")) |
| 755 |
nd.symbols.dme.setText(sprintf("%3.1f",getprop("instrumentation/dme/indicated-distance-nm"))); |
| 756 |
}, |
| 757 |
is_false: func(nd) nd.symbols.dme.hide(), |
| 758 |
}, |
| 759 |
}, |
| 760 |
{ |
| 761 |
id:'trkInd2', |
| 762 |
impl: { |
| 763 |
init: func(nd,symbol), |
| 764 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and nd.get_switch('toggle_centered')), |
| 765 |
is_true: func(nd) { |
| 766 |
if (nd.get_switch('toggle_track_heading') and nd.get_switch('toggle_display_type') == "LCD") |
| 767 |
nd.symbols.trkInd2.setRotation(0); |
| 768 |
else |
| 769 |
nd.symbols.trkInd2.setRotation((nd.userTrk-nd.userHdg)*D2R); |
| 770 |
nd.symbols.trkInd2.show(); |
| 771 |
}, |
| 772 |
is_false: func(nd) nd.symbols.trkInd2.hide(), |
| 773 |
}, |
| 774 |
}, |
| 775 |
{ |
| 776 |
id:'trkIndMapCtr', |
| 777 |
impl: { |
| 778 |
init: func(nd,symbol), |
| 779 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['MAP']) and nd.get_switch('toggle_centered')), |
| 780 |
is_true: func(nd) { |
| 781 |
if (nd.get_switch('toggle_display_type') == "CRT" or (nd.get_switch('toggle_track_heading') and nd.get_switch('toggle_display_type') == "LCD")) |
| 782 |
nd.symbols.trkIndMapCtr.setRotation(0); |
| 783 |
else |
| 784 |
nd.symbols.trkIndMapCtr.setRotation((nd.userTrk-nd.userHdg)*D2R); |
| 785 |
nd.symbols.trkIndMapCtr.show(); |
| 786 |
}, |
| 787 |
is_false: func(nd) nd.symbols.trkIndMapCtr.hide(), |
| 788 |
}, |
| 789 |
}, |
| 790 |
{ |
| 791 |
id:'vorCrsPtr', |
| 792 |
impl: { |
| 793 |
init: func(nd,symbol), |
| 794 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and !nd.get_switch('toggle_centered')), |
| 795 |
is_true: func(nd) { |
| 796 |
nd.symbols.vorCrsPtr.show(); |
| 797 |
if((nd.in_mode('toggle_display_mode', ['MAP']) and nd.get_switch('toggle_display_type') == "CRT") |
| 798 |
or (nd.get_switch('toggle_track_heading') and nd.get_switch('toggle_display_type') == "LCD")) |
| 799 |
nd.symbols.vorCrsPtr.setRotation((getprop("instrumentation/nav/radials/selected-deg")-nd.aircraft_source.get_trk_mag())*D2R); |
| 800 |
else |
| 801 |
nd.symbols.vorCrsPtr.setRotation((getprop("instrumentation/nav/radials/selected-deg")-nd.aircraft_source.get_hdg_mag())*D2R); |
| 802 |
}, |
| 803 |
is_false: func(nd) nd.symbols.vorCrsPtr.hide(), |
| 804 |
}, |
| 805 |
}, |
| 806 |
{ |
| 807 |
id:'vorCrsPtr2', |
| 808 |
impl: { |
| 809 |
init: func(nd,symbol), |
| 810 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and nd.get_switch('toggle_centered')), |
| 811 |
is_true: func(nd) { |
| 812 |
nd.symbols.vorCrsPtr2.show(); |
| 813 |
if((nd.in_mode('toggle_display_mode', ['MAP']) and nd.get_switch('toggle_display_type') == "CRT") |
| 814 |
or (nd.get_switch('toggle_track_heading') and nd.get_switch('toggle_display_type') == "LCD")) |
| 815 |
nd.symbols.vorCrsPtr2.setRotation((getprop("instrumentation/nav/radials/selected-deg")-nd.aircraft_source.get_trk_mag())*D2R); |
| 816 |
else |
| 817 |
nd.symbols.vorCrsPtr2.setRotation((getprop("instrumentation/nav/radials/selected-deg")-nd.aircraft_source.get_hdg_mag())*D2R); |
| 818 |
}, |
| 819 |
is_false: func(nd) nd.symbols.vorCrsPtr2.hide(), |
| 820 |
}, |
| 821 |
}, |
| 822 |
{ |
| 823 |
id: 'gsDiamond', |
| 824 |
impl: { |
| 825 |
init: func(nd,symbol), |
| 826 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP']) and getprop("instrumentation/nav/gs-in-range"), |
| 827 |
is_true: func(nd) { |
| 828 |
var gs_deflection = getprop("instrumentation/nav/gs-needle-deflection-norm"); |
| 829 |
if(gs_deflection != nil) |
| 830 |
nd.symbols.gsDiamond.setTranslation(gs_deflection*150,0); |
| 831 |
if(abs(gs_deflection) < 0.99) |
| 832 |
nd.symbols.gsDiamond.setColorFill(1,0,1,1); |
| 833 |
else |
| 834 |
nd.symbols.gsDiamond.setColorFill(0,0,0,1); |
| 835 |
}, |
| 836 |
is_false: func(nd) nd.symbols.gsGroup.hide(), |
| 837 |
}, |
| 838 |
}, |
| 839 |
{ |
| 840 |
id:'locPtr', |
| 841 |
impl: { |
| 842 |
init: func(nd,symbol), |
| 843 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and !nd.get_switch('toggle_centered') and getprop("instrumentation/nav/in-range")), |
| 844 |
is_true: func(nd) { |
| 845 |
nd.symbols.locPtr.show(); |
| 846 |
var deflection = getprop("instrumentation/nav/heading-needle-deflection-norm"); |
| 847 |
nd.symbols.locPtr.setTranslation(deflection*150,0); |
| 848 |
if(abs(deflection) < 0.99) |
| 849 |
nd.symbols.locPtr.setColorFill(1,0,1,1); |
| 850 |
else |
| 851 |
nd.symbols.locPtr.setColorFill(0,0,0,1); |
| 852 |
}, |
| 853 |
is_false: func(nd) nd.symbols.locPtr.hide(), |
| 854 |
}, |
| 855 |
}, |
| 856 |
{ |
| 857 |
id:'locPtr2', |
| 858 |
impl: { |
| 859 |
init: func(nd,symbol), |
| 860 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and nd.get_switch('toggle_centered') and getprop("instrumentation/nav/in-range")), |
| 861 |
is_true: func(nd) { |
| 862 |
nd.symbols.locPtr2.show(); |
| 863 |
var deflection = getprop("instrumentation/nav/heading-needle-deflection-norm"); |
| 864 |
nd.symbols.locPtr2.setTranslation(deflection*150,0); |
| 865 |
if(abs(deflection) < 0.99) |
| 866 |
nd.symbols.locPtr2.setColorFill(1,0,1,1); |
| 867 |
else |
| 868 |
nd.symbols.locPtr2.setColorFill(0,0,0,1); |
| 869 |
}, |
| 870 |
is_false: func(nd) nd.symbols.locPtr2.hide(), |
| 871 |
}, |
| 872 |
}, |
| 873 |
{ |
| 874 |
id:'wind', |
| 875 |
impl: { |
| 876 |
init: func(nd,symbol), |
| 877 |
predicate: func(nd) (nd.aircraft_source.get_spd() > 100 and getprop("environment/wind-speed-kt") > 4), |
| 878 |
is_true: func(nd) { |
| 879 |
var windDir = getprop("environment/wind-from-heading-deg"); |
| 880 |
var windSpd = getprop("environment/wind-speed-kt"); |
| 881 |
if(!nd.get_switch('toggle_true_north')) |
| 882 |
windDir = windDir - getprop("environment/magnetic-variation-deg"); |
| 883 |
while(windDir < 0.5) windDir += 360; |
| 884 |
while(windDir > 360.5) windDir -= 360; |
| 885 |
if (windSpd > 6) |
| 886 |
nd.windShown = 1; |
| 887 |
if (nd.windShown != 0) { |
| 888 |
nd.symbols.wind.setText(sprintf("%03.0f° / %02.0f",windDir,windSpd)); |
| 889 |
nd.symbols.wind.show(); |
| 890 |
} else |
| 891 |
nd.symbols.wind.hide(); |
| 892 |
}, |
| 893 |
is_false: func(nd) { |
| 894 |
nd.windShown = 0; |
| 895 |
nd.symbols.wind.hide(); |
| 896 |
}, |
| 897 |
}, |
| 898 |
}, |
| 899 |
{ |
| 900 |
id:'windArrow', |
| 901 |
impl: { |
| 902 |
init: func(nd,symbol), |
| 903 |
predicate: func(nd) (!(nd.in_mode('toggle_display_mode', ['PLAN']) and (nd.get_switch('toggle_display_type') == "LCD")) and nd.aircraft_source.get_spd() > 100 and getprop("environment/wind-speed-kt") > 4), |
| 904 |
is_true: func(nd) { |
| 905 |
if (nd.windShown != 0) { |
| 906 |
nd.symbols.windArrow.show(); |
| 907 |
var windArrowRot = getprop("environment/wind-from-heading-deg") - getprop("environment/magnetic-variation-deg"); |
| 908 |
if((nd.in_mode('toggle_display_mode', ['MAP','PLAN']) and nd.get_switch('toggle_display_type') == "CRT") |
| 909 |
or (nd.get_switch('toggle_track_heading') and nd.get_switch('toggle_display_type') == "LCD")) |
| 910 |
windArrowRot = windArrowRot - nd.aircraft_source.get_trk_mag(); |
| 911 |
else |
| 912 |
windArrowRot = windArrowRot - nd.aircraft_source.get_hdg_mag(); |
| 913 |
nd.symbols.windArrow.setRotation(windArrowRot*D2R); |
| 914 |
} else { |
| 915 |
nd.symbols.windArrow.hide(); |
| 916 |
} |
| 917 |
}, |
| 918 |
is_false: func(nd) nd.symbols.windArrow.hide(), |
| 919 |
}, |
| 920 |
}, |
| 921 |
{ |
| 922 |
id:'trendVector', |
| 923 |
impl: { |
| 924 |
init: func(nd,symbol), |
| 925 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['MAP'])), |
| 926 |
is_true: func(nd) { |
| 927 |
var rollDeg = getprop("/orientation/roll-deg") or 0; |
| 928 |
nd.symbols.trendVector.setVisible(abs(rollDeg) < 90); |
| 929 |
|
| 930 |
if (abs(rollDeg) > 0.2 and abs(rollDeg) < 90 and nd.aircraft_source.get_gnd_spd() > 100) { |
| 931 |
var radius = abs(nd.aircraft_source.get_gnd_spd()*nd.aircraft_source.get_gnd_spd()/(68578.83369*math.tan(rollDeg*D2R))); |
| 932 |
var sec = 90; |
| 933 |
if (nd.rangeNm() <= 10) sec = 30; |
| 934 |
elsif (nd.rangeNm() == 20) sec = 60; |
| 935 |
var L = nd.aircraft_source.get_gnd_spd()*0.0002778*sec; |
| 936 |
var angle = L/radius; |
| 937 |
var factor = 346/(0.5*nd.rangeNm()); |
| 938 |
radius = radius*factor; |
| 939 |
if (radius > 65535) radius = 65535; # prevent 16-bit overflow |
| 940 |
var y = radius*math.sin(angle); |
| 941 |
var x = (1-math.cos(angle))*radius; |
| 942 |
if (rollDeg < 0) { |
| 943 |
x = -x; |
| 944 |
var cmd = 21; |
| 945 |
if (angle > math.pi and angle < 2 * math.pi) cmd = 25; |
| 946 |
} else { |
| 947 |
var cmd = 19; |
| 948 |
if (angle > math.pi and angle < 2 * math.pi) cmd = 23; |
| 949 |
} |
| 950 |
var y1 = 824; |
| 951 |
if (nd.get_switch('toggle_centered')) y1 = 562; |
| 952 |
nd.symbols.trendVector.setData([2,cmd],[512,y1,radius,radius,0,x,-y]); |
| 953 |
var dash = L*factor; |
| 954 |
var dashArray = [dash/3-3, 5]; |
| 955 |
if (nd.rangeNm() <= 10) dashArray = [dash]; |
| 956 |
elsif (nd.rangeNm() == 20) dashArray = [dash/2-2, 5]; |
| 957 |
nd.symbols.trendVector.setStrokeDashArray(dashArray); |
| 958 |
} |
| 959 |
}, |
| 960 |
is_false: func(nd) nd.symbols.trendVector.hide(), |
| 961 |
}, |
| 962 |
}, |
| 963 |
{ |
| 964 |
id:'vorL', |
| 965 |
impl: { |
| 966 |
init: func(nd,symbol), |
| 967 |
predicate: func(nd) (nd.get_switch('toggle_lh_vor_adf') != 0), |
| 968 |
is_true: func(nd) { |
| 969 |
if(nd.get_switch('toggle_lh_vor_adf') == 1) { |
| 970 |
nd.symbols.vorL.setText("VOR L"); |
| 971 |
nd.symbols.vorL.setColor(0.195,0.96,0.097); |
| 972 |
} else { |
| 973 |
nd.symbols.vorL.setText("ADF L"); |
| 974 |
nd.symbols.vorL.setColor(0,0.6,0.85); |
| 975 |
} |
| 976 |
nd.symbols.vorL.show(); |
| 977 |
}, |
| 978 |
is_false: func(nd) nd.symbols.vorL.hide(), |
| 979 |
}, |
| 980 |
}, |
| 981 |
{ |
| 982 |
id:'vorLId', |
| 983 |
impl: { |
| 984 |
init: func(nd,symbol), |
| 985 |
predicate: func(nd) (nd.get_switch('toggle_lh_vor_adf') != 0), |
| 986 |
is_true: func(nd) { |
| 987 |
if(nd.get_switch('toggle_lh_vor_adf') == 1) { |
| 988 |
if(getprop("instrumentation/nav/in-range")) |
| 989 |
nd.symbols.vorLId.setText(getprop("instrumentation/nav/nav-id")); |
| 990 |
else |
| 991 |
nd.symbols.vorLId.setText(getprop("instrumentation/nav/frequencies/selected-mhz-fmt")); |
| 992 |
nd.symbols.vorLId.setColor(0.195,0.96,0.097); |
| 993 |
} else { |
| 994 |
if((var navident=getprop("instrumentation/adf/ident")) != "") |
| 995 |
nd.symbols.vorLId.setText(navident); |
| 996 |
else |
| 997 |
nd.symbols.vorLId.setText(sprintf("%3d",getprop("instrumentation/adf/frequencies/selected-khz"))); |
| 998 |
nd.symbols.vorLId.setColor(0,0.6,0.85); |
| 999 |
} |
| 1000 |
nd.symbols.vorLId.show(); |
| 1001 |
}, |
| 1002 |
is_false: func(nd) nd.symbols.vorLId.hide(), |
| 1003 |
}, |
| 1004 |
}, |
| 1005 |
{ |
| 1006 |
id:'dmeLDist', |
| 1007 |
impl: { |
| 1008 |
init: func(nd,symbol), |
| 1009 |
predicate: func(nd) (nd.get_switch('toggle_lh_vor_adf') != 0), |
| 1010 |
is_true: func(nd) { |
| 1011 |
if(nd.get_switch('toggle_lh_vor_adf') == 1) { |
| 1012 |
if(getprop("instrumentation/dme/in-range")) |
| 1013 |
nd.symbols.dmeLDist.setText(sprintf("%3.1f",getprop("instrumentation/dme/indicated-distance-nm"))); |
| 1014 |
else |
| 1015 |
nd.symbols.dmeLDist.setText(" ---"); |
| 1016 |
nd.symbols.dmeLDist.setColor(0.195,0.96,0.097); |
| 1017 |
} else { |
| 1018 |
nd.symbols.dmeLDist.setText(""); |
| 1019 |
nd.symbols.dmeLDist.setColor(0,0.6,0.85); |
| 1020 |
} |
| 1021 |
nd.symbols.dmeLDist.show(); |
| 1022 |
}, |
| 1023 |
is_false: func(nd) nd.symbols.dmeLDist.hide(), |
| 1024 |
}, |
| 1025 |
}, |
| 1026 |
{ |
| 1027 |
id:'dmeL', |
| 1028 |
impl: { |
| 1029 |
init: func(nd,symbol), |
| 1030 |
predicate: func(nd) (nd.get_switch('toggle_lh_vor_adf') != 0), |
| 1031 |
is_true: func(nd) { |
| 1032 |
if(nd.get_switch('toggle_lh_vor_adf') == 1) { |
| 1033 |
nd.symbols.dmeL.setText("DME"); |
| 1034 |
nd.symbols.dmeL.setColor(0.195,0.96,0.097); |
| 1035 |
} else { |
| 1036 |
nd.symbols.dmeL.setText(""); |
| 1037 |
nd.symbols.dmeL.setColor(0,0.6,0.85); |
| 1038 |
} |
| 1039 |
nd.symbols.dmeL.show(); |
| 1040 |
}, |
| 1041 |
is_false: func(nd) nd.symbols.dmeL.hide(), |
| 1042 |
}, |
| 1043 |
}, |
| 1044 |
# TACAN added by tikibar (J. Williams) |
| 1045 |
{ |
| 1046 |
id:'TCNArrow', |
| 1047 |
impl: { |
| 1048 |
init: func(nd,symbol), |
| 1049 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['MAP','APP','VOR']) and !nd.get_switch('toggle_centered') and nd.efis_switches['toggle_tacan'] != nil), |
| 1050 |
is_true: func(nd) { |
| 1051 |
if (nd.get_switch('toggle_tacan')) { |
| 1052 |
nd.symbols.TCNArrow.show(); |
| 1053 |
nd.symbols.TCNArrow.setRotation((getprop("instrumentation/tacan/indicated-bearing-true-deg")-nd.aircraft_source.get_hdg_tru())*D2R); |
| 1054 |
} else { |
| 1055 |
nd.symbols.TCNArrow.hide(); |
| 1056 |
} |
| 1057 |
}, |
| 1058 |
is_false: func(nd) nd.symbols.TCNArrow.hide(), |
| 1059 |
}, |
| 1060 |
}, |
| 1061 |
{ |
| 1062 |
id:'TCNArrow2', |
| 1063 |
impl: { |
| 1064 |
init: func(nd,symbol), |
| 1065 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['MAP','APP','VOR']) and nd.get_switch('toggle_centered') and nd.efis_switches['toggle_tacan'] != nil), |
| 1066 |
is_true: func(nd) { |
| 1067 |
if (nd.get_switch('toggle_tacan')) { |
| 1068 |
nd.symbols.TCNArrow2.show(); |
| 1069 |
nd.symbols.TCNArrow2.setRotation((getprop("instrumentation/tacan/indicated-bearing-true-deg")-nd.aircraft_source.get_hdg_tru())*D2R); |
| 1070 |
} else { |
| 1071 |
nd.symbols.TCNArrow2.hide(); |
| 1072 |
} |
| 1073 |
}, |
| 1074 |
is_false: func(nd) nd.symbols.TCNArrow2.hide(), |
| 1075 |
}, |
| 1076 |
}, |
| 1077 |
{ |
| 1078 |
id:'TACAN', |
| 1079 |
impl: { |
| 1080 |
init: func(nd,symbol), |
| 1081 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['MAP','APP','VOR']) and nd.efis_switches['toggle_tacan'] != nil), |
| 1082 |
is_true: func(nd) { |
| 1083 |
if (nd.get_switch('toggle_tacan')) { |
| 1084 |
nd.symbols.TACAN.setText("TACAN"); |
| 1085 |
nd.symbols.TACAN.show(); |
| 1086 |
} else { |
| 1087 |
nd.symbols.TACAN.hide(); |
| 1088 |
} |
| 1089 |
}, |
| 1090 |
is_false: func(nd) nd.symbols.TACAN.hide(), |
| 1091 |
}, |
| 1092 |
}, |
| 1093 |
{ |
| 1094 |
id:'TACANId', |
| 1095 |
impl: { |
| 1096 |
init: func(nd,symbol), |
| 1097 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['MAP','APP','VOR']) and nd.efis_switches['toggle_tacan'] != nil), |
| 1098 |
is_true: func(nd) { |
| 1099 |
if (nd.get_switch('toggle_tacan') and getprop("instrumentation/tacan/in-range")) { |
| 1100 |
nd.symbols.TACANId.setText(getprop("instrumentation/tacan/ident")); |
| 1101 |
nd.symbols.TACANId.show(); |
| 1102 |
} else { |
| 1103 |
nd.symbols.TACANId.hide(); |
| 1104 |
} |
| 1105 |
}, |
| 1106 |
is_false: func(nd) nd.symbols.TACANId.hide(), |
| 1107 |
}, |
| 1108 |
}, |
| 1109 |
{ |
| 1110 |
id:'TACANdme', |
| 1111 |
impl: { |
| 1112 |
init: func(nd,symbol), |
| 1113 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['MAP','APP','VOR']) and nd.efis_switches['toggle_tacan'] != nil), |
| 1114 |
is_true: func(nd) { |
| 1115 |
if (nd.get_switch('toggle_tacan') and getprop("instrumentation/tacan/in-range")) { |
| 1116 |
nd.symbols.TACANdme.setText("DIST"); |
| 1117 |
nd.symbols.TACANdme.show(); |
| 1118 |
} else { |
| 1119 |
nd.symbols.TACANdme.hide(); |
| 1120 |
} |
| 1121 |
}, |
| 1122 |
is_false: func(nd) nd.symbols.TACANdme.hide(), |
| 1123 |
}, |
| 1124 |
}, |
| 1125 |
{ |
| 1126 |
id:'TACANdmeDist', |
| 1127 |
impl: { |
| 1128 |
init: func(nd,symbol), |
| 1129 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['MAP','APP','VOR']) and nd.efis_switches['toggle_tacan'] != nil), |
| 1130 |
is_true: func(nd) { |
| 1131 |
if (nd.get_switch('toggle_tacan') and getprop("instrumentation/tacan/in-range")) { |
| 1132 |
nd.symbols.TACANdmeDist.setText(sprintf("%3.1f",getprop("instrumentation/tacan/indicated-distance-nm"))); |
| 1133 |
nd.symbols.TACANdmeDist.show(); |
| 1134 |
} else { |
| 1135 |
nd.symbols.TACANdmeDist.hide(); |
| 1136 |
} |
| 1137 |
}, |
| 1138 |
is_false: func(nd) nd.symbols.TACANdmeDist.hide(), |
| 1139 |
}, |
| 1140 |
}, |
| 1141 |
|
| 1142 |
], # end of vector with features |
| 1143 |
|
| 1144 |
|
| 1145 |
}, # end of Boeing style |
| 1146 |
"Airbus" : { |
| 1147 |
font_mapper: func(family, weight) { |
| 1148 |
if( family == "Liberation Sans" and weight == "normal" ) |
| 1149 |
return "LiberationFonts/LiberationSans-Regular.ttf"; |
| 1150 |
}, |
| 1151 |
|
| 1152 |
# where all the symbols are stored |
| 1153 |
# TODO: SVG elements should be renamed to use boeing/airbus prefix |
| 1154 |
# aircraft developers should all be editing the same ND.svg image |
| 1155 |
# the code can deal with the differences now |
| 1156 |
svg_filename: "Nasal/canvas/map/Airbus/Images/airbusND.svg", |
| 1157 |
|
| 1158 |
initialize_elements: func(me) { |
| 1159 |
|
| 1160 |
### this is the "old" method that's less flexible, we want to use the style hash instead (see above) |
| 1161 |
# because things are much better configurable that way |
| 1162 |
# now look up all required SVG elements and initialize member fields using the same name to have a convenient handle |
| 1163 |
foreach(var element; ["dmeLDist","dmeRDist","dmeL","dmeR","vorL","vorR","vorLId","vorRId", |
| 1164 |
"status.wxr","status.wpt","status.sta","status.arpt"]) |
| 1165 |
me.symbols[element] = me.nd.getElementById(element); |
| 1166 |
|
| 1167 |
# load elements from vector image, and create instance variables using identical names, and call updateCenter() on each |
| 1168 |
# anything that needs updatecenter called, should be added to the vector here |
| 1169 |
# |
| 1170 |
foreach(var element; ["staArrowL2","staArrowR2","staFromL2","staToL2","staFromR2","staToR2", |
| 1171 |
"hdgTrk","trkInd","hdgBug","HdgBugCRT","TrkBugLCD","HdgBugLCD","curHdgPtr", |
| 1172 |
"HdgBugCRT2","TrkBugLCD2","HdgBugLCD2","hdgBug2","selHdgLine","selHdgLine2","curHdgPtr2", |
| 1173 |
"staArrowL","staArrowR","staToL","staFromL","staToR","staFromR"] ) |
| 1174 |
me.symbols[element] = me.nd.getElementById(element).updateCenter(); |
| 1175 |
|
| 1176 |
}, # initialize_elements |
| 1177 |
|
| 1178 |
|
| 1179 |
|
| 1180 |
## |
| 1181 |
## this loads and configures existing layers (currently, *.layer files in Nasal/canvas/map) |
| 1182 |
## |
| 1183 |
options: { |
| 1184 |
position_callback: func(nd, pos){ |
| 1185 |
if(nd.get_switch('toggle_centered') or |
| 1186 |
nd.get_switch('toggle_display_mode') == 'PLAN') |
| 1187 |
pos.range = (nd.rangeNm() * 1.6156087432822295); |
| 1188 |
}, |
| 1189 |
translation_callback: func(nd){ |
| 1190 |
var t = {x: 512, y: 824}; |
| 1191 |
if(nd.get_switch('toggle_centered') or |
| 1192 |
nd.get_switch('toggle_display_mode') == 'PLAN') |
| 1193 |
t.y = 512; |
| 1194 |
return t; |
| 1195 |
}, |
| 1196 |
defaults: { |
| 1197 |
# Configurable Global Options: |
| 1198 |
# - fplan_active: the boolean property used to determine if the flight plan is active |
| 1199 |
# - lat_ctrl: the property used to determine if lateral flight mode is managed |
| 1200 |
# Lateral managed mode is similar to Boeing LNAV and indicates that the |
| 1201 |
# aircraft should follow the current active flight plan. By default |
| 1202 |
# the lat_ctrl property is checked against 'fmgc' (managed) value. |
| 1203 |
# You can use a custom value instead on 'fmgc' by overriding 'managed_val' |
| 1204 |
# - managed_val: the value that the property defined by 'lat_ctrl' should have in case |
| 1205 |
# that the lateral flight mode is managed. |
| 1206 |
# You can easily override these options before creating the ND, example: |
| 1207 |
# canvas.NDStyles['Airbus'].options.defaults.fplan_active = 'my/autpilot/f-plan/active' |
| 1208 |
fplan_active: 'autopilot/route-manager/active', |
| 1209 |
lat_ctrl: 'flight-management/control/lat-ctrl', |
| 1210 |
managed_val: 'fmgc', |
| 1211 |
ver_ctrl: 'flight-management/control/ver-ctrl', |
| 1212 |
spd_ctrl: '/flight-management/control/spd-ctrl', |
| 1213 |
current_wp: '/autopilot/route-manager/current-wp', |
| 1214 |
ap1: '/flight-management/control/ap1-master', |
| 1215 |
ap2: '/flight-management/control/ap2-master', |
| 1216 |
nav1_frq: 'instrumentation/nav/frequencies/selected-mhz', |
| 1217 |
nav2_frq: 'instrumentation/nav[1]/frequencies/selected-mhz', |
| 1218 |
adf1_frq: 'instrumentation/adf/frequencies/selected-khz', |
| 1219 |
adf2_frq: 'instrumentation/adf[1]/frequencies/selected-khz', |
| 1220 |
dep_rwy: '/autopilot/route-manager/departure/runway', |
| 1221 |
dest_rwy: '/autopilot/route-manager/destination/runway', |
| 1222 |
wp_count: 'autopilot/route-manager/route/num', |
| 1223 |
level_off_alt: '/autopilot/route-manager/vnav/level-off-alt', |
| 1224 |
athr: '/flight-management/control/a-thrust', |
| 1225 |
app_mode: 'instrumentation/nd/app-mode', |
| 1226 |
chrono_node: 'instrumentation/chrono', |
| 1227 |
active_route_color: [0.4,0.7,0.4], |
| 1228 |
inactive_route_color: [0.95,0.95,0.21] |
| 1229 |
}, |
| 1230 |
map: { |
| 1231 |
"z-index" : -1 |
| 1232 |
} |
| 1233 |
}, |
| 1234 |
layers: [ |
| 1235 |
# Should redraw every 10 seconds TODO: use new MapStructure/WXR here once that works properly (Gijs should check first!) |
| 1236 |
{ |
| 1237 |
name:'WXR_live', |
| 1238 |
isMapStructure:1, |
| 1239 |
always_update: 1, |
| 1240 |
update_on:[ 'toggle_range','toggle_weather','toggle_display_mode','toggle_weather_live'], |
| 1241 |
predicate: func(nd, layer) { |
| 1242 |
var visible=nd.get_switch('toggle_weather') and |
| 1243 |
nd.get_switch('toggle_weather_live') and |
| 1244 |
nd.get_switch('toggle_display_mode') != "PLAN"; |
| 1245 |
layer.group.setVisible(visible); |
| 1246 |
if (visible) { |
| 1247 |
layer.update(); |
| 1248 |
} |
| 1249 |
}, # end of layer update predicate |
| 1250 |
options: { |
| 1251 |
viewport_radius: 706 |
| 1252 |
}, |
| 1253 |
'z-index': -100, |
| 1254 |
}, |
| 1255 |
{ |
| 1256 |
name:'WXR', |
| 1257 |
isMapStructure:1, |
| 1258 |
update_on:[ {rate_hz: 0.1}, 'toggle_range','toggle_weather','toggle_display_mode', 'toggle_weather_live'], |
| 1259 |
predicate: func(nd, layer) { |
| 1260 |
#print("Running storms predicate"); |
| 1261 |
var visible=nd.get_switch('toggle_weather') and |
| 1262 |
!nd.get_switch('toggle_weather_live') and |
| 1263 |
nd.get_switch('toggle_display_mode') != "PLAN"; |
| 1264 |
layer.group.setVisible(visible); |
| 1265 |
if (visible) { |
| 1266 |
print("storms update requested! (timer issue when closing the dialog?)"); |
| 1267 |
layer.update(); |
| 1268 |
} |
| 1269 |
}, # end of layer update predicate |
| 1270 |
'z-index': -4, |
| 1271 |
}, # end of storms/WXR layer |
| 1272 |
{ |
| 1273 |
name:'FIX', |
| 1274 |
isMapStructure:1, |
| 1275 |
update_on:['toggle_waypoints','toggle_display_mode'], |
| 1276 |
predicate: func(nd, layer) { |
| 1277 |
var visible = nd.get_switch('toggle_waypoints') and |
| 1278 |
nd.in_mode('toggle_display_mode', ['MAP']) and |
| 1279 |
(nd.rangeNm() <= 40); |
| 1280 |
layer.group.setVisible( visible ); |
| 1281 |
if (visible) |
| 1282 |
layer.update(); |
| 1283 |
}, # end of layer update predicate |
| 1284 |
style: { |
| 1285 |
color: [0.69, 0, 0.39], |
| 1286 |
text_offset: [20,10], |
| 1287 |
text_color: [1,1,1] |
| 1288 |
}, |
| 1289 |
options: { |
| 1290 |
range_dependant: 1, |
| 1291 |
draw_function: func(group){ |
| 1292 |
group.createChild('path') |
| 1293 |
.moveTo(-10,0) |
| 1294 |
.lineTo(0,-17) |
| 1295 |
.lineTo(10,0) |
| 1296 |
.lineTo(0,17) |
| 1297 |
.close() |
| 1298 |
.setStrokeLineWidth(3) |
| 1299 |
.setColor(color) |
| 1300 |
.setScale(1); |
| 1301 |
} |
| 1302 |
} |
| 1303 |
}, # end of FIX layer |
| 1304 |
{ |
| 1305 |
name: 'ALT-profile', |
| 1306 |
isMapStructure: 1, |
| 1307 |
update_on: ['toggle_display_mode','toggle_range',{rate_hz: 2}], |
| 1308 |
predicate: func(nd, layer) { |
| 1309 |
var visible = nd.in_mode('toggle_display_mode', ['MAP', 'PLAN']);# and nd.get_switch('toggle_fplan'); |
| 1310 |
layer.group.setVisible( visible ); |
| 1311 |
if (visible) { |
| 1312 |
layer.update(); |
| 1313 |
} |
| 1314 |
}, |
| 1315 |
style: { |
| 1316 |
default_color: [1,1,1], |
| 1317 |
armed_color: [0.06,0.55,1], |
| 1318 |
managed_color: [0.68, 0, 0.38] |
| 1319 |
}, |
| 1320 |
options: { |
| 1321 |
# You can overwrite these with different nodes, before creating the ND |
| 1322 |
# Example: canvas.NDStyles['Airbus'].layers['ALT-profile'].options.vnav_node = 'my/vnav/node'; |
| 1323 |
# In order to display ALT-profile on your ND you have to create the various |
| 1324 |
# nodes corresponding to the different ALT pseudowaypoint in your aircraft code. |
| 1325 |
# Every node must be set into the 'vnav_node' configured here (you can override it). |
| 1326 |
# Example: if you want to display the top-of-descent symbol you must create a 'td' |
| 1327 |
# node into vnav_node. Something like this: |
| 1328 |
# /autopilot/route-manager/vnav/td/ |
| 1329 |
# Each node should have the latitude-deg and longitude-deg properties. |
| 1330 |
# Available nodes are: |
| 1331 |
# tc (top of climb) |
| 1332 |
# td (top of descent) |
| 1333 |
# ec (end of climb) |
| 1334 |
# ed (end of descent) |
| 1335 |
# sc (start of climb) |
| 1336 |
# sd (start of descent) |
| 1337 |
# If ec and ed are altitude constraints, their node should have the |
| 1338 |
# boolean 'alt-cstr' property set to 1. |
| 1339 |
vnav_node: "/autopilot/route-manager/vnav/", |
| 1340 |
types: ["tc", "td", "ec", "ed","sc","sd"], |
| 1341 |
svg_path: { |
| 1342 |
tc: 'Nasal/canvas/map/Airbus/Images/airbus_tc.svg', |
| 1343 |
td: 'Nasal/canvas/map/Airbus/Images/airbus_td.svg', |
| 1344 |
ec: 'Nasal/canvas/map/Airbus/Images/airbus_ec.svg', |
| 1345 |
ed: 'Nasal/canvas/map/Airbus/Images/airbus_ed.svg', |
| 1346 |
sc: 'Nasal/canvas/map/Airbus/Images/airbus_sc.svg', |
| 1347 |
sd: 'Nasal/canvas/map/Airbus/Images/airbus_sd.svg' |
| 1348 |
}, |
| 1349 |
listen: [ |
| 1350 |
'fplan_active', |
| 1351 |
'ver_ctrl', |
| 1352 |
'ap1', |
| 1353 |
'ap2', |
| 1354 |
'current_wp' |
| 1355 |
], |
| 1356 |
draw_callback: func(){ |
| 1357 |
var name = me.model.getName(); |
| 1358 |
var grp = me.element.getElementById(name~'_symbol'); |
| 1359 |
if(grp == nil) return; |
| 1360 |
var dfcolor = me.getStyle('default_color'); |
| 1361 |
var armed_color = me.getStyle('armed_color'); |
| 1362 |
var managed_color = me.getStyle('managed_color'); |
| 1363 |
#print('Draw: -> ' ~ name); |
| 1364 |
if(name == 'td' or name == 'sd' or name == 'sc'){ |
| 1365 |
var vnav_armed = me.model.getValue('vnav-armed'); |
| 1366 |
if(vnav_armed) |
| 1367 |
grp.setColor(armed_color); |
| 1368 |
else |
| 1369 |
grp.setColor(dfcolor); |
| 1370 |
} |
| 1371 |
elsif(name == 'ed' or name == 'ec'){ |
| 1372 |
var is_cstr = me.model.getValue('alt-cstr'); |
| 1373 |
if(is_cstr) |
| 1374 |
grp.setColor(managed_color); |
| 1375 |
else |
| 1376 |
grp.setColor(armed_color); |
| 1377 |
} |
| 1378 |
}, |
| 1379 |
init_after_callback: func{ |
| 1380 |
var name = me.model.getName(); |
| 1381 |
var grp = me.element.getElementById(name~'_symbol'); |
| 1382 |
if(name != 'td' and name != 'sd' and name != 'sc'){ |
| 1383 |
grp.setTranslation(-50,0); |
| 1384 |
} |
| 1385 |
} |
| 1386 |
} |
| 1387 |
}, |
| 1388 |
{ |
| 1389 |
name:'APT', |
| 1390 |
isMapStructure:1, |
| 1391 |
update_on:['toggle_airports','toggle_display_mode'], |
| 1392 |
predicate: func(nd, layer) { |
| 1393 |
var visible = nd.get_switch('toggle_airports') and |
| 1394 |
nd.in_mode('toggle_display_mode', ['MAP']); |
| 1395 |
layer.group.setVisible( visible ); |
| 1396 |
if (visible) { |
| 1397 |
layer.update(); |
| 1398 |
} |
| 1399 |
}, # end of layer update predicate |
| 1400 |
options: { |
| 1401 |
range_dependant: 1, |
| 1402 |
}, |
| 1403 |
style: { |
| 1404 |
svg_path: 'Nasal/canvas/map/Airbus/Images/airbus_airport.svg', |
| 1405 |
text_offset: [45, 35], |
| 1406 |
label_font_color: [1,1,1], |
| 1407 |
label_font_size: 28 |
| 1408 |
} |
| 1409 |
}, # end of APT layer |
| 1410 |
{ |
| 1411 |
name:'VOR-airbus', |
| 1412 |
isMapStructure:1, |
| 1413 |
update_on:['toggle_vor','toggle_display_mode'], |
| 1414 |
# FIXME: this is a really ugly place for controller code |
| 1415 |
predicate: func(nd, layer) { |
| 1416 |
# print("Running vor layer predicate"); |
| 1417 |
# toggle visibility here |
| 1418 |
var visible = nd.get_switch('toggle_vor') and |
| 1419 |
nd.in_mode('toggle_display_mode', ['MAP']) and |
| 1420 |
(nd.rangeNm() <= 40); |
| 1421 |
layer.group.setVisible( visible ); |
| 1422 |
if (visible) { |
| 1423 |
layer.update(); |
| 1424 |
} |
| 1425 |
}, # end of layer update predicate |
| 1426 |
# You can override default colors within the style |
| 1427 |
# Default color: 'color' |
| 1428 |
# Tuned color: 'tuned_color' |
| 1429 |
# Example: |
| 1430 |
# canvas.NDStyles['Airbus'].layers['VOR-airbus'].style.color = [1,1,1]; |
| 1431 |
# canvas.NDStyles['Airbus'].layers['VOR-airbus'].style.tuned_color = [0,0,1]; |
| 1432 |
style: {}, |
| 1433 |
options:{ |
| 1434 |
range_dependant: 1, |
| 1435 |
listen: [ |
| 1436 |
'nav1_frq', |
| 1437 |
'nav2_frq' |
| 1438 |
], |
| 1439 |
} |
| 1440 |
}, # end of VOR layer |
| 1441 |
{ |
| 1442 |
name:'DME', |
| 1443 |
isMapStructure:1, |
| 1444 |
disabled:1, |
| 1445 |
update_on:['toggle_display_mode','toggle_dme'], |
| 1446 |
# FIXME: this is a really ugly place for controller code |
| 1447 |
predicate: func(nd, layer) { |
| 1448 |
var visible = nd.get_switch('toggle_dme') and |
| 1449 |
nd.in_mode('toggle_display_mode', ['MAP']) and |
| 1450 |
(nd.rangeNm() <= 40); |
| 1451 |
# toggle visibility here |
| 1452 |
layer.group.setVisible( visible ); |
| 1453 |
if (visible) { |
| 1454 |
#print("Updating MapStructure ND layer: DME"); |
| 1455 |
layer.update(); |
| 1456 |
} |
| 1457 |
}, # end of layer update predicate |
| 1458 |
options: { |
| 1459 |
range_dependant: 1, |
| 1460 |
draw_dme: func(sym){ |
| 1461 |
return sym.createChild("path") |
| 1462 |
.moveTo(-13, 0) |
| 1463 |
.arcSmallCW(13,13,0,26,0) |
| 1464 |
.arcSmallCW(13,13,0,-26,0) |
| 1465 |
.setStrokeLineWidth(2) |
| 1466 |
.close(); |
| 1467 |
}, |
| 1468 |
draw_text: 1 |
| 1469 |
}, |
| 1470 |
style: { |
| 1471 |
color_default: [0.9,0,0.47], |
| 1472 |
color_tuned: [0,0.62,0.84], |
| 1473 |
}, |
| 1474 |
'z-index': -2, |
| 1475 |
}, # end of DME layer |
| 1476 |
{ |
| 1477 |
name:'NDB', |
| 1478 |
isMapStructure:1, |
| 1479 |
update_on:['toggle_ndb','toggle_display_mode'], |
| 1480 |
# FIXME: this is a really ugly place for controller code |
| 1481 |
predicate: func(nd, layer) { |
| 1482 |
var visible = nd.get_switch('toggle_ndb') and |
| 1483 |
nd.in_mode('toggle_display_mode', ['MAP']) and |
| 1484 |
(nd.rangeNm() <= 40); |
| 1485 |
# print("Running vor layer predicate"); |
| 1486 |
# toggle visibility here |
| 1487 |
layer.group.setVisible( visible ); |
| 1488 |
if (visible) { |
| 1489 |
layer.update(); |
| 1490 |
} |
| 1491 |
}, # end of layer update predicate |
| 1492 |
# You can override default colors within the style |
| 1493 |
# Default color: 'color' |
| 1494 |
# Tuned color: 'tuned_color' |
| 1495 |
# Example: |
| 1496 |
# canvas.NDStyles['Airbus'].layers['VOR-airbus'].style.color = [1,1,1]; |
| 1497 |
# canvas.NDStyles['Airbus'].layers['VOR-airbus'].style.tuned_color = [0,0,1]; |
| 1498 |
style: { |
| 1499 |
#svg_path: 'Nasal/canvas/map/Airbus/Images/airbus_ndb.svg' |
| 1500 |
svg_path: '' |
| 1501 |
}, |
| 1502 |
options: { |
| 1503 |
range_dependant: 1, |
| 1504 |
listen: [ |
| 1505 |
'adf1_frq', |
| 1506 |
'adf2_frq' |
| 1507 |
], |
| 1508 |
init_after_callback: func{ |
| 1509 |
#me.element.removeAllChildren(); |
| 1510 |
me.text_ndb = me.element.createChild("text") |
| 1511 |
.setDrawMode( canvas.Text.TEXT ) |
| 1512 |
.setText(me.model.id) |
| 1513 |
.setFont("LiberationFonts/LiberationSans-Regular.ttf") |
| 1514 |
.setFontSize(28) |
| 1515 |
.setTranslation(25,10); |
| 1516 |
me.ndb_sym = me.element.createChild('path'); |
| 1517 |
me.ndb_sym.moveTo(-15,15) |
| 1518 |
.lineTo(0,-15) |
| 1519 |
.lineTo(15,15) |
| 1520 |
.close() |
| 1521 |
.setStrokeLineWidth(3) |
| 1522 |
.setColor(0.69,0,0.39) |
| 1523 |
.setScale(1,1); |
| 1524 |
}, |
| 1525 |
draw_callback: func{ |
| 1526 |
var frq = me.model.frequency; |
| 1527 |
if(frq != nil){ |
| 1528 |
var dfcolor = me.getStyle('color', [0.9,0,0.47]); |
| 1529 |
var tuned_color = me.getStyle('tuned_color', [0,0.62,0.84]); |
| 1530 |
frq = frq / 100; |
| 1531 |
var adf1_frq = getprop(me.options.adf1_frq); |
| 1532 |
var adf2_frq = getprop(me.options.adf2_frq); |
| 1533 |
if(adf1_frq == frq or adf2_frq == frq){ |
| 1534 |
me.element.setColor(tuned_color, [Path]); |
| 1535 |
} else { |
| 1536 |
me.element.setColor(dfcolor, [Path]); |
| 1537 |
} |
| 1538 |
} |
| 1539 |
}, |
| 1540 |
} |
| 1541 |
}, # end of NDB layer |
| 1542 |
{ |
| 1543 |
name:'TFC', |
| 1544 |
#disabled:1, |
| 1545 |
always_update: 1, |
| 1546 |
isMapStructure:1, |
| 1547 |
update_on:['toggle_range','toggle_traffic'], |
| 1548 |
predicate: func(nd, layer) { |
| 1549 |
var visible = nd.get_switch('toggle_traffic'); |
| 1550 |
layer.group.setVisible( visible ); |
| 1551 |
if (visible) { |
| 1552 |
#print("Updating MapStructure ND layer: TFC"); |
| 1553 |
layer.update(); |
| 1554 |
} |
| 1555 |
}, # end of layer update predicate |
| 1556 |
}, # end of traffic layer |
| 1557 |
{ |
| 1558 |
name:'RWY-profile', |
| 1559 |
isMapStructure:1, |
| 1560 |
update_on:['toggle_range','toggle_display_mode'], |
| 1561 |
predicate: func(nd, layer) { |
| 1562 |
var visible = (nd.rangeNm() <= 40) and |
| 1563 |
nd.in_mode('toggle_display_mode', ['MAP','PLAN']) ; |
| 1564 |
layer.group.setVisible( visible ); |
| 1565 |
if (visible) { |
| 1566 |
layer.update(); |
| 1567 |
} |
| 1568 |
}, # end of layer update predicate |
| 1569 |
options: { |
| 1570 |
listen: [ |
| 1571 |
'fplan_active', |
| 1572 |
'dep_rwy', |
| 1573 |
'dest_rwy' |
| 1574 |
] |
| 1575 |
} |
| 1576 |
}, # end of runway layer |
| 1577 |
{ |
| 1578 |
name:'HOLD', |
| 1579 |
isMapStructure: 1, |
| 1580 |
always_update: 1, |
| 1581 |
update_on:['toggle_range','toggle_display_mode','toggle_wpt_idx'], |
| 1582 |
predicate: func(nd, layer) { |
| 1583 |
var visible= nd.in_mode('toggle_display_mode', ['MAP','PLAN']); |
| 1584 |
layer.group.setVisible( visible ); |
| 1585 |
if (visible) { |
| 1586 |
layer.update(); |
| 1587 |
} |
| 1588 |
}, |
| 1589 |
options: { |
| 1590 |
hold_node: '/flight-management/hold', |
| 1591 |
hold_init: 'flight-management/hold/init', |
| 1592 |
points_node: '/flight-management/hold/points', |
| 1593 |
first_point_node: '/flight-management/hold/points/point/lat', |
| 1594 |
hold_wp: '/flight-management/hold/wp', |
| 1595 |
hold_wp_idx: '/flight-management/hold/wp_id', |
| 1596 |
range_dependant: 1, |
| 1597 |
listen: [ |
| 1598 |
'first_point_node', |
| 1599 |
'fplan_active', |
| 1600 |
'lat_ctrl', |
| 1601 |
'current_wp', |
| 1602 |
'hold_wp', |
| 1603 |
'hold_init', |
| 1604 |
'hold_wp_idx' |
| 1605 |
] |
| 1606 |
} |
| 1607 |
# end of layer update predicate |
| 1608 |
}, # end of HOLD layer |
| 1609 |
{ |
| 1610 |
name:'RTE', |
| 1611 |
isMapStructure: 1, |
| 1612 |
update_on:['toggle_range','toggle_display_mode', 'toggle_cstr', |
| 1613 |
'toggle_wpt_idx'], |
| 1614 |
predicate: func(nd, layer) { |
| 1615 |
var visible= (nd.in_mode('toggle_display_mode', ['MAP','PLAN'])); |
| 1616 |
layer.group.setVisible( visible ); |
| 1617 |
if (visible) { |
| 1618 |
layer.update(); |
| 1619 |
} |
| 1620 |
}, # end of layer update predicate |
| 1621 |
options: { |
| 1622 |
display_inactive_rte: 1, |
| 1623 |
listen: [ |
| 1624 |
'fplan_active', |
| 1625 |
'lat_ctrl', |
| 1626 |
'current_wp', |
| 1627 |
'wp_count' |
| 1628 |
], |
| 1629 |
draw_after_callback: func{ |
| 1630 |
me.setRouteStyle(); |
| 1631 |
} |
| 1632 |
}, |
| 1633 |
style: { |
| 1634 |
line_width: 5, |
| 1635 |
#inactive_color: [0.95,0.95,0.21], |
| 1636 |
#active_color: [0.4,0.7,0.4], |
| 1637 |
color: func{ |
| 1638 |
if(!contains(me, 'inactive_color')){ |
| 1639 |
me.inactive_color = me.getStyle('inactive_color'); |
| 1640 |
if(me.inactive_color == nil) |
| 1641 |
me.inactive_color = me.getOption('inactive_route_color'); |
| 1642 |
} |
| 1643 |
if(!contains(me, 'active_color')){ |
| 1644 |
me.active_color = me.getStyle('active_color'); |
| 1645 |
if(me.active_color == nil) |
| 1646 |
me.active_color = me.getOption('active_route_color'); |
| 1647 |
} |
| 1648 |
var is_active = getprop(me.options.fplan_active); |
| 1649 |
(is_active ? me.active_color : me.inactive_color); |
| 1650 |
}, |
| 1651 |
color_alternate_current: [0,0.62,0.84], |
| 1652 |
color_missed: [0,0.62,0.84], |
| 1653 |
color_temporary: func me.getStyle('inactive_color', me.getOption('inactive_route_color')), |
| 1654 |
color_secondary: [1,1,1], |
| 1655 |
color_alternate_secondary: [1,1,1], |
| 1656 |
line_dash: func{ |
| 1657 |
var lat_ctrl = getprop(me.options.lat_ctrl); |
| 1658 |
var is_managed = (lat_ctrl == me.options.managed_val); |
| 1659 |
var is_active = getprop(me.options.fplan_active); |
| 1660 |
(is_managed and is_active ? [] : [32, 16]); |
| 1661 |
}, |
| 1662 |
line_dash_alternate_current: [32,16], |
| 1663 |
line_dash_temporary: [32,16] |
| 1664 |
} |
| 1665 |
}, # end of route layer |
| 1666 |
{ |
| 1667 |
name:'WPT-airbus', |
| 1668 |
isMapStructure: 1, |
| 1669 |
update_on:['toggle_range','toggle_display_mode', 'toggle_cstr', |
| 1670 |
'toggle_wpt_idx'], |
| 1671 |
style: { |
| 1672 |
wp_color: [0.4,0.7,0.4], |
| 1673 |
current_wp_color: [1,1,1], |
| 1674 |
constraint_color: [1,1,1], |
| 1675 |
active_constraint_color: [0.69,0,0.39], |
| 1676 |
missed_constraint_color: [1,0.57,0.14] |
| 1677 |
}, |
| 1678 |
predicate: func(nd, layer) { |
| 1679 |
var visible= (nd.in_mode('toggle_display_mode', ['MAP','PLAN'])); |
| 1680 |
layer.group.setVisible( visible ); |
| 1681 |
if (visible) { |
| 1682 |
layer.toggle_cstr = nd.get_switch('toggle_cstr'); |
| 1683 |
layer.update(); |
| 1684 |
} |
| 1685 |
}, # end of layer update predicate |
| 1686 |
options: { |
| 1687 |
listen: [ |
| 1688 |
'fplan_active', |
| 1689 |
'lat_ctrl', |
| 1690 |
'ver_ctrl', |
| 1691 |
'current_wp', |
| 1692 |
'wp_count', |
| 1693 |
'dep_rwy', |
| 1694 |
'dest_rwy', |
| 1695 |
'level_off_alt' |
| 1696 |
], |
| 1697 |
} |
| 1698 |
}, # end of WPT layer |
| 1699 |
{ |
| 1700 |
name: 'SPD-profile', |
| 1701 |
isMapStructure: 1, |
| 1702 |
update_on: ['toggle_display_mode','toggle_range',{rate_hz: 2}], |
| 1703 |
predicate: func(nd, layer) { |
| 1704 |
var visible = nd.in_mode('toggle_display_mode', ['MAP', 'PLAN']); |
| 1705 |
layer.group.setVisible( visible ); |
| 1706 |
if (visible) { |
| 1707 |
layer.update(); |
| 1708 |
} |
| 1709 |
}, |
| 1710 |
style: { |
| 1711 |
color: [0.69,0,0.39] |
| 1712 |
}, |
| 1713 |
options: { |
| 1714 |
spd_node: "/autopilot/route-manager/spd/", |
| 1715 |
listen: [ |
| 1716 |
'fplan_active' |
| 1717 |
] |
| 1718 |
} |
| 1719 |
}, |
| 1720 |
{ |
| 1721 |
name: 'DECEL', |
| 1722 |
isMapStructure: 1, |
| 1723 |
update_on: ['toggle_display_mode','toggle_range'], |
| 1724 |
predicate: func(nd, layer) { |
| 1725 |
var visible = nd.in_mode('toggle_display_mode', ['MAP', 'PLAN']); |
| 1726 |
layer.group.setVisible( visible ); |
| 1727 |
if (visible) { |
| 1728 |
layer.update(); |
| 1729 |
} |
| 1730 |
}, |
| 1731 |
options: { |
| 1732 |
# Overridable options: |
| 1733 |
# decel_node: node containing latitude-deg and longitude-deg used to mark the deceleration point |
| 1734 |
# managed_speed_node: boolean property indicating that the aircraft is flying in managed speed mode |
| 1735 |
listen: [ |
| 1736 |
'fplan_active', |
| 1737 |
'spd_ctrl', |
| 1738 |
'ver_ctrl', |
| 1739 |
'athr' |
| 1740 |
] |
| 1741 |
}, |
| 1742 |
style: { |
| 1743 |
# managed_color: decelaration symbol color when the aircraft flies in managed speed mode |
| 1744 |
# selected_color: decelaration symbol color when the aircraft flies in selected speed mode |
| 1745 |
managed_color: [0.68, 0, 0.38], |
| 1746 |
selected_color: [1,1,1] |
| 1747 |
} |
| 1748 |
}, |
| 1749 |
{ |
| 1750 |
name:'APS', |
| 1751 |
isMapStructure:1, |
| 1752 |
always_update: 1, |
| 1753 |
update_on:['toggle_display_mode'], |
| 1754 |
predicate: func(nd, layer) { |
| 1755 |
var visible = nd.get_switch('toggle_display_mode') == "PLAN"; |
| 1756 |
layer.group.setVisible( visible ); |
| 1757 |
if (visible) { |
| 1758 |
layer.update(); |
| 1759 |
} |
| 1760 |
}, |
| 1761 |
style: { |
| 1762 |
svg_path: 'Nasal/canvas/map/Airbus/Images/airbusAirplane.svg', |
| 1763 |
#translate: [-45,-52] |
| 1764 |
}, |
| 1765 |
options: { |
| 1766 |
model: { |
| 1767 |
parents: [geo.Coord], |
| 1768 |
id: 999999, |
| 1769 |
pos: props.globals.getNode('position'), |
| 1770 |
type: 'position', |
| 1771 |
latlon: func(){ |
| 1772 |
me.pos = props.globals.getNode('position'); |
| 1773 |
return [ |
| 1774 |
me.pos.getValue("latitude-deg"), |
| 1775 |
me.pos.getValue("longitude-deg"), |
| 1776 |
me.pos.getValue("altitude-ft") |
| 1777 |
]; |
| 1778 |
}, |
| 1779 |
equals: func(o){me.id == o.id} |
| 1780 |
}, |
| 1781 |
init_after_callback: func{ |
| 1782 |
var aplSymbol = me.element.getElementById("airplane"); |
| 1783 |
aplSymbol.setTranslation(-45,-52); |
| 1784 |
} |
| 1785 |
} |
| 1786 |
}, |
| 1787 |
# end of storms/WXR layer |
| 1788 |
## add other layers here, layer names must match the registered names as used in *.layer files for now |
| 1789 |
## this will all change once we're using Philosopher's MapStructure framework |
| 1790 |
|
| 1791 |
], # end of vector with configured layers |
| 1792 |
|
| 1793 |
# This is where SVG elements are configured by providing "behavior" hashes, i.e. for animations |
| 1794 |
|
| 1795 |
# to animate each SVG symbol, specify behavior via callbacks (predicate, and true/false implementation) |
| 1796 |
# SVG identifier, callback etc |
| 1797 |
# TODO: update_on([]), update_mode (update() vs. timers/listeners) |
| 1798 |
# TODO: support putting symbols on specific layers |
| 1799 |
features: [ |
| 1800 |
{ |
| 1801 |
id: 'compass_mask', |
| 1802 |
impl: { |
| 1803 |
init: func(nd, symbol), |
| 1804 |
predicate: func(nd) !nd.get_switch('toggle_centered'), |
| 1805 |
is_true: func(nd) nd.symbols.compass_mask.show(), |
| 1806 |
is_false: func(nd) nd.symbols.compass_mask.hide(), |
| 1807 |
} |
| 1808 |
}, |
| 1809 |
{ |
| 1810 |
id: 'compass_mask_ctr', |
| 1811 |
impl: { |
| 1812 |
init: func(nd, symbol), |
| 1813 |
predicate: func(nd) nd.get_switch('toggle_centered') or nd.in_mode('toggle_display_mode',['PLAN']), |
| 1814 |
is_true: func(nd) nd.symbols.compass_mask_ctr.show(), |
| 1815 |
is_false: func(nd) nd.symbols.compass_mask_ctr.hide(), |
| 1816 |
} |
| 1817 |
}, |
| 1818 |
{ |
| 1819 |
# TODO: taOnly doesn't need to use getprop polling in update(), use a listener instead! |
| 1820 |
id: 'taOnly', # the SVG ID |
| 1821 |
impl: { # implementation hash |
| 1822 |
init: func(nd, symbol), # for updateCenter stuff, called during initialization in the ctor |
| 1823 |
predicate: func(nd) getprop("instrumentation/tcas/inputs/mode") == 2, # the condition |
| 1824 |
is_true: func(nd) nd.symbols.taOnly.show(), # if true, run this |
| 1825 |
is_false: func(nd) nd.symbols.taOnly.hide(), # if false, run this |
| 1826 |
}, # end of taOnly behavior/callbacks |
| 1827 |
}, # end of taOnly |
| 1828 |
{ |
| 1829 |
id: 'tas', |
| 1830 |
impl: { |
| 1831 |
init: func(nd,symbol), |
| 1832 |
predicate: func(nd) nd.aircraft_source.get_spd() > 100, |
| 1833 |
is_true: func(nd) { |
| 1834 |
nd.symbols.tas.setText(sprintf("%3.0f",getprop("/velocities/airspeed-kt") )); |
| 1835 |
nd.symbols.tas.show(); |
| 1836 |
}, |
| 1837 |
is_false: func(nd) nd.symbols.tas.hide(), |
| 1838 |
}, |
| 1839 |
}, |
| 1840 |
{ |
| 1841 |
id: 'tasLbl', |
| 1842 |
impl: { |
| 1843 |
init: func(nd,symbol), |
| 1844 |
predicate: func(nd) nd.aircraft_source.get_spd() > 100, |
| 1845 |
is_true: func(nd) nd.symbols.tasLbl.show(), |
| 1846 |
is_false: func(nd) nd.symbols.tasLbl.hide(), |
| 1847 |
}, |
| 1848 |
}, |
| 1849 |
{ |
| 1850 |
id: 'ilsFreq', |
| 1851 |
impl: { |
| 1852 |
init: func(nd,symbol), |
| 1853 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP', 'VOR']), |
| 1854 |
is_true: func(nd) { |
| 1855 |
nd.symbols.ilsFreq.show(); |
| 1856 |
nd.symbols.ilsFreq.setText(getprop("instrumentation/nav/frequencies/selected-mhz-fmt")); |
| 1857 |
if(nd.get_switch('toggle_display_mode') == 'APP') |
| 1858 |
nd.symbols.ilsFreq.setColor(0.69,0,0.39); |
| 1859 |
else |
| 1860 |
nd.symbols.ilsFreq.setColor(1,1,1); |
| 1861 |
}, |
| 1862 |
is_false: func(nd) nd.symbols.ilsFreq.hide(), |
| 1863 |
}, |
| 1864 |
}, |
| 1865 |
{ |
| 1866 |
id: 'ilsLbl', |
| 1867 |
impl: { |
| 1868 |
init: func(nd,symbol), |
| 1869 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP', 'VOR']), |
| 1870 |
is_true: func(nd) { |
| 1871 |
nd.symbols.ilsLbl.show(); |
| 1872 |
if(nd.get_switch('toggle_display_mode') == 'APP') |
| 1873 |
nd.symbols.ilsLbl.setText('ILS'); |
| 1874 |
else |
| 1875 |
nd.symbols.ilsLbl.setText('VOR 1'); |
| 1876 |
}, |
| 1877 |
is_false: func(nd) nd.symbols.ilsLbl.hide(), |
| 1878 |
}, |
| 1879 |
}, |
| 1880 |
{ |
| 1881 |
id: 'wpActiveId', |
| 1882 |
impl: { |
| 1883 |
init: func(nd,symbol), |
| 1884 |
predicate: func(nd) getprop("/autopilot/route-manager/wp/id") != nil and |
| 1885 |
getprop("autopilot/route-manager/active") and |
| 1886 |
nd.in_mode('toggle_display_mode', ['MAP', 'PLAN']), |
| 1887 |
is_true: func(nd) { |
| 1888 |
nd.symbols.wpActiveId.setText(getprop("/autopilot/route-manager/wp/id")); |
| 1889 |
nd.symbols.wpActiveId.show(); |
| 1890 |
}, |
| 1891 |
is_false: func(nd) nd.symbols.wpActiveId.hide(), |
| 1892 |
}, # of wpActiveId.impl |
| 1893 |
}, # of wpActiveId |
| 1894 |
{ |
| 1895 |
id: 'wpActiveCrs', |
| 1896 |
impl: { |
| 1897 |
init: func(nd,symbol), |
| 1898 |
predicate: func(nd) getprop("/autopilot/route-manager/wp/id") != nil and |
| 1899 |
getprop("autopilot/route-manager/active") and |
| 1900 |
nd.in_mode('toggle_display_mode', ['MAP', 'PLAN']), |
| 1901 |
is_true: func(nd) { |
| 1902 |
#var cur_wp = getprop("autopilot/route-manager/current-wp"); |
| 1903 |
var deg = int(getprop("/autopilot/route-manager/wp/bearing-deg")); |
| 1904 |
nd.symbols.wpActiveCrs.setText(''~deg~'°'); |
| 1905 |
nd.symbols.wpActiveCrs.show(); |
| 1906 |
}, |
| 1907 |
is_false: func(nd) nd.symbols.wpActiveCrs.hide(), |
| 1908 |
}, # of wpActiveId.impl |
| 1909 |
}, # of wpActiveId |
| 1910 |
{ |
| 1911 |
id: 'wpActiveDist', |
| 1912 |
impl: { |
| 1913 |
init: func(nd,symbol), |
| 1914 |
predicate: func(nd) getprop("/autopilot/route-manager/wp/dist") != nil and |
| 1915 |
getprop("autopilot/route-manager/active") and |
| 1916 |
nd.in_mode('toggle_display_mode', ['MAP', 'PLAN']), |
| 1917 |
is_true: func(nd) { |
| 1918 |
var dst = getprop("/autopilot/route-manager/wp/dist"); |
| 1919 |
nd.symbols.wpActiveDist.setText(sprintf("%3.01f",dst)); |
| 1920 |
nd.symbols.wpActiveDist.show(); |
| 1921 |
}, |
| 1922 |
is_false: func(nd) nd.symbols.wpActiveDist.hide(), |
| 1923 |
}, |
| 1924 |
}, |
| 1925 |
{ |
| 1926 |
id: 'wpActiveDistLbl', |
| 1927 |
impl: { |
| 1928 |
init: func(nd,symbol), |
| 1929 |
predicate: func(nd) getprop("/autopilot/route-manager/wp/dist") != nil and getprop("autopilot/route-manager/active") and nd.in_mode('toggle_display_mode', ['MAP', 'PLAN']), |
| 1930 |
is_true: func(nd) { |
| 1931 |
nd.symbols.wpActiveDistLbl.show(); |
| 1932 |
if(getprop("/autopilot/route-manager/wp/dist") > 1000) |
| 1933 |
nd.symbols.wpActiveDistLbl.setText(" NM"); |
| 1934 |
}, |
| 1935 |
is_false: func(nd) nd.symbols.wpActiveDistLbl.hide(), |
| 1936 |
}, |
| 1937 |
}, |
| 1938 |
{ |
| 1939 |
id: 'eta', |
| 1940 |
impl: { |
| 1941 |
init: func(nd,symbol), |
| 1942 |
predicate: func(nd) getprop("autopilot/route-manager/wp/eta") != nil and getprop("autopilot/route-manager/active") and nd.in_mode('toggle_display_mode', ['MAP', 'PLAN']), |
| 1943 |
is_true: func(nd) { |
| 1944 |
var etaSec = getprop("/sim/time/utc/day-seconds")+ |
| 1945 |
getprop("autopilot/route-manager/wp/eta-seconds"); |
| 1946 |
var h = math.floor(etaSec/3600); |
| 1947 |
etaSec = etaSec-3600*h; |
| 1948 |
var m = math.floor(etaSec/60); |
| 1949 |
etaSec = etaSec-60*m; |
| 1950 |
var s = etaSec / 10; |
| 1951 |
if (h > 24) h = h - 24; |
| 1952 |
nd.symbols.eta.setText(sprintf("%02.0f:%02.0f",h,m)); |
| 1953 |
nd.symbols.eta.show(); |
| 1954 |
}, |
| 1955 |
is_false: func(nd) nd.symbols.eta.hide(), |
| 1956 |
}, # of eta.impl |
| 1957 |
}, # of eta |
| 1958 |
{ |
| 1959 |
id: 'gsGroup', |
| 1960 |
impl: { |
| 1961 |
init: func(nd,symbol), |
| 1962 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP']), |
| 1963 |
is_true: func(nd) { |
| 1964 |
if(nd.get_switch('toggle_centered')) |
| 1965 |
nd.symbols.gsGroup.setTranslation(0,0); |
| 1966 |
else |
| 1967 |
nd.symbols.gsGroup.setTranslation(0,150); |
| 1968 |
nd.symbols.gsGroup.show(); |
| 1969 |
}, |
| 1970 |
is_false: func(nd) nd.symbols.gsGroup.hide(), |
| 1971 |
}, |
| 1972 |
}, |
| 1973 |
{ |
| 1974 |
id:'hdg', |
| 1975 |
impl: { |
| 1976 |
init: func(nd,symbol), |
| 1977 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','MAP','VOR']), |
| 1978 |
is_true: func(nd) { |
| 1979 |
var hdgText = ""; |
| 1980 |
if(nd.in_mode('toggle_display_mode', ['MAP'])) { |
| 1981 |
if(nd.get_switch('toggle_true_north')) |
| 1982 |
hdgText = nd.aircraft_source.get_trk_tru(); |
| 1983 |
else |
| 1984 |
hdgText = nd.aircraft_source.get_trk_mag(); |
| 1985 |
} else { |
| 1986 |
if(nd.get_switch('toggle_true_north')) |
| 1987 |
hdgText = nd.aircraft_source.get_hdg_tru(); |
| 1988 |
else |
| 1989 |
hdgText = nd.aircraft_source.get_hdg_mag(); |
| 1990 |
} |
| 1991 |
nd.symbols.hdg.setText(sprintf("%03.0f", hdgText+0.5)); |
| 1992 |
}, |
| 1993 |
is_false: NOTHING, |
| 1994 |
}, |
| 1995 |
}, |
| 1996 |
{ |
| 1997 |
id:'hdgGroup', |
| 1998 |
impl: { |
| 1999 |
init: func(nd,symbol), |
| 2000 |
predicate: func(nd) {return 0},#nd.in_mode('toggle_display_mode', ['APP','MAP','VOR']), |
| 2001 |
is_true: func(nd) { |
| 2002 |
nd.symbols.hdgGroup.show(); |
| 2003 |
if(nd.get_switch('toggle_centered')) |
| 2004 |
nd.symbols.hdgGroup.setTranslation(0,100); |
| 2005 |
else |
| 2006 |
nd.symbols.hdgGroup.setTranslation(0,0); |
| 2007 |
}, |
| 2008 |
is_false: func(nd) nd.symbols.hdgGroup.hide(), |
| 2009 |
}, |
| 2010 |
}, |
| 2011 |
{ |
| 2012 |
id:'altArc', |
| 2013 |
impl: { |
| 2014 |
init: func(nd,symbol), |
| 2015 |
predicate: func(nd) {return 0},#nd.in_mode('toggle_display_mode', ['APP','MAP','VOR']), |
| 2016 |
is_true: func(nd) { |
| 2017 |
nd.symbols.altArc.show(); |
| 2018 |
}, |
| 2019 |
is_false: func(nd) nd.symbols.altArc.hide(), |
| 2020 |
}, |
| 2021 |
}, |
| 2022 |
{ |
| 2023 |
id:'gs', |
| 2024 |
impl: { |
| 2025 |
init: func(nd,symbol), |
| 2026 |
common: func(nd) nd.symbols.gs.setText(sprintf("%3.0f",nd.aircraft_source.get_gnd_spd() )), |
| 2027 |
predicate: func(nd) nd.aircraft_source.get_gnd_spd() >= 30, |
| 2028 |
is_true: func(nd) { |
| 2029 |
#nd.symbols.gs.show(); |
| 2030 |
nd.symbols.gs.setFontSize(36); |
| 2031 |
}, |
| 2032 |
is_false: func(nd) {},#nd.symbols.gs.hide(), |
| 2033 |
}, |
| 2034 |
}, |
| 2035 |
{ |
| 2036 |
id:'compass', |
| 2037 |
impl: { |
| 2038 |
init: func(nd,symbol), |
| 2039 |
predicate: func(nd) (!nd.get_switch('toggle_centered') and nd.get_switch('toggle_display_mode') != "PLAN"), |
| 2040 |
is_true: func(nd) { |
| 2041 |
nd.symbols.compass.setRotation(-nd.userHdgTrk*D2R); |
| 2042 |
nd.symbols.compass.show() |
| 2043 |
}, |
| 2044 |
is_false: func(nd) nd.symbols.compass.hide(), |
| 2045 |
}, # of compass.impl |
| 2046 |
}, # of compass |
| 2047 |
{ |
| 2048 |
id:'compassApp', |
| 2049 |
impl: { |
| 2050 |
init: func(nd,symbol), |
| 2051 |
predicate: func(nd) (nd.get_switch('toggle_centered') and nd.get_switch('toggle_display_mode') != "PLAN"), |
| 2052 |
is_true: func(nd) { |
| 2053 |
nd.symbols.compassApp.setRotation(-nd.userHdgTrk*D2R); |
| 2054 |
nd.symbols.compassApp.show() |
| 2055 |
}, |
| 2056 |
is_false: func(nd) nd.symbols.compassApp.hide(), |
| 2057 |
}, # of compassApp.impl |
| 2058 |
}, # of compassApp |
| 2059 |
{ |
| 2060 |
id:'northUp', |
| 2061 |
impl: { |
| 2062 |
init: func(nd,symbol), |
| 2063 |
predicate: func(nd) nd.get_switch('toggle_display_mode') == "PLAN", |
| 2064 |
is_true: func(nd) nd.symbols.northUp.show(), |
| 2065 |
is_false: func(nd) nd.symbols.northUp.hide(), |
| 2066 |
}, # of northUp.impl |
| 2067 |
}, # of northUp |
| 2068 |
{ |
| 2069 |
id:'planArcs', |
| 2070 |
impl: { |
| 2071 |
init: func(nd,symbol), |
| 2072 |
predicate: func(nd) ((nd.in_mode('toggle_display_mode', ['APP','VOR','PLAN'])) or ((nd.get_switch('toggle_display_mode') == "MAP") and (nd.get_switch('toggle_centered')))), |
| 2073 |
is_true: func(nd) nd.symbols.planArcs.show(), |
| 2074 |
is_false: func(nd) nd.symbols.planArcs.hide(), |
| 2075 |
}, # of planArcs.impl |
| 2076 |
}, # of planArcs |
| 2077 |
{ |
| 2078 |
id:'rangeArcs', |
| 2079 |
impl: { |
| 2080 |
init: func(nd,symbol), |
| 2081 |
predicate: func(nd) ((nd.get_switch('toggle_display_mode') == "MAP") and (!nd.get_switch('toggle_centered'))), |
| 2082 |
is_true: func(nd) nd.symbols.rangeArcs.show(), |
| 2083 |
is_false: func(nd) nd.symbols.rangeArcs.hide(), |
| 2084 |
}, # of rangeArcs.impl |
| 2085 |
}, # of rangeArcs |
| 2086 |
{ |
| 2087 |
id:'rangePln1', |
| 2088 |
impl: { |
| 2089 |
init: func(nd,symbol), |
| 2090 |
predicate: func(nd) {return 0}, |
| 2091 |
is_true: func(nd) { |
| 2092 |
nd.symbols.rangePln1.show(); |
| 2093 |
nd.symbols.rangePln1.setText(sprintf("%3.0f",nd.rangeNm())); |
| 2094 |
}, |
| 2095 |
is_false: func(nd) nd.symbols.rangePln1.hide(), |
| 2096 |
}, |
| 2097 |
}, |
| 2098 |
{ |
| 2099 |
id:'rangePln2', |
| 2100 |
impl: { |
| 2101 |
init: func(nd,symbol), |
| 2102 |
predicate: func(nd) nd.get_switch('toggle_display_mode') == "MAP" and !nd.get_switch('toggle_centered'), |
| 2103 |
is_true: func(nd) { |
| 2104 |
nd.symbols.rangePln2.show(); |
| 2105 |
nd.symbols.rangePln2.setText(sprintf("%3.0f",(nd.rangeNm()/2) + (nd.rangeNm()/4))); |
| 2106 |
}, |
| 2107 |
is_false: func(nd) nd.symbols.rangePln2.hide(), |
| 2108 |
}, |
| 2109 |
}, |
| 2110 |
{ |
| 2111 |
id:'rangePln3', |
| 2112 |
impl: { |
| 2113 |
init: func(nd,symbol), |
| 2114 |
predicate: func(nd) nd.get_switch('toggle_display_mode') == "PLAN" or nd.get_switch('toggle_centered'), |
| 2115 |
is_true: func(nd) { |
| 2116 |
nd.symbols.rangePln3.show(); |
| 2117 |
nd.symbols.rangePln3.setText(sprintf("%3.0f",nd.rangeNm()/2)); |
| 2118 |
}, |
| 2119 |
is_false: func(nd) nd.symbols.rangePln3.hide(), |
| 2120 |
}, |
| 2121 |
}, |
| 2122 |
{ |
| 2123 |
id:'rangePln4', |
| 2124 |
impl: { |
| 2125 |
init: func(nd,symbol), |
| 2126 |
predicate: func(nd) nd.get_switch('toggle_display_mode') == "PLAN" or nd.get_switch('toggle_centered'), |
| 2127 |
is_true: func(nd) { |
| 2128 |
nd.symbols.rangePln4.show(); |
| 2129 |
nd.symbols.rangePln4.setText(sprintf("%3.0f",nd.rangeNm())); |
| 2130 |
}, |
| 2131 |
is_false: func(nd) nd.symbols.rangePln4.hide(), |
| 2132 |
}, |
| 2133 |
}, |
| 2134 |
{ |
| 2135 |
id:'rangePln5', |
| 2136 |
impl: { |
| 2137 |
init: func(nd,symbol), |
| 2138 |
predicate: func(nd) nd.get_switch('toggle_display_mode') == "MAP" and !nd.get_switch('toggle_centered'), |
| 2139 |
is_true: func(nd) { |
| 2140 |
nd.symbols.rangePln5.show(); |
| 2141 |
nd.symbols.rangePln5.setText(sprintf("%3.0f",(nd.rangeNm()/2) + (nd.rangeNm()/4))); |
| 2142 |
}, |
| 2143 |
is_false: func(nd) nd.symbols.rangePln5.hide(), |
| 2144 |
}, |
| 2145 |
}, |
| 2146 |
{ |
| 2147 |
id:'range', |
| 2148 |
impl: { |
| 2149 |
init: func(nd,symbol), |
| 2150 |
predicate: func(nd) !nd.get_switch('toggle_centered'), |
| 2151 |
is_true: func(nd) { |
| 2152 |
nd.symbols.range.show(); |
| 2153 |
nd.symbols.range.setText(sprintf("%3.0f",nd.rangeNm()/2)); |
| 2154 |
}, |
| 2155 |
is_false: func(nd) nd.symbols.range.hide(), |
| 2156 |
}, |
| 2157 |
}, |
| 2158 |
{ |
| 2159 |
id:'range_r', |
| 2160 |
impl: { |
| 2161 |
init: func(nd,symbol), |
| 2162 |
predicate: func(nd) !nd.get_switch('toggle_centered'), |
| 2163 |
is_true: func(nd) { |
| 2164 |
nd.symbols.range_r.show(); |
| 2165 |
nd.symbols.range_r.setText(sprintf("%3.0f",nd.rangeNm()/2)); |
| 2166 |
}, |
| 2167 |
is_false: func(nd) nd.symbols.range_r.hide(), |
| 2168 |
}, |
| 2169 |
}, |
| 2170 |
{ |
| 2171 |
id:'aplSymMap', |
| 2172 |
impl: { |
| 2173 |
init: func(nd,symbol), |
| 2174 |
predicate: func(nd) (nd.get_switch('toggle_display_mode') == "MAP" and !nd.get_switch('toggle_centered')), |
| 2175 |
is_true: func(nd) { |
| 2176 |
nd.symbols.aplSymMap.set('z-index', 10); |
| 2177 |
nd.symbols.aplSymMap.show(); |
| 2178 |
|
| 2179 |
}, |
| 2180 |
is_false: func(nd) nd.symbols.aplSymMap.hide(), |
| 2181 |
}, |
| 2182 |
}, |
| 2183 |
{ |
| 2184 |
id:'aplSymMapCtr', |
| 2185 |
impl: { |
| 2186 |
init: func(nd,symbol), |
| 2187 |
predicate: func(nd) ((nd.get_switch('toggle_display_mode') == "MAP" and nd.get_switch('toggle_centered')) or nd.in_mode('toggle_display_mode', ['APP','VOR'])), |
| 2188 |
is_true: func(nd) { |
| 2189 |
nd.symbols.aplSymMapCtr.set('z-index', 10); |
| 2190 |
nd.symbols.aplSymMapCtr.show(); |
| 2191 |
|
| 2192 |
}, |
| 2193 |
is_false: func(nd) nd.symbols.aplSymMapCtr.hide(), |
| 2194 |
}, |
| 2195 |
}, |
| 2196 |
{ |
| 2197 |
id:'aplSymVor', |
| 2198 |
impl: { |
| 2199 |
init: func(nd,symbol), |
| 2200 |
predicate: func(nd) {return 0;}, |
| 2201 |
is_true: func(nd) { |
| 2202 |
nd.symbols.aplSymVor.show(); |
| 2203 |
}, |
| 2204 |
is_false: func(nd) nd.symbols.aplSymVor.hide(), |
| 2205 |
}, |
| 2206 |
}, |
| 2207 |
{ |
| 2208 |
id:'crsLbl', |
| 2209 |
impl: { |
| 2210 |
init: func(nd,symbol), |
| 2211 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','VOR']), |
| 2212 |
is_true: func(nd) nd.symbols.crsLbl.show(), |
| 2213 |
is_false: func(nd) nd.symbols.crsLbl.hide(), |
| 2214 |
}, |
| 2215 |
}, |
| 2216 |
{ |
| 2217 |
id:'crs', |
| 2218 |
impl: { |
| 2219 |
init: func(nd,symbol), |
| 2220 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','VOR']), |
| 2221 |
is_true: func(nd) { |
| 2222 |
nd.symbols.crs.show(); |
| 2223 |
if(getprop("instrumentation/nav/radials/selected-deg") != nil) |
| 2224 |
nd.symbols.crs.setText(sprintf("%03.0f",getprop("instrumentation/nav/radials/selected-deg"))); |
| 2225 |
}, |
| 2226 |
is_false: func(nd) nd.symbols.crs.hide(), |
| 2227 |
}, |
| 2228 |
}, |
| 2229 |
{ |
| 2230 |
id:'dmeLbl', |
| 2231 |
impl: { |
| 2232 |
init: func(nd,symbol), |
| 2233 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','VOR']), |
| 2234 |
is_true: func(nd) nd.symbols.dmeLbl.show(), |
| 2235 |
is_false: func(nd) nd.symbols.dmeLbl.hide(), |
| 2236 |
}, |
| 2237 |
}, |
| 2238 |
{ |
| 2239 |
id:'dme', |
| 2240 |
impl: { |
| 2241 |
init: func(nd,symbol), |
| 2242 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP','VOR']), |
| 2243 |
is_true: func(nd) { |
| 2244 |
nd.symbols.dme.show(); |
| 2245 |
nd.symbols.dme.setText(getprop("instrumentation/nav/nav-id")); |
| 2246 |
if(nd.get_switch('toggle_display_mode') == 'APP') |
| 2247 |
nd.symbols.dme.setColor(0.69,0,0.39); |
| 2248 |
else |
| 2249 |
nd.symbols.dme.setColor(1,1,1); |
| 2250 |
}, |
| 2251 |
is_false: func(nd) nd.symbols.dme.hide(), |
| 2252 |
}, |
| 2253 |
}, |
| 2254 |
{ |
| 2255 |
id:'trkline', |
| 2256 |
impl: { |
| 2257 |
init: func(nd,symbol), |
| 2258 |
predicate: func(nd){ |
| 2259 |
nd.get_switch('toggle_display_mode') == 'MAP' and |
| 2260 |
!nd.get_switch('toggle_centered') and |
| 2261 |
( |
| 2262 |
getprop(nd.options.defaults.lat_ctrl) != nd.options.defaults.managed_val or |
| 2263 |
nd.get_switch('toggle_trk_line') |
| 2264 |
) |
| 2265 |
}, |
| 2266 |
is_true: func(nd) { |
| 2267 |
nd.symbols.trkline.show(); |
| 2268 |
}, |
| 2269 |
is_false: func(nd) nd.symbols.trkline.hide(), |
| 2270 |
}, |
| 2271 |
}, |
| 2272 |
{ |
| 2273 |
id:'trkInd2', |
| 2274 |
impl: { |
| 2275 |
init: func(nd,symbol), |
| 2276 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR','MAP']) and |
| 2277 |
nd.get_switch('toggle_centered')), |
| 2278 |
is_true: func(nd) { |
| 2279 |
nd.symbols.trkInd2.show(); |
| 2280 |
nd.symbols.trkInd2.setRotation((nd.aircraft_source.get_trk_mag()-nd.aircraft_source.get_hdg_mag())*D2R); |
| 2281 |
}, |
| 2282 |
is_false: func(nd) nd.symbols.trkInd2.hide(), |
| 2283 |
}, |
| 2284 |
}, |
| 2285 |
{ |
| 2286 |
id:'trkline2', |
| 2287 |
impl: { |
| 2288 |
init: func(nd,symbol), |
| 2289 |
predicate: func(nd) (nd.get_switch('toggle_display_mode') == 'MAP' and |
| 2290 |
nd.get_switch('toggle_centered') and |
| 2291 |
getprop(nd.options.defaults.lat_ctrl) != nd.options.defaults.managed_val), |
| 2292 |
is_true: func(nd) { |
| 2293 |
nd.symbols.trkline2.show(); |
| 2294 |
}, |
| 2295 |
is_false: func(nd) nd.symbols.trkline2.hide(), |
| 2296 |
}, |
| 2297 |
}, |
| 2298 |
{ |
| 2299 |
id:'vorCrsPtr', |
| 2300 |
impl: { |
| 2301 |
init: func(nd,symbol), |
| 2302 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and !nd.get_switch('toggle_centered')), |
| 2303 |
is_true: func(nd) { |
| 2304 |
nd.symbols.vorCrsPtr.show(); |
| 2305 |
nd.symbols.vorCrsPtr.setRotation((getprop("instrumentation/nav/radials/selected-deg")-nd.aircraft_source.get_hdg_tru())*D2R); |
| 2306 |
|
| 2307 |
}, |
| 2308 |
is_false: func(nd) nd.symbols.vorCrsPtr.hide(), |
| 2309 |
}, |
| 2310 |
}, |
| 2311 |
{ |
| 2312 |
id:'vorCrsPtr2', |
| 2313 |
impl: { |
| 2314 |
init: func(nd,symbol), |
| 2315 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and nd.get_switch('toggle_centered')), |
| 2316 |
is_true: func(nd) { |
| 2317 |
nd.symbols.vorCrsPtr2.show(); |
| 2318 |
nd.symbols.vorCrsPtr2.setRotation((getprop("instrumentation/nav/radials/selected-deg")-nd.aircraft_source.get_hdg_tru())*D2R); |
| 2319 |
var line = nd.symbols.vorCrsPtr2.getElementById('vorCrsPtr2_line'); |
| 2320 |
if(nd.get_switch('toggle_display_mode') == 'VOR'){ |
| 2321 |
line.setColor(0,0.62,0.84); |
| 2322 |
line.setColorFill(0,0.62,0.84); |
| 2323 |
} else { |
| 2324 |
line.setColor(0.9,0,0.47); |
| 2325 |
line.setColorFill(0.9,0,0.47); |
| 2326 |
} |
| 2327 |
}, |
| 2328 |
is_false: func(nd) nd.symbols.vorCrsPtr2.hide(), |
| 2329 |
}, |
| 2330 |
}, |
| 2331 |
{ |
| 2332 |
id: 'gsDiamond', |
| 2333 |
impl: { |
| 2334 |
init: func(nd,symbol), |
| 2335 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['APP']), |
| 2336 |
is_true: func(nd) { |
| 2337 |
if(getprop("instrumentation/nav/gs-needle-deflection-norm") != nil) |
| 2338 |
nd.symbols.gsDiamond.setTranslation(getprop("instrumentation/nav/gs-needle-deflection-norm")*150,0); |
| 2339 |
}, |
| 2340 |
is_false: func(nd) nd.symbols.gsGroup.hide(), |
| 2341 |
}, |
| 2342 |
}, |
| 2343 |
{ |
| 2344 |
id:'locPtr', |
| 2345 |
impl: { |
| 2346 |
init: func(nd,symbol), |
| 2347 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and !nd.get_switch('toggle_centered') and getprop("instrumentation/nav/in-range")), |
| 2348 |
is_true: func(nd) { |
| 2349 |
nd.symbols.locPtr.show(); |
| 2350 |
var deflection = getprop("instrumentation/nav/heading-needle-deflection-norm"); |
| 2351 |
nd.symbols.locPtr.setTranslation(deflection*150,0); |
| 2352 |
}, |
| 2353 |
is_false: func(nd) nd.symbols.locPtr.hide(), |
| 2354 |
}, |
| 2355 |
}, |
| 2356 |
{ |
| 2357 |
id:'locPtr2', |
| 2358 |
impl: { |
| 2359 |
init: func(nd,symbol), |
| 2360 |
predicate: func(nd) (nd.in_mode('toggle_display_mode', ['APP','VOR']) and nd.get_switch('toggle_centered') and getprop("instrumentation/nav/in-range")), |
| 2361 |
is_true: func(nd) { |
| 2362 |
var curmode = nd.get_switch('toggle_display_mode'); |
| 2363 |
var ils_mode = getprop('/flight-management/freq/ils-mode'); |
| 2364 |
if((ils_mode and curmode == 'VOR') or (!ils_mode and curmode == 'APP')){ |
| 2365 |
nd.symbols.locPtr2.hide(); |
| 2366 |
return; |
| 2367 |
} |
| 2368 |
nd.symbols.locPtr2.show(); |
| 2369 |
var deflection = getprop("instrumentation/nav/heading-needle-deflection-norm"); |
| 2370 |
nd.symbols.locPtr2.setTranslation(deflection*150,0); |
| 2371 |
var line = nd.symbols.locPtr2.getElementById('locPtr2_line'); |
| 2372 |
var arr1 = nd.symbols.locPtr2.getElementById('locPtr2_arr1'); |
| 2373 |
var arr2 = nd.symbols.locPtr2.getElementById('locPtr2_arr2'); |
| 2374 |
if(curmode == 'VOR'){ |
| 2375 |
#nd.symbols.vorCrsPtr2.setColor(0,0.62,0.84); |
| 2376 |
line.setColor(0,0.62,0.84); |
| 2377 |
line.setColorFill(0,0.62,0.84); |
| 2378 |
arr1.show(); |
| 2379 |
arr2.show(); |
| 2380 |
} else { |
| 2381 |
line.setColor(0.9,0,0.47); |
| 2382 |
line.setColorFill(0.9,0,0.47); |
| 2383 |
arr1.hide(); |
| 2384 |
arr2.hide(); |
| 2385 |
} |
| 2386 |
}, |
| 2387 |
is_false: func(nd) nd.symbols.locPtr2.hide(), |
| 2388 |
}, |
| 2389 |
}, |
| 2390 |
{ |
| 2391 |
id:'wind', |
| 2392 |
impl: { |
| 2393 |
init: func(nd,symbol), |
| 2394 |
predicate: ALWAYS, |
| 2395 |
is_true: func(nd) { |
| 2396 |
var windDir = getprop("environment/wind-from-heading-deg"); |
| 2397 |
if(!nd.get_switch('toggle_true_north')) |
| 2398 |
windDir = windDir + getprop("environment/magnetic-variation-deg"); |
| 2399 |
nd.symbols.wind.setText(sprintf("%03.0f / %02.0f",windDir,getprop("environment/wind-speed-kt"))); |
| 2400 |
}, |
| 2401 |
is_false: NOTHING, |
| 2402 |
}, |
| 2403 |
}, |
| 2404 |
{ |
| 2405 |
id:'windArrow', |
| 2406 |
impl: { |
| 2407 |
init: func(nd,symbol), |
| 2408 |
predicate: func(nd) (!(nd.in_mode('toggle_display_mode', ['PLAN']) and (nd.get_switch('toggle_display_type') == "LCD"))), |
| 2409 |
is_true: func(nd) { |
| 2410 |
nd.symbols.windArrow.show(); |
| 2411 |
var windArrowRot = getprop("environment/wind-from-heading-deg") - getprop("environment/magnetic-variation-deg"); |
| 2412 |
if(nd.in_mode('toggle_display_mode', ['MAP','PLAN'])) { |
| 2413 |
if(nd.get_switch('toggle_true_north')) |
| 2414 |
windArrowRot = windArrowRot - nd.aircraft_source.get_trk_tru(); |
| 2415 |
else |
| 2416 |
windArrowRot = windArrowRot - nd.aircraft_source.get_trk_mag(); |
| 2417 |
} else { |
| 2418 |
if(nd.get_switch('toggle_true_north')) |
| 2419 |
windArrowRot = windArrowRot - nd.aircraft_source.get_hdg_tru(); |
| 2420 |
else |
| 2421 |
windArrowRot = windArrowRot - nd.aircraft_source.get_hdg_mag(); |
| 2422 |
} |
| 2423 |
nd.symbols.windArrow.setRotation(windArrowRot*D2R); |
| 2424 |
}, |
| 2425 |
is_false: func(nd) nd.symbols.windArrow.hide(), |
| 2426 |
}, |
| 2427 |
}, |
| 2428 |
{ |
| 2429 |
id:'staToL2', |
| 2430 |
impl: { |
| 2431 |
init: func(nd,symbol), |
| 2432 |
predicate: func(nd) !(nd.in_mode('toggle_display_mode', ['PLAN'])) and nd.get_switch('toggle_centered') and ((getprop("instrumentation/nav/in-range") and nd.get_switch('toggle_lh_vor_adf') == 1) or (getprop("instrumentation/adf/in-range") and nd.get_switch('toggle_lh_vor_adf') == -1)), |
| 2433 |
is_true: func(nd) { |
| 2434 |
if(nd.get_switch('toggle_lh_vor_adf') < 0){ |
| 2435 |
nd.symbols.staToL2.setColor(0.195,0.96,0.097); |
| 2436 |
nd.symbols.staFromL2.setColor(0.195,0.96,0.097); |
| 2437 |
} else { |
| 2438 |
nd.symbols.staToL2.setColor(1,1,1); |
| 2439 |
nd.symbols.staFromL2.setColor(1,1,1); |
| 2440 |
} |
| 2441 |
nd.symbols.staToL2.show(); |
| 2442 |
nd.symbols.staFromL2.show(); |
| 2443 |
}, |
| 2444 |
is_false: func(nd){ |
| 2445 |
nd.symbols.staToL2.hide(); |
| 2446 |
nd.symbols.staFromL2.hide(); |
| 2447 |
} |
| 2448 |
} |
| 2449 |
}, |
| 2450 |
{ |
| 2451 |
id:'staToR2', |
| 2452 |
impl: { |
| 2453 |
init: func(nd,symbol), |
| 2454 |
predicate: func(nd) !(nd.in_mode('toggle_display_mode', ['PLAN'])) and nd.get_switch('toggle_centered') and ((getprop("instrumentation/nav[1]/in-range") and nd.get_switch('toggle_rh_vor_adf') == 1) or (getprop("instrumentation/adf[1]/in-range") and nd.get_switch('toggle_rh_vor_adf') == -1)), |
| 2455 |
is_true: func(nd) { |
| 2456 |
if(nd.get_switch('toggle_rh_vor_adf') < 0){ |
| 2457 |
nd.symbols.staToR2.setColor(0.195,0.96,0.097); |
| 2458 |
nd.symbols.staFromR2.setColor(0.195,0.96,0.097); |
| 2459 |
} else { |
| 2460 |
nd.symbols.staToR2.setColor(1,1,1); |
| 2461 |
nd.symbols.staFromR2.setColor(1,1,1); |
| 2462 |
} |
| 2463 |
nd.symbols.staToR2.show(); |
| 2464 |
nd.symbols.staFromR2.show(); |
| 2465 |
}, |
| 2466 |
is_false: func(nd){ |
| 2467 |
nd.symbols.staToR2.hide(); |
| 2468 |
nd.symbols.staFromR2.hide(); |
| 2469 |
} |
| 2470 |
} |
| 2471 |
}, |
| 2472 |
{ |
| 2473 |
id:'staToL', |
| 2474 |
impl: { |
| 2475 |
init: func(nd,symbol), |
| 2476 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['MAP']) and !nd.get_switch('toggle_centered') and ((getprop("instrumentation/nav/in-range") and nd.get_switch('toggle_lh_vor_adf') == 1) or (getprop("instrumentation/adf/in-range") and nd.get_switch('toggle_lh_vor_adf') == -1)), |
| 2477 |
is_true: func(nd) { |
| 2478 |
if(nd.get_switch('toggle_lh_vor_adf') < 0){ |
| 2479 |
nd.symbols.staToL.setColor(0.195,0.96,0.097); |
| 2480 |
nd.symbols.staFromL.setColor(0.195,0.96,0.097); |
| 2481 |
} else { |
| 2482 |
nd.symbols.staToL.setColor(1,1,1); |
| 2483 |
nd.symbols.staFromL.setColor(1,1,1); |
| 2484 |
} |
| 2485 |
nd.symbols.staToL.show(); |
| 2486 |
nd.symbols.staFromL.show(); |
| 2487 |
}, |
| 2488 |
is_false: func(nd){ |
| 2489 |
nd.symbols.staToL.hide(); |
| 2490 |
nd.symbols.staFromL.hide(); |
| 2491 |
} |
| 2492 |
} |
| 2493 |
}, |
| 2494 |
{ |
| 2495 |
id:'staToR', |
| 2496 |
impl: { |
| 2497 |
init: func(nd,symbol), |
| 2498 |
predicate: func(nd) nd.in_mode('toggle_display_mode', ['MAP']) and !nd.get_switch('toggle_centered') and ((getprop("instrumentation/nav[1]/in-range") and nd.get_switch('toggle_rh_vor_adf') == 1) or (getprop("instrumentation/adf[1]/in-range") and nd.get_switch('toggle_rh_vor_adf') == -1)), |
| 2499 |
is_true: func(nd) { |
| 2500 |
if(nd.get_switch('toggle_rh_vor_adf') < 0){ |
| 2501 |
nd.symbols.staToR.setColor(0.195,0.96,0.097); |
| 2502 |
nd.symbols.staFromR.setColor(0.195,0.96,0.097); |
| 2503 |
} else { |
| 2504 |
nd.symbols.staToR.setColor(1,1,1); |
| 2505 |
nd.symbols.staFromR.setColor(1,1,1); |
| 2506 |
} |
| 2507 |
nd.symbols.staToR.show(); |
| 2508 |
nd.symbols.staFromR.show(); |
| 2509 |
}, |
| 2510 |
is_false: func(nd){ |
| 2511 |
nd.symbols.staToR.hide(); |
| 2512 |
nd.symbols.staFromR.hide(); |
| 2513 |
} |
| 2514 |
} |
| 2515 |
}, |
| 2516 |
{ |
| 2517 |
id:'dmeL', |
| 2518 |
impl: { |
| 2519 |
init: func(nd,symbol), |
| 2520 |
predicate: func(nd) (nd.get_switch('toggle_lh_vor_adf') != 0), |
| 2521 |
is_true: func(nd) { |
| 2522 |
nd.symbols.dmeL.show(); |
| 2523 |
if(nd.get_switch('toggle_lh_vor_adf') < 0){ |
| 2524 |
nd.symbols.vorL.setText("ADF 1"); |
| 2525 |
nd.symbols.vorL.setColor(0.195,0.96,0.097); |
| 2526 |
nd.symbols.vorLId.setColor(0.195,0.96,0.097); |
| 2527 |
nd.symbols.dmeLDist.setColor(0.195,0.96,0.097); |
| 2528 |
} |
| 2529 |
else{ |
| 2530 |
nd.symbols.vorL.setText("VOR 1"); |
| 2531 |
nd.symbols.vorL.setColor(1,1,1); |
| 2532 |
nd.symbols.vorLId.setColor(1,1,1); |
| 2533 |
nd.symbols.dmeLDist.setColor(1,1,1); |
| 2534 |
} |
| 2535 |
nd.symbols.dmeL.setText('NM'); |
| 2536 |
nd.symbols.dmeL.setColor(0,0.59,0.8); |
| 2537 |
}, |
| 2538 |
is_false: func(nd){ |
| 2539 |
nd.symbols.dmeL.hide(); |
| 2540 |
} |
| 2541 |
} |
| 2542 |
}, |
| 2543 |
{ |
| 2544 |
id:'dmeR', |
| 2545 |
impl: { |
| 2546 |
init: func(nd,symbol), |
| 2547 |
predicate: func(nd) (nd.get_switch('toggle_rh_vor_adf') != 0), |
| 2548 |
is_true: func(nd) { |
| 2549 |
nd.symbols.dmeR.show(); |
| 2550 |
if(nd.get_switch('toggle_rh_vor_adf') < 0){ |
| 2551 |
nd.symbols.vorR.setText("ADF 2"); |
| 2552 |
nd.symbols.vorR.setColor(0.195,0.96,0.097); |
| 2553 |
nd.symbols.vorRId.setColor(0.195,0.96,0.097); |
| 2554 |
nd.symbols.dmeRDist.setColor(0.195,0.96,0.097); |
| 2555 |
} else { |
| 2556 |
nd.symbols.vorR.setText("VOR 2"); |
| 2557 |
nd.symbols.vorR.setColor(1,1,1); |
| 2558 |
nd.symbols.vorRId.setColor(1,1,1); |
| 2559 |
nd.symbols.dmeRDist.setColor(1,1,1); |
| 2560 |
} |
| 2561 |
nd.symbols.dmeR.setText('NM'); |
| 2562 |
nd.symbols.dmeR.setColor(0,0.59,0.8); |
| 2563 |
}, |
| 2564 |
is_false: func(nd){ |
| 2565 |
nd.symbols.dmeR.hide(); |
| 2566 |
} |
| 2567 |
} |
| 2568 |
}, |
| 2569 |
{ |
| 2570 |
id: 'vorL', |
| 2571 |
impl: { |
| 2572 |
init: func(nd,symbol), |
| 2573 |
predicate: func(nd) (nd.get_switch('toggle_lh_vor_adf') != 0), |
| 2574 |
is_true: func(nd) { |
| 2575 |
nd.symbols.vorL.show(); |
| 2576 |
nd.symbols.vorLId.show(); |
| 2577 |
nd.symbols.dmeLDist.show(); |
| 2578 |
if(nd.get_switch('toggle_rh_vor_adf') < 0){ |
| 2579 |
var adf = 'instrumentation/adf/'; |
| 2580 |
var navident = getprop(adf~ "ident"); |
| 2581 |
var frq = getprop(adf~ "frequencies/selected-khz"); |
| 2582 |
if(navident != "") |
| 2583 |
nd.symbols.vorLId.setText(navident); |
| 2584 |
else |
| 2585 |
nd.symbols.vorLId.setText(sprintf("%3d", frq)); |
| 2586 |
nd.symbols.dmeLDist.setText(""); |
| 2587 |
} else { |
| 2588 |
var nav = 'instrumentation/nav/'; |
| 2589 |
var navID = getprop(nav~"nav-id"); |
| 2590 |
var frq = getprop(nav~"frequencies/selected-mhz-fmt"); |
| 2591 |
var dme = 'instrumentation/dme/'; |
| 2592 |
var dst = getprop(dme~ "indicated-distance-nm"); |
| 2593 |
if(getprop("instrumentation/nav/in-range")) |
| 2594 |
nd.symbols.vorLId.setText(navID); |
| 2595 |
else |
| 2596 |
nd.symbols.vorLId.setText(frq); |
| 2597 |
if(getprop("instrumentation/dme/in-range")) |
| 2598 |
nd.symbols.dmeLDist.setText(sprintf("%3.1f",dst)); |
| 2599 |
else nd.symbols.dmeLDist.setText(" ---"); |
| 2600 |
} |
| 2601 |
}, |
| 2602 |
is_false: func(nd){ |
| 2603 |
nd.symbols.vorL.hide(); |
| 2604 |
nd.symbols.vorLId.hide(); |
| 2605 |
nd.symbols.dmeLDist.hide(); |
| 2606 |
} |
| 2607 |
} |
| 2608 |
}, |
| 2609 |
{ |
| 2610 |
id:'vorLSym', |
| 2611 |
impl: { |
| 2612 |
init: func(nd,symbol), |
| 2613 |
predicate: func(nd) (nd.get_switch('toggle_lh_vor_adf') != 0), |
| 2614 |
is_true: func(nd) { |
| 2615 |
nd.symbols.vorLSym.show(); |
| 2616 |
}, |
| 2617 |
is_false: func(nd){ |
| 2618 |
nd.symbols.vorLSym.hide(); |
| 2619 |
} |
| 2620 |
} |
| 2621 |
}, |
| 2622 |
{ |
| 2623 |
id:'vorRSym', |
| 2624 |
impl: { |
| 2625 |
init: func(nd,symbol), |
| 2626 |
predicate: func(nd) (nd.get_switch('toggle_rh_vor_adf') != 0), |
| 2627 |
is_true: func(nd) { |
| 2628 |
nd.symbols.vorRSym.show(); |
| 2629 |
}, |
| 2630 |
is_false: func(nd){ |
| 2631 |
nd.symbols.vorRSym.hide(); |
| 2632 |
} |
| 2633 |
} |
| 2634 |
}, |
| 2635 |
{ |
| 2636 |
id:'appMode', |
| 2637 |
impl: { |
| 2638 |
init: func(nd,symbol), |
| 2639 |
predicate: func(nd) { |
| 2640 |
var mode = getprop(nd.options.defaults.app_mode); |
| 2641 |
return (mode != '' and mode != nil); |
| 2642 |
}, |
| 2643 |
is_true: func(nd) { |
| 2644 |
var mode = getprop(nd.options.defaults.app_mode); |
| 2645 |
nd.symbols.appMode.show(); |
| 2646 |
nd.symbols.appMode.setText(mode); |
| 2647 |
}, |
| 2648 |
is_false: func(nd){ |
| 2649 |
nd.symbols.appMode.hide(); |
| 2650 |
} |
| 2651 |
} |
| 2652 |
}, |
| 2653 |
{ |
| 2654 |
id:'chrono_box', |
| 2655 |
impl: { |
| 2656 |
init: func(nd,symbol), |
| 2657 |
predicate: func(nd) nd.get_switch('toggle_chrono'), |
| 2658 |
is_true: func(nd) { |
| 2659 |
var efis_node = props.globals.getNode(nd.efis_path); |
| 2660 |
var idx = efis_node.getIndex() or 0; |
| 2661 |
var chronoNode = nd.options.defaults.chrono_node~'['~idx~']'; |
| 2662 |
chronoNode = props.globals.getNode(chronoNode); |
| 2663 |
var time = nil; |
| 2664 |
if(chronoNode != nil){ |
| 2665 |
time = chronoNode.getValue('text'); |
| 2666 |
} |
| 2667 |
nd.symbols.chrono_box.show(); |
| 2668 |
if(time != nil and time != '') |
| 2669 |
nd.symbols.chrono_text.setText(time); |
| 2670 |
}, |
| 2671 |
is_false: func(nd){ |
| 2672 |
nd.symbols.chrono_box.hide(); |
| 2673 |
} |
| 2674 |
} |
| 2675 |
}, |
| 2676 |
{ |
| 2677 |
id:'chrono_text', |
| 2678 |
impl: { |
| 2679 |
init: func(nd,symbol), |
| 2680 |
predicate: func(nd) 1, |
| 2681 |
is_true: func(nd) nd.symbols.chrono_text.show(), |
| 2682 |
is_false: func(nd) nd.symbols.chrono_text.hide(), |
| 2683 |
} |
| 2684 |
}, |
| 2685 |
{ |
| 2686 |
id:'degreeArrows', |
| 2687 |
impl: { |
| 2688 |
init: func(nd,symbol), |
| 2689 |
predicate: func(nd) (nd.get_switch('toggle_display_mode') != 'PLAN' and nd.get_switch('toggle_centered')), |
| 2690 |
is_true: func(nd) { |
| 2691 |
nd.symbols.degreeArrows.show(); |
| 2692 |
}, |
| 2693 |
is_false: func(nd){ |
| 2694 |
nd.symbols.degreeArrows.hide(); |
| 2695 |
} |
| 2696 |
} |
| 2697 |
}, |
| 2698 |
{ |
| 2699 |
id: 'legDistL', |
| 2700 |
impl: { |
| 2701 |
init: func(nd,symbol), |
| 2702 |
predicate: func(nd) (nd.get_switch('toggle_display_mode') == 'MAP' and !nd.get_switch('toggle_centered')), |
| 2703 |
is_true: func(nd){ |
| 2704 |
var active = getprop('autopilot/route-manager/active'); |
| 2705 |
var lat_ctrl = getprop(nd.options.defaults.lat_ctrl); |
| 2706 |
var managed_v = nd.options.defaults.managed_val; |
| 2707 |
var is_managed = (lat_ctrl == managed_v); |
| 2708 |
var toggle_xtrk_err = nd.get_switch('toggle_xtrk_error'); |
| 2709 |
if((!active or is_managed) and !toggle_xtrk_err){ |
| 2710 |
nd.symbols.legDistL.hide(); |
| 2711 |
} else { |
| 2712 |
var dist = getprop('instrumentation/gps/wp/wp[1]/course-error-nm'); |
| 2713 |
if(dist == nil or dist == '' or dist > -0.1){ |
| 2714 |
nd.symbols.legDistL.hide(); |
| 2715 |
} else { |
| 2716 |
dist = sprintf('%.1fL', math.abs(dist)); |
| 2717 |
nd.symbols.legDistL.setText(dist); |
| 2718 |
nd.symbols.legDistL.show(); |
| 2719 |
} |
| 2720 |
} |
| 2721 |
}, |
| 2722 |
is_false: func(nd){ |
| 2723 |
nd.symbols.legDistL.hide(); |
| 2724 |
} |
| 2725 |
} |
| 2726 |
}, |
| 2727 |
{ |
| 2728 |
id: 'legDistR', |
| 2729 |
impl: { |
| 2730 |
init: func(nd,symbol), |
| 2731 |
predicate: func(nd) (nd.get_switch('toggle_display_mode') == 'MAP' and !nd.get_switch('toggle_centered')), |
| 2732 |
is_true: func(nd){ |
| 2733 |
var active = getprop('autopilot/route-manager/active'); |
| 2734 |
var lat_ctrl = getprop(nd.options.defaults.lat_ctrl); |
| 2735 |
var managed_v = nd.options.defaults.managed_val; |
| 2736 |
var is_managed = (lat_ctrl == managed_v); |
| 2737 |
var toggle_xtrk_err = nd.get_switch('toggle_xtrk_error'); |
| 2738 |
if((!active or is_managed) and !toggle_xtrk_err){ |
| 2739 |
nd.symbols.legDistR.hide(); |
| 2740 |
} else { |
| 2741 |
var dist = getprop('instrumentation/gps/wp/wp[1]/course-error-nm'); |
| 2742 |
if(dist == nil or dist == '' or dist < 0.1){ |
| 2743 |
nd.symbols.legDistR.hide(); |
| 2744 |
} else { |
| 2745 |
dist = sprintf('%.1fR', math.abs(dist)); |
| 2746 |
nd.symbols.legDistR.setText(dist); |
| 2747 |
nd.symbols.legDistR.show(); |
| 2748 |
} |
| 2749 |
} |
| 2750 |
}, |
| 2751 |
is_false: func(nd){ |
| 2752 |
nd.symbols.legDistR.hide(); |
| 2753 |
} |
| 2754 |
} |
| 2755 |
}, |
| 2756 |
{ |
| 2757 |
id: 'legDistCtrL', |
| 2758 |
impl: { |
| 2759 |
init: func(nd,symbol), |
| 2760 |
predicate: func(nd) (nd.get_switch('toggle_display_mode') == 'MAP' and nd.get_switch('toggle_centered')), |
| 2761 |
is_true: func(nd){ |
| 2762 |
var active = getprop('autopilot/route-manager/active'); |
| 2763 |
var lat_ctrl = getprop(nd.options.defaults.lat_ctrl); |
| 2764 |
var managed_v = nd.options.defaults.managed_val; |
| 2765 |
var is_managed = (lat_ctrl == managed_v); |
| 2766 |
var toggle_xtrk_err = nd.get_switch('toggle_xtrk_error'); |
| 2767 |
if((!active or is_managed) and !toggle_xtrk_err){ |
| 2768 |
nd.symbols.legDistCtrL.hide(); |
| 2769 |
} else { |
| 2770 |
var dist = getprop('instrumentation/gps/wp/wp[1]/course-error-nm'); |
| 2771 |
if(dist == nil or dist == '' or dist > -0.1){ |
| 2772 |
nd.symbols.legDistCtrL.hide(); |
| 2773 |
} else { |
| 2774 |
dist = sprintf('%.1fL', math.abs(dist)); |
| 2775 |
nd.symbols.legDistCtrL.setText(dist); |
| 2776 |
nd.symbols.legDistCtrL.show(); |
| 2777 |
} |
| 2778 |
} |
| 2779 |
}, |
| 2780 |
is_false: func(nd){ |
| 2781 |
nd.symbols.legDistCtrL.hide(); |
| 2782 |
} |
| 2783 |
} |
| 2784 |
}, |
| 2785 |
{ |
| 2786 |
id: 'legDistCtrR', |
| 2787 |
impl: { |
| 2788 |
init: func(nd,symbol), |
| 2789 |
predicate: func(nd) (nd.get_switch('toggle_display_mode') == 'MAP' and nd.get_switch('toggle_centered')), |
| 2790 |
is_true: func(nd){ |
| 2791 |
var active = getprop('autopilot/route-manager/active'); |
| 2792 |
var lat_ctrl = getprop(nd.options.defaults.lat_ctrl); |
| 2793 |
var managed_v = nd.options.defaults.managed_val; |
| 2794 |
var is_managed = (lat_ctrl == managed_v); |
| 2795 |
var toggle_xtrk_err = nd.get_switch('toggle_xtrk_error'); |
| 2796 |
if((!active or is_managed) and !toggle_xtrk_err){ |
| 2797 |
nd.symbols.legDistCtrR.hide(); |
| 2798 |
} else { |
| 2799 |
var dist = getprop('instrumentation/gps/wp/wp[1]/course-error-nm'); |
| 2800 |
if(dist == nil or dist == '' or dist < 0.1){ |
| 2801 |
nd.symbols.legDistCtrR.hide(); |
| 2802 |
} else { |
| 2803 |
dist = sprintf('%.1fR', math.abs(dist)); |
| 2804 |
nd.symbols.legDistCtrR.setText(dist); |
| 2805 |
nd.symbols.legDistCtrR.show(); |
| 2806 |
} |
| 2807 |
} |
| 2808 |
}, |
| 2809 |
is_false: func(nd){ |
| 2810 |
nd.symbols.legDistCtrR.hide(); |
| 2811 |
} |
| 2812 |
} |
| 2813 |
}, |
| 2814 |
|
| 2815 |
], # end of vector with features |
| 2816 |
|
| 2817 |
} |
| 2818 |
##### |
| 2819 |
## |
| 2820 |
## add support for other aircraft/ND types and styles here |
| 2821 |
## or move to other files. |
| 2822 |
## |
| 2823 |
## see: http://wiki.flightgear.org/NavDisplay#Custom_ND_Styles |
| 2824 |
## and: http://wiki.flightgear.org/NavDisplay#Adding_new_features |
| 2825 |
|
| 2826 |
}; # end of NDStyles |
| 2827 |
|