17
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-10-24 18:01:53 +02:00

perf(debug): count what wakes the physics of the vehicles (brake pipe, main reservoir pipe, command, speed, acceleration, neighbour, other) in the debug panel

This commit is contained in:
2026-10-23 19:08:09 +02:00
parent f17462b186
commit 9a7ff372f7
4 changed files with 42 additions and 11 deletions

View File

@@ -2324,7 +2324,19 @@ class TMoverParameters
// Q *******************************************************************************************
double GetTrainsetVoltage(int const Coupling = coupling::heating | coupling::highvoltage) const;
double GetTrainsetHighVoltage() const;
bool switch_physics(bool const State);
// what turns the physics on, counted for the debug panel (Timer::switching_counter)
enum class wake_cause
{
other,
mainpipe, // air flowing in from a neighbour along the brake pipe
scndpipe, // along the main reservoir pipe
command,
speed, // the test of ComputeTotalForce(): the vehicle moves
acceleration, // accelerates
neighbour, // a neighbour moves or accelerates
rest // active cab, switching, ezt/dmu
};
bool switch_physics(bool const State, wake_cause const Cause = wake_cause::other);
// whether the vehicle accelerates, for the test which turns the physics off in vehicles standing still (ComputeTotalForce()).
// standing still, its acceleration is the pull of the slope and of the couplers, as the brakes and the resistance count only
// against a speed (FTotal); with Global.physics_sleepheld one held by them, the way ComputeMovement() keeps it standing, doesn't

View File

@@ -4745,7 +4745,7 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
c = Couplers[0].Connected; // skrot
dv1 = 0.5 * dt * PF(ScndPipePress, c->ScndPipePress, Spz * 0.75);
if (dv1 * dv1 > 0.00000000000001)
c->switch_physics(true);
c->switch_physics(true, wake_cause::scndpipe);
c->Pipe2->Flow(-dv1);
}
// sprzeg 2
@@ -4754,7 +4754,7 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
c = Couplers[1].Connected; // skrot
dv2 = 0.5 * dt * PF(ScndPipePress, c->ScndPipePress, Spz * 0.75);
if (dv2 * dv2 > 0.00000000000001)
c->switch_physics(true);
c->switch_physics(true, wake_cause::scndpipe);
c->Pipe2->Flow(-dv2);
}
if (Couplers[1].Connected != nullptr && Couplers[0].Connected != nullptr && TestFlag(Couplers[0].CouplingFlag, ctrain_scndpneumatic) && TestFlag(Couplers[1].CouplingFlag, ctrain_scndpneumatic))
@@ -4833,7 +4833,7 @@ double TMoverParameters::GetDVc(double dt)
c = Couplers[0].Connected; // skrot //0.08 //e/D * L/D = e/D^2 * L
dv1 = 0.5 * dt * PF(PipePress, c->PipePress, Spg / (1.0 + 0.015 / Spg * Dim.L));
if (dv1 * dv1 > 0.00000000000001)
c->switch_physics(true);
c->switch_physics(true, wake_cause::mainpipe);
c->Pipe->Flow(-dv1);
}
// sprzeg 2
@@ -4842,7 +4842,7 @@ double TMoverParameters::GetDVc(double dt)
c = Couplers[1].Connected; // skrot
dv2 = 0.5 * dt * PF(PipePress, c->PipePress, Spg / (1.0 + 0.015 / Spg * Dim.L));
if (dv2 * dv2 > 0.00000000000001)
c->switch_physics(true);
c->switch_physics(true, wake_cause::mainpipe);
c->Pipe->Flow(-dv2);
}
// if ((Couplers[1].Connected != NULL) && (Couplers[0].Connected != NULL))
@@ -4974,7 +4974,10 @@ void TMoverParameters::ComputeTotalForce(double dt)
auto const calculatephysics{vehicleisactive || movingvehicleahead || movingvehiclebehind};
switch_physics(calculatephysics);
switch_physics(calculatephysics, Vel > 0.0001 ? wake_cause::speed :
accelerating() ? wake_cause::acceleration :
vehicleisactive ? wake_cause::rest :
wake_cause::neighbour);
}
if (false == PhysicActivation)
@@ -8941,7 +8944,7 @@ bool TMoverParameters::accelerating() const
// *************************************************************************************************
// Kasowanie zmiennych pracy fizyki
// *************************************************************************************************
bool TMoverParameters::switch_physics(bool const State) // DO PRZETLUMACZENIA NA KONCU
bool TMoverParameters::switch_physics(bool const State, wake_cause const Cause) // DO PRZETLUMACZENIA NA KONCU
{
if (PhysicActivation == State)
{
@@ -8952,7 +8955,7 @@ bool TMoverParameters::switch_physics(bool const State) // DO PRZETLUMACZENIA NA
if (true == State)
{
LastSwitchingTime = 0;
Timer::subsystem.switching.note(Timer::switching_counter::wake, this, &TypeName, &Name);
Timer::subsystem.switching.note(static_cast<Timer::switching_counter::source>(Timer::switching_counter::wake + static_cast<std::size_t>(Cause)), this, &TypeName, &Name);
}
return true;
@@ -12720,7 +12723,7 @@ bool TMoverParameters::RunInternalCommand()
CommandIn.Location.X = 0;
CommandIn.Location.Y = 0;
CommandIn.Location.Z = 0;
switch_physics(true);
switch_physics(true, wake_cause::command);
}
}
else

View File

@@ -883,7 +883,15 @@ void opengl46_renderer::SwapBuffers()
3,
"switching per second: compressor on " + std::to_string( switching.events[ source::compressor_on ] ) + ", off "
+ std::to_string( switching.events[ source::compressor_off ] ) + ", mains " + std::to_string( switching.events[ source::mains ] ) + ", diesel "
+ std::to_string( switching.events[ source::diesel ] ) + ", physics woken " + std::to_string( switching.events[ source::wake ] ),
+ std::to_string( switching.events[ source::diesel ] ),
"" );
text += timeline(
3,
"physics woken per second: brake pipe " + std::to_string( switching.events[ source::wake_mainpipe ] ) + ", main reservoir pipe "
+ std::to_string( switching.events[ source::wake_scndpipe ] ) + ", command " + std::to_string( switching.events[ source::wake_command ] )
+ ", speed " + std::to_string( switching.events[ source::wake_speed ] ) + ", acceleration "
+ std::to_string( switching.events[ source::wake_acceleration ] ) + ", neighbour " + std::to_string( switching.events[ source::wake_neighbour ] )
+ ", cab/ezt " + std::to_string( switching.events[ source::wake_rest ] ) + ", other " + std::to_string( switching.events[ source::wake ] ),
"" );
if( switching.busiestevents > 0 ) {
text += timeline( 3, "most often: " + switching.busiest + " (" + std::to_string( switching.busiestevents ) + ")", "" );

View File

@@ -94,7 +94,15 @@ public:
compressor_off,
mains,
diesel,
wake, // switch_physics( true ) of a vehicle whose physics was off
// switch_physics( true ) of a vehicle whose physics was off, by TMoverParameters::wake_cause, in its order
wake,
wake_mainpipe,
wake_scndpipe,
wake_command,
wake_speed,
wake_acceleration,
wake_neighbour,
wake_rest,
count
};
struct result {