#include <simgear/debug/logstream.hxx>
-#include <simgear/math/fg_geodesy.hxx>
-#include <simgear/timing/fg_time.hxx>
+#include <simgear/math/sg_geodesy.hxx>
+#include <simgear/io/iochannel.hxx>
#include <FDM/flight.hxx>
+#include <Main/globals.hxx>
-#include "iochannel.hxx"
#include "garmin.hxx"
int deg;
double min;
- FGTime *t = FGTime::cur_time_params;
+ SGTime *t = globals->get_time_params();
char utc[10];
sprintf( utc, "%02d%02d%02d",
t->getGmt()->tm_hour, t->getGmt()->tm_min, t->getGmt()->tm_sec );
char lat[20];
- double latd = cur_fdm_state->get_Latitude() * RAD_TO_DEG;
+ double latd = cur_fdm_state->get_Latitude() * SGD_RADIANS_TO_DEGREES;
if ( latd < 0.0 ) {
latd *= -1.0;
dir = 'S';
sprintf( lat, "%02d%06.3f,%c", abs(deg), min, dir);
char lon[20];
- double lond = cur_fdm_state->get_Longitude() * RAD_TO_DEG;
+ double lond = cur_fdm_state->get_Longitude() * SGD_RADIANS_TO_DEGREES;
if ( lond < 0.0 ) {
lond *= -1.0;
dir = 'W';
sprintf( speed, "%05.1f", cur_fdm_state->get_V_equiv_kts() );
char heading[10];
- sprintf( heading, "%05.1f", cur_fdm_state->get_Psi() * RAD_TO_DEG );
+ sprintf( heading, "%05.1f", cur_fdm_state->get_Psi() * SGD_RADIANS_TO_DEGREES );
char altitude_m[10];
sprintf( altitude_m, "%02d",
lat *= -1;
}
- cur_fdm_state->set_Latitude( lat * DEG_TO_RAD );
+ cur_fdm_state->set_Latitude( lat * SGD_DEGREES_TO_RADIANS );
FG_LOG( FG_IO, FG_INFO, " lat = " << lat );
// lon val
lon *= -1;
}
- cur_fdm_state->set_Longitude( lon * DEG_TO_RAD );
+ cur_fdm_state->set_Longitude( lon * SGD_DEGREES_TO_RADIANS );
FG_LOG( FG_IO, FG_INFO, " lon = " << lon );
+#if 0
double sl_radius, lat_geoc;
- fgGeodToGeoc( cur_fdm_state->get_Latitude(),
+ sgGeodToGeoc( cur_fdm_state->get_Latitude(),
cur_fdm_state->get_Altitude(),
&sl_radius, &lat_geoc );
cur_fdm_state->set_Geocentric_Position( lat_geoc,
cur_fdm_state->get_Longitude(),
sl_radius + cur_fdm_state->get_Altitude() );
+#endif
// speed
end = msg.find(",", begin);
string speed_str = msg.substr(begin, end - begin);
begin = end + 1;
speed = atof( speed_str.c_str() );
- cur_fdm_state->set_V_equiv_kts( speed );
- cur_fdm_state->set_V_ground_speed( speed );
+ cur_fdm_state->set_V_calibrated_kts( speed );
+ // cur_fdm_state->set_V_ground_speed( speed );
FG_LOG( FG_IO, FG_INFO, " speed = " << speed );
// heading
heading = atof( hdg_str.c_str() );
cur_fdm_state->set_Euler_Angles( cur_fdm_state->get_Phi(),
cur_fdm_state->get_Theta(),
- heading * DEG_TO_RAD );
+ heading * SGD_DEGREES_TO_RADIANS );
FG_LOG( FG_IO, FG_INFO, " heading = " << heading );
} else if ( sentence == "PGRMZ" ) {
// altitude
return false;
}
- FGIOChannel *io = get_io_channel();
+ SGIOChannel *io = get_io_channel();
if ( ! io->open( get_direction() ) ) {
FG_LOG( FG_IO, FG_ALERT, "Error opening channel communication layer." );
// process work for this port
bool FGGarmin::process() {
- FGIOChannel *io = get_io_channel();
+ SGIOChannel *io = get_io_channel();
- if ( get_direction() == out ) {
+ if ( get_direction() == SG_IO_OUT ) {
gen_message();
if ( ! io->write( buf, length ) ) {
FG_LOG( FG_IO, FG_ALERT, "Error writing data." );
return false;
}
- } else if ( get_direction() == in ) {
+ } else if ( get_direction() == SG_IO_IN ) {
if ( (length = io->readline( buf, FG_MAX_MSG_SIZE )) > 0 ) {
FG_LOG( FG_IO, FG_ALERT, "Success reading data." );
if ( parse_message() ) {
// close the channel
bool FGGarmin::close() {
- FGIOChannel *io = get_io_channel();
+ SGIOChannel *io = get_io_channel();
set_enabled( false );