mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 05:02:45 +01:00
refactor(physics): what the rest of the simulator only reads of a vehicle is private to it
53 fields of physics::Vehicle that only the vehicle itself writes, and the rest
of the simulator reads, are private, with a query each, named as the field was
(Vmax(), TotalMass(), Ft(), nrot(), NAxles(), PhysicActivation(), ...): the
compiler now keeps the cab, the AI, the scenery, the renderer and the tests from
changing what the definition gives or the physics works out. The fields were
picked by what is never written outside the class, of plain types, with no
other member of the same name to confuse; inside the class they keep their
meaning under camelCase names. The one place outside that cleared a flag of
the AI through a reference does it through ClearAIFlag().
No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
@@ -48,12 +48,12 @@ bool physics::Vehicle::IncMainCtrl(int CtrlSpeed)
|
||||
// nie ma sterowania
|
||||
return false;
|
||||
}
|
||||
if (TrainType == train_type::et22 && scndCtrlPos != 0)
|
||||
if (trainType == train_type::et22 && scndCtrlPos != 0)
|
||||
{
|
||||
// w ET22 nie da się kręcić nastawnikiem przy włączonym boczniku
|
||||
return false;
|
||||
}
|
||||
if (TrainType == train_type::emu && DirActive == 0)
|
||||
if (trainType == train_type::emu && DirActive == 0)
|
||||
{
|
||||
// w EZT nie da się załączyć pozycji bez ustawienia kierunku
|
||||
return false;
|
||||
@@ -69,7 +69,7 @@ bool physics::Vehicle::IncMainCtrl(int CtrlSpeed)
|
||||
if (true == CoupledCtrl)
|
||||
{
|
||||
// wspólny wał nastawnika jazdy i bocznikowania
|
||||
if (scndCtrlPos < ScndCtrlPosNo)
|
||||
if (scndCtrlPos < scndCtrlPosNo)
|
||||
{ // 3<3 -> false
|
||||
++scndCtrlPos;
|
||||
OK = true;
|
||||
@@ -95,9 +95,9 @@ bool physics::Vehicle::IncMainCtrl(int CtrlSpeed)
|
||||
|
||||
if (OK)
|
||||
{
|
||||
if (DelayCtrlFlag)
|
||||
if (delayCtrlFlag)
|
||||
{
|
||||
if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay && mainCtrlPos == 1)
|
||||
if (lineContactors.TimeSinceSwitch() >= initialCtrlDelay && mainCtrlPos == 1)
|
||||
lineContactors.RestartSwitchTimer();
|
||||
}
|
||||
else if (lineContactors.TimeSinceSwitch() > CtrlDelay)
|
||||
@@ -125,7 +125,7 @@ bool physics::Vehicle::IncMainCtrlSeriesMotor(int const CtrlSpeed)
|
||||
if (CtrlSpeed > 1)
|
||||
{
|
||||
// szybkie przejœcie na bezoporow¹
|
||||
if (TrainType == train_type::et40)
|
||||
if (trainType == train_type::et40)
|
||||
{
|
||||
return false; // this means ET40 won't react at all to fast acceleration command. should it issue just IncMainCtrl(1) instead?
|
||||
}
|
||||
@@ -143,7 +143,7 @@ bool physics::Vehicle::IncMainCtrlSeriesMotor(int const CtrlSpeed)
|
||||
{ // CtrlSpeed == 1
|
||||
++mainCtrlPos;
|
||||
OK = true;
|
||||
if (Imax == ImaxHi && RList[mainCtrlPos].Bn > 1)
|
||||
if (Imax == imaxHi && RList[mainCtrlPos].Bn > 1)
|
||||
{
|
||||
/* NOTE: disabled, relay configuration was moved to compute_movement_
|
||||
if( true == MaxCurrentSwitch( false )) {
|
||||
@@ -151,7 +151,7 @@ bool physics::Vehicle::IncMainCtrlSeriesMotor(int const CtrlSpeed)
|
||||
SetFlag( soundFlag, sound::relay );
|
||||
}
|
||||
*/
|
||||
if (TrainType == train_type::et42)
|
||||
if (trainType == train_type::et42)
|
||||
{
|
||||
--mainCtrlPos;
|
||||
OK = false;
|
||||
@@ -167,7 +167,7 @@ bool physics::Vehicle::IncMainCtrlSeriesMotor(int const CtrlSpeed)
|
||||
//}
|
||||
}
|
||||
|
||||
if (TrainType == train_type::et42 && true == brakes.electrodynamic.on && mainCtrlPos > 20)
|
||||
if (trainType == train_type::et42 && true == brakes.electrodynamic.on && mainCtrlPos > 20)
|
||||
{
|
||||
mainCtrlPos = 20;
|
||||
OK = false;
|
||||
@@ -197,7 +197,7 @@ bool physics::Vehicle::DecMainCtrl(int CtrlSpeed)
|
||||
// TBD, TODO: replace with mainctrlpowerpos() check?
|
||||
if (mainCtrlPos > 0)
|
||||
{
|
||||
if (TrainType != train_type::et22 || scndCtrlPos == 0) // Ra: ET22 blokuje nastawnik przy boczniku
|
||||
if (trainType != train_type::et22 || scndCtrlPos == 0) // Ra: ET22 blokuje nastawnik przy boczniku
|
||||
{
|
||||
if (CoupledCtrl && scndCtrlPos > 0)
|
||||
{
|
||||
@@ -224,9 +224,9 @@ bool physics::Vehicle::DecMainCtrl(int CtrlSpeed)
|
||||
// hunter-101012: poprawka
|
||||
if (OK)
|
||||
{
|
||||
if (DelayCtrlFlag)
|
||||
if (delayCtrlFlag)
|
||||
{
|
||||
if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay)
|
||||
if (lineContactors.TimeSinceSwitch() >= initialCtrlDelay)
|
||||
lineContactors.RestartSwitchTimer();
|
||||
}
|
||||
else if (lineContactors.TimeSinceSwitch() > CtrlDownDelay)
|
||||
@@ -323,7 +323,7 @@ int physics::Vehicle::MainCtrlPowerPos() const
|
||||
|
||||
int physics::Vehicle::EIMCtrlEmergencyPositions() const
|
||||
{
|
||||
return (EIMCtrlType == 2 && EIMCtrlMainEmergency) ? 1 : 0;
|
||||
return (EIMCtrlType == 2 && eimCtrlMainEmergency) ? 1 : 0;
|
||||
}
|
||||
|
||||
bool physics::Vehicle::IsMainCtrlEmergencyPos() const
|
||||
@@ -350,20 +350,20 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed)
|
||||
{
|
||||
bool OK = false;
|
||||
|
||||
if (brakes.electrodynamic.on && TrainType == train_type::et42 && CabActive != 0 && IsMainCtrlNoPowerPos() && scndCtrlPos == 0)
|
||||
if (brakes.electrodynamic.on && trainType == train_type::et42 && CabActive != 0 && IsMainCtrlNoPowerPos() && scndCtrlPos == 0)
|
||||
{
|
||||
OK = DynamicBrakeSwitch(false);
|
||||
}
|
||||
else if (ScndCtrlPosNo > 0 && CabActive != 0 && !(TrainType == train_type::et42 && (Imax == ImaxHi || (brakes.electrodynamic.on && MainCtrlPowerPos() > 0))))
|
||||
else if (scndCtrlPosNo > 0 && CabActive != 0 && !(trainType == train_type::et42 && (Imax == imaxHi || (brakes.electrodynamic.on && MainCtrlPowerPos() > 0))))
|
||||
{
|
||||
// if (RList[mainCtrlPos].R=0) and (mainCtrlPos>0) and (scndCtrlPos<ScndCtrlPosNo) and
|
||||
// (not CoupledCtrl) then
|
||||
if (scndCtrlPos < ScndCtrlPosNo && !CoupledCtrl && !IsScndCtrlLockedByMainCtrl())
|
||||
if (scndCtrlPos < scndCtrlPosNo && !CoupledCtrl && !IsScndCtrlLockedByMainCtrl())
|
||||
{
|
||||
// TBD, TODO: refactor this validation as part of relay check routine (currently in tractionforce()
|
||||
// TBD, TODO: diesel electric engine utilize scndctrlactualpos like the other types?
|
||||
if (EngineType == TEngineType::DieselElectric &&
|
||||
(IsMainCtrlNoPowerPos() || fieldshunting::diesel_electric(AutoRelayType, FieldShuntSwitch, AutoRelayFlag) != fieldshunting::control::manual || ShuntMode || false == lineBreaker.IsClosed()))
|
||||
(IsMainCtrlNoPowerPos() || fieldshunting::diesel_electric(autoRelayType, fieldShuntSwitch, autoRelayFlag) != fieldshunting::control::manual || ShuntMode || false == lineBreaker.IsClosed()))
|
||||
{
|
||||
OK = false;
|
||||
}
|
||||
@@ -375,7 +375,7 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed)
|
||||
}
|
||||
else if (CtrlSpeed > 1)
|
||||
{
|
||||
scndCtrlPos = ScndCtrlPosNo; // takie chamskie, potem poprawie
|
||||
scndCtrlPos = scndCtrlPosNo; // takie chamskie, potem poprawie
|
||||
}
|
||||
OK = true;
|
||||
}
|
||||
@@ -395,7 +395,7 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed)
|
||||
if (OK && lineContactors.TimeSinceSwitch() > CtrlDelay)
|
||||
lineContactors.RestartSwitchTimer();
|
||||
|
||||
if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1 && mainCtrlPos > 0)
|
||||
if (OK && EngineType == TEngineType::ElectricInductionMotor && scndCtrlPosNo == 1 && mainCtrlPos > 0)
|
||||
{
|
||||
SpeedCtrlValue = Vel;
|
||||
if (EIMCtrlType == 0 && (SpeedCtrlAutoTurnOffFlag & 1) == 1)
|
||||
@@ -405,7 +405,7 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed)
|
||||
SpeedCtrlUnit.IsActive = true;
|
||||
}
|
||||
|
||||
if (OK && SpeedCtrl && scndCtrlPos == 1 && EngineType == TEngineType::DieselEngine)
|
||||
if (OK && speedCtrl && scndCtrlPos == 1 && EngineType == TEngineType::DieselEngine)
|
||||
{
|
||||
// NOTE: round() already adds 0.5, are the ones added here as well correct?
|
||||
SpeedCtrlValue = static_cast<double>(Round(Vel));
|
||||
@@ -423,14 +423,14 @@ bool physics::Vehicle::DecScndCtrl(int CtrlSpeed)
|
||||
{
|
||||
bool OK = false;
|
||||
|
||||
if (IsMainCtrlNoPowerPos() && CabActive != 0 && TrainType == train_type::et42 && scndCtrlPos == 0 && !brakes.electrodynamic.on && CtrlSpeed == 1)
|
||||
if (IsMainCtrlNoPowerPos() && CabActive != 0 && trainType == train_type::et42 && scndCtrlPos == 0 && !brakes.electrodynamic.on && CtrlSpeed == 1)
|
||||
{
|
||||
// Ra: AI wywołuje z CtrlSpeed=2 albo gdy scndCtrlPos>0
|
||||
OK = DynamicBrakeSwitch(true);
|
||||
}
|
||||
else if (ScndCtrlPosNo > 0 && CabActive != 0)
|
||||
else if (scndCtrlPosNo > 0 && CabActive != 0)
|
||||
{
|
||||
if (scndCtrlPos > 0 && !CoupledCtrl && (EngineType != TEngineType::DieselElectric || !AutoRelayFlag) && !IsScndCtrlLockedByMainCtrl())
|
||||
if (scndCtrlPos > 0 && !CoupledCtrl && (EngineType != TEngineType::DieselElectric || !autoRelayFlag) && !IsScndCtrlLockedByMainCtrl())
|
||||
{
|
||||
if (CtrlSpeed == 1)
|
||||
{
|
||||
@@ -457,7 +457,7 @@ bool physics::Vehicle::DecScndCtrl(int CtrlSpeed)
|
||||
if (OK && lineContactors.TimeSinceSwitch() > CtrlDownDelay)
|
||||
lineContactors.RestartSwitchTimer();
|
||||
|
||||
if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1)
|
||||
if (OK && EngineType == TEngineType::ElectricInductionMotor && scndCtrlPosNo == 1)
|
||||
{
|
||||
SpeedCtrlValue = 0;
|
||||
SpeedCtrlUnit.IsActive = false;
|
||||
@@ -467,7 +467,7 @@ bool physics::Vehicle::DecScndCtrl(int CtrlSpeed)
|
||||
}
|
||||
}
|
||||
|
||||
if (OK && SpeedCtrl && scndCtrlPos == 0 && EngineType == TEngineType::DieselEngine)
|
||||
if (OK && speedCtrl && scndCtrlPos == 0 && EngineType == TEngineType::DieselEngine)
|
||||
{
|
||||
SpeedCtrlValue = 0;
|
||||
SpeedCtrlUnit.IsActive = false;
|
||||
@@ -498,7 +498,7 @@ void physics::Vehicle::ScndCtrlResistiveLockCheck()
|
||||
|
||||
int physics::Vehicle::GetVirtualScndPos() const
|
||||
{
|
||||
if (TrainType == train_type::et42 && brakes.electrodynamic.on && !scndCtrlPos)
|
||||
if (trainType == train_type::et42 && brakes.electrodynamic.on && !scndCtrlPos)
|
||||
return -1;
|
||||
return scndCtrlPos;
|
||||
}
|
||||
@@ -506,13 +506,13 @@ int physics::Vehicle::GetVirtualScndPos() const
|
||||
bool physics::Vehicle::IsScndCtrlNoPowerPos() const
|
||||
{
|
||||
// TODO: refine the check on account of potential electric series vehicles with speed control
|
||||
return scndCtrlPos == 0 || true == SpeedCtrl;
|
||||
return scndCtrlPos == 0 || true == speedCtrl;
|
||||
}
|
||||
|
||||
bool physics::Vehicle::IsScndCtrlMaxPowerPos() const
|
||||
{
|
||||
// TODO: refine the check on account of potential electric series vehicles with speed control
|
||||
return scndCtrlPos == ScndCtrlPosNo || true == SpeedCtrl;
|
||||
return scndCtrlPos == scndCtrlPosNo || true == speedCtrl;
|
||||
}
|
||||
|
||||
// *************************************************************************************************
|
||||
@@ -522,9 +522,9 @@ bool physics::Vehicle::IsScndCtrlMaxPowerPos() const
|
||||
bool physics::Vehicle::AutoRelaySwitch(bool State)
|
||||
{
|
||||
bool ARS;
|
||||
if (AutoRelayType == 2 && AutoRelayFlag != State)
|
||||
if (autoRelayType == 2 && autoRelayFlag != State)
|
||||
{
|
||||
AutoRelayFlag = State;
|
||||
autoRelayFlag = State;
|
||||
ARS = true;
|
||||
SendCtrlToNext(VehicleCommand::autoRelaySwitch, int(State), CabActive);
|
||||
}
|
||||
@@ -559,9 +559,9 @@ bool physics::Vehicle::AutoRelayCheck(void)
|
||||
}
|
||||
|
||||
// sprawdzenie wszystkich warunkow (AutoRelayFlag, AutoSwitch, Im<Imin)
|
||||
auto const ARFASI2{(false == AutoRelayFlag || (motor_param(ScndCtrlActualPos).AutoSwitch && abs(Im) < Imin))};
|
||||
auto const ARFASI2{(false == autoRelayFlag || (motor_param(ScndCtrlActualPos).AutoSwitch && abs(Im) < imin))};
|
||||
auto const ARFASI{
|
||||
(false == AutoRelayFlag || (RList[MainCtrlActualPos].AutoSwitch && abs(Im) < Imin) || (!RList[MainCtrlActualPos].AutoSwitch && RList[MainCtrlActualPos].Relay < mainCtrlPos))};
|
||||
(false == autoRelayFlag || (RList[MainCtrlActualPos].AutoSwitch && abs(Im) < imin) || (!RList[MainCtrlActualPos].AutoSwitch && RList[MainCtrlActualPos].Relay < mainCtrlPos))};
|
||||
// brak PSR na tej pozycji działa PSR i prąd poniżej progu
|
||||
// na tej pozycji nie działa PSR i pozycja walu ponizej
|
||||
// chodzi w tym wszystkim o to, żeby można było zatrzymać rozruch na
|
||||
@@ -607,7 +607,7 @@ bool physics::Vehicle::AutoRelayShuntStep(bool const ARFASI2)
|
||||
}
|
||||
else if (ScndCtrlActualPos > scndCtrlPos)
|
||||
{
|
||||
if (lineContactors.TimeSinceSwitch() > CtrlDownDelay && TrainType != train_type::emu)
|
||||
if (lineContactors.TimeSinceSwitch() > CtrlDownDelay && trainType != train_type::emu)
|
||||
{
|
||||
--ScndCtrlActualPos;
|
||||
SetFlag(soundFlag, sound::shuntfield);
|
||||
@@ -626,11 +626,11 @@ bool physics::Vehicle::AutoRelayMainStep(bool const ARFASI)
|
||||
// running backwards, the motors don't get joined in more branches than allowed (the series connection
|
||||
// alone, usually); the camshaft still goes back down from there (eu07/maszyna#393: it stayed where it
|
||||
// was, the line contactors closed, whatever the driver did with the master controller)
|
||||
auto const backwardslimit{DirActive < 0 && TrainType != train_type::pseudodiesel && RList[MainCtrlActualPos + 1].Bn > BackwardsBranchesAllowed};
|
||||
auto const backwardslimit{DirActive < 0 && trainType != train_type::pseudodiesel && RList[MainCtrlActualPos + 1].Bn > BackwardsBranchesAllowed};
|
||||
// main bez samoczynnego rozruchu
|
||||
if (false == backwardslimit && MainCtrlActualPos < std::size(RList) - 1 // crude guard against running out of current fixed table
|
||||
&& (RList[MainCtrlActualPos].Relay < mainCtrlPos || (RList[MainCtrlActualPos + 1].Relay == mainCtrlPos && MainCtrlActualPos < RlistSize) ||
|
||||
(TrainType == train_type::et22 && DelayCtrlFlag)))
|
||||
(trainType == train_type::et22 && delayCtrlFlag)))
|
||||
{
|
||||
OK = AutoRelayMainUp(ARFASI);
|
||||
}
|
||||
@@ -695,19 +695,19 @@ bool physics::Vehicle::AutoRelayMainNotchUp()
|
||||
bool OK = false;
|
||||
// WriteLog("LRT = " + FloatToStr(LastRelayTime) + ", " +
|
||||
// FloatToStr(CtrlDelay));
|
||||
if (TrainType == train_type::et22 && mainCtrlPos > 1 && (RList[MainCtrlActualPos].Bn < RList[MainCtrlActualPos + 1].Bn || DelayCtrlFlag))
|
||||
if (trainType == train_type::et22 && mainCtrlPos > 1 && (RList[MainCtrlActualPos].Bn < RList[MainCtrlActualPos + 1].Bn || delayCtrlFlag))
|
||||
{
|
||||
// et22 z walem grupowym
|
||||
if (!DelayCtrlFlag) // najpierw przejscie
|
||||
if (!delayCtrlFlag) // najpierw przejscie
|
||||
{
|
||||
++MainCtrlActualPos;
|
||||
DelayCtrlFlag = true; // tryb przejscia
|
||||
delayCtrlFlag = true; // tryb przejscia
|
||||
OK = true;
|
||||
}
|
||||
else if (lineContactors.TimeSinceSwitch() > 4 * CtrlDelay) // przejscie
|
||||
{
|
||||
|
||||
DelayCtrlFlag = false;
|
||||
delayCtrlFlag = false;
|
||||
OK = true;
|
||||
}
|
||||
/*
|
||||
@@ -755,7 +755,7 @@ bool physics::Vehicle::AutoRelayMainDown()
|
||||
}
|
||||
else if (lineContactors.TimeSinceSwitch() > CtrlDownDelay)
|
||||
{
|
||||
if (TrainType != train_type::emu) // tutaj powinien być tryb sterowania wałem
|
||||
if (trainType != train_type::emu) // tutaj powinien być tryb sterowania wałem
|
||||
{
|
||||
--MainCtrlActualPos;
|
||||
OK = true;
|
||||
@@ -775,22 +775,22 @@ bool physics::Vehicle::AutoRelayLineContactorsStep(bool const motorconnectorsoff
|
||||
{
|
||||
bool OK = false;
|
||||
// ybARC - zalaczenie stycznikow liniowych
|
||||
if (false == motorconnectorsoff && MainCtrlActualPos == 0 && (TrainType == train_type::emu || HasCamshaft ? MainCtrlPowerPos() > 0 : MainCtrlPowerPos() == 1))
|
||||
if (false == motorconnectorsoff && MainCtrlActualPos == 0 && (trainType == train_type::emu || HasCamshaft ? MainCtrlPowerPos() > 0 : MainCtrlPowerPos() == 1))
|
||||
{
|
||||
|
||||
DelayCtrlFlag = true;
|
||||
if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay)
|
||||
delayCtrlFlag = true;
|
||||
if (lineContactors.TimeSinceSwitch() >= initialCtrlDelay)
|
||||
{
|
||||
lineContactors.Close();
|
||||
MainCtrlActualPos = 1;
|
||||
DelayCtrlFlag = false;
|
||||
delayCtrlFlag = false;
|
||||
SetFlag(soundFlag, sound::relay | sound::loud);
|
||||
OK = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DelayCtrlFlag = false;
|
||||
delayCtrlFlag = false;
|
||||
}
|
||||
|
||||
if (false == lineContactors.IsClosed() && (MainCtrlActualPos > 0 || ScndCtrlActualPos > 0))
|
||||
@@ -809,7 +809,7 @@ bool physics::Vehicle::CamshaftRunDown()
|
||||
if (CoupledCtrl)
|
||||
{
|
||||
|
||||
if (TrainType == train_type::emu)
|
||||
if (trainType == train_type::emu)
|
||||
{
|
||||
OK = CamshaftRunDownEMU();
|
||||
}
|
||||
@@ -871,7 +871,7 @@ bool physics::Vehicle::CamshaftRunDownEMU()
|
||||
// dojdz do konca
|
||||
++MainCtrlActualPos;
|
||||
}
|
||||
else if (ScndCtrlActualPos < ScndCtrlPosNo)
|
||||
else if (ScndCtrlActualPos < scndCtrlPosNo)
|
||||
{
|
||||
// potem boki
|
||||
++ScndCtrlActualPos;
|
||||
@@ -993,7 +993,7 @@ double stepped_uc_value(double const Current, double const Ramped, TUniversalCtr
|
||||
void physics::Vehicle::CheckEIMIC(double dt)
|
||||
{
|
||||
double offset = EIMCtrlAdditionalZeros ? 1.0 : 0.0;
|
||||
double multiplier = (EIMCtrlEmergency ? 1.0 : 0.0) + offset;
|
||||
double multiplier = (eimCtrlEmergency ? 1.0 : 0.0) + offset;
|
||||
// gdy SplitEDPneumaticBrake jest wlaczone, sterowanie ujemne (hamowanie ED) bierzemy
|
||||
// z osobnego nastawnika DynamicBrakeCtrl, a nie z hamulca pomocniczego (LocalBrake).
|
||||
// Dodatkowo zapotrzebowanie ED jest ograniczone przez strefe Vh0..Vh1: powyzej Vh1 - pelny ED,
|
||||
@@ -1037,7 +1037,7 @@ void physics::Vehicle::CheckEIMIC(double dt)
|
||||
void physics::Vehicle::EIMICFromController(double const brakeDemand, double const offset, double const multiplier)
|
||||
{
|
||||
eimic = brakeDemand > 0.01 ? -brakeDemand : eimicAnalog > 0.01 ? eimicAnalog : (double)mainCtrlPos / (double)MainCtrlPosNo;
|
||||
if (EIMCtrlAdditionalZeros || EIMCtrlEmergency)
|
||||
if (EIMCtrlAdditionalZeros || eimCtrlEmergency)
|
||||
{
|
||||
if (eimic > 0.001)
|
||||
eimic = std::max(0.002, eimic * (double)MainCtrlPosNo / ((double)MainCtrlPosNo - offset) - offset / ((double)MainCtrlPosNo - offset));
|
||||
@@ -1092,7 +1092,7 @@ void physics::Vehicle::EIMICFromFourPositions(double dt)
|
||||
// hamowanie nagle: pelne hamowanie od razu, przewod glowny oproznia UpdatePipePressure()
|
||||
eimic = -1.0;
|
||||
}
|
||||
else if (MainCtrlActualPos != mainCtrlPos || lineContactors.TimeSinceSwitch() > InitialCtrlDelay)
|
||||
else if (MainCtrlActualPos != mainCtrlPos || lineContactors.TimeSinceSwitch() > initialCtrlDelay)
|
||||
{
|
||||
double delta = MainCtrlActualPos == mainCtrlPos ? dt * CtrlDelay : 0.01;
|
||||
// the positions below are those of the controller without the emergency brake position
|
||||
@@ -1136,7 +1136,7 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak
|
||||
UniversalControllerTrainBrake();
|
||||
}
|
||||
|
||||
if (MainCtrlActualPos != mainCtrlPos || lineContactors.TimeSinceSwitch() > InitialCtrlDelay)
|
||||
if (MainCtrlActualPos != mainCtrlPos || lineContactors.TimeSinceSwitch() > initialCtrlDelay)
|
||||
{
|
||||
auto const &position{UniCtrlList[mainCtrlPos]};
|
||||
double ramped{eimic};
|
||||
@@ -1145,7 +1145,7 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak
|
||||
ramped += safe_clamp(position.SetCtrlVal - ramped, 0.0,
|
||||
MainCtrlActualPos == mainCtrlPos ? dt * position.SpeedUp : sign(position.SpeedUp) * 0.01); // dodawaj do X
|
||||
ramped = safe_clamp(ramped, position.MinCtrlVal, position.MaxCtrlVal);
|
||||
eimic = UniCtrlValStep > 0.0 ? stepped_uc_value(eimic, ramped, position, UniCtrlValStep, MainCtrlActualPos != mainCtrlPos, eimic_step_progress) : ramped;
|
||||
eimic = uniCtrlValStep > 0.0 ? stepped_uc_value(eimic, ramped, position, uniCtrlValStep, MainCtrlActualPos != mainCtrlPos, eimic_step_progress) : ramped;
|
||||
}
|
||||
if (MainCtrlActualPos == mainCtrlPos)
|
||||
lineContactors.AdvanceSwitchTimer(dt);
|
||||
@@ -1154,9 +1154,9 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak
|
||||
lineContactors.RestartSwitchTimer();
|
||||
MainCtrlActualPos = mainCtrlPos;
|
||||
}
|
||||
if (brakes.distributor->GetEDBCP() > 0.3 && eimic < 0 && !UniCtrlIntegratedLocalBrakeCtrl) // when braking with pneumatic brake
|
||||
if (brakes.distributor->GetEDBCP() > 0.3 && eimic < 0 && !uniCtrlIntegratedLocalBrakeCtrl) // when braking with pneumatic brake
|
||||
eimic = 0; // shut off retarder
|
||||
if (UniCtrlIntegratedBrakeCtrl == false && UniCtrlIntegratedLocalBrakeCtrl == false)
|
||||
if (UniCtrlIntegratedBrakeCtrl == false && uniCtrlIntegratedLocalBrakeCtrl == false)
|
||||
{
|
||||
// w trybie SplitEDPneumaticBrake hamowanie ED przychodzi z osobnego nastawnika,
|
||||
// LocalBrake operuje wylacznie pneumatycznym hamulcem lokomotywy
|
||||
@@ -1258,7 +1258,7 @@ void physics::Vehicle::CheckSpeedCtrl(double dt)
|
||||
if (EIMCtrlType >= 3 && UniCtrlList[mainCtrlPos].SpeedUp <= 0)
|
||||
{
|
||||
accfactor = 0.0;
|
||||
eimicSpeedCtrl = 0;
|
||||
eimicSpeedCtrlValue = 0;
|
||||
}
|
||||
}
|
||||
if (SpeedCtrlUnit.IsActive)
|
||||
@@ -1271,7 +1271,7 @@ void physics::Vehicle::CheckSpeedCtrl(double dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
eimicSpeedCtrl = 0;
|
||||
eimicSpeedCtrlValue = 0;
|
||||
eimicSpeedCtrlIntegral = 0;
|
||||
}
|
||||
SpeedCtrlUnit.Parking = Vel == 0.0 && eimic <= 0 && EngineType != TEngineType::ElectricInductionMotor;
|
||||
@@ -1279,10 +1279,10 @@ void physics::Vehicle::CheckSpeedCtrl(double dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Vmax < 250)
|
||||
eimicSpeedCtrl = std::clamp(0.5 * (SpeedCtrlValue - Vel), -1.0, 1.0);
|
||||
if (vmax < 250)
|
||||
eimicSpeedCtrlValue = std::clamp(0.5 * (SpeedCtrlValue - Vel), -1.0, 1.0);
|
||||
else
|
||||
eimicSpeedCtrl = std::clamp(0.5 * (SpeedCtrlValue * 2 - Vel), -1.0, 1.0);
|
||||
eimicSpeedCtrlValue = std::clamp(0.5 * (SpeedCtrlValue * 2 - Vel), -1.0, 1.0);
|
||||
}
|
||||
if ((SpeedCtrlAutoTurnOffFlag & 2) == 2 && brakes.distributor->GetEDBCP() > 0.25)
|
||||
{
|
||||
@@ -1292,7 +1292,7 @@ void physics::Vehicle::CheckSpeedCtrl(double dt)
|
||||
}
|
||||
else
|
||||
{
|
||||
eimicSpeedCtrl = 1;
|
||||
eimicSpeedCtrlValue = 1;
|
||||
eimicSpeedCtrlIntegral = 0;
|
||||
SpeedCtrlUnit.Parking = false;
|
||||
SendCtrlToNext(VehicleCommand::speedControlParking, SpeedCtrlUnit.Parking, CabActive);
|
||||
@@ -1311,7 +1311,7 @@ void physics::Vehicle::SpeedCtrlRegulator(double dt, double const accfactor)
|
||||
bool retarder_not_work = EngineType != TEngineType::DieselEngine || Vel < SpeedCtrlUnit.BrakeInterventionVel;
|
||||
if (eSCP < -1.0)
|
||||
{
|
||||
SpeedCtrlUnit.BrakeInterventionBraking = eSCP < -1.1 && retarder_not_work && eimicSpeedCtrl < -0.99 * SpeedCtrlUnit.DesiredPower;
|
||||
SpeedCtrlUnit.BrakeInterventionBraking = eSCP < -1.1 && retarder_not_work && eimicSpeedCtrlValue < -0.99 * SpeedCtrlUnit.DesiredPower;
|
||||
eSCP = -1.0;
|
||||
}
|
||||
SpeedCtrlUnit.BrakeInterventionUnbraking = eSCP > 0.0 || Vel == 0.0;
|
||||
@@ -1327,14 +1327,14 @@ void physics::Vehicle::SpeedCtrlRegulator(double dt, double const accfactor)
|
||||
eimicSpeedCtrlIntegral = 0;
|
||||
}
|
||||
auto const DesiredeimicSpeedCtrl{safe_clamp(eimicSpeedCtrlIntegral + eSCP, -SpeedCtrlUnit.DesiredPower, accfactor)};
|
||||
eimicSpeedCtrl = safe_clamp(DesiredeimicSpeedCtrl, eimicSpeedCtrl - SpeedCtrlUnit.PowerDownSpeed * dt, eimicSpeedCtrl + SpeedCtrlUnit.PowerUpSpeed * dt);
|
||||
eimicSpeedCtrlValue = safe_clamp(DesiredeimicSpeedCtrl, eimicSpeedCtrlValue - SpeedCtrlUnit.PowerDownSpeed * dt, eimicSpeedCtrlValue + SpeedCtrlUnit.PowerUpSpeed * dt);
|
||||
if (Vel < SpeedCtrlUnit.FullPowerVelocity)
|
||||
{
|
||||
eimicSpeedCtrl = std::min(eimicSpeedCtrl, SpeedCtrlUnit.InitialPower);
|
||||
eimicSpeedCtrlValue = std::min(eimicSpeedCtrlValue, SpeedCtrlUnit.InitialPower);
|
||||
}
|
||||
if (Vel < SpeedCtrlUnit.StartVelocity && mainCtrlPos < MainCtrlPosNo)
|
||||
{
|
||||
eimicSpeedCtrl = 0;
|
||||
eimicSpeedCtrlValue = 0;
|
||||
eimic = 0;
|
||||
}
|
||||
}
|
||||
@@ -1342,7 +1342,7 @@ void physics::Vehicle::SpeedCtrlRegulator(double dt, double const accfactor)
|
||||
bool physics::Vehicle::IsSpeedCtrlSeparate() const
|
||||
{
|
||||
// no secondary controller, or one of these engines', which shunts the field of the traction motors (eu07/maszyna#69)
|
||||
return SpeedCtrl && (ScndCtrlPosNo == 0 || EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric);
|
||||
return speedCtrl && (scndCtrlPosNo == 0 || EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric);
|
||||
}
|
||||
|
||||
bool physics::Vehicle::IsSpeedCtrlEngaged() const
|
||||
@@ -1379,7 +1379,7 @@ bool physics::Vehicle::SpeedCtrlSwitch(bool const State)
|
||||
|
||||
void physics::Vehicle::SpeedCtrlButton(int button)
|
||||
{
|
||||
if (SpeedCtrl && IsSpeedCtrlEngaged())
|
||||
if (speedCtrl && IsSpeedCtrlEngaged())
|
||||
{
|
||||
SpeedCtrlValue = SpeedCtrlButtons[button];
|
||||
}
|
||||
@@ -1387,7 +1387,7 @@ void physics::Vehicle::SpeedCtrlButton(int button)
|
||||
|
||||
void physics::Vehicle::SpeedCtrlInc()
|
||||
{
|
||||
if (SpeedCtrl && IsSpeedCtrlEngaged())
|
||||
if (speedCtrl && IsSpeedCtrlEngaged())
|
||||
{
|
||||
double x = floor(SpeedCtrlValue / SpeedCtrlUnit.VelocityStep) + 1.0;
|
||||
SpeedCtrlValue = std::min(x * SpeedCtrlUnit.VelocityStep, SpeedCtrlUnit.MaxVelocity);
|
||||
@@ -1396,7 +1396,7 @@ void physics::Vehicle::SpeedCtrlInc()
|
||||
|
||||
void physics::Vehicle::SpeedCtrlDec()
|
||||
{
|
||||
if (SpeedCtrl && IsSpeedCtrlEngaged())
|
||||
if (speedCtrl && IsSpeedCtrlEngaged())
|
||||
{
|
||||
double x = ceil(SpeedCtrlValue / SpeedCtrlUnit.VelocityStep) - 1.0;
|
||||
SpeedCtrlValue = std::max(x * SpeedCtrlUnit.VelocityStep, SpeedCtrlUnit.MinVelocity);
|
||||
@@ -1405,7 +1405,7 @@ void physics::Vehicle::SpeedCtrlDec()
|
||||
|
||||
bool physics::Vehicle::SpeedCtrlPowerInc()
|
||||
{
|
||||
if (!(SpeedCtrl && IsSpeedCtrlEngaged()))
|
||||
if (!(speedCtrl && IsSpeedCtrlEngaged()))
|
||||
return false;
|
||||
|
||||
if (SpeedCtrlUnit.DesiredPower == SpeedCtrlUnit.MaxPower)
|
||||
@@ -1417,7 +1417,7 @@ bool physics::Vehicle::SpeedCtrlPowerInc()
|
||||
|
||||
bool physics::Vehicle::SpeedCtrlPowerDec()
|
||||
{
|
||||
if (!(SpeedCtrl && IsSpeedCtrlEngaged()))
|
||||
if (!(speedCtrl && IsSpeedCtrlEngaged()))
|
||||
return false;
|
||||
|
||||
if (SpeedCtrlUnit.DesiredPower == SpeedCtrlUnit.MinPower)
|
||||
|
||||
Reference in New Issue
Block a user