//
// This file is in the Public Domain and comes with no warranty.
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
#include <simgear/compiler.h>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/math/sg_random.h>
} else if ( cname == "number" ) {
num = child->getIntValue();
} else {
- SG_LOG( SG_AUTOPILOT, SG_WARN, "Error in dme config logic" );
+ SG_LOG( SG_INSTR, SG_WARN, "Error in dme config logic" );
if ( name.length() ) {
- SG_LOG( SG_AUTOPILOT, SG_WARN, "Section = " << name );
+ SG_LOG( SG_INSTR, SG_WARN, "Section = " << name );
}
}
}
_frequency_node = fnode->getChild("selected-mhz", 0, true);
_in_range_node = node->getChild("in-range", 0, true);
_distance_node = node->getChild("indicated-distance-nm", 0, true);
- _speed_node = node->getChild("indicated-ground-speed", 0, true);
+ _speed_node = node->getChild("indicated-ground-speed-kt", 0, true);
_time_node = node->getChild("indicated-time-min", 0, true);
-
- _serviceable_node->setBoolValue(true);
}
void
if (source[0] == '\0') {
string branch;
branch = "/instrumentation/" + name + "/frequencies/selected-mhz";
- source = branch.c_str();
- _source_node->setStringValue(source);
+ _source_node->setStringValue(branch.c_str());
+ source = _source_node->getStringValue();
}
-
// Get the frequency
+
double frequency_mhz = fgGetDouble(source, 108.0);
if (frequency_mhz != _last_frequency_mhz) {
_time_before_search_sec = 0;
}
// Calculate the distance to the transmitter
- Point3D location =
- sgGeodToCart(Point3D(longitude_rad, latitude_rad, altitude_m));
- double distance_nm = _transmitter.distance3D(location) * SG_METER_TO_NM;
+ SGGeod geod = SGGeod::fromRadM(longitude_rad, latitude_rad, altitude_m);
+ SGVec3d location = SGVec3d::fromGeod(geod);
+
+ double distance_nm = dist(_transmitter, location) * SG_METER_TO_NM;
+
double range_nm = adjust_range(_transmitter_elevation_ft,
altitude_m * SG_METER_TO_FEET,
_transmitter_range_nm);
+
if (distance_nm <= range_nm) {
double speed_kt = (fabs(distance_nm - _last_distance_nm) *
((1 / delta_time_sec) * 3600.0));
_transmitter_valid = (dme != NULL);
if ( _transmitter_valid ) {
- _transmitter = Point3D(dme->get_x(), dme->get_y(), dme->get_z());
+ _transmitter = dme->get_cart();
_transmitter_elevation_ft = dme->get_elev_ft();
_transmitter_range_nm = dme->get_range();
_transmitter_bias = dme->get_multiuse();