mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 02:27:06 +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:
@@ -594,7 +594,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
|
||||
Action,
|
||||
[this](float const /*Parameter*/) {
|
||||
return AccDesired <= EU07_AI_NOACCELERATION || (false == Ready && false == occupied->ShuntMode) || AccDesired - AbsAccS <= 0.05 ||
|
||||
(occupied->EIMCtrlType > 0 ? mvControlling->eimic_real >= 1.0 : mvControlling->IsScndCtrlMaxPowerPos() && mvControlling->IsMainCtrlMaxPowerPos()); } );
|
||||
(occupied->EIMCtrlType > 0 ? mvControlling->EimicReal() >= 1.0 : mvControlling->IsScndCtrlMaxPowerPos() && mvControlling->IsMainCtrlMaxPowerPos()); } );
|
||||
break;
|
||||
}
|
||||
case driver_hint::bufferscompress: {
|
||||
|
||||
@@ -1255,7 +1255,7 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) const {
|
||||
"-" ) + ")"
|
||||
+ "\n desired diesel percentage: " + std::to_string(mechanik.DizelPercentage)
|
||||
+ "/" + std::to_string(mechanik.DizelPercentage_Speed)
|
||||
+ "/" + to_string(100.4*mechanik.mvControlling->eimic_real, 0);
|
||||
+ "/" + to_string(100.4*mechanik.mvControlling->EimicReal(), 0);
|
||||
|
||||
Output.emplace_back( textline, Global.UITextColor );
|
||||
|
||||
|
||||
@@ -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*/
|
||||
|
||||
@@ -120,7 +120,7 @@ TEST_CASE("6Dg: the shipped definition sets the controller's power demand in ste
|
||||
CAPTURE(i);
|
||||
CHECK(loco->eimic == doctest::Approx(std::min(top, before + 0.05)));
|
||||
CHECK(loco->eimic <= top + 1e-9);
|
||||
CHECK(loco->eimic_real == doctest::Approx(loco->eimic)); // the demand reaching the drive
|
||||
CHECK(loco->EimicReal() == doctest::Approx(loco->eimic)); // the demand reaching the drive
|
||||
changed += std::abs(loco->eimic - before) > 1e-9 ? 1 : 0;
|
||||
}
|
||||
CHECK(changed == steps);
|
||||
@@ -178,9 +178,9 @@ TEST_CASE("6Dg: the diesel-electric drive follows the stepped demand") {
|
||||
loco.step(line);
|
||||
}
|
||||
REQUIRE(loco->eimic == doctest::Approx(0.05 * taps));
|
||||
REQUIRE(loco->eimic_real == doctest::Approx(0.05 * taps));
|
||||
REQUIRE(loco->EimicReal() == doctest::Approx(0.05 * taps));
|
||||
test::drive(test::driving(loco), line, 10.0);
|
||||
readings.emplace_back(loco->eimic_real, loco->enrot, std::abs(loco->Ft()), loco->EnginePower, std::abs(loco.speed()));
|
||||
readings.emplace_back(loco->EimicReal(), loco->enrot, std::abs(loco->Ft()), loco->EnginePower, std::abs(loco.speed()));
|
||||
}
|
||||
// at 0.25, 0.5, 0.75 and 1: the engine at 897, 1198, 1499 and (still running up to) 1800 rpm as the WWList table
|
||||
// gives, about 28, 37, 48 and 59 kN, 87, 261, 445 and 663 kW, 14, 24, 28 and 30 km/h
|
||||
|
||||
@@ -29,7 +29,7 @@ std::vector<test::channel> state() {
|
||||
{"MainCtrlPos", [](auto const &M) { return M.MainCtrlPos(); }},
|
||||
{"ScndCtrlPos", [](auto const &M) { return M.ScndCtrlPos(); }},
|
||||
{"LastRelayTime", [](auto const &M) { return M.lineContactors.TimeSinceSwitch(); }},
|
||||
{"eimic_real", [](auto const &M) { return M.eimic_real; }},
|
||||
{"eimic_real", [](auto const &M) { return M.EimicReal(); }},
|
||||
{"TUHEX_StageActual", [](auto const &M) { return M.TUHEX_StageActual; }},
|
||||
{"TUHEX_Active", [](auto const &M) { return flag(M.TUHEX_Active); }},
|
||||
{"DynamicBrakeEMUStatus", [](auto const &M) { return flag(M.brakes.electrodynamic.emuWorking); }},
|
||||
|
||||
@@ -286,13 +286,13 @@ TEST_CASE("crew: the power an integrated handle asked for goes when the driver l
|
||||
impuls->CabActivisation();
|
||||
impuls->SetMainCtrlPos(impuls->MainCtrlPosNo);
|
||||
impuls->eimic = 0.8;
|
||||
impuls->eimic_real = 0.8;
|
||||
impuls->SetEimicReal(0.8);
|
||||
|
||||
crew::secure(impuls.physics(), impuls.physics());
|
||||
|
||||
CHECK(impuls->MainCtrlPos() == impuls->MainCtrlNoPowerPos());
|
||||
CHECK(impuls->eimic == 0.0);
|
||||
CHECK(impuls->eimic_real == 0.0);
|
||||
CHECK(impuls->EimicReal() == 0.0);
|
||||
CHECK(impuls->brakes.HandlePosition() == static_cast<int>(impuls->brakes.driverValve->GetPos(bh_EB)));
|
||||
CHECK(impuls->CabOccupied() == 0);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ TEST_CASE("diesel: the 214M railbus's torque converter, gears and retarder") {
|
||||
scenario.get_going();
|
||||
scenario.full_power(60.0);
|
||||
CHECK(railbus.MainCtrlPos() == 5);
|
||||
CHECK(railbus.eimic_real == doctest::Approx(1.0));
|
||||
CHECK(railbus.EimicReal() == doctest::Approx(1.0));
|
||||
CHECK(railbus.torqueConverter.lockedUp);
|
||||
CHECK(railbus.ScndCtrlActualPos == railbus.ScndCtrlPosNo());
|
||||
struct position {
|
||||
@@ -108,7 +108,7 @@ TEST_CASE("diesel: the 214M railbus's torque converter, gears and retarder") {
|
||||
scenario.act(std::format("position {}", number));
|
||||
railbus.DecMainCtrl(1);
|
||||
scenario.wait(8.0);
|
||||
CHECK(railbus.eimic_real == doctest::Approx(eimic));
|
||||
CHECK(railbus.EimicReal() == doctest::Approx(eimic));
|
||||
CHECK((railbus.retarder.fill > 0.99) == retarder);
|
||||
CHECK((railbus.retarder.torque > 1000.0) == retarder);
|
||||
CHECK((railbus.brakes.cylinderPressure > 2.0) == air);
|
||||
@@ -159,7 +159,7 @@ TEST_CASE("diesel: the 214M railbus's speed control, up to the speed of a button
|
||||
railbus.SpeedCtrlButton(2);
|
||||
scenario.wait(5.0);
|
||||
// the retarder does it at this speed, the air isn't needed
|
||||
CHECK(railbus.eimic_real == doctest::Approx(-1.0));
|
||||
CHECK(railbus.EimicReal() == doctest::Approx(-1.0));
|
||||
CHECK(railbus.retarder.fill == doctest::Approx(1.0));
|
||||
CHECK(railbus.brakes.cylinderPressure < 0.1);
|
||||
CHECK_FALSE(railbus.SpeedCtrlUnit.BrakeInterventionBraking);
|
||||
|
||||
@@ -33,9 +33,9 @@ drivingaid::readout read(vehicle &Vehicle, drivingaid::cab_controls const &Cab)
|
||||
// what the panel showed before: the throttle and brakes numbers, and the local brake always
|
||||
drivingaid::readout before(physics::Vehicle const &Physics) {
|
||||
drivingaid::readout result;
|
||||
result.throttle_first = Physics.EIMCtrlType > 0 ? std::max(0, static_cast<int>(100.4 * Physics.eimic_real)) : Physics.MainCtrlPos();
|
||||
result.throttle_first = Physics.EIMCtrlType > 0 ? std::max(0, static_cast<int>(100.4 * Physics.EimicReal())) : Physics.MainCtrlPos();
|
||||
result.throttle_second = Physics.EIMCtrlType > 0 ? Physics.MainCtrlPos() : Physics.ScndCtrlPos();
|
||||
result.brake_first = Physics.UniCtrlIntegratedBrakeCtrl ? std::max(0.0, -100.0 * Physics.eimic_real) : Physics.brakes.HandlePositionSmooth();
|
||||
result.brake_first = Physics.UniCtrlIntegratedBrakeCtrl ? std::max(0.0, -100.0 * Physics.EimicReal()) : Physics.brakes.HandlePositionSmooth();
|
||||
result.local_brake = Physics.brakes.IndependentPosition() * LocalBrakePosNo;
|
||||
return result;
|
||||
}
|
||||
@@ -64,7 +64,7 @@ TEST_CASE("driving aid: the Vectron's ED lever shows as a negative throttle step
|
||||
REQUIRE(vectron->Vel > 15.0); // above Vh1, where the ED brake has its full demand
|
||||
auto const braking{read(vectron, vectron_cab)};
|
||||
CHECK(braking.throttle_first == -6);
|
||||
REQUIRE(vectron->eimic_real == doctest::Approx(-0.4));
|
||||
REQUIRE(vectron->EimicReal() == doctest::Approx(-0.4));
|
||||
REQUIRE(braking.ed_percent.has_value());
|
||||
CHECK(*braking.ed_percent == 40);
|
||||
// the train brake handle and the local brake, as before
|
||||
@@ -85,10 +85,10 @@ TEST_CASE("driving aid: the Traxx's ED braking from its master controller") {
|
||||
// B+: the braking demand ramps towards full
|
||||
traxx->SetMainCtrlPos(0);
|
||||
traxx.run(3.0, line);
|
||||
REQUIRE(traxx->eimic_real < -0.2);
|
||||
REQUIRE(traxx->EimicReal() < -0.2);
|
||||
auto const braking{read(traxx, lever_cab)};
|
||||
REQUIRE(braking.ed_percent.has_value());
|
||||
CHECK(*braking.ed_percent == std::lround(-100.0 * traxx->eimic_real));
|
||||
CHECK(*braking.ed_percent == std::lround(-100.0 * traxx->EimicReal()));
|
||||
// the drive demand stays at zero while braking, with the controller position next to it, as before
|
||||
CHECK(braking.throttle_first == 0);
|
||||
CHECK(braking.throttle_second == 0);
|
||||
@@ -108,10 +108,10 @@ TEST_CASE("driving aid: the Elf leaves out the local brake it has no control of,
|
||||
// the controller at its lowest braking position: the demand ramps towards full braking
|
||||
elf->SetMainCtrlPos(0);
|
||||
elf.run(2.0, line);
|
||||
REQUIRE(elf->eimic_real < -0.1);
|
||||
REQUIRE(elf->EimicReal() < -0.1);
|
||||
auto const braking{read(elf, elf_cab)};
|
||||
REQUIRE(braking.ed_percent.has_value());
|
||||
CHECK(*braking.ed_percent == std::lround(-100.0 * elf->eimic_real));
|
||||
CHECK(*braking.ed_percent == std::lround(-100.0 * elf->EimicReal()));
|
||||
CHECK(braking.throttle_first == 0);
|
||||
CHECK(braking.throttle_second == 0);
|
||||
CHECK_FALSE(braking.show_local_brake);
|
||||
@@ -163,7 +163,7 @@ TEST_CASE("driving aid: every real vehicle with a local brake control shows the
|
||||
for (auto const &[mainctrl, localbrake, eimic] : {std::tuple{0, 0.0, 0.0}, std::tuple{1, 0.4, -0.25}, std::tuple{1, 0.0, 0.6}}) {
|
||||
real->SetMainCtrlPos(std::min(mainctrl, real->MainCtrlPosNo));
|
||||
real->brakes.SetIndependentPosition(localbrake);
|
||||
real->eimic_real = eimic;
|
||||
real->SetEimicReal(eimic);
|
||||
auto const now{read(real, lever_cab)};
|
||||
auto const was{before(real.physics())};
|
||||
CHECK(now.throttle_first == was.throttle_first);
|
||||
|
||||
@@ -23,7 +23,7 @@ std::vector<test::channel> dynamic_brake() {
|
||||
{"EDLevel", [](auto const &M) { return M.DEDynamicBrake.level; }},
|
||||
{"EDForce", [](auto const &M) { return M.DEDynamicBrake.force; }},
|
||||
{"DynamicBrakeFlag", [](auto const &M) { return M.brakes.electrodynamic.on ? 1.0 : 0.0; }},
|
||||
{"eimic_real", [](auto const &M) { return M.eimic_real; }},
|
||||
{"eimic_real", [](auto const &M) { return M.EimicReal(); }},
|
||||
{"DynamicBrakeCtrlPos", [](auto const &M) { return M.brakes.electrodynamic.controllerPosition; }},
|
||||
};
|
||||
}
|
||||
@@ -84,7 +84,7 @@ TEST_CASE("diesel-electric dynamic brake: none without its definition") {
|
||||
scenario.act("braking range");
|
||||
controller_to(locomotive, 0);
|
||||
scenario.wait(15.0);
|
||||
CHECK(locomotive.eimic_real == doctest::Approx(-1.0));
|
||||
CHECK(locomotive.EimicReal() == doctest::Approx(-1.0));
|
||||
CHECK(locomotive.Ft() == doctest::Approx(0.0));
|
||||
CHECK_FALSE(locomotive.brakes.electrodynamic.on);
|
||||
// coasting: braking with the power of the resistors above, it would lose more than 30 km/h
|
||||
@@ -110,7 +110,7 @@ TEST_CASE("diesel-electric dynamic brake: the BR285's controller") {
|
||||
scenario.act("EB+");
|
||||
controller_to(locomotive, 0);
|
||||
scenario.wait(10.0);
|
||||
CHECK(locomotive.eimic_real == doctest::Approx(-1.0));
|
||||
CHECK(locomotive.EimicReal() == doctest::Approx(-1.0));
|
||||
CHECK(locomotive.DEDynamicBrake.level == doctest::Approx(1.0));
|
||||
CHECK(locomotive.brakes.electrodynamic.on);
|
||||
REQUIRE(locomotive.Vel > 6.0);
|
||||
@@ -121,16 +121,16 @@ TEST_CASE("diesel-electric dynamic brake: the BR285's controller") {
|
||||
|
||||
scenario.act("EB- to half");
|
||||
controller_to(locomotive, 2);
|
||||
for (int i = 0; i < 20 && locomotive.eimic_real < -0.5; ++i) {
|
||||
for (int i = 0; i < 20 && locomotive.EimicReal() < -0.5; ++i) {
|
||||
scenario.wait(1.0);
|
||||
}
|
||||
scenario.act("EB");
|
||||
controller_to(locomotive, 1);
|
||||
scenario.wait(2.0);
|
||||
auto const held{locomotive.eimic_real};
|
||||
auto const held{locomotive.EimicReal()};
|
||||
CHECK(held == doctest::Approx(-0.5).epsilon(0.35));
|
||||
scenario.wait(5.0);
|
||||
CHECK(locomotive.eimic_real == doctest::Approx(held));
|
||||
CHECK(locomotive.EimicReal() == doctest::Approx(held));
|
||||
CHECK(locomotive.DEDynamicBrake.level == doctest::Approx(-held).epsilon(0.01));
|
||||
|
||||
scenario.act("EB+ to the stop");
|
||||
|
||||
@@ -281,7 +281,7 @@ template <typename Action> double release_time(elf &Unit, double Seconds, Action
|
||||
auto const time{i * step_time};
|
||||
Act(time);
|
||||
Unit.unit.step(Unit.line);
|
||||
if (cab.UpdateStopBrakeRelease(cab.eimic_real, step_time)) {
|
||||
if (cab.UpdateStopBrakeRelease(cab.EimicReal(), step_time)) {
|
||||
return time;
|
||||
}
|
||||
}
|
||||
@@ -339,14 +339,14 @@ template <typename Action> start start_off(elf &Unit, double Seconds, Action Act
|
||||
auto const time{i * step_time};
|
||||
Act(time);
|
||||
Unit.unit.step(Unit.line);
|
||||
auto const released{cab.UpdateStopBrakeRelease(cab.eimic_real, step_time)};
|
||||
auto const released{cab.UpdateStopBrakeRelease(cab.EimicReal(), step_time)};
|
||||
if (cab.Vel > 1.0) {
|
||||
shuntmode = false;
|
||||
}
|
||||
hold(Unit, shuntmode && false == released);
|
||||
if (released && result.release < 0.0) {
|
||||
result.release = time;
|
||||
result.demand = cab.eimic_real;
|
||||
result.demand = cab.EimicReal();
|
||||
}
|
||||
if (cab.Vel > 0.5 && result.moving < 0.0) {
|
||||
result.moving = time;
|
||||
@@ -397,7 +397,7 @@ TEST_CASE("elf holding brake: the controller held at power") {
|
||||
REQUIRE(unit.ready);
|
||||
auto const release{release_time(unit, 5.0, [&unit](double) { unit.set_controller(4); })};
|
||||
CHECK(release == doctest::Approx(0.0));
|
||||
CHECK(unit.cab().eimic_real == doctest::Approx(0.01));
|
||||
CHECK(unit.cab().EimicReal() == doctest::Approx(0.01));
|
||||
}
|
||||
SUBCASE("with SBDReleaseDelay=1.0 it lets go as the demand starts to ramp up, about 1 s on") {
|
||||
elf unit{{data::plain}, elf_delay};
|
||||
@@ -405,10 +405,10 @@ TEST_CASE("elf holding brake: the controller held at power") {
|
||||
auto &cab{unit.cab()};
|
||||
auto const release{release_time(unit, 5.0, [&unit](double) { unit.set_controller(4); })};
|
||||
// the 1% of the first step is all there is until then
|
||||
auto const demand{cab.eimic_real};
|
||||
auto const demand{cab.EimicReal()};
|
||||
// the step the ramp of the demand starts at
|
||||
auto rampstart{release};
|
||||
while (cab.eimic_real < 0.0101 && rampstart < 5.0) {
|
||||
while (cab.EimicReal() < 0.0101 && rampstart < 5.0) {
|
||||
rampstart += step_time;
|
||||
unit.unit.step(unit.line);
|
||||
}
|
||||
@@ -425,10 +425,10 @@ TEST_CASE("elf holding brake: the controller flicked to power once and back to h
|
||||
REQUIRE(unit.ready);
|
||||
auto &cab{unit.cab()};
|
||||
auto const release{release_time(unit, 5.0, [&unit](double Time) { flick(unit, Time); })};
|
||||
MESSAGE("flick: release " << release << " s, demand " << cab.eimic_real);
|
||||
MESSAGE("flick: release " << release << " s, demand " << cab.EimicReal());
|
||||
CHECK(release == doctest::Approx(1.0).epsilon(0.015));
|
||||
// the demand stays at the 1% of the flick
|
||||
CHECK(cab.eimic_real == doctest::Approx(0.01).epsilon(0.02));
|
||||
CHECK(cab.EimicReal() == doctest::Approx(0.01).epsilon(0.02));
|
||||
}
|
||||
|
||||
TEST_CASE("elf holding brake: a demand dropped to zero before the delay starts the count again") {
|
||||
@@ -439,7 +439,7 @@ TEST_CASE("elf holding brake: a demand dropped to zero before the delay starts t
|
||||
auto const release{release_time(unit, 5.0, [&unit](double Time) { unit.set_controller(Time > 0.495 && Time < 0.695 ? 2 : 4); })};
|
||||
MESSAGE("restart: release " << release << " s");
|
||||
CHECK(release == doctest::Approx(1.7).epsilon(0.01));
|
||||
CHECK(cab.eimic_real > 0.0);
|
||||
CHECK(cab.EimicReal() > 0.0);
|
||||
}
|
||||
|
||||
TEST_CASE("elf holding brake: it comes back when the demand drops to zero at standstill") {
|
||||
@@ -451,8 +451,8 @@ TEST_CASE("elf holding brake: it comes back when the demand drops to zero at sta
|
||||
// the braking position takes the demand off: the brake holds from the next step
|
||||
unit.set_controller(2);
|
||||
unit.unit.step(unit.line);
|
||||
CHECK(cab.eimic_real <= 0.0);
|
||||
CHECK_FALSE(cab.UpdateStopBrakeRelease(cab.eimic_real, step_time));
|
||||
CHECK(cab.EimicReal() <= 0.0);
|
||||
CHECK_FALSE(cab.UpdateStopBrakeRelease(cab.EimicReal(), step_time));
|
||||
// and power demanded again waits the delay again
|
||||
auto const again{release_time(unit, 5.0, [&unit](double) { unit.set_controller(4); })};
|
||||
CHECK(again == doctest::Approx(1.0).epsilon(0.015));
|
||||
@@ -529,8 +529,8 @@ TEST_CASE("elf holding brake: the force of the motors at 1% against the holding
|
||||
unit.set_controller(3);
|
||||
unit.wait(5.0);
|
||||
auto const holding{cab.brakes.holding.deceleration * mass};
|
||||
MESSAGE("mass " << mass << " kg, holding " << holding << " N, cars with motors " << powered << ", demand " << cab.eimic_real << ", cab car Ft " << cab.Ft()
|
||||
MESSAGE("mass " << mass << " kg, holding " << holding << " N, cars with motors " << powered << ", demand " << cab.EimicReal() << ", cab car Ft " << cab.Ft()
|
||||
<< " N, Fful " << cab.inductionMotor.state.fullForce << " kN, speed " << cab.Vel << " km/h after 5 s");
|
||||
CHECK(cab.eimic_real == doctest::Approx(0.01).epsilon(0.02));
|
||||
CHECK(cab.EimicReal() == doctest::Approx(0.01).epsilon(0.02));
|
||||
CHECK(cab.Ft() * powered < 0.1 * holding);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ std::vector<test::channel> cruise() {
|
||||
{"SpeedCtrlValue", [](auto const &M) { return M.SpeedCtrlValue; }},
|
||||
{"eimic", [](auto const &M) { return M.eimic; }},
|
||||
{"eimicSpeedCtrl", [](auto const &M) { return M.eimicSpeedCtrl(); }},
|
||||
{"eimic_real", [](auto const &M) { return M.eimic_real; }},
|
||||
{"eimic_real", [](auto const &M) { return M.EimicReal(); }},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ TEST_CASE("speed control: the field shunting of the vehicles with a cruise contr
|
||||
CHECK(loco.Vel > 100.0);
|
||||
CHECK(loco.ScndCtrlPos() == 1);
|
||||
CHECK_FALSE(loco.SpeedCtrlUnit.IsActive);
|
||||
CHECK(loco.eimic_real == doctest::Approx(loco.eimic));
|
||||
CHECK(loco.EimicReal() == doctest::Approx(loco.eimic));
|
||||
// the driver can't move the shunt
|
||||
CHECK_FALSE(loco.IncScndCtrl(1));
|
||||
CHECK_FALSE(loco.DecScndCtrl(2));
|
||||
@@ -224,7 +224,7 @@ TEST_CASE("speed control: the field shunting of the vehicles with a cruise contr
|
||||
CHECK(loco.Vel > 130.0);
|
||||
CHECK(most == 0);
|
||||
CHECK_FALSE(loco.SpeedCtrlUnit.IsActive);
|
||||
CHECK(loco.eimic_real == doctest::Approx(loco.eimic));
|
||||
CHECK(loco.EimicReal() == doctest::Approx(loco.eimic));
|
||||
// the speed buttons do nothing with the cruise control off
|
||||
loco.SpeedCtrlButton(4);
|
||||
loco.SpeedCtrlInc();
|
||||
@@ -300,7 +300,7 @@ TEST_CASE("speed control apart: the 6Dg's cruise control on its own switch, the
|
||||
count_shunting(scenario, loco, 60, shunted, unshunted);
|
||||
CHECK(loco.Vel == doctest::Approx(held).epsilon(0.03));
|
||||
CHECK_FALSE(loco.SpeedCtrlUnit.Standby);
|
||||
CHECK(loco.eimic_real < loco.eimic); // the cruise control holding the power back
|
||||
CHECK(loco.EimicReal() < loco.eimic); // the cruise control holding the power back
|
||||
|
||||
scenario.act("two steps up");
|
||||
loco.SpeedCtrlInc();
|
||||
@@ -337,7 +337,7 @@ TEST_CASE("speed control apart: the 6Dg's cruise control on its own switch, the
|
||||
CHECK_FALSE(loco.SpeedCtrlUnit.IsActive);
|
||||
CHECK(loco.SpeedCtrlValue == 0.0);
|
||||
scenario.wait(5.0);
|
||||
CHECK(loco.eimic_real == doctest::Approx(loco.eimic)); // the controller's demand again
|
||||
CHECK(loco.EimicReal() == doctest::Approx(loco.eimic)); // the controller's demand again
|
||||
scenario.check();
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ TEST_CASE("speed control apart: the ST45's cruise control on its own switch, wit
|
||||
CHECK(loco.SpeedCtrlUnit.DesiredPower == doctest::Approx(0.9));
|
||||
scenario.wait(60.0);
|
||||
CHECK(loco.Vel == doctest::Approx(65.0).epsilon(0.03));
|
||||
CHECK(loco.eimic_real <= 0.9 + 1e-9);
|
||||
CHECK(loco.EimicReal() <= 0.9 + 1e-9);
|
||||
scenario.act("cruise control off");
|
||||
CHECK(loco.SpeedCtrlSwitch(false));
|
||||
// off, its buttons do nothing
|
||||
|
||||
@@ -243,13 +243,13 @@ double vehicle::move(track const &Track, double Dt, TLocation const &Location, d
|
||||
if (physics.SpeedCtrl()) {
|
||||
physics.CheckSpeedCtrl(Dt);
|
||||
}
|
||||
physics.eimic_real = std::min(physics.eimic, physics.eimicSpeedCtrl());
|
||||
physics.SetEimicReal(std::min(physics.eimic, physics.eimicSpeedCtrl()));
|
||||
}
|
||||
if (physics.EngineType == ElectricInductionMotor) {
|
||||
// the share of the electric and pneumatic brake over the train (TDynamicObject's MED) isn't here
|
||||
physics.CheckEIMIC(Dt);
|
||||
physics.CheckSpeedCtrl(Dt);
|
||||
physics.eimic_real = std::min(physics.eimic, physics.eimicSpeedCtrl());
|
||||
physics.SetEimicReal(std::min(physics.eimic, physics.eimicSpeedCtrl()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1225,7 +1225,7 @@ void TController::SetTimeControllers()
|
||||
DizelPercentage_Speed = std::min(DizelPercentage, mvControlling->Vel < 0.99 * VelDesired ? 1 : 0);
|
||||
}
|
||||
|
||||
auto const DizelActualPercentage { int(100.4 * mvControlling->eimic_real) };
|
||||
auto const DizelActualPercentage { int(100.4 * mvControlling->EimicReal()) };
|
||||
|
||||
auto const PosInc { mvControlling->MainCtrlPosNo };
|
||||
auto PosDec { 0 };
|
||||
@@ -1370,7 +1370,7 @@ void TController::CheckTimeControllers()
|
||||
//5.1. Digital controller in DMUs with hydro
|
||||
if (mvControlling->EngineType == TEngineType::DieselEngine && mvControlling->EIMCtrlType == 3)
|
||||
{
|
||||
int DizelActualPercentage = 100.4 * mvControlling->eimic_real;
|
||||
int DizelActualPercentage = 100.4 * mvControlling->EimicReal();
|
||||
int NeutralPos = mvControlling->MainCtrlPosNo - 1; //przedostatnia powinna wstrzymywać - hipoteza robocza
|
||||
for (int i = mvControlling->MainCtrlPosNo; i >= 0; i--)
|
||||
if (mvControlling->UniCtrlList[i].SetCtrlVal <= 0 && mvControlling->UniCtrlList[i].SpeedDown < 0.01) //niby zero, ale nie zmniejsza procentów
|
||||
|
||||
@@ -553,7 +553,7 @@ void TTrain::completeUnitStates(int const in)
|
||||
// else
|
||||
// fEIMParams[0][3] =
|
||||
// controlled->inductionMotor.state.forceDemand - occupied->LocalBrakeRatio(); // procent zadany
|
||||
fEIMParams[0][3] = static_cast<float>(occupied->eimic_real);
|
||||
fEIMParams[0][3] = static_cast<float>(occupied->EimicReal());
|
||||
fEIMParams[0][4] = std::max(fEIMParams[0][3], 0.f);
|
||||
fEIMParams[0][5] = -std::min(fEIMParams[0][3], 0.f);
|
||||
fEIMParams[0][1] = static_cast<float>(fEIMParams[0][4] * controlled->inductionMotor.state.fullForce);
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ void cut_power(physics::Vehicle &Vehicle) {
|
||||
Vehicle.SetScndCtrlPos(0);
|
||||
// what the integrated handle and the cruise control asked for last stays in force until somebody drives
|
||||
Vehicle.eimic = 0.0;
|
||||
Vehicle.eimic_real = 0.0;
|
||||
Vehicle.SetEimicReal(0.0);
|
||||
Vehicle.SpeedCtrlValue = 0.0;
|
||||
Vehicle.SpeedCtrlUnit.IsActive = false;
|
||||
Vehicle.SendCtrlToNext(VehicleCommand::mainController, Vehicle.MainCtrlPosForCoupled(), Vehicle.CabActive);
|
||||
|
||||
@@ -65,7 +65,7 @@ input from_vehicles(physics::Vehicle const &Vehicle, physics::Vehicle const &Con
|
||||
result.eimctrltype = Vehicle.EIMCtrlType;
|
||||
result.splited = Controlling.brakes.electrodynamic.splitFromPneumatic;
|
||||
result.integratedbrake = Vehicle.UniCtrlIntegratedBrakeCtrl;
|
||||
result.eimic_real = Vehicle.eimic_real;
|
||||
result.eimic_real = Vehicle.EimicReal();
|
||||
result.dynamicbrakepos = Controlling.brakes.electrodynamic.controllerPosition;
|
||||
result.dynamicbrakeposno = Controlling.brakes.electrodynamic.controllerPositions;
|
||||
result.mainctrlpos = Controlling.MainCtrlPos();
|
||||
|
||||
@@ -311,8 +311,8 @@ void TDynamicObject::updateDriver( double const dt1 )
|
||||
physics->CheckEIMIC(dt1);
|
||||
if (physics->SpeedCtrl())
|
||||
physics->CheckSpeedCtrl(dt1);
|
||||
physics->eimic_real = std::min(physics->eimic,physics->eimicSpeedCtrl());
|
||||
physics->SendCtrlToNext(VehicleCommand::integratedController, physics->eimic_real, physics->CabActive);
|
||||
physics->SetEimicReal(std::min(physics->eimic,physics->eimicSpeedCtrl()));
|
||||
physics->SendCtrlToNext(VehicleCommand::integratedController, physics->EimicReal(), physics->CabActive);
|
||||
}
|
||||
if( Mechanik->primary()
|
||||
&& physics->EngineType == TEngineType::ElectricInductionMotor ) {
|
||||
|
||||
Reference in New Issue
Block a user