Advertisement
Guest User

Untitled

a guest
Oct 2nd, 2014
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     var nd_display = {};
  2.  
  3.     setlistener("sim/signals/fdm-initialized", func() {
  4.  
  5.         var toggle_listeners = {
  6.             # symbolic alias : relative property (as used in bindings), initial value, type
  7.             'toggle_range':     {path: '/inputs/range-nm', value:40, type:'INT'},
  8.             'toggle_weather':   {path: '/inputs/wxr', value:0, type:'BOOL'},
  9.             'toggle_airports':  {path: '/inputs/arpt', value:0, type:'BOOL'},
  10.             'toggle_ndb':   {path: '/inputs/NDB', value:0, type:'BOOL'},
  11.             'toggle_stations':     {path: '/inputs/sta', value:0, type:'BOOL'},
  12.             'toggle_vor':   {path: '/inputs/VORD', value:0, type:'BOOL'},
  13.             'toggle_cstr':  {path: '/inputs/CSTR', value:0, type:'BOOL'},
  14.             'toggle_waypoints':     {path: '/inputs/wpt', value:0, type:'BOOL'},
  15.             'toggle_position':  {path: '/inputs/pos', value:0, type:'BOOL'},
  16.             'toggle_data':      {path: '/inputs/data',value:0, type:'BOOL'},
  17.             'toggle_terrain':   {path: '/inputs/terr',value:0, type:'BOOL'},
  18.             'toggle_traffic':       {path: '/inputs/tfc',value:0, type:'BOOL'},
  19.             'toggle_centered':      {path: '/inputs/nd-centered',value:0, type:'BOOL'},
  20.             'toggle_lh_vor_adf':    {path: '/input/lh-vor-adf',value:0, type:'INT'},
  21.             'toggle_rh_vor_adf':    {path: '/input/rh-vor-adf',value:0, type:'INT'},
  22.             'toggle_display_mode':  {path: '/nd/canvas-display-mode', value:'NAV', type:'STRING'},
  23.             'toggle_display_type':  {path: '/mfd/display-type', value:'LCD', type:'STRING'},
  24.             'toggle_true_north':    {path: '/mfd/true-north', value:1, type:'BOOL'},
  25.             'toggle_track_heading':     {path: '/trk-selected', value:0, type:'BOOL'},
  26.             'toggle_fplan': {path: '/nd/route-manager-active', value:0, type: 'BOOL'}, # flight plan active
  27.             'toggle_lnav': {path: '/nd/lnav', value:0, type: 'BOOL'},              # LNAV active
  28.             'toggle_vnav': {path: '/nd/vnav', value:0, type: 'BOOL'},              # VNAV active
  29.             'toggle_wpt_idx': {path: '/inputs/plan-wpt-index', value: -1, type: 'INT'},# WPT Index to be used in PLAN
  30.             'toggle_plan_loop': {path: '/nd/plan-mode-loop', value: 0, type: 'INT'},   # Not used
  31.             'toggle_app_mode': {path: '/nd/app-mode', value:'', type: 'STRING'},       # Approach mode string (ie. 'ILS APP')
  32.             'toggle_cur_td': {path: '/nd/current-td', value: 0, type: 'INT'},          # Top of Desc dist. along route
  33.             'toggle_cur_tc': {path: '/nd/current-tc', value: 0, type: 'INT'},          # Top of Climb dist. along route
  34.             'toggle_cur_sc': {path: '/nd/current-sc', value: 0, type: 'INT'},          # Start of Climb dist. along route
  35.             'toggle_cur_ed': {path: '/nd/current-ed', value: 0, type: 'INT'},          # End of Desc dist. along route
  36.             'toggle_cur_sd': {path: '/nd/current-sd', value: 0, type: 'INT'},          # Start of Desc dist. along route
  37.             'toggle_cur_ec': {path: '/nd/current-ec', value: 0, type: 'INT'},          # End of Climb dist. along route
  38.             'toggle_lvl_off_at': {path: '/nd/level-off-at', value: 0, type: 'INT'}, # Level-off point along route
  39.             'toggle_man_spd': {path: '/nd/managed-spd', value: 0, type: 'INT'},     # Managed Speed Mode
  40.             'toggle_athr': {path: '/nd/athr', value: 0, type: 'INT'},           # Auto-thrust engaged
  41.             'toggle_spd_point_100': {path: '/nd/spd-change-raw-100', value: 0, type: 'INT'}, # Speed limit change point FL100
  42.             'toggle_spd_point_140': {path: '/nd/spd-change-raw-140', value: 0, type: 'INT'}, # Speed limit change point FL140
  43.             'toggle_spd_point_250': {path: '/nd/spd-change-raw-250', value: 0, type: 'INT'}, # Speed limit change point FL250
  44.             'toggle_spd_point_260': {path: '/nd/spd-change-raw-260', value: 0, type: 'INT'}, # Speed limit change point FL260
  45.             'toggle_nav1_frq': {path: '/nd/nav1_frq', value: 0, type: 'INT'}, # Nav1 Freq. Listener
  46.             'toggle_nav2_frq': {path: '/nd/nav2_frq', value: 0, type: 'INT'}, # Nav2 Freq. Listener
  47.             'toggle_adf1_frq': {path: '/nd/adf1_frq', value: 0, type: 'INT'}, # ADF1 Freq. Listener
  48.             'toggle_adf2_frq': {path: '/nd/adf2_frq', value: 0, type: 'INT'}, # ADF2 Freq. Listener
  49.             'toggle_hold_init': {path: '/nd/hold_init', value: 0, type: 'INT'}, # HOLD pattern init Listener
  50.             'toggle_hold_update': {path: '/nd/hold_update', value: 0, type: 'INT'}, # HOLD pattern update Listener
  51.             'toggle_hold_wp': {path: '/nd/hold_wp', value: '', type: 'STRING'}, # HOLD pattern waypoint
  52.             'toggle_route_num': {path: '/nd/route_num', value: 0, type: 'INT'}, # Route waypoint count
  53.             'toggle_cur_wp': {path: '/nd/cur_wp', value: 0, type: 'INT'}, # Current Waypoint (TO Waypoint) index
  54.             'toggle_ap1': {path: '/nd/ap1', value: '', type: 'STRING'}, # AP1 engaged
  55.             'toggle_ap2': {path: '/nd/ap2', value: '', type: 'STRING'}, # AP2 engaged
  56.             'toggle_dep_rwy': {path: '/nd/dep_rwy', value: '', type: 'STRING'}, # Departure runway
  57.             'toggle_dest_rwy': {path: '/nd/dest_rwy', value: '', type: 'STRING'}, # Destination runway
  58.         };
  59.  
  60.     var ND = canvas.NavDisplay;
  61.         var NDCpt = ND.new("instrumentation/efis", toggle_listeners, 'Airbus');
  62.  
  63.         nd_display.main = canvas.new({
  64.             "name": "ND",
  65.             "size": [1024, 1024],
  66.             "view": [1024, 1024],
  67.             "mipmapping": 1
  68.         });
  69.  
  70.         nd_display.main.addPlacement({"node": "ND.screen"});
  71.         var group = nd_display.main.createGroup();
  72.  
  73.         NDCpt.newMFD(group);
  74.        
  75.         NDCpt.update();
  76.  
  77.         setprop("instrumentation/efis/inputs/plan-wpt-index", -1);
  78.  
  79.         print("ND Canvas Initialized!");
  80.     }); # fdm-initialized listener callback
  81.  
  82.     # Create Listeners to update the ND, change the property map values to fit
  83.     # the properties you use in your own aircraft
  84.  
  85.     var property_map = {
  86.         des_apt: "/autopilot/route-manager/destination/airport",
  87.         dep_apt: "/autopilot/route-manager/departure/airport",
  88.         des_rwy: "/autopilot/route-manager/destination/runway",
  89.         dep_rwy: "/autopilot/route-manager/departure/runway",
  90.         fplan_active: 'autopilot/route-manager/active',
  91.         athr: '/flight-management/control/a-thrust',
  92.         cur_wp: "/autopilot/route-manager/current-wp",
  93.         vnav_node: "/autopilot/route-manager/vnav/",
  94.         spd_node: "/autopilot/route-manager/spd/",
  95.         holding: "/flight-management/hold",
  96.         holding_points: "/flight-management/hold/points",
  97.         adf1_frq: 'instrumentation/adf/frequencies/selected-khz',
  98.         adf2_frq: 'instrumentation/adf[1]/frequencies/selected-khz',
  99.         nav1_frq: 'instrumentation/nav/frequencies/selected-mhz',
  100.         nav2_frq: 'instrumentation/nav[1]/frequencies/selected-mhz',
  101.         lat_ctrl: 'flight-management/control/lat-ctrl',
  102.         ver_ctrl: "flight-management/control/ver-ctrl",
  103.     spd_ctrl: "flight-management/control/spd-ctrl",
  104.     };
  105.  
  106.     setlistener("instrumentation/efis/nd/display-mode", func{
  107.         var canvas_mode = "instrumentation/efis/nd/canvas-display-mode";
  108.         var nd_centered = "instrumentation/efis/inputs/nd-centered";
  109.         var mode = getprop("instrumentation/efis/nd/display-mode");
  110.         var cvs_mode = 'NAV';
  111.         var centered = 1;
  112.         if(mode == 'ILS'){
  113.             cvs_mode = 'APP';
  114.         }
  115.         elsif(mode == 'VOR') {
  116.             cvs_mode = 'VOR';
  117.         }
  118.         elsif(mode == 'NAV'){
  119.             cvs_mode = 'MAP';
  120.         }
  121.         elsif(mode == 'ARC'){
  122.             cvs_mode = 'MAP';
  123.             centered = 0;
  124.         }
  125.         elsif(mode == 'PLAN'){
  126.             cvs_mode = 'PLAN';
  127.         }
  128.         setprop(canvas_mode, cvs_mode);
  129.         setprop(nd_centered, centered);
  130.     });
  131.  
  132.     setlistener(property_map.fplan_active, func{
  133.         var actv = getprop(property_map.fplan_active);
  134.         setprop('instrumentation/efis/nd/route-manager-active', actv);
  135.     });
  136.  
  137.     setlistener(property_map.athr, func{
  138.         var athr = getprop(property_map.athr);
  139.         setprop('instrumentation/efis/nd/athr', (athr == 'eng'));
  140.     });
  141.  
  142.     setlistener(property_map.ver_ctrl, func{
  143.         var verctrl = getprop(property_map.ver_ctrl);
  144.         setprop('instrumentation/efis/nd/vnav', (verctrl == 'fmgc'));
  145.     });
  146.  
  147.     setlistener(property_map.spd_ctrl, func{
  148.         var spdctrl = getprop(property_map.spd_ctrl);
  149.         setprop('instrumentation/efis/nd/managed-spd', (spdctrl == 'fmgc'));
  150.     });
  151.  
  152.     setlistener(property_map.lat_ctrl, func{
  153.         var latctrl = getprop(property_map.lat_ctrl);
  154.         setprop('instrumentation/efis/nd/lnav', (latctrl == 'fmgc'));
  155.     });
  156.  
  157.     setlistener("/instrumentation/mcdu/f-pln/disp/first", func{
  158.         var first = getprop("/instrumentation/mcdu/f-pln/disp/first");
  159.         if(typeof(first) == 'nil') first = -1;
  160.         if(getprop('autopilot/route-manager/route/num') == 0) first = -1;
  161.         setprop("instrumentation/efis/inputs/plan-wpt-index", first);
  162.     });
  163.  
  164.     setlistener('/instrumentation/efis/nd/terrain-on-nd', func{
  165.         var terr_on_hd = getprop('/instrumentation/efis/nd/terrain-on-nd');
  166.         var alpha = 1;
  167.         if(terr_on_hd) alpha = 0.5;
  168.         nd_display.main.setColorBackground(0,0,0,alpha);
  169.     });
  170.  
  171.     setlistener('instrumentation/nav/frequencies/selected-mhz', func{
  172.         var mhz = getprop('instrumentation/nav/frequencies/selected-mhz');
  173.         if(mhz == nil) mhz = 0;
  174.         setprop('/instrumentation/efis/nd/nav1_frq', mhz);
  175.     });
  176.  
  177.     setlistener('instrumentation/nav[1]/frequencies/selected-mhz', func{
  178.         var mhz = getprop('instrumentation/nav[1]/frequencies/selected-mhz');
  179.         if(mhz == nil) mhz = 0;
  180.         setprop('/instrumentation/efis/nd/nav2_frq', mhz);
  181.     });
  182.  
  183.     setlistener('instrumentation/adf/frequencies/selected-khz', func{
  184.         var khz = getprop('instrumentation/adf/frequencies/selected-khz');
  185.         if(khz == nil) khz = 0;
  186.         setprop('/instrumentation/efis/nd/adf1_frq', khz);
  187.     });
  188.  
  189.     setlistener('instrumentation/adf[1]/frequencies/selected-khz', func{
  190.         var khz = getprop('instrumentation/adf[1]/frequencies/selected-khz');
  191.         if(khz == nil) khz = 0;
  192.         setprop('/instrumentation/efis/nd/adf2_frq', khz);
  193.     });
  194.  
  195.     setlistener('flight-management/hold/init', func{
  196.         var init = getprop('flight-management/hold/init');
  197.         if(init == nil) init = 0;
  198.         setprop('/instrumentation/efis/nd/hold_init', init);
  199.     });
  200.  
  201.     setlistener("/flight-management/hold/wp", func{
  202.         var wpid = getprop("/flight-management/hold/wp");
  203.         if(wpid == nil) wpid = '';
  204.             setprop('/instrumentation/efis/nd/hold_wp', wpid);
  205.     });
  206.  
  207.     setlistener('autopilot/route-manager/route/num', func{
  208.         var num = getprop('autopilot/route-manager/route/num');
  209.         setprop('/instrumentation/efis/nd/route_num', num);
  210.     });
  211.  
  212.     setlistener(property_map.cur_wp, func(){
  213.         var curwp = getprop(nd_props.cur_wp);
  214.         setprop('/instrumentation/efis/nd/cur_wp',curwp);
  215.     });
  216.  
  217.     setlistener("/flight-management/control/ap1-master", func(){
  218.         var ap1 = getprop("/flight-management/control/ap1-master");
  219.         setprop('/instrumentation/efis/nd/ap1',ap1);
  220.     });
  221.  
  222.     setlistener("/flight-management/control/ap2-master", func(){
  223.         var ap2 = getprop("/flight-management/control/ap2-master");
  224.         setprop('/instrumentation/efis/nd/ap2',ap2);
  225.     });
  226.  
  227.     setlistener("/autopilot/route-manager/departure/runway", func(){
  228.         var rwy = getprop("/autopilot/route-manager/departure/runway");
  229.         setprop('/instrumentation/efis/nd/dep_rwy',rwy);
  230.     });
  231.  
  232.     setlistener("/autopilot/route-manager/destination/runway", func(){
  233.         var rwy = getprop("/autopilot/route-manager/destination/runway");
  234.         setprop('/instrumentation/efis/nd/dest_rwy',rwy);
  235.     });
  236.  
  237.     var showNd = func() {
  238.         # The optional second arguments enables creating a window decoration
  239.         var dlg = canvas.Window.new([400, 400], "dialog");
  240.         dlg.setCanvas( nd_display["main"] );
  241.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement