1 // environment-ctrl.hxx -- controller for environment information.
3 // Written by David Megginson, started May 2002.
5 // Copyright (C) 2002 David Megginson - david@megginson.com
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #ifndef _ENVIRONMENT_CTRL_HXX
24 #define _ENVIRONMENT_CTRL_HXX
26 #include <simgear/compiler.h>
28 #ifdef SG_HAVE_STD_INCLUDES
40 #include <Main/fgfs.hxx>
42 #include "environment.hxx"
47 * Interface to control environment information for a specific location.
49 class FGEnvironmentCtrl : public FGSubsystem
55 virtual ~FGEnvironmentCtrl ();
57 virtual void setEnvironment (FGEnvironment * environment);
59 virtual FGEnvironment * getEnvironment () const { return _environment; }
61 virtual void setLongitudeDeg (double lon_deg);
62 virtual void setLatitudeDeg (double lat_deg);
63 virtual void setElevationFt (double elev_ft);
64 virtual void setPosition (double lon_deg, double lat_deg, double elev_ft);
66 virtual double getLongitudeDeg () const { return _lon_deg; }
67 virtual double getLatitudeDeg () const { return _lat_deg; }
68 virtual double getElevationFt () const { return _elev_ft; }
72 FGEnvironment * _environment;
82 * Environment controller using user-supplied parameters.
84 class FGUserDefEnvironmentCtrl : public FGEnvironmentCtrl
87 FGUserDefEnvironmentCtrl ();
88 virtual ~FGUserDefEnvironmentCtrl ();
91 virtual void update (double dt);
95 SGPropertyNode * _base_wind_speed_node;
96 SGPropertyNode * _gust_wind_speed_node;
98 double _current_wind_speed_kt;
99 double _delta_wind_speed_kt;
106 * Interplation controller using user-supplied parameters.
108 class FGInterpolateEnvironmentCtrl : public FGEnvironmentCtrl
111 FGInterpolateEnvironmentCtrl ();
112 virtual ~FGInterpolateEnvironmentCtrl ();
114 virtual void init ();
115 virtual void reinit ();
116 virtual void update (double delta_time_sec);
122 FGEnvironment environment;
123 bool operator< (const bucket &b) const;
126 void read_table (const SGPropertyNode * node, vector<bucket *> &table);
127 void do_interpolate (vector<bucket *> &table, double altitude_ft,
128 FGEnvironment * environment);
130 FGEnvironment env1, env2; // temporaries
132 vector<bucket *> _boundary_table;
133 vector<bucket *> _aloft_table;
137 #endif // _ENVIRONMENT_CTRL_HXX