diff --git a/Environment/interpolator.xml b/Environment/interpolator.xml index 400c08b86..04f942d57 100644 --- a/Environment/interpolator.xml +++ b/Environment/interpolator.xml @@ -126,4 +126,36 @@ 5 + + EnvironmentInterpolator:turbulence-magnitude + + + /environment/config/enabled + + + + + /environment/config/presets/turbulence-magnitude-norm-override + + /environment/config/presets/turbulence-magnitude-norm-override + + /environment/config/interpolated/turbulence/magnitude-norm + /environment/turbulence/magnitude-norm + exponential + 1 + + + + EnvironmentInterpolator:turbulence-rate + + + /environment/config/enabled + + + /environment/config/interpolated/turbulence/rate-hz + /environment/turbulence/rate-hz + exponential + 1 + + diff --git a/gui/dialogs/weather.xml b/gui/dialogs/weather.xml index d8594ab87..471dde092 100644 --- a/gui/dialogs/weather.xml +++ b/gui/dialogs/weather.xml @@ -578,6 +578,12 @@ + + 0 + 6 + + + aloft-4-elevation-ft 1 @@ -686,6 +692,33 @@ + + aloft-4-turbulence + 1 + 6 + 90 + true + /environment/config/aloft/entry[4]/turbulence-name + none + light + moderate + severe + + dialog-apply + aloft-4-turbulence + + + nasal + + + + + aloft-3-elevation-ft 2 @@ -794,6 +827,33 @@ + + aloft-3-turbulence + 2 + 6 + 90 + true + /environment/config/aloft/entry[3]/turbulence-name + none + light + moderate + severe + + dialog-apply + aloft-3-turbulence + + + nasal + + + + + aloft-2-elevation-ft 3 @@ -902,6 +962,34 @@ + + aloft-2-turbulence + 3 + 6 + 90 + true + /environment/config/aloft/entry[2]/turbulence-name + none + light + moderate + severe + + dialog-apply + aloft-2-turbulence + + + nasal + + + + + + aloft-1-elevation-ft 4 @@ -1010,6 +1098,33 @@ + + aloft-1-turbulence + 4 + 6 + 90 + true + /environment/config/aloft/entry[1]/turbulence-name + none + light + moderate + severe + + dialog-apply + aloft-1-turbulence + + + nasal + + + + + aloft-0-elevation-ft 5 @@ -1123,6 +1238,34 @@ aloft-0-dewpoint-degc + + + aloft-0-turbulence + 5 + 6 + 90 + true + /environment/config/aloft/entry[0]/turbulence-name + none + light + moderate + severe + + dialog-apply + aloft-0-turbulence + + + nasal + + + + + true @@ -1316,6 +1459,33 @@ + + boundary-1-turbulence + 1 + 6 + 90 + true + /environment/config/boundary/entry[1]/turbulence-name + none + light + moderate + severe + + dialog-apply + boundary-1-turbulence + + + nasal + + + + + boundary-0-elevation-ft 2 @@ -1429,6 +1599,34 @@ boundary-0-dewpoint-degc + + + boundary-0-turbulence + 2 + 6 + 90 + true + /environment/config/boundary/entry[0]/turbulence-name + none + light + moderate + severe + + dialog-apply + boundary-0-turbulence + + + nasal + + + + + true @@ -1593,6 +1791,12 @@ }, open : func { + for( var i = 0; i < 5; i+=1 ) + me.initTurbulence("aloft", i ); + + for( var i = 0; i < 2; i+=1 ) + me.initTurbulence("boundary", i ); + #initialize the METAR source selection if( getprop( "environment/params/metar-updates-environment" ) == 0 ) { setprop( me.base ~ "/source-selection", "Disabled" ); @@ -1713,6 +1917,26 @@ gui.dialog_update( "weather", "metar" ); }, + setTurbulence : func( where, idx ) { + var propPath = "/environment/config/" ~ where ~ "/entry[" ~ idx ~ "]/"; + setprop( propPath ~ "turbulence/magnitude-norm", + me.turbulenceNames[getprop(propPath ~ "turbulence-name")]/(size(me.turbulenceNames)-1) ); + }, + + initTurbulence : func( where, idx ) { + var propPath = "/environment/config/" ~ where ~ "/entry[" ~ idx ~ "]/"; + var turb = getprop( propPath ~ "turbulence/magnitude-norm" ) * (size(me.turbulenceNames)-1); + turb = int(int(10*turb+5)/10); # round to nearest integer + foreach( var t; keys(me.turbulenceNames) ) { + if( me.turbulenceNames[t] == turb ) { + setprop( propPath ~ "turbulence-name", t ); + break; + } + } + }, + + turbulenceNames : { "none" : 0, "light" : 1, "moderate" : 2, "severe" : 3 }, + }; var controller = GlobalWeatherDialogController.new( cmdarg() );