X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FMain%2Flogger.cxx;h=2a4561c7300610243673a77866383b08a86550eb;hb=d558b52cb6df91952963e95e6e6e987133b507bb;hp=da060caed2fb4480ffd5b0ddf1ac3c8c9a3d5a3e;hpb=8506e731a234e03acfdeae612d1c53cf58c9d707;p=flightgear.git diff --git a/src/Main/logger.cxx b/src/Main/logger.cxx index da060caed..2a4561c73 100644 --- a/src/Main/logger.cxx +++ b/src/Main/logger.cxx @@ -3,20 +3,21 @@ // // This file is in the Public Domain, and comes with no warranty. +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "logger.hxx" -#include STL_FSTREAM +#include #include -SG_USING_STD(ofstream); -SG_USING_STD(endl); -SG_USING_STD(string); - #include #include "fg_props.hxx" - +using std::string; +using std::endl; //////////////////////////////////////////////////////////////////////// // Implementation of FGLogger @@ -61,6 +62,7 @@ FGLogger::init () } log.interval_ms = child->getLongValue("interval-ms"); + log.last_time_ms = globals->get_sim_time_sec() * 1000; log.delimiter = delimiter.c_str()[0]; log.output = new ofstream(filename.c_str()); if (!log.output) { @@ -71,7 +73,7 @@ FGLogger::init () // // Process the individual entries (Time is automatic). // - vector entries = child->getChildren("entry"); + std::vector entries = child->getChildren("entry"); (*log.output) << "Time"; for (unsigned int j = 0; j < entries.size(); j++) { SGPropertyNode * entry = entries[j]; @@ -91,7 +93,7 @@ FGLogger::init () fgGetNode(entry->getStringValue("property"), true); log.nodes.push_back(node); (*log.output) << log.delimiter - << entry->getStringValue("title", node->getPath()); + << entry->getStringValue("title", node->getPath().c_str()); } (*log.output) << endl; } @@ -117,18 +119,19 @@ FGLogger::unbind () void FGLogger::update (double dt) { - double sim_time_ms = globals->get_sim_time_sec() * 1000; - for (unsigned int i = 0; i < _logs.size(); i++) { - if ((sim_time_ms - _logs[i].last_time_ms) >= _logs[i].interval_ms) { - _logs[i].last_time_ms = sim_time_ms; - (*_logs[i].output) << sim_time_ms; - for (unsigned int j = 0; j < _logs[i].nodes.size(); j++) { - (*_logs[i].output) << _logs[i].delimiter + double sim_time_sec = globals->get_sim_time_sec(); + double sim_time_ms = sim_time_sec * 1000; + for (unsigned int i = 0; i < _logs.size(); i++) { + while ((sim_time_ms - _logs[i].last_time_ms) >= _logs[i].interval_ms) { + _logs[i].last_time_ms += _logs[i].interval_ms; + (*_logs[i].output) << sim_time_sec; + for (unsigned int j = 0; j < _logs[i].nodes.size(); j++) { + (*_logs[i].output) << _logs[i].delimiter << _logs[i].nodes[j]->getStringValue(); - } - (*_logs[i].output) << endl; + } + (*_logs[i].output) << endl; + } } - } }