1 // environment-mgr.cxx -- manager for natural environment information.
3 // Written by David Megginson, started February 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 #include <simgear/debug/logstream.hxx>
25 #include <Main/fg_props.hxx>
26 #include <Aircraft/aircraft.hxx>
28 #include "environment_mgr.hxx"
31 FGEnvironmentMgr::FGEnvironmentMgr ()
33 _environment = new FGEnvironment();
36 FGEnvironmentMgr::~FGEnvironmentMgr ()
42 FGEnvironmentMgr::init ()
44 SG_LOG( SG_GENERAL, SG_INFO, "Initializing environment subsystem");
48 FGEnvironmentMgr::bind ()
50 fgTie("/environment/visibility-m", _environment,
51 &FGEnvironment::get_visibility_m, &FGEnvironment::set_visibility_m);
52 fgSetArchivable("/environment/visibility-m");
53 fgTie("/environment/temperature-sea-level-degc", _environment,
54 &FGEnvironment::get_temperature_sea_level_degc,
55 &FGEnvironment::set_temperature_sea_level_degc);
56 fgSetArchivable("/environment/temperature-sea-level-degc");
57 fgTie("/environment/pressure-sea-level-inhg", _environment,
58 &FGEnvironment::get_pressure_sea_level_inhg,
59 &FGEnvironment::set_pressure_sea_level_inhg);
60 fgSetArchivable("/environment/pressure-sea-level-inhg");
61 fgTie("/environment/wind-from-heading-deg", _environment,
62 &FGEnvironment::get_wind_from_heading_deg,
63 &FGEnvironment::set_wind_from_heading_deg);
64 fgTie("/environment/wind-speed-kt", _environment,
65 &FGEnvironment::get_wind_speed_kt, &FGEnvironment::set_wind_speed_kt);
66 fgTie("/environment/wind-from-north-fps", _environment,
67 &FGEnvironment::get_wind_from_north_fps,
68 &FGEnvironment::set_wind_from_north_fps);
69 fgSetArchivable("/environment/wind-from-north-fps");
70 fgTie("/environment/wind-from-east-fps", _environment,
71 &FGEnvironment::get_wind_from_east_fps,
72 &FGEnvironment::set_wind_from_east_fps);
73 fgSetArchivable("/environment/wind-from-east-fps");
74 fgTie("/environment/wind-from-down-fps", _environment,
75 &FGEnvironment::get_wind_from_down_fps,
76 &FGEnvironment::set_wind_from_down_fps);
77 fgSetArchivable("/environment/wind-from-down-fps");
81 FGEnvironmentMgr::unbind ()
83 fgUntie("/environment/visibility-m");
84 fgUntie("/environment/wind-from-heading-deg");
85 fgUntie("/environment/wind-speed-kt");
86 fgUntie("/environment/wind-from-north-fps");
87 fgUntie("/environment/wind-from-east-fps");
88 fgUntie("/environment/wind-from-down-fps");
92 FGEnvironmentMgr::update (int dt)
94 // FIXME: the FDMs should update themselves
95 current_aircraft.fdm_state
96 ->set_Velocities_Local_Airmass(_environment->get_wind_from_north_fps(),
97 _environment->get_wind_from_east_fps(),
98 _environment->get_wind_from_down_fps());
101 const FGEnvironment *
102 FGEnvironmentMgr::getEnvironment () const
107 const FGEnvironment *
108 FGEnvironmentMgr::getEnvironment (double lat, double lon, double alt) const
110 // Always returns the same environment
111 // for now; we'll make it interesting
116 // end of environment-mgr.cxx