18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 04:47:06 +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
+60 -60
View File
@@ -71,16 +71,16 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
// WriteLogSS("aa ok", BoolToYN(OK));
}
if (brakes.kind == TBrakeSystem::Individual && brakes.subsystem != TBrakeSubSystem::ss_None)
if (brakes.config.kind == TBrakeSystem::Individual && brakes.config.subsystem != TBrakeSubSystem::ss_None)
OK = false; //!
if (brakes.valveVolume == 0 && brakes.maxCylinderPressure[3] > 0 && brakes.kind != TBrakeSystem::Individual)
if (brakes.config.valveVolume == 0 && brakes.config.maxCylinderPressure[3] > 0 && brakes.config.kind != TBrakeSystem::Individual)
{
brakes.valveVolume = brakes.maxCylinderPressure[3] / (5.0 - brakes.maxCylinderPressure[3]) * (brakes.cylinders.radius * brakes.cylinders.radius * brakes.cylinders.stroke * brakes.cylinders.count * M_PI) * 1000;
brakes.config.valveVolume = brakes.config.maxCylinderPressure[3] / (5.0 - brakes.config.maxCylinderPressure[3]) * (brakes.config.cylinders.radius * brakes.config.cylinders.radius * brakes.config.cylinders.stroke * brakes.config.cylinders.count * M_PI) * 1000;
}
if (brakes.valveVolume == 0.0)
if (brakes.config.valveVolume == 0.0)
{
brakes.valveVolume = 0.01;
brakes.config.valveVolume = 0.01;
}
// WriteLog("BVV = " + FloatToStr(BrakeVVolume));
@@ -130,7 +130,7 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
ActFlowSpeed = 0.0;
brakes.handlePositionReal = brakes.handlePosition;
if (brakes.independentValveType == TBrakeHandle::Knorr)
if (brakes.config.independentValveType == TBrakeHandle::Knorr)
brakes.independentPosition = 0.5;
brakePipe.reservoir->CreatePress(brakePipe.Pressure());
@@ -165,9 +165,9 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
// taki mini automat - powinno byc ladnie dobrze :)
brakes.delaySetting = bdelay_P;
if (TestFlag(brakes.availableDelays, bdelay_G) && !TestFlag(brakes.availableDelays, bdelay_R))
if (TestFlag(brakes.config.availableDelays, bdelay_G) && !TestFlag(brakes.config.availableDelays, bdelay_R))
brakes.delaySetting = bdelay_G;
if (TestFlag(brakes.availableDelays, bdelay_R) && !TestFlag(brakes.availableDelays, bdelay_G))
if (TestFlag(brakes.config.availableDelays, bdelay_R) && !TestFlag(brakes.config.availableDelays, bdelay_G))
brakes.delaySetting = bdelay_R;
/*
// disabled, as test mode is used in specific situations and not really a default
@@ -182,12 +182,12 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
for (int b = 1; b < 4; b++)
{
if (brakes.delays[b] == 0)
brakes.delays[b] = DefBrakeTable[b];
brakes.delays[b] = brakes.delays[b] * (2.5 + Random(0.0, 0.2)) / 3.0;
if (brakes.config.delays[b] == 0)
brakes.config.delays[b] = DefBrakeTable[b];
brakes.config.delays[b] = brakes.config.delays[b] * (2.5 + Random(0.0, 0.2)) / 3.0;
}
brakes.distributor->Init(brakePipe.Pressure(), brakes.pipeHighPressure, brakes.pipeLowPressure, brakes.cylinderPressure, brakes.delaySetting);
brakes.distributor->Init(brakePipe.Pressure(), brakes.config.pipeHighPressure, brakes.config.pipeLowPressure, brakes.cylinderPressure, brakes.delaySetting);
/*
ScndPipePress = Compressor;
*/
@@ -220,28 +220,28 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
// the distributor valve of the vehicle's kind
void physics::Vehicle::CreateBrakeValve()
{
switch (brakes.distributorType)
switch (brakes.config.distributorType)
{
case TBrakeValve::W:
case TBrakeValve::K:
{
WriteLog("XBT W, K");
brakes.distributor = std::make_shared<TWest>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
if (brakes.maxPressureMass < 2) // jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.maxCylinderPressure[3], 0);
brakes.distributor = std::make_shared<TWest>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
if (brakes.config.maxPressureMass < 2) // jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0);
else
brakes.distributor->SetLP(Mass, brakes.maxPressureMass, brakes.maxCylinderPressure[1]);
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
break;
}
case TBrakeValve::KE:
{
WriteLog("XBT WKE");
brakes.distributor = std::make_shared<TKE>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
brakes.distributor->SetRM(brakes.rapidRatio);
if (brakes.maxPressureMass < 2) // jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.maxCylinderPressure[3], 0);
brakes.distributor = std::make_shared<TKE>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
brakes.distributor->SetRM(brakes.config.rapidRatio);
if (brakes.config.maxPressureMass < 2) // jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0);
else
brakes.distributor->SetLP(Mass, brakes.maxPressureMass, brakes.maxCylinderPressure[1]);
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
break;
}
case TBrakeValve::NESt3:
@@ -250,76 +250,76 @@ void physics::Vehicle::CreateBrakeValve()
case TBrakeValve::ESt4:
{
WriteLog("XBT NESt3, ESt3, ESt3AL2, ESt4");
brakes.distributor = std::make_shared<TNESt3>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
static_cast<TNESt3 *>(brakes.distributor.get())->SetSize(brakes.distributorSize, brakes.distributorParameters);
if (brakes.maxPressureMass < 2) // jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.maxCylinderPressure[3], 0);
brakes.distributor = std::make_shared<TNESt3>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
static_cast<TNESt3 *>(brakes.distributor.get())->SetSize(brakes.config.distributorSize, brakes.config.distributorParameters);
if (brakes.config.maxPressureMass < 2) // jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0);
else
brakes.distributor->SetLP(Mass, brakes.maxPressureMass, brakes.maxCylinderPressure[1]);
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
break;
}
case TBrakeValve::LSt:
{
WriteLog("XBT LSt");
brakes.distributor = std::make_shared<TLSt>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
brakes.distributor->SetRM(brakes.rapidRatio);
brakes.distributor = std::make_shared<TLSt>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
brakes.distributor->SetRM(brakes.config.rapidRatio);
break;
}
case TBrakeValve::EStED:
{
WriteLog("XBT EStED");
brakes.distributor = std::make_shared<TEStED>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
brakes.distributor->SetRM(brakes.rapidRatio);
if (brakes.maxPressureMass < 2)
brakes.distributor = std::make_shared<TEStED>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
brakes.distributor->SetRM(brakes.config.rapidRatio);
if (brakes.config.maxPressureMass < 2)
{
// jesli przystawka wazaca
brakes.distributor->SetLP(0, brakes.maxCylinderPressure[3], 0);
brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0);
}
else
{
brakes.distributor->SetLP(Mass, brakes.maxPressureMass, brakes.maxCylinderPressure[1]);
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
}
break;
}
case TBrakeValve::EP2:
{
WriteLog("XBT EP2");
brakes.distributor = std::make_shared<TEStEP2>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
brakes.distributor->SetLP(Mass, brakes.maxPressureMass, brakes.maxCylinderPressure[1]);
brakes.distributor = std::make_shared<TEStEP2>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
break;
}
case TBrakeValve::EP1:
{
WriteLog("XBT EP1");
brakes.distributor = std::make_shared<TEStEP1>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
brakes.distributor->SetLP(Mass, brakes.maxPressureMass, brakes.maxCylinderPressure[1]);
brakes.distributor->SetRM(brakes.rapidRatio);
brakes.distributor = std::make_shared<TEStEP1>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]);
brakes.distributor->SetRM(brakes.config.rapidRatio);
break;
}
case TBrakeValve::CV1:
{
WriteLog("XBT CV1");
brakes.distributor = std::make_shared<TCV1>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
brakes.distributor = std::make_shared<TCV1>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
break;
}
case TBrakeValve::CV1_L_TR:
{
WriteLog("XBT CV1_L_T");
brakes.distributor = std::make_shared<TCV1L_TR>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
brakes.distributor = std::make_shared<TCV1L_TR>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
break;
}
default:
brakes.distributor = std::make_shared<TBrake>(brakes.maxCylinderPressure[3], brakes.cylinders.radius, brakes.cylinders.stroke, brakes.valveVolume, brakes.cylinders.count, brakes.availableDelays, brakes.method, NAxles, brakes.blocksPerAxle);
brakes.distributor = std::make_shared<TBrake>(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle);
}
brakes.distributor->SetASBP(brakes.maxCylinderPressure[4]);
brakes.distributor->SetRV(brakes.rapidSpeed);
brakes.distributor->SetASBP(brakes.config.maxCylinderPressure[4]);
brakes.distributor->SetRV(brakes.config.rapidSpeed);
}
// the driver's handle and the local brake handle of the vehicle's kinds
void physics::Vehicle::CreateBrakeHandles()
{
switch (brakes.driverValveType)
switch (brakes.config.driverValveType)
{
using enum TBrakeHandle;
case FV4a:
@@ -356,14 +356,14 @@ void physics::Vehicle::CreateBrakeHandles()
default:
brakes.driverValve = std::make_shared<TDriverHandle>();
}
brakes.driverValve->SetParams(brakes.driverValveSettings.automaticOverload, brakes.driverValveSettings.manualOverload, brakes.driverValveSettings.genericParameter1, brakes.driverValveSettings.genericParameter2, brakes.driverValveSettings.overloadMaxPressure, brakes.driverValveSettings.overloadPressureDecrease);
brakes.driverValve->SetParams(brakes.config.driverValveSettings.automaticOverload, brakes.config.driverValveSettings.manualOverload, brakes.config.driverValveSettings.genericParameter1, brakes.config.driverValveSettings.genericParameter2, brakes.config.driverValveSettings.overloadMaxPressure, brakes.config.driverValveSettings.overloadPressureDecrease);
switch (brakes.independentValveType)
switch (brakes.config.independentValveType)
{
case TBrakeHandle::FD1:
{
brakes.independentValve = std::make_shared<TFD1>();
brakes.independentValve->Init(brakes.maxCylinderPressure[0]);
brakes.independentValve->Init(brakes.config.maxCylinderPressure[0]);
if (TrainType == train_type::emu)
{
@@ -374,7 +374,7 @@ void physics::Vehicle::CreateBrakeHandles()
case TBrakeHandle::Knorr:
{
brakes.independentValve = std::make_shared<TH1405>();
brakes.independentValve->Init(brakes.maxCylinderPressure[0]);
brakes.independentValve->Init(brakes.config.maxCylinderPressure[0]);
break;
}
default:
@@ -385,16 +385,16 @@ void physics::Vehicle::CreateBrakeHandles()
// the brake pipe, the main pipe and the spring brake's cylinder
void physics::Vehicle::CreateBrakePipes()
{
if (true == TestFlag(brakes.availableDelays, bdelay_G) && (false == TestFlag(brakes.availableDelays, bdelay_R) || Power > 1.0)) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy
brakes.pipeSection = 0.792;
if (true == TestFlag(brakes.config.availableDelays, bdelay_G) && (false == TestFlag(brakes.config.availableDelays, bdelay_R) || Power > 1.0)) // ustalanie srednicy przewodu glownego (lokomotywa lub napędowy
brakes.config.pipeSection = 0.792;
else
brakes.pipeSection = 0.507;
brakes.config.pipeSection = 0.507;
// WriteLog("SPG = " + FloatToStr(Spg));
brakePipe.reservoir = std::make_shared<TReservoir>();
mainPipe.reservoir = std::make_shared<TReservoir>(); // zabezpieczenie, bo sie PG wywala... :(
brakePipe.reservoir->CreateCap((std::max(Dim.L, 14.0) + 0.5) * brakes.pipeSection * 1); // dlugosc x przekroj x odejscia i takie tam
mainPipe.reservoir->CreateCap((std::max(Dim.L, 14.0) + 0.5) * brakes.pipeSection * 1);
brakePipe.reservoir->CreateCap((std::max(Dim.L, 14.0) + 0.5) * brakes.config.pipeSection * 1); // dlugosc x przekroj x odejscia i takie tam
mainPipe.reservoir->CreateCap((std::max(Dim.L, 14.0) + 0.5) * brakes.config.pipeSection * 1);
if (!brakes.spring.cylinder)
{
brakes.spring.cylinder = std::make_shared<TReservoir>();
@@ -447,19 +447,19 @@ void physics::Vehicle::SetReadyToDepart()
void physics::Vehicle::SetBraked()
{
WriteLog("Braked");
brakes.reservoirAir = brakes.valveVolume * brakes.maxCylinderPressure[3];
brakes.reservoirAir = brakes.config.valveVolume * brakes.config.maxCylinderPressure[3];
air.Fill(air.config.mainReservoirVolume * air.compressor.config.minPressure * 0.55);
/*
ScndPipePress = 5.1;
*/
mainPipe.SetPressure(InitialScndPipePress(5.1));
brakePipe.SetPressure(brakes.pipeLowPressure);
brakes.pipeCylinderPressure = brakes.maxCylinderPressure[3] * 0.5;
brakes.cylinderPressure = brakes.maxCylinderPressure[3] * 0.5;
brakePipe.SetPressure(brakes.config.pipeLowPressure);
brakes.pipeCylinderPressure = brakes.config.maxCylinderPressure[3] * 0.5;
brakes.cylinderPressure = brakes.config.maxCylinderPressure[3] * 0.5;
brakes.independentPosition = 0.0;
brakes.handlePosition = static_cast<int>(brakes.driverValve->GetPos(bh_NP));
brakes.pipeLimiterPressure = brakes.pipeLowPressure;
if (brakes.localKind == TLocalBrake::ManualBrake || brakes.hasHandBrake == true)
brakes.pipeLimiterPressure = brakes.config.pipeLowPressure;
if (brakes.config.localKind == TLocalBrake::ManualBrake || brakes.config.hasHandBrake == true)
{
IncManualBrakeLevel(ManualBrakePosNo);
}