18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 22:25:23 +01:00

refactor(physics): the demand of the integrated controller is private to the vehicle

eimic_real, the demand of the integrated controller the vehicle goes by with
the speed control counted, which TDynamicObject and the consist braking set
for the vehicle that leads, is private: EimicReal() and SetEimicReal(). The
field of the same name of drivingaid::input stays as it is.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 13:39:07 +01:00
parent f0978c36c7
commit 23b695752a
23 changed files with 76 additions and 73 deletions
+1 -1
View File
@@ -243,7 +243,7 @@ bool physics::Vehicle::EIMDirectionChangeAllow(void) const
bool OK = false;
/*
// NOTE: disabled while eimic variables aren't immediately synced with master controller changes inside ai module
OK = (EngineType != TEngineType::ElectricInductionMotor || ((eimic <= 0) && (eimic_real <= 0) && (Vel < 0.1)));
OK = (EngineType != TEngineType::ElectricInductionMotor || ((eimic <= 0) && (eimicReal <= 0) && (Vel < 0.1)));
*/
OK = mainCtrlPos <= mainCtrlMaxDirChangePos;
return OK;
+1 -1
View File
@@ -172,7 +172,7 @@ bool physics::Vehicle::RunControllerCommand(VehicleCommand const Command, double
end */
else if (Command == VehicleCommand::integratedController) // ElectricInductionMotor Integrated Control - propulsion and brakes in relative values
{
eimic_real = CValue1;
eimicReal = CValue1;
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else
+14 -14
View File
@@ -337,7 +337,7 @@ double physics::Vehicle::DieselElectricTargetRevolutions()
double tmp;
if (EIMCtrlType > 0) // sterowanie cyfrowe
tmp = (DElist[0].RPM + (DElist[MainCtrlPosNo].RPM - DElist[0].RPM) * std::max(0.0, eimic_real)) / 60.0;
tmp = (DElist[0].RPM + (DElist[MainCtrlPosNo].RPM - DElist[0].RPM) * std::max(0.0, eimicReal)) / 60.0;
else
tmp = DElist[protection.PressureSwitchTripped() ? MainCtrlNoPowerPos() : mainCtrlPos].RPM / 60.0;
@@ -467,7 +467,7 @@ void physics::Vehicle::DieselElectricShuntForce(double const tmpV, double &tmp)
// voltage and current limits too. returns the power the generator gives
double physics::Vehicle::DieselElectricDigitalForce(double const tmpV, double &tempUmax, double &tempImax)
{
auto eimic_positive = std::max(0.0, eimic_real);
auto eimic_positive = std::max(0.0, eimicReal);
auto const rpmratio{EngineRPMRatio()};
tempImax = DElist[MainCtrlPosNo].Imax * eimic_positive;
tempUmax = DElist[MainCtrlPosNo].Umax * std::min(eimic_positive, rpmratio);
@@ -527,7 +527,7 @@ void physics::Vehicle::DieselElectricGenerator(double const tmp, double const te
}
else
{
auto tempMCP = EIMCtrlType > 0 ? 1 + 99 * std::max(1.0, eimic_real) : mainCtrlPos;
auto tempMCP = EIMCtrlType > 0 ? 1 + 99 * std::max(1.0, eimicReal) : mainCtrlPos;
auto tempMCPN = EIMCtrlType > 0 ? 100 : MainCtrlPosNo;
// charakterystyka pradnicy obcowzbudnej (elipsa) - twierdzenie Pitagorasa
EngineVoltage = std::sqrt(std::abs(square(tempUmax) - square(tempUmax * Im / tempImax))) * (tempMCP - 1) + (1.0 - Im / tempImax) * tempUmax * (tempMCPN - tempMCP);
@@ -570,7 +570,7 @@ double physics::Vehicle::dieselelectric_dynamic_brake_demand() const
switch (DEDynamicBrake.source)
{
case diesel_electric_dynamic_brake::control::controller:
return std::clamp(-eimic_real, 0.0, 1.0);
return std::clamp(-eimicReal, 0.0, 1.0);
case diesel_electric_dynamic_brake::control::lever:
return DynamicBrakeRatio();
default:
@@ -608,7 +608,7 @@ double physics::Vehicle::dieselelectric_dynamic_brake_limit() const
void physics::Vehicle::update_dieselelectric_dynamic_brake(double const dt)
{
auto &brake{DEDynamicBrake};
auto const nopower{brake.source == diesel_electric_dynamic_brake::control::controller ? eimic_real <= 0.0 : IsMainCtrlNoPowerPos()};
auto const nopower{brake.source == diesel_electric_dynamic_brake::control::controller ? eimicReal <= 0.0 : IsMainCtrlNoPowerPos()};
if (lineBreaker.IsClosed() && DirActive != 0 && false == FuseFlag && false == slippingWheels && nopower)
{
brake.level += std::clamp(dieselelectric_dynamic_brake_demand() - brake.level, -brake.rate * dt, brake.rate * dt);
@@ -700,10 +700,10 @@ bool physics::Vehicle::dizel_AutoGearCheck(void)
auto OK{false};
auto const VelUp{(motor_param(ScndCtrlActualPos).mfi0 != 0.0 ?
motor_param(ScndCtrlActualPos).mfi0 + (motor_param(ScndCtrlActualPos).mfi - motor_param(ScndCtrlActualPos).mfi0) * std::max(0.0, eimic_real) :
motor_param(ScndCtrlActualPos).mfi0 + (motor_param(ScndCtrlActualPos).mfi - motor_param(ScndCtrlActualPos).mfi0) * std::max(0.0, eimicReal) :
motor_param(ScndCtrlActualPos).mfi)};
auto const VelDown{(motor_param(ScndCtrlActualPos).fi0 != 0.0 && eimic_real <= 0.0 ? motor_param(ScndCtrlActualPos).fi0 : motor_param(ScndCtrlActualPos).fi)};
auto const VelDown{(motor_param(ScndCtrlActualPos).fi0 != 0.0 && eimicReal <= 0.0 ? motor_param(ScndCtrlActualPos).fi0 : motor_param(ScndCtrlActualPos).fi)};
if (motor_param(ScndCtrlActualPos).AutoSwitch && lineBreaker.IsClosed())
{
@@ -832,7 +832,7 @@ void physics::Vehicle::dizel_ClutchByIntegratedController()
{
if (diesel.automaticGearShift == 0)
{
if ((torqueConverter.present && torqueConverter.fill > 0.01) || eimic_real > 0.005)
if ((torqueConverter.present && torqueConverter.fill > 0.01) || eimicReal > 0.005)
dizel_EngageSwitch(1.0);
else if (Vel > retarder.engageVelocity && retarder.present && retarder.fill > 0.01)
dizel_EngageSwitch(0.5);
@@ -984,10 +984,10 @@ double physics::Vehicle::dizel_fillcheck(int mcp, double dt)
double physics::Vehicle::dizel_DigitalFill(double dt)
{
double realfill;
realfill = std::max(0.0, std::min(eimic_real, 1 - motor_param(ScndCtrlActualPos).Isat));
if (eimic_real > 0.005 && !torqueConverter.lockedUp)
realfill = std::max(0.0, std::min(eimicReal, 1 - motor_param(ScndCtrlActualPos).Isat));
if (eimicReal > 0.005 && !torqueConverter.lockedUp)
{
diesel.governorMinRevolutions = std::min(diesel.governorMinRevolutions + 2.5 * dt, diesel.hydraulicMinRevolutions + eimic_real * diesel.hydraulicMinRevolutionsFactor);
diesel.governorMinRevolutions = std::min(diesel.governorMinRevolutions + 2.5 * dt, diesel.hydraulicMinRevolutions + eimicReal * diesel.hydraulicMinRevolutionsFactor);
}
else
{
@@ -1012,7 +1012,7 @@ double physics::Vehicle::dizel_GovernorFill(int const mcp, double realfill) cons
{
auto nreg{0.0};
if (EIMCtrlType > 0)
nreg = eimic_real > 0.005 ? diesel.governorMaxRevolutions : diesel.minRevolutions;
nreg = eimicReal > 0.005 ? diesel.governorMaxRevolutions : diesel.minRevolutions;
else
nreg = dizel_GovernorRevolutions(mcp, realfill);
if (enrot > nreg) // nad predkoscia regulatora zeruj dawke
@@ -1202,7 +1202,7 @@ void physics::Vehicle::hydro_TCFillCheck(double dt)
if (torqueConverter.present) // jesli przetwornik momentu
{
// napelnianie przetwornika
bool IsPower = EIMCtrlType > 0 ? eimic_real > 0.005 : MainCtrlPowerPos() > 0;
bool IsPower = EIMCtrlType > 0 ? eimicReal > 0.005 : MainCtrlPowerPos() > 0;
if (IsPower && lineBreaker.IsClosed() && enrot > diesel.minRevolutions * 0.9)
torqueConverter.fill += torqueConverter.fillRateIncrease * dt;
// oproznianie przetwornika
@@ -1266,7 +1266,7 @@ void physics::Vehicle::hydro_TCTorque()
double physics::Vehicle::dizel_MomentumRetarder(double n, double dt)
{
double RetarderRequest = lineBreaker.IsClosed() ? std::max(0.0, -eimic_real) : 0;
double RetarderRequest = lineBreaker.IsClosed() ? std::max(0.0, -eimicReal) : 0;
if (retarder.withIndividual)
RetarderRequest = LocalBrakeRatio();
if (Vel < retarder.minVelocity)
+1 -1
View File
@@ -890,7 +890,7 @@ void physics::Vehicle::UpdateLocalBrakeValve(double dt)
double lbpa = brakes.config.independentTraxx ? eim_localbrake : brakes.IndependentPosition();
if (EIMCtrlType > 0 && uniCtrlIntegratedLocalBrakeCtrl)
{
lbpa = std::max(0.0, -eimic_real);
lbpa = std::max(0.0, -eimicReal);
}
if (SpeedCtrlUnit.Parking)
{
+1 -1
View File
@@ -1152,7 +1152,7 @@ void physics::Vehicle::InductionMotorBrakeBlending(double const ActiveInverters,
}
else
{
PosRatio = std::max(eimic_real, 0.);
PosRatio = std::max(eimicReal, 0.);
inductionMotor.state.forceDemand = PosRatio;
if (Flat && inductionMotor.traction.startingForce * inductionMotor.state.fullForce > 0)
PosRatio = std::min(PosRatio * inductionMotor.traction.startingForce / inductionMotor.state.fullForce, 1.);