mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 16:36:53 +01:00
d0387753f8
The physics of a vehicle loses the name it had from the Pascal of 2001. Done by
tools/rename/mover_to_physics.py, committed with it:
physics/mover.h physics/vehicle.h
TMoverParameters physics::Vehicle (in namespace physics)
TDynamicObject::MoverParameters physics
mvOccupied, mvControlled occupied, controlled (TTrain, TController)
mvSecond, mvThird secondUnit, thirdUnit
mvPantographUnit pantographUnit
mover, Mover, movers physics, Physics, vehicles (locals, params)
m_mover, othermover, currentMover, from_movers, renderMoverEventSounds
m_physics, otherPhysics, currentPhysics,
from_vehicles, renderPhysicsEventSounds
The code and the comments are renamed, the string literals are not: no text
the game shows, logs or looks up has changed (none had the names). The movers
of the editor, the tracks a slide moves, keep their name.
By hand: two member functions of TDynamicObject (gather_off_track_terrain,
begin_off_track) had a local mover aliasing their own MoverParameters, which
the rename made physics { *physics }; the alias is gone, they use physics->.
No other function has a renamed local meeting a renamed member (checked over
all the functions of the code before the rename).
For the branches made before it: run the script on the branch (python
tools/rename/mover_to_physics.py, from the root of the repository) before
merging it with this one, and the names don't conflict. It can be run again;
the second time it changes nothing.
The class is the same as it was; breaking it into its parts (braking,
electrics, controls, load) and making its data private are the next stages.
No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
126 lines
4.4 KiB
C++
126 lines
4.4 KiB
C++
/*
|
|
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/.
|
|
*/
|
|
/*
|
|
MaSzyna EU07 locomotive simulator
|
|
Copyright (C) 2001-2004 Marcin Wozniak, Maciej Czapkiewicz and others
|
|
|
|
*/
|
|
|
|
// the log of the physics of the train the driver runs
|
|
|
|
#include "stdafx.h"
|
|
#include "vehicle/Driver.h"
|
|
#include "physics/vehicle.h"
|
|
#include "utilities/Globals.h"
|
|
#include "utilities/translation.h"
|
|
#include "utilities/Logs.h"
|
|
#include "utilities/physicslog.h"
|
|
#include "vehicle/Train.h"
|
|
#include "vehicle/brakereleaser.h"
|
|
#include "vehicle/brakesetting.h"
|
|
#include "vehicle/brakingcurve.h"
|
|
#include "vehicle/fieldshunting.h"
|
|
#include "vehicle/handover.h"
|
|
#include "vehicle/signalpassing.h"
|
|
#include "vehicle/timetableservice.h"
|
|
#include "world/mtable.h"
|
|
#include "world/stationnames.h"
|
|
#include "vehicle/DynObj.h"
|
|
#include "world/Event.h"
|
|
#include "world/MemCell.h"
|
|
#include "world/RoadOrder.h"
|
|
#include "simulation/simulation.h"
|
|
#include "simulation/blackboxrecorder.h"
|
|
#include "simulation/simulationtime.h"
|
|
#include "simulation/simulationtest.h"
|
|
#include "world/Track.h"
|
|
#include "world/station.h"
|
|
#include "input/keyboardinput.h"
|
|
#include <algorithm>
|
|
#include <format>
|
|
#include <ranges>
|
|
#include "vehicle/ai/internal.h"
|
|
|
|
|
|
std::string_view TController::physicslog_header() {
|
|
// the columns of the readers of these logs, the Hasler tape of the starter among them, stay where they are:
|
|
// a new one goes at the end
|
|
return "Time[s] Velocity[m/s] Acceleration[m/ss] "
|
|
"Coupler.Dist[m] Coupler.Force[N] TractionForce[kN] FrictionForce[kN] BrakeForce[kN] "
|
|
"BrakePress[MPa] PipePress[MPa] MotorCurrent[A] "
|
|
"MCP SCP BCP LBP Direction Command CVal1 CVal2 "
|
|
"Security Wheelslip "
|
|
"EngineTemp[Deg] OilTemp[Deg] WaterTemp[Deg] WaterAuxTemp[Deg] "
|
|
"VehicleVelocity[km/h]"
|
|
"\r\n";
|
|
}
|
|
|
|
std::string TController::physicslog_line() const {
|
|
std::ostringstream line;
|
|
line << std::fixed << std::setprecision( 4 )
|
|
<< ElapsedTime << " "
|
|
<< fabs(11.31 * occupied->WheelDiameter * occupied->nrot) << " "
|
|
<< mvControlling->AccS << " "
|
|
<< occupied->Couplers[1].Dist << " "
|
|
<< occupied->Couplers[1].CForce << " "
|
|
<< occupied->Ft << " "
|
|
<< occupied->Ff << " "
|
|
<< occupied->Fb << " "
|
|
<< occupied->BrakePress << " "
|
|
<< occupied->PipePress << " "
|
|
<< mvControlling->Im << " "
|
|
<< int(mvControlling->MainCtrlPos) << " "
|
|
<< int(mvControlling->ScndCtrlPos) << " "
|
|
<< occupied->fBrakeCtrlPos << " "
|
|
<< occupied->LocalBrakePosA << " "
|
|
<< int(mvControlling->DirActive) << " "
|
|
<< ( occupied->CommandIn.Text.empty() ? "none" : occupied->CommandIn.Text.c_str() ) << " "
|
|
<< occupied->CommandIn.Value1 << " "
|
|
<< occupied->CommandIn.Value2 << " "
|
|
<< int(mvControlling->SecuritySystem.is_blinking()) << " "
|
|
<< int(mvControlling->SlippingWheels) << " "
|
|
<< mvControlling->diesel.heat.Ts << " "
|
|
<< mvControlling->diesel.heat.To << " "
|
|
<< mvControlling->diesel.heat.temperatura1 << " "
|
|
<< mvControlling->diesel.heat.temperatura2 << " "
|
|
// vehicle speed [km/h], the second column is the wheel speed, which stays at 0 while the wheels are locked in a skid
|
|
<< occupied->V * 3.6
|
|
<< "\r\n";
|
|
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
|
|
PhysicsLogs.append( VehicleName, physicslog_line() );
|
|
#endif
|
|
#if LOGPRESS == 1
|
|
std::ostringstream line;
|
|
line << ElapsedTime << "\t" << fabs(11.31 * occupied->WheelDiameter * occupied->nrot)
|
|
<< "\t";
|
|
line << mvControlling->AccS << "\t";
|
|
line << occupied->PipePress << "\t" << occupied->CntrlPipePress << "\t"
|
|
<< occupied->BrakePress << "\t";
|
|
line << occupied->Volume << "\t" << occupied->Hamulec->GetCRP() << "\n";
|
|
PhysicsLogs.append( VehicleName, line.str() );
|
|
#endif
|
|
};
|