From 03a3b4c09a0e010756daebb0c3637974185173e3 Mon Sep 17 00:00:00 2001 From: maj00r Date: Sat, 14 Nov 2026 00:48:17 +0100 Subject: [PATCH] feat(physicslog): the logs written every two seconds by a thread of their own, no file kept open; the black box's tapes as it goes "physicslog yes" kept the .dat of every vehicle with a driver open for the whole run and flushed it twenty times a second from the simulation's thread: some 580 open files on Tomaszewo. The lines are kept now and a thread of their own writes them every two seconds, each file opened only for the moment it is written to. The files, their lines and their text mode stay as they were. - The black box, with the physics logs off, writes the tapes of the user's vehicles through the same writer as it goes, not at the end. A log begins when the user is first in the vehicle and goes on while the user looks around outside, until another vehicle is taken; back in it, the log goes on after the gap. The vehicle's own driver keeps the log only if it is the primary one, as a passive one's clock stands still; otherwise the driver of its train does. - What is kept is written when the simulator closes, after the black box, at the end of a test run, and when the test watchdog ends a run. A crash loses the last two seconds. - On Tomaszewo with the black box alone, the one tape grows every two seconds. With "physicslog yes", the 581 logs grow and the simulator holds as many handles as without them; writing them takes the thread about 1.9 s, which the closing waits for once. --- CMakeLists.txt | 1 + EU07.cpp | 11 ++- application/application.cpp | 4 + blackbox_doc.md | 15 ++-- simulation/blackboxrecorder.cpp | 30 ++------ simulation/blackboxrecorder.h | 12 +-- simulation/simulationtest.cpp | 2 + tests/unit/test_physicslog.cpp | 131 ++++++++++++++++++++++++++++++++ utilities/physicslog.cpp | 98 ++++++++++++++++++++++++ utilities/physicslog.h | 67 ++++++++++++++++ vehicle/Driver.cpp | 35 ++++----- vehicle/Driver.h | 2 +- 12 files changed, 347 insertions(+), 61 deletions(-) create mode 100644 tests/unit/test_physicslog.cpp create mode 100644 utilities/physicslog.cpp create mode 100644 utilities/physicslog.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e97e41d03..3c12c51a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -546,6 +546,7 @@ set(CORE_SOURCES "scripting/scriptscreendrawing.cpp" "simulation/simulationtestrules.cpp" "vehicle/blackbox.cpp" +"utilities/physicslog.cpp" "vehicle/enginestart.cpp" "vehicle/brakesetting.cpp" "vehicle/handover.cpp" diff --git a/EU07.cpp b/EU07.cpp index 136882299..4ccbd6f56 100644 --- a/EU07.cpp +++ b/EU07.cpp @@ -22,6 +22,7 @@ Stele, firleju, szociu, hunter, ZiomalCl, OLI_EU and others #include "simulation/simulationtest.h" #include "utilities/Globals.h" #include "utilities/Logs.h" +#include "utilities/physicslog.h" #include #include #include @@ -112,6 +113,8 @@ void finish_log() [[noreturn]] void end_test_run(std::string_view const Reason) { simulation::test().conclude(simulation::test_result::error, Reason); + // the last two seconds of the physics logs, which the runner of the tests reads + PhysicsLogs.stop(); finish_log(); fflush(stdout); fflush(stderr); @@ -141,10 +144,10 @@ void finish_log() end_test_run("the simulator stopped before the test ended"); } -// every vehicle with a driver keeps its physics log open for the whole run, and on a scenery with some five hundred -// of them the logs took all the files the C library of Windows lets a process have open by default (512): the -// files opened after them, the shaders of the map among them, couldn't be read. so the limit is raised to the most -// either system allows +// the physics logs used to keep a file open for every vehicle with a driver, and on a scenery with some five hundred +// of them they took all the files the C library of Windows lets a process have open by default (512): the files +// opened after them, the shaders of the map among them, couldn't be read. they keep none open now (physicslog.h), +// but the limit is raised to the most either system allows still, for whatever else opens many files at once void raise_open_files_limit() { #ifdef _WIN32 diff --git a/application/application.cpp b/application/application.cpp index 96f578514..ba62fe467 100644 --- a/application/application.cpp +++ b/application/application.cpp @@ -34,6 +34,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/dictionary.h" #include "version_info.h" #include "simulation/simulationtest.h" +#include "utilities/physicslog.h" #include #include #include @@ -745,6 +746,9 @@ void eu07_application::exit() track_sleepers::stop_background(); step("the black box"); simulation::Blackbox.close(); + step("the physics logs"); + // what is kept of them, the black box's written last + PhysicsLogs.stop(); step("the modes"); for (auto &mode : m_modes) mode.reset(); diff --git a/blackbox_doc.md b/blackbox_doc.md index 80ddbacf8..ea7322ca8 100644 --- a/blackbox_doc.md +++ b/blackbox_doc.md @@ -12,12 +12,15 @@ starter, a viewer) can replay the session on the map, or set the user's driving editor session. The file goes to `physicslog/_.blackbox` (the local time the recording started at), next to the `.dat` logs of the vehicles when those are on; they stay as they are. -With the physics logs off it still gives the `.dat` log of each vehicle the user was in, written when the -recording ends: `physicslog/.dat`, the same file name, the same columns and the same line every -0.05 s as `physicslog yes` would write, but only of the times the user was there. A vehicle with no driver -of its own takes the log of the driver of its train. So the speed recorder's tape can be read from them as -before, without the simulator keeping a log of every vehicle open all the time. A simulator that crashes -leaves the recording, but not these logs. +With the physics logs off it still gives the `.dat` log of each vehicle the user was in, as it goes: +`physicslog/.dat`, the same file name, the same columns and the same line every 0.05 s as +`physicslog yes` would write. A log begins when the user first is in the vehicle, and goes on while the +user looks around outside it, until the user takes another vehicle, whose log begins then. Back in a +vehicle, its log goes on after the gap in its time. A vehicle with no driver of its own takes the log of the +driver of its train. So the speed recorder's tape can be read from them as before, also while the +simulator runs, without a log of every vehicle. Like those of `physicslog yes`, they are written every +two seconds, each file opened only for the moment it is written to; a crash loses the last two seconds +of them. The recording starts once the scenery is loaded and ends when the simulator closes. Going into the editor (F11) ends it too, since the editor may take away the tracks and the vehicles it refers to; no diff --git a/simulation/blackboxrecorder.cpp b/simulation/blackboxrecorder.cpp index b5465053b..141ff070e 100644 --- a/simulation/blackboxrecorder.cpp +++ b/simulation/blackboxrecorder.cpp @@ -23,6 +23,7 @@ http://mozilla.org/MPL/2.0/. #include "world/Track.h" #include "utilities/Globals.h" #include "utilities/Logs.h" +#include "utilities/physicslog.h" #include "utilities/utilities.h" #include @@ -280,7 +281,6 @@ void blackbox_recorder::close() { m_writer->end(m_time); m_writer.reset(); m_file.close(); - write_tapes(); using milliseconds = std::chrono::duration; WriteLog(std::format("Black box: recording closed; {} looks around, {:.3f} ms each on average, the longest {:.3f} ms", m_looks, m_looks > 0 ? milliseconds{m_looktime}.count() / m_looks : 0.0, milliseconds{m_looklongest}.count())); @@ -492,30 +492,16 @@ void blackbox_recorder::keep_tape_line() { return; auto const *vehicle{train->Dynamic()}; // the driver of the vehicle, whose log it would be: it keeps the name of its first vehicle, so a change of the cab - // in a unit goes on in the same log. in a vehicle without one, the driver of its train - auto const *driver{vehicle->Mechanik != nullptr ? vehicle->Mechanik : vehicle->ctOwner}; + // in a unit goes on in the same log. a passive one stands still (its clock too), so then the driver of the train + auto const *driver{vehicle->Mechanik != nullptr && vehicle->Mechanik->primary() ? vehicle->Mechanik : vehicle->ctOwner}; if (driver == nullptr) return; - m_tapes[driver->physicslog_name()] += driver->physicslog_line(); -} - -void blackbox_recorder::write_tapes() { - for (auto const &[name, lines] : m_tapes) { - // opened as the driver opens its log, so the file is the same to the byte - auto const filename{"physicslog/" + name + ".dat"}; - std::fstream file{filename, std::ios::in | std::ios::out | std::ios::trunc}; - if (false == file.is_open()) { - ErrorLog(std::format("Black box: can't create the physics log \"{}\"", filename)); - continue; - } - file << TController::physicslog_header() << lines; - file.close(); - if (file.fail()) - ErrorLog(std::format("Black box: the physics log \"{}\" wasn't written whole", filename)); - else - WriteLog(std::format("Black box: the physics log \"{}\" written from the recording", filename)); + auto const &name{driver->physicslog_name()}; + if (m_tapes.insert(name).second) { + PhysicsLogs.begin(name, TController::physicslog_header()); + WriteLog(std::format("Black box: the physics log \"physicslog/{}.dat\" begun", name)); } - m_tapes.clear(); + PhysicsLogs.append(name, driver->physicslog_line()); } void blackbox_recorder::look_around(bool const Keyframe) { diff --git a/simulation/blackboxrecorder.h b/simulation/blackboxrecorder.h index b7715e04c..093f22d1d 100644 --- a/simulation/blackboxrecorder.h +++ b/simulation/blackboxrecorder.h @@ -15,9 +15,9 @@ http://mozilla.org/MPL/2.0/. #include #include #include -#include #include #include +#include #include #include #include @@ -87,10 +87,10 @@ private: void write_map(); static std::vector> stop_point_headings(); void write_cab(); - // with the physics logs off, the line of the log of the driver the user is with, kept for the end + // with the physics logs off, the line of the log of the driver the user is with, to its log, physicslog/.dat, + // as the physics logs would have it. a log is begun at the first line of the recording, and goes on while the user + // looks around outside, until the user takes another vehicle; back in the vehicle, it goes on after the gap void keep_tape_line(); - // the kept lines, each driver's to its log, physicslog/.dat, as the physics logs would have it - void write_tapes(); // the clock, the user's vehicle, the vehicles, the switches and the signals void look_around(bool Keyframe); void look_at_vehicles(bool Keyframe); @@ -115,8 +115,8 @@ private: double m_time{0.0}; double m_cabdue{0.0}; double m_tapedue{0.0}; - // the lines of the physics log by the name of its file, of the times the user was with its driver - std::map m_tapes; + // the names of the logs begun by the recording + std::set m_tapes; double m_lookdue{0.0}; double m_keyframedue{0.0}; std::unordered_map m_vehicles; diff --git a/simulation/simulationtest.cpp b/simulation/simulationtest.cpp index 89a8a1046..8f1856663 100644 --- a/simulation/simulationtest.cpp +++ b/simulation/simulationtest.cpp @@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/. #include "simulation/simulation.h" #include "utilities/Globals.h" #include "utilities/Logs.h" +#include "utilities/physicslog.h" #include "utilities/utilities.h" #include "vehicle/DynObj.h" #include "world/Event.h" @@ -262,6 +263,7 @@ void test_manager::check_wall_clock(double const Elapsed) if (false == conclude(test_result::timeout, std::format("still running after {:.0f} s of real time (test.wall_timeout)", limit))) ErrorLog(std::format("test: the simulator was still running {:.0f} s of real time after the start, ended", limit)); // what was logged last gets written, unless the log is held up by a hung thread + PhysicsLogs.flush(); StopLogService(); std::this_thread::sleep_for(std::chrono::milliseconds(250)); std::_Exit(exit_code()); diff --git a/tests/unit/test_physicslog.cpp b/tests/unit/test_physicslog.cpp new file mode 100644 index 000000000..afcd0f8c7 --- /dev/null +++ b/tests/unit/test_physicslog.cpp @@ -0,0 +1,131 @@ +#include "stdafx.h" +#include "doctest.h" + +#include "utilities/physicslog.h" + +#include +#include +#include +#include +#include +#include +#include +#include + +// the physics logs are kept and written by a thread of their own every so often, each file opened only to be written to + +namespace { + +// a folder of its own for the logs of a test, in the build folder of the tests, removed with the object. the writer +// makes it itself +class log_folder { +public: + explicit log_folder(std::string const &Name) : m_path{std::filesystem::path{EU07_UNIT_TESTS_SCRATCH} / std::format("eu07_physicslog_test_{}", Name)} { + std::filesystem::remove_all(m_path); + } + ~log_folder() { + std::error_code error; + std::filesystem::remove_all(m_path, error); + } + log_folder(log_folder const &) = delete; + log_folder &operator=(log_folder const &) = delete; + + std::filesystem::path const &path() const { return m_path; } + // the log as it stands, read in text mode as it is written: what was given to it + std::string read(std::string const &Name) const { + std::ifstream file{m_path / (Name + ".dat")}; + if (false == file.is_open()) + return {}; + std::ostringstream text; + text << file.rdbuf(); + return text.str(); + } + // waits up to five seconds for the log to read Text + bool reads(std::string const &Name, std::string const &Text) const { + auto const until{std::chrono::steady_clock::now() + std::chrono::seconds{5}}; + while (read(Name) != Text && std::chrono::steady_clock::now() < until) + std::this_thread::sleep_for(std::chrono::milliseconds{10}); + return read(Name) == Text; + } + +private: + std::filesystem::path m_path; +}; + +constexpr auto header{"Time[s] Velocity[m/s]\r\n"}; + +} // namespace + +TEST_CASE("physicslog: a log begun is emptied and given its header, and its lines follow it at each writing") { + log_folder folder{"begin"}; + physicslog_writer logs{folder.path(), std::chrono::hours{1}}; + + logs.begin("EU07-424", header); + logs.append("EU07-424", "0.0500 0.0000\r\n"); + CHECK(folder.read("EU07-424").empty()); + logs.flush(); + CHECK(folder.read("EU07-424") == std::string{header} + "0.0500 0.0000\r\n"); + + logs.append("EU07-424", "0.1000 1.5000\r\n"); + logs.flush(); + CHECK(folder.read("EU07-424") == std::string{header} + "0.0500 0.0000\r\n0.1000 1.5000\r\n"); + + // begun again: the lines not written yet are dropped along with those written + logs.append("EU07-424", "0.1500 3.0000\r\n"); + logs.begin("EU07-424", header); + logs.flush(); + CHECK(folder.read("EU07-424") == header); +} + +TEST_CASE("physicslog: no file is kept open between the writings, and a log not begun is added to as it stands") { + log_folder folder{"closed"}; + physicslog_writer logs{folder.path(), std::chrono::hours{1}}; + + logs.begin("SM42-001", header); + logs.flush(); + // Windows doesn't let a file open in a program be removed + std::error_code error; + CHECK(std::filesystem::remove(folder.path() / "SM42-001.dat", error)); + CHECK_FALSE(error); + + logs.append("SM42-001", "0.0500 0.0000\r\n"); + logs.flush(); + CHECK(folder.read("SM42-001") == "0.0500 0.0000\r\n"); +} + +TEST_CASE("physicslog: the thread writes the logs by itself") { + log_folder folder{"thread"}; + physicslog_writer logs{folder.path(), std::chrono::milliseconds{20}}; + + logs.begin("ET22-001", header); + logs.append("ET22-001", "0.0500 0.0000\r\n"); + CHECK(folder.reads("ET22-001", std::string{header} + "0.0500 0.0000\r\n")); + logs.append("ET22-001", "0.1000 0.0000\r\n"); + CHECK(folder.reads("ET22-001", std::string{header} + "0.0500 0.0000\r\n0.1000 0.0000\r\n")); +} + +TEST_CASE("physicslog: stopping writes what is kept at once, and what comes after waits for a writing") { + log_folder folder{"stop"}; + physicslog_writer logs{folder.path(), std::chrono::hours{1}}; + + logs.begin("EN57-1001", header); + logs.append("EN57-1001", "0.0500 0.0000\r\n"); + logs.stop(); + CHECK(folder.read("EN57-1001") == std::string{header} + "0.0500 0.0000\r\n"); + + logs.append("EN57-1001", "0.1000 0.0000\r\n"); + std::this_thread::sleep_for(std::chrono::milliseconds{50}); + CHECK(folder.read("EN57-1001") == std::string{header} + "0.0500 0.0000\r\n"); + logs.flush(); + CHECK(folder.read("EN57-1001") == std::string{header} + "0.0500 0.0000\r\n0.1000 0.0000\r\n"); +} + +TEST_CASE("physicslog: what is kept is written when the writer goes") { + log_folder folder{"end"}; + { + physicslog_writer logs{folder.path(), std::chrono::hours{1}}; + logs.begin("ST44-001", header); + logs.append("ST44-001", "0.0500 0.0000\r\n"); + } + CHECK(folder.read("ST44-001") == std::string{header} + "0.0500 0.0000\r\n"); +} diff --git a/utilities/physicslog.cpp b/utilities/physicslog.cpp new file mode 100644 index 000000000..cb57d5ca3 --- /dev/null +++ b/utilities/physicslog.cpp @@ -0,0 +1,98 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#include "stdafx.h" +#include "utilities/physicslog.h" +#include "utilities/Logs.h" + +#include +#include +#include + +physicslog_writer PhysicsLogs; + +physicslog_writer::physicslog_writer(std::filesystem::path Folder, std::chrono::milliseconds const Interval) : m_folder{std::move(Folder)}, m_interval{Interval} {} + +physicslog_writer::~physicslog_writer() { + stop(); +} + +void physicslog_writer::begin(std::string const &Name, std::string_view const Header) { + std::scoped_lock lock{m_mutex}; + auto &lines{m_pending[Name]}; + lines.fresh = true; + lines.text.assign(Header); + start(); +} + +void physicslog_writer::append(std::string const &Name, std::string_view const Line) { + std::scoped_lock lock{m_mutex}; + m_pending[Name].text.append(Line); + start(); +} + +void physicslog_writer::flush() { + write(); +} + +void physicslog_writer::stop() { + { + std::scoped_lock lock{m_mutex}; + m_stopped = true; + } + // started only before m_stopped was set, so no one else touches it now + if (m_thread.joinable()) { + m_thread.request_stop(); + m_thread.join(); + } + write(); +} + +void physicslog_writer::start() { + if (m_stopped || m_thread.joinable()) + return; + m_thread = std::jthread([this](std::stop_token const &Stop) { run(Stop); }); +} + +void physicslog_writer::run(std::stop_token const &Stop) { + while (false == Stop.stop_requested()) { + { + std::unique_lock lock{m_mutex}; + // woken early only to stop, which writes the rest itself + if (m_wake.wait_for(lock, Stop, m_interval, [] { return false; }) || Stop.stop_requested()) + return; + } + write(); + } +} + +void physicslog_writer::write() { + std::scoped_lock files{m_filemutex}; + std::map taken; + { + std::scoped_lock lock{m_mutex}; + taken.swap(m_pending); + } + if (taken.empty()) + return; + std::error_code error; + std::filesystem::create_directories(m_folder, error); + for (auto const &[name, lines] : taken) { + if (lines.text.empty() && false == lines.fresh) + continue; + auto const path{m_folder / (name + ".dat")}; + // in text mode, as the logs were always written: on Windows their lines, which end with "\r\n", end with "\r\r\n" + std::ofstream file{path, lines.fresh ? std::ios::out | std::ios::trunc : std::ios::out | std::ios::app}; + if (file.is_open()) + file << lines.text; + file.close(); + if (file.fail() && m_failed.insert(name).second) + ErrorLog("Bad physics log: can't write " + path.string()); + } +} diff --git a/utilities/physicslog.h b/utilities/physicslog.h new file mode 100644 index 000000000..2963c29a9 --- /dev/null +++ b/utilities/physicslog.h @@ -0,0 +1,67 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +#pragma once + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// the physics logs, /.dat. the lines given are kept, and written every two seconds by a thread of its +// own, each file opened only for the moment it is written to: the logs of hundreds of vehicles hold no files open, and +// the simulation doesn't wait for the disk. a crash loses the last two seconds of them +class physicslog_writer { +public: + explicit physicslog_writer(std::filesystem::path Folder = "physicslog", std::chrono::milliseconds Interval = std::chrono::seconds{2}); + physicslog_writer(physicslog_writer const &) = delete; + physicslog_writer &operator=(physicslog_writer const &) = delete; + // stops, writing what is kept + ~physicslog_writer(); + + // starts the log Name anew: its file is emptied and Header written into it, the next time the logs are written. + // the lines of it not written yet are dropped + void begin(std::string const &Name, std::string_view Header); + // Line at the end of the log Name. a log not begun is added to as its file stands + void append(std::string const &Name, std::string_view Line); + // writes what is kept, now + void flush(); + // writes what is kept and ends the thread. what is given after is written by a flush, or at the end + void stop(); + +private: + struct pending { + bool fresh{false}; // its file is to be emptied first + std::string text; + }; + + // the thread, on the first line given, unless stopped. called with m_mutex held + void start(); + void run(std::stop_token const &Stop); + void write(); + + std::filesystem::path const m_folder; + std::chrono::milliseconds const m_interval; + std::mutex m_mutex; // the lines kept and the thread + std::map m_pending; + bool m_stopped{false}; + std::condition_variable_any m_wake; + std::jthread m_thread; + std::mutex m_filemutex; // the files are written one batch at a time, so the lines of a log stay in order + std::set m_failed; // the logs whose file couldn't be written, told once +}; + +// the physics logs of the drivers (physicslog yes), and those the black box writes of the user's vehicles +extern physicslog_writer PhysicsLogs; diff --git a/vehicle/Driver.cpp b/vehicle/Driver.cpp index 8255a93cc..cde6ed99f 100644 --- a/vehicle/Driver.cpp +++ b/vehicle/Driver.cpp @@ -18,6 +18,7 @@ http://mozilla.org/MPL/2.0/. #include "utilities/Globals.h" #include "utilities/translation.h" #include "utilities/Logs.h" +#include "utilities/physicslog.h" #include "vehicle/Train.h" #include "vehicle/brakesetting.h" #include "vehicle/handover.h" @@ -2336,20 +2337,13 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, TableClear(); if( WriteLogFlag ) { -#ifdef _WIN32 - CreateDirectory( "physicslog", nullptr); -#elif __unix__ - mkdir( "physicslog", 0740 ); -#endif - LogFile.open( std::string( "physicslog/" + VehicleName + ".dat" ), - std::ios::in | std::ios::out | std::ios::trunc ); + // physicslog/.dat, written every two seconds along with the logs of the other drivers #if LOGPRESS == 0 - LogFile << physicslog_header(); + PhysicsLogs.begin( VehicleName, physicslog_header() ); #endif #if LOGPRESS == 1 - LogFile << string( "t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP" ).c_str() << "\n"; + PhysicsLogs.begin( VehicleName, "t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP\n" ); #endif - LogFile.flush(); } // HACK: give the simulation a small window to potentially replace the AI with a human driver @@ -2358,7 +2352,6 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, TController::~TController() { // wykopanie mechanika z roboty - // LogFile is closed by its own destructor }; // zamiana kodu rozkazu na opis @@ -5407,21 +5400,19 @@ std::string TController::physicslog_line() const { void TController::PhysicsLog() { // zapis logu - na razie tylko wypisanie parametrów - if (LogFile.is_open()) - { #if LOGPRESS == 0 - LogFile << physicslog_line(); + PhysicsLogs.append( VehicleName, physicslog_line() ); #endif #if LOGPRESS == 1 - LogFile << ElapsedTime << "\t" << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) - << "\t"; - LogFile << Controlling->AccS << "\t"; - LogFile << mvOccupied->PipePress << "\t" << mvOccupied->CntrlPipePress << "\t" - << mvOccupied->BrakePress << "\t"; - LogFile << mvOccupied->Volume << "\t" << mvOccupied->Hamulec->GetCRP() << "\n"; + std::ostringstream line; + line << ElapsedTime << "\t" << fabs(11.31 * mvOccupied->WheelDiameter * mvOccupied->nrot) + << "\t"; + line << mvControlling->AccS << "\t"; + line << mvOccupied->PipePress << "\t" << mvOccupied->CntrlPipePress << "\t" + << mvOccupied->BrakePress << "\t"; + line << mvOccupied->Volume << "\t" << mvOccupied->Hamulec->GetCRP() << "\n"; + PhysicsLogs.append( VehicleName, line.str() ); #endif - LogFile.flush(); - } }; void diff --git a/vehicle/Driver.h b/vehicle/Driver.h index 02b2c60e2..306287311 100644 --- a/vehicle/Driver.h +++ b/vehicle/Driver.h @@ -721,9 +721,9 @@ private: // logs // methods + // the line of the log, to PhysicsLogs (utilities/physicslog.h) void PhysicsLog(); // members - std::ofstream LogFile; // zapis parametrow fizycznych double LastUpdatedTime = 0.0; // czas od ostatniego logu double ElapsedTime = 0.0; // czas od poczatku logu