Add a command which will setup the temperature field in the boundary and
aloft layers to match a current OAT at the current altitude. This can be run from an external script or gui. Given the specified OAT (and the current aircraft altitude), the code calculates the equivalent sea level temperature, and then assigns that to all active boundary and aloft environment layers.
This commit is contained in:
parent
4a5961ca5b
commit
76107017cb
1 changed files with 51 additions and 0 deletions
|
@ -16,6 +16,7 @@
|
|||
|
||||
#include <Cockpit/panel.hxx>
|
||||
#include <Cockpit/panel_io.hxx>
|
||||
#include <Environment/environment.hxx>
|
||||
#include <FDM/flight.hxx>
|
||||
#include <GUI/gui.h>
|
||||
#include <GUI/new_gui.hxx>
|
||||
|
@ -470,6 +471,55 @@ do_tile_cache_reload (const SGPropertyNode * arg)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the outside air temperature at the "current" altitude by first
|
||||
* calculating the corresponding sea level temp, and assigning that to
|
||||
* all boundary and aloft environment layers.
|
||||
*/
|
||||
static bool
|
||||
do_set_oat_degc (const SGPropertyNode * arg)
|
||||
{
|
||||
const string &temp_str = arg->getStringValue("temp-degc", "15.0");
|
||||
|
||||
static const SGPropertyNode *altitude_ft
|
||||
= fgGetNode("/position/altitude-ft");
|
||||
|
||||
FGEnvironment dummy; // instantiate a dummy so we can leech a method
|
||||
dummy.set_elevation_ft( altitude_ft->getDoubleValue() );
|
||||
dummy.set_temperature_degc( atof( temp_str.c_str() ) );
|
||||
double temp_sea_level_degc = dummy.get_temperature_sea_level_degc();
|
||||
|
||||
cout << "Altitude = " << altitude_ft->getDoubleValue() << endl;
|
||||
cout << "Temp at alt (C) = " << atof( temp_str.c_str() ) << endl;
|
||||
cout << "Temp sea level (C) = " << temp_sea_level_degc << endl;
|
||||
|
||||
SGPropertyNode *node, *child;
|
||||
|
||||
// boundary layers
|
||||
node = fgGetNode( "/environment/config/boundary" );
|
||||
if ( node != NULL ) {
|
||||
int i = 0;
|
||||
while ( ( child = node->getNode( "entry", i ) ) != NULL ) {
|
||||
child->setDoubleValue( "temperature-sea-level-degc",
|
||||
temp_sea_level_degc );
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
// aloft layers
|
||||
node = fgGetNode( "/environment/config/aloft" );
|
||||
if ( node != NULL ) {
|
||||
int i = 0;
|
||||
while ( ( child = node->getNode( "entry", i ) ) != NULL ) {
|
||||
child->setDoubleValue( "temperature-sea-level-degc",
|
||||
temp_sea_level_degc );
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the lighting manually.
|
||||
*/
|
||||
|
@ -983,6 +1033,7 @@ static struct {
|
|||
{ "view-cycle", do_view_cycle },
|
||||
{ "screen-capture", do_screen_capture },
|
||||
{ "tile-cache-reload", do_tile_cache_reload },
|
||||
{ "set-outside-air-temp-degc", do_set_oat_degc },
|
||||
{ "timeofday", do_timeofday },
|
||||
{ "property-toggle", do_property_toggle },
|
||||
{ "property-assign", do_property_assign },
|
||||
|
|
Loading…
Add table
Reference in a new issue