#include <stdio.h>
-#include <Debug/fg_debug.h>
-#include <Flight/flight.h>
+#include "flight.hxx"
+#include "LaRCsim.hxx"
+
+#include <Debug/logstream.hxx>
#include <Flight/LaRCsim/ls_interface.h>
#include <Include/fg_constants.h>
-#include <Math/fg_geodesy.h>
+#include <Math/fg_geodesy.hxx>
fgFLIGHT cur_flight_params;
/* Initialize the flight model parameters */
-int fgFlightModelInit(int model, fgFLIGHT *f, double dt) {
+int fgFlightModelInit(int model, fgFLIGHT& f, double dt) {
double save_alt = 0.0;
int result;
- fgPrintf(FG_FLIGHT,FG_INFO,"Initializing flight model\n");
+ FG_LOG( FG_FLIGHT ,FG_INFO, "Initializing flight model" );
if ( model == FG_SLEW ) {
// fgSlewInit(dt);
} else if ( model == FG_LARCSIM ) {
/* lets try to avoid really screwing up the LaRCsim model */
- if ( FG_Altitude < -9000 ) {
- save_alt = FG_Altitude;
- FG_Altitude = 0;
+ if ( f.get_Altitude() < -9000.0 ) {
+ save_alt = f.get_Altitude();
+ f.set_Altitude( 0.0 );
}
fgFlight_2_LaRCsim(f); /* translate FG to LaRCsim structure */
fgLaRCsimInit(dt);
- fgPrintf( FG_FLIGHT, FG_INFO, "FG pos = %.2f\n", FG_Latitude );
+ FG_LOG( FG_FLIGHT, FG_INFO, "FG pos = " << f.get_Latitude() );
fgLaRCsim_2_Flight(f); /* translate LaRCsim back to FG structure */
/* but lets restore our original bogus altitude when we are done */
- if ( save_alt < -9000 ) {
- FG_Altitude = save_alt;
+ if ( save_alt < -9000.0 ) {
+ f.set_Altitude( save_alt );
}
} else {
- fgPrintf( FG_FLIGHT, FG_WARN,
- "Unimplemented flight model == %d\n", model );
+ FG_LOG( FG_FLIGHT, FG_WARN,
+ "Unimplemented flight model == " << model );
}
result = 1;
/* Run multiloop iterations of the flight model */
-int fgFlightModelUpdate(int model, fgFLIGHT *f, int multiloop) {
+int fgFlightModelUpdate(int model, fgFLIGHT& f, int multiloop) {
double time_step, start_elev, end_elev;
int result;
// printf("Altitude = %.2f\n", FG_Altitude * 0.3048);
time_step = (1.0 / DEFAULT_MODEL_HZ) * multiloop;
- start_elev = FG_Altitude;
+ start_elev = f.get_Altitude();
if ( model == FG_SLEW ) {
// fgSlewUpdate(f, multiloop);
} else if ( model == FG_LARCSIM ) {
fgLaRCsimUpdate(f, multiloop);
} else {
- fgPrintf( FG_FLIGHT, FG_WARN,
- "Unimplemented flight model == %d\n", model );
+ FG_LOG( FG_FLIGHT, FG_WARN,
+ "Unimplemented flight model == " << model );
}
- end_elev = FG_Altitude;
+ end_elev = f.get_Altitude();
- FG_Climb_Rate = (end_elev - start_elev) / time_step; /* feet per second */
+ // feet per second
+ f.set_Climb_Rate( (end_elev - start_elev) / time_step );
result = 1;
/* Set the altitude (force) */
-int fgFlightModelSetAltitude(int model, fgFLIGHT *f, double alt_meters) {
+void fgFlightModelSetAltitude(int model, fgFLIGHT& f, double alt_meters) {
double sea_level_radius_meters;
double lat_geoc;
// Set the FG variables first
- fgGeodToGeoc( FG_Latitude, alt_meters,
+ fgGeodToGeoc( f.get_Latitude(), alt_meters,
&sea_level_radius_meters, &lat_geoc);
- FG_Altitude = alt_meters * METER_TO_FEET;
- FG_Radius_to_vehicle = FG_Altitude +
- (sea_level_radius_meters * METER_TO_FEET);
+ f.set_Altitude( alt_meters * METER_TO_FEET );
+ f.set_Radius_to_vehicle( f.get_Altitude() +
+ (sea_level_radius_meters * METER_TO_FEET) );
/* additional work needed for some flight models */
if ( model == FG_LARCSIM ) {
- ls_ForceAltitude(FG_Altitude);
+ ls_ForceAltitude( f.get_Altitude() );
}
}
// $Log$
+// Revision 1.4 1998/12/03 01:16:40 curt
+// Converted fgFLIGHT to a class.
+//
+// Revision 1.3 1998/11/06 21:18:03 curt
+// Converted to new logstream debugging facility. This allows release
+// builds with no messages at all (and no performance impact) by using
+// the -DFG_NDEBUGNDEBUG flag.
+//
+// Revision 1.2 1998/10/16 23:27:40 curt
+// C++-ifying.
+//
// Revision 1.1 1998/10/16 20:16:41 curt
// Renamed flight.[ch] to flight.[ch]xx
//