18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 02:44:58 +01:00

feat(physicslog): the logs of the trains only, physicslog.trains

"physicslog.trains yes" in eu07.ini writes the .dat log of each driver who
drives rail vehicles, not of the passengers nor of the road vehicles that make
"physicslog yes" hundreds of files on a big scenery: the tape of every train.
A driver made primary later begins its log then, and isn't counted while it
doesn't log. The black box goes with it when the ini says nothing of its own,
and doesn't write a second log of a driver writing its own. The doc tells the
doors' sides are the vehicle's, the driver's swapped in the rear cab.
This commit is contained in:
maj00r
2026-11-15 23:48:23 +01:00
parent 043b9fb2f0
commit b7950af6b6
5 changed files with 54 additions and 14 deletions

View File

@@ -169,6 +169,7 @@ const double FSOverchargeCRP = 0.05;
const double FSMaxTime = 10.0;
const double DepartBlockedFSDelay = 10.0;
bool WriteLogFlag = false;
bool WriteTrainLogFlag = false;
double const deltalog = 0.05; // przyrost czasu
std::string StopReasonTable[] = {
@@ -2336,14 +2337,8 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche,
SetDriverPsyche(); // na końcu, bo wymaga ustawienia zmiennych
TableClear();
if( WriteLogFlag ) {
// physicslog/<vehicle>.dat, written every two seconds along with the logs of the other drivers
#if LOGPRESS == 0
PhysicsLogs.begin( VehicleName, physicslog_header() );
#endif
#if LOGPRESS == 1
PhysicsLogs.begin( VehicleName, "t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP\n" );
#endif
if( writes_physicslog() ) {
begin_physicslog();
}
// HACK: give the simulation a small window to potentially replace the AI with a human driver
@@ -5398,6 +5393,18 @@ std::string TController::physicslog_line() const {
return line.str();
}
void TController::begin_physicslog()
{
// physicslog/<vehicle>.dat, written every two seconds along with the logs of the other drivers
#if LOGPRESS == 0
PhysicsLogs.begin( VehicleName, physicslog_header() );
#endif
#if LOGPRESS == 1
PhysicsLogs.begin( VehicleName, "t\tVel\tAcc\tPP\tVVP\tBP\tBVP\tCVP\n" );
#endif
PhysicsLogBegun = true;
}
void TController::PhysicsLog()
{ // zapis logu - na razie tylko wypisanie parametrów
#if LOGPRESS == 0
@@ -6463,10 +6470,18 @@ TController::update_timers( double dt ) {
void
TController::update_logs( double const dt ) {
// log vehicle data
if( false == writes_physicslog() ) {
// not counted while it isn't logged: a driver which begins to, made primary, writes a line every 0.05 s
// from then on, not one each update to make up for the time before
LastUpdatedTime = 0.0;
return;
}
LastUpdatedTime += dt;
if( WriteLogFlag
&& LastUpdatedTime > deltalog ) {
if( LastUpdatedTime > deltalog ) {
// zapis do pliku DAT
if( false == PhysicsLogBegun ) {
begin_physicslog();
}
PhysicsLog();
LastUpdatedTime -= deltalog;
}

View File

@@ -198,6 +198,9 @@ static const bool Humandriver = false;
static const int maxorders = 64; // ilość rozkazów w tabelce
static const int maxdriverfails = 4; // ile błędów może zrobić AI zanim zmieni nastawienie
extern bool WriteLogFlag; // logowanie parametrów fizycznych
// the physics logs of the trains only (physicslog.trains yes): of each driver of rail vehicles who drives them, not
// of the passengers nor of the vehicles of the roads
extern bool WriteTrainLogFlag;
static const int BrakeAccTableSize = 20;
static const int gbh_NP = -2; //odciecie w hamulcu ogolnym
@@ -723,7 +726,10 @@ private:
// methods
// the line of the log, to PhysicsLogs (utilities/physicslog.h)
void PhysicsLog();
// its log begun anew, its file emptied and given the header
void begin_physicslog();
// members
bool PhysicsLogBegun = false; // its log was begun, by this driver
double LastUpdatedTime = 0.0; // czas od ostatniego logu
double ElapsedTime = 0.0; // czas od poczatku logu
@@ -736,6 +742,10 @@ public:
// user is in, to write its log at the end when the logs of all the vehicles are off
std::string const &physicslog_name() const {
return VehicleName; }
// whether it writes its physics log itself: all with "physicslog yes", with "physicslog.trains yes" one who drives
// rail vehicles. a driver made primary later begins its log then
bool writes_physicslog() const {
return WriteLogFlag || ( WriteTrainLogFlag && is_train() && primary() ); }
static std::string_view physicslog_header();
std::string physicslog_line() const;
TDynamicObject *Vehicle( end const Side ) const {