c172p-team / c172p

A high detailed version of the Cessna 172P aircraft for FlightGear
GNU General Public License v2.0
82 stars 43 forks source link

Potential bug in timer logic for various timers and/or listeners #1265

Closed wlbragg closed 5 years ago

wlbragg commented 5 years ago

I thought I better bring this up as a potential issue since this is the second time I ran into this. While testing fog and frost, I was relocating to a new airport to refresh my memory about how fast or slow environmental temps and humidity settled and how that was affecting the fog and frost creation. Using the Airport relocation feature in the sim I got a seg fault and noticed some familiar errors I have seen before. Also see: https://github.com/c172p-team/c172p/pull/1266

.61 [ALRT]:nasal      Nasal runtime error: Timer is running, cannot change type between real/sim time
  205.61 [ALRT]:nasal        at /mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/engine.nas, line 500
  205.61 [ALRT]:nasal        called from: /home/wayne/FGFS/install/flightgear/fgdata/Nasal/globals.nas, line 119
---
  206.01 [ALRT]:nasal      Nasal runtime error: vector index -1 out of bounds (size: 1)
  206.01 [ALRT]:nasal        at /home/wayne/FGFS/install/flightgear/fgdata/Nasal/local_weather/local_weather.nas, line 390
  206.01 [ALRT]:nasal        called from: /home/wayne/FGFS/install/flightgear/fgdata/Nasal/local_weather/local_weather.nas, line 882
 ---
  211.76 [ALRT]:nasal      Nasal runtime error: too few function args (have 0 need 24)
  211.76 [ALRT]:nasal        at 
Segmentation fault

I am specifically talking about the at /mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/engine.nas, line 500 I ran into this when doing the mooring relocation code. I had to turn off that timer using c172p.oil_consumption.stop(); in the mooring relocation code right before I execute the re-init.

I don't know how we can resolve this in the airport relocation re-init without core help.

wkitty42 commented 5 years ago

On 3/26/19 3:42 PM, wlbragg wrote:

I am specifically talking about the |js at /mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/engine.nas, line 500|

i think you meant nasal instead of js??

I ran into this when doing the mooring relocation code. I had to turn off that timer using |js c172p.oil_consumption.stop();| right before I execute the re-init.

I don't know how we can resolve this in the airport relocation re-init without core help.

was the craft's engine running? if not, that timer shouldn't be running, should it??

wlbragg commented 5 years ago

Maybe it was and that is why it appeared to happen intermittently. I'll test for that and see if that is this issue with any of them.

legoboyvdlp commented 5 years ago

See:

Starting timers from a fdm initialized listener at http://wiki.flightgear.org/Nasal_Loops

Your mention of re-initing makes this suspect this is the case.

wlbragg commented 5 years ago

@legoboyvdlp Yes that could be the case.

Also

you do not always know what listeners are registered where, and any listener that writes to a different property has the potential to infinitely call each other and thus segfault.

I just did some quick settimer and setlistener searches in our files. See lists below.

This is an interesting way to do a "singleshot" listener, so to speak.

<nasal>
            <script>
                var listeners = std.Vector.new();

                listeners.append(setlistener("/engines/active-engine/running", func (node) {
                    if (node.getBoolValue()) {
                        setprop("/controls/switches/starter", 0);
                        foreach (var listener; listeners.vector) {
                            removelistener(listener);
                        }
                        listeners.clear();
                    }
                }, 1, 0));
            </script>
        </nasal>

even easier?

var nasalInit = setlistener("/sim/signals/fdm-initialized", func{
  104:   settimer(init_variables, 2);
  105    removelistener(nasalInit);
  106  });
wlbragg commented 5 years ago

Stating maketimers...

Searching 950 files for ".start()"

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/c172p.nas:
  490      }
  491  });
  492: ad_timer.start();
  493  
  494  ############################################
  ...
  629          else {
  630              log_cabin_temp();
  631:             cabin_temp_timer.start();
  632          }
  633      }, 1, 0);
  ...
  636          if (node.getValue()) {
  637              log_fog_frost();
  638:             fog_frost_timer.start();
  639          }
  640          else {
  ...
  718  
  719      var c172_timer = maketimer(0.25, func{global_system_loop()});
  720:     c172_timer.start();
  721  });
  722  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/engine.nas:
   19      setlistener("/engines/engine[" ~ index ~ "]/running", func {
   20          if (getprop("/engines/engine[" ~ index ~ "]/running")) {
   21:             meter.start();
   22              print("Hobbs system started");
   23          } else {
   ..
  493  setlistener("/sim/signals/fdm-initialized", func {
  494      var engine_timer = maketimer(UPDATE_PERIOD, func { update(); });
  495:     engine_timer.start();
  496:     carb_icing_function.start();
  497      coughing_timer.singleShot = 1;
  498:     coughing_timer.start();
  499  
  500      oil_consumption.simulatedTime = 1;
  501:     oil_consumption.start();
  502:     calculate_real_oiltemp.start();
  503  });
  504  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/kr87.nas:
   41      restart : func {
   42          me.reset();
   43:         me.start();
   44      },
   45  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/light-manager.nas:
  126          me.light_manager_timer = maketimer(0.0, func{me.update()});
  127          
  128:         me.start();
  129      },
  130  
  ...
  141          setprop("/sim/rendering/als-secondary-lights/lightspot/stretch[1]", me.light2_stretch);
  142  
  143:         me.light_manager_timer.start();
  144      },
  145  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/terrain.nas:
   29  
   30  var terrain_timer = maketimer(0.5, func{terrain_loop()});
   31: terrain_timer.start();
   32  
   33  ###############################################################################

14 matches across 5 files
wlbragg commented 5 years ago

settimer...

Searching 950 files for "settimer"

/mnt/GDrive/Aircraft/Development Aircraft/c172p/CONTRIBUTING.md:
   84  Do not commit commented-out code or files that are no longer needed. Remove the code or the files.
   85  
   86: Use `maketimer` instead of `settimer`. Systems should be written in JSBSim if possible.
   87  
   88  # Creating a release

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Models/c172p.xml:
 3826                  <command>nasal</command>
 3827                  <script>
 3828:                     settimer(func(){
 3829                          fgcommand("dialog-show", {"dialog-name": "c172p-baggage-weight-dialog"});
 3830                      }, 2.0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Models/Interior/Panel/Instruments/garmin196/garmin196.nas:
  102  
  103  var nasalInit = setlistener("/sim/signals/fdm-initialized", func{
  104:   settimer(init_variables, 2);
  105    removelistener(nasalInit);
  106  });
  ...
  324    update_e6b_menu();
  325  
  326:   settimer(main_loop, 0.3);
  327  }
  328  
  ...
 2518    }
 2519    if(getprop("/instrumentation/garmin196/serviceable")==1 and getprop("/instrumentation/garmin196/status")==10){
 2520:     settimer(update_map,1);
 2521    }
 2522  }
 ....
 3817  var affiche_fpl_loaded = func{
 3818    setprop("/instrumentation/garmin196/menu_routes/fpl-loaded",1);
 3819:   settimer(close_fpl_loaded,3);
 3820  }
 3821  
 ....
 3825  var affiche_waypoint_jump = func{
 3826    setprop("/instrumentation/garmin196/menu_routes/waypoint-jump",1);
 3827:   settimer(close_waypoint_jump,3);
 3828  }
 3829  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/c172p.nas:
  106  
  107      var engine_running_check_delay = 5.0;
  108:     settimer(func {
  109          if (!getprop("/engines/active-engine/running")) {
  110              gui.popupTip("The autostart failed to start the engine. You must lean the mixture and start the engine manually.", 5);
  ...
  219      setprop("/controls/flight/auto-coordination", 0);
  220      interpolate("/controls/flight/aileron", 1.0, 0.5, -1.0, 1.0, 0.0, 0.5);
  221:     settimer(func(){
  222          setprop("/controls/flight/auto-coordination", auto_coordination);
  223      }, 2.0);
  ...
  231      setprop("/controls/flight/auto-coordination", 0);
  232      interpolate("/controls/flight/aileron", -1.0, 0.5, 1.0, 1.0, 0.0, 0.5);
  233:     settimer(func(){
  234          setprop("/controls/flight/auto-coordination", auto_coordination);
  235      }, 2.0);
  ...
  319      var sound_prop = "/sim/model/c172p/sound/click-" ~ name;
  320  
  321:     settimer(func {
  322          # Play the sound
  323          setprop(sound_prop, 1);
  ...
  325          # Reset the property after 0.2 seconds so that the sound can be
  326          # played again.
  327:         settimer(func {
  328              setprop(sound_prop, 0);
  329          }, timeout);
  ...
  370      var lightning_distance_norm = std.min(1.0, 1 / math.pow(lightning_distance / 5000.0, 2));
  371  
  372:     settimer(func {
  373          var thunder1 = getprop("/sim/model/c172p/sound/click-thunder1");
  374          var thunder2 = getprop("/sim/model/c172p/sound/click-thunder2");
  ...
  689  
  690      # set user defined pilot view or initialize it
  691:     settimer(func {
  692          if (getprop("sim/current-view/user/x-offset-m") != nil){
  693              setprop("sim/current-view/x-offset-m", getprop("sim/current-view/user/x-offset-m"));

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/clock.nas:
   70              if(me.MODE==0){
   71                  me.MODE=2;
   72:                 settimer(func(){
   73                      me.MODE=0;
   74                  },1.5);
   ..
  163  
  164  setlistener("/sim/signals/fdm-initialized", func {
  165:     settimer(update,2);
  166      print("Astro Tech LC-2 Chronometer Loaded");
  167  });
  ...
  169  var update = func{
  170  astrotech.update_clock();
  171: settimer(update,0.5);
  172  }
  173  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/engine.nas:
   72      if (p < 3) {
   73          pumpPrimer();
   74:         settimer(autoPrime, 1);
   75      }
   76  };
   ..
  292          # the code below kills the engine and then brings it back to life after 0.25 seconds, simulating a cough
  293          setprop("/engines/active-engine/kill-engine", 1);
  294:         settimer(func {
  295              setprop("/engines/active-engine/kill-engine", 0);
  296          }, 0.25);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/jsbsim-hydrodynamics.nas:
   29  
   30  
   31:     settimer(ground, 0.0);
   32  }
   33  
   34: settimer(ground, 0.0);
   35  
   36  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/ki266.nas:
   88      }
   89  
   90:     settimer( func { me.update() }, 0.2 );
   91  }
   92  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/kr87.nas:
  175          me.power = me.powerButtonN.getValue();
  176  
  177:         settimer( func { me.update() }, 0.1 );
  178      }
  179  };

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/mooring.nas:
   35              }
   36          }
   37:         settimer(func{
   38              if (getprop("/controls/mooring/automatic") and getprop("/controls/mooring/allowed")) {
   39                  seaplane = Mooring.new();
   ..
   91      # to search the harbor
   92      if(getprop("/sim/sceneryloaded")) {
   93:         settimer(func{ me.presetharbour(); },0.1);
   94      }
   95      setlistener("/sim/signals/fdm-initialized", func {
   ..
   99  
  100          if (getprop("/fdm/jsbsim/settings/damage-flag")) {
  101:             settimer(func {
  102                  setprop("/fdm/jsbsim/settings/damage", 1);
  103                  setprop("/fdm/jsbsim/settings/damage-flag", 0);
  ...
  110              setprop("/controls/gear/gear-down", 0);
  111              setprop("/fdm/jsbsim/gear/gear-pos-norm", 0);
  112:             settimer(func {
  113                  setprop("/controls/switches/master-bat", 0);
  114              }, 0.1);
  ...
  120          }
  121      });
  122:     settimer(func{ me.presetharbour(); },0.1);
  123  }
  124  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/save.nas:
  277  
  278      var load_delay = 2.0;
  279:     settimer(func {
  280  
  281          #var lat = getprop("/save/latitude-deg");
  ...
  440  
  441          if (anchorconnect) {
  442:             settimer(func {
  443                  var headwind = getprop("/environment/wind-from-heading-deg");
  444                  setprop("/orientation/heading-deg", headwind);
  445              }, heading_delay);
  446:             settimer(func {
  447                  var anchorlon = getprop("/save/anchorlon");
  448                  var anchorlat = getprop("/save/anchorlat");
  ...
  457          }
  458  
  459:         settimer(func {
  460              setprop("/fdm/jsbsim/settings/damage", damage);
  461          }, damage_delay);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/state-manager.nas:
   66  
   67      var engine_running_check_delay = 5.0;
   68:     settimer(func {
   69          if (!getprop("/engines/active-engine/running")) {
   70              gui.popupTip("The autostart failed to start the engine. You may have to adjust the mixture and start the engine manually.", 5);

33 matches across 12 files
wlbragg commented 5 years ago

setlisteners...

Searching 950 files for "setlistener"

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Models/c172p.xml:
  369              # Registration number
  370              var regnum_path = rplayer.getNode("sim/multiplay/generic/string[0]").getPath();
  371:             setlistener(regnum_path, func (node) {
  372                  set_registration_number(rplayer, node.getValue());
  373              }, 1, 0);
  ...
  381              var pilot = rplayer.initNode("pax/pilot/present", 0, "BOOL");
  382  
  383:             setlistener(pax_state_path, func (node) {
  384                  var state = node.getValue();
  385                  co_pilot.setBoolValue(bits.test(state, 0));
  ...
  399              var tail_tiedown  = rplayer.initNode("sim/model/c172p/securing/tiedownT-visible", 0, "BOOL");
  400  
  401:             setlistener(securing_state_path, func (node) {
  402                  var state = node.getValue();
  403                  pitot_cover.setBoolValue(bits.test(state, 0));
  ...
  431              var move_nav_light_right = rplayer.initNode("sim/model/c172p/lighting/nav-lights/right-damaged", 0, "BOOL");
  432  
  433:             setlistener(wing_left_state.getPath(), func (node) {
  434                  var move = node.getValue() == 2 and !wings_collapsed.getBoolValue();
  435                  move_nav_light_left.setBoolValue(move);
  436              }, 1, 0);
  437  
  438:             setlistener(wing_right_state.getPath(), func (node) {
  439                  var move = node.getValue() == 2 and !wings_collapsed.getBoolValue();
  440                  move_nav_light_right.setBoolValue(move);
  441              }, 1, 0);
  442  
  443:             setlistener(wings_collapsed.getPath(), func (node) {
  444                  var move = wing_left_state.getValue() == 2 and !node.getBoolValue();
  445                  move_nav_light_left.setBoolValue(move);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Models/Interior/Panel/Instruments/garmin196/garmin196.nas:
   99    main_loop();
  100  }
  101: #setlistener("/sim/signals/fdm-initialized",,0,0);
  102  
  103: var nasalInit = setlistener("/sim/signals/fdm-initialized", func{
  104    settimer(init_variables, 2);
  105    removelistener(nasalInit);
  ...
  222    }
  223  }
  224: setlistener("/sim/signals/fdm-initialized",load_parameters);
  225  
  226  var save_parameters = func{
  ...
 2257    }
 2258  }
 2259: setlistener("/instrumentation/gps/mode",change_wpt_id);
 2260  
 2261  var change_position_wpt_bug = func{
 ....
 3040  
 3041  }
 3042: setlistener("/autopilot/route-manager/wp[0]/id",update_wp_id_display);
 3043  
 3044  var init_list_aircraft = func{

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/c172p.nas:
  418  ############################################
  419  
  420: setlistener("/engines/active-engine/killed", func (node) {
  421      if (node.getValue() and getprop("/engines/active-engine/running")) {
  422          click("coughing-engine-sound", 0.7, 0);
  ...
  437          };
  438  
  439:         setlistener("/sim/" ~ name ~ "/enable", func (node) {
  440              if (node.getBoolValue()) {
  441                  m.add();
  ...
  532  };
  533  
  534: setlistener("/controls/engines/active-engine", func (node) {
  535      # Set new mass limits for Fuel and Payload Settings dialog
  536      set_limits(node);
  ...
  549  };
  550  
  551: setlistener("/pax/co-pilot/present", update_pax, 0, 0);
  552: setlistener("/pax/left-passenger/present", update_pax, 0, 0);
  553: setlistener("/pax/right-passenger/present", update_pax, 0, 0);
  554: setlistener("/pax/pilot/present", update_pax, 0, 0);
  555  update_pax();
  556  
  ...
  565  };
  566  
  567: setlistener("/sim/model/c172p/securing/pitot-cover-visible", update_securing, 0, 0);
  568: setlistener("/sim/model/c172p/securing/chock-visible", update_securing, 0, 0);
  569: setlistener("/sim/model/c172p/securing/tiedownL-visible", update_securing, 0, 0);
  570: setlistener("/sim/model/c172p/securing/tiedownR-visible", update_securing, 0, 0);
  571: setlistener("/sim/model/c172p/securing/tiedownT-visible", update_securing, 0, 0);
  572  update_securing();
  573  
  ...
  595  }
  596  
  597: setlistener("/sim/signals/fdm-initialized", func {
  598      # Randomize callsign of new users to avoid them blocking
  599      # other new users on multiplayer
  ...
  615  
  616      # Set alt alert of KAP 140 autopilot to 20_000 ft to get rid of annoying beep
  617:     setlistener("/autopilot/KAP140/settings/target-alt-ft", func (n) {
  618          if (n.getValue() == 0) {
  619              kap140.altPreselect = 20000;
  ...
  622      });
  623  
  624:     setlistener("/sim/model/c172p/cabin-air-temp-in-range", func (node) {
  625          if (node.getValue()) {
  626              cabin_temp_timer.stop();
  ...
  633      }, 1, 0);
  634  
  635:     setlistener("/sim/model/c172p/fog-or-frost-increasing", func (node) {
  636          if (node.getValue()) {
  637              log_fog_frost();
  ...
  644  
  645      # Close all caps and doors
  646:     setlistener("/engines/active-engine/cranking", func (node) {
  647          setprop("sim/model/show-dip-stick", 0);
  648          setprop("sim/model/open-pfuel-cap", 0);
  ...
  660      }, 0, 0);
  661  
  662:     setlistener("/engines/active-engine/running", func (node) {
  663          var autostart = getprop("/engines/active-engine/auto-start");
  664          var cranking  = getprop("/engines/active-engine/cranking");
  ...
  679  
  680      # Listening for lightning strikes
  681:     setlistener("/environment/lightning/lightning-pos-y", thunder);
  682  
  683      reset_system();

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/clock.nas:
  162  
  163  
  164: setlistener("/sim/signals/fdm-initialized", func {
  165      settimer(update,2);
  166      print("Astro Tech LC-2 Chronometer Loaded");

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/electrical.nas:
  510  var system_updater = ElectricalSystemUpdater.new();
  511  
  512: setlistener("/sim/signals/fdm-initialized", func {
  513      # checking if battery should be automatically recharged
  514      if (!getprop("/systems/electrical/save-battery-charge")) {

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/engine.nas:
   17  
   18  var init_hobbs_meter = func(index, meter) {
   19:     setlistener("/engines/engine[" ~ index ~ "]/running", func {
   20          if (getprop("/engines/engine[" ~ index ~ "]/running")) {
   21              meter.start();
   ..
   48  };
   49  
   50: setlistener("/sim/time/hobbs/engine[0]", update_hobbs_meter, 1, 0);
   51: setlistener("/sim/time/hobbs/engine[1]", update_hobbs_meter, 1, 0);
   52  
   53  # ========== primer stuff ======================
   ..
  372  };
  373  
  374: setlistener("/controls/switches/starter", func {
  375      var v = getprop("/controls/switches/starter") or 0;
  376      if (v == 0) {
  ...
  417  # this is the correct way to interface with the axis based controls - use a listener
  418  # on the *-all property
  419: setlistener("/controls/engines/throttle-all", func{
  420      var value = (1 - getprop("/controls/engines/throttle-all")) / 2;
  421      var new_value = std.max(0.0, std.min(value, 1.0));
  ...
  423  }, 0, 0);
  424  
  425: setlistener("/controls/engines/mixture-all", func{
  426      var value = (1 - getprop("/controls/engines/mixture-all")) / 2;
  427      var new_value = std.max(0.0, std.min(value, 1.0));
  ...
  491  };
  492  
  493: setlistener("/sim/signals/fdm-initialized", func {
  494      var engine_timer = maketimer(UPDATE_PERIOD, func { update(); });
  495      engine_timer.start();

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/immat.nas:
    9                    "Aircraft/c172p/gui/dialogs/immat.xml");
   10  
   11: setlistener("/sim/signals/fdm-initialized", func {
   12      if (props.globals.getNode("/sim/model/immat") == nil) {
   13          var immat = props.globals.getNode("/sim/model/immat", 1);
   ..
   19              immat.setValue("");
   20      }
   21:     setlistener("sim/model/immat", refresh_immat, 1, 0);
   22  });
   23  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/kma20.nas:
   31  
   32      # Monitor changes to COM1 switch
   33:     setlistener(rootPath ~ "/com1", func(v) {setprop("/instrumentation/comm/volume",            (v.getValue() != 0) * getprop("/instrumentation/comm/volume-selected"));}, 1);
   34      # Monitor changes to volume selection knob of COM1
   35:     setlistener("/instrumentation/comm/volume-selected", func(v) {setprop("/instrumentation/comm/volume", (getprop(rootPath ~ "/com1") != 0) * getprop("/instrumentation/comm/volume-selected"));}, 1);
   36  
   37      # Monitor changes to COM2 switch
   38:     setlistener(rootPath ~ "/com2", func(v) {setprop("/instrumentation/comm[1]/volume",         (v.getValue() != 0) * getprop("/instrumentation/comm[1]/volume-selected"));}, 1);
   39      # Monitor changes to volume selection knob of COM2
   40:     setlistener("/instrumentation/comm[1]/volume-selected", func(v) {setprop("/instrumentation/comm[1]/volume", (getprop(rootPath ~ "/com2") != 0) * getprop("/instrumentation/comm[1]/volume-selected"));}, 1);
   41  
   42      # Idea for the NAV is to set audio-btn (original-property) to true when both KMA-20 NAV switch is active & the NAV ident is pulled (ident-audible).
   43      # Monitor changes to NAV1 switch
   44:     setlistener(rootPath ~ "/nav1",                   func(v) {setprop("/instrumentation/nav/audio-btn", (v.getValue() != 0) and getprop("/instrumentation/nav/ident-audible"));}, 1);
   45      # Monitor changes to NAV1 pull ident
   46:     setlistener("/instrumentation/nav/ident-audible", func(v) {setprop("/instrumentation/nav/audio-btn", (getprop(rootPath ~ "/nav1") != 0) and v.getValue());}, 1);
   47  
   48      # Monitor changes to NAV2 switch
   49:     setlistener(rootPath ~ "/nav2",                      func(v) {setprop("/instrumentation/nav[1]/audio-btn", (v.getValue() != 0) and getprop("/instrumentation/nav[1]/ident-audible"));}, 1);
   50      # Monitor changes to NAV2 pull ident
   51:     setlistener("/instrumentation/nav[1]/ident-audible", func(v) {setprop("/instrumentation/nav[1]/audio-btn", (getprop(rootPath ~ "/nav2") != 0) and v.getValue());}, 1);
   52  
   53:     setlistener(rootPath ~ "/adf",  func(v) {setprop("/instrumentation/adf/ident-audible",      (v.getValue() != 0));}, 1);
   54:     setlistener(rootPath ~ "/dme",  func(v) {setprop("/instrumentation/dme/ident",              (v.getValue() != 0));}, 1);
   55:     setlistener(rootPath ~ "/mkr",  func(v) {setprop("/instrumentation/marker-beacon/audio-btn",(v.getValue() != 0));}, 1);
   56      print( "KMA20 audio panel initialized" );
   57      return obj;

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/kr87.nas:
  104              m.baseN.getNode( "frequencies/selected-khz", 1 )
  105          );
  106:         setlistener( m.base ~ "/adf-btn", func { m.modeButtonListener() } );
  107:         setlistener( m.base ~ "/bfo-btn", func { m.modeButtonListener() } );
  108          m.modeButtonListener();
  109  
  ...
  181  var kr87_0 = kr87.new( "/instrumentation/adf[0]" ).update();
  182  
  183: #setlistener("/sim/signals/fdm-initialized", func { timer_update() } );
  184  

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/light-manager.nas:
  263  };
  264  
  265: setlistener("/sim/signals/fdm-initialized", func {
  266  
  267      light_manager.init();
  268  
  269:     setlistener("/sim/rendering/als-secondary-lights/use-landing-light-ext", func (node) {
  270          light_manager.enable_or_disable(node.getValue(), 0);
  271      }, 1, 0);
  272:     setlistener("/sim/rendering/als-secondary-lights/use-taxi-light-ext", func (node) {
  273          light_manager.enable_or_disable(node.getValue(), 1);
  274      }, 1, 0);
  275:     setlistener("/sim/model/c172p/lighting/nav-lights/left-on", func (node) {
  276          light_manager.enable_or_disable(node.getValue(), 3);
  277      }, 1, 0);
  278:     setlistener("/sim/model/c172p/lighting/nav-lights/right-on", func (node) {
  279          light_manager.enable_or_disable(node.getValue(), 2);
  280      }, 1, 0);
  281:     setlistener("/sim/model/lighting/courtesy/factor", func (node) {
  282          light_manager.enable_or_disable(node.getValue(), 4);
  283      }, 1, 0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/mooring.nas:
   19  
   20  #init if allowed and called for
   21: setlistener("/sim/signals/fdm-initialized",
   22      func {
   23  
   ..
   42      }
   43  );
   44: setlistener("/controls/mooring/go-to-mooring",
   45      func {
   46          if (getprop("/controls/mooring/allowed")) {
   ..
   93          settimer(func{ me.presetharbour(); },0.1);
   94      }
   95:     setlistener("/sim/signals/fdm-initialized", func {
   96          # force aircraft into proper orientation (bug in presets or reset?)
   97          setprop("/orientation/roll-deg", 0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/physics.nas:
  154  bushkit_changed_timer.singleShot = 1;
  155  
  156: setlistener("/sim/signals/fdm-initialized", func {
  157      # Update the 3D model when changing bush kit
  158:     setlistener("/fdm/jsbsim/bushkit", func (n) {
  159          set_bushkit(n.getValue());
  160      }, 1, 0);
  161  
  162:     setlistener("/fdm/jsbsim/crash", func (n) {
  163          if (n.getBoolValue() and getprop("position/altitude-agl-m") < 10) {
  164              killengine();
  ...
  166      }, 0, 0);
  167  
  168:     setlistener("/fdm/jsbsim/wing-damage/left-wing", func (n) {
  169          var damage = n.getValue();
  170          var altitude = getprop("position/altitude-agl-m");
  ...
  174      }, 0, 0);
  175  
  176:     setlistener("/fdm/jsbsim/wing-damage/right-wing", func (n) {
  177          var damage = n.getValue();
  178          var altitude = getprop("position/altitude-agl-m");

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/tanks.nas:
    3  # /fdm/jsbsim/propulsion/tank[]/priority
    4  
    5: setlistener("consumables/fuel/tank[0]/selected", func(selected) {
    6      setprop("/fdm/jsbsim/propulsion/tank[0]/priority", selected.getBoolValue() ? 1 : 0);
    7  });
    8  
    9: setlistener("consumables/fuel/tank[1]/selected", func(selected) {
   10      setprop("/fdm/jsbsim/propulsion/tank[1]/priority", selected.getBoolValue() ? 1 : 0);
   11  });

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/tiedowns.nas:
  124  var tiedown_tail_updater  = TiedownPositionUpdater.new("tail");
  125  
  126: setlistener("/sim/signals/fdm-initialized", func {
  127:     setlistener("/sim/model/c172p/securing/tiedownL-visible", func (node) {
  128          tiedown_left_updater.enable_or_disable(node.getValue());
  129      }, 1, 0);
  130  
  131:     setlistener("/sim/model/c172p/securing/tiedownR-visible", func (node) {
  132          tiedown_right_updater.enable_or_disable(node.getValue());
  133      }, 1, 0);
  134  
  135:     setlistener("/sim/model/c172p/securing/tiedownT-visible", func (node) {
  136          tiedown_tail_updater.enable_or_disable(node.getValue());
  137      }, 1, 0);
  138  
  139:     setlistener("/fdm/jsbsim/damage/repairing", func (node) {
  140          # When the aircraft has been repaired (value is switched back
  141          # to 0), compute the new initial length of the tiedowns

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Tutorials/amphibious-night.xml:
   59                  var listeners = std.Vector.new();
   60  
   61:                 listeners.append(setlistener("/sim/signals/fdm-initialized", func (node) {
   62                      if (node.getBoolValue()) {
   63                          setprop("/controls/switches/starter", 0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Tutorials/amphibious-takeoff.xml:
   54                  var listeners = std.Vector.new();
   55  
   56:                 listeners.append(setlistener("/sim/signals/fdm-initialized", func (node) {
   57                      if (node.getBoolValue()) {
   58                          setprop("/controls/switches/starter", 0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Tutorials/engine-failure.xml:
  117                  var listeners = std.Vector.new();
  118  
  119:                 listeners.append(setlistener("/engines/active-engine/running", func (node) {
  120                      if (node.getBoolValue()) {
  121                          setprop("/controls/switches/starter", 0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Tutorials/landing.xml:
  176                  var listeners = std.Vector.new();
  177  
  178:                 listeners.append(setlistener("/engines/active-engine/running", func (node) {
  179                      if (node.getBoolValue()) {
  180                          setprop("/controls/switches/starter", 0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Tutorials/pattern.xml:
  159                  var listeners = std.Vector.new();
  160  
  161:                 listeners.append(setlistener("/engines/active-engine/running", func (node) {
  162                      if (node.getBoolValue()) {
  163                          setprop("/controls/switches/starter", 0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Tutorials/runup.xml:
  125                  var listeners = std.Vector.new();
  126  
  127:                 listeners.append(setlistener("/engines/active-engine/running", func (node) {
  128                      if (node.getBoolValue()) {
  129                          setprop("/controls/switches/starter", 0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Tutorials/takeoff.xml:
  137                  var listeners = std.Vector.new();
  138  
  139:                 listeners.append(setlistener("/engines/active-engine/running", func (node) {
  140                      if (node.getBoolValue()) {
  141                          setprop("/controls/switches/starter", 0);

/mnt/GDrive/Aircraft/Development Aircraft/c172p/Tutorials/taxiing.xml:
  148                  var listeners = std.Vector.new();
  149  
  150:                 listeners.append(setlistener("/engines/active-engine/running", func (node) {
  151                      if (node.getBoolValue()) {
  152                          setprop("/controls/switches/starter", 0);

84 matches across 22 files
wlbragg commented 5 years ago

This error is accounted for...

.61 [ALRT]:nasal      Nasal runtime error: Timer is running, cannot change type between real/sim time
  205.61 [ALRT]:nasal        at /mnt/GDrive/Aircraft/Development Aircraft/c172p/Nasal/engine.nas, line 500
  205.61 [ALRT]:nasal        called from: /home/wayne/FGFS/install/flightgear/fgdata/Nasal/globals.nas, line 119

This is the error I am now getting that I can't account for. I'm seeing it after re-init's but with various different amounts of "too few function args"?

211.76 [ALRT]:nasal Nasal runtime error: too few function args (have 0 need 24) 211.76 [ALRT]:nasal at Segmentation fault

wlbragg commented 5 years ago

Can anyone else verify something for me? Using the master branch, startup with the default gear and then to an airport relocation to Harrison SkyRanch 9V3 It's already there in the default search list. See if you get and nasal errors or segfault. If not the first time then try a few other random airports and see what happens.

wlbragg commented 5 years ago

If it does segfault or you get some errors try adding

    if (carb_icing_function.isRunning) {
        carb_icing_function.stop();
    }
    if (calculate_real_oiltemp.isRunning) {
        calculate_real_oiltemp.stop();
    }
    if (coughing_timer.isRunning) {
        coughing_timer.stop();
    }
        if (oil_consumption.isRunning) {
        oil_consumption.stop();
    }

to engines.nas and try again.

gilbertohasnofb commented 5 years ago

@wlbragg I loaded the sim, started the engine, changed the airport via the menu inside the sim, everything went fine and the engine continued to be on, I turned it off and back on, all working normal. Checked my ~/.fgfs/fgfs.log file and found no such Nasal errors that you mentioned. I am running FG 2018.3.1 and the current master of our aircraft. Let me know if you want me to test anything specific.

wlbragg commented 5 years ago

I am running FG 2018.3.1

Is that the last stable release? Can anyone try this with the new 2019.1.1 release candidate?

wlbragg commented 5 years ago

I don't trust anything i am seeing at this point. My hydo variants are acting so buggy I can't even use them. Can someone else please verify that the floats and amphibian are working correctly on the water and over land. That you don't notice any glaring bug in them. Things like switching between default, float, amphibian and if float and amphibian work correctly over land as well as water. Does your wake and spray effect work correctly, it shuts off when you leave the surface of the water in both float and amphibian?

wlbragg commented 5 years ago

@gilbertohasnofb

changed the airport via the menu inside the sim, everything went fine and the engine continued to be on

Try changing airports through the GUI a few times in a row.

wlbragg commented 5 years ago

I'm also having trouble starting at an airport that also has a seaport nearby and using the "Go now" button. When it reloads at the seaport after the re-init the default gear is selected instead of the float variant that was selected. I also think this https://github.com/c172p-team/c172p/commit/62eef41b8629532d65cde40ffd6ab2b691a29b53 should actually be

        <fcs_function name="tmp/floats-enabled-norm">
            <function>
                <product>
                    <value>1.0</value>
                    <and>
                        <ge>
                            <property>bushkit</property>
                            <value>3.0</value>
                        </ge>
                        <le>
                            <property>bushkit</property>
                            <value>4.0</value>
                        </le>
                    </and>
                    <not>
                        <and>
                            <property>contact/unit[13]/solid</property>
                            <property>contact/unit[14]/solid</property>
                            <property>contact/unit[15]/solid</property>
                            <property>contact/unit[16]/solid</property>
                            <property>contact/unit[17]/solid</property>
                            <property>contact/unit[18]/solid</property>
                        </and>
                    </not>
                </product>
            </function>
            <output>floats-enabled-norm</output>
        </fcs_function>
wlbragg commented 5 years ago

I am so totally frustrated I am about to call it quits. I don't know if it is 2019.1.1 (next) in my case and a fairly recent build of FGFS or what. Nothing that does a re-init is working correctly. Mooring, airport relocation, tutorials. Not only in the c172p but also the j3cub. I am at my wits end. Until I get some kind of verification that this is not just me, I am stuck. If it is me then I need to rebuild and start over. Something is seriously wrong. The closest I can get to a cause is an error like this

75.73 [ALRT]:nasal      Nasal runtime error: too few function args (have 0 need 5)
   75.73 [ALRT]:nasal        at 

and the "(have 0 need 5)" part has been as low as (have 0 need 2) and as high as (have 0 need 15). I'm guessing that it is a nasal error that is breaking everything after the nasal error. That is assuming I don't crash with a segfault.

wlbragg commented 5 years ago

My float and amphibian is pretty well broken as well, in master. I can't even determine what the issue is other than the determination as to whether it is in water is not working and I can't tell if it is because of some unseen error breaking the code that is executed after the unseen error. If that make any sense.

wlbragg commented 5 years ago

Best I can tell is the fdm/jsbsim/hydro/active-norm is not setting to 0 when it should be. I have tried tracing the issue but can't find it. My system is so messed up I can't even get to a stable point to start troubleshooting any of this.

wlbragg commented 5 years ago

What I really need to know I guess is if anyone else has tested any of this and if it is all working. Do your floats and amphibious work on water and does the wake effect stop when airborne? Can you use the "Go now" button to relocate to a seaport when using either floats or amphibious? Can you relocate to another airport in any variant several times in a row?

You can use Hilo International, Hawaii PHTO for seaport relocation.

legoboyvdlp commented 5 years ago

Let me try it tomorrow and see, I'm using self-compiled next.

wlbragg commented 5 years ago

Thanks @legoboyvdlp

legoboyvdlp commented 5 years ago

It initially seemed fine after I hit "Go Now", but then I noticed something odd...

image

Wake does not stop after I takeoff: image

But the hydronamics seem to be fine?

I don't see any of the nasal errors.

wlbragg commented 5 years ago

Oh, no. It's not just me. I guess I am going to have to do some git bisecting and see what happened. @legoboyvdlp I think I narrowed down why the effect doesn't shut off and that is because fdm/jsbsim/hydro/active-norm never goes to 0 unlessfdm/jsbsim/ground/solid=0 Where ground solid is part of the equation but it wasn't the only determining factor. It also checks

<sum>
                        <property>hydro/buoyancy-lbs</property>
                        <property>hydro/planing-lift-lbs</property>
                    </sum>

which I assume is 0 if the floats are not touching the surface of the water.

wlbragg commented 5 years ago

I think I isolated the gear not changing because in c172p-set.xml <path>/fdm/jsbsim/bushkit</path> has been removed from the saved aircraft data. After adding that line back in then my problem is that the float works when relocating to the seaport but not the amphibious. And the particle effect not turning off, of course.

wlbragg commented 5 years ago

But when I do start my relocation to seaport with the float VS the amphibian I get a segfault a good percentage of the time.

wlbragg commented 5 years ago

I'm really getting concerned here. I keep confusing new work with what is in master. Here is what is concerning to me. This is master that appears to be broke in a few ways. This does not contain any new work, or very little. Nothing I think that would account for any of this. Now to confirm my suspicion I went all the way back to e806c5a433569c34b527d9fb9226dbea0080f73b during the time we added the float and amphibian tutorials which I know were working correctly, that time frame is just as broke, this has to be a core change! Beware, the j3cub us just as broke. But it does parallel this aircraft in a lot of these systems and changes.

@legoboyvdlp @gilbertohasnofb I need verification that this is not something we did, however you choose to verify this so I can take it to the dev list and get to the bottom of this.

wlbragg commented 5 years ago

Another thing I am banging my head against the wall over. I can relocate with the floats selected and start out floating (if I don't happen to get a segfault) but not with the amphibious. If I try to do a relocation to seaport with the amphibious selected, it starts out sunk and doesn't float. But if I start with the floats and then after the relocation I switch to the amphibious it works. I can't find the common denominator.

legoboyvdlp commented 5 years ago

Maybe you could push the fix for the particles so we are using an equivalent branch?

legoboyvdlp commented 5 years ago

Just to note the aircraft seemed to float fine, after 40 knots I definitely noticed the step and some bouncing. The only bug I noticed was the aircraft going back to default gear after reinit and the spray not turning off after takeoff both of which are due to the missing property in the set file?

I didn't see the other things whether they be no floating, nasal errors, segment faults or other things.

wlbragg commented 5 years ago

The only bug I noticed was the aircraft going back to default gear after reinit and the spray not turning off after takeoff both of which are due to the missing property in the set file?

Unfortunately not. Start the sim, switch to amphibian, "go now" to seaport and go to external view. Are you floating on the floats or are they sunk?

Now try the same exact thing with the floats instead of amphibian. Start the sim, switch to floats, not amphibian, "go now" to seaport and go to external view. Are you floating on the floats or are they sunk?

In both cases the wake effect doesn't turn off when leaving the surface and that has nothing to do with the missing saved data line. The missing saved data line is trivial and not the cause of any of the really bad bugs.

legoboyvdlp commented 5 years ago

Regardless it would be good to get it into master to be sure that we're both seeing the same things (ie seeing the bad bugs if we see a problem, not the "good" bugs 😀 )

I'll try and do it locally anyway

legoboyvdlp commented 5 years ago

With floats: I get a FlightGear crash a few seconds after hitting "Go Now". I didn't see any segfaults or anything in the log - last message is 252.94 [INFO]:flight c:\users\redpa\documents\flightgear\fg-from-scratch\flightgear-git\src\fdm\jsbsim\jsbsim.cxx:577:64: GEAR_CONTACT: 2.91667 seconds: COCKPIT_TOP 1 253.37 [INFO]:flight c:\users\redpa\documents\flightgear\fg-from-scratch\flightgear-git\src\fdm\jsbsim\jsbsim.cxx:577:65: GEAR_CONTACT: 3.35 seconds: COCKPIT_TOP 0

Note that Issue-1267 works excellently - I automatically get put on the water with no crash after re-starting FlightGear.

image

It stayed like that until I got above 15 knots at which point I "sank" as such: image Then at about 20 knots it rose up again image

The particles remain on after takeoff image

legoboyvdlp commented 5 years ago

Hitting "go now" with amphibian works. But I'm not floating.

image

I got stuck there - when I hit ctrl + u particles are enabled

image

So floats doesn't work at all - hitting "go now" with amphibian doesn't either even though it initialises properly.

Starting flightgear with floats pre-selected and spawn on startup works - but particles are broken and I'm not so sure if its behaving correctly as seen in my screenshots in my first post.

Starting with amphibian doesn't work either as its sunk: image

legoboyvdlp commented 5 years ago

So to summarize:

wlbragg commented 5 years ago

starting on runway and hitting GO NOW causes a crash with floats

I actually think that is relatively normal, although I don't remember it being this consistent. In fact, I remember struggling with the decision to turn off "Allow damage" before doing the relocation. I wouldn't have been surprised at all if I had turned it off in the code prior to re-init. I will check history to see if that had ever been done and somehow got regressed. Our damage code could stand some love. I think the initial numbers when doing a water startup are just too high to allow damage to be on until it settles.

tarting directly on the water (using the checkbox in aircraft options) works with floats but something is odd

If your talking about the sinking at a slow KT, I think that is also normal. It's caused by drag and I'm not too concerned. In fact I've seen video of floats at low speed pull back on the yoke to "dig in" and slow the aircraft.

The other observations are confirming my observations, except I never tried to start out the gate on the water. I'll test that today.

I think my other observation of it feeling really sluggish when taking off is that the particle effect is really bogging it down. I never was satisfied with the particle effect code, it is way to heavy. you can see that now when off the ground or before if you looked under the water. I just need to spend some time with on it and make a new or adjust it. Now that I get the full effect of how much it affects the performance when left on, I want to reduce the performance cost when on the water as I think it will be much smoother and more sensitive on the water if those effects are really reduced and optimized.

Note that Issue-1267 works excellently - I automatically get put on the water with no crash after re-starting FlightGear.

I am mostly concerned with the FlightGear crashing. If it did it once, you will find it does it intermittently and you can't pin it to one float variant or the other or to one PR or another. Even the new PR Issue-1267 doesn't fix any of this. All that did was to make the bushkit parameter persistent. The fact that you didn't crash FG or the aircraft was random, Do it a few times and you'll see what I am talking about.

The other thing I can't wrap my head around is why you can do the relocation in the float and then switch to amphibian and it works, but you can't do a relocation with amphibian, it sinks? There is something very strange going on there.

I was able to get the float to startup in the water , still not the amphibian. Starting in the water is the same as doing a relocation. It does the same thing only quicker.

I did notice this and I don't know if it is normal, the float appeared to stabilize shortly after on its own. float I tried turning of everything fog/frost, complex engine, even particles under rendering to see if it stopped the segfaults. I don't have a definitive result yet.

legoboyvdlp commented 5 years ago

Do you have a state of both the aircraft and FlightGear when you know it worked? I'm prepared to spend a few hours tomorrow bisecting if it will help...

legoboyvdlp commented 5 years ago

I actually think that is relatively normal, although I don't remember it being this consistent. In fact, I remember struggling with the decision to turn off "Allow damage" before doing the relocation. I wouldn't have been surprised at all if I had turned it off in the code prior to re-init. I will check history to see if that had ever been done and somehow got regressed. Our damage code could stand some love. I think the initial numbers when doing a water startup are just too high to allow damage to be on until it settles.

A crash as in FlightGear exiting but with no console output - sorry for the confusion :grinning:

And for reference each time I was starting FlightGear with the default variant at PHTO, on the runway.

Yeah, Issue-1267 is unrelated to the segfaults, but it works fine and saves the aircraft state properly - if you think it's ready to merge I can go ahead and do so.

wlbragg commented 5 years ago

A crash as in FlightGear exiting but with no console output - sorry for the confusion

No, as in damage to the aircraft.

Yes, you can merge 1267.

I think the fgfs version that breaks this is 2019..x I think we will find 2018.3.x possibly working. That is the bisect we need to determine when it broke, fgfs versions and then at commit level, not aircraft.

wlbragg commented 5 years ago

Reminder to myself, change float and amphibious selection capable condition to not on the water VS not over the water.

legoboyvdlp commented 5 years ago

I meant as in FlightGear exiting - there was sometimes damage to the aircraft after re-initing but I definitely got a FlightGear crash wiht flaots. But then restarting I didn't get it... because it put me on the water runway directly (maybe before nasal was initialized?)

wlbragg commented 5 years ago

Ah, good information. Yes I hadn't noticed if I crashed as much starting on the water. When your talking about starting on the water I assume you mean you check the box in the GUI that lets you start on the water during the next startup if there is a seaport near that location?

legoboyvdlp commented 5 years ago

Yeah

It then automatically put me on water next start at PHTO without toggling it

With floats it worked on the second launch, amphibian didn't (sunken).

And regardless after hitting GO NOW on the first launch floats segfaulted (I assume, I don't see any log error, it just exits) and amphibian was sunken.

Didn't get a chance to bisect today but will try to do so next week

gilbertohasnofb commented 5 years ago

@wlbragg @legoboyvdlp Apologies for not participating in the discussion during these last days, I had to finish an important work for my uni and had no time for anything else. Where are we standing on the issue with the floats, are they still broken, and do we still get all those error messages in the log? And have we managed to narrow down what might be causing it? As I mentioned before, I am running 2018.3 and I was not seeing the error messages that @wlbragg was seeing. I am happy to help troubleshooting this, particularly if we want to compare different versions of FG.

wlbragg commented 5 years ago

@gilbertohasnofb yes it is still broken. No we really haven't narrowed anything down yet. I am pretty sure this is a symptom of core changes to FGFS or JSBSim. It requires a newer version of FGFS to show up. I need to rebuild with the latest to see if maybe it magically goes away. We need to verify if it is broken on the newest release candidate. There are three overall issues best we can tell.

1) Something in one of the properties used to drive the particle effect of the wake is not working as it used to. Specifically it is not zeroing out when it used to. I think I have narrowed it down to see: https://github.com/c172p-team/c172p/issues/1265#issuecomment-479129141

2) You cannot initialize on the water starting with the amphibious variant or neither amphibious or float works correctly, they sink in the water and act like there is no buoyancy, it makes sense that it to might be related to https://github.com/c172p-team/c172p/issues/1265#issuecomment-479129141 But if you initialize on the water starting with the float variant, then both the float and amphibious works and float as they should. Very strange and I haven't determined why this is yet, why one way works and the other doesn't.

3) Any re-init, airport relocation, water relocation, maybe the save/resume is subject to random segfaults either with vague nasal errors (see https://github.com/c172p-team/c172p/issues/1265#issuecomment-478360294 and https://github.com/c172p-team/c172p/issues/1265#issuecomment-478416763 ) or no error message (see https://github.com/c172p-team/c172p/issues/1265#issuecomment-479834811 ).

gilbertohasnofb commented 5 years ago

@wlbragg Thank you so much for the concise summary of the issues, I had missed a lot of the discussion so far. So, have the devs been warned about these issues? They look pretty major to me!

@legoboyvdlp Can you confirm you are also running 2019.1 and you also see the issues that @wlbragg is seeing?

legoboyvdlp commented 5 years ago

I can see them all, yes, I am running a self compiled next about a week out of date.

wlbragg commented 5 years ago

HELP Someone needs to walk me through this. If any property or equation contributing to the product portion of this function is 0 then the active-norm has to be 0, correct?

<fcs_function name="hydro/active-norm">
            <description>
                A property that is 0 when no part of the hull is in the water.
                The maximum value is 1.
            </description>
            <function>
                <product>
                    <property>floats-enabled-norm</property>
                    <value>0.001</value>
                    <lt>
                        <value>-100.0</value>
                        <property>hydro/float/roll-deg</property>
                    </lt>
                    <lt>
                        <property>hydro/float/roll-deg</property>
                        <value>100.0</value>
                    </lt>
                    <sum>
                        <property>hydro/buoyancy-lbs</property>
                        <property>hydro/planing-lift-lbs</property>
                    </sum>
                </product>
            </function>
            <clipto>
                <min>0.0</min>
                <max>1.0</max>
            </clipto>
        </fcs_function>

That is the bottom line issue with the floats as best I can tell. active-norm is still containing a positive value even when a contributing input to the product is at 0. In other words I am not seeing any issue with the contributing properties. Only the derived product. If you follow out the particle effect trigger it goes to here...

<fcs_function name="hydro/spray-wake-speed-kt">
            <function>
                <product>
                    <not>
                        <property>/fdm/jsbsim/ground/solid</property>
                    </not>
                    <gt>
                        <property>hydro/active-norm</property>
                        <value>0.0</value>
                    </gt>
                    <property>/velocities/groundspeed-kt</property>
                </product>
            </function>
        </fcs_function>

which relies on hydro/active-norm to be 0 when over water to shut off the effect.

wlbragg commented 5 years ago

Something else I noticed in the process is this timer, is this timer "safe" should we replace it with start-stop and should we maybe also use a listener to activate it so it only runs when needed? I don't think it is necessarily a heavy lift, but this stuff all adds up.

var ground = func {
    # Send the current ground level to the JSBSim hydrodynamics model.
    setprop("/fdm/jsbsim/hydro/environment/water-level-ft",
            getprop("/position/ground-elev-ft") +
            getprop("/fdm/jsbsim/hydro/environment/wave-amplitude-ft"));

    # Connect the JSBSim hydrodynamics wave model with the custom water shader.
    setprop("environment/waves/time-sec",
            getprop("/fdm/jsbsim/simulation/sim-time-sec"));
    setprop("environment/waves/from-deg",
            getprop("/fdm/jsbsim/hydro/environment/waves-from-deg"));
    setprop("environment/waves/length-ft",
            getprop("/fdm/jsbsim/hydro/environment/wave-length-ft"));
    setprop("environment/waves/amplitude-ft",
            getprop("/fdm/jsbsim/hydro/environment/wave-amplitude-ft"));
    setprop("environment/waves/angular-frequency-rad_sec",
            getprop("/fdm/jsbsim/hydro/environment/wave/angular-frequency-rad_sec"));
    setprop("environment/waves/wave-number-rad_ft",
            getprop("/fdm/jsbsim/hydro/environment/wave/wave-number-rad_ft"));

    settimer(ground, 0.0);
}

settimer(ground, 0.0);
wlbragg commented 5 years ago

OK, the issue with the amphibious model not initializing correctly in the water is that hydro/active-norm is at 0. That appears to be because floats-enabled-norm is not initializing to > 0

<fcs_function name="tmp/floats-enabled-norm">
            <function>
                <product>
                    <value>1.0</value>
                    <le>
                        <value>3.0</value>
                        <property>bushkit</property>
                    </le>
                    <le>
                        <property>bushkit</property>
                        <value>4.0</value>
                    </le>
                    <not>
                        <and>
                            <property>contact/unit[13]/solid</property>
                            <property>contact/unit[14]/solid</property>
                            <property>contact/unit[15]/solid</property>
                            <property>contact/unit[16]/solid</property>
                            <property>contact/unit[17]/solid</property>
                            <property>contact/unit[18]/solid</property>
                        </and>
                    </not>
                </product>
            </function>
            <output>floats-enabled-norm</output>
        </fcs_function>

I even tried this to be sure this logic is correct.

                    <or>
                        <eq>
                            <property>bushkit</property>
                            <value>3.0</value>
                        </eq>
                        <eq>
                            <property>bushkit</property>
                            <value>4.0</value>
                        </eq>
                    </or>
wlbragg commented 5 years ago

@dany93 Something else I just noticed, these are now being flagged in jsbsim warnings as single input products. We really should clean this stuff up. It would make reading the log a bit easier.

        <function name="aero/function/kCDge">
            <description>Change_in_drag_due_to_ground_effect</description>
            <product>
                <table>
                    <independentVar>aero/h_b-mac-ft</independentVar>
                    <tableData>
                          0.0000    0.4800
                          0.1000    0.5150
                          0.1500    0.6290
                          0.2000    0.7090
                          0.3000    0.8150
                          0.4000    0.8820
                          0.5000    0.9280
                          0.6000    0.9620
                          0.7000    0.9880
                          0.8000    1.0000
                          0.9000    1.0000
                          1.0000    1.0000
                          1.1000    1.0000
                      </tableData>
                </table>
            </product>
        </function>

        <function name="aero/function/kCLge">
            <description>Change_in_lift_due_to_ground_effect</description>
            <product>
                <table>
                    <independentVar>aero/h_b-mac-ft</independentVar>
                    <tableData>
                          0.0000    1.2030
                          0.1000    1.1270
                          0.1500    1.0900
                          0.2000    1.0730
                          0.3000    1.0460
                          0.4000    1.0280
                          0.5000    1.0190
                          0.6000    1.0130
                          0.7000    1.0080
                          0.8000    1.0060
                          0.9000    1.0030
                          1.0000    1.0020
                          1.1000    1.0000
                      </tableData>
                </table>
            </product>
        </function>