X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FNetwork%2Fgarmin.cxx;h=00a266f47f6496daa6f924f2268372e31ee2ec1c;hb=17c96ae69ed7a3c33c816e821ae88c501ab7cf65;hp=2505c39db560a47691fe4a64961139761b4dea7a;hpb=0ffa19cd32c02405d0e740393b37f4009ed5a312;p=flightgear.git diff --git a/src/Network/garmin.cxx b/src/Network/garmin.cxx index 2505c39db..00a266f47 100644 --- a/src/Network/garmin.cxx +++ b/src/Network/garmin.cxx @@ -22,12 +22,12 @@ #include -#include -#include +#include +#include #include +#include
-#include "iochannel.hxx" #include "garmin.hxx" @@ -67,14 +67,14 @@ bool FGGarmin::gen_message() { int deg; double min; - SGTime *t = SGTime::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'; @@ -86,7 +86,7 @@ bool FGGarmin::gen_message() { 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'; @@ -101,7 +101,7 @@ bool FGGarmin::gen_message() { 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", @@ -236,7 +236,7 @@ bool FGGarmin::parse_message() { 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 @@ -265,16 +265,18 @@ bool FGGarmin::parse_message() { 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); @@ -285,8 +287,8 @@ bool FGGarmin::parse_message() { 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 @@ -300,7 +302,7 @@ bool FGGarmin::parse_message() { 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 @@ -350,7 +352,7 @@ bool FGGarmin::open() { 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." ); @@ -365,15 +367,15 @@ bool FGGarmin::open() { // 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() ) { @@ -404,7 +406,7 @@ bool FGGarmin::process() { // close the channel bool FGGarmin::close() { - FGIOChannel *io = get_io_channel(); + SGIOChannel *io = get_io_channel(); set_enabled( false );