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:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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.);
|
||||
|
||||
@@ -71,7 +71,7 @@ void physics::ConsistBrakeBlending::SetControl(Step &state, Vehicle &Lead, Input
|
||||
Lead.CheckSpeedCtrl(dt1);
|
||||
|
||||
state.eimic = std::min(Lead.eimic, Lead.eimicSpeedCtrl());
|
||||
Lead.eimic_real = state.eimic;
|
||||
Lead.SetEimicReal(state.eimic);
|
||||
// Elf: full braking at once in the lowest position, and in the emergency brake position below it
|
||||
if (Lead.EIMCtrlType == 2 && Lead.MainCtrlPos() <= Lead.EIMCtrlEmergencyPositions())
|
||||
state.eimic = -1.0;
|
||||
|
||||
+4
-1
@@ -1021,7 +1021,9 @@ class Vehicle
|
||||
double eimic = 0; /*aktualna pozycja zintegrowanego sterowania jazda i hamowaniem*/
|
||||
double const &EimicAnalog() const { return eimicAnalog; } /*pozycja zadajnika analogowa*/
|
||||
void SetEimicAnalog(double const Value) { eimicAnalog = Value; }
|
||||
double eimic_real = 0; /*faktycznie uzywana pozycja zintegrowanego sterowania jazda i hamowaniem*/
|
||||
// the demand of the integrated controller the vehicle goes by, the speed control counted /*faktycznie uzywana pozycja zintegrowanego sterowania jazda i hamowaniem*/
|
||||
double const &EimicReal() const { return eimicReal; }
|
||||
void SetEimicReal(double const Value) { eimicReal = Value; }
|
||||
double eim_localbrake = 0; /*nastawa hamowania dodatkowego pneumatycznego lokomotywy*/
|
||||
int EIMCtrlType = 0; /*rodzaj wariantu zadajnika jazdy*/
|
||||
bool const &SpeedCtrlTypeTime() const { return speedCtrlTypeTime; } /*czy tempomat sterowany czasowo*/
|
||||
@@ -1788,6 +1790,7 @@ class Vehicle
|
||||
|
||||
private:
|
||||
// the state and the definition no code outside the vehicle uses
|
||||
double eimicReal = 0;
|
||||
std::string chkPath;
|
||||
TPowerParameters SystemPowerSource; /*zrodlo mocy dla systemow sterowania/przetwornic/sprezarek*/
|
||||
TPowerParameters AlterHeatPowerSource; /*alternatywne zrodlo mocy dla ogrzewania*/
|
||||
|
||||
Reference in New Issue
Block a user