18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 10:46:45 +01:00

refactor(physics): the definition of the brakes apart from their state

What the .fiz gives about the brakes of a vehicle (the kinds of the brake
system, the valves and the handles, the cylinders and the rigging, the pipe
pressures, the delays and the modes it can be set to: 35 fields) moves into
physics::Braking::Config, held as brakes.config, set as the vehicle loads and
not changed after. Six fields that sat with the definition but change in the
run (the weighted pressures of the handle position, the universal buttons
pressed, the load setting, the control reservoir, the emergency valve, the
lock of the pipe) go with the state.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 10:36:09 +01:00
parent 447fe54f3d
commit 2d67e9b1a3
42 changed files with 485 additions and 481 deletions
+36 -36
View File
@@ -101,17 +101,17 @@ physics::Vehicle::Vehicle(double VelInitial, std::string const &TypeNameInit, st
for (int b = -1; b <= MainBrakeMaxPos; ++b)
{
brakes.pressureTable[b].PipePressureVal = 0.0;
brakes.pressureTable[b].BrakePressureVal = 0.0;
brakes.pressureTable[b].FlowSpeedVal = 0.0;
brakes.config.pressureTable[b].PipePressureVal = 0.0;
brakes.config.pressureTable[b].BrakePressureVal = 0.0;
brakes.config.pressureTable[b].FlowSpeedVal = 0.0;
}
// with BrakePressureTable[-2] do {pozycja odciecia}
{
brakes.pressureTable[-2].PipePressureVal = -1.0;
brakes.pressureTable[-2].BrakePressureVal = -1.0;
brakes.pressureTable[-2].FlowSpeedVal = 0.0;
brakes.config.pressureTable[-2].PipePressureVal = -1.0;
brakes.config.pressureTable[-2].BrakePressureVal = -1.0;
brakes.config.pressureTable[-2].FlowSpeedVal = 0.0;
}
for (auto &delay : brakes.delays)
for (auto &delay : brakes.config.delays)
{
delay = 0.0;
}
@@ -126,7 +126,7 @@ physics::Vehicle::Vehicle(double VelInitial, std::string const &TypeNameInit, st
Couplers[b].DmaxC = 0.1;
Couplers[b].FmaxC = 1000.0;
}
for (auto &cylindermult : brakes.cylinders.leverRatio)
for (auto &cylindermult : brakes.config.cylinders.leverRatio)
{
cylindermult = 0.0;
}
@@ -143,7 +143,7 @@ physics::Vehicle::Vehicle(double VelInitial, std::string const &TypeNameInit, st
couplerentry.CheckCollision = false;
}
for (auto &brakepress : brakes.maxCylinderPressure)
for (auto &brakepress : brakes.config.maxCylinderPressure)
{
brakepress = 0.0;
}
@@ -504,7 +504,7 @@ void physics::Vehicle::compute_movement_(double const Deltatime)
brakes.electrodynamic.emuWorking &= Couplers[VehicleEnd::rear].Connected->brakes.electrodynamic.emuWorking;
}
if (brakes.antiSlipTimer > 0.8 && brakes.antiSlipType != 128)
if (brakes.antiSlipTimer > 0.8 && brakes.config.antiSlipType != 128)
{ // ASBSpeed=0.8
// hamulec antypoślizgowy - wyłączanie
brakes.distributor->ASB(0);
@@ -834,11 +834,11 @@ void physics::Vehicle::ComputeTotalForce(double dt)
double old_nrot = abs(nrot);
nrot = v2n(); // przeliczenie prędkości liniowej na obrotową
if (true == TestFlag(brakes.method, bp_MHS) && brakePipe.Pressure() < 3.0 // ustawione na sztywno na 3 bar
if (true == TestFlag(brakes.config.method, bp_MHS) && brakePipe.Pressure() < 3.0 // ustawione na sztywno na 3 bar
&& Vel > 45 && true == TestFlag(brakes.delaySetting, bdelay_M))
{
// doliczenie hamowania hamulcem szynowym
FStand += brakes.trackBrakeForce;
FStand += brakes.config.trackBrakeForce;
}
// w charakterystykach jest wartość siły hamowania zamiast nacisku
@@ -942,22 +942,22 @@ double physics::Vehicle::BrakeForceR(double ratio, double velocity) const
{
double press = 0;
ratio = brakes.distributor->GetBrakeRatio(ratio);
if (brakes.maxPressureMass > 2)
if (brakes.config.maxPressureMass > 2)
{
press = brakes.maxCylinderPressure[1] + (brakes.maxCylinderPressure[3] - brakes.maxCylinderPressure[1]) * std::min(1.0, (TotalMass - Mass) / (brakes.maxPressureMass - Mass));
press = brakes.config.maxCylinderPressure[1] + (brakes.config.maxCylinderPressure[3] - brakes.config.maxCylinderPressure[1]) * std::min(1.0, (TotalMass - Mass) / (brakes.config.maxPressureMass - Mass));
}
else
{
if (brakes.maxCylinderPressure[1] > 0.1)
if (brakes.config.maxCylinderPressure[1] > 0.1)
{
press = brakes.maxCylinderPressure[brakes.loadSetting];
press = brakes.config.maxCylinderPressure[brakes.loadSetting];
}
else
{
press = brakes.maxCylinderPressure[3];
press = brakes.config.maxCylinderPressure[3];
if (brakes.electrodynamic.type == dbrake_automatic)
ratio = ratio + (1.5 - ratio) * std::min(1.0, Vel * 0.02);
if (brakes.delaySetting & bdelay_R && brakes.method % 128 != bp_Cosid && brakes.method % 128 != bp_D1 && brakes.method % 128 != bp_D2 && Power < 1)
if (brakes.delaySetting & bdelay_R && brakes.config.method % 128 != bp_Cosid && brakes.config.method % 128 != bp_D1 && brakes.config.method % 128 != bp_D2 && Power < 1)
ratio *= brakes.distributor->GetRapidRatio(velocity);
if (TrainType == train_type::dmu && velocity < 30.0)
{
@@ -971,9 +971,9 @@ double physics::Vehicle::BrakeForceR(double ratio, double velocity) const
double physics::Vehicle::BrakeForceP(double press, double velocity) const
{
double BFP = 0;
double K = ((press * brakes.pressureToForce - brakes.cylinders.springForce) * brakes.cylinders.leverRatio[0] - brakes.cylinders.slackAdjusterForce) * brakes.cylinders.riggingEfficiency;
K *= static_cast<double>(brakes.cylinders.count) / (NAxles * std::max(1, brakes.blocksPerAxle));
BFP = brakes.distributor->GetFC(velocity, K) * K * (NAxles * std::max(1, brakes.blocksPerAxle)) * 1000;
double K = ((press * brakes.config.pressureToForce - brakes.config.cylinders.springForce) * brakes.config.cylinders.leverRatio[0] - brakes.config.cylinders.slackAdjusterForce) * brakes.config.cylinders.riggingEfficiency;
K *= static_cast<double>(brakes.config.cylinders.count) / (NAxles * std::max(1, brakes.config.blocksPerAxle));
BFP = brakes.distributor->GetFC(velocity, K) * K * (NAxles * std::max(1, brakes.config.blocksPerAxle)) * 1000;
return BFP;
}
@@ -987,16 +987,16 @@ double physics::Vehicle::BrakeForce(TTrackParam const & /*Track*/)
double K{0};
double brakeforce{0};
switch (brakes.localKind)
switch (brakes.config.localKind)
{
case TLocalBrake::ManualBrake:
{
K = brakes.maxForce * ManualBrakeRatio();
K = brakes.config.maxForce * ManualBrakeRatio();
break;
}
case TLocalBrake::HydraulicBrake:
{
K = brakes.maxForce * LocalBrakeRatio();
K = brakes.config.maxForce * LocalBrakeRatio();
break;
}
default:
@@ -1005,34 +1005,34 @@ double physics::Vehicle::BrakeForce(TTrackParam const & /*Track*/)
}
}
if (brakes.hasHandBrake == true)
if (brakes.config.hasHandBrake == true)
{
K = brakes.maxForce * ManualBrakeRatio();
K = brakes.config.maxForce * ManualBrakeRatio();
}
// the spring brake of a vehicle prepared for hauling (PulleeMode) is released by hand: no force, whatever its cylinder has
if (brakes.spring.isReady && false == PulleeMode)
K += std::max(0.0, brakes.spring.minForcePressure - brakes.spring.cylinder->P()) * brakes.spring.maxForce;
u = (brakes.cylinderPressure * brakes.pressureToForce - brakes.cylinders.springForce) * brakes.cylinders.leverRatio[0] - brakes.cylinders.slackAdjusterForce;
if (u * brakes.cylinders.riggingEfficiency > Ntotal) // histereza na nacisku klockow
Ntotal = u * brakes.cylinders.riggingEfficiency;
u = (brakes.cylinderPressure * brakes.config.pressureToForce - brakes.config.cylinders.springForce) * brakes.config.cylinders.leverRatio[0] - brakes.config.cylinders.slackAdjusterForce;
if (u * brakes.config.cylinders.riggingEfficiency > Ntotal) // histereza na nacisku klockow
Ntotal = u * brakes.config.cylinders.riggingEfficiency;
else
{
u = (brakes.cylinderPressure * brakes.pressureToForce - brakes.cylinders.springForce) * brakes.cylinders.leverRatio[0] - brakes.cylinders.slackAdjusterForce;
if (u * (2.0 - brakes.cylinders.riggingEfficiency) < Ntotal) // histereza na nacisku klockow
Ntotal = u * (2.0 - brakes.cylinders.riggingEfficiency);
u = (brakes.cylinderPressure * brakes.config.pressureToForce - brakes.config.cylinders.springForce) * brakes.config.cylinders.leverRatio[0] - brakes.config.cylinders.slackAdjusterForce;
if (u * (2.0 - brakes.config.cylinders.riggingEfficiency) < Ntotal) // histereza na nacisku klockow
Ntotal = u * (2.0 - brakes.config.cylinders.riggingEfficiency);
}
auto const NBrakeAxles{NAxles};
if (NBrakeAxles * brakes.blocksPerAxle > 0)
if (NBrakeAxles * brakes.config.blocksPerAxle > 0)
{
if (Ntotal > 0) // nie luz
K += Ntotal; // w kN
K *= static_cast<double>(brakes.cylinders.count) / (NBrakeAxles * static_cast<double>(brakes.blocksPerAxle)); // w kN na os
K *= static_cast<double>(brakes.config.cylinders.count) / (NBrakeAxles * static_cast<double>(brakes.config.blocksPerAxle)); // w kN na os
}
if (brakes.kind == TBrakeSystem::Pneumatic || brakes.kind == TBrakeSystem::ElectroPneumatic)
if (brakes.config.kind == TBrakeSystem::Pneumatic || brakes.config.kind == TBrakeSystem::ElectroPneumatic)
{
u = brakes.distributor->GetFC(Vel, K);
brakes.unitForce = u * K * 1000.0; // sila na jeden klocek w N
@@ -1043,7 +1043,7 @@ double physics::Vehicle::BrakeForce(TTrackParam const & /*Track*/)
// Fb:=UnitBrakeForce*NBpA {ham. reczny dziala na jedna os}
// else //yB: to nie do konca ma sens, ponieważ ręczny w wagonie działa na jeden cylinder
// hamulcowy/wózek, dlatego potrzebne są oddzielnie liczone osie
brakeforce = brakes.unitForce * NBrakeAxles * std::max(1, brakes.blocksPerAxle);
brakeforce = brakes.unitForce * NBrakeAxles * std::max(1, brakes.config.blocksPerAxle);
// u:=((BrakePress*P2FTrans)-BrakeCylSpring*BrakeCylMult[BCMFlag]/BrakeCylNo-0.83*BrakeSlckAdj/(BrakeCylNo))*BrakeCylNo;
// { end; }