From 04f76951f52340f1bac8e6118bfecacedda4a7f4 Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sat, 28 Nov 2026 15:23:36 +0100 Subject: [PATCH] refactor(physics): the diesel engine, the torque converter and the retarder are components of their own TMoverParameters held some 80 fields of the diesel engine and its hydraulic transmission among its other 600, named dizel_*, hydro_TC_* and hydro_R_*. They are now three structures of physics/components/dieselengine.h, with English names: - DieselEngine diesel: the definition (maxMoment, maxRevolutions, minRevolutions, the governor, the clutch, the fuel consumption, the tables) and the state (fill, clutchState, clutchPressure, torque, power, the start up, the fuel consumed) and its heat (EngineHeat, heat_data before) - TorqueConverter torqueConverter: present, the ratios, the lockup, the fill rates, the table, and its state (fill, lockedUp, torqueRatio, the revolutions in and out) - Retarder retarder: present, its placement, torque, power, fill rates, clutch, and its state The .fiz keywords, the keys of the dictionaries of the Python screens and the names of the golden channels (dizel_fill...) are unchanged; only the C++ names changed. The functions of the engine (dizel_Update, dizel_Momentum...) stay members of TMoverParameters for now. No change in behaviour: 1144/1144 tests, golden traces exact against staging 62f7a29b. --- application/driverhints.cpp | 4 +- application/driveruipanels.cpp | 50 ++-- physics/components/commands.cpp | 2 +- physics/components/diesel.cpp | 446 ++++++++++++++-------------- physics/components/dieselengine.h | 185 ++++++++++++ physics/components/drive.cpp | 12 +- physics/components/electrics.cpp | 8 +- physics/components/fizparser.cpp | 6 +- physics/components/fizsections.cpp | 174 +++++------ physics/mover.h | 162 +--------- rendering/particles.cpp | 10 +- simulation/blackboxrecorder.cpp | 12 +- tests/unit/golden.cpp | 2 +- tests/unit/invariants.cpp | 8 +- tests/unit/test_cab.cpp | 2 +- tests/unit/test_diesel.cpp | 34 +-- tests/unit/test_engine_shutdown.cpp | 6 +- tests/unit/test_engine_start.cpp | 4 +- tests/unit/test_oil_pump.cpp | 4 +- tests/unit/test_smoke.cpp | 26 +- vehicle/ai/consist.cpp | 2 +- vehicle/ai/controls.cpp | 10 +- vehicle/ai/engine.cpp | 2 +- vehicle/ai/physicslog.cpp | 8 +- vehicle/cab/setup.cpp | 8 +- vehicle/cab/update.cpp | 36 +-- vehicle/dynamic/lifecycle.cpp | 4 +- vehicle/dynamic/sounds.cpp | 36 +-- vehicle/dynamic/visual.cpp | 8 +- vehicle/enginestart.cpp | 2 +- vehicle/smoke.cpp | 4 +- vehicle/smoke.h | 2 +- widgets/vehicleparams.cpp | 6 +- 33 files changed, 660 insertions(+), 625 deletions(-) create mode 100644 physics/components/dieselengine.h diff --git a/application/driverhints.cpp b/application/driverhints.cpp index 890628964..e00158bc0 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -725,7 +725,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == true; } ); + return mvControlling->diesel.heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == true; } ); break; } case driver_hint::watercircuitslinkoff: { @@ -736,7 +736,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == false; } ); + return mvControlling->diesel.heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == false; } ); break; } case driver_hint::waittemperaturetoolow: { diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index cb9f9e6d8..a6fd2ee8b 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -900,8 +900,8 @@ debug_panel::update_section_vehicle( std::vector &Output ) { mover.RventRot * 60, std::abs( mover.MotorBlowers[end::front].revolutions ), std::abs( mover.MotorBlowers[end::rear].revolutions ), - mover.dizel_heat.rpmw, - mover.dizel_heat.rpmw2 ); + mover.diesel.heat.rpmw, + mover.diesel.heat.rpmw2 ); std::string textline { m_buffer.data() }; @@ -909,11 +909,11 @@ debug_panel::update_section_vehicle( std::vector &Output ) { std::snprintf( m_buffer.data(), m_buffer.size(), STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"), - mover.dizel_heat.Ts, - mover.dizel_heat.To, - mover.dizel_heat.temperatura1, + mover.diesel.heat.Ts, + mover.diesel.heat.To, + mover.diesel.heat.temperatura1, mover.WaterCircuitsLink ? '-' : '|', - mover.dizel_heat.temperatura2 ); + mover.diesel.heat.temperatura2 ); textline += m_buffer.data(); } @@ -1122,22 +1122,22 @@ debug_panel::update_section_engine( std::vector &Output ) const { double fuel_mean = 0.0; if (mover.DistCounter > 0.5) { - fuel_mean = 100 * mover.dizel_FuelConsumptedTotal / mover.DistCounter; + fuel_mean = 100 * mover.diesel.fuelConsumedTotal / mover.DistCounter; } std::string parameterstext = "param value"; std::vector< std::pair > const paramvalues { { " rpm: ", mover.enrot * 60.0 }, - { "efill: ", mover.dizel_fill }, - { "etorq: ", mover.dizel_Torque }, - { "power: ", mover.dizel_Power }, - { "f_act: ", mover.dizel_FuelConsumptionActual }, - { "f_tot: ", mover.dizel_FuelConsumptedTotal }, + { "efill: ", mover.diesel.fill }, + { "etorq: ", mover.diesel.torque }, + { "power: ", mover.diesel.power }, + { "f_act: ", mover.diesel.fuelConsumptionActual }, + { "f_tot: ", mover.diesel.fuelConsumedTotal }, { "fmean: ", fuel_mean }, - { "creal: ", mover.dizel_engage }, - { "cdesi: ", mover.dizel_engagestate }, - { "cdelt: ", mover.dizel_engagedeltaomega }, - { "gears: ", mover.dizel_automaticgearstatus} }; + { "creal: ", mover.diesel.clutchPressure }, + { "cdesi: ", mover.diesel.clutchState }, + { "cdelt: ", mover.diesel.clutchSlip }, + { "gears: ", mover.diesel.automaticGearShift} }; for( auto const &[parametername, parametervalue] : paramvalues ) { parameterstext += "\n" + parametername + to_string( parametervalue, 2, 9 ); } @@ -1145,15 +1145,15 @@ debug_panel::update_section_engine( std::vector &Output ) const { parameterstext = "hydro value"; std::vector< std::pair > const hydrovalues { - { "hTCnI: ", mover.hydro_TC_nIn }, - { "hTCnO: ", mover.hydro_TC_nOut }, - { "hTCTM: ", mover.hydro_TC_TMRatio }, - { "hTCTI: ", mover.hydro_TC_TorqueIn }, - { "hTCTO: ", mover.hydro_TC_TorqueOut }, - { "hTCfl: ", mover.hydro_TC_Fill }, - { "hRtFl: ", mover.hydro_R_Fill } , - { " hRtn: ", mover.hydro_R_n } , - { "hRtTq: ", mover.hydro_R_Torque } + { "hTCnI: ", mover.torqueConverter.revolutionsIn }, + { "hTCnO: ", mover.torqueConverter.revolutionsOut }, + { "hTCTM: ", mover.torqueConverter.torqueRatio }, + { "hTCTI: ", mover.torqueConverter.torqueIn }, + { "hTCTO: ", mover.torqueConverter.torqueOut }, + { "hTCfl: ", mover.torqueConverter.fill }, + { "hRtFl: ", mover.retarder.fill } , + { " hRtn: ", mover.retarder.revolutions } , + { "hRtTq: ", mover.retarder.torque } }; for( auto const &[parametername, parametervalue] : hydrovalues ) { diff --git a/physics/components/commands.cpp b/physics/components/commands.cpp index 57d33dc8e..8a1ca64c5 100644 --- a/physics/components/commands.cpp +++ b/physics/components/commands.cpp @@ -463,7 +463,7 @@ bool TMoverParameters::RunPumpsCommand(VehicleCommand const Command, double CVal } else if (Command == VehicleCommand::waterCircuitsLinkSwitch) { - if (true == dizel_heat.auxiliary_water_circuit) + if (true == diesel.heat.auxiliary_water_circuit) { // can only link circuits if the vehicle has more than one of them WaterCircuitsLink = CValue1 == 1; diff --git a/physics/components/diesel.cpp b/physics/components/diesel.cpp index 0be62d9a2..8879fdd6e 100644 --- a/physics/components/diesel.cpp +++ b/physics/components/diesel.cpp @@ -59,11 +59,11 @@ void TMoverParameters::WaterHeaterCheck(double const /*Timestep*/) { WaterHeater.is_active = false == WaterHeater.is_damaged && true == (Power24vIsAvailable || Power110vIsAvailable) && true == WaterHeater.is_enabled && true == WaterHeater.breaker && - (WaterHeater.is_active || WaterHeater.config.temp_min < 0 || dizel_heat.temperatura1 < WaterHeater.config.temp_min); + (WaterHeater.is_active || WaterHeater.config.temp_min < 0 || diesel.heat.temperatura1 < WaterHeater.config.temp_min); WaterHeater.is_damaged = true == WaterHeater.is_damaged || (true == WaterHeater.is_active && false == WaterPump.is_active); - if (WaterHeater.config.temp_max > 0 && dizel_heat.temperatura1 > WaterHeater.config.temp_max) + if (WaterHeater.config.temp_max > 0 && diesel.heat.temperatura1 > WaterHeater.config.temp_max) { WaterHeater.is_active = false; } @@ -76,8 +76,8 @@ void TMoverParameters::FuelPumpCheck(double const /*Timestep*/) FuelPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && false == FuelPump.is_disabled && (FuelPump.is_active || (FuelPump.start_type == manual ? FuelPump.is_enabled : - FuelPump.start_type == automatic ? dizel_startup || Mains : - FuelPump.start_type == manualwithautofallback ? FuelPump.is_enabled || dizel_startup || Mains : + FuelPump.start_type == automatic ? diesel.startupRequested || Mains : + FuelPump.start_type == manualwithautofallback ? FuelPump.is_enabled || diesel.startupRequested || Mains : false)); // shouldn't ever get this far but, eh } @@ -87,8 +87,8 @@ void TMoverParameters::OilPumpCheck(double const Timestep) OilPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && false == Mains && false == OilPump.is_disabled && (OilPump.is_active || (OilPump.start_type == start_t::manual ? OilPump.is_enabled : - OilPump.start_type == start_t::automatic ? dizel_startup : - OilPump.start_type == start_t::manualwithautofallback ? OilPump.is_enabled || dizel_startup : + OilPump.start_type == start_t::automatic ? diesel.startupRequested : + OilPump.start_type == start_t::manualwithautofallback ? OilPump.is_enabled || diesel.startupRequested : false)); // shouldn't ever get this far but, eh auto const minpressure{OilPump.pressure_minimum > 0.f ? OilPump.pressure_minimum : 0.15f}; // arbitrary fallback value @@ -220,7 +220,7 @@ bool TMoverParameters::WaterHeaterSwitch(bool State, range_t const Notify) bool TMoverParameters::WaterCircuitsLinkSwitch(bool State, range_t const Notify) { - if (false == dizel_heat.auxiliary_water_circuit) + if (false == diesel.heat.auxiliary_water_circuit) { // can't link the circuits if the vehicle only has one return false; @@ -341,12 +341,12 @@ double TMoverParameters::UpdateEngineRevolutions(double dt, double &dtrans, doub else { tmp = 0.0; - dizel_fill = 0.0; + diesel.fill = 0.0; } if (enrot != tmp) { - enrot = safe_clamp(enrot + dt / dizel_AIM * (enrot < tmp ? 1.0 : -1.0 * dizel_RevolutionsDecreaseRate), // NOTE: revolutions typically drop faster than they rise + enrot = safe_clamp(enrot + dt / diesel.shaftInertia * (enrot < tmp ? 1.0 : -1.0 * diesel.revolutionsDecreaseRate), // NOTE: revolutions typically drop faster than they rise 0.0, std::max(tmp, enrot)); if (std::abs(tmp - enrot) < 0.001) { @@ -362,7 +362,7 @@ double TMoverParameters::UpdateEngineRevolutions(double dt, double &dtrans, doub else dtrans = Transmision.Ratio * motor_param(ScndCtrlActualPos).mIsat; - dmoment = dizel_Momentum(dizel_fill, dtrans * nrot * DirActive, dt); // oblicza tez enrot + dmoment = dizel_Momentum(diesel.fill, dtrans * nrot * DirActive, dt); // oblicza tez enrot break; } default: @@ -390,15 +390,15 @@ double TMoverParameters::DieselElectricTargetRevolutions() // bump engine revolutions up if needed, when heating is on tmp = std::max(tmp, std::min(EngineMaxRPM(), EngineHeatingRPM) / 60.0); } - // NOTE: fake dizel_fill calculation for the sake of smoke emitter which uses this parameter to determine smoke opacity - dizel_fill = std::clamp(0.2 + 0.35 * (tmp - enrot) + 0.5 * (std::abs(Im) / DElist[MainCtrlPosNo].Imax), 0.05, 1.0); + // NOTE: fake diesel.fill calculation for the sake of smoke emitter which uses this parameter to determine smoke opacity + diesel.fill = std::clamp(0.2 + 0.35 * (tmp - enrot) + 0.5 * (std::abs(Im) / DElist[MainCtrlPosNo].Imax), 0.05, 1.0); return tmp; } void TMoverParameters::DieselEngineTractionForce(double dt, double const dmoment, double const dtrans) { Mw = dmoment * dtrans * Transmision.Efficiency; // dmoment i dtrans policzone przy okazji enginerotation - if (hydro_R && hydro_R_Placement == 0) + if (retarder.present && retarder.placement == 0) Mw -= dizel_MomentumRetarder(nrot * Transmision.Ratio, dt) * Transmision.Ratio * Transmision.Efficiency; Fw = Mw * 2.0 / WheelDiameter / NPoweredAxles; Ft = Fw * NPoweredAxles; // sila trakcyjna @@ -692,9 +692,9 @@ void TMoverParameters::apply_dieselelectric_dynamic_brake(double const dt) // ************************************************************************************************* bool TMoverParameters::dizel_EngageSwitch(double state) { - if (EngineType == TEngineType::DieselEngine && state <= 1 && state >= 0 && state != dizel_engagestate) + if (EngineType == TEngineType::DieselEngine && state <= 1 && state >= 0 && state != diesel.clutchState) { - dizel_engagestate = state; + diesel.clutchState = state; return true; } else @@ -711,24 +711,24 @@ bool TMoverParameters::dizel_EngageChange(double dt) bool DEC; DEC = false; - if (dizel_engage - dizel_engagestate > 0) + if (diesel.clutchPressure - diesel.clutchState > 0) engagespeed = engagedownspeed; else engagespeed = engageupspeed; if (dt > 0.2) dt = 0.1; - if (abs(dizel_engage - dizel_engagestate) < 0.11) + if (abs(diesel.clutchPressure - diesel.clutchState) < 0.11) { - if (dizel_engage != dizel_engagestate) + if (diesel.clutchPressure != diesel.clutchState) { DEC = true; - dizel_engage = dizel_engagestate; + diesel.clutchPressure = diesel.clutchState; } // else OK:=false; //już jest false } else { - dizel_engage = dizel_engage + engagespeed * dt * (dizel_engagestate - dizel_engage); + diesel.clutchPressure = diesel.clutchPressure + engagespeed * dt * (diesel.clutchState - diesel.clutchPressure); // OK:=false; } // dizel_EngageChange:=OK; @@ -765,24 +765,24 @@ bool TMoverParameters::dizel_AutoGearCheck(void) bool TMoverParameters::dizel_GearShiftCheck(double const VelUp, double const VelDown) { auto OK{false}; - if (RList[MainCtrlPos].Mn == 0 && !hydro_TC) + if (RList[MainCtrlPos].Mn == 0 && !torqueConverter.present) { - if (dizel_engagestate > 0) + if (diesel.clutchState > 0) dizel_EngageSwitch(0); if (IsMainCtrlNoPowerPos() && ScndCtrlActualPos > 0) - dizel_automaticgearstatus = -1; + diesel.automaticGearShift = -1; } else { OK = dizel_GearShiftRequest(VelUp, VelDown); } - if (dizel_engage < 0.1 && dizel_automaticgearstatus != 0) + if (diesel.clutchPressure < 0.1 && diesel.automaticGearShift != 0) { - if (dizel_automaticgearstatus == 1) + if (diesel.automaticGearShift == 1) ScndCtrlActualPos++; else ScndCtrlActualPos--; - dizel_automaticgearstatus = 0; + diesel.automaticGearShift = 0; dizel_EngageSwitch(1.0); OK = true; } @@ -793,14 +793,14 @@ bool TMoverParameters::dizel_GearShiftCheck(double const VelUp, double const Vel bool TMoverParameters::dizel_GearShiftRequest(double const VelUp, double const VelDown) { auto OK{false}; - if (motor_param(ScndCtrlActualPos).AutoSwitch && dizel_automaticgearstatus == 0) // sprawdz czy zmienic biegi + if (motor_param(ScndCtrlActualPos).AutoSwitch && diesel.automaticGearShift == 0) // sprawdz czy zmienic biegi { if (Vel > VelUp) { // shift up if (ScndCtrlActualPos < ScndCtrlPosNo) { - dizel_automaticgearstatus = 1; + diesel.automaticGearShift = 1; OK = true; } } @@ -809,7 +809,7 @@ bool TMoverParameters::dizel_GearShiftRequest(double const VelUp, double const V // shift down if (ScndCtrlActualPos > 0) { - dizel_automaticgearstatus = -1; + diesel.automaticGearShift = -1; OK = true; } } @@ -824,7 +824,7 @@ void TMoverParameters::dizel_ClutchCheck() { dizel_ClutchByIntegratedController(); } - else if (dizel_automaticgearstatus == 0) // ustaw cisnienie w silowniku sprzegla} + else if (diesel.automaticGearShift == 0) // ustaw cisnienie w silowniku sprzegla} dizel_ClutchByController(); else dizel_EngageSwitch(0.0); @@ -846,25 +846,25 @@ void TMoverParameters::dizel_ClutchByController() dizel_EngageSwitch(1.0); break; case 3: - if (Vel > dizel_minVelfullengage) + if (Vel > diesel.fullEngageMinVelocity) dizel_EngageSwitch(1.0); else dizel_EngageSwitch(0.5); break; case 4: - if (Vel > dizel_minVelfullengage) + if (Vel > diesel.fullEngageMinVelocity) dizel_EngageSwitch(1.0); else dizel_EngageSwitch(0.66); break; case 5: - if (Vel > dizel_minVelfullengage) + if (Vel > diesel.fullEngageMinVelocity) dizel_EngageSwitch(1.0); else dizel_EngageSwitch(0.35 * (1 + RList[MainCtrlPos].R) * RList[MainCtrlPos].R); break; default: - if (hydro_TC && hydro_TC_Fill > 0.01) + if (torqueConverter.present && torqueConverter.fill > 0.01) dizel_EngageSwitch(1.0); else dizel_EngageSwitch(0.0); @@ -874,11 +874,11 @@ void TMoverParameters::dizel_ClutchByController() // the clutch of the integrated controller: in with the converter filled or the power asked, half in for the retarder void TMoverParameters::dizel_ClutchByIntegratedController() { - if (dizel_automaticgearstatus == 0) + if (diesel.automaticGearShift == 0) { - if ((hydro_TC && hydro_TC_Fill > 0.01) || eimic_real > 0.005) + if ((torqueConverter.present && torqueConverter.fill > 0.01) || eimic_real > 0.005) dizel_EngageSwitch(1.0); - else if (Vel > hydro_R_EngageVel && hydro_R && hydro_R_Fill > 0.01) + else if (Vel > retarder.engageVelocity && retarder.present && retarder.fill > 0.01) dizel_EngageSwitch(0.5); else dizel_EngageSwitch(0.0); @@ -900,7 +900,7 @@ bool TMoverParameters::dizel_StartupCheck() engineisready = false; // if( FuelPump.start_type == start_t::manual ) { // with manual pump control startup procedure is done only once per starter switch press - dizel_startup = false; + diesel.startupRequested = false; // } } // test the oil pump @@ -910,15 +910,15 @@ bool TMoverParameters::dizel_StartupCheck() if (OilPump.start_type == start_t::manual) { // with manual pump control startup procedure is done only once per starter switch press - dizel_startup = false; + diesel.startupRequested = false; } } // test the water circuits and water temperature - if (true == dizel_heat.PA) + if (true == diesel.heat.PA) { engineisready = false; // TBD, TODO: reset startup procedure depending on pump and heater control mode - dizel_startup = false; + diesel.startupRequested = false; } return engineisready; @@ -936,30 +936,30 @@ bool TMoverParameters::dizel_Update(double dt) OilPumpCheck(dt); FuelPumpCheck(dt); // the engine being started fires once the starter has turned it a while; one stopped meanwhile starts over - dizel_FiringCountdown = (Mains ? std::max(0.0, dizel_FiringCountdown - dt) : 0.0); + diesel.firingCountdown = (Mains ? std::max(0.0, diesel.firingCountdown - dt) : 0.0); - if (true == dizel_startup && true == dizel_StartupCheck()) + if (true == diesel.startupRequested && true == dizel_StartupCheck()) { - dizel_ignition = true; + diesel.ignitionRequested = true; } - if (true == dizel_ignition && LastSwitchingTime >= InitialCtrlDelay) + if (true == diesel.ignitionRequested && LastSwitchingTime >= InitialCtrlDelay) { - dizel_startup = false; - dizel_ignition = false; + diesel.startupRequested = false; + diesel.ignitionRequested = false; // TODO: split engine and main circuit state indicator in two separate flags LastSwitchingTime = 0; Timer::subsystem.switching.note(Timer::switching_counter::diesel, this, &TypeName, &Name); Mains = true; - dizel_spinup = true; - dizel_FiringCountdown = dizel_SmokeDelay; + diesel.spinningUp = true; + diesel.firingCountdown = diesel.smokeDelay; enrot = std::max(enrot, 0.35 * ( // TODO: dac zaleznie od temperatury i baterii - EngineType == TEngineType::DieselEngine ? dizel_nmin : DElist[0].RPM / 60.0)); + EngineType == TEngineType::DieselEngine ? diesel.minRevolutions : DElist[0].RPM / 60.0)); } - dizel_spinup = dizel_spinup && Mains && enrot < 0.95 * (EngineType == TEngineType::DieselEngine ? dizel_nmin : DElist[0].RPM / 60.0); + diesel.spinningUp = diesel.spinningUp && Mains && enrot < 0.95 * (EngineType == TEngineType::DieselEngine ? diesel.minRevolutions : DElist[0].RPM / 60.0); if (true == Mains && false == FuelPump.is_active) { @@ -976,7 +976,7 @@ bool TMoverParameters::dizel_Update(double dt) dizel_EngageChange(dt); DU = dizel_AutoGearCheck(); double const fillspeed{2}; - dizel_fill = dizel_fill + fillspeed * dt * (dizel_fillcheck(MainCtrlPos, dt) - dizel_fill); + diesel.fill = diesel.fill + fillspeed * dt * (dizel_fillcheck(MainCtrlPos, dt) - diesel.fill); } dizel_Heat(dt); @@ -995,7 +995,7 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt) if (true == Mains && MainCtrlPosNo > 0 && true == FuelPump.is_active) { - if (true == dizel_ignition && LastSwitchingTime >= 0.9 * InitialCtrlDelay) + if (true == diesel.ignitionRequested && LastSwitchingTime >= 0.9 * InitialCtrlDelay) { // wzbogacenie przy rozruchu // NOTE: ignition flag is reset before this code is executed @@ -1011,11 +1011,11 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt) } else { - dizel_nreg_max = dizel_nmax; + diesel.governorMaxRevolutions = diesel.maxRevolutions; realfill = RList[mcp].R; } } - if (dizel_nmax_cutoff > 0) + if (diesel.cutoffRevolutions > 0) { realfill = dizel_GovernorFill(mcp, realfill); } @@ -1029,24 +1029,24 @@ double TMoverParameters::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 && !hydro_TC_Lockup) + if (eimic_real > 0.005 && !torqueConverter.lockedUp) { - dizel_nreg_min = std::min(dizel_nreg_min + 2.5 * dt, dizel_nmin_hdrive + eimic_real * dizel_nmin_hdrive_factor); + diesel.governorMinRevolutions = std::min(diesel.governorMinRevolutions + 2.5 * dt, diesel.hydraulicMinRevolutions + eimic_real * diesel.hydraulicMinRevolutionsFactor); } else { - if (Vel < hydro_R_EngageVel && hydro_R && hydro_R_Fill > 0.01) - dizel_nreg_min = std::min(dizel_nreg_min + 5.0 * dt, dizel_nmin_retarder); + if (Vel < retarder.engageVelocity && retarder.present && retarder.fill > 0.01) + diesel.governorMinRevolutions = std::min(diesel.governorMinRevolutions + 5.0 * dt, diesel.retarderRevolutions); else - dizel_nreg_min = dizel_nmin; + diesel.governorMinRevolutions = diesel.minRevolutions; } - if (!dizel_vel2nmax_Table.empty() && !hydro_TC_Lockup) + if (!diesel.speedMaxRevolutionsTable.empty() && !torqueConverter.lockedUp) { - dizel_nreg_max = std::min(std::min(dizel_nreg_max, enrot) + dizel_nreg_acc * dt, TableInterpolation(dizel_vel2nmax_Table, Vel)); + diesel.governorMaxRevolutions = std::min(std::min(diesel.governorMaxRevolutions, enrot) + diesel.governorAcceleration * dt, TableInterpolation(diesel.speedMaxRevolutionsTable, Vel)); } else { - dizel_nreg_max = dizel_nmax; + diesel.governorMaxRevolutions = diesel.maxRevolutions; } return realfill; } @@ -1056,12 +1056,12 @@ double TMoverParameters::dizel_GovernorFill(int const mcp, double realfill) cons { auto nreg{0.0}; if (EIMCtrlType > 0) - nreg = eimic_real > 0.005 ? dizel_nreg_max : dizel_nmin; + nreg = eimic_real > 0.005 ? diesel.governorMaxRevolutions : diesel.minRevolutions; else nreg = dizel_GovernorRevolutions(mcp, realfill); if (enrot > nreg) // nad predkoscia regulatora zeruj dawke realfill = 0; - if (enrot < dizel_nreg_min && RList[mcp].R > 0.001) // jesli ponizej biegu jalowego i niezerowa dawka, to dawaj pelna + if (enrot < diesel.governorMinRevolutions && RList[mcp].R > 0.001) // jesli ponizej biegu jalowego i niezerowa dawka, to dawaj pelna realfill = 1; return realfill; } @@ -1075,31 +1075,31 @@ double TMoverParameters::dizel_GovernorRevolutions(int const mcp, double &realfi { case 0: case 1: - nreg = dizel_nmin; + nreg = diesel.minRevolutions; break; case 2: - if (dizel_automaticgearstatus == 0 && true /*(!hydro_TC) || (dizel_engage>dizel_fill)*/) - nreg = dizel_nreg_max; + if (diesel.automaticGearShift == 0 && true /*(!torqueConverter.present) || (diesel.clutchPressure>diesel.fill)*/) + nreg = diesel.governorMaxRevolutions; else - nreg = dizel_nmin; + nreg = diesel.minRevolutions; break; case 3: - if (dizel_automaticgearstatus == 0 && Vel > dizel_minVelfullengage) - nreg = dizel_nreg_max; + if (diesel.automaticGearShift == 0 && Vel > diesel.fullEngageMinVelocity) + nreg = diesel.governorMaxRevolutions; else - nreg = dizel_nmin; + nreg = diesel.minRevolutions; break; case 4: - if (dizel_automaticgearstatus == 0 && Vel > dizel_minVelfullengage) - nreg = dizel_nmax; + if (diesel.automaticGearShift == 0 && Vel > diesel.fullEngageMinVelocity) + nreg = diesel.maxRevolutions; else - nreg = dizel_nmin * 0.75 + dizel_nreg_max * 0.25; + nreg = diesel.minRevolutions * 0.75 + diesel.governorMaxRevolutions * 0.25; break; case 5: - if (Vel > dizel_minVelfullengage) - nreg = dizel_nreg_max; + if (Vel > diesel.fullEngageMinVelocity) + nreg = diesel.governorMaxRevolutions; else - nreg = dizel_nmin + 0.8 * (dizel_nreg_max - dizel_nmin) * RList[mcp].R; + nreg = diesel.minRevolutions + 0.8 * (diesel.governorMaxRevolutions - diesel.minRevolutions) * RList[mcp].R; break; default: realfill = 0; // sluczaj @@ -1126,51 +1126,51 @@ double TMoverParameters::dizel_Momentum(double Fill, double n, double dt) n = n * CabActive; if (motor_param(ScndCtrlActualPos).mIsat < 0.001 || DirActive == 0) n = enrot; - friction = dizel_engagefriction; - hydro_TC_nIn = enrot; // wal wejsciowy przetwornika momentu - hydro_TC_nOut = dizel_n_old; // wal wyjsciowy przetwornika momentu + friction = diesel.clutchFriction; + torqueConverter.revolutionsIn = enrot; // wal wejsciowy przetwornika momentu + torqueConverter.revolutionsOut = diesel.previousRevolutions; // wal wyjsciowy przetwornika momentu if (enrot > 0) { - if (dizel_Momentum_Table.size() > 1) + if (diesel.momentTable.size() > 1) { - Moment = TableInterpolation(dizel_Momentum_Table, enrot) * Fill - dizel_Mstand; + Moment = TableInterpolation(diesel.momentTable, enrot) * Fill - diesel.standingMoment; } else { - Moment = (dizel_Mmax - (dizel_Mmax - dizel_Mnmax) * square((enrot - dizel_nMmax) / (dizel_nMmax - dizel_nmax))) * Fill - dizel_Mstand; + Moment = (diesel.maxMoment - (diesel.maxMoment - diesel.maxRevolutionsMoment) * square((enrot - diesel.maxMomentRevolutions) / (diesel.maxMomentRevolutions - diesel.maxRevolutions))) * Fill - diesel.standingMoment; } Mm = Moment; - dizel_FuelConsumptionActual = dizel_FuelConsumption * enrot * Fill; - dizel_FuelConsumptedTotal += dizel_FuelConsumptionActual * dt / 3600.0; - if (hydro_R && hydro_R_Placement == 2) + diesel.fuelConsumptionActual = diesel.fuelConsumption * enrot * Fill; + diesel.fuelConsumedTotal += diesel.fuelConsumptionActual * dt / 3600.0; + if (retarder.present && retarder.placement == 2) Moment -= dizel_MomentumRetarder(enrot, dt); } else { - Moment = -dizel_Mstand; + Moment = -diesel.standingMoment; } - if (enrot < dizel_nmin / 10.0 && eAngle < M_PI_2) + if (enrot < diesel.minRevolutions / 10.0 && eAngle < M_PI_2) { // wstrzymywanie przy malych obrotach - Moment -= dizel_Mstand; + Moment -= diesel.standingMoment; } - if (true == dizel_spinup) - Moment += dizel_Mstand / (0.3 + std::max(0.0, enrot / dizel_nmin)); // rozrusznik + if (true == diesel.spinningUp) + Moment += diesel.standingMoment / (0.3 + std::max(0.0, enrot / diesel.minRevolutions)); // rozrusznik - dizel_Torque = Moment; + diesel.torque = Moment; hydro_TCFillCheck(dt); // obliczanie momentow poszczegolnych sprzegiel // sprzeglo glowne (skrzynia biegow) - TorqueC = dizel_engageMaxForce * dizel_engage * dizel_engageDia * friction; + TorqueC = diesel.clutchMaxForce * diesel.clutchPressure * diesel.clutchDiameter * friction; - if (hydro_TC) // jesli hydro + if (torqueConverter.present) // jesli hydro { hydro_TCTorque(); - TorqueH = hydro_TC_TorqueOut; - TorqueL = hydro_TC_LockupTorque * hydro_TC_LockupRate; + TorqueH = torqueConverter.torqueOut; + TorqueL = torqueConverter.lockupTorque * torqueConverter.lockupRate; } else { @@ -1179,34 +1179,34 @@ double TMoverParameters::dizel_Momentum(double Fill, double n, double dt) } // sprawdzanie dociskow poszczegolnych sprzegiel - if (abs(Moment) > std::min(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) || abs(dizel_n_old - enrot) > 0.1) // slizga sie z powodu roznic predkosci albo przekroczenia momentu + if (abs(Moment) > std::min(TorqueC, TorqueL + abs(torqueConverter.torqueIn)) || abs(diesel.previousRevolutions - enrot) > 0.1) // slizga sie z powodu roznic predkosci albo przekroczenia momentu { - dizel_engagedeltaomega = enrot - dizel_n_old; + diesel.clutchSlip = enrot - diesel.previousRevolutions; if (TorqueC > TorqueL) { if (TorqueC > TorqueL + abs(TorqueH)) { - hydro_TC_nOut = n; - gearMoment = TorqueL + abs(TorqueH) * sign(dizel_engagedeltaomega); - enMoment = Moment - (TorqueL + abs(hydro_TC_TorqueIn)) * sign(dizel_engagedeltaomega); + torqueConverter.revolutionsOut = n; + gearMoment = TorqueL + abs(TorqueH) * sign(diesel.clutchSlip); + enMoment = Moment - (TorqueL + abs(torqueConverter.torqueIn)) * sign(diesel.clutchSlip); } else { - hydro_TC_nOut = enrot - (n - enrot) * (TorqueC - TorqueL) / TorqueH; // slizganie proporcjonalne, zeby przetwornik nadrabial - gearMoment = TorqueC * sign(dizel_engagedeltaomega); + torqueConverter.revolutionsOut = enrot - (n - enrot) * (TorqueC - TorqueL) / TorqueH; // slizganie proporcjonalne, zeby przetwornik nadrabial + gearMoment = TorqueC * sign(diesel.clutchSlip); enMoment = Moment - gearMoment; } } else { - hydro_TC_nOut = enrot; - gearMoment = TorqueC*sign(dizel_engagedeltaomega); + torqueConverter.revolutionsOut = enrot; + gearMoment = TorqueC*sign(diesel.clutchSlip); enMoment = Moment - gearMoment; } - eps = enMoment / dizel_AIM; + eps = enMoment / diesel.shaftInertia; newn = enrot + eps * dt; - if ((newn - n) * (enrot - dizel_n_old) < 0 && TorqueC > 0.1) // przejscie przez zero - slizgalo sie i przestało + if ((newn - n) * (enrot - diesel.previousRevolutions) < 0 && TorqueC > 0.1) // przejscie przez zero - slizgalo sie i przestało newn = n; if (newn * enrot <= 0 && eps * enrot < 0) // przejscie przez zero obrotow newn = 0; @@ -1214,16 +1214,16 @@ double TMoverParameters::dizel_Momentum(double Fill, double n, double dt) } else // nie slizga sie (jeszcze) { - dizel_engagedeltaomega = 0; + diesel.clutchSlip = 0; gearMoment = Moment; - double enrot_min = enrot - (std::min(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) - Moment) / dizel_AIM * dt; - double enrot_max = enrot + (std::min(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) + Moment) / dizel_AIM * dt; + double enrot_min = enrot - (std::min(TorqueC, TorqueL + abs(torqueConverter.torqueIn)) - Moment) / diesel.shaftInertia * dt; + double enrot_max = enrot + (std::min(TorqueC, TorqueL + abs(torqueConverter.torqueIn)) + Moment) / diesel.shaftInertia * dt; enrot = safe_clamp(n, enrot_min, enrot_max); } - if (hydro_R && hydro_R_Placement == 1) - gearMoment -= dizel_MomentumRetarder(hydro_TC_nOut, dt); + if (retarder.present && retarder.placement == 1) + gearMoment -= dizel_MomentumRetarder(torqueConverter.revolutionsOut, dt); - if (enrot <= 0 && false == dizel_spinup) + if (enrot <= 0 && false == diesel.spinningUp) { // an engine stalling stops those started together with it, once. one already stopped, from its own switch or // another vehicle's, or not started at all, has nothing to stop: it stays quiet, rather than stop every frame @@ -1235,7 +1235,7 @@ double TMoverParameters::dizel_Momentum(double Fill, double n, double dt) enrot = 0; } - dizel_n_old = n; // obecna predkosc katowa na potrzeby kolejnej klatki + diesel.previousRevolutions = n; // obecna predkosc katowa na potrzeby kolejnej klatki return gearMoment; } @@ -1243,37 +1243,37 @@ double TMoverParameters::dizel_Momentum(double Fill, double n, double dt) // the torque converter filled and emptied, and its lockup clutch engaged and released, by the power and the speed void TMoverParameters::hydro_TCFillCheck(double dt) { - if (hydro_TC) // jesli przetwornik momentu + if (torqueConverter.present) // jesli przetwornik momentu { // napelnianie przetwornika bool IsPower = EIMCtrlType > 0 ? eimic_real > 0.005 : MainCtrlPowerPos() > 0; - if (IsPower && Mains && enrot > dizel_nmin * 0.9) - hydro_TC_Fill += hydro_TC_FillRateInc * dt; + if (IsPower && Mains && enrot > diesel.minRevolutions * 0.9) + torqueConverter.fill += torqueConverter.fillRateIncrease * dt; // oproznianie przetwornika - if ((!IsPower && Vel < dizel_maxVelANS) || !Mains || enrot < dizel_nmin * 0.8) - hydro_TC_Fill -= hydro_TC_FillRateDec * dt; + if ((!IsPower && Vel < diesel.converterReleaseVelocity) || !Mains || enrot < diesel.minRevolutions * 0.8) + torqueConverter.fill -= torqueConverter.fillRateDecrease * dt; // obcinanie zakresu - hydro_TC_Fill = std::clamp(hydro_TC_Fill, 0.0, 1.0); + torqueConverter.fill = std::clamp(torqueConverter.fill, 0.0, 1.0); // blokowanie sprzegla blokującego - if (Vel > hydro_TC_LockupSpeed && Mains && enrot > 0.9 * dizel_nmin && IsPower) + if (Vel > torqueConverter.lockupSpeed && Mains && enrot > 0.9 * diesel.minRevolutions && IsPower) { - hydro_TC_Lockup = true; - hydro_TC_LockupRate += hydro_TC_FillRateInc * dt; + torqueConverter.lockedUp = true; + torqueConverter.lockupRate += torqueConverter.fillRateIncrease * dt; } // luzowanie sprzegla blokujacego - if (Vel < (IsPower ? hydro_TC_LockupSpeed : hydro_TC_UnlockSpeed) || !Mains || enrot < 0.8 * dizel_nmin) + if (Vel < (IsPower ? torqueConverter.lockupSpeed : torqueConverter.unlockSpeed) || !Mains || enrot < 0.8 * diesel.minRevolutions) { - hydro_TC_Lockup = false; - hydro_TC_LockupRate -= hydro_TC_FillRateDec * dt; + torqueConverter.lockedUp = false; + torqueConverter.lockupRate -= torqueConverter.fillRateDecrease * dt; } // obcinanie zakresu - hydro_TC_LockupRate = std::clamp(hydro_TC_LockupRate, 0.0, 1.0); + torqueConverter.lockupRate = std::clamp(torqueConverter.lockupRate, 0.0, 1.0); } else { - hydro_TC_Fill = 0.0; - hydro_TC_LockupRate = 0.0; + torqueConverter.fill = 0.0; + torqueConverter.lockupRate = 0.0; } } @@ -1281,29 +1281,29 @@ void TMoverParameters::hydro_TCFillCheck(double dt) void TMoverParameters::hydro_TCTorque() { double HydroTorque = 0; - HydroTorque += hydro_TC_nIn * hydro_TC_nIn * hydro_TC_TorqueInIn; - HydroTorque += (hydro_TC_nIn - hydro_TC_nOut) * hydro_TC_TorqueInOut; - HydroTorque += hydro_TC_nOut * hydro_TC_nOut * hydro_TC_TorqueOutOut; - double nOut2In = hydro_TC_nOut / std::max(0.01, hydro_TC_nIn); - if (hydro_TC_Table.size() > 1) + HydroTorque += torqueConverter.revolutionsIn * torqueConverter.revolutionsIn * torqueConverter.torqueInIn; + HydroTorque += (torqueConverter.revolutionsIn - torqueConverter.revolutionsOut) * torqueConverter.torqueInOut; + HydroTorque += torqueConverter.revolutionsOut * torqueConverter.revolutionsOut * torqueConverter.torqueOutOut; + double nOut2In = torqueConverter.revolutionsOut / std::max(0.01, torqueConverter.revolutionsIn); + if (torqueConverter.table.size() > 1) { - hydro_TC_TMRatio = TableInterpolation(hydro_TC_Table, nOut2In); - hydro_TC_TorqueOut = HydroTorque * hydro_TC_Fill * hydro_TC_TMRatio; - hydro_TC_TorqueIn = HydroTorque * hydro_TC_Fill * std::min(1.0, hydro_TC_TMRatio); + torqueConverter.torqueRatio = TableInterpolation(torqueConverter.table, nOut2In); + torqueConverter.torqueOut = HydroTorque * torqueConverter.fill * torqueConverter.torqueRatio; + torqueConverter.torqueIn = HydroTorque * torqueConverter.fill * std::min(1.0, torqueConverter.torqueRatio); } else { - if (nOut2In < hydro_TC_CouplingPoint) + if (nOut2In < torqueConverter.couplingPoint) { - hydro_TC_TMRatio = 1 + (hydro_TC_TMMax - 1) * square(1 - nOut2In / hydro_TC_CouplingPoint); - hydro_TC_TorqueIn = HydroTorque * hydro_TC_Fill; - hydro_TC_TorqueOut = HydroTorque * hydro_TC_Fill * hydro_TC_TMRatio; + torqueConverter.torqueRatio = 1 + (torqueConverter.maxTorqueRatio - 1) * square(1 - nOut2In / torqueConverter.couplingPoint); + torqueConverter.torqueIn = HydroTorque * torqueConverter.fill; + torqueConverter.torqueOut = HydroTorque * torqueConverter.fill * torqueConverter.torqueRatio; } else { - hydro_TC_TMRatio = (1 - nOut2In) / (1 - hydro_TC_CouplingPoint); - hydro_TC_TorqueIn = HydroTorque * hydro_TC_Fill * hydro_TC_TMRatio; - hydro_TC_TorqueOut = HydroTorque * hydro_TC_Fill * hydro_TC_TMRatio; + torqueConverter.torqueRatio = (1 - nOut2In) / (1 - torqueConverter.couplingPoint); + torqueConverter.torqueIn = HydroTorque * torqueConverter.fill * torqueConverter.torqueRatio; + torqueConverter.torqueOut = HydroTorque * torqueConverter.fill * torqueConverter.torqueRatio; } } } @@ -1311,46 +1311,46 @@ void TMoverParameters::hydro_TCTorque() double TMoverParameters::dizel_MomentumRetarder(double n, double dt) { double RetarderRequest = Mains ? std::max(0.0, -eimic_real) : 0; - if (hydro_R_WithIndividual) + if (retarder.withIndividual) RetarderRequest = LocalBrakeRatio(); - if (Vel < hydro_R_MinVel) + if (Vel < retarder.minVelocity) RetarderRequest = 0; - if (hydro_R_Placement == 2 && enrot < dizel_nmin) + if (retarder.placement == 2 && enrot < diesel.minRevolutions) { RetarderRequest = 0; } - hydro_R_ClutchActive = !hydro_R_Clutch || RetarderRequest > 0; - if (!hydro_R_Clutch || (hydro_R_ClutchActive && hydro_R_ClutchSpeed == 0)) + retarder.clutchActive = !retarder.hasClutch || RetarderRequest > 0; + if (!retarder.hasClutch || (retarder.clutchActive && retarder.clutchSpeed == 0)) { - hydro_R_n = n * 60; + retarder.revolutions = n * 60; } - else if (hydro_R_ClutchActive) + else if (retarder.clutchActive) { - hydro_R_n = sign(n) * std::min(std::abs(hydro_R_n + hydro_R_ClutchSpeed * dt), std::abs(n * 60)); + retarder.revolutions = sign(n) * std::min(std::abs(retarder.revolutions + retarder.clutchSpeed * dt), std::abs(n * 60)); } else { - hydro_R_n = 0; + retarder.revolutions = 0; } - n = hydro_R_n / 60.f; + n = retarder.revolutions / 60.f; - if (hydro_R_Fill < RetarderRequest) // gdy zadane hamowanie + if (retarder.fill < RetarderRequest) // gdy zadane hamowanie { - hydro_R_Fill = std::min(hydro_R_Fill + hydro_R_FillRateInc * dt, RetarderRequest); + retarder.fill = std::min(retarder.fill + retarder.fillRateIncrease * dt, RetarderRequest); } else { - hydro_R_Fill = std::max(hydro_R_Fill - hydro_R_FillRateDec * dt, RetarderRequest); + retarder.fill = std::max(retarder.fill - retarder.fillRateDecrease * dt, RetarderRequest); } - double Moment = hydro_R_MaxTorque; - if (double pwr = Moment * std::abs(n) * M_PI * 2 * 0.001; pwr > hydro_R_MaxPower) - Moment = Moment * hydro_R_MaxPower / pwr; - double moment_in = n * n * hydro_R_TorqueInIn; - Moment = std::min(moment_in, Moment * hydro_R_Fill); + double Moment = retarder.maxTorque; + if (double pwr = Moment * std::abs(n) * M_PI * 2 * 0.001; pwr > retarder.maxPower) + Moment = Moment * retarder.maxPower / pwr; + double moment_in = n * n * retarder.torqueInIn; + Moment = std::min(moment_in, Moment * retarder.fill); - hydro_R_Torque = Moment; + retarder.torque = Moment; return Moment; } @@ -1360,15 +1360,15 @@ void TMoverParameters::dizel_HeatSet(float const Value) { // TODO: don't include ambient temperature, pull it from environment data instead - dizel_heat.Te = Value; - dizel_heat.Ts = Value; - dizel_heat.To = Value; - dizel_heat.Tsr = Value; - dizel_heat.Twy = Value; - dizel_heat.Tsr2 = Value; - dizel_heat.Twy2 = Value; - dizel_heat.temperatura1 = Value; - dizel_heat.temperatura2 = Value; + diesel.heat.Te = Value; + diesel.heat.Ts = Value; + diesel.heat.To = Value; + diesel.heat.Tsr = Value; + diesel.heat.Twy = Value; + diesel.heat.Tsr2 = Value; + diesel.heat.Twy2 = Value; + diesel.heat.temperatura1 = Value; + diesel.heat.temperatura2 = Value; } // calculates diesel engine temperature and heat transfers @@ -1386,7 +1386,7 @@ void TMoverParameters::dizel_Heat(double const dt) auto const gwmin2{400.0}; auto const gwmax2{4000.0}; - dizel_heat.Te = Global.AirTemperature; + diesel.heat.Te = Global.AirTemperature; auto const engineon{(Mains ? 1 : 0)}; auto const engineoff{(Mains ? 0 : 1)}; @@ -1399,36 +1399,36 @@ void TMoverParameters::dizel_Heat(double const dt) auto const gw2 = engineon * std::lerp(gwmin2, gwmax2, revolutionsfactor) + waterpump * 1000 + engineoff * 200; auto const gwO = std::lerp(gwmin, gwmax, revolutionsfactor); - dizel_heat.water.is_cold = dizel_heat.water.config.temp_min > 0 && dizel_heat.temperatura1 < dizel_heat.water.config.temp_min - (Mains ? 5 : 0); - dizel_heat.water.is_hot = dizel_heat.water.config.temp_max > 0 && dizel_heat.temperatura1 > dizel_heat.water.config.temp_max - (dizel_heat.water.is_hot ? 8 : 0); - dizel_heat.water_aux.is_cold = dizel_heat.water_aux.config.temp_min > 0 && dizel_heat.temperatura2 < dizel_heat.water_aux.config.temp_min - (Mains ? 5 : 0); - dizel_heat.water_aux.is_hot = dizel_heat.water_aux.config.temp_max > 0 && dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_max - (dizel_heat.water_aux.is_hot ? 8 : 0); - dizel_heat.oil.is_cold = dizel_heat.oil.config.temp_min > 0 && dizel_heat.To < dizel_heat.oil.config.temp_min - (Mains ? 5 : 0); - dizel_heat.oil.is_hot = dizel_heat.oil.config.temp_max > 0 && dizel_heat.To > dizel_heat.oil.config.temp_max - (dizel_heat.oil.is_hot ? 8 : 0); + diesel.heat.water.is_cold = diesel.heat.water.config.temp_min > 0 && diesel.heat.temperatura1 < diesel.heat.water.config.temp_min - (Mains ? 5 : 0); + diesel.heat.water.is_hot = diesel.heat.water.config.temp_max > 0 && diesel.heat.temperatura1 > diesel.heat.water.config.temp_max - (diesel.heat.water.is_hot ? 8 : 0); + diesel.heat.water_aux.is_cold = diesel.heat.water_aux.config.temp_min > 0 && diesel.heat.temperatura2 < diesel.heat.water_aux.config.temp_min - (Mains ? 5 : 0); + diesel.heat.water_aux.is_hot = diesel.heat.water_aux.config.temp_max > 0 && diesel.heat.temperatura2 > diesel.heat.water_aux.config.temp_max - (diesel.heat.water_aux.is_hot ? 8 : 0); + diesel.heat.oil.is_cold = diesel.heat.oil.config.temp_min > 0 && diesel.heat.To < diesel.heat.oil.config.temp_min - (Mains ? 5 : 0); + diesel.heat.oil.is_hot = diesel.heat.oil.config.temp_max > 0 && diesel.heat.To > diesel.heat.oil.config.temp_max - (diesel.heat.oil.is_hot ? 8 : 0); // engine overheat check - dizel_heat.engine_is_hot = dizel_heat.engine_max_temp > 0 && dizel_heat.Ts > dizel_heat.engine_max_temp - (dizel_heat.engine_is_hot ? 8 : 0); + diesel.heat.engine_is_hot = diesel.heat.engine_max_temp > 0 && diesel.heat.Ts > diesel.heat.engine_max_temp - (diesel.heat.engine_is_hot ? 8 : 0); - auto const PT = false == dizel_heat.water.is_cold && false == dizel_heat.water.is_hot && false == dizel_heat.water_aux.is_cold && false == dizel_heat.water_aux.is_hot && - false == dizel_heat.oil.is_cold && false == dizel_heat.oil.is_hot && false == dizel_heat.engine.is_hot /* && ( false == awaria_termostatow ) */ + auto const PT = false == diesel.heat.water.is_cold && false == diesel.heat.water.is_hot && false == diesel.heat.water_aux.is_cold && false == diesel.heat.water_aux.is_hot && + false == diesel.heat.oil.is_cold && false == diesel.heat.oil.is_hot && false == diesel.heat.engine.is_hot /* && ( false == awaria_termostatow ) */ /* || PTp */; auto const PPT = false == PT /* && ( false == PPTp ) */; - dizel_heat.PA = /* ( ( !zamkniecie or niedomkniecie ) and !WBD ) || */ PPT /* || nurnik || ( woda < 7 ) */; + diesel.heat.PA = /* ( ( !zamkniecie or niedomkniecie ) and !WBD ) || */ PPT /* || nurnik || ( woda < 7 ) */; // engine heat transfers - auto const Ge{engineon * (0.21 * dizel_heat.powerfactor * EnginePower + 12) / 3600}; + auto const Ge{engineon * (0.21 * diesel.heat.powerfactor * EnginePower + 12) / 3600}; // TODO: replace fixed heating power cost with more accurate calculation - auto const obciazenie{engineon * (dizel_heat.powerfactor * EnginePower / 950 + (Heating ? HeatingPower : 0) + 70)}; + auto const obciazenie{engineon * (diesel.heat.powerfactor * EnginePower / 950 + (Heating ? HeatingPower : 0) + 70)}; auto const Qd{qs * Ge - obciazenie}; // silnik oddaje czesc ciepla do wody chlodzacej, a takze pewna niewielka czesc do otoczenia, modyfikowane przez okienko - auto const Qs{(Qd - dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr) - dizel_heat.kfe * /* ( 0.3 + 0.7 * ( dizel_heat.okienko ? 1 : 0 ) ) * */ (dizel_heat.Ts - dizel_heat.Te))}; + auto const Qs{(Qd - diesel.heat.kfs * (diesel.heat.Ts - diesel.heat.Tsr) - diesel.heat.kfe * /* ( 0.3 + 0.7 * ( diesel.heat.okienko ? 1 : 0 ) ) * */ (diesel.heat.Ts - diesel.heat.Te))}; auto const dTss{Qs / Cs}; - dizel_heat.Ts += static_cast(dTss * dt); + diesel.heat.Ts += static_cast(dTss * dt); // oil heat transfers // olej oddaje cieplo do wody gdy krazy przez wymiennik ciepla == wlaczona pompka lub silnik - auto const dTo{(dizel_heat.auxiliary_water_circuit ? (dizel_heat.kfo * (dizel_heat.Ts - dizel_heat.To) - dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr2)) / (gwO * Co) : - (dizel_heat.kfo * (dizel_heat.Ts - dizel_heat.To) - dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr)) / (gwO * Co))}; - dizel_heat.To += static_cast(dTo * dt); + auto const dTo{(diesel.heat.auxiliary_water_circuit ? (diesel.heat.kfo * (diesel.heat.Ts - diesel.heat.To) - diesel.heat.kfo2 * (diesel.heat.To - diesel.heat.Tsr2)) / (gwO * Co) : + (diesel.heat.kfo * (diesel.heat.Ts - diesel.heat.To) - diesel.heat.kfo2 * (diesel.heat.To - diesel.heat.Tsr)) / (gwO * Co))}; + diesel.heat.To += static_cast(dTo * dt); // heater /* @@ -1436,54 +1436,54 @@ void TMoverParameters::dizel_Heat(double const dt) Qp = (float)( podgrzewacz and ( true == WaterPump.is_active ) and ( Twy < 55 ) and ( Twy2 < 55 ) ) * 1000; else */ - auto const Qp = (true == WaterHeater.is_active && true == WaterPump.is_active && dizel_heat.Twy < 60 && dizel_heat.Twy2 < 60 ? 1 : 0) * 1000; + auto const Qp = (true == WaterHeater.is_active && true == WaterPump.is_active && diesel.heat.Twy < 60 && diesel.heat.Twy2 < 60 ? 1 : 0) * 1000; auto const kurek07{1}; // unknown/unimplemented device TBD, TODO: identify and implement? - if (true == dizel_heat.auxiliary_water_circuit) + if (true == diesel.heat.auxiliary_water_circuit) { // auxiliary water circuit setup - dizel_heat.water_aux.is_warm = true == dizel_heat.cooling || + diesel.heat.water_aux.is_warm = true == diesel.heat.cooling || (true == Mains && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ - && dizel_heat.water_aux.config.temp_cooling > 0 && dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_cooling - (dizel_heat.water_aux.is_warm ? 8 : 0)); - auto const PTC2{(dizel_heat.water_aux.is_warm /*or PTC2p*/ ? 1 : 0)}; - dizel_heat.rpmwz2 = static_cast(PTC2 * (dizel_heat.fan_speed >= 0 ? rpm * dizel_heat.fan_speed : dizel_heat.fan_speed * -1)); - dizel_heat.zaluzje2 = dizel_heat.water_aux.config.shutters ? PTC2 == 1 : true; // no shutters is an equivalent to having them open - auto const zaluzje2{(dizel_heat.zaluzje2 ? 1 : 0)}; + && diesel.heat.water_aux.config.temp_cooling > 0 && diesel.heat.temperatura2 > diesel.heat.water_aux.config.temp_cooling - (diesel.heat.water_aux.is_warm ? 8 : 0)); + auto const PTC2{(diesel.heat.water_aux.is_warm /*or PTC2p*/ ? 1 : 0)}; + diesel.heat.rpmwz2 = static_cast(PTC2 * (diesel.heat.fan_speed >= 0 ? rpm * diesel.heat.fan_speed : diesel.heat.fan_speed * -1)); + diesel.heat.zaluzje2 = diesel.heat.water_aux.config.shutters ? PTC2 == 1 : true; // no shutters is an equivalent to having them open + auto const zaluzje2{(diesel.heat.zaluzje2 ? 1 : 0)}; // auxiliary water circuit heat transfer values - auto const kf2{kurek07 * (dizel_heat.kw * (0.3 + 0.7 * zaluzje2) * dizel_heat.rpmw2 + dizel_heat.kv * (0.3 + 0.7 * zaluzje2) * Vel / 3.6) + 2}; - auto const dTs2{dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr2) / (gw2 * Cw)}; + auto const kf2{kurek07 * (diesel.heat.kw * (0.3 + 0.7 * zaluzje2) * diesel.heat.rpmw2 + diesel.heat.kv * (0.3 + 0.7 * zaluzje2) * Vel / 3.6) + 2}; + auto const dTs2{diesel.heat.kfo2 * (diesel.heat.To - diesel.heat.Tsr2) / (gw2 * Cw)}; // przy otwartym kurku B ma³y obieg jest dogrzewany przez du¿y - stosujemy przy korzystaniu z podgrzewacza oraz w zimie - auto const Qch2{-kf2 * (dizel_heat.Tsr2 - dizel_heat.Te) + 80 * (true == WaterCircuitsLink ? 1 : 0) * (dizel_heat.Twy - dizel_heat.Tsr2)}; + auto const Qch2{-kf2 * (diesel.heat.Tsr2 - diesel.heat.Te) + 80 * (true == WaterCircuitsLink ? 1 : 0) * (diesel.heat.Twy - diesel.heat.Tsr2)}; auto const dTch2{Qch2 / (gw2 * Cw)}; // auxiliary water circuit heat transfers finalization // NOTE: since primary circuit doesn't read data from the auxiliary one, we can pretty safely finalize auxiliary updates before touching the primary circuit - auto const Twe2{dizel_heat.Twy2 + dTch2 * dt}; - dizel_heat.Twy2 = static_cast(Twe2 + dTs2 * dt); - dizel_heat.Tsr2 = static_cast(0.5 * (dizel_heat.Twy2 + Twe2)); - dizel_heat.temperatura2 = dizel_heat.Twy2; + auto const Twe2{diesel.heat.Twy2 + dTch2 * dt}; + diesel.heat.Twy2 = static_cast(Twe2 + dTs2 * dt); + diesel.heat.Tsr2 = static_cast(0.5 * (diesel.heat.Twy2 + Twe2)); + diesel.heat.temperatura2 = diesel.heat.Twy2; } // primary water circuit setup - dizel_heat.water.is_flowing = dizel_heat.water.config.temp_flow < 0 || dizel_heat.temperatura1 > dizel_heat.water.config.temp_flow - (dizel_heat.water.is_flowing ? 5 : 0); - auto const obieg{(dizel_heat.water.is_flowing ? 1 : 0)}; - dizel_heat.water.is_warm = - true == dizel_heat.cooling || (true == Mains && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ - && dizel_heat.water.config.temp_cooling > 0 && dizel_heat.temperatura1 > dizel_heat.water.config.temp_cooling - (dizel_heat.water.is_warm ? 8 : 0)); - auto const PTC1{(dizel_heat.water.is_warm /*or PTC1p*/ ? 1 : 0)}; - dizel_heat.rpmwz = static_cast(PTC1 * (dizel_heat.fan_speed >= 0 ? rpm * dizel_heat.fan_speed : dizel_heat.fan_speed * -1)); - dizel_heat.zaluzje1 = dizel_heat.water.config.shutters ? PTC1 == 1 : true; // no shutters is an equivalent to having them open - auto const zaluzje1{(dizel_heat.zaluzje1 ? 1 : 0)}; + diesel.heat.water.is_flowing = diesel.heat.water.config.temp_flow < 0 || diesel.heat.temperatura1 > diesel.heat.water.config.temp_flow - (diesel.heat.water.is_flowing ? 5 : 0); + auto const obieg{(diesel.heat.water.is_flowing ? 1 : 0)}; + diesel.heat.water.is_warm = + true == diesel.heat.cooling || (true == Mains && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ + && diesel.heat.water.config.temp_cooling > 0 && diesel.heat.temperatura1 > diesel.heat.water.config.temp_cooling - (diesel.heat.water.is_warm ? 8 : 0)); + auto const PTC1{(diesel.heat.water.is_warm /*or PTC1p*/ ? 1 : 0)}; + diesel.heat.rpmwz = static_cast(PTC1 * (diesel.heat.fan_speed >= 0 ? rpm * diesel.heat.fan_speed : diesel.heat.fan_speed * -1)); + diesel.heat.zaluzje1 = diesel.heat.water.config.shutters ? PTC1 == 1 : true; // no shutters is an equivalent to having them open + auto const zaluzje1{(diesel.heat.zaluzje1 ? 1 : 0)}; // primary water circuit heat transfer values - auto const kf{obieg * kurek07 * (dizel_heat.kw * (0.3 + 0.7 * zaluzje1) * dizel_heat.rpmw + dizel_heat.kv * (0.3 + 0.7 * zaluzje1) * Vel / 3.6 + 3) + 2}; - auto const dTs{(dizel_heat.auxiliary_water_circuit ? dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr) / (gw * Cw) : - (dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr) + dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr)) / (gw * Cw))}; - auto const Qch{-kf * (dizel_heat.Tsr - dizel_heat.Te) + Qp}; + auto const kf{obieg * kurek07 * (diesel.heat.kw * (0.3 + 0.7 * zaluzje1) * diesel.heat.rpmw + diesel.heat.kv * (0.3 + 0.7 * zaluzje1) * Vel / 3.6 + 3) + 2}; + auto const dTs{(diesel.heat.auxiliary_water_circuit ? diesel.heat.kfs * (diesel.heat.Ts - diesel.heat.Tsr) / (gw * Cw) : + (diesel.heat.kfs * (diesel.heat.Ts - diesel.heat.Tsr) + diesel.heat.kfo2 * (diesel.heat.To - diesel.heat.Tsr)) / (gw * Cw))}; + auto const Qch{-kf * (diesel.heat.Tsr - diesel.heat.Te) + Qp}; auto const dTch{Qch / (gw * Cw)}; // primary water circuit heat transfers finalization - auto const Twe{dizel_heat.Twy + dTch * dt}; - dizel_heat.Twy = static_cast(Twe + dTs * dt); - dizel_heat.Tsr = static_cast(0.5 * (dizel_heat.Twy + Twe)); - dizel_heat.temperatura1 = dizel_heat.Twy; + auto const Twe{diesel.heat.Twy + dTch * dt}; + diesel.heat.Twy = static_cast(Twe + dTs * dt); + diesel.heat.Tsr = static_cast(0.5 * (diesel.heat.Twy + Twe)); + diesel.heat.temperatura1 = diesel.heat.Twy; /* fuelConsumed = fuelConsumed + ( Ge * 0.5 ); diff --git a/physics/components/dieselengine.h b/physics/components/dieselengine.h new file mode 100644 index 000000000..07937ffcb --- /dev/null +++ b/physics/components/dieselengine.h @@ -0,0 +1,185 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +// the diesel engine of a vehicle and its hydraulic transmission: their definition from the .fiz and their state. +// a vehicle has them whatever its drive; the drives of a diesel engine (DieselEngine, DieselElectric) use them + +#pragma once + +#include + +// the heat of a diesel engine: its cooling circuits, their fans and shutters, the temperatures +struct EngineHeat +{ + // input, state of relevant devices + bool cooling{false}; // TODO: user controlled device, implement + // bool okienko { true }; // window in the engine compartment + // system configuration + bool auxiliary_water_circuit{false}; // cooling system has an extra water circuit + double fan_speed{0.075}; // cooling fan rpm; either fraction of engine rpm, or absolute value if negative + // heat exchange factors + double kw{0.35}; + double kv{0.6}; + double kfe{1.0}; + double kfs{80.0}; + double kfo{25.0}; + double kfo2{25.0}; + // system parts + struct fluid_circuit_t + { + + struct circuit_config_t + { + float temp_min{-1}; // lowest accepted temperature + float temp_max{-1}; // highest accepted temperature + float temp_cooling{-1}; // active cooling activation point + float temp_flow{-1}; // fluid flow activation point + bool shutters{false}; // the radiator has shutters to assist the cooling + }; + circuit_config_t config; + bool is_cold{false}; // fluid is too cold + bool is_warm{false}; // fluid is too hot + bool is_hot{false}; // fluid temperature crossed cooling threshold + bool is_flowing{false}; // fluid is being pushed through the circuit + }; + fluid_circuit_t water; + fluid_circuit_t water_aux; + fluid_circuit_t oil; + fluid_circuit_t engine; + // output, state of affected devices + bool PA{false}; // malfunction flag + float rpmw{0.0}; // current main circuit fan revolutions + float rpmwz{0.0}; // desired main circuit fan revolutions + bool zaluzje1{false}; + float rpmw2{0.0}; // current auxiliary circuit fan revolutions + float rpmwz2{0.0}; // desired auxiliary circuit fan revolutions + bool zaluzje2{false}; + // output, temperatures + float Te{15.0}; // ambient temperature TODO: get it from environment data + // NOTE: by default the engine is initialized in warm, startup-ready state + float Ts{50.0}; // engine temperature + float To{45.0}; // oil temperature + float Tsr{50.0}; // main circuit radiator temperature (?) + float Twy{50.0}; // main circuit water temperature + float Tsr2{40.0}; // secondary circuit radiator temperature (?) + float Twy2{40.0}; // secondary circuit water temperature + float temperatura1{50.0}; + float temperatura2{40.0}; + float powerfactor{1.0}; // coefficient of heat generation for engines other than su45 + // engine overheat threshold + float engine_max_temp{-1}; // maximum acceptable engine temperature, triggers overheat lamp when exceeded + bool engine_is_hot{false}; // engine temperature crossed cooling threshold +}; + +// the diesel engine, its governor, its clutch and its fuel (the dizel_ values before) +struct DieselEngine +{ + // the definition (the Engine section of the .fiz) + double maxMoment = 1.0; // Mmax + double maxMomentRevolutions = 1.0; // nMmax + double maxRevolutionsMoment = 2.0; // Mnmax + double maxRevolutions = 2.0; // nmax + double nominalFill = 0.0; + std::map momentTable; + std::map speedMaxRevolutionsTable; // vel2nmax + /*parametry aproksymacji silnika spalinowego*/ + double standingMoment = 0.0; /*moment oporow ruchu silnika dla enrot=0*/ + double cutoffRevolutions = 0.0; /*predkosc obrotowa zadzialania ogranicznika predkosci*/ + double minRevolutions = 0.0; /*najmniejsza dopuszczalna predkosc obrotowa*/ + double hydraulicMinRevolutions = 0.0; /*najmniejsza dopuszczalna predkosc obrotowa w czasie jazdy na hydro */ + double hydraulicMinRevolutionsFactor = 0.0; /*wspolczynnik wzrostu obrotow minimalnych hydro zaleznosci od zadanego procentu*/ + double retarderRevolutions = 0.0; /*obroty pracy podczas hamowania retarderem*/ + double governorAcceleration = 999.0; /*tempo zwiększania prędkości przez regulator dizla */ + double fullEngageMinVelocity = 0.0; /*najmniejsza predkosc przy jezdzie ze sprzeglem bez poslizgu*/ + double converterReleaseVelocity = 3.0; /*predkosc progowa rozlaczenia przetwornika momentu*/ + double shaftInertia = 1.0; /*moment bezwladnosci walu itp*/ + double revolutionsDecreaseRate{2.0}; + double nominalFuelConsumptionRate = 250.0; /*jednostkowe zużycie paliwa przy mocy nominalnej, wczytywane z fiz, g/kWh*/ + double fuelConsumption = 0.0; /*współczynnik zużycia paliwa przeliczony do jednostek maszynowych, l/obrót*/ + double clutchDiameter = 0.5; + double clutchMaxForce = 6000.0; + double clutchFriction = 0.5; /*parametry sprzegla*/ + // the starter turns the engine a while before it fires: smoke comes out only after SmokeDelay (the Engine section of the vehicle's + // .fiz, seconds from the start of the spin up) has passed. 0, the default, lets it out as soon as the starter turns, as before eu07/maszyna#523 + double smokeDelay{0.0}; + + // the state + double fill = 0.0; /*napelnienie*/ + double clutchState = 0.0; /*sprzeglo skrzyni biegow: 0 - luz, 1 - wlaczone, 0.5 - wlaczone 50% (z poslizgiem)*/ + double clutchPressure = 0.0; /*sprzeglo skrzyni biegow: aktualny docisk*/ + double automaticGearShift = 0.0; /*0 - bez zmiany, -1 zmiana na nizszy +1 zmiana na wyzszy*/ + bool startupRequested{false}; // engine startup procedure request indicator + bool ignitionRequested{false}; // engine ignition request indicator + bool spinningUp{false}; // engine spin up to idle speed flag + double firingCountdown{0.0}; // seconds left until the engine being started fires, 0 once it runs on its own + double clutchSlip = 0.0; /*roznica predkosci katowych tarcz sprzegla*/ + double previousRevolutions = 0.0; /*poredkosc na potrzeby obliczen sprzegiel*/ + double torque = 0.0; /*aktualny moment obrotowy silnika spalinowego*/ + double power = 0.0; /*aktualna moc silnika spalinowego*/ + double governorMinRevolutions = 0.0; /*predkosc regulatora minimalna, zmienna w hydro*/ + double governorMaxRevolutions = 0.0; /*predkosc regulatora maksymalna, zmienna w hydro*/ + double fuelConsumptionActual = 0.0; /*chwilowe spalanie paliwa w l/h*/ + double fuelConsumedTotal = 0.0; /*ilość paliwa zużyta od początku symulacji, l*/ + EngineHeat heat; +}; + +// the hydraulic torque converter (the hydro_TC values before) +struct TorqueConverter +{ + // the definition + bool present = false; /*obecnosc hydraulicznego przetwornika momentu*/ + double maxTorqueRatio = 2.0; /*maksymalne wzmocnienie momentu*/ + double couplingPoint = 0.85; /*wzgledna predkosc zasprzeglenia*/ + double lockupTorque = 3000.0; /*moment graniczny sprzegla blokujacego*/ + double lockupRate = 1.0; /*szybkosc zalaczania sprzegla blokujacego*/ + double unlockRate = 1.0; /*szybkosc rozlaczania sprzegla blokujacego*/ + double fillRateIncrease = 1.0; /*szybkosc napelniania sprzegla*/ + double fillRateDecrease = 1.0; /*szybkosc oprozniania sprzegla*/ + double torqueInIn = 4.5; /*stala momentu proporcjonalnego do kwadratu obrotow wejsciowych*/ + double torqueInOut = 0.0; /*stala momentu proporcjonalnego do roznica obrotow wejsciowych i wyjsciowych*/ + double torqueOutOut = 0.0; /*stala momentu proporcjonalnego do kwadratu obrotow wyjsciowych*/ + double lockupSpeed = 1.0; /*prog predkosci zalaczania sprzegla blokujacego*/ + double unlockSpeed = 1.0; /*prog predkosci rozlaczania sprzegla blokujacego*/ + std::map table; /*tablica przetwornika momentu*/ + + // the state + double fill = 0.0; /*napelnienie*/ + bool lockedUp = false; /*zapiecie sprzegla*/ + double torqueIn = 0.0; /*moment*/ + double torqueOut = 0.0; /*moment*/ + double torqueRatio = 1.0; /*aktualne przelozenie momentu*/ + double request = 0.0; /*zadanie sily*/ + double revolutionsIn = 0.0; /*predkosc obrotowa walu wejsciowego*/ + double revolutionsOut = 0.0; /*predkosc obrotowa walu wyjsciowego*/ +}; + +// the hydraulic retarder (the hydro_R values before) +struct Retarder +{ + // the definition + bool present = false; /*obecnosc retardera*/ + int placement = 0; /*umiejscowienie retardera: 0 - za skrzynia biegow, 1 - miedzy przetwornikiem a biegami, 2 - przed skrzynia biegow */ + double torqueInIn = 1.0; /*stala momentu proporcjonalnego do kwadratu obrotow wejsciowych*/ + double maxTorque = 1.0; /*maksymalny moment retardera*/ + double maxPower = 1.0; /*maksymalna moc retardera - ogranicza moment*/ + double fillRateIncrease = 1.0; /*szybkosc napelniania sprzegla*/ + double fillRateDecrease = 1.0; /*szybkosc oprozniania sprzegla*/ + double minVelocity = 1.0; /*minimalna predkosc, przy ktorej retarder dziala*/ + double engageVelocity = 1.0; /*minimalna predkosc hamowania, przy ktorej sprzeglo jest wciaz wlaczone*/ + bool hasClutch = false; /*czy retarder ma rozłączalne sprzęgło*/ + double clutchSpeed = 10.0; /*szybkość narastania obrotów po włączeniu sprzęgła retardera*/ + bool withIndividual = false; /*czy dla autobusów jest to łączone*/ + + // the state + double fill = 0.0; /*napelnienie*/ + double torque = 0.0; /*moment*/ + double request = 0.0; /*zadanie sily hamowania*/ + double revolutions = 0.0; /*predkosc obrotowa retardera*/ + bool clutchActive = false; /*czy retarder jest napędzany*/ +}; diff --git a/physics/components/drive.cpp b/physics/components/drive.cpp index 55284f396..16e2c5294 100644 --- a/physics/components/drive.cpp +++ b/physics/components/drive.cpp @@ -71,7 +71,7 @@ namespace // the radiator fans of a diesel engine follow their demanded revolutions while the engine runs, and run down without it void updateRadiatorFans(TMoverParameters &vehicle, double const dt) { - auto &heat{vehicle.dizel_heat}; + auto &heat{vehicle.diesel.heat}; if (true == vehicle.Mains) { heat.rpmw += static_cast(std::clamp(heat.rpmwz - heat.rpmw, -100.f, 50.f) * dt); @@ -164,12 +164,12 @@ class DieselMechanicalDrive final : public TractionDrive public: double UpdateEnginePower(TMoverParameters &vehicle) const override { - vehicle.dizel_Power = vehicle.Mm * vehicle.enrot * (2.0 * M_PI / 1000.0); - vehicle.EnginePower = (vehicle.dizel_Mstand + vehicle.Mm) * vehicle.enrot * (2.0 * M_PI / 1000.0); + vehicle.diesel.power = vehicle.Mm * vehicle.enrot * (2.0 * M_PI / 1000.0); + vehicle.EnginePower = (vehicle.diesel.standingMoment + vehicle.Mm) * vehicle.enrot * (2.0 * M_PI / 1000.0); if (vehicle.MainCtrlPowerPos() > 1) { // dodatkowe opory z powodu sprezarki} - // dmoment -= dizel_Mstand * ( 0.2 * enrot / dizel_nmax ); //yB: skąd to w ogóle się bierze?! + // dmoment -= diesel.standingMoment * ( 0.2 * enrot / diesel.maxRevolutions ); //yB: skąd to w ogóle się bierze?! } return 0.0; } @@ -188,11 +188,11 @@ public: } double EngineIdleRpm(TMoverParameters const &vehicle) const override { - return vehicle.dizel_nmin * 60; + return vehicle.diesel.minRevolutions * 60; } double EngineMaxRpm(TMoverParameters const &vehicle) const override { - return vehicle.dizel_nmax * 60; + return vehicle.diesel.maxRevolutions * 60; } }; diff --git a/physics/components/electrics.cpp b/physics/components/electrics.cpp index a14840bc3..6634c2496 100644 --- a/physics/components/electrics.cpp +++ b/physics/components/electrics.cpp @@ -308,7 +308,7 @@ void TMoverParameters::MainsCheck(double const Deltatime) else { // optional automatic circuit start - if (MainsStart != start_t::manual && false == (Mains || dizel_startup)) + if (MainsStart != start_t::manual && false == (Mains || diesel.startupRequested)) { MainSwitch(true); } @@ -919,7 +919,7 @@ bool TMoverParameters::CompartmentLightsSwitchOff(bool State, range_t const Noti bool TMoverParameters::MainSwitch(bool const State, range_t const Notify) { - bool const initialstate{Mains || dizel_startup}; + bool const initialstate{Mains || diesel.startupRequested}; MainSwitch_(State); @@ -930,7 +930,7 @@ bool TMoverParameters::MainSwitch(bool const State, range_t const Notify) SendCtrlToNext(VehicleCommand::mainSwitch, State ? 1 : 0, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control); } - return (Mains || dizel_startup) != initialstate; + return (Mains || diesel.startupRequested) != initialstate; } void TMoverParameters::MainSwitch_(bool const State) @@ -953,7 +953,7 @@ void TMoverParameters::MainSwitch_(bool const State) if (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric) { // launch diesel engine startup procedure - dizel_startup = true; + diesel.startupRequested = true; } else { diff --git a/physics/components/fizparser.cpp b/physics/components/fizparser.cpp index 32a50d653..c4c0fab0a 100644 --- a/physics/components/fizparser.cpp +++ b/physics/components/fizparser.cpp @@ -327,7 +327,7 @@ bool TMoverParameters::readDMList(std::string const &line) double y = 0.0; parser >> x >> y; - dizel_Momentum_Table.emplace(x / 60.0, y); + diesel.momentTable.emplace(x / 60.0, y); return true; } @@ -347,7 +347,7 @@ bool TMoverParameters::readV2NMAXList(std::string const &line) double y = 0.0; parser >> x >> y; - dizel_vel2nmax_Table.emplace(x, y / 60.0); + diesel.speedMaxRevolutionsTable.emplace(x, y / 60.0); return true; } @@ -367,7 +367,7 @@ bool TMoverParameters::readHTCList(std::string const &line) double y = 0.0; parser >> x >> y; - hydro_TC_Table.emplace(x, y); + torqueConverter.table.emplace(x, y); return true; } diff --git a/physics/components/fizsections.cpp b/physics/components/fizsections.cpp index b567b3712..440532edf 100644 --- a/physics/components/fizsections.cpp +++ b/physics/components/fizsections.cpp @@ -1270,32 +1270,32 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input) void TMoverParameters::LoadFIZ_EngineDiesel(std::string const &Input) { - extract_value(dizel_nmin, "nmin", Input, ""); - dizel_nmin /= 60.0; - dizel_nreg_min = dizel_nmin * 0.98; - extract_value(dizel_nmin_hdrive, "nmin_hdrive", Input, ""); - dizel_nmin_hdrive /= 60.0; - if (dizel_nmin_hdrive == 0.0) + extract_value(diesel.minRevolutions, "nmin", Input, ""); + diesel.minRevolutions /= 60.0; + diesel.governorMinRevolutions = diesel.minRevolutions * 0.98; + extract_value(diesel.hydraulicMinRevolutions, "nmin_hdrive", Input, ""); + diesel.hydraulicMinRevolutions /= 60.0; + if (diesel.hydraulicMinRevolutions == 0.0) { - dizel_nmin_hdrive = dizel_nmin; + diesel.hydraulicMinRevolutions = diesel.minRevolutions; } - extract_value(dizel_nmin_hdrive_factor, "nmin_hdrive_factor", Input, ""); - dizel_nmin_hdrive_factor /= 60.0; - extract_value(dizel_nmin_retarder, "nmin_retarder", Input, ""); - dizel_nmin_retarder /= 60.0; - if (dizel_nmin_retarder == 0.0) + extract_value(diesel.hydraulicMinRevolutionsFactor, "nmin_hdrive_factor", Input, ""); + diesel.hydraulicMinRevolutionsFactor /= 60.0; + extract_value(diesel.retarderRevolutions, "nmin_retarder", Input, ""); + diesel.retarderRevolutions /= 60.0; + if (diesel.retarderRevolutions == 0.0) { - dizel_nmin_retarder = dizel_nmin; + diesel.retarderRevolutions = diesel.minRevolutions; } // TODO: unify naming scheme and sort out which diesel engine params are used where and how extract_value(nmax, "nmax", Input, ""); nmax /= 60.0; - extract_value(dizel_nmax_cutoff, "nmax_cutoff", Input, "0.0"); - dizel_nmax_cutoff /= 60.0; - extract_value(dizel_nreg_acc, "nreg_acc", Input, ""); - dizel_nreg_acc /= 60.0; - extract_value(dizel_AIM, "AIM", Input, "1.0"); - extract_value(dizel_RevolutionsDecreaseRate, "RPMDecRate", Input, ""); + extract_value(diesel.cutoffRevolutions, "nmax_cutoff", Input, "0.0"); + diesel.cutoffRevolutions /= 60.0; + extract_value(diesel.governorAcceleration, "nreg_acc", Input, ""); + diesel.governorAcceleration /= 60.0; + extract_value(diesel.shaftInertia, "AIM", Input, "1.0"); + extract_value(diesel.revolutionsDecreaseRate, "RPMDecRate", Input, ""); extract_value(engageupspeed, "EUS", Input, "0.5"); extract_value(engagedownspeed, "EDS", Input, "0.9"); @@ -1311,37 +1311,37 @@ void TMoverParameters::LoadFIZ_EngineDiesel(std::string const &Input) AnPos = 1.0 / AnPos; // im większa liczba, tym wolniej jedzie } } - extract_value(hydro_TC, "IsTC", Input, ""); - if (true == hydro_TC) + extract_value(torqueConverter.present, "IsTC", Input, ""); + if (true == torqueConverter.present) { - extract_value(hydro_TC_TMMax, "TC_TMMax", Input, ""); - extract_value(hydro_TC_CouplingPoint, "TC_CP", Input, ""); - extract_value(hydro_TC_LockupTorque, "TC_LT", Input, ""); - extract_value(hydro_TC_LockupRate, "TC_LR", Input, ""); - extract_value(hydro_TC_UnlockRate, "TC_ULR", Input, ""); - extract_value(hydro_TC_FillRateInc, "TC_FRI", Input, ""); - extract_value(hydro_TC_FillRateDec, "TC_FRD", Input, ""); - extract_value(hydro_TC_TorqueInIn, "TC_TII", Input, ""); - extract_value(hydro_TC_TorqueInOut, "TC_TIO", Input, ""); - extract_value(hydro_TC_TorqueOutOut, "TC_TOO", Input, ""); - extract_value(hydro_TC_LockupSpeed, "TC_LS", Input, ""); - extract_value(hydro_TC_UnlockSpeed, "TC_ULS", Input, ""); - extract_value(dizel_maxVelANS, "MaxVelANS", Input, ""); + extract_value(torqueConverter.maxTorqueRatio, "TC_TMMax", Input, ""); + extract_value(torqueConverter.couplingPoint, "TC_CP", Input, ""); + extract_value(torqueConverter.lockupTorque, "TC_LT", Input, ""); + extract_value(torqueConverter.lockupRate, "TC_LR", Input, ""); + extract_value(torqueConverter.unlockRate, "TC_ULR", Input, ""); + extract_value(torqueConverter.fillRateIncrease, "TC_FRI", Input, ""); + extract_value(torqueConverter.fillRateDecrease, "TC_FRD", Input, ""); + extract_value(torqueConverter.torqueInIn, "TC_TII", Input, ""); + extract_value(torqueConverter.torqueInOut, "TC_TIO", Input, ""); + extract_value(torqueConverter.torqueOutOut, "TC_TOO", Input, ""); + extract_value(torqueConverter.lockupSpeed, "TC_LS", Input, ""); + extract_value(torqueConverter.unlockSpeed, "TC_ULS", Input, ""); + extract_value(diesel.converterReleaseVelocity, "MaxVelANS", Input, ""); - extract_value(hydro_R, "IsRetarder", Input, ""); - if (true == hydro_R) + extract_value(retarder.present, "IsRetarder", Input, ""); + if (true == retarder.present) { - extract_value(hydro_R_Placement, "R_Place", Input, ""); - extract_value(hydro_R_TorqueInIn, "R_TII", Input, ""); - extract_value(hydro_R_MaxTorque, "R_MT", Input, ""); - extract_value(hydro_R_MaxPower, "R_MP", Input, ""); - extract_value(hydro_R_FillRateInc, "R_FRI", Input, ""); - extract_value(hydro_R_FillRateDec, "R_FRD", Input, ""); - extract_value(hydro_R_MinVel, "R_MinVel", Input, ""); - extract_value(hydro_R_EngageVel, "R_EngageVel", Input, ""); - extract_value(hydro_R_Clutch, "R_IsClutch", Input, ""); - extract_value(hydro_R_ClutchSpeed, "R_ClutchSpeed", Input, ""); - extract_value(hydro_R_WithIndividual, "R_WithIndividual", Input, ""); + extract_value(retarder.placement, "R_Place", Input, ""); + extract_value(retarder.torqueInIn, "R_TII", Input, ""); + extract_value(retarder.maxTorque, "R_MT", Input, ""); + extract_value(retarder.maxPower, "R_MP", Input, ""); + extract_value(retarder.fillRateIncrease, "R_FRI", Input, ""); + extract_value(retarder.fillRateDecrease, "R_FRD", Input, ""); + extract_value(retarder.minVelocity, "R_MinVel", Input, ""); + extract_value(retarder.engageVelocity, "R_EngageVel", Input, ""); + extract_value(retarder.hasClutch, "R_IsClutch", Input, ""); + extract_value(retarder.clutchSpeed, "R_ClutchSpeed", Input, ""); + extract_value(retarder.withIndividual, "R_WithIndividual", Input, ""); } } } @@ -1368,8 +1368,8 @@ void TMoverParameters::LoadFIZ_EngineDieselElectric(std::string const &Input) ImaxLo = 1; } extract_value(EngineHeatingRPM, "HeatingRPM", Input, ""); - extract_value(dizel_AIM, "AIM", Input, "1.25"); - extract_value(dizel_RevolutionsDecreaseRate, "RPMDecRate", Input, ""); + extract_value(diesel.shaftInertia, "AIM", Input, "1.25"); + extract_value(diesel.revolutionsDecreaseRate, "RPMDecRate", Input, ""); LoadFIZ_DieselElectricDynamicBrake(Input); } @@ -1432,36 +1432,36 @@ void TMoverParameters::LoadFIZ_EngineDieselShared(std::string const &Input) extract_value(OilPump.pressure_minimum, "OilMinPressure", Input, ""); extract_value(OilPump.pressure_maximum, "OilMaxPressure", Input, ""); // the time the starter turns the engine before it fires and smokes (eu07/maszyna#523) - extract_value(dizel_SmokeDelay, "SmokeDelay", Input, "0"); - dizel_SmokeDelay = std::max(0.0, dizel_SmokeDelay); + extract_value(diesel.smokeDelay, "SmokeDelay", Input, "0"); + diesel.smokeDelay = std::max(0.0, diesel.smokeDelay); // engine cooling factore - extract_value(dizel_heat.kw, "HeatKW", Input, ""); - extract_value(dizel_heat.kv, "HeatKV", Input, ""); - extract_value(dizel_heat.kfe, "HeatKFE", Input, ""); - extract_value(dizel_heat.kfs, "HeatKFS", Input, ""); - extract_value(dizel_heat.kfo, "HeatKFO", Input, ""); - extract_value(dizel_heat.kfo2, "HeatKFO2", Input, ""); + extract_value(diesel.heat.kw, "HeatKW", Input, ""); + extract_value(diesel.heat.kv, "HeatKV", Input, ""); + extract_value(diesel.heat.kfe, "HeatKFE", Input, ""); + extract_value(diesel.heat.kfs, "HeatKFS", Input, ""); + extract_value(diesel.heat.kfo, "HeatKFO", Input, ""); + extract_value(diesel.heat.kfo2, "HeatKFO2", Input, ""); // engine cooling systems - extract_value(dizel_heat.water.config.temp_min, "WaterMinTemperature", Input, ""); - extract_value(dizel_heat.water.config.temp_max, "WaterMaxTemperature", Input, ""); - extract_value(dizel_heat.water.config.temp_flow, "WaterFlowTemperature", Input, ""); - extract_value(dizel_heat.water.config.temp_cooling, "WaterCoolingTemperature", Input, ""); - extract_value(dizel_heat.water.config.shutters, "WaterShutters", Input, ""); - extract_value(dizel_heat.auxiliary_water_circuit, "WaterAuxCircuit", Input, ""); - extract_value(dizel_heat.water_aux.config.temp_min, "WaterAuxMinTemperature", Input, ""); - extract_value(dizel_heat.water_aux.config.temp_max, "WaterAuxMaxTemperature", Input, ""); - extract_value(dizel_heat.water_aux.config.temp_cooling, "WaterAuxCoolingTemperature", Input, ""); - extract_value(dizel_heat.water_aux.config.shutters, "WaterAuxShutters", Input, ""); - extract_value(dizel_heat.oil.config.temp_min, "OilMinTemperature", Input, ""); - extract_value(dizel_heat.oil.config.temp_max, "OilMaxTemperature", Input, ""); - extract_value(dizel_heat.engine_max_temp, "EngineMaxTemperature", Input, ""); - extract_value(dizel_heat.fan_speed, "WaterCoolingFanSpeed", Input, ""); + extract_value(diesel.heat.water.config.temp_min, "WaterMinTemperature", Input, ""); + extract_value(diesel.heat.water.config.temp_max, "WaterMaxTemperature", Input, ""); + extract_value(diesel.heat.water.config.temp_flow, "WaterFlowTemperature", Input, ""); + extract_value(diesel.heat.water.config.temp_cooling, "WaterCoolingTemperature", Input, ""); + extract_value(diesel.heat.water.config.shutters, "WaterShutters", Input, ""); + extract_value(diesel.heat.auxiliary_water_circuit, "WaterAuxCircuit", Input, ""); + extract_value(diesel.heat.water_aux.config.temp_min, "WaterAuxMinTemperature", Input, ""); + extract_value(diesel.heat.water_aux.config.temp_max, "WaterAuxMaxTemperature", Input, ""); + extract_value(diesel.heat.water_aux.config.temp_cooling, "WaterAuxCoolingTemperature", Input, ""); + extract_value(diesel.heat.water_aux.config.shutters, "WaterAuxShutters", Input, ""); + extract_value(diesel.heat.oil.config.temp_min, "OilMinTemperature", Input, ""); + extract_value(diesel.heat.oil.config.temp_max, "OilMaxTemperature", Input, ""); + extract_value(diesel.heat.engine_max_temp, "EngineMaxTemperature", Input, ""); + extract_value(diesel.heat.fan_speed, "WaterCoolingFanSpeed", Input, ""); // water heater extract_value(WaterHeater.config.temp_min, "HeaterMinTemperature", Input, ""); extract_value(WaterHeater.config.temp_max, "HeaterMaxTemperature", Input, ""); float pf{1235.f}; extract_value(pf, "NominalCoolingPower", Input, "1235"); - dizel_heat.powerfactor = 1235 / pf; + diesel.heat.powerfactor = 1235 / pf; } void TMoverParameters::LoadFIZ_Switches(std::string const &Input) @@ -1497,10 +1497,10 @@ void TMoverParameters::LoadFIZ_MotorParamTable(std::string const &Input) case TEngineType::DieselEngine: { - extract_value(dizel_minVelfullengage, "minVelfullengage", Input, ""); - extract_value(dizel_engageDia, "engageDia", Input, ""); - extract_value(dizel_engageMaxForce, "engageMaxForce", Input, ""); - extract_value(dizel_engagefriction, "engagefriction", Input, ""); + extract_value(diesel.fullEngageMinVelocity, "minVelfullengage", Input, ""); + extract_value(diesel.clutchDiameter, "engageDia", Input, ""); + extract_value(diesel.clutchMaxForce, "engageMaxForce", Input, ""); + extract_value(diesel.clutchFriction, "engagefriction", Input, ""); break; } default: @@ -1612,25 +1612,25 @@ void TMoverParameters::LoadFIZ_UCList(std::string const &Input) void TMoverParameters::LoadFIZ_DList(std::string const &Input) { - extract_value(dizel_Mmax, "Mmax", Input, ""); - extract_value(dizel_nMmax, "nMmax", Input, ""); - extract_value(dizel_Mnmax, "Mnmax", Input, ""); - extract_value(dizel_nmax, "nmax", Input, ""); - extract_value(dizel_nominalfill, "nominalfill", Input, ""); - extract_value(dizel_Mstand, "Mstand", Input, ""); - extract_value(dizel_NominalFuelConsumptionRate, "NomFuelConsRate", Input, ""); + extract_value(diesel.maxMoment, "Mmax", Input, ""); + extract_value(diesel.maxMomentRevolutions, "nMmax", Input, ""); + extract_value(diesel.maxRevolutionsMoment, "Mnmax", Input, ""); + extract_value(diesel.maxRevolutions, "nmax", Input, ""); + extract_value(diesel.nominalFill, "nominalfill", Input, ""); + extract_value(diesel.standingMoment, "Mstand", Input, ""); + extract_value(diesel.nominalFuelConsumptionRate, "NomFuelConsRate", Input, ""); - if (dizel_nMmax == dizel_nmax) + if (diesel.maxMomentRevolutions == diesel.maxRevolutions) { // HACK: guard against cases where nMmax == nmax, leading to division by 0 in momentum calculation - dizel_nMmax = dizel_nmax - 1.0 / 60.0; + diesel.maxMomentRevolutions = diesel.maxRevolutions - 1.0 / 60.0; } // Calculation of fuel consumption coefficient for futher calculation - double dizel_max_power = dizel_nmax * (dizel_Mnmax - dizel_Mstand) * M_PI * 2 * 0.001; // power in kW + double dizel_max_power = diesel.maxRevolutions * (diesel.maxRevolutionsMoment - diesel.standingMoment) * M_PI * 2 * 0.001; // power in kW double dizel_max_energy = dizel_max_power; // energy per one hour in kWh is equal to power in kW times 1 h double fuel_density = 850; // g/l - dizel_FuelConsumption = dizel_NominalFuelConsumptionRate * dizel_max_energy / fuel_density / dizel_nmax; + diesel.fuelConsumption = diesel.nominalFuelConsumptionRate * dizel_max_energy / fuel_density / diesel.maxRevolutions; } void TMoverParameters::LoadFIZ_FFList(std::string const &Input) diff --git a/physics/mover.h b/physics/mover.h index 25db352e1..6dd3eebe1 100644 --- a/physics/mover.h +++ b/physics/mover.h @@ -22,6 +22,7 @@ http://mozilla.org/MPL/2.0/. #include "vehicle/derailmotion.h" #include "vehicle/odometerreading.h" #include "physics/vehicletypes.h" +#include "physics/components/dieselengine.h" class TractionDrive; @@ -810,68 +811,6 @@ class TMoverParameters bool is_damaged{false}; // device is damaged }; - struct heat_data - { - // input, state of relevant devices - bool cooling{false}; // TODO: user controlled device, implement - // bool okienko { true }; // window in the engine compartment - // system configuration - bool auxiliary_water_circuit{false}; // cooling system has an extra water circuit - double fan_speed{0.075}; // cooling fan rpm; either fraction of engine rpm, or absolute value if negative - // heat exchange factors - double kw{0.35}; - double kv{0.6}; - double kfe{1.0}; - double kfs{80.0}; - double kfo{25.0}; - double kfo2{25.0}; - // system parts - struct fluid_circuit_t - { - - struct circuit_config_t - { - float temp_min{-1}; // lowest accepted temperature - float temp_max{-1}; // highest accepted temperature - float temp_cooling{-1}; // active cooling activation point - float temp_flow{-1}; // fluid flow activation point - bool shutters{false}; // the radiator has shutters to assist the cooling - }; - circuit_config_t config; - bool is_cold{false}; // fluid is too cold - bool is_warm{false}; // fluid is too hot - bool is_hot{false}; // fluid temperature crossed cooling threshold - bool is_flowing{false}; // fluid is being pushed through the circuit - }; - fluid_circuit_t water; - fluid_circuit_t water_aux; - fluid_circuit_t oil; - fluid_circuit_t engine; - // output, state of affected devices - bool PA{false}; // malfunction flag - float rpmw{0.0}; // current main circuit fan revolutions - float rpmwz{0.0}; // desired main circuit fan revolutions - bool zaluzje1{false}; - float rpmw2{0.0}; // current auxiliary circuit fan revolutions - float rpmwz2{0.0}; // desired auxiliary circuit fan revolutions - bool zaluzje2{false}; - // output, temperatures - float Te{15.0}; // ambient temperature TODO: get it from environment data - // NOTE: by default the engine is initialized in warm, startup-ready state - float Ts{50.0}; // engine temperature - float To{45.0}; // oil temperature - float Tsr{50.0}; // main circuit radiator temperature (?) - float Twy{50.0}; // main circuit water temperature - float Tsr2{40.0}; // secondary circuit radiator temperature (?) - float Twy2{40.0}; // secondary circuit water temperature - float temperatura1{50.0}; - float temperatura2{40.0}; - float powerfactor{1.0}; // coefficient of heat generation for engines other than su45 - // engine overheat threshold - float engine_max_temp{-1}; // maximum acceptable engine temperature, triggers overheat lamp when exceeded - bool engine_is_hot{false}; // engine temperature crossed cooling threshold - }; - struct spring_brake { std::shared_ptr Cylinder; @@ -1184,64 +1123,12 @@ class TMoverParameters int SmallCompressorPower = 0; /*Winger ZROBIC*/ bool Trafo = false; /*pojazd wyposażony w transformator*/ - /*-sekcja parametrow dla lokomotywy spalinowej z przekladnia mechaniczna*/ - double dizel_Mmax = 1.0; - double dizel_nMmax = 1.0; - double dizel_Mnmax = 2.0; - double dizel_nmax = 2.0; - double dizel_nominalfill = 0.0; - std::map dizel_Momentum_Table; - std::map dizel_vel2nmax_Table; - /*parametry aproksymacji silnika spalinowego*/ - double dizel_Mstand = 0.0; /*moment oporow ruchu silnika dla enrot=0*/ - /* dizel_auto_min, dizel_auto_max: real; {predkosc obrotowa przelaczania automatycznej skrzyni biegow*/ - double dizel_nmax_cutoff = 0.0; /*predkosc obrotowa zadzialania ogranicznika predkosci*/ - double dizel_nmin = 0.0; /*najmniejsza dopuszczalna predkosc obrotowa*/ - double dizel_nmin_hdrive = 0.0; /*najmniejsza dopuszczalna predkosc obrotowa w czasie jazdy na hydro */ - double dizel_nmin_hdrive_factor = 0.0; /*wspolczynnik wzrostu obrotow minimalnych hydro zaleznosci od zadanego procentu*/ - double dizel_nmin_retarder = 0.0; /*obroty pracy podczas hamowania retarderem*/ - double dizel_nreg_acc = 999.0; /*tempo zwiększania prędkości przez regulator dizla */ - double dizel_minVelfullengage = 0.0; /*najmniejsza predkosc przy jezdzie ze sprzeglem bez poslizgu*/ - double dizel_maxVelANS = 3.0; /*predkosc progowa rozlaczenia przetwornika momentu*/ - double dizel_AIM = 1.0; /*moment bezwladnosci walu itp*/ - double dizel_RevolutionsDecreaseRate{2.0}; - double dizel_NominalFuelConsumptionRate = 250.0; /*jednostkowe zużycie paliwa przy mocy nominalnej, wczytywane z fiz, g/kWh*/ - double dizel_FuelConsumption = 0.0; /*współczynnik zużycia paliwa przeliczony do jednostek maszynowych, l/obrót*/ - double dizel_FuelConsumptionActual = 0.0; /*chwilowe spalanie paliwa w l/h*/ - double dizel_FuelConsumptedTotal = 0.0; /*ilość paliwa zużyta od początku symulacji, l*/ - double dizel_engageDia = 0.5; - double dizel_engageMaxForce = 6000.0; - double dizel_engagefriction = 0.5; /*parametry sprzegla*/ + // the diesel engine, its torque converter and its retarder (physics/components/dieselengine.h) + DieselEngine diesel; + TorqueConverter torqueConverter; + Retarder retarder; double engagedownspeed = 0.9; double engageupspeed = 0.5; - /*parametry przetwornika momentu*/ - bool hydro_TC = false; /*obecnosc hydraulicznego przetwornika momentu*/ - double hydro_TC_TMMax = 2.0; /*maksymalne wzmocnienie momentu*/ - double hydro_TC_CouplingPoint = 0.85; /*wzgledna predkosc zasprzeglenia*/ - double hydro_TC_LockupTorque = 3000.0; /*moment graniczny sprzegla blokujacego*/ - double hydro_TC_LockupRate = 1.0; /*szybkosc zalaczania sprzegla blokujacego*/ - double hydro_TC_UnlockRate = 1.0; /*szybkosc rozlaczania sprzegla blokujacego*/ - double hydro_TC_FillRateInc = 1.0; /*szybkosc napelniania sprzegla*/ - double hydro_TC_FillRateDec = 1.0; /*szybkosc oprozniania sprzegla*/ - double hydro_TC_TorqueInIn = 4.5; /*stala momentu proporcjonalnego do kwadratu obrotow wejsciowych*/ - double hydro_TC_TorqueInOut = 0.0; /*stala momentu proporcjonalnego do roznica obrotow wejsciowych i wyjsciowych*/ - double hydro_TC_TorqueOutOut = 0.0; /*stala momentu proporcjonalnego do kwadratu obrotow wyjsciowych*/ - double hydro_TC_LockupSpeed = 1.0; /*prog predkosci zalaczania sprzegla blokujacego*/ - double hydro_TC_UnlockSpeed = 1.0; /*prog predkosci rozlaczania sprzegla blokujacego*/ - std::map hydro_TC_Table; /*tablica przetwornika momentu*/ - /*parametry retardera*/ - bool hydro_R = false; /*obecnosc retardera*/ - int hydro_R_Placement = 0; /*umiejscowienie retardera: 0 - za skrzynia biegow, 1 - miedzy przetwornikiem a biegami, 2 - przed skrzynia biegow */ - double hydro_R_TorqueInIn = 1.0; /*stala momentu proporcjonalnego do kwadratu obrotow wejsciowych*/ - double hydro_R_MaxTorque = 1.0; /*maksymalny moment retardera*/ - double hydro_R_MaxPower = 1.0; /*maksymalna moc retardera - ogranicza moment*/ - double hydro_R_FillRateInc = 1.0; /*szybkosc napelniania sprzegla*/ - double hydro_R_FillRateDec = 1.0; /*szybkosc oprozniania sprzegla*/ - double hydro_R_MinVel = 1.0; /*minimalna predkosc, przy ktorej retarder dziala*/ - double hydro_R_EngageVel = 1.0; /*minimalna predkosc hamowania, przy ktorej sprzeglo jest wciaz wlaczone*/ - bool hydro_R_Clutch = false; /*czy retarder ma rozłączalne sprzęgło*/ - double hydro_R_ClutchSpeed = 10.0; /*szybkość narastania obrotów po włączeniu sprzęgła retardera*/ - bool hydro_R_WithIndividual = false; /*czy dla autobusów jest to łączone*/ /*- dla lokomotyw spalinowo-elektrycznych -*/ double AnPos = 0.0; // pozycja sterowania dokladnego (analogowego) bool AnalogCtrl = false; // @@ -1448,7 +1335,6 @@ class TMoverParameters water_pump WaterPump; water_heater WaterHeater; bool WaterCircuitsLink{false}; // optional connection between water circuits - heat_data dizel_heat; std::array MotorBlowers; door_data Doors; float DoorsOpenWithPermitAfter{-1.f}; // remote open if permit button is held for specified time. NOTE: separate from door data as its cab control thing @@ -1598,42 +1484,6 @@ class TMoverParameters bool s_CAtestebrake = false; // hunter-091012: zmienna dla testu ca std::array, 4> PowerCircuits; // 24v, 110v, 3x400v and 3000v power circuits, voltage from local sources and current draw pairs - /*-zmienne dla lokomotywy spalinowej z przekladnia mechaniczna*/ - double dizel_fill = 0.0; /*napelnienie*/ - double dizel_engagestate = 0.0; /*sprzeglo skrzyni biegow: 0 - luz, 1 - wlaczone, 0.5 - wlaczone 50% (z poslizgiem)*/ - double dizel_engage = 0.0; /*sprzeglo skrzyni biegow: aktualny docisk*/ - double dizel_automaticgearstatus = 0.0; /*0 - bez zmiany, -1 zmiana na nizszy +1 zmiana na wyzszy*/ - bool dizel_startup{false}; // engine startup procedure request indicator - bool dizel_ignition{false}; // engine ignition request indicator - bool dizel_spinup{false}; // engine spin up to idle speed flag - // the starter turns the engine a while before it fires: smoke comes out only after SmokeDelay (the Engine section of the vehicle's - // .fiz, seconds from the start of the spin up) has passed. 0, the default, lets it out as soon as the starter turns, as before eu07/maszyna#523 - double dizel_SmokeDelay{0.0}; - double dizel_FiringCountdown{0.0}; // seconds left until the engine being started fires, 0 once it runs on its own - double dizel_engagedeltaomega = 0.0; /*roznica predkosci katowych tarcz sprzegla*/ - double dizel_n_old = 0.0; /*poredkosc na potrzeby obliczen sprzegiel*/ - double dizel_Torque = 0.0; /*aktualny moment obrotowy silnika spalinowego*/ - double dizel_Power = 0.0; /*aktualna moc silnika spalinowego*/ - double dizel_nreg_min = 0.0; /*predkosc regulatora minimalna, zmienna w hydro*/ - double dizel_nreg_max = 0.0; /*predkosc regulatora maksymalna, zmienna w hydro*/ - - /* - zmienne dla przetowrnika momentu */ - double hydro_TC_Fill = 0.0; /*napelnienie*/ - bool hydro_TC_Lockup = false; /*zapiecie sprzegla*/ - double hydro_TC_TorqueIn = 0.0; /*moment*/ - double hydro_TC_TorqueOut = 0.0; /*moment*/ - double hydro_TC_TMRatio = 1.0; /*aktualne przelozenie momentu*/ - double hydro_TC_Request = 0.0; /*zadanie sily*/ - double hydro_TC_nIn = 0.0; /*predkosc obrotowa walu wejsciowego*/ - double hydro_TC_nOut = 0.0; /*predkosc obrotowa walu wyjsciowego*/ - - /* - zmienne dla przetowrnika momentu */ - double hydro_R_Fill = 0.0; /*napelnienie*/ - double hydro_R_Torque = 0.0; /*moment*/ - double hydro_R_Request = 0.0; /*zadanie sily hamowania*/ - double hydro_R_n = 0.0; /*predkosc obrotowa retardera*/ - bool hydro_R_ClutchActive = false; /*czy retarder jest napędzany*/ - /*- zmienne dla lokomotyw z silnikami indukcyjnymi -*/ double eimic = 0; /*aktualna pozycja zintegrowanego sterowania jazda i hamowaniem*/ double eimic_analog = 0; /*pozycja zadajnika analogowa*/ @@ -2329,7 +2179,7 @@ class TMoverParameters double dizel_DigitalFill(double dt); double dizel_GovernorFill(int mcp, double realfill) const; double dizel_GovernorRevolutions(int mcp, double &realfill) const; - double dizel_Momentum(double dizel_fill, double n, double dt); + double dizel_Momentum(double Fill, double n, double dt); void hydro_TCFillCheck(double dt); void hydro_TCTorque(); double dizel_MomentumRetarder(double n, double dt); // moment hamowania retardera diff --git a/rendering/particles.cpp b/rendering/particles.cpp index 67d81f3c2..391dd1903 100644 --- a/rendering/particles.cpp +++ b/rendering/particles.cpp @@ -346,19 +346,19 @@ smoke_source::launch_scales( float &Velocity, float &Opacity ) const { Opacity = 1.f; if( m_ownertype != owner_type::vehicle ) { return; } - Opacity = static_cast(m_owner.vehicle->MoverParameters->dizel_fill); + Opacity = static_cast(m_owner.vehicle->MoverParameters->diesel.fill); if (m_owner.vehicle->MoverParameters->EngineType == TEngineType::DieselElectric) { - if (m_owner.vehicle->MoverParameters->dizel_spinup == true) + if (m_owner.vehicle->MoverParameters->diesel.spinningUp == true) { - Velocity = static_cast(0.38*(((m_owner.vehicle->MoverParameters->enrot)/2)*0.5)); // / m_owner.vehicle->MoverParameters->dizel_fill *0.01)) ; + Velocity = static_cast(0.38*(((m_owner.vehicle->MoverParameters->enrot)/2)*0.5)); // / m_owner.vehicle->MoverParameters->diesel.fill *0.01)) ; } else { - Velocity = static_cast((((m_owner.vehicle->MoverParameters->enrot)/60)*0.6) * (m_owner.vehicle->MoverParameters->EnginePower *0.03)); // / m_owner.vehicle->MoverParameters->dizel_fill *0.01)) ; - //Particle.velocity *= m_owner.vehicle->GetVelocity(); // / m_owner.vehicle->MoverParameters->dizel_fill *0.01)) ; + Velocity = static_cast((((m_owner.vehicle->MoverParameters->enrot)/60)*0.6) * (m_owner.vehicle->MoverParameters->EnginePower *0.03)); // / m_owner.vehicle->MoverParameters->diesel.fill *0.01)) ; + //Particle.velocity *= m_owner.vehicle->GetVelocity(); // / m_owner.vehicle->MoverParameters->diesel.fill *0.01)) ; } } diff --git a/simulation/blackboxrecorder.cpp b/simulation/blackboxrecorder.cpp index 5d21c47d0..6b573e1ea 100644 --- a/simulation/blackboxrecorder.cpp +++ b/simulation/blackboxrecorder.cpp @@ -87,7 +87,7 @@ std::uint32_t devices_of(TMoverParameters const &Occupied, TMoverParameters cons on(Occupied.Hamulec != nullptr && Occupied.Hamulec->Releaser(), device::brake_releaser) | on(Controlling.FuelPump.is_active, device::fuel_pump) | on(Controlling.OilPump.is_active, device::oil_pump) | on(Controlling.MotorBlowers[end::front].is_active || Controlling.MotorBlowers[end::rear].is_active, device::motor_blowers) | - on(Controlling.dizel_heat.engine_is_hot, device::engine_hot) | on(Controlling.SpeedCtrl && Controlling.SpeedCtrlUnit.IsActive, device::speed_control); + on(Controlling.diesel.heat.engine_is_hot, device::engine_hot) | on(Controlling.SpeedCtrl && Controlling.SpeedCtrlUnit.IsActive, device::speed_control); } std::uint8_t engine_of(TMoverParameters const &Mover) { @@ -480,17 +480,17 @@ void blackbox_recorder::write_cab() { sample.driver_valve = occupied->Handle != nullptr ? static_cast(occupied->Handle->GetCP()) : 0.0f; sample.feed_pipe = static_cast(occupied->ScndPipePress); sample.oil_pressure = controlling->OilPump.pressure; - sample.water_temperature = controlling->dizel_heat.Twy; - sample.oil_temperature = controlling->dizel_heat.To; - sample.engine_temperature = controlling->dizel_heat.Ts; + sample.water_temperature = controlling->diesel.heat.Twy; + sample.oil_temperature = controlling->diesel.heat.To; + sample.engine_temperature = controlling->diesel.heat.Ts; sample.speed_control_kmh = controlling->SpeedCtrl ? static_cast(controlling->SpeedCtrlUnit.DesiredVelocity) : 0.0f; sample.engine_power = static_cast(controlling->EnginePower); sample.hand_brake = static_cast(std::clamp(occupied->ManualBrakePos, -128, 127)); sample.brake_mode = static_cast(occupied->BrakeOpModeFlag); sample.horn = static_cast(occupied->WarningSignal); sample.integrated_controller = static_cast(controlling->eimic); - sample.clutch = static_cast(controlling->dizel_engagestate); - sample.converter_fill = static_cast(controlling->hydro_TC_Fill); + sample.clutch = static_cast(controlling->diesel.clutchState); + sample.converter_fill = static_cast(controlling->torqueConverter.fill); // the brakes of the whole train: the highest of its cylinders, from the head to the tail auto brakes{occupied->BrakePress}; for (auto const *each{owner != nullptr ? owner->Vehicle(end::front) : nullptr}; each != nullptr; each = each->Next()) diff --git a/tests/unit/golden.cpp b/tests/unit/golden.cpp index 72cd31f9b..ce4225906 100644 --- a/tests/unit/golden.cpp +++ b/tests/unit/golden.cpp @@ -66,7 +66,7 @@ std::vector traction() { {"EngineVoltage", [](auto const &M) { return M.EngineVoltage; }}, {"EnginePower", [](auto const &M) { return M.EnginePower; }}, {"enrot", [](auto const &M) { return M.enrot; }}, - {"dizel_fill", [](auto const &M) { return M.dizel_fill; }}, + {"dizel_fill", [](auto const &M) { return M.diesel.fill; }}, {"eimv_pr", [](auto const &M) { return M.eimv_pr; }}, {"DynamicBrakeFlag", [](auto const &M) { return M.DynamicBrakeFlag ? 1.0 : 0.0; }}, }; diff --git a/tests/unit/invariants.cpp b/tests/unit/invariants.cpp index 4fafeb04d..e742fce41 100644 --- a/tests/unit/invariants.cpp +++ b/tests/unit/invariants.cpp @@ -84,14 +84,14 @@ std::vector const &invariants() { [](auto const &M, double, auto const *) { return M.Power >= 0.01 || std::abs(M.Ft) < 1.0; }, [](auto const &M) { return values({{"Power", M.Power}, {"Ft", M.Ft}}); }}, {"engine fill between none and full", - [](auto const &M, double, auto const *) { return M.dizel_fill >= 0.0 && M.dizel_fill <= 1.0; }, - [](auto const &M) { return values({{"dizel_fill", M.dizel_fill}}); }}, + [](auto const &M, double, auto const *) { return M.diesel.fill >= 0.0 && M.diesel.fill <= 1.0; }, + [](auto const &M) { return values({{"dizel_fill", M.diesel.fill}}); }}, {"diesel engine turning forward, no faster than its top speed", [](auto const &M, double, auto const *) { // the governor lets it overshoot a little (the SN61 by 1%) - return M.EngineType != TEngineType::DieselEngine || (M.enrot >= 0.0 && M.enrot <= 1.05 * M.dizel_nmax); + return M.EngineType != TEngineType::DieselEngine || (M.enrot >= 0.0 && M.enrot <= 1.05 * M.diesel.maxRevolutions); }, - [](auto const &M) { return values({{"enrot", M.enrot}, {"dizel_nmax", M.dizel_nmax}}); }}, + [](auto const &M) { return values({{"enrot", M.enrot}, {"dizel_nmax", M.diesel.maxRevolutions}}); }}, {"battery no higher than its nominal voltage", [](auto const &M, double, auto const *) { return M.NominalBatteryVoltage <= 0.0 || M.BatteryVoltage <= 1.05 * M.NominalBatteryVoltage; }, [](auto const &M) { return values({{"BatteryVoltage", M.BatteryVoltage}, {"NominalBatteryVoltage", M.NominalBatteryVoltage}}); }}, diff --git a/tests/unit/test_cab.cpp b/tests/unit/test_cab.cpp index c0896e6e3..ca58d6a65 100644 --- a/tests/unit/test_cab.cpp +++ b/tests/unit/test_cab.cpp @@ -60,7 +60,7 @@ TEST_CASE("cab: the lamps of the overload relay and the starting resistors, read TEST_CASE("cab: the engine's idle speed, and the ET42's second controller shown in its dynamic brake") { vehicle sn61{definition::fiz("sn61_v2/sn61")}; - CHECK(sn61->EngineIdleRPM() == doctest::Approx(sn61->dizel_nmin * 60.0)); + CHECK(sn61->EngineIdleRPM() == doctest::Approx(sn61->diesel.minRevolutions * 60.0)); vehicle su45{definition::fiz("su45_v2/301d")}; CHECK(su45->EngineIdleRPM() == doctest::Approx(su45->DElist[su45->MainCtrlNoPowerPos()].RPM)); vehicle eu07{definition::fiz("4e_v1/4e")}; diff --git a/tests/unit/test_diesel.cpp b/tests/unit/test_diesel.cpp index a902a0195..847633ec0 100644 --- a/tests/unit/test_diesel.cpp +++ b/tests/unit/test_diesel.cpp @@ -15,15 +15,15 @@ namespace { std::vector heat() { return { - {"Ts", [](auto const &M) { return M.dizel_heat.Ts; }}, - {"To", [](auto const &M) { return M.dizel_heat.To; }}, - {"Twy", [](auto const &M) { return M.dizel_heat.Twy; }}, - {"Twy2", [](auto const &M) { return M.dizel_heat.Twy2; }}, - {"PA", [](auto const &M) { return M.dizel_heat.PA ? 1.0 : 0.0; }}, + {"Ts", [](auto const &M) { return M.diesel.heat.Ts; }}, + {"To", [](auto const &M) { return M.diesel.heat.To; }}, + {"Twy", [](auto const &M) { return M.diesel.heat.Twy; }}, + {"Twy2", [](auto const &M) { return M.diesel.heat.Twy2; }}, + {"PA", [](auto const &M) { return M.diesel.heat.PA ? 1.0 : 0.0; }}, {"WaterHeater", [](auto const &M) { return M.WaterHeater.is_active ? 1.0 : 0.0; }}, {"WaterPump", [](auto const &M) { return M.WaterPump.is_active ? 1.0 : 0.0; }}, - {"zaluzje1", [](auto const &M) { return M.dizel_heat.zaluzje1 ? 1.0 : 0.0; }}, - {"zaluzje2", [](auto const &M) { return M.dizel_heat.zaluzje2 ? 1.0 : 0.0; }}, + {"zaluzje1", [](auto const &M) { return M.diesel.heat.zaluzje1 ? 1.0 : 0.0; }}, + {"zaluzje2", [](auto const &M) { return M.diesel.heat.zaluzje2 ? 1.0 : 0.0; }}, }; } @@ -43,12 +43,12 @@ TEST_CASE("diesel: an engine too cold to start, warmed by its heater") { auto &locomotive{scenario.cab()}; locomotive.dizel_HeatSet(-10.f); CHECK(scenario.start_up() == starts); - CHECK(locomotive.dizel_heat.PA != starts); + CHECK(locomotive.diesel.heat.PA != starts); CHECK(locomotive.WaterHeater.is_active); scenario.act("heating"); scenario.wait(1200.0); - CHECK_FALSE(locomotive.dizel_heat.PA); - CHECK(locomotive.dizel_heat.Twy > 50.f); + CHECK_FALSE(locomotive.diesel.heat.PA); + CHECK(locomotive.diesel.heat.Twy > 50.f); CHECK(scenario.start_up()); scenario.check(); } @@ -70,13 +70,13 @@ TEST_CASE("diesel: an engine started hot, and run at full power") { auto &locomotive{scenario.cab()}; locomotive.dizel_HeatSet(88.f); CHECK(scenario.start_up() == starts); - CHECK(locomotive.dizel_heat.PA != starts); + CHECK(locomotive.diesel.heat.PA != starts); if (starts) { scenario.get_going(); scenario.full_power(300.0); CHECK(locomotive.Vel > 50.0); - CHECK(locomotive.dizel_heat.zaluzje1); - CHECK(locomotive.dizel_heat.Twy < locomotive.dizel_heat.water.config.temp_max); + CHECK(locomotive.diesel.heat.zaluzje1); + CHECK(locomotive.diesel.heat.Twy < locomotive.diesel.heat.water.config.temp_max); } scenario.check(); } @@ -94,7 +94,7 @@ TEST_CASE("diesel: the 214M railbus's torque converter, gears and retarder") { scenario.full_power(60.0); CHECK(railbus.MainCtrlPos == 5); CHECK(railbus.eimic_real == doctest::Approx(1.0)); - CHECK(railbus.hydro_TC_Lockup); + CHECK(railbus.torqueConverter.lockedUp); CHECK(railbus.ScndCtrlActualPos == railbus.ScndCtrlPosNo); struct position { double eimic; @@ -109,8 +109,8 @@ TEST_CASE("diesel: the 214M railbus's torque converter, gears and retarder") { railbus.DecMainCtrl(1); scenario.wait(8.0); CHECK(railbus.eimic_real == doctest::Approx(eimic)); - CHECK((railbus.hydro_R_Fill > 0.99) == retarder); - CHECK((railbus.hydro_R_Torque > 1000.0) == retarder); + CHECK((railbus.retarder.fill > 0.99) == retarder); + CHECK((railbus.retarder.torque > 1000.0) == retarder); CHECK((railbus.BrakePress > 2.0) == air); } scenario.act("position 0"); @@ -160,7 +160,7 @@ TEST_CASE("diesel: the 214M railbus's speed control, up to the speed of a button 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.hydro_R_Fill == doctest::Approx(1.0)); + CHECK(railbus.retarder.fill == doctest::Approx(1.0)); CHECK(railbus.BrakePress < 0.1); CHECK_FALSE(railbus.SpeedCtrlUnit.BrakeInterventionBraking); scenario.wait(60.0); diff --git a/tests/unit/test_engine_shutdown.cpp b/tests/unit/test_engine_shutdown.cpp index 9230330f4..e9629c4ed 100644 --- a/tests/unit/test_engine_shutdown.cpp +++ b/tests/unit/test_engine_shutdown.cpp @@ -29,7 +29,7 @@ TEST_CASE("engine shutdown: the shunter starts with the starter button") { REQUIRE(shunter->FuelPump.start_type == start_t::automatic); CHECK(shunter->Mains); CHECK(shunter->FuelPump.is_active); - CHECK(shunter->enrot > 0.9 * shunter->dizel_nmin); + CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions); } TEST_CASE("engine shutdown: neither the fuel pump switch nor the battery switch stop the engine") { @@ -41,7 +41,7 @@ TEST_CASE("engine shutdown: neither the fuel pump switch nor the battery switch shunter.run(10.0); CHECK(shunter->Power110vIsAvailable); // the converter run by the engine keeps feeding the fuel pump CHECK(shunter->Mains); - CHECK(shunter->enrot > 0.9 * shunter->dizel_nmin); + CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions); } TEST_CASE("engine shutdown: the command opening the main circuit stops the engine and it stays stopped") { @@ -62,7 +62,7 @@ TEST_CASE("engine shutdown: the engine starts again after it was stopped") { shunter->MainSwitch(true); shunter.run(15.0); CHECK(shunter->Mains); - CHECK(shunter->enrot > 0.9 * shunter->dizel_nmin); + CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions); } TEST_CASE("engine shutdown: vehicles without a diesel keep ignoring the command with only the button closing the circuit") { diff --git a/tests/unit/test_engine_start.cpp b/tests/unit/test_engine_start.cpp index 59bb6af0e..a7aeff790 100644 --- a/tests/unit/test_engine_start.cpp +++ b/tests/unit/test_engine_start.cpp @@ -39,7 +39,7 @@ void prepare(consist &Train) { } bool running(TMoverParameters const &Vehicle) { - return Vehicle.Mains && Vehicle.enrot > 0.5 * Vehicle.dizel_nmin; + return Vehicle.Mains && Vehicle.enrot > 0.5 * Vehicle.diesel.minRevolutions; } // the time step of the train in the loops below @@ -185,7 +185,7 @@ TEST_CASE("engine start: the switch of another vehicle is held for the vehicle's hold(train, switchb, &second, 5.0); train.run(5.0); CHECK_FALSE(second.Mains); - CHECK_FALSE(second.dizel_startup); + CHECK_FALSE(second.diesel.startupRequested); prepare(train); // let go too early diff --git a/tests/unit/test_oil_pump.cpp b/tests/unit/test_oil_pump.cpp index a5f623233..aaac2e871 100644 --- a/tests/unit/test_oil_pump.cpp +++ b/tests/unit/test_oil_pump.cpp @@ -31,11 +31,11 @@ TEST_CASE("oil pump: the pump started with the engine start procedure stops once REQUIRE(loco->OilPump.start_type == start_t::automatic); loco->Power24vIsAvailable = true; - loco->dizel_startup = true; // starter button pressed + loco->diesel.startupRequested = true; // starter button pressed loco->OilPumpCheck(0.01); CHECK(loco->OilPump.is_active); - loco->dizel_startup = false; // start procedure done, the pump keeps working until the engine runs + loco->diesel.startupRequested = false; // start procedure done, the pump keeps working until the engine runs loco->OilPumpCheck(0.01); CHECK(loco->OilPump.is_active); diff --git a/tests/unit/test_smoke.cpp b/tests/unit/test_smoke.cpp index 281b5dbf6..e8c31d87b 100644 --- a/tests/unit/test_smoke.cpp +++ b/tests/unit/test_smoke.cpp @@ -28,7 +28,7 @@ test::vehicle diesel() { TEST_CASE("smoke: a vehicle taken off the tracks puffs no more (#90)") { auto vehicle{diesel()}; - SUBCASE("engine starting") { vehicle->dizel_spinup = true; } + SUBCASE("engine starting") { vehicle->diesel.spinningUp = true; } SUBCASE("engine idling") { vehicle->DirAbsolute = 0; } SUBCASE("engine under load") { vehicle->DirAbsolute = 1; @@ -68,7 +68,7 @@ TEST_CASE("smoke: the engine adds to the steady rate of the source") { CHECK(working > steady); // the faster the starting engine turns, the more it puffs - vehicle->dizel_spinup = true; + vehicle->diesel.spinningUp = true; vehicle->enrot = 100.0; auto const slow{smoke::vehicle_spawn_count(vehicle.mover(), true, source, update)}; vehicle->enrot = 400.0; @@ -77,7 +77,7 @@ TEST_CASE("smoke: the engine adds to the steady rate of the source") { TEST_CASE("smoke: the pending particles never outgrow the room of the source") { auto vehicle{diesel()}; - vehicle->dizel_spinup = true; + vehicle->diesel.spinningUp = true; vehicle->enrot = 100000.0; auto rate{source}; rate.pending = 99.f; @@ -87,14 +87,14 @@ TEST_CASE("smoke: the pending particles never outgrow the room of the source") { TEST_CASE("smoke: an engine the starter turns lets out no smoke until it fires (#523)") { auto vehicle{diesel()}; - vehicle->dizel_spinup = true; + vehicle->diesel.spinningUp = true; auto pending{source}; pending.pending = 5.f; - vehicle->dizel_FiringCountdown = 0.5; + vehicle->diesel.firingCountdown = 0.5; CHECK(smoke::vehicle_spawn_count(vehicle.mover(), true, pending, update) == 0.f); - vehicle->dizel_FiringCountdown = 0.0; + vehicle->diesel.firingCountdown = 0.0; CHECK(smoke::vehicle_spawn_count(vehicle.mover(), true, pending, update) >= 1.f); } @@ -118,16 +118,16 @@ TEST_CASE("smoke: a real diesel smokes only once its engine has fired, SmokeDela { // SmokeDelay set in the .fiz of the locomotive test::vehicle locomotive{test::definition{test::definition::fiz(path)}.set("Engine", "SmokeDelay", 2)}; - REQUIRE(locomotive->dizel_SmokeDelay == doctest::Approx(2.0)); + REQUIRE(locomotive->diesel.smokeDelay == doctest::Approx(2.0)); auto const driven{test::driving(locomotive)}; REQUIRE(start_engine(driven, track)); // the engine started less than a second ago: the starter still turns it - CHECK(locomotive->dizel_FiringCountdown > 0.5); + CHECK(locomotive->diesel.firingCountdown > 0.5); CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) == 0.f); // it has fired since test::drive(driven, track, 3.0); CHECK(locomotive->Mains); - CHECK(locomotive->dizel_FiringCountdown == 0.0); + CHECK(locomotive->diesel.firingCountdown == 0.0); CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) >= 1.f); } { @@ -149,13 +149,13 @@ TEST_CASE("smoke: without SmokeDelay in its .fiz a diesel smokes as soon as the test::track const track{}; // a locomotive which has the delay, loaded first, doesn't hand it on to the next one: the value is the vehicle's own test::vehicle delayed{test::definition{test::definition::fiz(path)}.set("Engine", "SmokeDelay", 3)}; - REQUIRE(delayed->dizel_SmokeDelay == doctest::Approx(3.0)); + REQUIRE(delayed->diesel.smokeDelay == doctest::Approx(3.0)); test::vehicle locomotive{test::definition::fiz(path)}; - REQUIRE(locomotive->dizel_SmokeDelay == 0.0); - CHECK(delayed->dizel_SmokeDelay == doctest::Approx(3.0)); + REQUIRE(locomotive->diesel.smokeDelay == 0.0); + CHECK(delayed->diesel.smokeDelay == doctest::Approx(3.0)); auto const driven{test::driving(locomotive)}; REQUIRE(start_engine(driven, track)); - CHECK(locomotive->dizel_FiringCountdown == 0.0); + CHECK(locomotive->diesel.firingCountdown == 0.0); CHECK(smoke::vehicle_spawn_count(locomotive.mover(), true, source, update) >= 1.f); } } diff --git a/vehicle/ai/consist.cpp b/vehicle/ai/consist.cpp index d9994df93..8fa123ed9 100644 --- a/vehicle/ai/consist.cpp +++ b/vehicle/ai/consist.cpp @@ -951,7 +951,7 @@ TController::determine_consist_state() { Ready = vehicle->Vel > EU07_AI_MOVEMENT // already moving || false == vehicle->Mains // deadweight vehicle - || vehicle->enrot > 0.8 * (vehicle->EngineType == TEngineType::DieselEngine ? vehicle->dizel_nmin : vehicle->DElist[0].RPM / 60.0); + || vehicle->enrot > 0.8 * (vehicle->EngineType == TEngineType::DieselEngine ? vehicle->diesel.minRevolutions : vehicle->DElist[0].RPM / 60.0); } p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła) } diff --git a/vehicle/ai/controls.cpp b/vehicle/ai/controls.cpp index cde186f61..4163afc9e 100644 --- a/vehicle/ai/controls.cpp +++ b/vehicle/ai/controls.cpp @@ -707,7 +707,7 @@ bool TController::IncSpeed() if (mvControlling->EIMCtrlType > 0) { if (true == Ready) { - bool max = mvControlling->Vel > mvControlling->dizel_minVelfullengage + bool max = mvControlling->Vel > mvControlling->diesel.fullEngageMinVelocity || (mvControlling->SpeedCtrl && mvControlling->ScndCtrlPos > 0); DizelPercentage = max ? 100 : 1; } @@ -715,7 +715,7 @@ bool TController::IncSpeed() } else { if( true == Ready ) { - if( mvControlling->Vel > mvControlling->dizel_minVelfullengage + if( mvControlling->Vel > mvControlling->diesel.fullEngageMinVelocity && mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0 ) { OK = mvControlling->IncMainCtrl( 1 ); } @@ -794,7 +794,7 @@ bool TController::DecSpeed(bool force) break; } - if (mvControlling->Vel > mvControlling->dizel_minVelfullengage) + if (mvControlling->Vel > mvControlling->diesel.fullEngageMinVelocity) { if (mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0) OK = mvControlling->DecMainCtrl(1); @@ -1202,7 +1202,7 @@ void TController::SetTimeControllers() { DizelPercentage_Speed = DizelPercentage; //wstepnie procenty - auto MinVel{ std::min(mvControlling->hydro_TC_LockupSpeed, mvControlling->Vmax / 6) }; //minimal velocity + auto MinVel{ std::min(mvControlling->torqueConverter.lockupSpeed, mvControlling->Vmax / 6) }; //minimal velocity //when speed controll unit is active - start with the procedure if (mvControlling->SpeedCtrl && mvControlling->ScndCtrlPos > 0) { if (mvControlling->ScndCtrlPos > 0 && mvControlling->Vel < 1 + mvControlling->SpeedCtrlUnit.StartVelocity && DizelPercentage > 0) @@ -1272,7 +1272,7 @@ void TController::SetTimeControllers() if (!mvControlling->SlippingWheels) { while (mvControlling->MainCtrlPos > DesiredPos) mvControlling->DecMainCtrl(1); - if (mvControlling->Vel>mvControlling->dizel_minVelfullengage) + if (mvControlling->Vel>mvControlling->diesel.fullEngageMinVelocity) while (mvControlling->MainCtrlPos < DesiredPos) mvControlling->IncMainCtrl(1); } } diff --git a/vehicle/ai/engine.cpp b/vehicle/ai/engine.cpp index 7142d43c1..8194aecb7 100644 --- a/vehicle/ai/engine.cpp +++ b/vehicle/ai/engine.cpp @@ -364,7 +364,7 @@ TController::PrepareHeating() { case TEngineType::DieselElectric: case TEngineType::DieselEngine: { - auto const &heat { mvControlling->dizel_heat }; + auto const &heat { mvControlling->diesel.heat }; // determine whether there's need to enable the water heater // if the heater has configured maximum temperature, it'll disable itself automatically, so we can leave it always running diff --git a/vehicle/ai/physicslog.cpp b/vehicle/ai/physicslog.cpp index 758bd1184..cc32e5738 100644 --- a/vehicle/ai/physicslog.cpp +++ b/vehicle/ai/physicslog.cpp @@ -85,10 +85,10 @@ std::string TController::physicslog_line() const { << mvOccupied->CommandIn.Value2 << " " << int(mvControlling->SecuritySystem.is_blinking()) << " " << int(mvControlling->SlippingWheels) << " " - << mvControlling->dizel_heat.Ts << " " - << mvControlling->dizel_heat.To << " " - << mvControlling->dizel_heat.temperatura1 << " " - << mvControlling->dizel_heat.temperatura2 << " " + << mvControlling->diesel.heat.Ts << " " + << mvControlling->diesel.heat.To << " " + << mvControlling->diesel.heat.temperatura1 << " " + << mvControlling->diesel.heat.temperatura2 << " " // vehicle speed [km/h], the second column is the wheel speed, which stays at 0 while the wheels are locked in a skid << mvOccupied->V * 3.6 << "\r\n"; diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index ba53920d7..e72aefc54 100644 --- a/vehicle/cab/setup.cpp +++ b/vehicle/cab/setup.cpp @@ -1880,21 +1880,21 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // oil temperature auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignFloat(&mvControlled->dizel_heat.To); + gauge.AssignFloat(&mvControlled->diesel.heat.To); } else if (Label == "water1temp:") { // main circuit water temperature auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignFloat(&mvControlled->dizel_heat.temperatura1); + gauge.AssignFloat(&mvControlled->diesel.heat.temperatura1); } else if (Label == "water2temp:") { // auxiliary circuit water temperature auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignFloat(&mvControlled->dizel_heat.temperatura2); + gauge.AssignFloat(&mvControlled->diesel.heat.temperatura2); } else if (Label == "pantpress:") { @@ -1982,7 +1982,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // np. ciśnienie sterownika sprzęgła auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject); - gauge.AssignDouble(&mvControlled->dizel_engage); + gauge.AssignDouble(&mvControlled->diesel.clutchPressure); } // ggEngageRatio.Load(Parser,DynamicObject->mdKabina); else if (Label == "maingearstatus:") { diff --git a/vehicle/cab/update.cpp b/vehicle/cab/update.cpp index a68733c00..5d193a004 100644 --- a/vehicle/cab/update.cpp +++ b/vehicle/cab/update.cpp @@ -56,7 +56,7 @@ bool TTrain::Update(double const Deltatime) // crude way to sync state of the linebreaker with ai-issued commands m_linebreakerstate = linebreaker::state::closed; } - if (m_linebreakerstate == linebreaker::state::closed && false == (mvControlled->Mains || mvControlled->dizel_startup)) + if (m_linebreakerstate == linebreaker::state::closed && false == (mvControlled->Mains || mvControlled->diesel.startupRequested)) { // crude way to catch cases where the main was knocked out // because the state of the line breaker isn't changed to match, we need to do it here manually @@ -378,13 +378,13 @@ bool TTrain::Update(double const Deltatime) fDieselParams[1 + in][0] = static_cast(p->MoverParameters->enrot * 60); fDieselParams[1 + in][1] = static_cast(p->MoverParameters->nrot); fDieselParams[1 + in][2] = static_cast(p->MoverParameters->RList[p->MoverParameters->MainCtrlPos].R); - fDieselParams[1 + in][3] = static_cast(p->MoverParameters->dizel_fill); + fDieselParams[1 + in][3] = static_cast(p->MoverParameters->diesel.fill); fDieselParams[1 + in][4] = static_cast(p->MoverParameters->RList[p->MoverParameters->MainCtrlPos].Mn); - fDieselParams[1 + in][5] = static_cast(p->MoverParameters->dizel_engage); - fDieselParams[1 + in][6] = p->MoverParameters->dizel_heat.Twy; + fDieselParams[1 + in][5] = static_cast(p->MoverParameters->diesel.clutchPressure); + fDieselParams[1 + in][6] = p->MoverParameters->diesel.heat.Twy; fDieselParams[1 + in][7] = p->MoverParameters->OilPump.pressure; - fDieselParams[1 + in][8] = p->MoverParameters->dizel_heat.Ts; - fDieselParams[1 + in][9] = static_cast(p->MoverParameters->hydro_R_Fill); + fDieselParams[1 + in][8] = p->MoverParameters->diesel.heat.Ts; + fDieselParams[1 + in][9] = static_cast(p->MoverParameters->retarder.fill); bMains[in] = p->MoverParameters->Mains; fCntVol[in] = static_cast(p->MoverParameters->BatteryVoltage); bFuse[in] = p->MoverParameters->FuseFlag; @@ -523,7 +523,7 @@ bool TTrain::Update(double const Deltatime) } if (ggWater1TempB.SubModel) { - ggWater1TempB.UpdateValue(tmp->MoverParameters->dizel_heat.temperatura1); + ggWater1TempB.UpdateValue(tmp->MoverParameters->diesel.heat.temperatura1); ggWater1TempB.Update(); } if (ggOilPressB.SubModel) @@ -605,14 +605,14 @@ bool TTrain::Update(double const Deltatime) if (ggMainGearStatus.SubModel) { if (mvControlled->Mains) - ggMainGearStatus.UpdateValue(static_cast(1.1 - std::abs(mvControlled->dizel_automaticgearstatus))); + ggMainGearStatus.UpdateValue(static_cast(1.1 - std::abs(mvControlled->diesel.automaticGearShift))); else ggMainGearStatus.UpdateValue(0.0); ggMainGearStatus.Update(); } if (ggIgnitionKey.SubModel && ggIgnitionKey.GetDesiredValue() == 0.0) { - ggIgnitionKey.UpdateValue(mvControlled->Mains || mvControlled->dizel_startup || fMainRelayTimer > 0.f || + ggIgnitionKey.UpdateValue(mvControlled->Mains || mvControlled->diesel.startupRequested || fMainRelayTimer > 0.f || (ggMainButton.SubModel != nullptr && ggMainButton.GetDesiredValue() > 0.95) || (ggMainOnButton.SubModel != nullptr && ggMainOnButton.GetDesiredValue() > 0.95)); } @@ -721,9 +721,9 @@ bool TTrain::Update(double const Deltatime) btLampkaBocznik4.Turn(!mvControlled->DelayCtrlFlag && mvControlled->ScndCtrlPos > 3 || mvControlled->ScndCtrlActualPos > 3 || scp > 3); // biegi dla motoraka - btLampkaGear1.Turn(mvControlled->ScndCtrlActualPos == 1 && mvControlled->dizel_engagestate > 0); // bieg 1 - btLampkaGear2.Turn(mvControlled->ScndCtrlActualPos == 2 && mvControlled->dizel_engagestate > 0); // bieg 2 - btLampkaHydroLockup.Turn(mvControlled->hydro_TC_Lockup); // zblokowanie skrzyni z silnikiem + btLampkaGear1.Turn(mvControlled->ScndCtrlActualPos == 1 && mvControlled->diesel.clutchState > 0); // bieg 1 + btLampkaGear2.Turn(mvControlled->ScndCtrlActualPos == 2 && mvControlled->diesel.clutchState > 0); // bieg 2 + btLampkaHydroLockup.Turn(mvControlled->torqueConverter.lockedUp); // zblokowanie skrzyni z silnikiem if (mvControlled->Signalling == true) { @@ -829,12 +829,12 @@ bool TTrain::Update(double const Deltatime) btLampkaRearLeftEndLight.Turn((mvOccupied->iLights[end::rear] & light::redmarker_left) != 0); btLampkaRearRightEndLight.Turn((mvOccupied->iLights[end::rear] & light::redmarker_right) != 0); // others - btLampkaMalfunction.Turn(mvControlled->dizel_heat.PA); + btLampkaMalfunction.Turn(mvControlled->diesel.heat.PA); // overheat indicator lamps - btLampkaOilOverheat.Turn(mvControlled->dizel_heat.oil.is_hot); - btLampkaWaterOverheat.Turn(mvControlled->dizel_heat.water.is_hot); - btLampkaWaterAuxOverheat.Turn(mvControlled->dizel_heat.water_aux.is_hot); - btLampkaEngineOverheat.Turn(mvControlled->dizel_heat.engine_is_hot); + btLampkaOilOverheat.Turn(mvControlled->diesel.heat.oil.is_hot); + btLampkaWaterOverheat.Turn(mvControlled->diesel.heat.water.is_hot); + btLampkaWaterAuxOverheat.Turn(mvControlled->diesel.heat.water_aux.is_hot); + btLampkaEngineOverheat.Turn(mvControlled->diesel.heat.engine_is_hot); btLampkaMotorBlowers.Turn(mvControlled->MotorBlowers[end::front].is_active && mvControlled->MotorBlowers[end::rear].is_active); btLampkaCoolingFans.Turn(mvControlled->RventRot > 1.0); btLampkaLouvresClosed.Turn(mvControlled->LouvresClosed()); @@ -993,7 +993,7 @@ bool TTrain::Update(double const Deltatime) btLampkaPrzetwB.Turn(mover->ConverterFlag); // zalaczenie przetwornicy btLampkaPrzetwBOff.Turn(false == mover->ConverterFlag); btLampkaHVoltageB.Turn(mover->NoVoltRelay && mover->OvervoltageRelay); - btLampkaMalfunctionB.Turn(mover->dizel_heat.PA); + btLampkaMalfunctionB.Turn(mover->diesel.heat.PA); // motor fuse indicator turns on if the fuse was blown in any unit under control if (mover->Mains) { diff --git a/vehicle/dynamic/lifecycle.cpp b/vehicle/dynamic/lifecycle.cpp index a442440d3..128fb73c2 100644 --- a/vehicle/dynamic/lifecycle.cpp +++ b/vehicle/dynamic/lifecycle.cpp @@ -653,10 +653,10 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" btMechanik1.Init( "mechanik1", mdLowPolyInt, false); btMechanik2.Init( "mechanik2", mdLowPolyInt, false); - if( MoverParameters->dizel_heat.water.config.shutters ) { + if( MoverParameters->diesel.heat.water.config.shutters ) { btShutters1.Init( "shutters1", mdModel, false ); } - if( MoverParameters->dizel_heat.water_aux.config.shutters ) { + if( MoverParameters->diesel.heat.water_aux.config.shutters ) { btShutters2.Init( "shutters2", mdModel, false ); } TurnOff(); // resetowanie zmiennych submodeli diff --git a/vehicle/dynamic/sounds.cpp b/vehicle/dynamic/sounds.cpp index fe661e2a4..3cde7887c 100644 --- a/vehicle/dynamic/sounds.cpp +++ b/vehicle/dynamic/sounds.cpp @@ -1022,8 +1022,8 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub } case TEngineType::DieselEngine: { if( Vehicle.enrot > 0.0 ) { - volume = Vehicle.EnginePower > 0 ? engine.m_amplitudeoffset + engine.m_amplitudefactor * Vehicle.dizel_fill : - engine.m_amplitudeoffset + engine.m_amplitudefactor * std::fabs(Vehicle.enrot / Vehicle.dizel_nmax); + volume = Vehicle.EnginePower > 0 ? engine.m_amplitudeoffset + engine.m_amplitudefactor * Vehicle.diesel.fill : + engine.m_amplitudeoffset + engine.m_amplitudefactor * std::fabs(Vehicle.enrot / Vehicle.diesel.maxRevolutions); } break; } @@ -1108,7 +1108,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub // youBy - przenioslem, bo diesel tez moze miec turbo if( Vehicle.TurboTest > 0 ) { // udawanie turbo: - auto const pitch_diesel{Vehicle.EngineType == TEngineType::DieselEngine || Vehicle.EngineType == TEngineType::DieselElectric ? Vehicle.enrot / Vehicle.dizel_nmax * Vehicle.dizel_fill : 1}; + auto const pitch_diesel{Vehicle.EngineType == TEngineType::DieselEngine || Vehicle.EngineType == TEngineType::DieselElectric ? Vehicle.enrot / Vehicle.diesel.maxRevolutions * Vehicle.diesel.fill : 1}; auto const goalpitch { std::max( 0.025, ( /*engine_volume **/ pitch_diesel + engine_turbo.m_frequencyoffset ) * engine_turbo.m_frequencyfactor ) }; auto const goalvolume { ( Vehicle.MainCtrlPos >= Vehicle.TurboTest && Vehicle.enrot > 0.1 ? @@ -1133,14 +1133,14 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub } } - if( Vehicle.dizel_engage > 0.1 ) { - if( std::abs( Vehicle.dizel_engagedeltaomega ) > 0.2 ) { - frequency = rsEngageSlippery.m_frequencyoffset + rsEngageSlippery.m_frequencyfactor * std::fabs( Vehicle.dizel_engagedeltaomega ); - volume = rsEngageSlippery.m_amplitudeoffset + rsEngageSlippery.m_amplitudefactor * Vehicle.dizel_engage; + if( Vehicle.diesel.clutchPressure > 0.1 ) { + if( std::abs( Vehicle.diesel.clutchSlip ) > 0.2 ) { + frequency = rsEngageSlippery.m_frequencyoffset + rsEngageSlippery.m_frequencyfactor * std::fabs( Vehicle.diesel.clutchSlip ); + volume = rsEngageSlippery.m_amplitudeoffset + rsEngageSlippery.m_amplitudefactor * Vehicle.diesel.clutchPressure; } else { frequency = 1.f; // rsEngageSlippery.FA+0.7*rsEngageSlippery.FM*(fabs(mvControlled->enrot)+mvControlled->nmax); - volume = Vehicle.dizel_engage > 0.2 ? rsEngageSlippery.m_amplitudeoffset + 0.2 * rsEngageSlippery.m_amplitudefactor * (Vehicle.enrot / Vehicle.nmax) : 0.f; + volume = Vehicle.diesel.clutchPressure > 0.2 ? rsEngageSlippery.m_amplitudeoffset + 0.2 * rsEngageSlippery.m_amplitudefactor * (Vehicle.enrot / Vehicle.nmax) : 0.f; } rsEngageSlippery @@ -1152,14 +1152,14 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub rsEngageSlippery.stop(); } - if (Vehicle.hydro_R) { - float speed = std::abs(Vehicle.hydro_R_n); + if (Vehicle.retarder.present) { + float speed = std::abs(Vehicle.retarder.revolutions); retarder .pitch(retarder.m_frequencyoffset + speed * retarder.m_frequencyfactor) - .gain(retarder.m_amplitudeoffset + Vehicle.hydro_R_Fill * retarder.m_amplitudefactor); + .gain(retarder.m_amplitudeoffset + Vehicle.retarder.fill * retarder.m_amplitudefactor); - if (retarder.gain() > 0.01 && speed > 1 && Vehicle.hydro_R_ClutchActive) { + if (retarder.gain() > 0.01 && speed > 1 && Vehicle.retarder.clutchActive) { retarder.play(sound_flags::exclusive | sound_flags::looping); } else { @@ -1332,11 +1332,11 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub if( Vehicle.EngineType == TEngineType::DieselEngine || Vehicle.EngineType == TEngineType::DieselElectric ) { - if( Vehicle.dizel_heat.rpmw > 0.1 ) { + if( Vehicle.diesel.heat.rpmw > 0.1 ) { // NOTE: fan speed tends to max out at ~100 rpm; by default we try to get pitch range of 0.5-1.5 and volume range of 0.5-1.0 radiator_fan - .pitch( 0.5 + radiator_fan.m_frequencyoffset + radiator_fan.m_frequencyfactor * Vehicle.dizel_heat.rpmw * 0.01 ) - .gain( 0.5 + radiator_fan.m_amplitudeoffset + 0.5 * radiator_fan.m_amplitudefactor * Vehicle.dizel_heat.rpmw * 0.01 ) + .pitch( 0.5 + radiator_fan.m_frequencyoffset + radiator_fan.m_frequencyfactor * Vehicle.diesel.heat.rpmw * 0.01 ) + .gain( 0.5 + radiator_fan.m_amplitudeoffset + 0.5 * radiator_fan.m_amplitudefactor * Vehicle.diesel.heat.rpmw * 0.01 ) .play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -1344,11 +1344,11 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub radiator_fan.stop(); } - if( Vehicle.dizel_heat.rpmw2 > 0.1 ) { + if( Vehicle.diesel.heat.rpmw2 > 0.1 ) { // NOTE: fan speed tends to max out at ~100 rpm; by default we try to get pitch range of 0.5-1.5 and volume range of 0.5-1.0 radiator_fan_aux - .pitch( 0.5 + radiator_fan_aux.m_frequencyoffset + radiator_fan_aux.m_frequencyfactor * Vehicle.dizel_heat.rpmw2 * 0.01 ) - .gain( 0.5 + radiator_fan_aux.m_amplitudeoffset + 0.5 * radiator_fan_aux.m_amplitudefactor * Vehicle.dizel_heat.rpmw2 * 0.01 ) + .pitch( 0.5 + radiator_fan_aux.m_frequencyoffset + radiator_fan_aux.m_frequencyfactor * Vehicle.diesel.heat.rpmw2 * 0.01 ) + .gain( 0.5 + radiator_fan_aux.m_amplitudeoffset + 0.5 * radiator_fan_aux.m_amplitudefactor * Vehicle.diesel.heat.rpmw2 * 0.01 ) .play( sound_flags::exclusive | sound_flags::looping ); } else { diff --git a/vehicle/dynamic/visual.cpp b/vehicle/dynamic/visual.cpp index 16b196acc..3f01e16de 100644 --- a/vehicle/dynamic/visual.cpp +++ b/vehicle/dynamic/visual.cpp @@ -406,13 +406,13 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) // cooling shutters // NOTE: shutters display _on state when they're closed, _off otherwise - if( true == MoverParameters->dizel_heat.water.config.shutters - && false == MoverParameters->dizel_heat.zaluzje1 ) { + if( true == MoverParameters->diesel.heat.water.config.shutters + && false == MoverParameters->diesel.heat.zaluzje1 ) { btShutters1.Turn( true ); btnOn = true; } - if( true == MoverParameters->dizel_heat.water_aux.config.shutters - && false == MoverParameters->dizel_heat.zaluzje2 ) { + if( true == MoverParameters->diesel.heat.water_aux.config.shutters + && false == MoverParameters->diesel.heat.zaluzje2 ) { btShutters2.Turn( true ); btnOn = true; } diff --git a/vehicle/enginestart.cpp b/vehicle/enginestart.cpp index ca276b73c..a1178196e 100644 --- a/vehicle/enginestart.cpp +++ b/vehicle/enginestart.cpp @@ -103,7 +103,7 @@ bool remote_switch::open(TMoverParameters &Engine) { } bool remote_switch::is_running(TMoverParameters const &Engine) { - return Engine.Mains || Engine.dizel_startup; + return Engine.Mains || Engine.diesel.startupRequested; } } // namespace engine_start diff --git a/vehicle/smoke.cpp b/vehicle/smoke.cpp index 88897c722..b12c4d3ca 100644 --- a/vehicle/smoke.cpp +++ b/vehicle/smoke.cpp @@ -18,7 +18,7 @@ namespace { // how hard the engine works, scaling the spawn rate of the source double engine_load(TMoverParameters const &Mover) { - if (Mover.dizel_spinup) { + if (Mover.diesel.spinningUp) { // starting up, it puffs harder the faster it turns return ((Mover.enrot / 4) * 0.01); } @@ -34,7 +34,7 @@ double engine_load(TMoverParameters const &Mover) { } // namespace float vehicle_spawn_count(TMoverParameters const &Mover, bool const Ontracks, spawn_rate const &Rate, double const Timedelta) { - if (false == Ontracks || Mover.dizel_FiringCountdown > 0.0) { + if (false == Ontracks || Mover.diesel.firingCountdown > 0.0) { return 0.f; } // the steady rate of the source, the way a source of the scenery spawns... diff --git a/vehicle/smoke.h b/vehicle/smoke.h index dbcc131ae..e3c3adec5 100644 --- a/vehicle/smoke.h +++ b/vehicle/smoke.h @@ -25,7 +25,7 @@ struct spawn_rate { // number of particles the smoke source of a vehicle has to spawn after Timedelta seconds: the steady rate of the // source, plus a share which grows with the work of its engine. a vehicle taken off the tracks (Ontracks false: gone through a portal, or waiting in the pool of the road // traffic) puffs no more, the particles it already let out fade away as usual -// an engine the starter turns but which hasn't fired yet (TMoverParameters::dizel_FiringCountdown) lets out no smoke either +// an engine the starter turns but which hasn't fired yet (TMoverParameters::diesel.firingCountdown) lets out no smoke either float vehicle_spawn_count(TMoverParameters const &Mover, bool Ontracks, spawn_rate const &Rate, double Timedelta); } // namespace smoke diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index 56f28782b..02b924bad 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -173,14 +173,14 @@ void ui::vehicleparams_panel::render_contents() mover.EnginePower, std::abs(mover.TrainType == train_type::emu ? mover.ShowCurrent(0) : mover.Im), // revolutions std::abs(mover.enrot) * 60, std::abs(mover.nrot) * mover.Transmision.Ratio * 60, mover.RventRot * 60, std::abs(mover.MotorBlowers[end::front].revolutions), - std::abs(mover.MotorBlowers[end::rear].revolutions), mover.dizel_heat.rpmw, mover.dizel_heat.rpmw2); + std::abs(mover.MotorBlowers[end::rear].revolutions), mover.diesel.heat.rpmw, mover.diesel.heat.rpmw2); ImGui::TextUnformatted(buffer.data()); if (isdieselenginepowered) { - std::snprintf(buffer.data(), buffer.size(), STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"), mover.dizel_heat.Ts, mover.dizel_heat.To, mover.dizel_heat.temperatura1, - (mover.WaterCircuitsLink ? '-' : '|'), mover.dizel_heat.temperatura2); + std::snprintf(buffer.data(), buffer.size(), STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"), mover.diesel.heat.Ts, mover.diesel.heat.To, mover.diesel.heat.temperatura1, + (mover.WaterCircuitsLink ? '-' : '|'), mover.diesel.heat.temperatura2); ImGui::TextUnformatted(buffer.data()); }