From 5879c228dc579757a6f6cf0459fb0bdc046e529e Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sun, 29 Nov 2026 13:17:56 +0100 Subject: [PATCH] refactor(physics): what the rest of the simulator only reads of a vehicle is private to it 53 fields of physics::Vehicle that only the vehicle itself writes, and the rest of the simulator reads, are private, with a query each, named as the field was (Vmax(), TotalMass(), Ft(), nrot(), NAxles(), PhysicActivation(), ...): the compiler now keeps the cab, the AI, the scenery, the renderer and the tests from changing what the definition gives or the physics works out. The fields were picked by what is never written outside the class, of plain types, with no other member of the same name to confuse; inside the class they keep their meaning under camelCase names. The one place outside that cleared a flag of the AI through a reference does it through ClearAIFlag(). No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit. --- application/driverhints.cpp | 28 ++-- application/driveruipanels.cpp | 22 +-- input/drivermouseinput.cpp | 6 +- input/messaging.cpp | 4 +- physics/components/body.cpp | 131 ++++++++--------- physics/components/cab.cpp | 20 +-- physics/components/collisions.cpp | 86 ++++++------ physics/components/commands.cpp | 24 ++-- physics/components/controllers.cpp | 140 +++++++++---------- physics/components/couplers.cpp | 4 +- physics/components/diesel.cpp | 76 +++++----- physics/components/drive.cpp | 14 +- physics/components/electrics.cpp | 10 +- physics/components/fizparser.cpp | 4 +- physics/components/fizsections.cpp | 110 +++++++-------- physics/components/pneumatics.cpp | 40 +++--- physics/components/securitysystem.cpp | 4 +- physics/components/setup.cpp | 32 ++--- physics/components/traction.cpp | 160 ++++++++++----------- physics/consistbraking.cpp | 24 ++-- physics/vehicle.h | 170 +++++++++++++++-------- simulation/blackboxrecorder.cpp | 10 +- tests/unit/drive.cpp | 4 +- tests/unit/figures.cpp | 4 +- tests/unit/golden.cpp | 28 ++-- tests/unit/invariants.cpp | 8 +- tests/unit/test_6dg_power_steps.cpp | 6 +- tests/unit/test_ai_hints.cpp | 12 +- tests/unit/test_brakes.cpp | 10 +- tests/unit/test_cab.cpp | 6 +- tests/unit/test_cntrl.cpp | 8 +- tests/unit/test_collisions.cpp | 74 +++++----- tests/unit/test_commands.cpp | 12 +- tests/unit/test_consist_braking.cpp | 2 +- tests/unit/test_controls.cpp | 8 +- tests/unit/test_couplers_trains.cpp | 2 +- tests/unit/test_crew.cpp | 6 +- tests/unit/test_definition.cpp | 10 +- tests/unit/test_derail_motion.cpp | 22 +-- tests/unit/test_derailment_vehicle.cpp | 10 +- tests/unit/test_diesel.cpp | 6 +- tests/unit/test_dimmer.cpp | 2 +- tests/unit/test_dynamic_brake_diesel.cpp | 20 +-- tests/unit/test_elf_controller.cpp | 28 ++-- tests/unit/test_engine_start.cpp | 2 +- tests/unit/test_equipment_faults.cpp | 8 +- tests/unit/test_field_shunting.cpp | 14 +- tests/unit/test_fiz.cpp | 12 +- tests/unit/test_genset.cpp | 4 +- tests/unit/test_handover.cpp | 14 +- tests/unit/test_horn.cpp | 6 +- tests/unit/test_loads.cpp | 4 +- tests/unit/test_pullee.cpp | 10 +- tests/unit/test_speed_control.cpp | 36 ++--- tests/unit/test_traction.cpp | 10 +- tests/unit/test_uc_steps.cpp | 4 +- tests/unit/test_wheelslip.cpp | 4 +- tests/unit/vehicle.cpp | 8 +- utilities/motiontelemetry.cpp | 2 +- vehicle/ai/consist.cpp | 20 +-- vehicle/ai/controls.cpp | 94 ++++++------- vehicle/ai/driver.cpp | 8 +- vehicle/ai/force.cpp | 8 +- vehicle/ai/physicslog.cpp | 8 +- vehicle/ai/situation.cpp | 20 +-- vehicle/ai/speed.cpp | 10 +- vehicle/brakesetting.cpp | 2 +- vehicle/cab/auxiliarycommands.cpp | 6 +- vehicle/cab/brakecommands.cpp | 8 +- vehicle/cab/cabcommands.cpp | 4 +- vehicle/cab/controllercommands.cpp | 8 +- vehicle/cab/lightcommands.cpp | 10 +- vehicle/cab/powercommands.cpp | 8 +- vehicle/cab/setup.cpp | 30 ++-- vehicle/cab/sounds.cpp | 18 +-- vehicle/cab/train.cpp | 20 +-- vehicle/cab/update.cpp | 74 +++++----- vehicle/dynamic/lifecycle.cpp | 16 +-- vehicle/dynamic/mmd.cpp | 16 +-- vehicle/dynamic/movement.cpp | 4 +- vehicle/dynamic/offtrack.cpp | 14 +- vehicle/dynamic/sounds.cpp | 26 ++-- vehicle/dynamic/update.cpp | 30 ++-- vehicle/dynamic/vehicletable.cpp | 14 +- vehicle/dynamic/visual.cpp | 6 +- vehicle/enginestart.cpp | 2 +- vehicle/handover.cpp | 4 +- widgets/vehicleparams.cpp | 12 +- 88 files changed, 1053 insertions(+), 992 deletions(-) diff --git a/application/driverhints.cpp b/application/driverhints.cpp index 13641f60b..081d21862 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -124,7 +124,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return occupied->AutomaticCabActivation || (occupied->CabMaster == false && occupied->CabActive == 0); } ); + return occupied->AutomaticCabActivation || (occupied->CabMaster() == false && occupied->CabActive == 0); } ); break; } // radio @@ -560,7 +560,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) Action, [this](float const /*Parameter*/) { return mvControlling->EIMDirectionChangeAllow(); }, - static_cast(mvControlling->MainCtrlMaxDirChangePos) ); + static_cast(mvControlling->MainCtrlMaxDirChangePos()) ); break; } case driver_hint::tractiveforcedecrease: { @@ -571,12 +571,12 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const Parameter) { - return std::abs(mvControlling->Ft) <= Parameter; }, + return std::abs(mvControlling->Ft()) <= Parameter; }, static_cast(std::min( 0.0, std::max( - std::abs( mvControlling->Ft ) * 0.95, - std::abs( mvControlling->Ft ) - 5.0 ) )) ); + std::abs( mvControlling->Ft() ) * 0.95, + std::abs( mvControlling->Ft() ) - 5.0 ) )) ); break; } case driver_hint::tractiveforceincrease: { @@ -598,14 +598,14 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) break; } case driver_hint::bufferscompress: { - if (aiControlled && std::abs( mvControlling->Ft ) < 50000.0) { + if (aiControlled && std::abs( mvControlling->Ft() ) < 50000.0) { IncSpeed(); } remove_master_controller_hints(); hint( Action, [this](float const /*Parameter*/) { - return std::abs(mvControlling->Ft) > 30.0 || false == OrderCurrentGet().HasAny(DriverOrder::disconnect); } ); + return std::abs(mvControlling->Ft()) > 30.0 || false == OrderCurrentGet().HasAny(DriverOrder::disconnect); } ); break; } @@ -725,7 +725,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvControlling->diesel.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->diesel.heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == false; } ); + return mvControlling->diesel.heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink() == false; } ); break; } case driver_hint::waittemperaturetoolow: { @@ -901,7 +901,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) case driver_hint::independentbrakeapply: { if (aiControlled && occupied->brakes.IndependentPosition() < 1.0) { occupied->IncLocalBrakeLevel( LocalBrakePosNo ); - if (occupied->EIMCtrlEmergency) { + if (occupied->EIMCtrlEmergency()) { occupied->DecLocalBrakeLevel(1); } } @@ -910,7 +910,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) Action, [this](float const Parameter) { return occupied->brakes.IndependentPosition() >= Parameter; }, - ( LocalBrakePosNo - ( occupied->EIMCtrlEmergency ? 1 : 0 ) ) / LocalBrakePosNo ); + ( LocalBrakePosNo - ( occupied->EIMCtrlEmergency() ? 1 : 0 ) ) / LocalBrakePosNo ); break; } case driver_hint::independentbrakerelease: { @@ -980,7 +980,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvControlling->Sand == 0 || mvControlling->SandDose == true || mvControlling->SlippingWheels == false; } ); + return mvControlling->Sand == 0 || mvControlling->SandDose() == true || mvControlling->SlippingWheels() == false; } ); break; } case driver_hint::sandingoff: { @@ -991,7 +991,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvControlling->Sand == 0 || mvControlling->SandDose == false; } ); + return mvControlling->Sand == 0 || mvControlling->SandDose() == false; } ); break; } case driver_hint::antislip: { @@ -1001,7 +1001,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return mvControlling->brakes.config.antiSlipType != 1 || (mvControlling->brakes.distributor->GetBrakeStatus() & b_asb) != 0 || mvControlling->SlippingWheels == false; } ); + return mvControlling->brakes.config.antiSlipType != 1 || (mvControlling->brakes.distributor->GetBrakeStatus() & b_asb) != 0 || mvControlling->SlippingWheels() == false; } ); break; } // horns diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 1a3963434..e6a8cd768 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -167,7 +167,7 @@ drivingaid_panel::update() { STR_C("Brakes: %5.1f+%-2.0f%c%s"), readout.brake_first, readout.local_brake, - physics->SlippingWheels ? '!' : ' ', + physics->SlippingWheels() ? '!' : ' ', expandedtext.c_str() ); } else { @@ -176,7 +176,7 @@ drivingaid_panel::update() { m_buffer.data(), m_buffer.size(), STR_C("Brakes: %5.1f%c%s"), readout.brake_first, - physics->SlippingWheels ? '!' : ' ', + physics->SlippingWheels() ? '!' : ' ', expandedtext.c_str() ); } @@ -386,11 +386,11 @@ timetable_panel::update() { if( false == owner->is_dmu() && false == owner->is_emu() ) { //odejmij lokomotywy czynne, a przynajmniej aktualną - consistmass -= owner->pVehicle->physics->TotalMass; + consistmass -= owner->pVehicle->physics->TotalMass(); // subtract potential other half of a two-part vehicle - if( auto const *previous { owner->pVehicle->Prev( Coupling::permanent ) }; previous != nullptr ) { consistmass -= previous->physics->TotalMass; } + if( auto const *previous { owner->pVehicle->Prev( Coupling::permanent ) }; previous != nullptr ) { consistmass -= previous->physics->TotalMass(); } auto const *next { owner->pVehicle->Next( Coupling::permanent ) }; - if( next != nullptr ) { consistmass -= next->physics->TotalMass; } + if( next != nullptr ) { consistmass -= next->physics->TotalMass(); } } std::snprintf( m_buffer.data(), m_buffer.size(), @@ -893,10 +893,10 @@ debug_panel::update_section_vehicle( std::vector &Output ) { std::string( isdieselinshuntmode ? to_string( physics.AnPos(), 2 ) + STR(" (shunt mode)") : std::to_string( physics.ScndCtrlPos() ) + "(" + std::to_string( physics.ScndCtrlActualPos ) + ")" ).c_str(), // engine physics.EnginePower, - std::abs( physics.TrainType == train_type::emu ? physics.ShowCurrent( 0 ) : physics.Im ), + std::abs( physics.TrainType() == train_type::emu ? physics.ShowCurrent( 0 ) : physics.Im ), // revolutions std::abs( physics.enrot ) * 60, - std::abs( physics.nrot ) * physics.Transmision.Ratio * 60, + std::abs( physics.nrot() ) * physics.Transmision.Ratio * 60, physics.RventRot * 60, std::abs( physics.MotorBlowers[VehicleEnd::front].revolutions ), std::abs( physics.MotorBlowers[VehicleEnd::rear].revolutions ), @@ -912,7 +912,7 @@ debug_panel::update_section_vehicle( std::vector &Output ) { physics.diesel.heat.Ts, physics.diesel.heat.To, physics.diesel.heat.temperatura1, - physics.WaterCircuitsLink ? '-' : '|', + physics.WaterCircuitsLink() ? '-' : '|', physics.diesel.heat.temperatura2 ); textline += m_buffer.data(); } @@ -962,12 +962,12 @@ debug_panel::update_section_vehicle( std::vector &Output ) { m_buffer.data(), m_buffer.size(), STR_C("Forces:\n tractive: %.1f, brake: %.1f, drag: %.2f%s\nAcceleration:\n tangential: %.2f, normal: %.2f (path radius: %s)\nVelocity: %.2f, distance traveled: %.2f\nPosition: [%.2f, %.2f, %.2f]"), // forces - physics.Ft * 0.001f * ( physics.CabOccupied() ? physics.CabOccupied() : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabOccupied() : 1 ) + 0.001f, + physics.Ft() * 0.001f * ( physics.CabOccupied() ? physics.CabOccupied() : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabOccupied() : 1 ) + 0.001f, physics.Fb * 0.001f, physics.FrictionForce() * 0.001f, - physics.SlippingWheels ? " (!)" : "", + physics.SlippingWheels() ? " (!)" : "", // acceleration - physics.AccSVBased, + physics.AccSVBased(), physics.AccN() + 0.001f, std::string( std::abs( physics.RunningShape.R ) > 15000.0 ? "~0" : to_string( physics.RunningShape.R, 0 ) ).c_str(), // velocity diff --git a/input/drivermouseinput.cpp b/input/drivermouseinput.cpp index 37bc1992c..bc13495b0 100644 --- a/input/drivermouseinput.cpp +++ b/input/drivermouseinput.cpp @@ -63,7 +63,7 @@ mouse_slider::bind( user_command const &Command ) { auto const powerrange { static_cast( vehicle->CoupledCtrl ? - vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo : + vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo() : vehicle->MainCtrlPosNo ) }; // for simplicity upper half of the range controls power, lower controls brakes @@ -79,14 +79,14 @@ mouse_slider::bind( user_command const &Command ) { break; } case user_command::mastercontrollerset: { - m_valuerange = vehicle->CoupledCtrl ? vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo : vehicle->MainCtrlPosNo; + m_valuerange = vehicle->CoupledCtrl ? vehicle->MainCtrlPosNo + vehicle->ScndCtrlPosNo() : vehicle->MainCtrlPosNo; m_value = vehicle->CoupledCtrl ? vehicle->MainCtrlPos() + vehicle->ScndCtrlPos() : vehicle->MainCtrlPos(); m_analogue = false; m_invertrange = false; break; } case user_command::secondcontrollerset: { - m_valuerange = vehicle->ScndCtrlPosNo; + m_valuerange = vehicle->ScndCtrlPosNo(); m_value = vehicle->ScndCtrlPos(); m_analogue = false; m_invertrange = true; diff --git a/input/messaging.cpp b/input/messaging.cpp index ce52e718d..4bdb39060 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -277,8 +277,8 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle) r.fPar[3] = Vehicle->physics->Loc().Y; // pozycja Y r.fPar[4] = Vehicle->physics->Loc().Z; // pozycja Z r.fPar[5] = Vehicle->physics->V(); // prędkość ruchu X - r.fPar[6] = Vehicle->physics->nrot * M_PI * - Vehicle->physics->WheelDiameter; // prędkość obrotowa kóŁ + r.fPar[6] = Vehicle->physics->nrot() * M_PI * + Vehicle->physics->WheelDiameter(); // prędkość obrotowa kóŁ r.fPar[7] = 0; // prędkość ruchu Z r.fPar[8] = Vehicle->physics->AccS(); // przyspieszenie X r.fPar[9] = Vehicle->physics->AccN(); // przyspieszenie Y //na razie nie diff --git a/physics/components/body.cpp b/physics/components/body.cpp index 507fc9545..bfede4797 100644 --- a/physics/components/body.cpp +++ b/physics/components/body.cpp @@ -217,7 +217,7 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap } if (CategoryFlag == 4) - offsetTrackV = TotalMass / (Dim.L * Dim.W * 1000.0); + offsetTrackV = totalMass / (Dim.L * Dim.W * 1000.0); else if (TestFlag(CategoryFlag, 1) && TestFlag(RunningTrack.CategoryFlag, 1) && DamageFlag.HasAll(VehicleDamage::derailed)) { offsetTrackV = -0.2; @@ -232,7 +232,7 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap { auto const AccSprev{accS}; // przyspieszenie styczne - accS = std::lerp(AccSprev, FTotal / TotalMass, 0.5); + accS = std::lerp(AccSprev, FTotal / totalMass, 0.5); // std::clamp( dt * 3.0, 0.0, 1.0 ) ); // prawo Newtona ale z wygladzaniem (średnia z poprzednim) // a vehicle derailed by the physical criteria slides on with the friction of ComputeTotalForce(), and so does one @@ -263,14 +263,14 @@ double physics::Vehicle::ComputeMovement(double dt, double dt1, const TTrackShap } // tangential acceleration, from velocity change - AccSVBased = std::lerp(AccSVBased, (travelSpeed - Vprev) / dt, std::clamp(dt * 3.0, 0.0, 1.0)); + accSVBased = std::lerp(accSVBased, (travelSpeed - Vprev) / dt, std::clamp(dt * 3.0, 0.0, 1.0)); // vertical acceleration accVert = std::abs(accVert) < 0.01 ? 0.0 : accVert * 0.5; // szarpanie /* #ifdef EU07_USE_FUZZYLOGIC - if( FuzzyLogic( ( 10.0 + Track.DamageFlag ) * Mass * Vel / Vmax, 500000.0, p_accn ) ) { + if( FuzzyLogic( ( 10.0 + Track.DamageFlag ) * Mass * Vel / vmax, 500000.0, p_accn ) ) { // Ra: czemu tu masa bez ładunku? AccV /= ( 2.0 * 0.95 + 2.0 * Random() * 0.1 ); // 95-105% of base modifier (2.0) } @@ -346,7 +346,7 @@ double physics::Vehicle::FastComputeMovement(double dt, const TTrackShape & /*Sh { auto const AccSprev{accS}; // przyspieszenie styczne - accS = std::lerp(AccSprev, FTotal / TotalMass, 0.5); + accS = std::lerp(AccSprev, FTotal / totalMass, 0.5); // std::clamp( dt * 3.0, 0.0, 1.0 ) ); // prawo Newtona ale z wygladzaniem (średnia z poprzednim) if (DamageFlag.HasAll(VehicleDamage::derailed) && Derailed == derailment::outcome::none && false == legacy_derailed_slides(*this)) @@ -417,20 +417,20 @@ void physics::Vehicle::compute_movement_(double const Deltatime) // relay settings // adjust motor overload relay threshold - if (EngineType == TEngineType::ElectricSeriesMotor && ImaxHi > ImaxLo) + if (EngineType == TEngineType::ElectricSeriesMotor && imaxHi > imaxLo) { - if (MotorOverloadRelayHighThreshold) + if (motorOverloadRelayHighThreshold) { // set high threshold - if (TrainType != train_type::et42 ? RList[mainCtrlPos].Bn < 2 : mainCtrlPos == 0) + if (trainType != train_type::et42 ? RList[mainCtrlPos].Bn < 2 : mainCtrlPos == 0) { - Imax = ImaxHi; + Imax = imaxHi; } } else { // set low threshold - if (TrainType != train_type::et42 || mainCtrlPos == 0) + if (trainType != train_type::et42 || mainCtrlPos == 0) { - Imax = ImaxLo; + Imax = imaxLo; } } } @@ -620,21 +620,21 @@ bool physics::Vehicle::Sandbox(bool const State, range_t const Notify) { bool result{false}; - if (SandDose != State) + if (sandDose != State) { - if (SandDose == false) + if (sandDose == false) { // switch on if (Sand > 0 && DirActive != 0) { - SandDose = true; + sandDose = true; result = true; } } else { // switch off - SandDose = false; + sandDose = false; result = true; } } @@ -687,7 +687,7 @@ void physics::Vehicle::ComputeConstans(void) double HideModifier; double Curvature; // Ra 2014-07: odwrotność promienia - TotalMassxg = TotalMass * g; // TotalMass*g + TotalMassxg = totalMass * g; // TotalMass*g BearingF = DamageFlag.HasAny(VehicleDamage::bearing) ? 2.0 : 0; HideModifier = 0; // int(Couplers[0].CouplingFlag>0)+int(Couplers[1].CouplingFlag>0); @@ -701,7 +701,7 @@ void physics::Vehicle::ComputeConstans(void) // if (NPoweredAxles > 0) // RollF = RollF * 1.5; //dodatkowe lozyska silnikow - if (NPoweredAxles > 0) // drobna optymalka + if (nPoweredAxles > 0) // drobna optymalka { RollF += 0.025; // if (Ft * Ft < 1) @@ -745,7 +745,7 @@ void physics::Vehicle::ComputeConstans(void) void physics::Vehicle::ComputeMass() { // Ra: na razie tak, ale nie wszędzie masy wirujące się wliczają - TotalMass = Mass + Mred; + totalMass = Mass + mred; if (loadAmount == 0) { @@ -765,7 +765,7 @@ void physics::Vehicle::ComputeMass() loadtypeunitweight = lookup != simulation::Weights.end() ? lookup->second : 1000.f; // legacy default unit weight value } - TotalMass += loadAmount * loadtypeunitweight; + totalMass += loadAmount * loadtypeunitweight; } // ************************************************************************************************* @@ -803,7 +803,7 @@ void physics::Vehicle::ComputeTotalForce(double dt) wake_cause::neighbour); } - if (false == PhysicActivation) + if (false == physicActivation) { return; } @@ -817,12 +817,12 @@ void physics::Vehicle::ComputeTotalForce(double dt) // off the rails by the physical criteria: the vehicle slides on the sleepers and the ballast, or on its side; // off the track on the ground, as far as it tipped over (physics.derailment new) auto const friction{OffTrack.active() ? OffTrack.friction() : derailment::sliding_friction(Derailed)}; - FStand = friction * (TotalMass - Mred) * g; + FStand = friction * (totalMass - mred) * g; } else if (legacy_derailed_slides(*this)) { // derailed the legacy way with physics.collisions new: the deceleration of g of the legacy model, as a friction - FStand = TotalMass * g; + FStand = totalMass * g; } else { @@ -831,8 +831,8 @@ void physics::Vehicle::ComputeTotalForce(double dt) FStand *= 1e20; } } - double old_nrot = abs(nrot); - nrot = v2n(); // przeliczenie prędkości liniowej na obrotową + double old_nrot = abs(nrotValue); + nrotValue = v2n(); // przeliczenie prędkości liniowej na obrotową if (true == TestFlag(brakes.config.method, bp_MHS) && brakePipe.Pressure() < 3.0 // ustawione na sztywno na 3 bar && Vel > 45 && true == TestFlag(brakes.delaySetting, bdelay_M)) @@ -859,30 +859,30 @@ void physics::Vehicle::ComputeTotalForce(double dt) if (Vel > 0.1 // crude trap, to prevent braked stationary vehicles from passing fb > mass * adhesive test && std::abs(Fwheels) > TotalMassxg * Adhesive(RunningTrack.friction)) { - SlippingWheels = true; + slippingWheels = true; } - if (true == SlippingWheels && Vel < 0.1 // the same crude trap: (nearly) stopped vehicle... - && std::abs(nrot * M_PI * WheelDiameter - travelSpeed) < 0.1 / 3.6) // ...with wheels turning at its speed, i.e. locked wheels at the end of a skid + if (true == slippingWheels && Vel < 0.1 // the same crude trap: (nearly) stopped vehicle... + && std::abs(nrotValue * M_PI * wheelDiameter - travelSpeed) < 0.1 / 3.6) // ...with wheels turning at its speed, i.e. locked wheels at the end of a skid { // locked wheels never pass the rotation speed test below once the vehicle stops, and a skidding vehicle // keeps its braking force capped by the sliding adhesion, so the rest of the consist could push it around - SlippingWheels = false; - nrot = travelSpeed / M_PI / WheelDiameter; + slippingWheels = false; + nrotValue = travelSpeed / M_PI / wheelDiameter; } - double temp_nrot = nrot; - if (true == SlippingWheels) + double temp_nrot = nrotValue; + if (true == slippingWheels) { - temp_nrot = ComputeRotatingWheel(Fwheels - Sign(nrot * M_PI * WheelDiameter - travelSpeed) * Adhesive(RunningTrack.friction) * TotalMassxg, dt, nrot); - if (Sign(nrot * M_PI * WheelDiameter - travelSpeed) * Sign(temp_nrot * M_PI * WheelDiameter - travelSpeed) < 0) + temp_nrot = ComputeRotatingWheel(Fwheels - Sign(nrotValue * M_PI * wheelDiameter - travelSpeed) * Adhesive(RunningTrack.friction) * TotalMassxg, dt, nrotValue); + if (Sign(nrotValue * M_PI * wheelDiameter - travelSpeed) * Sign(temp_nrot * M_PI * wheelDiameter - travelSpeed) < 0) { - SlippingWheels = false; - temp_nrot = travelSpeed / M_PI / WheelDiameter; + slippingWheels = false; + temp_nrot = travelSpeed / M_PI / wheelDiameter; } } - if (true == SlippingWheels) + if (true == slippingWheels) { - Fwheels = Sign(temp_nrot * M_PI * WheelDiameter - travelSpeed) * TotalMassxg * Adhesive(RunningTrack.friction); + Fwheels = Sign(temp_nrot * M_PI * wheelDiameter - travelSpeed) * TotalMassxg * Adhesive(RunningTrack.friction); if (Fwheels * Sign(travelSpeed) > 0) { FTrain = Fwheels + Fb * Sign(travelSpeed); @@ -897,14 +897,14 @@ void physics::Vehicle::ComputeTotalForce(double dt) Fb *= factor; FTrain *= factor; } - if (std::abs(nrot) < 0.1) + if (std::abs(nrotValue) < 0.1) { - wheelFlat = sqrt(square(wheelFlat) + abs(Fwheels) / NAxles * Vel * 0.000002); + wheelFlat = sqrt(square(wheelFlat) + abs(Fwheels) / nAxles * Vel * 0.000002); } - nrot = temp_nrot; + nrotValue = temp_nrot; } - nrot_eps = (abs(nrot) - old_nrot) / dt; + nrot_eps = (abs(nrotValue) - old_nrot) / dt; // doliczenie sił z innych pojazdów for (auto const end : VehicleEnds) { @@ -944,7 +944,7 @@ double physics::Vehicle::BrakeForceR(double ratio, double velocity) const ratio = brakes.distributor->GetBrakeRatio(ratio); if (brakes.config.maxPressureMass > 2) { - press = brakes.config.maxCylinderPressure[1] + (brakes.config.maxCylinderPressure[3] - brakes.config.maxCylinderPressure[1]) * std::min(1.0, (TotalMass - Mass) / (brakes.config.maxPressureMass - Mass)); + press = brakes.config.maxCylinderPressure[1] + (brakes.config.maxCylinderPressure[3] - brakes.config.maxCylinderPressure[1]) * std::min(1.0, (totalMass - Mass) / (brakes.config.maxPressureMass - Mass)); } else { @@ -959,7 +959,7 @@ double physics::Vehicle::BrakeForceR(double ratio, double velocity) const ratio = ratio + (1.5 - ratio) * std::min(1.0, Vel * 0.02); if (brakes.delaySetting & bdelay_R && brakes.config.method % 128 != bp_Cosid && brakes.config.method % 128 != bp_D1 && brakes.config.method % 128 != bp_D2 && Power < 1) ratio *= brakes.distributor->GetRapidRatio(velocity); - if (TrainType == train_type::dmu && velocity < 30.0) + if (trainType == train_type::dmu && velocity < 30.0) { ratio -= 0.3; } @@ -972,8 +972,8 @@ double physics::Vehicle::BrakeForceP(double press, double velocity) const { double BFP = 0; double K = ((press * brakes.config.pressureToForce - brakes.config.cylinders.springForce) * brakes.config.cylinders.leverRatio[0] - brakes.config.cylinders.slackAdjusterForce) * brakes.config.cylinders.riggingEfficiency; - K *= static_cast(brakes.config.cylinders.count) / (NAxles * std::max(1, brakes.config.blocksPerAxle)); - BFP = brakes.distributor->GetFC(velocity, K) * K * (NAxles * std::max(1, brakes.config.blocksPerAxle)) * 1000; + K *= static_cast(brakes.config.cylinders.count) / (nAxles * std::max(1, brakes.config.blocksPerAxle)); + BFP = brakes.distributor->GetFC(velocity, K) * K * (nAxles * std::max(1, brakes.config.blocksPerAxle)) * 1000; return BFP; } @@ -1011,7 +1011,7 @@ double physics::Vehicle::BrakeForce(TTrackParam const & /*Track*/) } // the spring brake of a vehicle prepared for hauling (PulleeMode) is released by hand: no force, whatever its cylinder has - if (brakes.spring.isReady && false == PulleeMode) + if (brakes.spring.isReady && false == pulleeMode) K += std::max(0.0, brakes.spring.minForcePressure - brakes.spring.cylinder->P()) * brakes.spring.maxForce; u = (brakes.cylinderPressure * brakes.config.pressureToForce - brakes.config.cylinders.springForce) * brakes.config.cylinders.leverRatio[0] - brakes.config.cylinders.slackAdjusterForce; @@ -1024,7 +1024,7 @@ double physics::Vehicle::BrakeForce(TTrackParam const & /*Track*/) Ntotal = u * (2.0 - brakes.config.cylinders.riggingEfficiency); } - auto const NBrakeAxles{NAxles}; + auto const NBrakeAxles{nAxles}; if (NBrakeAxles * brakes.config.blocksPerAxle > 0) { @@ -1078,9 +1078,9 @@ double physics::Vehicle::Adhesive(double staticfriction) const /* // ABu: male przerobki, tylko czy to da jakikolwiek skutek w FPS? // w kazdym razie zaciemni kod na pewno :) - if (SlippingWheels == false) + if (slippingWheels == false) { - if (SandDose) + if (sandDose) adhesion = (std::max(staticfriction * (100.0 + Vel) / ((50.0 + Vel) * 11.0), 0.048)) * (11.0 - 2.0 * Random(0.0, 1.0)); else @@ -1089,7 +1089,7 @@ double physics::Vehicle::Adhesive(double staticfriction) const } else { - if (SandDose) + if (sandDose) adhesion = (0.048) * (11.0 - 2.0 * Random(0.0, 1.0)); else adhesion = (staticfriction * 0.02) * (11.0 - 2.0 * Random(0.0, 1.0)); @@ -1098,24 +1098,24 @@ double physics::Vehicle::Adhesive(double staticfriction) const return adhesion; //wersja druga - if( true == SlippingWheels ) { + if( true == slippingWheels ) { - if( true == SandDose ) { adhesion = 0.48; } + if( true == sandDose ) { adhesion = 0.48; } else { adhesion = staticfriction * 0.2; } } else { - if( true == SandDose ) { adhesion = std::max( staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ) * 1.1, 0.48 ); } + if( true == sandDose ) { adhesion = std::max( staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ) * 1.1, 0.48 ); } else { adhesion = staticfriction * ( 100.0 + Vel ) / ( 50.0 + Vel ); } } // adhesion *= ( 0.9 + 0.2 * Random() ); */ // wersja3 by youBy - uwzględnia naturalne mikropoślizgi i wpływ piasecznicy, usuwa losowość z pojazdu - double Vwheels = nrot * M_PI * WheelDiameter; // predkosc liniowa koła wynikająca z obrotowej + double Vwheels = nrotValue * M_PI * wheelDiameter; // predkosc liniowa koła wynikająca z obrotowej double deltaV = travelSpeed - Vwheels; // poślizg - różnica prędkości w punkcie styku koła i szyny deltaV = std::max(0.0, std::abs(deltaV) - 0.25); // mikropoślizgi do ok. 0,25 m/s nie zrywają przyczepności Vwheels = std::abs(Vwheels); - adhesion = staticfriction * (28 + Vwheels) / (14 + Vwheels) * ((SandDose ? sandfactor : 1) - (1 - adh_factor) * (deltaV / (deltaV + slipfactor))); + adhesion = staticfriction * (28 + Vwheels) / (14 + Vwheels) * ((sandDose ? sandfactor : 1) - (1 - adh_factor) * (deltaV / (deltaV + slipfactor))); return adhesion; } @@ -1132,7 +1132,7 @@ double physics::Vehicle::ComputeRotatingWheel(double WForce, double dt, double n newn = 0; else { - eps = WForce * WheelDiameter / (2.0 * AxleInertialMoment); + eps = WForce * wheelDiameter / (2.0 * AxleInertialMoment); newn = n + eps * dt; if (newn * n <= 0 && eps * n < 0) newn = 0; @@ -1262,7 +1262,7 @@ void physics::Vehicle::wake_for_brake() // ************************************************************************************************* bool physics::Vehicle::brakes_changed_asleep() const { - if (PhysicActivation) + if (physicActivation) return false; constexpr double pressure_change{0.05}; // [bar] return std::abs(brakes.cylinderPressure - sleep_brakes.cylinder) > pressure_change || std::abs(brakes.spring.pressure - sleep_brakes.spring) > pressure_change || @@ -1274,12 +1274,12 @@ bool physics::Vehicle::brakes_changed_asleep() const // ************************************************************************************************* bool physics::Vehicle::switch_physics(bool const State, wake_cause const Cause) // DO PRZETLUMACZENIA NA KONCU { - if (PhysicActivation == State) + if (physicActivation == State) { return false; } - PhysicActivation = State; + physicActivation = State; if (true == State) { LastSwitchingTime = 0; @@ -1315,12 +1315,12 @@ void physics::Vehicle::SetEquipmentFaults(EquipmentFaultSet const Faults) if (Faults.HasAll(EquipmentFault::control)) // usterka sterowania { lineContactors.Open(); - if (InitialCtrlDelay < faultthreshold) - InitialCtrlDelay += faultoffset; + if (initialCtrlDelay < faultthreshold) + initialCtrlDelay += faultoffset; } - else if (InitialCtrlDelay > faultthreshold) + else if (initialCtrlDelay > faultthreshold) { - InitialCtrlDelay -= faultoffset; + initialCtrlDelay -= faultoffset; } if (Faults.HasAll(EquipmentFault::converter) && converter.config.start != start_t::disabled) // blokada przetwornicy { @@ -1344,3 +1344,8 @@ void physics::Vehicle::SetEquipmentFaults(EquipmentFaultSet const Faults) // hamowanie nagłe (emergencyBrake): nothing yet equipmentFaults = Faults; } + +void physics::Vehicle::ClearAIFlag(int const Flag) +{ + ClearFlag(aiFlag, Flag); +} diff --git a/physics/components/cab.cpp b/physics/components/cab.cpp index 1b421558b..65dd87b91 100644 --- a/physics/components/cab.cpp +++ b/physics/components/cab.cpp @@ -44,7 +44,7 @@ bool physics::Vehicle::DirectionForward() SendCtrlToNext(VehicleCommand::direction, DirActive, CabActive); return true; } - else if (DirActive == 1 && IsMainCtrlNoPowerPos() && TrainType == train_type::emu && EngineType != TEngineType::ElectricInductionMotor) + else if (DirActive == 1 && IsMainCtrlNoPowerPos() && trainType == train_type::emu && EngineType != TEngineType::ElectricInductionMotor) return MinCurrentSwitch(true); //"wysoki rozruch" EN57 return false; }; @@ -86,7 +86,7 @@ int physics::Vehicle::SoundingHorns(int const Signal) const return false == mainpipe || mainPipe.Pressure() >= HornMinPressure; }}; auto horns{0}; - if (supplied(HornSupply)) + if (supplied(hornSupply)) { horns |= Signal & (1 | 2); } @@ -106,7 +106,7 @@ bool physics::Vehicle::CabActivisation(bool const Enforce) bool OK = false; OK = Enforce || CabActive == 0; // numer kabiny, z której jest sterowanie - if (PulleeMode) + if (pulleeMode) { // nobody drives from a vehicle prepared for hauling OK = false; @@ -115,7 +115,7 @@ bool physics::Vehicle::CabActivisation(bool const Enforce) { CabActive = cabOccupied; // sterowanie jest z kabiny z obsadą DirAbsolute = DirActive * CabActive; - CabMaster = true; + cabMaster = true; SecuritySystem.set_enabled(true); // activate the alerter TODO: make it part of control based cab selection SendCtrlToNext(VehicleCommand::cabActivation, 1, CabActive); SendCtrlToNext(VehicleCommand::direction, DirActive, CabActive); @@ -165,7 +165,7 @@ bool physics::Vehicle::CabDeactivisation(bool const Enforce) CabActive = 0; DirAbsolute = DirActive * CabActive; - CabMaster = false; + cabMaster = false; DepartureSignal = false; // nie buczeć z nieaktywnej kabiny SecuritySystem.set_enabled(false); // deactivate alerter TODO: make it part of control based cab selection @@ -194,12 +194,12 @@ bool physics::Vehicle::CabDeactivisationAuto(bool const Enforce) // ************************************************************************************************* bool physics::Vehicle::PulleeModeSwitch(bool const State) { - if (PulleeMode == State || (State && CabActive != 0)) + if (pulleeMode == State || (State && CabActive != 0)) { return false; } - PulleeMode = State; - if (PulleeMode) + pulleeMode = State; + if (pulleeMode) { DecManualBrakeLevel(ManualBrakePosNo); brakes.spring.activate = false; @@ -220,7 +220,7 @@ bool physics::Vehicle::DirectionBackward(void) return false; } - if (DirActive == 1 && mainCtrlPos == 0 && TrainType == train_type::emu && EngineType != TEngineType::ElectricInductionMotor && MinCurrentSwitch(false)) + if (DirActive == 1 && mainCtrlPos == 0 && trainType == train_type::emu && EngineType != TEngineType::ElectricInductionMotor && MinCurrentSwitch(false)) { return true; } @@ -245,6 +245,6 @@ bool physics::Vehicle::EIMDirectionChangeAllow(void) const // NOTE: disabled while eimic variables aren't immediately synced with master controller changes inside ai module OK = (EngineType != TEngineType::ElectricInductionMotor || ((eimic <= 0) && (eimic_real <= 0) && (Vel < 0.1))); */ - OK = mainCtrlPos <= MainCtrlMaxDirChangePos; + OK = mainCtrlPos <= mainCtrlMaxDirChangePos; return OK; } diff --git a/physics/components/collisions.cpp b/physics/components/collisions.cpp index 4d62b829e..687466138 100644 --- a/physics/components/collisions.cpp +++ b/physics/components/collisions.cpp @@ -116,12 +116,12 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt) { case VehicleEnd::front: { - CCF = ComputeCollision(velocity, othervehiclevelocity, TotalMass, othervehicle->TotalMass, loss, VirtualCoupling) / dt; + CCF = ComputeCollision(velocity, othervehiclevelocity, totalMass, othervehicle->totalMass, loss, VirtualCoupling) / dt; break; // yB: ej ej ej, a po } case VehicleEnd::rear: { - CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->TotalMass, TotalMass, loss, VirtualCoupling) / dt; + CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->totalMass, totalMass, loss, VirtualCoupling) / dt; break; } default: @@ -152,11 +152,11 @@ void physics::Vehicle::CollisionDetect(VehicleEnd const End, double const dt) WriteLog("Bad driving: " + Name + " and " + othervehicle->Name + " collided with velocity " + to_string(velocitydifference, 0) + " km/h"); } - if (velocitydifference > SafeCollisionVelocity * (TotalMass / othervehicle->TotalMass)) + if (velocitydifference > SafeCollisionVelocity * (totalMass / othervehicle->totalMass)) { Derail(COLLISION); } - if (velocitydifference > SafeCollisionVelocity * (othervehicle->TotalMass / TotalMass)) + if (velocitydifference > SafeCollisionVelocity * (othervehicle->totalMass / totalMass)) { othervehicle->Derail(COLLISION); } @@ -260,17 +260,17 @@ void physics::Vehicle::derail_in_collision(DerailReason const Reason, std::strin } // upright, it slides on the sleepers and keeps passing the forces on Derailed = derailment::outcome::off_rails; - DerailCause = derail_motion::cause::collision; - DerailAcceleration = 0.0; - DerailSide = 0; - CollisionDerail = Reason; + derailCause = derail_motion::cause::collision; + derailAcceleration = 0.0; + derailSide = 0; + collisionDerail = Reason; eventFlag = true; MainSwitch(false, range_t::local); if (Vel < 5.0) { // HACK: prevent permanent axle spin in static vehicle after a collision - nrot = 0.0; - SlippingWheels = false; + nrotValue = 0.0; + slippingWheels = false; } // the brake hoses tear: the brake pipe vents and the rest of the train brakes in emergency tear_brake_hoses(*this); @@ -379,8 +379,8 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt) return false; } constexpr double immovable{1e12}; - auto const mass{wall ? immovable : TotalMass}; - auto const othermass{otherwall ? immovable : othervehicle->TotalMass}; + auto const mass{wall ? immovable : totalMass}; + auto const othermass{otherwall ? immovable : othervehicle->totalMass}; auto const loss{physical ? coupler_physics::solid_hit_loss(thiscoupler.physics, othercoupler.physics) : (thiscoupler.beta + othercoupler.beta) / 2.0}; auto const firstcurve{crush_curve_at(End)}; @@ -410,8 +410,8 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt) collision::override_input climbing; climbing.crush1 = Crush1; climbing.crush2 = Crush2; - climbing.mass1 = TotalMass - Mred; - climbing.mass2 = othervehicle->TotalMass - othervehicle->Mred; + climbing.mass1 = totalMass - mred; + climbing.mass2 = othervehicle->totalMass - othervehicle->mred; climbing.height1 = buffer_height_at(End); climbing.height2 = othervehicle->buffer_height_at(otherend); climbing.anticlimbers = collision::anticlimber_of(thiscoupler.collision, collision_kind()) && collision::anticlimber_of(othercoupler.collision, othervehicle->collision_kind()); @@ -425,7 +425,7 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt) { thiscoupler.crush_monitored = true; othercoupler.crush_monitored = true; - ++crush_reports; + ++crushreportsValue; auto const crush1{thiscoupler.crush + hit.crush1}; auto const crush2{othercoupler.crush + hit.crush2}; auto const climbed{collision::override_of(climbing_of(crush1, crush2))}; @@ -436,8 +436,8 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt) : std::string{"both would stay on the rails"}}; WriteLog(std::format("collision monitor: {} and {} collided at {:.0f} km/h: the {} end of {} ({:.1f} t {}) would crush by {:.2f} m, the {} end of {} ({:.1f} t {}) by {:.2f} m, " "at {:.0f} kN; draw gear {}; {}", - Name, othervehicle->Name, closing * 3.6, end_name(End), Name, TotalMass / 1000.0, kind_name(collision_kind()), crush1, end_name(otherend), othervehicle->Name, - othervehicle->TotalMass / 1000.0, kind_name(othervehicle->collision_kind()), crush2, hit.force / 1000.0, torn ? "torn off" : "holds", outcome)); + Name, othervehicle->Name, closing * 3.6, end_name(End), Name, totalMass / 1000.0, kind_name(collision_kind()), crush1, end_name(otherend), othervehicle->Name, + othervehicle->totalMass / 1000.0, kind_name(othervehicle->collision_kind()), crush2, hit.force / 1000.0, torn ? "torn off" : "holds", outcome)); } return false; } @@ -480,8 +480,8 @@ bool physics::Vehicle::crush_hit(VehicleEnd const End, double const dt) return std::format("{} {:.1f} t {}, {} end crushed {:.2f} m, gives at {:.0f} kN; {} {:.1f} t {}, {} end crushed {:.2f} m, gives at {:.0f} kN; force {:.0f} kN, springs {:.0f} kN, " "closing at {:.1f} km/h at the start of the step; energy {:.0f} kJ of the motion and {:.0f} kJ in the buffers, past the {:.0f} kJ they take in, " "{:.0f} kJ crushed in the contact", - Name, TotalMass / 1000.0, kind_name(collision_kind()), end_name(End), thiscoupler.crush, firstcurve.force(thiscoupler.crush) / 1000.0, othervehicle->Name, - othervehicle->TotalMass / 1000.0, kind_name(othervehicle->collision_kind()), end_name(otherend), othercoupler.crush, + Name, totalMass / 1000.0, kind_name(collision_kind()), end_name(End), thiscoupler.crush, firstcurve.force(thiscoupler.crush) / 1000.0, othervehicle->Name, + othervehicle->totalMass / 1000.0, kind_name(othervehicle->collision_kind()), end_name(otherend), othercoupler.crush, secondcurve.force(othercoupler.crush) / 1000.0, hit.force / 1000.0, springs / 1000.0, input.start_velocity * 3.6, kinetic / 1000.0, thiscoupler.contact.absorbed() / 1000.0, capacity / 1000.0, thiscoupler.contact.crush_work() / 1000.0); }; @@ -548,11 +548,11 @@ void physics::Vehicle::check_pushed_off(double const dt, double const Distance) return; } collision::pushed_vehicle vehicle; - vehicle.mass = TotalMass - Mred; - vehicle.axles = NAxles > 0 ? NAxles : 4; + vehicle.mass = totalMass - mred; + vehicle.axles = nAxles > 0 ? nAxles : 4; vehicle.length = Dim.L; - vehicle.pivots = BDist; - vehicle.axle_base = ADist > 0.0 ? ADist : BDist; + vehicle.pivots = bDist; + vehicle.axle_base = aDist > 0.0 ? aDist : bDist; auto climbs{false}; auto distance{0.0}; @@ -670,7 +670,7 @@ double physics::Vehicle::centre_of_gravity() const { auto const kind{EngineType == TEngineType::None ? derailment::vehicle_class::unpowered : derailment::vehicle_class::powered}; auto const empty{CentreOfGravity > 0.0 ? CentreOfGravity : derailment::default_centre_of_gravity(Dim.H, kind)}; - auto const loadmass{TotalMass - Mass - Mred}; + auto const loadmass{totalMass - Mass - mred}; auto const loadshare{maxLoad > 0.f ? loadAmount / maxLoad : 1.0}; return derailment::loaded_centre_of_gravity(empty, Mass, loadmass, loadshare, Floor, Dim.H); } @@ -683,10 +683,10 @@ void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam co return; } derailment::vehicle_state vehicle; - vehicle.mass = TotalMass - Mred; - vehicle.axles = NAxles > 0 ? NAxles : 4; + vehicle.mass = totalMass - mred; + vehicle.axles = nAxles > 0 ? nAxles : 4; vehicle.length = Dim.L; - vehicle.axle_base = ADist > 0.0 ? ADist : BDist; + vehicle.axle_base = aDist > 0.0 ? aDist : bDist; vehicle.centre_of_gravity = centre_of_gravity(); for (auto const end : VehicleEnds) { @@ -724,7 +724,7 @@ void physics::Vehicle::check_derailment(TTrackShape const &Shape, TTrackParam co return; } derailment_reported = Track.Name; - ++derailment_reports; + ++derailmentreportsValue; WriteLog("derailment monitor: " + Name + " " + derailment::report(verdict, vehicle, track, travelSpeed, Track.Name != nullptr ? *Track.Name : std::string{})); } @@ -735,10 +735,10 @@ void physics::Vehicle::derail(derailment::verdict const &Verdict, derailment::ve return; } Derailed = Verdict.result; - DerailCause = Verdict.result == derailment::outcome::overturned ? derail_motion::cause::overturned : derail_motion::cause::off_rails; + derailCause = Verdict.result == derailment::outcome::overturned ? derail_motion::cause::overturned : derail_motion::cause::off_rails; // out of the curve; a buckle bending the line against the curve more than the curve does throws it into the curve - DerailAcceleration = std::abs(Track.radius) > 1e-3 && derailment::line_curvature(Track) < 0.0 ? -Verdict.acceleration : Verdict.acceleration; - DerailSide = 0; + derailAcceleration = std::abs(Track.radius) > 1e-3 && derailment::line_curvature(Track) < 0.0 ? -Verdict.acceleration : Verdict.acceleration; + derailSide = 0; eventFlag = true; MainSwitch(false, range_t::local); // the brake hoses tear: the brake pipe vents and the rest of the train brakes in emergency @@ -757,14 +757,14 @@ void physics::Vehicle::rerail() Derailed = derailment::outcome::none; // and back on the track; what derailed it before has no say in how it leaves the track the next time OffTrack.reset(); - DerailCause = derail_motion::cause::off_rails; - DerailAcceleration = 0.0; - DerailSide = 0; + derailCause = derail_motion::cause::off_rails; + derailAcceleration = 0.0; + derailSide = 0; derailment_monitor.reset(); derailmentDistance = 0.0; derailment_reported.reset(); // nor derailed in a collision - CollisionDerail = NONE; + collisionDerail = NONE; pushed_off_monitor.reset(); // back on the axis of the track, which the derailment shifted the vehicle off aside and down (a road vehicle keeps // its place on the road) @@ -814,17 +814,17 @@ void physics::Vehicle::Derail(DerailReason const Reason) if (Vel < 5.0) { // HACK: prevent permanent axle spin in static vehicle after a collision - nrot = 0.0; - SlippingWheels = false; + nrotValue = 0.0; + slippingWheels = false; } // physics.derailment new: off the end of the track the vehicle runs on straight on its wheels, sliding on the // ground as the vehicles the criteria derail do, and its brake hoses tear if (Reason == END_OF_TRACK && Global.derailment == global_settings::derailment_model::physical && TestFlag(CategoryFlag, 1)) { Derailed = derailment::outcome::off_rails; - DerailCause = derail_motion::cause::end_of_track; - DerailAcceleration = 0.0; - DerailSide = 0; + derailCause = derail_motion::cause::end_of_track; + derailAcceleration = 0.0; + derailSide = 0; tear_brake_hoses(*this); } @@ -858,9 +858,9 @@ void physics::Vehicle::pull_off(int const Side, double const Acceleration, std:: } // upright, its flange climbs the rail the coupling pulls it over Derailed = derailment::outcome::off_rails; - DerailCause = derail_motion::cause::pulled_off; - DerailAcceleration = Acceleration; - DerailSide = Side; + derailCause = derail_motion::cause::pulled_off; + derailAcceleration = Acceleration; + derailSide = Side; eventFlag = true; MainSwitch(false, range_t::local); tear_brake_hoses(*this); diff --git a/physics/components/commands.cpp b/physics/components/commands.cpp index 50e26c96d..2fd4228da 100644 --- a/physics/components/commands.cpp +++ b/physics/components/commands.cpp @@ -142,9 +142,9 @@ bool physics::Vehicle::RunControllerCommand(VehicleCommand const Command, double if (auto const position{MainCtrlPosFromCoupled(static_cast(floor(CValue1)))}; MainCtrlPosNo >= position) { mainCtrlPos = position; - if (DelayCtrlFlag) + if (delayCtrlFlag) { - if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay && mainCtrlPos == 1) + if (lineContactors.TimeSinceSwitch() >= initialCtrlDelay && mainCtrlPos == 1) lineContactors.RestartSwitchTimer(); } else if (lineContactors.TimeSinceSwitch() > CtrlDelay) @@ -154,7 +154,7 @@ bool physics::Vehicle::RunControllerCommand(VehicleCommand const Command, double } else if (Command == VehicleCommand::secondaryController) { - if (ScndCtrlPosNo >= floor(CValue1)) + if (scndCtrlPosNo >= floor(CValue1)) { scndCtrlPos = static_cast(floor(CValue1)); if (lineContactors.TimeSinceSwitch() > CtrlDelay) @@ -193,10 +193,10 @@ bool physics::Vehicle::RunRelaysCommand(VehicleCommand const Command, double CVa } else if (Command == VehicleCommand::autoRelaySwitch) { - if (CValue1 == 1 && AutoRelayType == 2) - AutoRelayFlag = true; + if (CValue1 == 1 && autoRelayType == 2) + autoRelayFlag = true; else - AutoRelayFlag = false; + autoRelayFlag = false; OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } else if (Command == VehicleCommand::maxCurrentSwitch) @@ -240,18 +240,18 @@ bool physics::Vehicle::RunCabCommand(VehicleCommand const Command, double CValue break; } } - if (PulleeMode) + if (pulleeMode) { // a vehicle prepared for hauling takes no cab, the command only passes through it CabActive = 0; } DirAbsolute = DirActive * CabActive; - CabMaster = false; + cabMaster = false; OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } else if (Command == VehicleCommand::speedControl) { - if (EngineType == TEngineType::ElectricInductionMotor || SpeedCtrl) + if (EngineType == TEngineType::ElectricInductionMotor || speedCtrl) SpeedCtrlValue = static_cast(round(CValue1)); OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } @@ -370,7 +370,7 @@ bool physics::Vehicle::RunAuxiliariesCommand(VehicleCommand const Command, doubl else if (Command == VehicleCommand::batterySwitch) /*NBMX*/ { // the battery of a vehicle prepared for hauling (PulleeMode) stays off - if (false == PulleeMode || CValue1 <= 0.0) + if (false == pulleeMode || CValue1 <= 0.0) { lowVoltage.SwitchBattery(CValue1 > 0.0); } @@ -463,7 +463,7 @@ bool physics::Vehicle::RunPumpsCommand(VehicleCommand const Command, double CVal if (true == diesel.heat.auxiliary_water_circuit) { // can only link circuits if the vehicle has more than one of them - WaterCircuitsLink = CValue1 == 1; + waterCircuitsLink = CValue1 == 1; } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } @@ -594,7 +594,7 @@ bool physics::Vehicle::RunPowerCommand(VehicleCommand const Command, double CVal auto const inputend{(static_cast(CValue1) & 0x80) != 0 ? 1 : 0}; auto const inputcab{(static_cast(CValue1) & 0x40) != 0 ? 1 : 0}; auto const inputoperation{static_cast(CValue1) & ~(0x80 | 0x40)}; - auto const noswap{TrainType == train_type::emu || TrainType == train_type::et41}; + auto const noswap{trainType == train_type::emu || trainType == train_type::et41}; auto swap{false == noswap && Couplers[CValue2 == -1 ? VehicleEnd::rear : VehicleEnd::front].CouplingFlag.HasAll(Coupling::control)}; if (auto const reversed{inputcab != (CabActive != -1 ? 1 : 0)}; reversed) { diff --git a/physics/components/controllers.cpp b/physics/components/controllers.cpp index e54a8beb5..364feb8be 100644 --- a/physics/components/controllers.cpp +++ b/physics/components/controllers.cpp @@ -48,12 +48,12 @@ bool physics::Vehicle::IncMainCtrl(int CtrlSpeed) // nie ma sterowania return false; } - if (TrainType == train_type::et22 && scndCtrlPos != 0) + if (trainType == train_type::et22 && scndCtrlPos != 0) { // w ET22 nie da się kręcić nastawnikiem przy włączonym boczniku return false; } - if (TrainType == train_type::emu && DirActive == 0) + if (trainType == train_type::emu && DirActive == 0) { // w EZT nie da się załączyć pozycji bez ustawienia kierunku return false; @@ -69,7 +69,7 @@ bool physics::Vehicle::IncMainCtrl(int CtrlSpeed) if (true == CoupledCtrl) { // wspólny wał nastawnika jazdy i bocznikowania - if (scndCtrlPos < ScndCtrlPosNo) + if (scndCtrlPos < scndCtrlPosNo) { // 3<3 -> false ++scndCtrlPos; OK = true; @@ -95,9 +95,9 @@ bool physics::Vehicle::IncMainCtrl(int CtrlSpeed) if (OK) { - if (DelayCtrlFlag) + if (delayCtrlFlag) { - if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay && mainCtrlPos == 1) + if (lineContactors.TimeSinceSwitch() >= initialCtrlDelay && mainCtrlPos == 1) lineContactors.RestartSwitchTimer(); } else if (lineContactors.TimeSinceSwitch() > CtrlDelay) @@ -125,7 +125,7 @@ bool physics::Vehicle::IncMainCtrlSeriesMotor(int const CtrlSpeed) if (CtrlSpeed > 1) { // szybkie przejœcie na bezoporow¹ - if (TrainType == train_type::et40) + if (trainType == train_type::et40) { return false; // this means ET40 won't react at all to fast acceleration command. should it issue just IncMainCtrl(1) instead? } @@ -143,7 +143,7 @@ bool physics::Vehicle::IncMainCtrlSeriesMotor(int const CtrlSpeed) { // CtrlSpeed == 1 ++mainCtrlPos; OK = true; - if (Imax == ImaxHi && RList[mainCtrlPos].Bn > 1) + if (Imax == imaxHi && RList[mainCtrlPos].Bn > 1) { /* NOTE: disabled, relay configuration was moved to compute_movement_ if( true == MaxCurrentSwitch( false )) { @@ -151,7 +151,7 @@ bool physics::Vehicle::IncMainCtrlSeriesMotor(int const CtrlSpeed) SetFlag( soundFlag, sound::relay ); } */ - if (TrainType == train_type::et42) + if (trainType == train_type::et42) { --mainCtrlPos; OK = false; @@ -167,7 +167,7 @@ bool physics::Vehicle::IncMainCtrlSeriesMotor(int const CtrlSpeed) //} } - if (TrainType == train_type::et42 && true == brakes.electrodynamic.on && mainCtrlPos > 20) + if (trainType == train_type::et42 && true == brakes.electrodynamic.on && mainCtrlPos > 20) { mainCtrlPos = 20; OK = false; @@ -197,7 +197,7 @@ bool physics::Vehicle::DecMainCtrl(int CtrlSpeed) // TBD, TODO: replace with mainctrlpowerpos() check? if (mainCtrlPos > 0) { - if (TrainType != train_type::et22 || scndCtrlPos == 0) // Ra: ET22 blokuje nastawnik przy boczniku + if (trainType != train_type::et22 || scndCtrlPos == 0) // Ra: ET22 blokuje nastawnik przy boczniku { if (CoupledCtrl && scndCtrlPos > 0) { @@ -224,9 +224,9 @@ bool physics::Vehicle::DecMainCtrl(int CtrlSpeed) // hunter-101012: poprawka if (OK) { - if (DelayCtrlFlag) + if (delayCtrlFlag) { - if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay) + if (lineContactors.TimeSinceSwitch() >= initialCtrlDelay) lineContactors.RestartSwitchTimer(); } else if (lineContactors.TimeSinceSwitch() > CtrlDownDelay) @@ -323,7 +323,7 @@ int physics::Vehicle::MainCtrlPowerPos() const int physics::Vehicle::EIMCtrlEmergencyPositions() const { - return (EIMCtrlType == 2 && EIMCtrlMainEmergency) ? 1 : 0; + return (EIMCtrlType == 2 && eimCtrlMainEmergency) ? 1 : 0; } bool physics::Vehicle::IsMainCtrlEmergencyPos() const @@ -350,20 +350,20 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed) { bool OK = false; - if (brakes.electrodynamic.on && TrainType == train_type::et42 && CabActive != 0 && IsMainCtrlNoPowerPos() && scndCtrlPos == 0) + if (brakes.electrodynamic.on && trainType == train_type::et42 && CabActive != 0 && IsMainCtrlNoPowerPos() && scndCtrlPos == 0) { OK = DynamicBrakeSwitch(false); } - else if (ScndCtrlPosNo > 0 && CabActive != 0 && !(TrainType == train_type::et42 && (Imax == ImaxHi || (brakes.electrodynamic.on && MainCtrlPowerPos() > 0)))) + else if (scndCtrlPosNo > 0 && CabActive != 0 && !(trainType == train_type::et42 && (Imax == imaxHi || (brakes.electrodynamic.on && MainCtrlPowerPos() > 0)))) { // if (RList[mainCtrlPos].R=0) and (mainCtrlPos>0) and (scndCtrlPos 1) { - scndCtrlPos = ScndCtrlPosNo; // takie chamskie, potem poprawie + scndCtrlPos = scndCtrlPosNo; // takie chamskie, potem poprawie } OK = true; } @@ -395,7 +395,7 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed) if (OK && lineContactors.TimeSinceSwitch() > CtrlDelay) lineContactors.RestartSwitchTimer(); - if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1 && mainCtrlPos > 0) + if (OK && EngineType == TEngineType::ElectricInductionMotor && scndCtrlPosNo == 1 && mainCtrlPos > 0) { SpeedCtrlValue = Vel; if (EIMCtrlType == 0 && (SpeedCtrlAutoTurnOffFlag & 1) == 1) @@ -405,7 +405,7 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed) SpeedCtrlUnit.IsActive = true; } - if (OK && SpeedCtrl && scndCtrlPos == 1 && EngineType == TEngineType::DieselEngine) + if (OK && speedCtrl && scndCtrlPos == 1 && EngineType == TEngineType::DieselEngine) { // NOTE: round() already adds 0.5, are the ones added here as well correct? SpeedCtrlValue = static_cast(Round(Vel)); @@ -423,14 +423,14 @@ bool physics::Vehicle::DecScndCtrl(int CtrlSpeed) { bool OK = false; - if (IsMainCtrlNoPowerPos() && CabActive != 0 && TrainType == train_type::et42 && scndCtrlPos == 0 && !brakes.electrodynamic.on && CtrlSpeed == 1) + if (IsMainCtrlNoPowerPos() && CabActive != 0 && trainType == train_type::et42 && scndCtrlPos == 0 && !brakes.electrodynamic.on && CtrlSpeed == 1) { // Ra: AI wywołuje z CtrlSpeed=2 albo gdy scndCtrlPos>0 OK = DynamicBrakeSwitch(true); } - else if (ScndCtrlPosNo > 0 && CabActive != 0) + else if (scndCtrlPosNo > 0 && CabActive != 0) { - if (scndCtrlPos > 0 && !CoupledCtrl && (EngineType != TEngineType::DieselElectric || !AutoRelayFlag) && !IsScndCtrlLockedByMainCtrl()) + if (scndCtrlPos > 0 && !CoupledCtrl && (EngineType != TEngineType::DieselElectric || !autoRelayFlag) && !IsScndCtrlLockedByMainCtrl()) { if (CtrlSpeed == 1) { @@ -457,7 +457,7 @@ bool physics::Vehicle::DecScndCtrl(int CtrlSpeed) if (OK && lineContactors.TimeSinceSwitch() > CtrlDownDelay) lineContactors.RestartSwitchTimer(); - if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1) + if (OK && EngineType == TEngineType::ElectricInductionMotor && scndCtrlPosNo == 1) { SpeedCtrlValue = 0; SpeedCtrlUnit.IsActive = false; @@ -467,7 +467,7 @@ bool physics::Vehicle::DecScndCtrl(int CtrlSpeed) } } - if (OK && SpeedCtrl && scndCtrlPos == 0 && EngineType == TEngineType::DieselEngine) + if (OK && speedCtrl && scndCtrlPos == 0 && EngineType == TEngineType::DieselEngine) { SpeedCtrlValue = 0; SpeedCtrlUnit.IsActive = false; @@ -498,7 +498,7 @@ void physics::Vehicle::ScndCtrlResistiveLockCheck() int physics::Vehicle::GetVirtualScndPos() const { - if (TrainType == train_type::et42 && brakes.electrodynamic.on && !scndCtrlPos) + if (trainType == train_type::et42 && brakes.electrodynamic.on && !scndCtrlPos) return -1; return scndCtrlPos; } @@ -506,13 +506,13 @@ int physics::Vehicle::GetVirtualScndPos() const bool physics::Vehicle::IsScndCtrlNoPowerPos() const { // TODO: refine the check on account of potential electric series vehicles with speed control - return scndCtrlPos == 0 || true == SpeedCtrl; + return scndCtrlPos == 0 || true == speedCtrl; } bool physics::Vehicle::IsScndCtrlMaxPowerPos() const { // TODO: refine the check on account of potential electric series vehicles with speed control - return scndCtrlPos == ScndCtrlPosNo || true == SpeedCtrl; + return scndCtrlPos == scndCtrlPosNo || true == speedCtrl; } // ************************************************************************************************* @@ -522,9 +522,9 @@ bool physics::Vehicle::IsScndCtrlMaxPowerPos() const bool physics::Vehicle::AutoRelaySwitch(bool State) { bool ARS; - if (AutoRelayType == 2 && AutoRelayFlag != State) + if (autoRelayType == 2 && autoRelayFlag != State) { - AutoRelayFlag = State; + autoRelayFlag = State; ARS = true; SendCtrlToNext(VehicleCommand::autoRelaySwitch, int(State), CabActive); } @@ -559,9 +559,9 @@ bool physics::Vehicle::AutoRelayCheck(void) } // sprawdzenie wszystkich warunkow (AutoRelayFlag, AutoSwitch, Im scndCtrlPos) { - if (lineContactors.TimeSinceSwitch() > CtrlDownDelay && TrainType != train_type::emu) + if (lineContactors.TimeSinceSwitch() > CtrlDownDelay && trainType != train_type::emu) { --ScndCtrlActualPos; SetFlag(soundFlag, sound::shuntfield); @@ -626,11 +626,11 @@ bool physics::Vehicle::AutoRelayMainStep(bool const ARFASI) // running backwards, the motors don't get joined in more branches than allowed (the series connection // alone, usually); the camshaft still goes back down from there (eu07/maszyna#393: it stayed where it // was, the line contactors closed, whatever the driver did with the master controller) - auto const backwardslimit{DirActive < 0 && TrainType != train_type::pseudodiesel && RList[MainCtrlActualPos + 1].Bn > BackwardsBranchesAllowed}; + auto const backwardslimit{DirActive < 0 && trainType != train_type::pseudodiesel && RList[MainCtrlActualPos + 1].Bn > BackwardsBranchesAllowed}; // main bez samoczynnego rozruchu if (false == backwardslimit && MainCtrlActualPos < std::size(RList) - 1 // crude guard against running out of current fixed table && (RList[MainCtrlActualPos].Relay < mainCtrlPos || (RList[MainCtrlActualPos + 1].Relay == mainCtrlPos && MainCtrlActualPos < RlistSize) || - (TrainType == train_type::et22 && DelayCtrlFlag))) + (trainType == train_type::et22 && delayCtrlFlag))) { OK = AutoRelayMainUp(ARFASI); } @@ -695,19 +695,19 @@ bool physics::Vehicle::AutoRelayMainNotchUp() bool OK = false; // WriteLog("LRT = " + FloatToStr(LastRelayTime) + ", " + // FloatToStr(CtrlDelay)); - if (TrainType == train_type::et22 && mainCtrlPos > 1 && (RList[MainCtrlActualPos].Bn < RList[MainCtrlActualPos + 1].Bn || DelayCtrlFlag)) + if (trainType == train_type::et22 && mainCtrlPos > 1 && (RList[MainCtrlActualPos].Bn < RList[MainCtrlActualPos + 1].Bn || delayCtrlFlag)) { // et22 z walem grupowym - if (!DelayCtrlFlag) // najpierw przejscie + if (!delayCtrlFlag) // najpierw przejscie { ++MainCtrlActualPos; - DelayCtrlFlag = true; // tryb przejscia + delayCtrlFlag = true; // tryb przejscia OK = true; } else if (lineContactors.TimeSinceSwitch() > 4 * CtrlDelay) // przejscie { - DelayCtrlFlag = false; + delayCtrlFlag = false; OK = true; } /* @@ -755,7 +755,7 @@ bool physics::Vehicle::AutoRelayMainDown() } else if (lineContactors.TimeSinceSwitch() > CtrlDownDelay) { - if (TrainType != train_type::emu) // tutaj powinien być tryb sterowania wałem + if (trainType != train_type::emu) // tutaj powinien być tryb sterowania wałem { --MainCtrlActualPos; OK = true; @@ -775,22 +775,22 @@ bool physics::Vehicle::AutoRelayLineContactorsStep(bool const motorconnectorsoff { bool OK = false; // ybARC - zalaczenie stycznikow liniowych - if (false == motorconnectorsoff && MainCtrlActualPos == 0 && (TrainType == train_type::emu || HasCamshaft ? MainCtrlPowerPos() > 0 : MainCtrlPowerPos() == 1)) + if (false == motorconnectorsoff && MainCtrlActualPos == 0 && (trainType == train_type::emu || HasCamshaft ? MainCtrlPowerPos() > 0 : MainCtrlPowerPos() == 1)) { - DelayCtrlFlag = true; - if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay) + delayCtrlFlag = true; + if (lineContactors.TimeSinceSwitch() >= initialCtrlDelay) { lineContactors.Close(); MainCtrlActualPos = 1; - DelayCtrlFlag = false; + delayCtrlFlag = false; SetFlag(soundFlag, sound::relay | sound::loud); OK = true; } } else { - DelayCtrlFlag = false; + delayCtrlFlag = false; } if (false == lineContactors.IsClosed() && (MainCtrlActualPos > 0 || ScndCtrlActualPos > 0)) @@ -809,7 +809,7 @@ bool physics::Vehicle::CamshaftRunDown() if (CoupledCtrl) { - if (TrainType == train_type::emu) + if (trainType == train_type::emu) { OK = CamshaftRunDownEMU(); } @@ -871,7 +871,7 @@ bool physics::Vehicle::CamshaftRunDownEMU() // dojdz do konca ++MainCtrlActualPos; } - else if (ScndCtrlActualPos < ScndCtrlPosNo) + else if (ScndCtrlActualPos < scndCtrlPosNo) { // potem boki ++ScndCtrlActualPos; @@ -993,7 +993,7 @@ double stepped_uc_value(double const Current, double const Ramped, TUniversalCtr void physics::Vehicle::CheckEIMIC(double dt) { double offset = EIMCtrlAdditionalZeros ? 1.0 : 0.0; - double multiplier = (EIMCtrlEmergency ? 1.0 : 0.0) + offset; + double multiplier = (eimCtrlEmergency ? 1.0 : 0.0) + offset; // gdy SplitEDPneumaticBrake jest wlaczone, sterowanie ujemne (hamowanie ED) bierzemy // z osobnego nastawnika DynamicBrakeCtrl, a nie z hamulca pomocniczego (LocalBrake). // Dodatkowo zapotrzebowanie ED jest ograniczone przez strefe Vh0..Vh1: powyzej Vh1 - pelny ED, @@ -1037,7 +1037,7 @@ void physics::Vehicle::CheckEIMIC(double dt) void physics::Vehicle::EIMICFromController(double const brakeDemand, double const offset, double const multiplier) { eimic = brakeDemand > 0.01 ? -brakeDemand : eimicAnalog > 0.01 ? eimicAnalog : (double)mainCtrlPos / (double)MainCtrlPosNo; - if (EIMCtrlAdditionalZeros || EIMCtrlEmergency) + if (EIMCtrlAdditionalZeros || eimCtrlEmergency) { if (eimic > 0.001) eimic = std::max(0.002, eimic * (double)MainCtrlPosNo / ((double)MainCtrlPosNo - offset) - offset / ((double)MainCtrlPosNo - offset)); @@ -1092,7 +1092,7 @@ void physics::Vehicle::EIMICFromFourPositions(double dt) // hamowanie nagle: pelne hamowanie od razu, przewod glowny oproznia UpdatePipePressure() eimic = -1.0; } - else if (MainCtrlActualPos != mainCtrlPos || lineContactors.TimeSinceSwitch() > InitialCtrlDelay) + else if (MainCtrlActualPos != mainCtrlPos || lineContactors.TimeSinceSwitch() > initialCtrlDelay) { double delta = MainCtrlActualPos == mainCtrlPos ? dt * CtrlDelay : 0.01; // the positions below are those of the controller without the emergency brake position @@ -1136,7 +1136,7 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak UniversalControllerTrainBrake(); } - if (MainCtrlActualPos != mainCtrlPos || lineContactors.TimeSinceSwitch() > InitialCtrlDelay) + if (MainCtrlActualPos != mainCtrlPos || lineContactors.TimeSinceSwitch() > initialCtrlDelay) { auto const &position{UniCtrlList[mainCtrlPos]}; double ramped{eimic}; @@ -1145,7 +1145,7 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak ramped += safe_clamp(position.SetCtrlVal - ramped, 0.0, MainCtrlActualPos == mainCtrlPos ? dt * position.SpeedUp : sign(position.SpeedUp) * 0.01); // dodawaj do X ramped = safe_clamp(ramped, position.MinCtrlVal, position.MaxCtrlVal); - eimic = UniCtrlValStep > 0.0 ? stepped_uc_value(eimic, ramped, position, UniCtrlValStep, MainCtrlActualPos != mainCtrlPos, eimic_step_progress) : ramped; + eimic = uniCtrlValStep > 0.0 ? stepped_uc_value(eimic, ramped, position, uniCtrlValStep, MainCtrlActualPos != mainCtrlPos, eimic_step_progress) : ramped; } if (MainCtrlActualPos == mainCtrlPos) lineContactors.AdvanceSwitchTimer(dt); @@ -1154,9 +1154,9 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak lineContactors.RestartSwitchTimer(); MainCtrlActualPos = mainCtrlPos; } - if (brakes.distributor->GetEDBCP() > 0.3 && eimic < 0 && !UniCtrlIntegratedLocalBrakeCtrl) // when braking with pneumatic brake + if (brakes.distributor->GetEDBCP() > 0.3 && eimic < 0 && !uniCtrlIntegratedLocalBrakeCtrl) // when braking with pneumatic brake eimic = 0; // shut off retarder - if (UniCtrlIntegratedBrakeCtrl == false && UniCtrlIntegratedLocalBrakeCtrl == false) + if (UniCtrlIntegratedBrakeCtrl == false && uniCtrlIntegratedLocalBrakeCtrl == false) { // w trybie SplitEDPneumaticBrake hamowanie ED przychodzi z osobnego nastawnika, // LocalBrake operuje wylacznie pneumatycznym hamulcem lokomotywy @@ -1258,7 +1258,7 @@ void physics::Vehicle::CheckSpeedCtrl(double dt) if (EIMCtrlType >= 3 && UniCtrlList[mainCtrlPos].SpeedUp <= 0) { accfactor = 0.0; - eimicSpeedCtrl = 0; + eimicSpeedCtrlValue = 0; } } if (SpeedCtrlUnit.IsActive) @@ -1271,7 +1271,7 @@ void physics::Vehicle::CheckSpeedCtrl(double dt) } else { - eimicSpeedCtrl = 0; + eimicSpeedCtrlValue = 0; eimicSpeedCtrlIntegral = 0; } SpeedCtrlUnit.Parking = Vel == 0.0 && eimic <= 0 && EngineType != TEngineType::ElectricInductionMotor; @@ -1279,10 +1279,10 @@ void physics::Vehicle::CheckSpeedCtrl(double dt) } else { - if (Vmax < 250) - eimicSpeedCtrl = std::clamp(0.5 * (SpeedCtrlValue - Vel), -1.0, 1.0); + if (vmax < 250) + eimicSpeedCtrlValue = std::clamp(0.5 * (SpeedCtrlValue - Vel), -1.0, 1.0); else - eimicSpeedCtrl = std::clamp(0.5 * (SpeedCtrlValue * 2 - Vel), -1.0, 1.0); + eimicSpeedCtrlValue = std::clamp(0.5 * (SpeedCtrlValue * 2 - Vel), -1.0, 1.0); } if ((SpeedCtrlAutoTurnOffFlag & 2) == 2 && brakes.distributor->GetEDBCP() > 0.25) { @@ -1292,7 +1292,7 @@ void physics::Vehicle::CheckSpeedCtrl(double dt) } else { - eimicSpeedCtrl = 1; + eimicSpeedCtrlValue = 1; eimicSpeedCtrlIntegral = 0; SpeedCtrlUnit.Parking = false; SendCtrlToNext(VehicleCommand::speedControlParking, SpeedCtrlUnit.Parking, CabActive); @@ -1311,7 +1311,7 @@ void physics::Vehicle::SpeedCtrlRegulator(double dt, double const accfactor) bool retarder_not_work = EngineType != TEngineType::DieselEngine || Vel < SpeedCtrlUnit.BrakeInterventionVel; if (eSCP < -1.0) { - SpeedCtrlUnit.BrakeInterventionBraking = eSCP < -1.1 && retarder_not_work && eimicSpeedCtrl < -0.99 * SpeedCtrlUnit.DesiredPower; + SpeedCtrlUnit.BrakeInterventionBraking = eSCP < -1.1 && retarder_not_work && eimicSpeedCtrlValue < -0.99 * SpeedCtrlUnit.DesiredPower; eSCP = -1.0; } SpeedCtrlUnit.BrakeInterventionUnbraking = eSCP > 0.0 || Vel == 0.0; @@ -1327,14 +1327,14 @@ void physics::Vehicle::SpeedCtrlRegulator(double dt, double const accfactor) eimicSpeedCtrlIntegral = 0; } auto const DesiredeimicSpeedCtrl{safe_clamp(eimicSpeedCtrlIntegral + eSCP, -SpeedCtrlUnit.DesiredPower, accfactor)}; - eimicSpeedCtrl = safe_clamp(DesiredeimicSpeedCtrl, eimicSpeedCtrl - SpeedCtrlUnit.PowerDownSpeed * dt, eimicSpeedCtrl + SpeedCtrlUnit.PowerUpSpeed * dt); + eimicSpeedCtrlValue = safe_clamp(DesiredeimicSpeedCtrl, eimicSpeedCtrlValue - SpeedCtrlUnit.PowerDownSpeed * dt, eimicSpeedCtrlValue + SpeedCtrlUnit.PowerUpSpeed * dt); if (Vel < SpeedCtrlUnit.FullPowerVelocity) { - eimicSpeedCtrl = std::min(eimicSpeedCtrl, SpeedCtrlUnit.InitialPower); + eimicSpeedCtrlValue = std::min(eimicSpeedCtrlValue, SpeedCtrlUnit.InitialPower); } if (Vel < SpeedCtrlUnit.StartVelocity && mainCtrlPos < MainCtrlPosNo) { - eimicSpeedCtrl = 0; + eimicSpeedCtrlValue = 0; eimic = 0; } } @@ -1342,7 +1342,7 @@ void physics::Vehicle::SpeedCtrlRegulator(double dt, double const accfactor) bool physics::Vehicle::IsSpeedCtrlSeparate() const { // no secondary controller, or one of these engines', which shunts the field of the traction motors (eu07/maszyna#69) - return SpeedCtrl && (ScndCtrlPosNo == 0 || EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric); + return speedCtrl && (scndCtrlPosNo == 0 || EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric); } bool physics::Vehicle::IsSpeedCtrlEngaged() const @@ -1379,7 +1379,7 @@ bool physics::Vehicle::SpeedCtrlSwitch(bool const State) void physics::Vehicle::SpeedCtrlButton(int button) { - if (SpeedCtrl && IsSpeedCtrlEngaged()) + if (speedCtrl && IsSpeedCtrlEngaged()) { SpeedCtrlValue = SpeedCtrlButtons[button]; } @@ -1387,7 +1387,7 @@ void physics::Vehicle::SpeedCtrlButton(int button) void physics::Vehicle::SpeedCtrlInc() { - if (SpeedCtrl && IsSpeedCtrlEngaged()) + if (speedCtrl && IsSpeedCtrlEngaged()) { double x = floor(SpeedCtrlValue / SpeedCtrlUnit.VelocityStep) + 1.0; SpeedCtrlValue = std::min(x * SpeedCtrlUnit.VelocityStep, SpeedCtrlUnit.MaxVelocity); @@ -1396,7 +1396,7 @@ void physics::Vehicle::SpeedCtrlInc() void physics::Vehicle::SpeedCtrlDec() { - if (SpeedCtrl && IsSpeedCtrlEngaged()) + if (speedCtrl && IsSpeedCtrlEngaged()) { double x = ceil(SpeedCtrlValue / SpeedCtrlUnit.VelocityStep) - 1.0; SpeedCtrlValue = std::max(x * SpeedCtrlUnit.VelocityStep, SpeedCtrlUnit.MinVelocity); @@ -1405,7 +1405,7 @@ void physics::Vehicle::SpeedCtrlDec() bool physics::Vehicle::SpeedCtrlPowerInc() { - if (!(SpeedCtrl && IsSpeedCtrlEngaged())) + if (!(speedCtrl && IsSpeedCtrlEngaged())) return false; if (SpeedCtrlUnit.DesiredPower == SpeedCtrlUnit.MaxPower) @@ -1417,7 +1417,7 @@ bool physics::Vehicle::SpeedCtrlPowerInc() bool physics::Vehicle::SpeedCtrlPowerDec() { - if (!(SpeedCtrl && IsSpeedCtrlEngaged())) + if (!(speedCtrl && IsSpeedCtrlEngaged())) return false; if (SpeedCtrlUnit.DesiredPower == SpeedCtrlUnit.MinPower) diff --git a/physics/components/couplers.cpp b/physics/components/couplers.cpp index dd0e300e6..2ee5f8ec3 100644 --- a/physics/components/couplers.cpp +++ b/physics/components/couplers.cpp @@ -448,7 +448,7 @@ void physics::Vehicle::automatic_coupling(VehicleEnd const End, physics::Vehicle auto const safe{AutomaticCouplingSafe(End, Other, OtherEnd)}; auto const caught{safe && Attach(End, OtherEnd, &Other, couplingtype)}; // HACK: we're reusing sound enum to mark whether vehicle was connected to another - AIFlag |= (caught ? sound::attachcoupler : 0); + aiFlag |= (caught ? sound::attachcoupler : 0); // coupled, or locked until the vehicles part, so they don't couple as soon as the collision slows them down thiscoupler.AutomaticCouplingAllowed = safe && false == caught; othercoupler.AutomaticCouplingAllowed = safe && false == caught; @@ -565,7 +565,7 @@ bool physics::Vehicle::coupler_stop_hit(VehicleEnd const End, physics::Vehicle & { return true; } - auto const hit{coupler_physics::impact(thiscoupler.physics, othercoupler.physics, state, closing, TotalMass, Other.TotalMass)}; + auto const hit{coupler_physics::impact(thiscoupler.physics, othercoupler.physics, state, closing, totalMass, Other.totalMass)}; // the other vehicle keeps the state of the pair alike othercoupler.physics_state.elongation = state.elongation; // with physics.collisions new the crush of the ends past the buffers is crush_hit()'s diff --git a/physics/components/diesel.cpp b/physics/components/diesel.cpp index 4ebbc65bd..71014515d 100644 --- a/physics/components/diesel.cpp +++ b/physics/components/diesel.cpp @@ -226,16 +226,16 @@ bool physics::Vehicle::WaterCircuitsLinkSwitch(bool State, range_t const Notify) return false; } - bool const initialstate{WaterCircuitsLink}; + bool const initialstate{waterCircuitsLink}; - WaterCircuitsLink = State; + waterCircuitsLink = State; if (Notify != range_t::local) { - SendCtrlToNext(VehicleCommand::waterCircuitsLinkSwitch, WaterCircuitsLink ? 1 : 0, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control); + SendCtrlToNext(VehicleCommand::waterCircuitsLinkSwitch, waterCircuitsLink ? 1 : 0, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control); } - return WaterCircuitsLink != initialstate; + return waterCircuitsLink != initialstate; } // fuel pump state toggle @@ -355,10 +355,10 @@ void physics::Vehicle::DieselEngineTractionForce(double dt, double const dmoment { Mw = dmoment * dtrans * Transmision.Efficiency; // dmoment i dtrans policzone przy okazji enginerotation 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 - Ft = Ft * DirAbsolute; // DirActive*CabActive; + Mw -= dizel_MomentumRetarder(nrotValue * Transmision.Ratio, dt) * Transmision.Ratio * Transmision.Efficiency; + Fw = Mw * 2.0 / wheelDiameter / nPoweredAxles; + ft = Fw * nPoweredAxles; // sila trakcyjna + ft = ft * DirAbsolute; // DirActive*CabActive; } // tmp: the revolutions the engine aims at [1/s], see UpdateEngineRevolutions() @@ -366,7 +366,7 @@ void physics::Vehicle::DieselElectricTractionForce(double tmp) { double PosRatio; // tmpV:=V*CabActive*DirActive; - auto const tmpV{nrot * Pirazy2 * 0.5 * WheelDiameter * DirAbsolute}; //*CabActive*DirActive; + auto const tmpV{nrotValue * Pirazy2 * 0.5 * wheelDiameter * DirAbsolute}; //*CabActive*DirActive; auto tempUmax = 0.0; auto tempImax = 0.0; // jazda manewrowa @@ -400,19 +400,19 @@ void physics::Vehicle::DieselElectricTractionForce(double tmp) // stosunek mocy teraz do mocy max // NOTE: Mains in this context is working diesel engine if (true == lineContactors.IsClosed()) - Ft = DieselElectricForce(tmpV, power, PosRatio, tmp); + ft = DieselElectricForce(tmpV, power, PosRatio, tmp); else - Ft = 0; // jak nastawnik na zero, to sila tez zero + ft = 0; // jak nastawnik na zero, to sila tez zero PosRatio = tmp / DElist[MainCtrlPosNo].GenPower; } if (FuseFlag) - Ft = 0; + ft = 0; else - Ft = Ft * DirAbsolute; // DirActive * CabActive; //zwrot sily i jej wartosc - Fw = Ft / NPoweredAxles; // sila na obwodzie kola - Mw = Fw * WheelDiameter / 2.0; // moment na osi kola + ft = ft * DirAbsolute; // DirActive * CabActive; //zwrot sily i jej wartosc + Fw = ft / nPoweredAxles; // sila na obwodzie kola + Mw = Fw * wheelDiameter / 2.0; // moment na osi kola Mm = Mw / Transmision.Ratio; // moment silnika trakcyjnego Im = dieselelectric_motor_current(Mm); @@ -432,12 +432,12 @@ void physics::Vehicle::DieselElectricTractionForce(double tmp) EngineVoltage = 0; // przekazniki bocznikowania, kazdy inny dla kazdej pozycji - if (auto const fieldshuntingcontrol{fieldshunting::diesel_electric(AutoRelayType, FieldShuntSwitch, AutoRelayFlag)}; + if (auto const fieldshuntingcontrol{fieldshunting::diesel_electric(autoRelayType, fieldShuntSwitch, autoRelayFlag)}; false == lineContactors.IsClosed() || ShuntMode || fieldshuntingcontrol == fieldshunting::control::off) { scndCtrlPos = 0; } - else if (AutoRelayFlag) + else if (autoRelayFlag) { // the shunting relays set the field shunting (fieldshunting::control::automatic) ShuntFieldRelaysCheck(tmpV, PosRatio, tmp); @@ -454,12 +454,12 @@ void physics::Vehicle::DieselElectricShuntForce(double const tmpV, double &tmp) // NOTE: very crude way to approximate power generated at current rpm instead of instant top output // NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it tmp = EngineRPMRatio() * (SST[mainCtrlPos].Pmax * anPos) + SST[mainCtrlPos].Pmin * (1.0 - anPos); - Ft = tmp * 1000.0 / (abs(tmpV) + 1.6); + ft = tmp * 1000.0 / (abs(tmpV) + 1.6); } else { EngineVoltage = 0; - Ft = 0; + ft = 0; } } @@ -473,9 +473,9 @@ double physics::Vehicle::DieselElectricDigitalForce(double const tmpV, double &t tempUmax = DElist[MainCtrlPosNo].Umax * std::min(eimic_positive, rpmratio); auto const tempPmax = DElist[MainCtrlPosNo].GenPower * std::min(eimic_positive, rpmratio); if (true == lineContactors.IsClosed()) - Ft = DieselElectricForce(tmpV, tempPmax, eimic_positive, tempPmax); + ft = DieselElectricForce(tmpV, tempPmax, eimic_positive, tempPmax); else - Ft = 0; // jak nastawnik na zero, to sila tez zero + ft = 0; // jak nastawnik na zero, to sila tez zero return tempPmax; } @@ -504,7 +504,7 @@ void physics::Vehicle::DieselElectricShuntPower(double const tmp) } if (EnginePower < tmp) { - Ft *= EnginePower / tmp; + ft *= EnginePower / tmp; } } @@ -513,7 +513,7 @@ void physics::Vehicle::DieselElectricGenerator(double const tmp, double const te { if (abs(Im) > tempImax) { // nie ma nadmiarowego, tylko Imax i zwarcie na pradnicy - Ft = Ft / Im * tempImax; + ft = ft / Im * tempImax; Im = tempImax; } @@ -547,8 +547,8 @@ void physics::Vehicle::DieselElectricGenerator(double const tmp, double const te // power curve drop // NOTE: disabled for the time being due to side-effects if( ( tmpV > 1 ) && ( EnginePower < tmp ) ) { - Ft = std::lerp( - Ft, EnginePower / tmp, + ft = std::lerp( + ft, EnginePower / tmp, std::clamp( tmpV - 1.0, 0.0, 1.0 ) ); } */ @@ -559,9 +559,9 @@ double physics::Vehicle::dieselelectric_motor_current(double const Moment) const { // with MotorParam[scndCtrlPos] do if (abs(Moment) > motor_param(scndCtrlPos).fi) - return NPoweredAxles * abs(abs(Moment) / motor_param(scndCtrlPos).mfi + motor_param(scndCtrlPos).mIsat); + return nPoweredAxles * abs(abs(Moment) / motor_param(scndCtrlPos).mfi + motor_param(scndCtrlPos).mIsat); else - return NPoweredAxles * sqrt(abs(Moment * motor_param(scndCtrlPos).Isat)); + return nPoweredAxles * sqrt(abs(Moment * motor_param(scndCtrlPos).Isat)); } // the effort of a diesel-electric vehicle's dynamic brake the driver asks for, 0..1 @@ -609,7 +609,7 @@ void physics::Vehicle::update_dieselelectric_dynamic_brake(double const dt) { auto &brake{DEDynamicBrake}; auto const nopower{brake.source == diesel_electric_dynamic_brake::control::controller ? eimic_real <= 0.0 : IsMainCtrlNoPowerPos()}; - if (lineBreaker.IsClosed() && DirActive != 0 && false == FuseFlag && false == SlippingWheels && nopower) + if (lineBreaker.IsClosed() && DirActive != 0 && false == FuseFlag && false == slippingWheels && nopower) { brake.level += std::clamp(dieselelectric_dynamic_brake_demand() - brake.level, -brake.rate * dt, brake.rate * dt); } @@ -632,10 +632,10 @@ void physics::Vehicle::update_dieselelectric_dynamic_brake(double const dt) // would turn round each time the speed crosses zero, and in FTrain it never lets the stop of ComputeMovement() catch it void physics::Vehicle::apply_dieselelectric_dynamic_brake(double const dt) { - auto const force{dt > 0.0 ? std::min(DEDynamicBrake.force, TotalMass * std::abs(travelSpeed) / dt) : DEDynamicBrake.force}; - Ft = travelSpeed > 0.0 ? -force : travelSpeed < 0.0 ? force : 0.0; - Fw = Ft / NPoweredAxles; - Mw = Fw * WheelDiameter / 2.0; + auto const force{dt > 0.0 ? std::min(DEDynamicBrake.force, totalMass * std::abs(travelSpeed) / dt) : DEDynamicBrake.force}; + ft = travelSpeed > 0.0 ? -force : travelSpeed < 0.0 ? force : 0.0; + Fw = ft / nPoweredAxles; + Mw = Fw * wheelDiameter / 2.0; Mm = Mw / Transmision.Ratio; Im = dieselelectric_motor_current(Mm); EngineVoltage = 0.0; @@ -754,7 +754,7 @@ bool physics::Vehicle::dizel_GearShiftRequest(double const VelUp, double const V if (Vel > VelUp) { // shift up - if (ScndCtrlActualPos < ScndCtrlPosNo) + if (ScndCtrlActualPos < scndCtrlPosNo) { diesel.automaticGearShift = 1; OK = true; @@ -786,7 +786,7 @@ void physics::Vehicle::dizel_ClutchCheck() dizel_EngageSwitch(0.0); if (!(motor_param(ScndCtrlActualPos).mIsat > 0)) dizel_EngageSwitch(0.0); // wylacz sprzeglo na pozycjach neutralnych - if (!AutoRelayFlag) + if (!autoRelayFlag) ScndCtrlActualPos = scndCtrlPos; } @@ -899,7 +899,7 @@ bool physics::Vehicle::dizel_Update(double dt) diesel.ignitionRequested = true; } - if (true == diesel.ignitionRequested && LastSwitchingTime >= InitialCtrlDelay) + if (true == diesel.ignitionRequested && LastSwitchingTime >= initialCtrlDelay) { diesel.startupRequested = false; @@ -951,7 +951,7 @@ double physics::Vehicle::dizel_fillcheck(int mcp, double dt) if (true == lineBreaker.IsClosed() && MainCtrlPosNo > 0 && true == FuelPump.is_active) { - if (true == diesel.ignitionRequested && 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 @@ -1106,7 +1106,7 @@ double physics::Vehicle::dizel_Momentum(double Fill, double n, double dt) { Moment = -diesel.standingMoment; } - if (enrot < diesel.minRevolutions / 10.0 && eAngle < M_PI_2) + if (enrot < diesel.minRevolutions / 10.0 && eAngleValue < M_PI_2) { // wstrzymywanie przy malych obrotach Moment -= diesel.standingMoment; @@ -1410,7 +1410,7 @@ void physics::Vehicle::dizel_Heat(double const dt) 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 * (diesel.heat.Tsr2 - diesel.heat.Te) + 80 * (true == WaterCircuitsLink ? 1 : 0) * (diesel.heat.Twy - diesel.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 diff --git a/physics/components/drive.cpp b/physics/components/drive.cpp index b160d57b0..62543c048 100644 --- a/physics/components/drive.cpp +++ b/physics/components/drive.cpp @@ -68,7 +68,7 @@ double TractionDrive::EngineMaxRpm(physics::Vehicle const & /*vehicle*/) const double TractionDrive::UpdateEngineRevolutions(physics::Vehicle &vehicle, double /*dt*/, double & /*transmission*/, double & /*moment*/) const { - vehicle.enrot = vehicle.Transmision.Ratio * vehicle.nrot; + vehicle.enrot = vehicle.Transmision.Ratio * vehicle.nrot(); return 0.0; } @@ -189,7 +189,7 @@ class DumbDrive final : public TractionDrive public: double UpdateEnginePower(physics::Vehicle &vehicle) const override { - auto const posRatio{(vehicle.MainCtrlPos() + vehicle.ScndCtrlPos()) / (vehicle.MainCtrlPosNo + vehicle.ScndCtrlPosNo + 0.01)}; + auto const posRatio{(vehicle.MainCtrlPos() + vehicle.ScndCtrlPos()) / (vehicle.MainCtrlPosNo + vehicle.ScndCtrlPosNo() + 0.01)}; vehicle.EnginePower = /*1000.0 **/ vehicle.Power * posRatio; return posRatio; } @@ -273,7 +273,7 @@ public: // wywalanie szybkiego z powodu niewłaściwego napięcia // (a line breaker closed ahead of the pantographs holds without voltage) if (true == vehicle.lineBreaker.IsClosed() && ((false == vehicle.protection.UndervoltageHolds() && false == vehicle.lineBreaker.config.pantographsRequireIt) || false == vehicle.protection.OvervoltageHolds()) && - vehicle.MainSwitch(false, vehicle.TrainType == train_type::emu ? range_t::unit : range_t::local)) // TODO: check whether we need to send this EMU-wide + vehicle.MainSwitch(false, vehicle.TrainType() == train_type::emu ? range_t::unit : range_t::local)) // TODO: check whether we need to send this EMU-wide { vehicle.RaiseEventFlag(); } @@ -321,9 +321,9 @@ public: switch (ammeter) { // do asynchronicznych case 1: - return vehicle.WindingRes * vehicle.Mm / vehicle.Vadd; + return vehicle.WindingRes() * vehicle.Mm / vehicle.Vadd; case 2: - return vehicle.inductionMotor.forceShare * vehicle.WindingRes; + return vehicle.inductionMotor.forceShare * vehicle.WindingRes(); default: return vehicle.ShowCurrentP(ammeter); } @@ -341,7 +341,7 @@ public: if (vehicle.lineBreaker.IsClosed() && ((vehicle.TractionSupplyVoltage() < vehicle.TractionSupplyMinVoltage() && false == vehicle.lineBreaker.config.pantographsRequireIt) || vehicle.TractionSupplyVoltage() > vehicle.EnginePowerSource.CollectorParameters.MaxV + 200)) { - vehicle.MainSwitch(false, vehicle.TrainType == train_type::emu ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide + vehicle.MainSwitch(false, vehicle.TrainType() == train_type::emu ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide } } }; @@ -372,7 +372,7 @@ public: else transmission = vehicle.Transmision.Ratio * vehicle.motor_param(vehicle.ScndCtrlActualPos).mIsat; - moment = vehicle.dizel_Momentum(vehicle.diesel.fill, transmission * vehicle.nrot * vehicle.DirActive, dt); // oblicza tez enrot + moment = vehicle.dizel_Momentum(vehicle.diesel.fill, transmission * vehicle.nrot() * vehicle.DirActive, dt); // oblicza tez enrot return 0.0; } bool IncreaseMainController(physics::Vehicle &vehicle, int const speed) const override diff --git a/physics/components/electrics.cpp b/physics/components/electrics.cpp index ec185a5a8..97d17fab5 100644 --- a/physics/components/electrics.cpp +++ b/physics/components/electrics.cpp @@ -48,7 +48,7 @@ physics::PantographAirSupply physics::Vehicle::PantographAirSupplyNow() const supply.lowVoltage = lowVoltage.IsAvailable(); // tylko jeśli pantografujący supply.collectors = EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0; - supply.multipleUnit = TrainType == train_type::emu; + supply.multipleUnit = trainType == train_type::emu; supply.mainReservoirPressure = mainPipe.Pressure(); supply.controlReservoirPressure = brakes.controlReservoirPressure; supply.maxPressure = EnginePowerSource.CollectorParameters.MaxPress; @@ -71,14 +71,14 @@ void physics::Vehicle::PantPressureSwitchCheck() void physics::Vehicle::PantPressureSwitchTrip() { // opuszczenie pantografów przy niskim ciśnieniu - if (TrainType != train_type::emu) + if (trainType != train_type::emu) { // pressure switch safety measure -- open the line breaker, unless there's alternate source of traction voltage // (the genset of a dual-mode vehicle, when the selector is on it, doesn't need the pantographs) if (GetTrainsetHighVoltage() < EnginePowerSource.CollectorParameters.MinV && false == GensetSelected()) { // TODO: check whether line breaker should be open EMU-wide - MainSwitch(false, TrainType == train_type::emu ? range_t::unit : range_t::local); + MainSwitch(false, trainType == train_type::emu ? range_t::unit : range_t::local); } } else @@ -251,7 +251,7 @@ void physics::Vehicle::MainsCheck(double const Deltatime) // an emergency brake application made under power opens the line breaker, where the vehicle has such an interlock if (lineBreaker.IsClosed() && EmergencyBrakeHoldsMainOff()) { - MainSwitch(false, TrainType == train_type::emu ? range_t::unit : range_t::local); + MainSwitch(false, trainType == train_type::emu ? range_t::unit : range_t::local); } } @@ -722,7 +722,7 @@ void physics::Vehicle::LightsCheck(double const /*Timestep*/) bool physics::Vehicle::BatterySwitch(bool State, range_t const Notify) { using enum range_t; - if (PulleeMode && State) + if (pulleeMode && State) { // the battery of a vehicle prepared for hauling stays off return false; diff --git a/physics/components/fizparser.cpp b/physics/components/fizparser.cpp index d4dbda73a..a3819786f 100644 --- a/physics/components/fizparser.cpp +++ b/physics/components/fizparser.cpp @@ -754,7 +754,7 @@ bool physics::Vehicle::LoadFIZ_Parse(cParser &fizparser) // the DefaultPos of a short or an empty DimmerList would put the dimmer outside of it modernDimmerDefaultPosition = clampDimmerPosition(modernDimmerDefaultPosition); modernDimmerPosition = clampDimmerPosition(modernDimmerPosition); - if (!enableModernDimmer) + if (!enableModernDimmerValue) { modernDimmerPosition = modernDimmerDefaultPosition; } @@ -1008,7 +1008,7 @@ bool physics::Vehicle::LoadFIZ_Section(std::string const &inputline, std::mapsecond : train_type::generic; + trainType = lookup != types.end() ? lookup->second : train_type::generic; } - if (TrainType == train_type::emu) + if (trainType == train_type::emu) { IminLo = 1; IminHi = 2; - Imin = 1; + imin = 1; } } @@ -176,23 +176,23 @@ void physics::Vehicle::LoadFIZ_Dimensions(std::string const &line) void physics::Vehicle::LoadFIZ_Wheels(std::string const &line) { - extract_value(WheelDiameter, "D", line, ""); - WheelDiameterL = WheelDiameter; // gdyby nie było parametru, lepsze to niż zero + extract_value(wheelDiameter, "D", line, ""); + WheelDiameterL = wheelDiameter; // gdyby nie było parametru, lepsze to niż zero extract_value(WheelDiameterL, "Dl", line, ""); - WheelDiameterT = WheelDiameter; // gdyby nie było parametru, lepsze to niż zero + WheelDiameterT = wheelDiameter; // gdyby nie było parametru, lepsze to niż zero extract_value(WheelDiameterT, "Dt", line, ""); extract_value(TrackW, "Tw", line, ""); extract_value(AxleInertialMoment, "AIM", line, ""); extract_value(AxleArangement, "Axle", line, ""); - NPoweredAxles = s2NPW(AxleArangement); - NAxles = NPoweredAxles + s2NNW(AxleArangement); + nPoweredAxles = s2NPW(AxleArangement); + nAxles = nPoweredAxles + s2NNW(AxleArangement); BearingType = extract_value("BearingType", line) == "Roll" ? 1 : 0; - extract_value(ADist, "Ad", line, ""); - extract_value(BDist, "Bd", line, ""); + extract_value(aDist, "Ad", line, ""); + extract_value(bDist, "Bd", line, ""); if (AxleInertialMoment <= 0.0) { @@ -201,8 +201,8 @@ void physics::Vehicle::LoadFIZ_Wheels(std::string const &line) */ // approximation formula by youby auto const k = 472.0; // arbitrary constant - AxleInertialMoment = k / 4.0 * std::pow(WheelDiameter, 4.0) * NAxles; - Mred = k * std::pow(WheelDiameter, 2.0) * NAxles; + AxleInertialMoment = k / 4.0 * std::pow(wheelDiameter, 4.0) * nAxles; + mred = k * std::pow(wheelDiameter, 2.0) * nAxles; } } @@ -435,7 +435,7 @@ void physics::Vehicle::LoadFIZ_Doors(std::string const &line) extract_value(MirrorVelClose, "MirrorVelClose", line, ""); extract_value(DoorsOpenWithPermitAfter, "DoorOpenWithPermit", line, ""); - extract_value(DoorsPermitLightBlinking, "DoorsPermitLightBlinking", line, ""); + extract_value(doorsPermitLightBlinking, "DoorsPermitLightBlinking", line, ""); } namespace { @@ -805,9 +805,9 @@ void physics::Vehicle::LoadFIZ_CntrlControllers(std::string const &line) using enum horn_supply; std::map> const hornsupplies{{"Pneumatic", air}, {"Electric", electric}}; auto lookup = hornsupplies.find(extract_value("HornType", line)); - HornSupply = lookup != hornsupplies.end() ? lookup->second : air; + hornSupply = lookup != hornsupplies.end() ? lookup->second : air; lookup = hornsupplies.find(extract_value("Horn3Type", line)); - Horn3Supply = lookup != hornsupplies.end() ? lookup->second : HornSupply; + Horn3Supply = lookup != hornsupplies.end() ? lookup->second : hornSupply; } // dynamicbrake @@ -831,25 +831,25 @@ void physics::Vehicle::LoadFIZ_CntrlControllers(std::string const &line) } extract_value(MainCtrlPosNo, "MCPN", line, ""); - extract_value(ScndCtrlPosNo, "SCPN", line, ""); + extract_value(scndCtrlPosNo, "SCPN", line, ""); extract_value(ScndInMain, "SCIM", line, ""); - extract_value(MainCtrlMaxDirChangePos, "DirChangeMaxPos", line, ""); + extract_value(mainCtrlMaxDirChangePos, "DirChangeMaxPos", line, ""); if (auto const autorelay{ToLower(extract_value("AutoRelay", line))}; autorelay == "optional") { - AutoRelayType = 2; + autoRelayType = 2; } else if (autorelay == "yes") { - AutoRelayType = 1; + autoRelayType = 1; } else { - AutoRelayType = 0; + autoRelayType = 0; } // a key of its own rather than a new AutoRelay value: an exe that doesn't know it reads the line as before, and the value // stays Optional, which every check of the switch looks for - extract_value(FieldShuntSwitch, "FieldShuntSwitch", line, ""); + extract_value(fieldShuntSwitch, "FieldShuntSwitch", line, ""); extract_value(CoupledCtrl, "CoupledCtrl", line, ""); extract_value(HasCamshaft, "Camshaft", line, ""); @@ -857,22 +857,22 @@ void physics::Vehicle::LoadFIZ_CntrlControllers(std::string const &line) EIMCtrlType = std::clamp(EIMCtrlType, 0, 3); extract_value(brakes.config.independentTraxx, "LocalBrakeTraxx", line, ""); extract_value(EIMCtrlAdditionalZeros, "EIMCtrlAddZeros", line, ""); - extract_value(EIMCtrlEmergency, "EIMCtrlEmergency", line, ""); + extract_value(eimCtrlEmergency, "EIMCtrlEmergency", line, ""); // Elf (EIMCtrlType 2): an emergency brake position below the controller's position 0, which shifts the other positions up by one - extract_value(EIMCtrlMainEmergency, "EIMCtrlMainEmergency", line, ""); + extract_value(eimCtrlMainEmergency, "EIMCtrlMainEmergency", line, ""); if (auto const elfpositions{4 + EIMCtrlEmergencyPositions()}; EIMCtrlEmergencyPositions() > 0 && MainCtrlPosNo < elfpositions) { // the old positions in the file: without the fix-up the controller would have no power position, and the // reverser would stop working at neutral (DirChangeMaxPos read before, in the old positions) - MainCtrlMaxDirChangePos += EIMCtrlEmergencyPositions(); - ErrorLog(std::format("Bad fiz: EIMCtrlMainEmergency needs MCPN={} in {}, DirChangeMaxPos taken as {}", elfpositions, TypeName, MainCtrlMaxDirChangePos)); + mainCtrlMaxDirChangePos += EIMCtrlEmergencyPositions(); + ErrorLog(std::format("Bad fiz: EIMCtrlMainEmergency needs MCPN={} in {}, DirChangeMaxPos taken as {}", elfpositions, TypeName, mainCtrlMaxDirChangePos)); MainCtrlPosNo = elfpositions; } extract_value(ScndS, "ScndS", line, ""); // brak pozycji rownoleglej przy niskiej nastawie PSR extract_value(ScndCtrlResistiveLock, "ScndCtrlResistiveLock", line, ""); // bocznikowanie tylko na pozycjach bezoporowych - extract_value(InitialCtrlDelay, "IniCDelay", line, ""); + extract_value(initialCtrlDelay, "IniCDelay", line, ""); extract_value(CtrlDelay, "SCDelay", line, ""); CtrlDownDelay = CtrlDelay; // hunter-101012: jesli nie ma SCDDelay; extract_value(CtrlDownDelay, "SCDDelay", line, ""); @@ -929,7 +929,7 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) this->converter.config.start = lookup != starts.end() ? lookup->second : manual; } extract_value(this->converter.config.startDelay, "ConverterStartDelay", line, ""); - extract_value(this->converter.config.overloadRelayOffWithLineBreaker, "ConverterOverloadWhenMainIsOff", line, TrainType == train_type::emu ? "yes" : "no"); + extract_value(this->converter.config.overloadRelayOffWithLineBreaker, "ConverterOverloadWhenMainIsOff", line, trainType == train_type::emu ? "yes" : "no"); // compressor { auto lookup = starts.find(extract_value("CompressorStart", line)); @@ -941,7 +941,7 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) pantographAir.config.compressorStart = lookup != starts.end() ? lookup->second : manual; } // pantograph compressor valve - pantographAir.config.autoValve = TrainType == train_type::emu; // legacy code behaviour, automatic valve was initially installed in all EMUs + pantographAir.config.autoValve = trainType == train_type::emu; // legacy code behaviour, automatic valve was initially installed in all EMUs extract_value(pantographAir.config.autoValve, "PantAutoValve", line, ""); // pantographs valve { @@ -1006,14 +1006,14 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) // ground relay { auto lookup = starts.find(extract_value("GroundRelayStart", line)); - auto const defaultstart{TrainType == train_type::emu ? automatic : manual}; + auto const defaultstart{trainType == train_type::emu ? automatic : manual}; protection.config.groundStart = lookup != starts.end() ? lookup->second : defaultstart; } // converter overload relay { auto lookup = starts.find(extract_value("ConverterOverloadRelayStart", line)); // the relay of a multiple unit activates when the converter is switched off - auto const defaultstart{TrainType == train_type::emu ? converter : manual}; + auto const defaultstart{trainType == train_type::emu ? converter : manual}; this->converter.config.overloadRelayStart = lookup != starts.end() ? lookup->second : defaultstart; } } @@ -1021,9 +1021,9 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) void physics::Vehicle::LoadFIZ_Blending(std::string const &line) { - extract_value(brakes.blending.maxSpeed, "MED_Vmax", line, std::to_string(Vmax)); + extract_value(brakes.blending.maxSpeed, "MED_Vmax", line, std::to_string(vmax)); extract_value(brakes.blending.minSpeed, "MED_Vmin", line, "0"); - extract_value(brakes.blending.referenceSpeed, "MED_Vref", line, std::to_string(Vmax)); + extract_value(brakes.blending.referenceSpeed, "MED_Vref", line, std::to_string(vmax)); extract_value(brakes.blending.maxDeceleration, "MED_amax", line, "9.81"); extract_value(brakes.blending.epCorrection, "MED_EPVC", line, ""); extract_value(brakes.blending.loadCorrection, "MED_Ncor", line, ""); @@ -1144,11 +1144,11 @@ void physics::Vehicle::LoadFIZ_Genset(std::string const &Line) void physics::Vehicle::LoadFIZ_SpeedControl(std::string const &Line) { // speed control - extract_value(SpeedCtrl, "SpeedCtrl", Line, ""); - if (!SpeedCtrl && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo > 0) // backward compatibility - SpeedCtrl = true; + extract_value(speedCtrl, "SpeedCtrl", Line, ""); + if (!speedCtrl && EngineType == TEngineType::ElectricInductionMotor && scndCtrlPosNo > 0) // backward compatibility + speedCtrl = true; extract_value(SpeedCtrlDelay, "SpeedCtrlDelay", Line, ""); - SpeedCtrlTypeTime = extract_value("SpeedCtrlType", Line) == "Time" ? true : false; + speedCtrlTypeTime = extract_value("SpeedCtrlType", Line) == "Time" ? true : false; extract_value(SpeedCtrlAutoTurnOffFlag, "SpeedCtrlATOF", Line, ""); auto speedpresets = Split(extract_value("SpeedButtons", Line), '|'); @@ -1213,11 +1213,11 @@ void physics::Vehicle::LoadFIZ_Engine(std::string const &Input) { extract_value(NominalVoltage, "Volt", Input, ""); - extract_value(WindingRes, "WindingRes", Input, ""); - if (WindingRes == 0.0) + extract_value(windingRes, "WindingRes", Input, ""); + if (windingRes == 0.0) { - WindingRes = 0.01; + windingRes = 0.01; } extract_value(nmax, "nmax", Input, ""); nmax /= 60.0; @@ -1263,7 +1263,7 @@ void physics::Vehicle::LoadFIZ_Engine(std::string const &Input) extract_value(MotorBlowers[VehicleEnd::front].min_start_velocity, "MotorBlowersStartVelocity", Input, ""); MotorBlowers[VehicleEnd::rear] = MotorBlowers[VehicleEnd::front]; // pressure switch - extract_value(protection.config.hasPressureSwitch, "PressureSwitch", Input, TrainType != train_type::emu ? "yes" : "no"); + extract_value(protection.config.hasPressureSwitch, "PressureSwitch", Input, trainType != train_type::emu ? "yes" : "no"); // its brake cylinder half; the brake pipe one stays extract_value(protection.config.pressureSwitchWatchesCylinders, "PressureSwitchBrakeCylinder", Input, ""); } @@ -1366,8 +1366,8 @@ void physics::Vehicle::LoadFIZ_EngineDieselElectric(std::string const &Input) ShuntModeAllow = true; ShuntMode = false; anPos = 0.0; - ImaxHi = 2; - ImaxLo = 1; + imaxHi = 2; + imaxLo = 1; } extract_value(trainHeating.config.engineRpm, "HeatingRPM", Input, ""); extract_value(diesel.shaftInertia, "AIM", Input, "1.25"); @@ -1481,7 +1481,7 @@ void physics::Vehicle::LoadFIZ_Switches(std::string const &Input) extract_value(UniversalResetButtonFlag[0], "RelayResetButton1", Input, ""); extract_value(UniversalResetButtonFlag[1], "RelayResetButton2", Input, ""); extract_value(UniversalResetButtonFlag[2], "RelayResetButton3", Input, ""); - extract_value(enableModernDimmer, "ModernDimmer", Input, ""); + extract_value(enableModernDimmerValue, "ModernDimmer", Input, ""); // pantograph presets { auto &presets{pantographCircuit.presets.first}; @@ -1518,10 +1518,10 @@ void physics::Vehicle::LoadFIZ_Circuit(std::string const &Input) extract_value(CircuitRes, "CircuitRes", Input, ""); extract_value(IminLo, "IminLo", Input, ""); extract_value(IminHi, "IminHi", Input, ""); - extract_value(ImaxLo, "ImaxLo", Input, ""); - extract_value(ImaxHi, "ImaxHi", Input, ""); - Imin = IminLo; - Imax = ImaxLo; + extract_value(imaxLo, "ImaxLo", Input, ""); + extract_value(imaxHi, "ImaxHi", Input, ""); + imin = IminLo; + Imax = imaxLo; extract_value(TUHEX_Sum, "TUHEX_Sum", Input, ""); extract_value(TUHEX_Diff, "TUHEX_Diff", Input, ""); extract_value(TUHEX_MaxIw, "TUHEX_MaxIw", Input, ""); @@ -1535,10 +1535,10 @@ void physics::Vehicle::LoadFIZ_Circuit(std::string const &Input) void physics::Vehicle::LoadFIZ_AI(std::string const &Input) { - extract_value(AIHintPantstate, "Pantstate", Input, ""); - extract_value(AIHintShuntPantstate, "ShuntPantstate", Input, ""); + extract_value(aiHintPantstate, "Pantstate", Input, ""); + extract_value(aiHintShuntPantstate, "ShuntPantstate", Input, ""); extract_value(AIHintPantUpIfIdle, "IdlePantUp", Input, ""); - extract_value(AIHintLocalBrakeAccFactor, "LocalBrakeAccFactor", Input, ""); + extract_value(aiHintLocalBrakeAccFactor, "LocalBrakeAccFactor", Input, ""); } void physics::Vehicle::LoadFIZ_RList(std::string const &Input) @@ -1605,10 +1605,10 @@ void physics::Vehicle::LoadFIZ_UCList(std::string const &Input) extract_value(UniCtrlListSize, "Size", Input, ""); extract_value(UniCtrlIntegratedBrakeCtrl, "IntegratedBrake", Input, ""); - extract_value(UniCtrlIntegratedLocalBrakeCtrl, "IntegratedLocBrake", Input, ""); + extract_value(uniCtrlIntegratedLocalBrakeCtrl, "IntegratedLocBrake", Input, ""); extract_value(UniCtrlIntegratedBrakePNCtrl, "IntegratedBrakePN", Input, ""); - extract_value(UniCtrlValStep, "CtrlValStep", Input, ""); - UniCtrlValStep = std::max(UniCtrlValStep, 0.0); + extract_value(uniCtrlValStep, "CtrlValStep", Input, ""); + uniCtrlValStep = std::max(uniCtrlValStep, 0.0); } void physics::Vehicle::LoadFIZ_DList(std::string const &Input) diff --git a/physics/components/pneumatics.cpp b/physics/components/pneumatics.cpp index f057e4cce..3103f7911 100644 --- a/physics/components/pneumatics.cpp +++ b/physics/components/pneumatics.cpp @@ -229,9 +229,9 @@ double physics::Vehicle::PipeRatio(void) const // ************************************************************************************************* bool physics::Vehicle::EpFuseSwitch(bool State) { - if (EpFuse != State) + if (epFuse != State) { - EpFuse = State; + epFuse = State; return true; } else @@ -588,7 +588,7 @@ bool physics::Vehicle::SwitchEPBrake(int state) bool physics::Vehicle::EPBrakeControlPowered() const { - return lowVoltage.Is24vAvailable() && DirActive != 0 && EpFuse; + return lowVoltage.Is24vAvailable() && DirActive != 0 && epFuse; } // ************************************************************************************************* @@ -600,7 +600,7 @@ bool physics::Vehicle::IncBrakePress(double &brake, double PressLimit, double dp bool IBP; // if (DynamicBrakeType<>dbrake_switch) and (DynamicBrakeType<>dbrake_none) and // ((BrakePress>2.0) or (PipePress<3.7{(LowPipePress+0.5)})) then - if (brakes.electrodynamic.type != dbrake_switch && brakes.electrodynamic.type != dbrake_none && brakes.cylinderPressure > 2.0 && TrainType != train_type::emu) // yB radzi nie sprawdzać ciśnienia w przewodzie + if (brakes.electrodynamic.type != dbrake_switch && brakes.electrodynamic.type != dbrake_none && brakes.cylinderPressure > 2.0 && trainType != train_type::emu) // yB radzi nie sprawdzać ciśnienia w przewodzie // hunter-301211: dla EN57 silnikow nie odlaczamy { brakes.electrodynamic.on = true; // uruchamianie hamulca ED albo odlaczanie silnikow @@ -861,7 +861,7 @@ void physics::Vehicle::UpdatePipePressure(double dt) brakePipe.SetCouplersPending(true); if (brakes.config.antiSlipType == 128) - brakes.distributor->ASB(int(SlippingWheels && Vel > 1) * (1 + 2 * int(nrot_eps < -0.01))); + brakes.distributor->ASB(int(slippingWheels && Vel > 1) * (1 + 2 * int(nrot_eps < -0.01))); brakes.pipeFlow = 0; @@ -888,7 +888,7 @@ void physics::Vehicle::UpdateLocalBrakeValve(double dt) if (EngineType != TEngineType::ElectricInductionMotor) { double lbpa = brakes.config.independentTraxx ? eim_localbrake : brakes.IndependentPosition(); - if (EIMCtrlType > 0 && UniCtrlIntegratedLocalBrakeCtrl) + if (EIMCtrlType > 0 && uniCtrlIntegratedLocalBrakeCtrl) { lbpa = std::max(0.0, -eimic_real); } @@ -896,7 +896,7 @@ void physics::Vehicle::UpdateLocalBrakeValve(double dt) { lbpa = std::max(lbpa, brakes.holding.deceleration); } - brakes.independentValveFlow = brakes.independentValve->GetPF(PulleeMode ? 0.0 : std::max(lbpa, brakes.IndependentPositionEim()), brakes.distributor->GetBCP(), mainPipe.Pressure(), dt, 0); + brakes.independentValveFlow = brakes.independentValve->GetPF(pulleeMode ? 0.0 : std::max(lbpa, brakes.IndependentPositionEim()), brakes.distributor->GetBCP(), mainPipe.Pressure(), dt, 0); } else { @@ -917,7 +917,7 @@ void physics::Vehicle::UpdateLocalBrakeValve(double dt) { lbpa = 0.0; } - brakes.independentValveFlow = brakes.independentValve->GetPF(PulleeMode ? 0.0 : std::max(lbpa, brakes.IndependentPositionEim()), brakes.distributor->GetBCP(), mainPipe.Pressure(), dt, 0); + brakes.independentValveFlow = brakes.independentValve->GetPF(pulleeMode ? 0.0 : std::max(lbpa, brakes.IndependentPositionEim()), brakes.distributor->GetBCP(), mainPipe.Pressure(), dt, 0); } } @@ -927,7 +927,7 @@ void physics::Vehicle::UpdateMainValve(double dt) auto const temp{MainValveSupply()}; brakes.driverValve->SetReductor(brakes.HandleCapPosition()); - if (PulleeMode) + if (pulleeMode) { // the driver's valve of a vehicle prepared for hauling is cut out, whatever its handle shows brakes.driverValveFlow = 0; @@ -967,7 +967,7 @@ double physics::Vehicle::MainValveSupply() brakes.pipeLock.locked = brakePipe.Pressure() < (brakes.pipeLock.locked ? brakes.pipeLock.offPressure : brakes.pipeLock.onPressure); bool lock_new = (brakes.pipeLock.locked && !brakes.pipeLock.unlockPressed && brakes.HandlePositionReal() > brakes.pipeLock.unlockHandlePosition) || (brakes.config.emergencyCutsOffDriverValve && brakes.emergencyValve.flow > 0); // new simple codition based on .fiz bool lock_old = brakes.config.driverValveType == TBrakeHandle::FV4a // old complex condition based on assumptions - && brakePipe.Pressure() < 2.75 && (brakes.distributor->GetStatus() & b_rls) == 0 && brakes.config.subsystem == TBrakeSubSystem::ss_LSt && TrainType != train_type::emu && !brakes.pipeLock.unlockPressed; + && brakePipe.Pressure() < 2.75 && (brakes.distributor->GetStatus() & b_rls) == 0 && brakes.config.subsystem == TBrakeSubSystem::ss_LSt && trainType != train_type::emu && !brakes.pipeLock.unlockPressed; if (lock_old || lock_new) { @@ -1002,10 +1002,10 @@ void physics::Vehicle::UpdateEmergencyValve(double dt) // vents the pipe only from the vehicle driven from, whatever the controllers of the others show. // a vehicle prepared for hauling (PulleeMode) vents it for nothing of its own, only for the alarm chain, // which a train parting sets too - auto const ownemergency{radioStopFlag || (EIMCtrlEmergency && brakes.IndependentPosition() >= 1.0) || (IsMainCtrlEmergencyPos() && IsCabMaster()) || SecuritySystem.is_braking() || + auto const ownemergency{radioStopFlag || (eimCtrlEmergency && brakes.IndependentPosition() >= 1.0) || (IsMainCtrlEmergencyPos() && IsCabMaster()) || SecuritySystem.is_braking() || (brakes.spring.driveEmergencySpeed >= 0 && Vel > brakes.spring.driveEmergencySpeed && brakes.spring.isActive) || (0 == CabActive && (InactiveCabFlag & activation::emergencybrake) != 0)}; - if (brakes.alarmChain || (ownemergency && false == PulleeMode)) + if (brakes.alarmChain || (ownemergency && false == pulleeMode)) { brakes.emergencyValve.flow = PF(0, brakePipe.Pressure(), 0.15) * dt; } @@ -1034,7 +1034,7 @@ void physics::Vehicle::UpdateDistributorSettings() brakes.distributor->PLC(brakes.config.maxCylinderPressure[brakes.loadSetting]); else //(Hamulec as TWest).PLC(TotalMass); - brakes.distributor->PLC(TotalMass - Mred); + brakes.distributor->PLC(totalMass - mred); break; } @@ -1047,7 +1047,7 @@ void physics::Vehicle::UpdateDistributorSettings() for (auto const &couplerentry : Couplers) // nie podoba mi się to rozwiązanie, chyba trzeba // dodać jakiś wpis do fizyki na to - if (et41or42(TrainType) && couplerentry.Connected != nullptr && et41or42(couplerentry.Connected->TrainType) && couplerentry.CouplingFlag.HasAll(Coupling::control | Coupling::mainHose)) + if (et41or42(trainType) && couplerentry.Connected != nullptr && et41or42(couplerentry.Connected->trainType) && couplerentry.CouplingFlag.HasAll(Coupling::control | Coupling::mainHose)) brakes.independentCylinderPressure = std::max(couplerentry.Connected->brakes.independentValve->GetCP(), brakes.independentCylinderPressure); // if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor)) @@ -1065,7 +1065,7 @@ void physics::Vehicle::UpdateDistributorSettings() if (brakes.config.maxPressureMass < 2) brakes.distributor->PLC(brakes.config.maxCylinderPressure[brakes.loadSetting]); else - brakes.distributor->PLC(TotalMass - Mred); + brakes.distributor->PLC(totalMass - mred); } break; } @@ -1081,7 +1081,7 @@ void physics::Vehicle::UpdateDistributorSettings() case TBrakeValve::EP2: case TBrakeValve::EP1: { - brakes.distributor->PLC(TotalMass - Mred); + brakes.distributor->PLC(totalMass - mred); break; } case TBrakeValve::ESt3AL2: @@ -1094,7 +1094,7 @@ void physics::Vehicle::UpdateDistributorSettings() brakes.distributor->PLC(brakes.config.maxCylinderPressure[brakes.loadSetting]); else //(Hamulec as TNESt3).PLC(TotalMass); - brakes.distributor->PLC(TotalMass - Mred); + brakes.distributor->PLC(totalMass - mred); brakes.independentCylinderPressure = brakes.independentValve->GetCP(); //(Hamulec as TNESt3).SetLBP(LocBrakePress); brakes.distributor->SetLBP(brakes.independentCylinderPressure); @@ -1110,7 +1110,7 @@ void physics::Vehicle::UpdateDistributorSettings() brakes.distributor->PLC(brakes.config.maxCylinderPressure[brakes.loadSetting]); else //(Hamulec as TKE).PLC(TotalMass); - brakes.distributor->PLC(TotalMass - Mred); + brakes.distributor->PLC(totalMass - mred); break; } default: @@ -1164,7 +1164,7 @@ void physics::Vehicle::UpdateScndPipePressure(double dt) mainPipe.reservoir->Flow(brakes.distributor->GetHPFlow(mainPipe.Pressure(), dt)); // NOTE: condition disabled to allow the air flow from the main hose to the main tank as well - if (/* ( ( Compressor > ScndPipePress ) && ( */ air.config.mainReservoirVolume > 0.0 /* ) ) || ( TrainType == train_type::emu ) || ( TrainType == train_type::dmu ) */) + if (/* ( ( Compressor > ScndPipePress ) && ( */ air.config.mainReservoirVolume > 0.0 /* ) ) || ( trainType == train_type::emu ) || ( trainType == train_type::dmu ) */) { double const dV = PF(air.MainReservoirPressure(), mainPipe.Pressure(), Spz) * dt; air.AddAir(dV / 1000.0); @@ -1234,7 +1234,7 @@ bool pipe_wakes(double const Flow, double const Pressure, TReservoir const &Rese // carry on past the pressure of the vehicle it comes from. so of one asleep, the pressure with what has flown in since double neighbour_pipe_pressure(physics::Vehicle const &Neighbour, double const Pressure, TReservoir const &Reservoir) { - if ((Global.physics_pipewake <= 0.f) || Neighbour.PhysicActivation) + if ((Global.physics_pipewake <= 0.f) || Neighbour.PhysicActivation()) return Pressure; return Reservoir.P_pending(); } diff --git a/physics/components/securitysystem.cpp b/physics/components/securitysystem.cpp index d922c51f2..3605d6810 100644 --- a/physics/components/securitysystem.cpp +++ b/physics/components/securitysystem.cpp @@ -205,7 +205,7 @@ bool TSecuritySystem::is_engine_blocked() const return velocity < AwareMinSpeed && pressed; } -void TSecuritySystem::load(std::string const &line, double Vmax) +void TSecuritySystem::load(std::string const &line, double vmax) { std::string awaresystem = extract_value("AwareSystem", line); if (awaresystem.find("Active") != std::string::npos) @@ -218,7 +218,7 @@ void TSecuritySystem::load(std::string const &line, double Vmax) separate_acknowledge = true; extract_value(AwareDelay, "AwareDelay", line, ""); - AwareMinSpeed = 0.1 * Vmax; // domyślnie 10% Vmax + AwareMinSpeed = 0.1 * vmax; // domyślnie 10% Vmax extract_value(AwareMinSpeed, "AwareMinSpeed", line, ""); extract_value(SoundSignalDelay, "SoundSignalDelay", line, ""); extract_value(EmergencyBrakeDelay, "EmergencyBrakeDelay", line, ""); diff --git a/physics/components/setup.cpp b/physics/components/setup.cpp index e2af68095..bd3f6b271 100644 --- a/physics/components/setup.cpp +++ b/physics/components/setup.cpp @@ -39,7 +39,7 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/) WriteLog("check locomotive parameters..."); bool OK = true; - AutoRelayFlag = AutoRelayType == 1; + autoRelayFlag = autoRelayType == 1; if (lowVoltage.config.nominalBatteryVoltage == 0.0) { @@ -56,10 +56,10 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/) // for these engine types secondary controller positions index MotorParam table if ((EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric) && - ScndCtrlPosNo > MotorParametersArraySize) + scndCtrlPosNo > MotorParametersArraySize) { - WriteLog("SCPN=" + std::to_string(ScndCtrlPosNo) + " exceeds motor parameter table size, limited to " + std::to_string(MotorParametersArraySize)); - ScndCtrlPosNo = MotorParametersArraySize; + WriteLog("SCPN=" + std::to_string(scndCtrlPosNo) + " exceeds motor parameter table size, limited to " + std::to_string(MotorParametersArraySize)); + scndCtrlPosNo = MotorParametersArraySize; } // WriteLog("aa = " + AxleArangement + " " + std::string( Pos("o", AxleArangement)) ); @@ -67,7 +67,7 @@ bool physics::Vehicle::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/) if (contains(AxleArangement, "o") && EngineType == TEngineType::ElectricSeriesMotor) { // test poprawnosci ilosci osi indywidualnie napedzanych - OK = RList[1].Bn * RList[1].Mn == NPoweredAxles; + OK = RList[1].Bn * RList[1].Mn == nPoweredAxles; // WriteLogSS("aa ok", BoolToYN(OK)); } @@ -226,7 +226,7 @@ void physics::Vehicle::CreateBrakeValve() case TBrakeValve::K: { WriteLog("XBT W, K"); - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); if (brakes.config.maxPressureMass < 2) // jesli przystawka wazaca brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0); else @@ -236,7 +236,7 @@ void physics::Vehicle::CreateBrakeValve() case TBrakeValve::KE: { WriteLog("XBT WKE"); - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); brakes.distributor->SetRM(brakes.config.rapidRatio); if (brakes.config.maxPressureMass < 2) // jesli przystawka wazaca brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0); @@ -250,7 +250,7 @@ void physics::Vehicle::CreateBrakeValve() case TBrakeValve::ESt4: { WriteLog("XBT NESt3, ESt3, ESt3AL2, ESt4"); - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); static_cast(brakes.distributor.get())->SetSize(brakes.config.distributorSize, brakes.config.distributorParameters); if (brakes.config.maxPressureMass < 2) // jesli przystawka wazaca brakes.distributor->SetLP(0, brakes.config.maxCylinderPressure[3], 0); @@ -261,14 +261,14 @@ void physics::Vehicle::CreateBrakeValve() case TBrakeValve::LSt: { WriteLog("XBT LSt"); - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); brakes.distributor->SetRM(brakes.config.rapidRatio); break; } case TBrakeValve::EStED: { WriteLog("XBT EStED"); - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); brakes.distributor->SetRM(brakes.config.rapidRatio); if (brakes.config.maxPressureMass < 2) { @@ -284,14 +284,14 @@ void physics::Vehicle::CreateBrakeValve() case TBrakeValve::EP2: { WriteLog("XBT EP2"); - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]); break; } case TBrakeValve::EP1: { WriteLog("XBT EP1"); - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); brakes.distributor->SetLP(Mass, brakes.config.maxPressureMass, brakes.config.maxCylinderPressure[1]); brakes.distributor->SetRM(brakes.config.rapidRatio); break; @@ -299,17 +299,17 @@ void physics::Vehicle::CreateBrakeValve() case TBrakeValve::CV1: { WriteLog("XBT CV1"); - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); break; } case TBrakeValve::CV1_L_TR: { WriteLog("XBT CV1_L_T"); - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); break; } default: - brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, NAxles, brakes.config.blocksPerAxle); + brakes.distributor = std::make_shared(brakes.config.maxCylinderPressure[3], brakes.config.cylinders.radius, brakes.config.cylinders.stroke, brakes.config.valveVolume, brakes.config.cylinders.count, brakes.config.availableDelays, brakes.config.method, nAxles, brakes.config.blocksPerAxle); } brakes.distributor->SetASBP(brakes.config.maxCylinderPressure[4]); @@ -364,7 +364,7 @@ void physics::Vehicle::CreateBrakeHandles() { brakes.independentValve = std::make_shared(); brakes.independentValve->Init(brakes.config.maxCylinderPressure[0]); - if (TrainType == train_type::emu) + if (trainType == train_type::emu) { dynamic_cast(brakes.independentValve.get())->SetSpeed(3.5); diff --git a/physics/components/traction.cpp b/physics/components/traction.cpp index 6767bac9c..03a61a753 100644 --- a/physics/components/traction.cpp +++ b/physics/components/traction.cpp @@ -76,14 +76,14 @@ double physics::Vehicle::Current(double n, double U) ResistorsFlag = RList[MainCtrlActualPos].R > 0.01; // and (!DelayCtrlFlag) ResistorsFlag = ResistorsFlag || (brakes.electrodynamic.on == true && brakes.electrodynamic.type == dbrake_automatic); - if (TrainType == train_type::et22 && DelayCtrlFlag && MainCtrlActualPos > 1) + if (trainType == train_type::et22 && delayCtrlFlag && MainCtrlActualPos > 1) Bn = 1.0 - 1.0 / RList[MainCtrlActualPos].Bn; else Bn = 1; // to jest wykonywane dla EU07 R = RList[MainCtrlActualPos].R * Bn + CircuitRes; - if (TrainType != train_type::emu || Imin != IminLo || false == ScndS) + if (trainType != train_type::emu || imin != IminLo || false == ScndS) { // yBARC - boczniki na szeregu poprawnie Mn = RList[MainCtrlActualPos].Mn; // to jest wykonywane dla EU07 @@ -133,7 +133,7 @@ double physics::Vehicle::Current(double n, double U) void physics::Vehicle::UpdateSeriesMotorDynamicBrakeFlag() { // i dzialanie hamulca ED w EP09 - if (brakes.electrodynamic.type == dbrake_automatic && TrainType != train_type::emu) + if (brakes.electrodynamic.type == dbrake_automatic && trainType != train_type::emu) { if ((brakes.distributor->GetEDBCP() < 0.25 && Vadd < 1) || brakes.cylinderPressure > 2.1) brakes.electrodynamic.on = false; @@ -141,7 +141,7 @@ void physics::Vehicle::UpdateSeriesMotorDynamicBrakeFlag() brakes.electrodynamic.on = true; brakes.electrodynamic.on = brakes.electrodynamic.on && lowVoltage.Is110vAvailable(); } - if (brakes.electrodynamic.type == dbrake_automatic && TrainType == train_type::emu) + if (brakes.electrodynamic.type == dbrake_automatic && trainType == train_type::emu) { brakes.electrodynamic.on = lowVoltage.Is110vAvailable() && (TUHEX_Active || Vadd > TUHEX_MinIw) && brakes.electrodynamic.emuWorking; } @@ -178,7 +178,7 @@ double physics::Vehicle::SeriesMotorCurrent(double const n, double const U, doub SP = RList[MainCtrlActualPos].ScndAct; } - Rz = Mn * WindingRes + R; + Rz = Mn * windingRes + R; if (brakes.electrodynamic.on) // hamowanie { @@ -191,9 +191,9 @@ double physics::Vehicle::SeriesMotorCurrent(double const n, double const U, doub MotorCurrent:=(U-Isf*Rz-Mn*fi*n+SQRT(Delta))/(2*Rz) end*/ // only the ET42's switched brake brakes on the starting resistors, otherwise the current is cut off (0) - if (brakes.electrodynamic.type == dbrake_switch && TrainType == train_type::et42) + if (brakes.electrodynamic.type == dbrake_switch && trainType == train_type::et42) { // z Megapacka - Rz = WindingRes + R; + Rz = windingRes + R; MotorCurrent = -motor_param(SP).fi * n / Rz; //{hamowanie silnikiem na oporach rozruchowych} } } @@ -250,7 +250,7 @@ void physics::Vehicle::MotorFailuresCheck(double const n) { if (FuzzyLogic(abs(n), nmax * 1.1, p_elengproblem) && MainSwitch(false)) eventFlag = true; /*zbyt duze obroty - wywalanie wskutek ognia okreznego*/ - if (DamageFlag.HasAll(VehicleDamage::engine) && FuzzyLogic(MotorCurrent, (double)ImaxLo / 10.0, p_elengproblem) && MainSwitch(false)) + if (DamageFlag.HasAll(VehicleDamage::engine) && FuzzyLogic(MotorCurrent, (double)imaxLo / 10.0, p_elengproblem) && MainSwitch(false)) eventFlag = true; /*uszkodzony silnik (uplywy)*/ /* or FuzzyLogic(Abs(U/Mn),2*NominalVoltage,1)) then */ /*poprawic potem*/ if ((FuzzyLogic(abs(Im), Imax * 2, p_elengproblem) || FuzzyLogic(abs(n), nmax * 1.11, p_elengproblem)) && DamageFlag.Set(VehicleDamage::engine)) @@ -278,7 +278,7 @@ bool physics::Vehicle::CurrentSwitch(bool const State) if (MaxCurrentSwitch(State)) { - if (TrainType != train_type::emu) + if (trainType != train_type::emu) { MinCurrentSwitch(State); } @@ -291,7 +291,7 @@ bool physics::Vehicle::CurrentSwitch(bool const State) bool physics::Vehicle::IsMotorOverloadRelayHighThresholdOn() const { - return ImaxHi > ImaxLo && Imax > ImaxLo; + return imaxHi > imaxLo && Imax > imaxLo; } double physics::Vehicle::ShowEngineRotation(int VehN) const @@ -568,18 +568,18 @@ bool physics::Vehicle::DynamicBrakeSwitch(bool Switch) // ************************************************************************************************* double physics::Vehicle::TractionForce(double dt) { - Ft = 0; + ft = 0; double dtrans{0.0}; double dmoment{0.0}; auto const revolutions{UpdateEngineRevolutions(dt, dtrans, dmoment)}; - eAngle += enrot * dt; - if (eAngle > M_PI * 2.0) - eAngle = std::fmod(eAngle, M_PI * 2.0); + eAngleValue += enrot * dt; + if (eAngleValue > M_PI * 2.0) + eAngleValue = std::fmod(eAngleValue, M_PI * 2.0); /* - while (eAngle > M_PI * 2.0) + while (eAngleValue > M_PI * 2.0) // eAngle = Pirazy2 - eAngle; <- ABu: a nie czasem tak, jak nizej? - eAngle -= M_PI * 2.0; + eAngleValue -= M_PI * 2.0; */ // hunter-091012: przeniesione z if DirActive<>0 (zeby po zejsciu z kierunku dalej spadala predkosc wentylatorow) // wentylatory rozruchowe @@ -596,7 +596,7 @@ double physics::Vehicle::TractionForce(double dt) } drive.AfterTractionForce(*this); - return Ft; + return ft; } // the starting resistors' blowers, and the diesels' radiator fans @@ -626,15 +626,15 @@ void physics::Vehicle::UpdateResistorBlowers(double dt) case 2: { // automatic - auto const motorcurrent{std::min(ImaxHi, std::abs(Im))}; + auto const motorcurrent{std::min(imaxHi, std::abs(Im))}; if (std::abs(Itot) > RVentMinI && RList[MainCtrlActualPos].R > RVentCutOff) { - RventRot += (RVentnmax * std::min(1.0, motorcurrent / NPoweredAxles / RVentMinI) * motorcurrent / ImaxLo - RventRot) * RVentSpeed * dt; + RventRot += (RVentnmax * std::min(1.0, motorcurrent / nPoweredAxles / RVentMinI) * motorcurrent / imaxLo - RventRot) * RVentSpeed * dt; } else if (brakes.electrodynamic.type == dbrake_automatic && true == brakes.electrodynamic.on) { - RventRot += (RVentnmax * motorcurrent / ImaxLo - RventRot) * RVentSpeed * dt; + RventRot += (RVentnmax * motorcurrent / imaxLo - RventRot) * RVentSpeed * dt; } else if (rventForceOn) { @@ -672,24 +672,24 @@ void physics::Vehicle::DumbTractionForce(double const PosRatio) { if (Vel > 0.1) { - Ft = std::min(1000.0 * Power / std::abs(travelSpeed), Ftmax) * PosRatio; + ft = std::min(1000.0 * Power / std::abs(travelSpeed), Ftmax) * PosRatio; } else { - Ft = Ftmax * PosRatio; + ft = Ftmax * PosRatio; } - Ft = Ft * DirAbsolute; // DirActive*CabActive; + ft = ft * DirAbsolute; // DirActive*CabActive; } else { - Ft = 0; + ft = 0; } } void physics::Vehicle::WheelsDrivenTractionForce(double dt) { if (EnginePowerSource.SourceType == TPowerSource::InternalSource && EnginePowerSource.PowerType == TPowerType::BioPower) - Ft = Sign(sin(eAngle)) * PulseForce * Transmision.Ratio; + ft = Sign(sin(eAngleValue)) * PulseForce * Transmision.Ratio; PulseForceTimer = PulseForceTimer + dt; if (PulseForceTimer > CtrlDelay) { @@ -697,20 +697,20 @@ void physics::Vehicle::WheelsDrivenTractionForce(double dt) if (PulseForceCount > 0) PulseForceCount--; } - EnginePower = Ft * (1.0 + Vel); + EnginePower = ft * (1.0 + Vel); } void physics::Vehicle::SeriesMotorTractionForce(double dt) { // enrot:=Transmision.Ratio*nrot; // yB: szereg dwoch sekcji w ET42 - if (TrainType == train_type::et42 && Imax == ImaxHi) + if (trainType == train_type::et42 && Imax == imaxHi) EngineVoltage = EngineVoltage / 2.0; Mm = Momentum(Current(enrot, EngineVoltage)); // oblicza tez prad p/slinik - if (TrainType == train_type::et42) + if (trainType == train_type::et42) { - if (Imax == ImaxHi) + if (Imax == imaxHi) EngineVoltage = EngineVoltage * 2; if (brakes.electrodynamic.on && abs(Im) > 300) // przeiesione do physics.cpp FuseOff(); @@ -720,7 +720,7 @@ void physics::Vehicle::SeriesMotorTractionForce(double dt) SeriesMotorDynamicBrake(dt); } - if (TrainType == train_type::et22 && DelayCtrlFlag) // szarpanie przy zmianie układu w byku + if (trainType == train_type::et22 && delayCtrlFlag) // szarpanie przy zmianie układu w byku Mm = Mm * RList[MainCtrlActualPos].Bn / (RList[MainCtrlActualPos].Bn + 1); // zrobione w momencie, żeby nie dawac elektryki w przeliczaniu sił if (abs(Im) > Imax) @@ -732,13 +732,13 @@ void physics::Vehicle::SeriesMotorTractionForce(double dt) if ((brakes.electrodynamic.type == dbrake_automatic || brakes.electrodynamic.type == dbrake_switch) && brakes.electrodynamic.on) Itot = Im * 2; // 2x2 silniki w EP09 - else if (TrainType == train_type::emu && Imin == IminLo && ScndS) // yBARC - boczniki na szeregu poprawnie + else if (trainType == train_type::emu && imin == IminLo && ScndS) // yBARC - boczniki na szeregu poprawnie Itot = Im; else Itot = Im * RList[MainCtrlActualPos].Bn; // prad silnika * ilosc galezi Mw = Mm * Transmision.Ratio * Transmision.Efficiency; - Fw = Mw * 2.0 / WheelDiameter; - Ft = Fw * NPoweredAxles; // sila trakcyjna + Fw = Mw * 2.0 / wheelDiameter; + ft = Fw * nPoweredAxles; // sila trakcyjna } // the automatic dynamic brake of the series motors: the excitation current, by the stages of the ep brake (TUHEX) @@ -804,7 +804,7 @@ void physics::Vehicle::ShuntFieldRelaysCheck(double const tmpV, double const Pos case 0: { - if (scndCtrlPos < ScndCtrlPosNo && Im <= MPTRelay[scndCtrlPos].Iup * PosRatio) + if (scndCtrlPos < scndCtrlPosNo && Im <= MPTRelay[scndCtrlPos].Iup * PosRatio) { ++scndCtrlPos; } @@ -817,7 +817,7 @@ void physics::Vehicle::ShuntFieldRelaysCheck(double const tmpV, double const Pos case 1: { - if (scndCtrlPos < ScndCtrlPosNo && MPTRelay[scndCtrlPos].Iup < Vel) + if (scndCtrlPos < scndCtrlPosNo && MPTRelay[scndCtrlPos].Iup < Vel) { ++scndCtrlPos; } @@ -863,7 +863,7 @@ void physics::Vehicle::ShuntFieldRelaysCheck(double const tmpV, double const Pos // the relays of type 2: up by the speed while the engine has power to spare (tmp, the power it gives), down by the current void physics::Vehicle::ShuntFieldRelaysType2(double const tmp) { - if (scndCtrlPos < ScndCtrlPosNo && MPTRelay[scndCtrlPos].Iup < Vel && EnginePower < tmp * 0.99) + if (scndCtrlPos < scndCtrlPosNo && MPTRelay[scndCtrlPos].Iup < Vel && EnginePower < tmp * 0.99) { ++scndCtrlPos; } @@ -876,7 +876,7 @@ void physics::Vehicle::ShuntFieldRelaysType2(double const tmp) // the relays of type 41: up by the speed tmpV at full power, the engine slowed down, down by the current void physics::Vehicle::ShuntFieldRelaysType41(double const tmpV) { - if (scndCtrlPos < ScndCtrlPosNo && mainCtrlPos == MainCtrlPosNo && tmpV * 3.6 > MPTRelay[scndCtrlPos].Iup) + if (scndCtrlPos < scndCtrlPosNo && mainCtrlPos == MainCtrlPosNo && tmpV * 3.6 > MPTRelay[scndCtrlPos].Iup) { ++scndCtrlPos; enrot = enrot * 0.73; @@ -890,7 +890,7 @@ void physics::Vehicle::ShuntFieldRelaysType41(double const tmpV) // the relays of type 45, by the current and the speed: up from the 11th position, at most two under it, none under the 8th void physics::Vehicle::ShuntFieldRelaysType45() { - if (scndCtrlPos < ScndCtrlPosNo && mainCtrlPos >= 11) + if (scndCtrlPos < scndCtrlPosNo && mainCtrlPos >= 11) { if (Im < MPTRelay[scndCtrlPos].Iup) @@ -946,7 +946,7 @@ void physics::Vehicle::ShuntFieldRelaysType45() void physics::Vehicle::ShuntFieldRelaysType46() { // wzrastanie - if (mainCtrlPos >= 12 && scndCtrlPos < ScndCtrlPosNo) + if (mainCtrlPos >= 12 && scndCtrlPos < scndCtrlPosNo) { ShuntFieldRelaysType46Up(); } @@ -1025,7 +1025,7 @@ void physics::Vehicle::InductionMotorTractionForce(double dt) InductionMotorBrakeBlending(ActiveInverters, PosRatio, tmp); // NOTE: the commands to operate the sandbox are likely to conflict with other similar ai decisions // TODO: gather these in single place so they can be resolved together - if (SlippingWheels) + if (slippingWheels) { PosRatio = 0; tmp = 10; @@ -1056,11 +1056,11 @@ void physics::Vehicle::InductionMotorTractionForce(double dt) void physics::Vehicle::InductionMotorSpeedControl(double dt) { // tempomat - if (ScndCtrlPosNo == 4 && SpeedCtrlTypeTime) + if (scndCtrlPosNo == 4 && speedCtrlTypeTime) { SpeedControlByTime(dt); } - else if (ScndCtrlPosNo > 1) + else if (scndCtrlPosNo > 1) { SpeedControlByPosition(dt); } @@ -1069,18 +1069,18 @@ void physics::Vehicle::InductionMotorSpeedControl(double dt) // the speed control set by the position of the second controller, after it's been held for its delay void physics::Vehicle::SpeedControlByPosition(double dt) { - if (scndCtrlPos != NewSpeed) + if (scndCtrlPos != newSpeed) { SpeedCtrlTimer = 0; - NewSpeed = scndCtrlPos; + newSpeed = scndCtrlPos; } else { SpeedCtrlTimer += dt; if (SpeedCtrlTimer > SpeedCtrlDelay) { - auto NewSCAP = static_cast((float)scndCtrlPos / (float)ScndCtrlPosNo * Vmax); + auto NewSCAP = static_cast((float)scndCtrlPos / (float)scndCtrlPosNo * vmax); if (NewSCAP != SpeedCtrlValue) { SpeedCtrlValue = NewSCAP; @@ -1099,7 +1099,7 @@ void physics::Vehicle::SpeedControlByTime(double dt) switch (scndCtrlPos) { case 0: - NewSpeed = 0; + newSpeed = 0; SpeedCtrlValue = 0; SpeedCtrlTimer = 10; break; @@ -1107,31 +1107,31 @@ void physics::Vehicle::SpeedControlByTime(double dt) if (SpeedCtrlTimer > SpeedCtrlDelay) { SpeedCtrlTimer = 0; - NewSpeed -= 10; - if (NewSpeed < 0) - NewSpeed = 0; + newSpeed -= 10; + if (newSpeed < 0) + newSpeed = 0; } else SpeedCtrlTimer += dt; break; case 2: SpeedCtrlTimer = 10; - SpeedCtrlValue = NewSpeed; + SpeedCtrlValue = newSpeed; break; case 3: if (SpeedCtrlTimer > SpeedCtrlDelay) { SpeedCtrlTimer = 0; - NewSpeed += 10; - if (NewSpeed > Vmax) - NewSpeed = Vmax; + newSpeed += 10; + if (newSpeed > vmax) + newSpeed = vmax; } else SpeedCtrlTimer += dt; break; case 4: - NewSpeed = Vmax; - SpeedCtrlValue = Vmax; + newSpeed = vmax; + SpeedCtrlValue = vmax; SpeedCtrlTimer = 10; break; default: @@ -1157,7 +1157,7 @@ void physics::Vehicle::InductionMotorBrakeBlending(double const ActiveInverters, if (Flat && inductionMotor.traction.startingForce * inductionMotor.state.fullForce > 0) PosRatio = std::min(PosRatio * inductionMotor.traction.startingForce / inductionMotor.state.fullForce, 1.); /* if (ScndCtrlActualPos > 0) //speed control - if (Vmax < 250) + if (vmax < 250) PosRatio = std::min(PosRatio, std::max(-1, 0.5 * (ScndCtrlActualPos - Vel))); else PosRatio = @@ -1265,7 +1265,7 @@ void physics::Vehicle::InductionMotorDrive(double dt) } inductionMotor.state.absoluteMaxForce = 0.001 * square(std::min(1.0, inductionMotor.state.criticalFrequency / std::max(abs(enrot) * inductionMotor.motor.polePairs + inductionMotor.motor.maxSlipFrequency * inductionMotor.state.slipShare, inductionMotor.motor.maxSlipFrequency)) * f_cfu / inductionMotor.motor.voltsPerHertz) * - (inductionMotor.motor.maxSlipFrequency * inductionMotor.motor.currentPerSlip * inductionMotor.motor.torquePerCurrent) * Transmision.Ratio * NPoweredAxles * 2.0 / WheelDiameter; + (inductionMotor.motor.maxSlipFrequency * inductionMotor.motor.currentPerSlip * inductionMotor.motor.torquePerCurrent) * Transmision.Ratio * nPoweredAxles * 2.0 / wheelDiameter; InductionMotorForceLimits(); for (auto &inv : inductionMotor.inverters) { @@ -1286,8 +1286,8 @@ void physics::Vehicle::InductionMotorDrive(double dt) inductionMotor.state.torqueCurrent = (inductionMotor.state.supplyFrequency - DirAbsolute * enrot * inductionMotor.motor.polePairs) * inductionMotor.motor.currentPerSlip * inductionMotor.state.flux; inductionMotor.state.fieldCurrent = inductionMotor.state.torqueCurrent * inductionMotor.motor.fieldCurrentRatio; inductionMotor.state.torque = inductionMotor.state.flux * inductionMotor.state.torqueCurrent * inductionMotor.motor.torquePerCurrent; - inductionMotor.state.lineCurrent = inductionMotor.state.torqueCurrent * NPoweredAxles * inductionMotor.inverterRatio * inductionMotor.state.voltage / (EngineVoltage - inductionMotor.converter.voltageDrop) + inductionMotor.converter.noLoadCurrent; - inductionMotor.state.mechanicalPower = DirActive * inductionMotor.state.torque * NPoweredAxles * inductionMotor.inverterRatio * enrot * Pirazy2 / 1000; + inductionMotor.state.lineCurrent = inductionMotor.state.torqueCurrent * nPoweredAxles * inductionMotor.inverterRatio * inductionMotor.state.voltage / (EngineVoltage - inductionMotor.converter.voltageDrop) + inductionMotor.converter.noLoadCurrent; + inductionMotor.state.mechanicalPower = DirActive * inductionMotor.state.torque * nPoweredAxles * inductionMotor.inverterRatio * enrot * Pirazy2 / 1000; inductionMotor.state.electricalPower = inductionMotor.state.lineCurrent * EngineVoltage / 1000; inductionMotor.state.efficiency = inductionMotor.state.mechanicalPower / inductionMotor.state.electricalPower; @@ -1302,15 +1302,15 @@ void physics::Vehicle::InductionMotorDrive(double dt) Vadd = std::max(Vadd * (1.0 - 0.2 * dt), 0.007 * (std::abs(EngineVoltage) - (EnginePowerSource.CollectorParameters.MaxV - 100))); Itot = inductionMotor.state.lineCurrent * (0.01 + std::min(0.99, 0.99 - Vadd)); - EnginePower = abs(inductionMotor.state.torqueCurrent * inductionMotor.state.voltage * NPoweredAxles) / 1000; + EnginePower = abs(inductionMotor.state.torqueCurrent * inductionMotor.state.voltage * nPoweredAxles) / 1000; // power inverters UpdateInverterFrequency(); Mm = inductionMotor.state.torque * DirAbsolute; Mw = Mm * Transmision.Ratio * Transmision.Efficiency; - Fw = Mw * 2.0 / WheelDiameter; - Ft = Fw * NPoweredAxles * inductionMotor.inverterRatio; - inductionMotor.state.force = DirAbsolute * Ft / 1000; + Fw = Mw * 2.0 / wheelDiameter; + ft = Fw * nPoweredAxles * inductionMotor.inverterRatio; + inductionMotor.state.force = DirAbsolute * ft / 1000; } // the force the motors give at full and at the setting (inductionMotor.forceShare), braking within the power and the force of the @@ -1378,7 +1378,7 @@ void physics::Vehicle::InductionMotorOff() Mm = 0.0; Mw = 0.0; Fw = 0.0; - Ft = 0.0; + ft = 0.0; Itot = 0.0; inductionMotor.forceShare = 0.0; EnginePower = 0.0; @@ -1512,18 +1512,18 @@ double physics::Vehicle::v2n(void) double n; double deltan = 0; - n = travelSpeed / (M_PI * WheelDiameter); // predkosc obrotowa wynikajaca z liniowej [obr/s] - deltan = n - nrot; //"pochodna" prędkości obrotowej - /* if (SlippingWheels) + n = travelSpeed / (M_PI * wheelDiameter); // predkosc obrotowa wynikajaca z liniowej [obr/s] + deltan = n - nrotValue; //"pochodna" prędkości obrotowej + /* if (slippingWheels) if (std::abs(deltan) < 0.001) - SlippingWheels = false; // wygaszenie poslizgu */ //poslizg jest w innym miejscu wygaszany też - if (SlippingWheels) // nie ma zwiazku z predkoscia liniowa V + slippingWheels = false; // wygaszenie poslizgu */ //poslizg jest w innym miejscu wygaszany też + if (slippingWheels) // nie ma zwiazku z predkoscia liniowa V { // McZapkie-221103: uszkodzenia kol podczas poslizgu if (deltan > dmgn && FuzzyLogic(deltan, dmgn, p_slippdmg) && DamageFlag.Set(VehicleDamage::wheelWear)) // podkucie eventFlag = true; if (deltan < -dmgn && FuzzyLogic(-deltan, dmgn, p_slippdmg) && DamageFlag.Set(VehicleDamage::thinWheel)) // wycieranie sie obreczy eventFlag = true; - n = nrot; // predkosc obrotowa nie zalezy od predkosci liniowej + n = nrotValue; // predkosc obrotowa nie zalezy od predkosci liniowej } return n; } @@ -1563,9 +1563,9 @@ double physics::Vehicle::MomentumF(double I, double Iw, int SCP) const bool physics::Vehicle::CutOffEngine(void) { bool COE = false; // Ra: wartość domyślna, sprawdzić to trzeba - if (NPoweredAxles > 0 && CabActive == 0 && EngineType == TEngineType::ElectricSeriesMotor && DamageFlag.Clear(VehicleDamage::engine)) + if (nPoweredAxles > 0 && CabActive == 0 && EngineType == TEngineType::ElectricSeriesMotor && DamageFlag.Clear(VehicleDamage::engine)) { - NPoweredAxles = NPoweredAxles / 2; // bylo div czyli mod? + nPoweredAxles = nPoweredAxles / 2; // bylo div czyli mod? COE = true; } return COE; @@ -1577,9 +1577,9 @@ bool physics::Vehicle::CutOffEngine(void) // ************************************************************************************************* bool physics::Vehicle::MaxCurrentSwitch(bool State, range_t const Notify) { - auto const initialstate{MotorOverloadRelayHighThreshold}; + auto const initialstate{motorOverloadRelayHighThreshold}; - MotorOverloadRelayHighThreshold = State; + motorOverloadRelayHighThreshold = State; if (Notify != range_t::local) { @@ -1596,19 +1596,19 @@ bool physics::Vehicle::MaxCurrentSwitch(bool State, range_t const Notify) bool physics::Vehicle::MinCurrentSwitch(bool State) { bool MCS = false; - if ((EngineType == TEngineType::ElectricSeriesMotor && IminHi > IminLo) || (TrainType == train_type::emu && EngineType != TEngineType::ElectricInductionMotor)) + if ((EngineType == TEngineType::ElectricSeriesMotor && IminHi > IminLo) || (trainType == train_type::emu && EngineType != TEngineType::ElectricInductionMotor)) { - if (State && Imin == IminLo) + if (State && imin == IminLo) { - Imin = IminHi; + imin = IminHi; MCS = true; if (CabActive != 0) SendCtrlToNext(VehicleCommand::minCurrentSwitch, 1, CabActive); } - if (!State && Imin == IminHi) + if (!State && imin == IminHi) { - Imin = IminLo; + imin = IminLo; MCS = true; if (CabActive != 0) SendCtrlToNext(VehicleCommand::minCurrentSwitch, 0, CabActive); @@ -1646,7 +1646,7 @@ double physics::Vehicle::ShowCurrentP(int AmpN) const bool Grupowy; // ClearPendingExceptions; - Grupowy = DelayCtrlFlag && TrainType == train_type::et22; // przerzucanie walu grupowego w ET22; + Grupowy = delayCtrlFlag && trainType == train_type::et22; // przerzucanie walu grupowego w ET22; Bn = RList[MainCtrlActualPos].Bn; // ile równoległych gałęzi silników if (brakes.electrodynamic.type == dbrake_automatic && brakes.electrodynamic.on) diff --git a/physics/consistbraking.cpp b/physics/consistbraking.cpp index 423b636e4..455fdaa28 100644 --- a/physics/consistbraking.cpp +++ b/physics/consistbraking.cpp @@ -70,7 +70,7 @@ void physics::ConsistBrakeBlending::SetControl(Step &state, Vehicle &Lead, Input Lead.CheckEIMIC(dt1); Lead.CheckSpeedCtrl(dt1); - state.eimic = std::min(Lead.eimic, Lead.eimicSpeedCtrl); + state.eimic = std::min(Lead.eimic, Lead.eimicSpeedCtrl()); Lead.eimic_real = state.eimic; // Elf: full braking at once in the lowest position, and in the emergency brake position below it if (Lead.EIMCtrlType == 2 && Lead.MainCtrlPos() <= Lead.EIMCtrlEmergencyPositions()) @@ -101,18 +101,18 @@ void physics::ConsistBrakeBlending::SumForces(Step &state, std::vectorbrakes.config.maxPressureMass > 1.0 ? 0.0 : vehicle->Mass ) - + vehicle->Mred; + + vehicle->Mred(); auto const Nmax = ((vehicle->brakes.config.pressureToForce * vehicle->brakes.config.maxCylinderPressure[0] - vehicle->brakes.config.cylinders.springForce) * vehicle->brakes.config.cylinders.leverRatio[0] - vehicle->brakes.config.cylinders.slackAdjusterForce) * vehicle->brakes.config.cylinders.count * vehicle->brakes.config.cylinders.riggingEfficiency; state.FmaxPN += Nmax * vehicle->brakes.distributor->GetFC( - Nmax / (vehicle->NAxles * vehicle->brakes.config.blocksPerAxle), + Nmax / (vehicle->NAxles() * vehicle->brakes.config.blocksPerAxle), vehicle->brakes.blending.referenceSpeed) * 1000; // sila hamowania pn state.FmaxED += vehicle->lineBreaker.IsClosed() && vehicle->DirActive != 0 && vehicle->inductionMotor.inverterRatio == 1.0 && - vehicle->inductionMotor.braking.maxForce * vehicle->NPoweredAxles > 0 ? + vehicle->inductionMotor.braking.maxForce * vehicle->NPoweredAxles() > 0 ? vehicle->inductionMotor.braking.maxForce * 1000 : 0; // chwilowy max ED -> do rozdzialu sil FED -= std::min(vehicle->inductionMotor.state.maxForce, 0.0) * @@ -123,8 +123,8 @@ void physics::ConsistBrakeBlending::SumForces(Step &state, std::vector do pneumatyki Frj += std::max(vehicle->inductionMotor.state.maxForce, 0.0) * 1000;// chwilowo realizowany napęd -> do utrzymującego - state.masa += vehicle->TotalMass; - state.osie += vehicle->NAxles; + state.masa += vehicle->TotalMass(); + state.osie += vehicle->NAxles(); } } @@ -217,7 +217,7 @@ void physics::ConsistBrakeBlending::ComputeElectrodynamicDemand(Step &state, Veh if( state.LBR > Lead.brakes.blending.minEdDemand && ( Lead.brakes.config.driverValveType == TBrakeHandle::MHZ_EN57 ? (Lead.brakes.operatingMode & bom_MED) != 0 : - Lead.EpFuse ) ) { + Lead.EpFuse() ) ) { state.FzadED = std::min( state.Fzad, state.FmaxED ); } /*/ELF - wdrazanie ED po powrocie na utrzymanie hamowania - do usuniecia @@ -280,14 +280,14 @@ void physics::ConsistBrakeBlending::DistributeForces(Step &state, Vehicle const vehicle->brakes.config.cylinders.count * vehicle->brakes.config.cylinders.riggingEfficiency; FmaxEP[i] = Nmax * vehicle->brakes.distributor->GetFC( - Nmax / (vehicle->NAxles * vehicle->brakes.config.blocksPerAxle), + Nmax / (vehicle->NAxles() * vehicle->brakes.config.blocksPerAxle), vehicle->brakes.blending.referenceSpeed) * 1000; // sila hamowania pn PrzekrF[i] = false; FzED[i] = state.FmaxED > 0 ? state.FzadED / state.FmaxED : 0; vehicle->SetAnPos(Lead.ScndS ? state.LBR : FzED[i]); - FzEP[ i ] = static_cast( state.FzadPN * vehicle->NAxles ) / static_cast( state.osie ); + FzEP[ i ] = static_cast( state.FzadPN * vehicle->NAxles() ) / static_cast( state.osie ); ++i; vehicle->ShuntMode = Lead.ShuntMode; vehicle->ShuntModeAllow = Lead.ShuntModeAllow; @@ -300,12 +300,12 @@ void physics::ConsistBrakeBlending::DistributeForces(Step &state, Vehicle const for (auto *vehicle : Consist) { if (FzEP[i] > 0.01 && - FzEP[i] > vehicle->TotalMass * vehicle->inductionMotor.braking.maxEpDeceleration + std::min(vehicle->inductionMotor.state.maxForce, 0.) * 1000 && + FzEP[i] > vehicle->TotalMass() * vehicle->inductionMotor.braking.maxEpDeceleration + std::min(vehicle->inductionMotor.state.maxForce, 0.) * 1000 && !PrzekrF[i]) { float przek1 = -std::min(vehicle->inductionMotor.state.maxForce, 0.) * 1000 + FzEP[i] - - vehicle->TotalMass * + vehicle->TotalMass() * vehicle->inductionMotor.braking.maxEpDeceleration * 0.999; PrzekrF[i] = true; test = true; @@ -345,7 +345,7 @@ void physics::ConsistBrakeBlending::DistributeForces(Step &state, Vehicle const float VelC = EPVC ? safe_clamp(vehicle->Vel, vehicle->brakes.blending.minSpeed, vehicle->brakes.blending.maxSpeed) : vehicle->brakes.blending.referenceSpeed;//korekcja EP po prędkości float FmaxPoj = Nmax * vehicle->brakes.distributor->GetFC( - Nmax / (vehicle->NAxles * vehicle->brakes.config.blocksPerAxle), VelC) * + Nmax / (vehicle->NAxles() * vehicle->brakes.config.blocksPerAxle), VelC) * 1000; // sila hamowania pn vehicle->brakes.SetIndependentPositionEim(FzEP[i] / FmaxPoj); if (vehicle->brakes.IndependentPositionEim()>0.009) diff --git a/physics/vehicle.h b/physics/vehicle.h index 4d6cc4277..3e6a68ab6 100644 --- a/physics/vehicle.h +++ b/physics/vehicle.h @@ -449,7 +449,7 @@ class TSecuritySystem bool is_engine_blocked() const; bool radiostop_available() const; bool has_separate_acknowledge() const; - void load(std::string const &line, double Vmax); + void load(std::string const &line, double vmax); double MagnetLocation = 0.0; }; @@ -629,11 +629,11 @@ class Vehicle int CategoryFlag = 1; /*1 - pociag, 2 - samochod, 4 - statek, 8 - samolot*/ /*--sekcja stalych typowych parametrow*/ std::string TypeName; /*nazwa serii/typu*/ - train_type TrainType{train_type::generic}; // the vehicles of a handling of their own, from the Type of the .fiz + train_type const &TrainType() const { return trainType; } // the vehicles of a handling of their own, from the Type of the .fiz // an electric or a diesel multiple unit bool is_multiple_unit() const { - return TrainType == train_type::emu || TrainType == train_type::dmu; + return trainType == train_type::emu || trainType == train_type::dmu; } TEngineType EngineType = TEngineType::None; /*typ napedu*/ TPowerParameters EnginePowerSource; /*zrodlo mocy dla silnikow*/ @@ -642,13 +642,13 @@ class Vehicle TPowerParameters AlterHeatPowerSource; /*alternatywne zrodlo mocy dla ogrzewania*/ TPowerParameters LightPowerSource; /*zrodlo mocy dla oswietlenia*/ TPowerParameters AlterLightPowerSource; /*alternatywne mocy dla oswietlenia*/ - double Vmax = -1.0; + double const &Vmax() const { return vmax; } double Mass = 0.0; double Power = 0.0; /*max. predkosc kontrukcyjna, masa wlasna, moc*/ - double Mred = 0.0; /*Ra: zredukowane masy wirujące; potrzebne do obliczeń hamowania*/ - double TotalMass = 0.0; /*wyliczane przez ComputeMass*/ + double const &Mred() const { return mred; } /*Ra: zredukowane masy wirujące; potrzebne do obliczeń hamowania*/ + double const &TotalMass() const { return totalMass; } /*wyliczane przez ComputeMass*/ double LightPower = 0.0; /*moc pobierana na ogrzewanie/oswietlenie*/ - bool EpFuse = true; /*Czy jest wlaczony hamulec EP*/ + bool const &EpFuse() const { return epFuse; } /*Czy jest wlaczony hamulec EP*/ double EpForce = 0.0; /*Poziom zadanej sily EP*/ bool const &Signalling() const { return signalling; } /*Czy jest zalaczona sygnalizacja hamowania ostatniego wagonu*/ void SetSignalling(bool const Value) { signalling = Value; } @@ -664,17 +664,17 @@ class Vehicle // height of the centre of gravity of the empty vehicle above the rail [m] (CoGH in the Dimensions of the .fiz), // negative when the definition gives none: derailment::default_centre_of_gravity() then double CentreOfGravity = -1.0; - float WheelDiameter = 1.f; /*srednica kol napednych*/ + float const &WheelDiameter() const { return wheelDiameter; } /*srednica kol napednych*/ float WheelDiameterL = 0.9f; // Ra: srednica kol tocznych przednich float WheelDiameterT = 0.9f; // Ra: srednica kol tocznych tylnych float TrackW = 1.435f; /*nominalna szerokosc toru [m]*/ double AxleInertialMoment = 0.0; /*moment bezwladnosci zestawu kolowego*/ std::string AxleArangement; /*uklad osi np. Bo'Bo' albo 1'C*/ - int NPoweredAxles = 0; /*ilosc osi napednych liczona z powyzszego*/ - int NAxles = 0; /*ilosc wszystkich osi j.w.*/ + int const &NPoweredAxles() const { return nPoweredAxles; } /*ilosc osi napednych liczona z powyzszego*/ + int const &NAxles() const { return nAxles; } /*ilosc wszystkich osi j.w.*/ int BearingType = 1; /*lozyska: 0 - slizgowe, 1 - toczne*/ - double ADist = 0.0; - double BDist = 0.0; /*odlegosc osi oraz czopow skretu*/ + double const &ADist() const { return aDist; } + double const &BDist() const { return bDist; } /*odlegosc osi oraz czopow skretu*/ int SandCapacity = 0; /*zasobnik piasku [kg]*/ int const &WiperSwitchPos() const { return wiperSwitchPos; } // pozycja przelacznika wycieraczek @@ -699,7 +699,7 @@ class Vehicle int TurboTest = 0; /*nastawniki:*/ int MainCtrlPosNo = 0; /*ilosc pozycji nastawnika*/ - int ScndCtrlPosNo = 0; + int const &ScndCtrlPosNo() const { return scndCtrlPosNo; } int LightsPosNo = 0; int LightsDefPos = 1; bool LightsWrap = false; @@ -719,7 +719,7 @@ class Vehicle float DistanceCounterDoublePressPeriod = {1.f}; // czas w jakim nalezy podwojnie wcisnac przycisk, aby rozpoczac pomiar odleglosci TSecuritySystem SecuritySystem; int EmergencyBrakeWarningSignal{0}; // combined with basic warningSignal when manual emergency brake is active - horn_supply HornSupply{horn_supply::air}; // of the low and high tone horns (warningSignal 1 and 2) + horn_supply const &HornSupply() const { return hornSupply; } // of the low and high tone horns (warningSignal 1 and 2) horn_supply Horn3Supply{horn_supply::air}; // of the third horn (warningSignal 4) // main reservoir pressure [bar, as MinCP and MaxCP] below which a pneumatic horn stays silent static constexpr double HornMinPressure{2.0}; @@ -727,12 +727,12 @@ class Vehicle int UniCtrlListSize = 0; /*wielkosc listy pozycji uniwersalnego nastawnika*/ bool UniCtrlIntegratedBrakePNCtrl = false; /*zintegrowany nastawnik JH obsluguje hamulec PN*/ bool UniCtrlIntegratedBrakeCtrl = false; /*zintegrowany nastawnik JH obsluguje hamowanie*/ - bool UniCtrlIntegratedLocalBrakeCtrl = false; /*zintegrowany nastawnik JH obsluguje hamowanie hamulcem pomocniczym*/ + bool const &UniCtrlIntegratedLocalBrakeCtrl() const { return uniCtrlIntegratedLocalBrakeCtrl; } /*zintegrowany nastawnik JH obsluguje hamowanie hamulcem pomocniczym*/ int UniCtrlNoPowerPos{0}; // cached highesr position not generating traction force // UCList CtrlValStep: the universal controller (EIMCtrlType 3) changes its setting in steps of this size (e.g. 0.05 for the // 5% steps of the 6Dg), one at once when moved to a raising or lowering position, then one each time its SpeedUp / SpeedDown // covers a step; 0 (the default) changes it continuously - double UniCtrlValStep{0.0}; + double const &UniCtrlValStep() const { return uniCtrlValStep; } /*-sekcja parametrow dla lokomotywy elektrycznej*/ TSchemeTable RList; /*lista rezystorow rozruchowych i polaczen silnikow, dla dizla: napelnienia*/ @@ -755,24 +755,24 @@ class Vehicle // Ratio: real; {NToothW/NToothM} // end; double NominalVoltage = 0.0; /*nominalne napiecie silnika*/ - double WindingRes = 0.0; + double const &WindingRes() const { return windingRes; } double u = 0.0; // wspolczynnik tarcia yB wywalic!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! double CircuitRes = 0.0; /*rezystancje silnika i obwodu*/ int IminLo = 0; int IminHi = 0; /*prady przelacznika automatycznego rozruchu, uzywane tez przez ai_driver*/ - int ImaxLo = 0; // maksymalny prad niskiego rozruchu - int ImaxHi = 0; // maksymalny prad wysokiego rozruchu - bool MotorOverloadRelayHighThreshold{false}; + int const &ImaxLo() const { return imaxLo; } // maksymalny prad niskiego rozruchu + int const &ImaxHi() const { return imaxHi; } // maksymalny prad wysokiego rozruchu + bool const &MotorOverloadRelayHighThreshold() const { return motorOverloadRelayHighThreshold; } double nmax = 0.0; /*maksymalna dop. ilosc obrotow /s*/ - double InitialCtrlDelay = 0.0; + double const &InitialCtrlDelay() const { return initialCtrlDelay; } double CtrlDelay = 0.0; /* -//- -//- miedzy kolejnymi poz.*/ double CtrlDownDelay = 0.0; /* -//- -//- przy schodzeniu z poz.*/ /*hunter-101012*/ int FastSerialCircuit = 0; /*0 - po kolei zamyka styczniki az do osiagniecia szeregowej, 1 - natychmiastowe wejscie na szeregowa*/ /*hunter-111012*/ int BackwardsBranchesAllowed = 1; - int AutoRelayType = 0; /*0 -brak, 1 - jest, 2 - opcja*/ + int const &AutoRelayType() const { return autoRelayType; } /*0 -brak, 1 - jest, 2 - opcja*/ // FieldShuntSwitch=Yes: the switch of AutoRelay=Optional of a diesel-electric is its switch of the field shunting, as the SU45's // and SP45's (fieldshunting.h): off, the field stays full. without it, off hands the shunting to the second controller, as before - bool FieldShuntSwitch = false; + bool const &FieldShuntSwitch() const { return fieldShuntSwitch; } bool CoupledCtrl = false; /*czy mainctrl i scndctrl sa sprzezone*/ bool HasCamshaft{false}; // the dynamic brake of a diesel-electric vehicle (Engine: EDBrake=...): the traction motors brake into resistors while @@ -891,7 +891,7 @@ class Vehicle void SetMirrorForbidden(bool const Value) { mirrorForbidden = Value; } bool ScndS = false; /*Czy jest bocznikowanie na szeregowej*/ bool ScndCtrlResistiveLock{false}; // the shunt controller can't be moved, up or down, while the master controller is at zero or on a resistive position, and drops to 0 when the master controller gets there (ScndCtrlResistiveLock=Yes in Cntrl.) - bool SpeedCtrl = false; /*czy jest tempomat*/ + bool const &SpeedCtrl() const { return speedCtrl; } /*czy jest tempomat*/ speed_control SpeedCtrlUnit; /*parametry tempomatu*/ double SpeedCtrlButtons[10]{30, 40, 50, 60, 70, 80, 90, 100, 110, 120}; /*przyciski prędkości*/ double SpeedCtrlDelay = 2; /*opoznienie dzialania tempomatu z wybieralna predkoscia*/ @@ -916,7 +916,9 @@ class Vehicle // the events of the step the sounds are to follow up (sound::), cleared once they did int SoundFlag() const { return soundFlag; } void ClearSoundFlags() { soundFlag = 0; } - int AIFlag{0}; // HACK: events of interest for consist owner + int const &AIFlag() const { return aiFlag; } // HACK: events of interest for consist owner + // the flag of an event the AI has seen to + void ClearAIFlag(int Flag); double const &DistCounter() const { return distCounter; } /*! licznik kilometrow */ void SetDistCounter(double const Value) { distCounter = Value; } // the criteria of derailment (physics.derailment new), and the distance travelled since they were checked [m] @@ -926,7 +928,7 @@ class Vehicle // physics.derailment monitor: the name of the track the criteria were last reported on (one report on a track), and // how many reports there were std::optional derailment_reported; - int derailment_reports = 0; + int const &derailment_reports() const { return derailmentreportsValue; } odometer::reading Odometer; // total distance run, kept between the sessions (eu07/maszyna#72) std::pair EnergyMeter; // energy from grid [kWh] double const &V() const { return travelSpeed; } // predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0) @@ -934,7 +936,7 @@ class Vehicle double Vel = 0.0; // moduł prędkości w [km/h], używany przez AI double const &AccS() const { return accS; } // efektywne przyspieszenie styczne w [m/s^2] (wszystkie siły) void SetAccS(double const Value) { accS = Value; } - double AccSVBased{}; // tangential acceleration calculated from velocity change + double const &AccSVBased() const { return accSVBased; } // tangential acceleration calculated from velocity change double const &AccN() const { return accN; } // przyspieszenie normalne w [m/s^2] void SetAccN(double const Value) { accN = Value; } double const &AccVert() const { return accVert; } // vertical acceleration @@ -946,7 +948,7 @@ class Vehicle accS += Acceleration; accN += Acceleration; } - double nrot = 0.0; // predkosc obrotowa kol (obrotow na sekunde) + double const &nrot() const { return nrotValue; } // predkosc obrotowa kol (obrotow na sekunde) double nrot_eps = 0.0; // przyspieszenie kątowe kół (bez kierunku) double const &WheelFlat() const { return wheelFlat; } void SetWheelFlat(double const Value) { wheelFlat = Value; } @@ -961,8 +963,8 @@ class Vehicle double FStand = 0.0; /*! sila pociagowa i oporow ruchu*/ double FTotal = 0.0; /*! calkowita sila dzialajaca na pojazd*/ double Ntotal = 0.0; /*!s siła nacisku klockow*/ - bool SlippingWheels = false; - bool SandDose = false; /*! poslizg kol, sypanie piasku*/ + bool const &SlippingWheels() const { return slippingWheels; } + bool const &SandDose() const { return sandDose; } /*! poslizg kol, sypanie piasku*/ bool SandDoseManual = false; /*piaskowanie reczne*/ bool SandDoseAuto = false; /*piaskowanie automatyczne*/ bool SandDoseAutoAllow = true; /*zezwolenie na automatyczne piaskowanie*/ @@ -977,11 +979,11 @@ class Vehicle bool GensetSelected() const { return TractionMode == traction_mode::genset; } water_pump WaterPump; water_heater WaterHeater; - bool WaterCircuitsLink{false}; // optional connection between water circuits + bool const &WaterCircuitsLink() const { return waterCircuitsLink; } // optional connection between water circuits ByEnd 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 - int DoorsPermitLightBlinking{0}; // when the doors permit signal light is blinking + int const &DoorsPermitLightBlinking() const { return doorsPermitLightBlinking; } // when the doors permit signal light is blinking /* */ @@ -1020,17 +1022,17 @@ class Vehicle void SetLightsPos(int const Value) { lightsPos = Value; } int DirActive = 0; // czy lok. jest wlaczona i w ktorym kierunku: względem wybranej kabiny: -1 - do tylu, +1 - do przodu, 0 - wylaczona int DirAbsolute = 0; // zadany kierunek jazdy względem sprzęgów (1=w strone 0,-1=w stronę 1) - int MainCtrlMaxDirChangePos{0}; // can't change reverser state with master controller set above this position + int const &MainCtrlMaxDirChangePos() const { return mainCtrlMaxDirChangePos; } // can't change reverser state with master controller set above this position int CabActive = 0; // numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad int const &CabOccupied() const { return cabOccupied; } // numer kabiny, w ktorej jest obsada (zwykle jedna na skład) // TODO: move to TController void SetCabOccupied(int const Value) { cabOccupied = Value; } - bool CabMaster = false; // czy pojazd jest nadrzędny w składzie + bool const &CabMaster() const { return cabMaster; } // czy pojazd jest nadrzędny w składzie // pullee mode ("jazda ciągniona", MaSzyna-EU07/maszyna#64): the vehicle is prepared for being hauled dead in a // train, see PulleeModeSwitch() - bool PulleeMode{false}; + bool const &PulleeMode() const { return pulleeMode; } inline bool IsCabMaster() const { - return CabActive == cabOccupied && CabMaster; + return CabActive == cabOccupied && cabMaster; } // czy aktualna kabina jest na pewno tą, z której można sterować bool AutomaticCabActivation = true; // czy zmostkowany rozrzad przelacza sie sam przy zmianie kabiny int InactiveCabFlag = 0; // co sie dzieje przy dezaktywacji kabiny @@ -1058,17 +1060,17 @@ class Vehicle double Mw = 0.0; // sily napedne double Fw = 0.0; - double Ft = 0.0; + double const &Ft() const { return ft; } // Ra: Im jest ujemny, jeśli lok jedzie w stronę sprzęgu 1 // a ujemne powinien być przy odwróconej polaryzacji sieci... // w wielu miejscach jest używane abs(Im) - int Imin = 0; + int const &Imin() const { return imin; } int Imax = 0; /*prad przelaczania automatycznego rozruchu, prad bezpiecznika*/ double EngineVoltage = 0.0; // voltage supplied to engine int MainCtrlActualPos = 0; /*wskaznik RList*/ int ScndCtrlActualPos = 0; /*wskaznik MotorParam*/ - bool DelayCtrlFlag = false; // czy czekanie na 1. pozycji na załączenie? - bool AutoRelayFlag = false; /*mozna zmieniac jesli AutoRelayType=2*/ + bool const &DelayCtrlFlag() const { return delayCtrlFlag; } // czy czekanie na 1. pozycji na załączenie? + bool const &AutoRelayFlag() const { return autoRelayFlag; } /*mozna zmieniac jesli autoRelayType=2*/ bool FuseFlag = false; /*!o bezpiecznik nadmiarowy*/ double LouvresOpenPressure{5.0}; // main reservoir pressure [bar] at which the pneumatic louvres of the motor fans open (ET22) bool ResistorsFlag = false; /*!o jazda rezystorowa*/ @@ -1084,15 +1086,15 @@ class Vehicle double eimic_step_progress{0.0}; // the part of the next UniCtrlValStep the controller has covered so far double eim_localbrake = 0; /*nastawa hamowania dodatkowego pneumatycznego lokomotywy*/ int EIMCtrlType = 0; /*rodzaj wariantu zadajnika jazdy*/ - bool SpeedCtrlTypeTime = false; /*czy tempomat sterowany czasowo*/ + bool const &SpeedCtrlTypeTime() const { return speedCtrlTypeTime; } /*czy tempomat sterowany czasowo*/ int SpeedCtrlAutoTurnOffFlag = 0; /*czy tempomat sam się wyłącza*/ bool EIMCtrlAdditionalZeros = false; /*czy ma dodatkowe zero jazdy i zero hamowania */ - bool EIMCtrlEmergency = false; /*czy ma dodatkowe zero jazdy i zero hamowania */ - bool EIMCtrlMainEmergency = false; /*czy zadajnik typu 2 (Elf) ma pozycje hamowania naglego ponizej swojej pozycji 0*/ + bool const &EIMCtrlEmergency() const { return eimCtrlEmergency; } /*czy ma dodatkowe zero jazdy i zero hamowania */ + bool const &EIMCtrlMainEmergency() const { return eimCtrlMainEmergency; } /*czy zadajnik typu 2 (Elf) ma pozycje hamowania naglego ponizej swojej pozycji 0*/ double SpeedCtrlTimer = 0; /*zegar dzialania tempomatu z wybieralna predkoscia*/ - double eimicSpeedCtrl = 1; /*pozycja sugerowana przez tempomat*/ + double const &eimicSpeedCtrl() const { return eimicSpeedCtrlValue; } /*pozycja sugerowana przez tempomat*/ double eimicSpeedCtrlIntegral = 0; /*calkowany blad ustawienia predkosci*/ - double NewSpeed = 0; /*nowa predkosc do zadania*/ + double const &NewSpeed() const { return newSpeed; } /*nowa predkosc do zadania*/ /*-zmienne dla drezyny*/ double PulseForce = 0.0; /*przylozona sila*/ @@ -1100,7 +1102,7 @@ class Vehicle int PulseForceCount = 0; /*dla drezyny, silnika spalinowego i parowego*/ - double eAngle = M_PI * 0.5; + double const &eAngle() const { return eAngleValue; } /*-dla wagonow*/ float const &LoadAmount() const { return loadAmount; } /*masa w T lub ilosc w sztukach - zaladowane*/ @@ -1137,7 +1139,7 @@ class Vehicle int DoubleTr = 1; // trakcja ukrotniona - przedni pojazd 'Winger 160304 basic_light CompartmentLights; - bool PhysicActivation = true; + bool const &PhysicActivation() const { return physicActivation; } // what the brake force (Fb) came from when the physics fell asleep (switch_physics()), for the test of ComputeTotalForce(): // asleep, a vehicle keeps the Fb and FStand of its last step, and a change of these wakes it struct @@ -1152,7 +1154,7 @@ class Vehicle double FrictConst1 = 0.0; double FrictConst2s = 0.0; double FrictConst2d = 0.0; - double TotalMassxg = 0.0; /*TotalMass*g*/ + double TotalMassxg = 0.0; /*totalMass*g*/ int iProblem = 0; // flagi problemów z taborem, aby AI nie musiało porównywać; 0=może jechać // the lights switched on at each end (light::), from which the current they draw is counted @@ -1181,7 +1183,7 @@ class Vehicle void SetDimmerPosition(int const Value) { modernDimmerPosition = Value; } int modernDimmerDefaultPosition{0}; // bool modernContainOffPos{true}; - bool enableModernDimmer{false}; + bool const &enableModernDimmer() const { return enableModernDimmerValue; } bool modernDimmerCanCycle{false}; // the given dimmer position brought into the DimmerList, to its first or last entry; 0 for an empty list int clampDimmerPosition(int Position) const; @@ -1204,12 +1206,12 @@ class Vehicle plc::basic_controller m_plc; - int AIHintPantstate{0}; // suggested pantograph setup + int const &AIHintPantstate() const { return aiHintPantstate; } // suggested pantograph setup // suggested pantograph setup in shunting (AI: ShuntPantstate=, eu07/maszyna#461), the bits as in Pantstate: 1 front, // 2 rear, 3 both; 0 (the default) shunts with the pantographs handled as in train mode - int AIHintShuntPantstate{0}; + int const &AIHintShuntPantstate() const { return aiHintShuntPantstate; } bool AIHintPantUpIfIdle{true}; // whether raise both pantographs if idling for a while - double AIHintLocalBrakeAccFactor{1.05}; // suggested acceleration weight for local brake operation + double const &AIHintLocalBrakeAccFactor() const { return aiHintLocalBrakeAccFactor; } // suggested acceleration weight for local brake operation Vehicle(double VelInitial, std::string const &TypeNameInit, std::string const &NameInit, int Cab); // obsługa sprzęgów @@ -1260,9 +1262,9 @@ class Vehicle // what derailed it, the lateral acceleration of its body out of the curve then [m/s2] (negative into the curve, where a // buckle bends the line the other way), and the side it was pulled off to by a coupling (1 the left of its front, -1 // the right; 0 the side the acceleration throws it to, from the track) - derail_motion::cause DerailCause{derail_motion::cause::off_rails}; - double DerailAcceleration{0.0}; - int DerailSide{0}; + derail_motion::cause const &DerailCause() const { return derailCause; } + double const &DerailAcceleration() const { return derailAcceleration; } + int const &DerailSide() const { return derailSide; } // the vehicle off the track, on the ground: begun and stepped by TDynamicObject, which knows the ground; its friction // and the grade under it go into the forces of this one derail_motion::body OffTrack; @@ -1279,9 +1281,9 @@ class Vehicle double buffer_height_at(VehicleEnd End) const; collision::pushed_monitor pushed_off_monitor; // how the vehicle left the rails in a collision (physics.collisions new): overriding or pushed off, NONE otherwise - DerailReason CollisionDerail{NONE}; + DerailReason const &CollisionDerail() const { return collisionDerail; } // physics.collisions monitor: how many crushes the log told of, of the hits of this vehicle on the others - int crush_reports{0}; + int const &crush_reports() const { return crushreportsValue; } // physics.collisions new: the hit of the end on the stop of its buffers, harder than the steel takes, crushes the // weaker end and may let one vehicle climb onto the other one, see collision.h. returns: whether it did, and the // velocities took the hit; the legacy collision takes the rest. physics.collisions monitor: the log tells what the @@ -1860,6 +1862,60 @@ class Vehicle std::optional LightsPresetCabLight(int Position) const; private: + // what the vehicle works out or is defined with, which the rest of the simulator only reads + double vmax = -1.0; + train_type trainType{train_type::generic}; + double totalMass = 0.0; + double ft = 0.0; + int scndCtrlPosNo = 0; + bool slippingWheels = false; + int nAxles = 0; + bool speedCtrl = false; + double nrotValue = 0.0; + double aDist = 0.0; + bool sandDose = false; + float wheelDiameter = 1.f; + DerailReason collisionDerail{NONE}; + bool autoRelayFlag = false; + double bDist = 0.0; + bool physicActivation = true; + bool waterCircuitsLink{false}; + bool enableModernDimmerValue{false}; + double mred = 0.0; + bool delayCtrlFlag = false; + int crushreportsValue{0}; + bool epFuse = true; + int imaxHi = 0; + double initialCtrlDelay = 0.0; + double accSVBased{}; + derail_motion::cause derailCause{derail_motion::cause::off_rails}; + int nPoweredAxles = 0; + bool motorOverloadRelayHighThreshold{false}; + int doorsPermitLightBlinking{0}; + int mainCtrlMaxDirChangePos{0}; + double derailAcceleration{0.0}; + int derailmentreportsValue = 0; + bool cabMaster = false; + bool pulleeMode{false}; + int imin = 0; + bool speedCtrlTypeTime = false; + bool eimCtrlEmergency = false; + double eimicSpeedCtrlValue = 1; + double newSpeed = 0; + int aiHintPantstate{0}; + double uniCtrlValStep{0.0}; + int imaxLo = 0; + int autoRelayType = 0; + bool fieldShuntSwitch = false; + int aiFlag{0}; + bool eimCtrlMainEmergency = false; + double eAngleValue = M_PI * 0.5; + int aiHintShuntPantstate{0}; + double aiHintLocalBrakeAccFactor{1.05}; + int derailSide{0}; + horn_supply hornSupply{horn_supply::air}; + bool uniCtrlIntegratedLocalBrakeCtrl = false; + double windingRes = 0.0; // the switches and the controllers the cab, the AI and the scenery change only through the operations above double travelSpeed = 0.0; TLocation location{0.0, 0.0, 0.0}; diff --git a/simulation/blackboxrecorder.cpp b/simulation/blackboxrecorder.cpp index 48749f3ff..2178bcb22 100644 --- a/simulation/blackboxrecorder.cpp +++ b/simulation/blackboxrecorder.cpp @@ -76,7 +76,7 @@ std::uint32_t devices_of(physics::Vehicle const &Occupied, physics::Vehicle cons return on(Occupied.lowVoltage.IsBatteryOn() || Controlling.lowVoltage.IsBatteryOn(), device::battery) | on(Controlling.lineBreaker.IsClosed(), device::main_breaker) | on(Controlling.pantographs[VehicleEnd::front].is_active, device::pantograph_front) | on(Controlling.pantographs[VehicleEnd::rear].is_active, device::pantograph_rear) | on(Controlling.converter.IsRunning(), device::converter) | on(Controlling.air.compressor.IsRunning(), device::compressor) | on(Controlling.lineContactors.IsClosed(), device::line_contactors) | - on(Controlling.FuseFlag, device::overload_relay) | on(Controlling.SandDose, device::sanding) | on(Occupied.WarningSignal() != 0, device::horn) | + on(Controlling.FuseFlag, device::overload_relay) | on(Controlling.SandDose(), device::sanding) | on(Occupied.WarningSignal() != 0, device::horn) | on(false == Occupied.Doors.instances[VehicleSide::left].is_closed, device::doors_left) | on(false == Occupied.Doors.instances[VehicleSide::right].is_closed, device::doors_right) | on(Occupied.Radio(), device::radio) | on(Controlling.trainHeating.IsOn(), device::heating) | on(Occupied.brakes.spring.isActive, device::spring_brake) | on(Controlling.ShuntMode, device::shunt_mode) | @@ -87,7 +87,7 @@ std::uint32_t devices_of(physics::Vehicle const &Occupied, physics::Vehicle cons on(Occupied.brakes.distributor != nullptr && Occupied.brakes.distributor->Releaser(), device::brake_releaser) | on(Controlling.FuelPump.is_active, device::fuel_pump) | on(Controlling.OilPump.is_active, device::oil_pump) | on(Controlling.MotorBlowers[VehicleEnd::front].is_active || Controlling.MotorBlowers[VehicleEnd::rear].is_active, device::motor_blowers) | - on(Controlling.diesel.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(physics::Vehicle const &Physics) { @@ -431,7 +431,7 @@ void blackbox_recorder::write_cab() { // the vehicle itself, if none in the unit is powered auto const *powered{train->Dynamic()->FindPowered()}; auto const facing{powered->DirectionGet() * vehicle->DirectionGet()}; - sample.wheel_speed_kmh = static_cast(facing * M_PI * powered->physics->WheelDiameter * powered->physics->nrot * 3.6); + sample.wheel_speed_kmh = static_cast(facing * M_PI * powered->physics->WheelDiameter() * powered->physics->nrot() * 3.6); sample.acceleration = static_cast(controlling->AccS()); sample.lateral_acceleration = static_cast(occupied->AccN()); if (owner != nullptr && owner->is_train()) { @@ -445,7 +445,7 @@ void blackbox_recorder::write_cab() { sample.driving = driver_of(*vehicle); sample.flags = (FreeFlyModeFlag ? 0 : blackbox::cab_flags::in_cab) | (owner != nullptr && owner->is_active() ? blackbox::cab_flags::ai_valid : 0) | (controlling->SecuritySystem.is_blinking() ? blackbox::cab_flags::alerter_blinking : 0) | - (controlling->SecuritySystem.is_beeping() ? blackbox::cab_flags::alerter_beeping : 0) | (controlling->SlippingWheels ? blackbox::cab_flags::wheel_slip : 0) | + (controlling->SecuritySystem.is_beeping() ? blackbox::cab_flags::alerter_beeping : 0) | (controlling->SlippingWheels() ? blackbox::cab_flags::wheel_slip : 0) | (occupied->RadioStopFlag() ? blackbox::cab_flags::radio_stop : 0) | (occupied->brakes.alarmChain ? blackbox::cab_flags::alarm_chain : 0); sample.main_controller = static_cast(controlling->MainCtrlPos()); sample.scnd_controller = static_cast(controlling->ScndCtrlPos()); @@ -483,7 +483,7 @@ void blackbox_recorder::write_cab() { 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.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->brakes.HandBrakePosition(), -128, 127)); sample.brake_mode = static_cast(occupied->brakes.operatingMode); diff --git a/tests/unit/drive.cpp b/tests/unit/drive.cpp index 339b85e00..524a9e39a 100644 --- a/tests/unit/drive.cpp +++ b/tests/unit/drive.cpp @@ -108,7 +108,7 @@ void prepare_diesel(driven const &Driven) { // the pantographs' own air topped up by their compressor, and the pantographs raised void raise_pantographs(driven const &Driven) { auto &pantographs{Driven.pantographs}; - if (auto const enough{(pantographs.TrainType == train_type::emu ? 2.5 : 3.5) + 0.1}; pantographs.pantographAir.Pressure() < enough) { + if (auto const enough{(pantographs.TrainType() == train_type::emu ? 2.5 : 3.5) + 0.1}; pantographs.pantographAir.Pressure() < enough) { if (false == pantographs.pantographAir.config.autoValve) { pantographs.pantographAir.ConnectToMainReservoir(false); // the pantographs on their own air } @@ -149,7 +149,7 @@ void switch_auxiliaries_on(physics::Vehicle &Cab) { Cab.MotorBlowersSwitch(true, side); } } - if (Cab.EngineType == TEngineType::DieselElectric && fieldshunting::has_switch(Cab.AutoRelayType, Cab.FieldShuntSwitch)) { + if (Cab.EngineType == TEngineType::DieselElectric && fieldshunting::has_switch(Cab.AutoRelayType(), Cab.FieldShuntSwitch())) { Cab.AutoRelaySwitch(true); } } diff --git a/tests/unit/figures.cpp b/tests/unit/figures.cpp index ce086154c..bb3483dff 100644 --- a/tests/unit/figures.cpp +++ b/tests/unit/figures.cpp @@ -88,7 +88,7 @@ void figures::sample(double Time, physics::Vehicle const &Vehicle) { } part.cylinders_peak = std::max(part.cylinders_peak, Vehicle.brakes.cylinderPressure); part.current_peak = std::max(part.current_peak, std::abs(Vehicle.Im)); - part.force_peak = std::max(part.force_peak, std::abs(Vehicle.Ft) / 1000.0); + part.force_peak = std::max(part.force_peak, std::abs(Vehicle.Ft()) / 1000.0); m_last_time = Time; m_last_speed = speed; @@ -98,7 +98,7 @@ void figures::sample(double Time, physics::Vehicle const &Vehicle) { m_piped |= pipe >= 0.1; m_braked |= Vehicle.brakes.cylinderPressure >= 0.005; m_current |= std::abs(Vehicle.Im) >= 0.5; - m_force |= std::abs(Vehicle.Ft) >= 50.0; + m_force |= std::abs(Vehicle.Ft()) >= 50.0; } void figures::mark(std::string const &Event) { diff --git a/tests/unit/golden.cpp b/tests/unit/golden.cpp index 429349288..1210a7354 100644 --- a/tests/unit/golden.cpp +++ b/tests/unit/golden.cpp @@ -45,11 +45,11 @@ std::vector motion() { {"V", [](auto const &M) { return M.V(); }}, {"DistCounter", [](auto const &M) { return M.DistCounter(); }}, {"AccS", [](auto const &M) { return M.AccS(); }}, - {"nrot", [](auto const &M) { return M.nrot; }}, - {"Ft", [](auto const &M) { return M.Ft; }}, + {"nrot", [](auto const &M) { return M.nrot(); }}, + {"Ft", [](auto const &M) { return M.Ft(); }}, {"Fb", [](auto const &M) { return M.Fb; }}, {"FStand", [](auto const &M) { return M.FStand; }}, - {"SlippingWheels", [](auto const &M) { return M.SlippingWheels ? 1.0 : 0.0; }}, + {"SlippingWheels", [](auto const &M) { return M.SlippingWheels() ? 1.0 : 0.0; }}, }; } @@ -126,25 +126,25 @@ std::vector doors() { std::vector parameters() { std::vector result{ {"CategoryFlag", [](auto const &M) { return M.CategoryFlag; }}, - {"TrainType", [](auto const &M) { return legacy_code(M.TrainType); }}, + {"TrainType", [](auto const &M) { return legacy_code(M.TrainType()); }}, {"EngineType", [](auto const &M) { return static_cast(M.EngineType); }}, - {"Vmax", [](auto const &M) { return M.Vmax; }}, + {"Vmax", [](auto const &M) { return M.Vmax(); }}, {"Mass", [](auto const &M) { return M.Mass; }}, - {"TotalMass", [](auto const &M) { return M.TotalMass; }}, - {"Mred", [](auto const &M) { return M.Mred; }}, + {"TotalMass", [](auto const &M) { return M.TotalMass(); }}, + {"Mred", [](auto const &M) { return M.Mred(); }}, {"Power", [](auto const &M) { return M.Power; }}, {"HeatingPower", [](auto const &M) { return M.trainHeating.config.power; }}, {"LightPower", [](auto const &M) { return M.LightPower; }}, {"BatteryVoltage", [](auto const &M) { return M.lowVoltage.BatteryVoltage(); }}, {"Cx", [](auto const &M) { return M.Cx; }}, - {"WheelDiameter", [](auto const &M) { return M.WheelDiameter; }}, + {"WheelDiameter", [](auto const &M) { return M.WheelDiameter(); }}, {"TrackW", [](auto const &M) { return M.TrackW; }}, {"AxleInertialMoment", [](auto const &M) { return M.AxleInertialMoment; }}, - {"NPoweredAxles", [](auto const &M) { return M.NPoweredAxles; }}, - {"NAxles", [](auto const &M) { return M.NAxles; }}, + {"NPoweredAxles", [](auto const &M) { return M.NPoweredAxles(); }}, + {"NAxles", [](auto const &M) { return M.NAxles(); }}, {"BearingType", [](auto const &M) { return M.BearingType; }}, - {"ADist", [](auto const &M) { return M.ADist; }}, - {"BDist", [](auto const &M) { return M.BDist; }}, + {"ADist", [](auto const &M) { return M.ADist(); }}, + {"BDist", [](auto const &M) { return M.BDist(); }}, {"NBpA", [](auto const &M) { return M.brakes.config.blocksPerAxle; }}, {"SandCapacity", [](auto const &M) { return M.SandCapacity; }}, {"BrakeSystem", [](auto const &M) { return static_cast(M.brakes.config.kind); }}, @@ -179,13 +179,13 @@ std::vector parameters() { {"AirLeakRate", [](auto const &M) { return M.air.config.leakRate; }}, {"BrakeCtrlPosNo", [](auto const &M) { return M.brakes.config.handlePositions; }}, {"MainCtrlPosNo", [](auto const &M) { return M.MainCtrlPosNo; }}, - {"ScndCtrlPosNo", [](auto const &M) { return M.ScndCtrlPosNo; }}, + {"ScndCtrlPosNo", [](auto const &M) { return M.ScndCtrlPosNo(); }}, {"LightsPosNo", [](auto const &M) { return M.LightsPosNo; }}, {"MBrake", [](auto const &M) { return M.brakes.config.hasHandBrake ? 1.0 : 0.0; }}, {"StopBrakeDecc", [](auto const &M) { return M.brakes.holding.deceleration; }}, {"BrakeDelays", [](auto const &M) { return M.brakes.config.availableDelays; }}, {"BrakeOpModes", [](auto const &M) { return M.brakes.config.availableOperatingModes; }}, - {"Imin", [](auto const &M) { return M.Imin; }}, + {"Imin", [](auto const &M) { return M.Imin(); }}, {"Imax", [](auto const &M) { return M.Imax; }}, {"EIMCtrlType", [](auto const &M) { return M.EIMCtrlType; }}, {"Volume", [](auto const &M) { return M.brakes.reservoirAir; }}, diff --git a/tests/unit/invariants.cpp b/tests/unit/invariants.cpp index 39c7049d2..5075299a9 100644 --- a/tests/unit/invariants.cpp +++ b/tests/unit/invariants.cpp @@ -41,12 +41,12 @@ std::vector const &invariants() { static std::vector const rules{ {"every value a number", [](auto const &M, double, auto const *) { - std::initializer_list const values{M.V(), M.AccS(), M.Ft, M.Fb, M.Im, M.Itot, M.EngineVoltage, + std::initializer_list const values{M.V(), M.AccS(), M.Ft(), M.Fb, M.Im, M.Itot, M.EngineVoltage, M.enrot, M.brakePipe.Pressure(), M.brakes.cylinderPressure, M.brakes.independentCylinderPressure, M.mainPipe.Pressure(), M.air.MainReservoirPressure(), M.lowVoltage.BatteryVoltage()}; return std::ranges::all_of(values, [](double const Value) { return std::isfinite(Value); }); }, [](auto const &M) { - return values({{"V", M.V()}, {"AccS", M.AccS()}, {"Ft", M.Ft}, {"Fb", M.Fb}, {"Im", M.Im}, {"Itot", M.Itot}, {"EngineVoltage", M.EngineVoltage}, + return values({{"V", M.V()}, {"AccS", M.AccS()}, {"Ft", M.Ft()}, {"Fb", M.Fb}, {"Im", M.Im}, {"Itot", M.Itot}, {"EngineVoltage", M.EngineVoltage}, {"enrot", M.enrot}, {"PipePress", M.brakePipe.Pressure()}, {"BrakePress", M.brakes.cylinderPressure}, {"LocBrakePress", M.brakes.independentCylinderPressure}, {"ScndPipePress", M.mainPipe.Pressure()}, {"Compressor", M.air.MainReservoirPressure()}, {"BatteryVoltage", M.lowVoltage.BatteryVoltage()}}); }}, @@ -81,8 +81,8 @@ std::vector const &invariants() { return values({{"StLinFlag", M.lineContactors.IsClosed()}, {"DynamicBrakeFlag", M.brakes.electrodynamic.on}, {"Im", M.Im}, {"MainCtrlActualPos", M.MainCtrlActualPos}}); }}, {"no tractive force without power", - [](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}}); }}, + [](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.diesel.fill >= 0.0 && M.diesel.fill <= 1.0; }, [](auto const &M) { return values({{"dizel_fill", M.diesel.fill}}); }}, diff --git a/tests/unit/test_6dg_power_steps.cpp b/tests/unit/test_6dg_power_steps.cpp index c2ca18274..5f3d8ce4e 100644 --- a/tests/unit/test_6dg_power_steps.cpp +++ b/tests/unit/test_6dg_power_steps.cpp @@ -100,7 +100,7 @@ TEST_CASE("6Dg: the shipped definition sets the controller's power demand in ste vehicle loco{shipped(), 0.0, "test", 1}; // the key as the game data has it, on the controller it acts on REQUIRE(loco->EIMCtrlType == 3); - CHECK(loco->UniCtrlValStep == doctest::Approx(0.05)); + CHECK(loco->UniCtrlValStep() == doctest::Approx(0.05)); // the ends of the table: raising goes up to 1, lowering down to 0, 20 steps of 0.05 between them auto const top{loco->UniCtrlList[raise].SetCtrlVal}; auto const bottom{loco->UniCtrlList[lower].SetCtrlVal}; @@ -180,7 +180,7 @@ TEST_CASE("6Dg: the diesel-electric drive follows the stepped demand") { REQUIRE(loco->eimic == doctest::Approx(0.05 * taps)); REQUIRE(loco->eimic_real == doctest::Approx(0.05 * taps)); test::drive(test::driving(loco), line, 10.0); - readings.emplace_back(loco->eimic_real, loco->enrot, std::abs(loco->Ft), loco->EnginePower, std::abs(loco.speed())); + readings.emplace_back(loco->eimic_real, loco->enrot, std::abs(loco->Ft()), loco->EnginePower, std::abs(loco.speed())); } // at 0.25, 0.5, 0.75 and 1: the engine at 897, 1198, 1499 and (still running up to) 1800 rpm as the WWList table // gives, about 28, 37, 48 and 59 kN, 87, 261, 445 and 663 kW, 14, 24, 28 and 30 km/h @@ -200,7 +200,7 @@ TEST_CASE("6Dg: the diesel-electric drive follows the stepped demand") { TEST_CASE("6Dg: without CtrlValStep the demand moves continuously between the rows of the table, as before") { test::track const line{0.15, 0.0}; vehicle loco{shipped().remove("UCList", "CtrlValStep"), 0.0, "test", 1}; - REQUIRE(loco->UniCtrlValStep == 0.0); + REQUIRE(loco->UniCtrlValStep() == 0.0); get_ready(loco, line); // a tap moves it by 0.01 only tap(loco, raise, line); diff --git a/tests/unit/test_ai_hints.cpp b/tests/unit/test_ai_hints.cpp index d01e421c9..e23a9bf36 100644 --- a/tests/unit/test_ai_hints.cpp +++ b/tests/unit/test_ai_hints.cpp @@ -10,8 +10,8 @@ using test::vehicle; TEST_CASE("ai hints: without the AI section the pantographs follow the built-in logic") { vehicle wagon{definition::load("wagon")}; - CHECK(wagon->AIHintPantstate == 0); - CHECK(wagon->AIHintShuntPantstate == 0); + CHECK(wagon->AIHintPantstate() == 0); + CHECK(wagon->AIHintShuntPantstate() == 0); CHECK(wagon->AIHintPantUpIfIdle); } @@ -19,13 +19,13 @@ TEST_CASE("ai hints: the suggested pantograph setup for shunting is read apart f // eu07/maszyna#461: so the ET41 doesn't shunt with all of its four pantographs up vehicle shunting{definition::load("wagon").set("AI", "Pantstate", 1).set("AI", "ShuntPantstate", 2)}; - CHECK(shunting->AIHintPantstate == 1); - CHECK(shunting->AIHintShuntPantstate == 2); + CHECK(shunting->AIHintPantstate() == 1); + CHECK(shunting->AIHintShuntPantstate() == 2); } TEST_CASE("ai hints: a .fiz with the setup for train mode only has none for shunting") { vehicle train{definition::load("wagon").set("AI", "Pantstate", 3)}; - CHECK(train->AIHintPantstate == 3); - CHECK(train->AIHintShuntPantstate == 0); + CHECK(train->AIHintPantstate() == 3); + CHECK(train->AIHintShuntPantstate() == 0); } diff --git a/tests/unit/test_brakes.cpp b/tests/unit/test_brakes.cpp index e83c25334..d4dae6f50 100644 --- a/tests/unit/test_brakes.cpp +++ b/tests/unit/test_brakes.cpp @@ -167,14 +167,14 @@ TEST_CASE("brakes: a wagon standing braked on a gradient sleeps while the brakes wagon.run(30.0, slope); REQUIRE(wagon->brakes.cylinderPressure > 1.0); CHECK(std::abs(wagon.speed()) < 0.01); - CHECK_FALSE(wagon->PhysicActivation); + CHECK_FALSE(wagon->PhysicActivation()); // the brakes holding as they are, it sleeps on auto wakes{0}; for (int step = 0; step < 12000; ++step) { - auto const asleep{false == wagon->PhysicActivation}; + auto const asleep{false == wagon->PhysicActivation()}; wagon.step(slope); - if (asleep && wagon->PhysicActivation) { + if (asleep && wagon->PhysicActivation()) { ++wakes; } } @@ -187,7 +187,7 @@ TEST_CASE("brakes: a wagon standing braked on a gradient sleeps while the brakes CHECK(wagon->brakes.cylinderPressure < 0.1); CHECK(wagon->Fb < 1.0); CHECK(std::abs(wagon.speed()) > 1.0); - CHECK(wagon->PhysicActivation); + CHECK(wagon->PhysicActivation()); } TEST_CASE("brakes: a wagon held by its hand brake on a gradient wakes and rolls away once the hand brake is released") { @@ -202,7 +202,7 @@ TEST_CASE("brakes: a wagon held by its hand brake on a gradient wakes and rolls wagon.run(90.0, slope); REQUIRE(wagon->brakes.cylinderPressure < 0.1); CHECK(std::abs(wagon.speed()) < 0.01); - CHECK_FALSE(wagon->PhysicActivation); + CHECK_FALSE(wagon->PhysicActivation()); wagon->DecManualBrakeLevel(ManualBrakePosNo); wagon.run(30.0, slope); diff --git a/tests/unit/test_cab.cpp b/tests/unit/test_cab.cpp index b87c1576e..5cf01117f 100644 --- a/tests/unit/test_cab.cpp +++ b/tests/unit/test_cab.cpp @@ -74,7 +74,7 @@ TEST_CASE("cab: the engine's idle speed, and the ET42's second controller shown CHECK(et42->GetVirtualScndPos() == 1); // with a speed control in place of the second controller, either end of it, for the AI vehicle railbus{definition::fiz("21xm_v1/214ma")}; - REQUIRE(railbus->SpeedCtrl); + REQUIRE(railbus->SpeedCtrl()); railbus->SetScndCtrlPos(1); CHECK(railbus->IsScndCtrlNoPowerPos()); CHECK(railbus->IsScndCtrlMaxPowerPos()); @@ -167,11 +167,11 @@ TEST_CASE("cab: damaged motors cut off in a car without a driver") { driven->DamageFlag |= VehicleDamage::engine; CHECK_FALSE(driven->CutOffEngine()); vehicle car{definition::fiz("ew58_v1/ew58-sa")}; - auto const axles{car->NPoweredAxles}; + auto const axles{car->NPoweredAxles()}; CHECK_FALSE(car->CutOffEngine()); car->DamageFlag |= VehicleDamage::engine; CHECK(car->CutOffEngine()); - CHECK(car->NPoweredAxles == axles / 2); + CHECK(car->NPoweredAxles() == axles / 2); CHECK_FALSE(car->DamageFlag.HasAll(VehicleDamage::engine)); vehicle wagon{definition::fiz("3wl_v2/3wl")}; wagon->DamageFlag |= VehicleDamage::engine; diff --git a/tests/unit/test_cntrl.cpp b/tests/unit/test_cntrl.cpp index 017bc0ee6..428381092 100644 --- a/tests/unit/test_cntrl.cpp +++ b/tests/unit/test_cntrl.cpp @@ -22,7 +22,7 @@ TEST_CASE("cntrl: the brake delays of the settings come from BDelay1 to BDelay4" TEST_CASE("cntrl: the relays of a multiple unit start on their own, of other vehicles by hand") { SUBCASE("multiple unit") { vehicle unit{definition::load("wagon").set("Param", "Type", "ezt")}; - REQUIRE(unit->TrainType == train_type::emu); + REQUIRE(unit->TrainType() == train_type::emu); CHECK(unit->protection.config.groundStart == start_t::automatic); CHECK(unit->converter.config.overloadRelayStart == start_t::converter); // activates when the converter is switched off } @@ -64,7 +64,7 @@ TEST_CASE("cntrl: ScndCtrlResistiveLock keeps the field shunting off at zero and CAPTURE(path); vehicle locked{definition::fiz(path).set("Cntrl", "ScndCtrlResistiveLock", "Yes"), 0.0, "test", 1}; REQUIRE(locked->ScndCtrlResistiveLock); - REQUIRE(locked->ScndCtrlPosNo > 0); + REQUIRE(locked->ScndCtrlPosNo() > 0); auto const resistancefree{resistance_free_position(locked.physics())}; REQUIRE(resistancefree > 1); if (resistancefree <= 1) { @@ -117,7 +117,7 @@ TEST_CASE("cntrl: ScndCtrlResistiveLock keeps the field shunting off at zero and SUBCASE("the master controller taken back from a shunt step drops the shunt") { controllers_at(locked, resistancefree); REQUIRE(locked->IncScndCtrl(1)); - if (locked->TrainType == train_type::et22) { + if (locked->TrainType() == train_type::et22) { // the ET22's master controller doesn't turn with the shunt on: the shunt goes off first, as before CHECK_FALSE(locked->DecMainCtrl(1)); CHECK(locked->MainCtrlPos() == resistancefree); @@ -152,7 +152,7 @@ TEST_CASE("cntrl: ScndCtrlResistiveLock keeps the field shunting off at zero and controllers_at(locked, lastseries); locked->DirActive = 1; REQUIRE(locked->IncScndCtrl(1)); - if (locked->TrainType == train_type::et22) { + if (locked->TrainType() == train_type::et22) { CHECK_FALSE(locked->IncMainCtrl(1)); // the ET22's interlock, as before CHECK(locked->ScndCtrlPos() == 1); } diff --git a/tests/unit/test_collisions.cpp b/tests/unit/test_collisions.cpp index eadd5732f..f4222beac 100644 --- a/tests/unit/test_collisions.cpp +++ b/tests/unit/test_collisions.cpp @@ -180,10 +180,10 @@ crash_outcome freight_crash(double const Speed, double const Radius, double cons result.crush = std::max(result.crush, crush_of(vehicle)); if (derailed(vehicle)) { ++result.derailed; - result.overridden += vehicle.CollisionDerail == COLLISION_OVERRIDE; - result.pushed += vehicle.CollisionDerail == COLLISION_PUSHED_OFF; + result.overridden += vehicle.CollisionDerail() == COLLISION_OVERRIDE; + result.pushed += vehicle.CollisionDerail() == COLLISION_PUSHED_OFF; result.locomotive = result.locomotive || i == standing; - result.list += std::format("{} ({:.1f} t) {}; ", name, vehicle.TotalMass / 1000.0, vehicle.CollisionDerail == COLLISION_OVERRIDE ? "overrode" : "pushed off"); + result.list += std::format("{} ({:.1f} t) {}; ", name, vehicle.TotalMass() / 1000.0, vehicle.CollisionDerail() == COLLISION_OVERRIDE ? "overrode" : "pushed off"); } else if (crush_of(vehicle) >= cl::crush_mark) { result.list += std::format("{} crushed {:.2f} m; ", name, crush_of(vehicle)); @@ -219,7 +219,7 @@ double capacity_of(physics::Vehicle const &First, VehicleEnd const FirstEnd, phy // the kinetic energy of the relative motion of two vehicles closing in at the velocity [J] double relative_energy(physics::Vehicle const &First, physics::Vehicle const &Second, double const Velocity) { - auto const mass{First.TotalMass * Second.TotalMass / (First.TotalMass + Second.TotalMass)}; + auto const mass{First.TotalMass() * Second.TotalMass() / (First.TotalMass() + Second.TotalMass())}; return 0.5 * mass * Velocity * Velocity; } @@ -253,11 +253,11 @@ definition coach(double const Mass) { // Y / Q of the leading wheel of the vehicle at the end pressed in by its coupling, as check_pushed_off() takes it double pushed_ratio_of(physics::Vehicle const &Vehicle, VehicleEnd const End, double const OtherLength, double const Radius) { cl::pushed_vehicle pushed; - pushed.mass = Vehicle.TotalMass - Vehicle.Mred; - pushed.axles = Vehicle.NAxles > 0 ? Vehicle.NAxles : 4; + pushed.mass = Vehicle.TotalMass() - Vehicle.Mred(); + pushed.axles = Vehicle.NAxles() > 0 ? Vehicle.NAxles() : 4; pushed.length = Vehicle.Dim.L; - pushed.pivots = Vehicle.BDist; - pushed.axle_base = Vehicle.ADist > 0.0 ? Vehicle.ADist : Vehicle.BDist; + pushed.pivots = Vehicle.BDist(); + pushed.axle_base = Vehicle.ADist() > 0.0 ? Vehicle.ADist() : Vehicle.BDist(); cl::pushed_end end; end.force = std::max(0.0, (End == VehicleEnd::front ? -1.0 : 1.0) * Vehicle.Couplers[End].CForce); end.other_length = OtherLength; @@ -473,11 +473,11 @@ TEST_CASE("collisions: an empty two-axle wagon between loaded ones in a curve of vehicle empty{definition::fiz("3wl_v2/3wl")}; vehicle loaded{definition::fiz("430w_v2/430w")}; cl::pushed_vehicle wagon; - wagon.mass = empty->TotalMass - empty->Mred; - wagon.axles = empty->NAxles; + wagon.mass = empty->TotalMass() - empty->Mred(); + wagon.axles = empty->NAxles(); wagon.length = empty->Dim.L; - wagon.pivots = empty->BDist; - wagon.axle_base = empty->ADist > 0.0 ? empty->ADist : empty->BDist; + wagon.pivots = empty->BDist(); + wagon.axle_base = empty->ADist() > 0.0 ? empty->ADist() : empty->BDist(); REQUIRE(wagon.axles == 2); cl::pushed_end end; end.other_length = loaded->Dim.L; @@ -502,11 +502,11 @@ TEST_CASE("collisions: an empty two-axle wagon between loaded ones in a curve of // the loaded wagon, four axles, takes it cl::pushed_vehicle heavy; - heavy.mass = loaded->TotalMass - loaded->Mred + 59.5e3; - heavy.axles = loaded->NAxles; + heavy.mass = loaded->TotalMass() - loaded->Mred() + 59.5e3; + heavy.axles = loaded->NAxles(); heavy.length = loaded->Dim.L; - heavy.pivots = loaded->BDist; - heavy.axle_base = loaded->ADist; + heavy.pivots = loaded->BDist(); + heavy.axle_base = loaded->ADist(); end.force = 600.0e3; CHECK(cl::pushed_ratio(heavy, end, 150.0) < 0.5); @@ -613,7 +613,7 @@ TEST_CASE("collisions: a locomotive at its starting effort against a braked trai REQUIRE(worst >= derailment::climbing_limit); CHECK(rolled < 0.5); CHECK_FALSE(derailed(empty.physics())); - CHECK(empty->CollisionDerail == NONE); + CHECK(empty->CollisionDerail() == NONE); } TEST_CASE("collisions: a locomotive running onto an empty wagon at 9 km/h doesn't push it off with the peak of the springs") { @@ -668,9 +668,9 @@ TEST_CASE("collisions: a train propelling an empty wagon into a braked one in a } auto const start{empty->DistCounter()}; train.run(10.0, curve); - MESSAGE(std::format("the empty 3WL: derailed {}, {}, rolled {:.2f} m", derailed(empty.physics()), empty->CollisionDerail == COLLISION_PUSHED_OFF ? "pushed off" : "not pushed off", + MESSAGE(std::format("the empty 3WL: derailed {}, {}, rolled {:.2f} m", derailed(empty.physics()), empty->CollisionDerail() == COLLISION_PUSHED_OFF ? "pushed off" : "not pushed off", (empty->DistCounter() - start) * 1000.0)); - CHECK(empty->CollisionDerail == COLLISION_PUSHED_OFF); + CHECK(empty->CollisionDerail() == COLLISION_PUSHED_OFF); } // ---- recovery @@ -691,7 +691,7 @@ TEST_CASE("collisions: a repaired vehicle has its ends rebuilt and is back on th physics.repair_damage(); CHECK(physics.DamageFlag.Empty()); CHECK(physics.Derailed == derailment::outcome::none); - CHECK(physics.CollisionDerail == NONE); + CHECK(physics.CollisionDerail() == NONE); CHECK(physics.pushed_off_monitor.distance() == 0.0); CHECK(physics.pushed_off_monitor.time() == 0.0); for (auto const &coupler : physics.Couplers) { @@ -723,10 +723,10 @@ TEST_CASE("collisions: the repair of a coupler torn off by the crush rebuilds it TEST_CASE("collisions: SetDamage taking the derailment off clears the collision's") { vehicle wagon{definition::fiz("3wl_v2/3wl")}; wagon->derail_in_collision(COLLISION_PUSHED_OFF, "test"); - REQUIRE(wagon->CollisionDerail == COLLISION_PUSHED_OFF); + REQUIRE(wagon->CollisionDerail() == COLLISION_PUSHED_OFF); REQUIRE(wagon->Derailed == derailment::outcome::off_rails); wagon->RunCommand(VehicleCommand::setDamage, DamageSet{VehicleDamage::derailed}.Bits(), -1); - CHECK(wagon->CollisionDerail == NONE); + CHECK(wagon->CollisionDerail() == NONE); CHECK(wagon->Derailed == derailment::outcome::none); CHECK_FALSE(wagon->DamageFlag.HasAll(VehicleDamage::derailed)); } @@ -776,7 +776,7 @@ TEST_CASE("collisions: the legacy rule with physics.collisions old, the crush wi else { CHECK(crush == 0.0); } - CHECK(train[0]->crush_reports + train[1]->crush_reports == (model == global_settings::collision_model::monitor ? monitored : 0)); + CHECK(train[0]->crush_reports() + train[1]->crush_reports() == (model == global_settings::collision_model::monitor ? monitored : 0)); } } } @@ -887,8 +887,8 @@ TEST_CASE("collisions: road vehicles keep the legacy rule") { CHECK(derailed(road[0].physics())); CHECK(derailed(road[1].physics())); CHECK(road[0]->Couplers[VehicleEnd::rear].crush == 0.0); - CHECK(road[1]->CollisionDerail == NONE); - CHECK(road[0]->crush_reports + road[1]->crush_reports == 0); + CHECK(road[1]->CollisionDerail() == NONE); + CHECK(road[0]->crush_reports() + road[1]->crush_reports() == 0); } } @@ -900,10 +900,10 @@ TEST_CASE("collisions: a vehicle off the rails by the new model stays in the cha auto &locomotive{train.add(definition::fiz("4e_v1/4e"), 0, Coupling::none, 10.0, 0.5)}; wagon->derail_in_collision(COLLISION_PUSHED_OFF, "for the test"); REQUIRE(derailed(wagon.physics())); - auto const before{wagon->TotalMass * wagon->V() + locomotive->TotalMass * locomotive->V()}; + auto const before{wagon->TotalMass() * wagon->V() + locomotive->TotalMass() * locomotive->V()}; // the hit is over within a second, the friction of the derailed wagon slows the pair down over it train.run(1.0); - auto const after{wagon->TotalMass * wagon->V() + locomotive->TotalMass * locomotive->V()}; + auto const after{wagon->TotalMass() * wagon->V() + locomotive->TotalMass() * locomotive->V()}; // pushed along, not a wall the locomotive bounces off CHECK(wagon.speed() > 1.0); CHECK(locomotive.speed() > 0.0); @@ -1136,7 +1136,7 @@ TEST_CASE("collisions: two locomotives (117 t and 84 t) touching at walking spee auto const sm42{definition::fiz("sm42_v1/6d1")}; { vehicle check{su45}; - CHECK(check->TotalMass == doctest::Approx(117.0e3).epsilon(0.02)); + CHECK(check->TotalMass() == doctest::Approx(117.0e3).epsilon(0.02)); } for (auto const physics : {false, true}) { CAPTURE(physics); @@ -1184,8 +1184,8 @@ TEST_CASE("collisions: two coaches (36 t and 41.6 t) at 8 km/h don't crush, nor auto const heavy{coach(39.9e3)}; { vehicle check{light}; - CHECK(check->TotalMass == doctest::Approx(36.0e3).epsilon(0.01)); - CHECK(vehicle{heavy}->TotalMass == doctest::Approx(41.6e3).epsilon(0.01)); + CHECK(check->TotalMass() == doctest::Approx(36.0e3).epsilon(0.01)); + CHECK(vehicle{heavy}->TotalMass() == doctest::Approx(41.6e3).epsilon(0.01)); } for (auto const speed : {5.0, 8.0}) { CAPTURE(speed); @@ -1208,7 +1208,7 @@ TEST_CASE("collisions: two coaches (36 t and 41.6 t) at 8 km/h don't crush, nor auto &running{train.add(heavy, 0, Coupling::none, 5.0, gap)}; train.run(5.0); CHECK(wall->Couplers[VehicleEnd::rear].crush + running->Couplers[VehicleEnd::front].crush == 0.0); - CHECK(running->CollisionDerail == NONE); + CHECK(running->CollisionDerail() == NONE); } } @@ -1300,14 +1300,14 @@ TEST_CASE("collisions: the monitor goes by the energy of the hit as well") { train.add(definition::fiz("sm42_v1/6d1")); train.add(definition::fiz("su45_v2/301d"), 0, Coupling::none, 5.8, gap); train.run(5.0); - CHECK(train[0]->crush_reports + train[1]->crush_reports == 0); + CHECK(train[0]->crush_reports() + train[1]->crush_reports() == 0); } // one past them it does consist train; train.add(definition::fiz("4e_v1/4e")); train.add(definition::fiz("4e_v1/4e"), 0, Coupling::none, 25.0, 20.0); train.run(10.0); - CHECK(train[0]->crush_reports + train[1]->crush_reports == 1); + CHECK(train[0]->crush_reports() + train[1]->crush_reports() == 1); } // ---- the legacy derailment (physics.derailment old or monitor) in a train, with physics.collisions new @@ -1331,12 +1331,12 @@ train_damage damage_of(consist &Train) { for (auto const end : VehicleEnds) { result.energy += vehicle.crush_curve_at(end).energy(0.0, vehicle.Couplers[end].crush); } - result.derailed += vehicle.CollisionDerail != NONE; + result.derailed += vehicle.CollisionDerail() != NONE; if (i + 1 < Train.size()) { result.broken += vehicle.Couplers[VehicleEnd::rear].broken; } - if (crush_of(vehicle) > 0.0 || vehicle.CollisionDerail != NONE) { - result.list += std::format("{} crushed {:.2f} m{}; ", i, crush_of(vehicle), vehicle.CollisionDerail != NONE ? ", derailed" : ""); + if (crush_of(vehicle) > 0.0 || vehicle.CollisionDerail() != NONE) { + result.list += std::format("{} crushed {:.2f} m{}; ", i, crush_of(vehicle), vehicle.CollisionDerail() != NONE ? ", derailed" : ""); } } return result; @@ -1346,7 +1346,7 @@ train_damage damage_of(consist &Train) { double kinetic_of(consist &Train) { auto energy{0.0}; for (std::size_t i = 0; i < Train.size(); ++i) { - energy += 0.5 * Train[i]->TotalMass * Train[i]->V() * Train[i]->V(); + energy += 0.5 * Train[i]->TotalMass() * Train[i]->V() * Train[i]->V(); } return energy; } diff --git a/tests/unit/test_commands.cpp b/tests/unit/test_commands.cpp index 930893627..b06e4944d 100644 --- a/tests/unit/test_commands.cpp +++ b/tests/unit/test_commands.cpp @@ -39,7 +39,7 @@ std::vector state() { {"WaterPumpDisabled", [](auto const &M) { return flag(M.WaterPump.is_disabled); }}, {"WaterHeaterBreaker", [](auto const &M) { return flag(M.WaterHeater.breaker); }}, {"WaterHeaterEnabled", [](auto const &M) { return flag(M.WaterHeater.is_enabled); }}, - {"WaterCircuitsLink", [](auto const &M) { return flag(M.WaterCircuitsLink); }}, + {"WaterCircuitsLink", [](auto const &M) { return flag(M.WaterCircuitsLink()); }}, {"FuelPumpEnabled", [](auto const &M) { return flag(M.FuelPump.is_enabled); }}, {"FuelPumpDisabled", [](auto const &M) { return flag(M.FuelPump.is_disabled); }}, {"OilPumpEnabled", [](auto const &M) { return flag(M.OilPump.is_enabled); }}, @@ -51,8 +51,8 @@ std::vector state() { {"DirActive", [](auto const &M) { return M.DirActive; }}, {"DirAbsolute", [](auto const &M) { return M.DirAbsolute; }}, {"CabActive", [](auto const &M) { return M.CabActive; }}, - {"CabMaster", [](auto const &M) { return flag(M.CabMaster); }}, - {"AutoRelayFlag", [](auto const &M) { return flag(M.AutoRelayFlag); }}, + {"CabMaster", [](auto const &M) { return flag(M.CabMaster()); }}, + {"AutoRelayFlag", [](auto const &M) { return flag(M.AutoRelayFlag()); }}, {"ConverterAllow", [](auto const &M) { return flag(M.converter.IsAllowed()); }}, {"Battery", [](auto const &M) { return flag(M.lowVoltage.IsBatteryOn()); }}, {"CompressorAllow", [](auto const &M) { return flag(M.air.compressor.IsAllowed()); }}, @@ -62,12 +62,12 @@ std::vector state() { {"DoorRemoteOnly", [](auto const &M) { return flag(M.Doors.remote_only); }}, {"DepartureSignal", [](auto const &M) { return flag(M.DepartureSignal); }}, {"PantsValve", [](auto const &M) { return flag(M.pantographAir.valve.is_enabled) + 2 * flag(M.pantographAir.valve.is_disabled); }}, - {"MaxCurrentHigh", [](auto const &M) { return flag(M.MotorOverloadRelayHighThreshold); }}, - {"Imin", [](auto const &M) { return M.Imin; }}, + {"MaxCurrentHigh", [](auto const &M) { return flag(M.MotorOverloadRelayHighThreshold()); }}, + {"Imin", [](auto const &M) { return M.Imin(); }}, {"DamageFlag", [](auto const &M) { return M.DamageFlag.Bits(); }}, {"RadioStop", [](auto const &M) { return flag(M.RadioStopFlag()); }}, {"BrakeDelayFlag", [](auto const &M) { return M.brakes.delaySetting; }}, - {"SandDose", [](auto const &M) { return flag(M.SandDose); }}, + {"SandDose", [](auto const &M) { return flag(M.SandDose()); }}, {"CabSignal", [](auto const &M) { return flag(M.SecuritySystem.is_cabsignal_blinking()); }}, {"LoadAmount", [](auto const &M) { return M.LoadAmount(); }}, {"LoadStatus", [](auto const &M) { return M.LoadStatus(); }}, diff --git a/tests/unit/test_consist_braking.cpp b/tests/unit/test_consist_braking.cpp index 6b9367407..78859f9db 100644 --- a/tests/unit/test_consist_braking.cpp +++ b/tests/unit/test_consist_braking.cpp @@ -65,7 +65,7 @@ TEST_CASE("consist braking: the full braking position demands the most decelerat CHECK(figures[deceleration] == doctest::Approx(amax)); auto mass_t{0.0}; for (auto const *car : unit.cars) { - mass_t += car->TotalMass * 0.001; + mass_t += car->TotalMass() * 0.001; } CHECK(figures[mass] == doctest::Approx(mass_t)); // the holding brake standing still asks for no more than the service braking does diff --git a/tests/unit/test_controls.cpp b/tests/unit/test_controls.cpp index b53f0f904..4f754d0fc 100644 --- a/tests/unit/test_controls.cpp +++ b/tests/unit/test_controls.cpp @@ -259,10 +259,10 @@ TEST_CASE("controls: wheel slip on a slippery track, sand and the anti-slip brak // a notch a second: the controller put to full power at once never gets the line contactors closed scenario.act("full power"); scenario.full_power(0.0); - auto slipped{cab.SlippingWheels}; + auto slipped{cab.SlippingWheels()}; for (int i = 0; i < 10; ++i) { scenario.wait(1.0); - slipped = slipped || cab.SlippingWheels; + slipped = slipped || cab.SlippingWheels(); } // the electric locomotives slip at full power, the SM42, of less power for its weight, doesn't CHECK(slipped == (std::string{path} != "sm42_v1/6d1")); @@ -477,11 +477,11 @@ TEST_CASE("controls: a freight wagon loaded and braked") { CHECK(wagon.AssignLoad(load, 30.f) == (known || std::string{load}.empty())); wagon.ComputeMass(); if (*load == '\0') { - emptymass = wagon.TotalMass; + emptymass = wagon.TotalMass(); } else { // 30 t of a load the wagon takes, none of one it doesn't - CHECK(wagon.TotalMass == doctest::Approx(emptymass + (known ? 30000.0 : 0.0)).epsilon(0.01)); + CHECK(wagon.TotalMass() == doctest::Approx(emptymass + (known ? 30000.0 : 0.0)).epsilon(0.01)); } scenario.start_up(); scenario.get_going(); diff --git a/tests/unit/test_couplers_trains.cpp b/tests/unit/test_couplers_trains.cpp index a98feb802..a98d9bd08 100644 --- a/tests/unit/test_couplers_trains.cpp +++ b/tests/unit/test_couplers_trains.cpp @@ -134,7 +134,7 @@ TEST_CASE("couplers: automatic couplers coupling on contact") { // once coupled, not again until uncoupled; the vehicle which coupled marks it for the AI CHECK_FALSE(first.Couplers[VehicleEnd::rear].AutomaticCouplingAllowed); CHECK_FALSE(second.Couplers[VehicleEnd::front].AutomaticCouplingAllowed); - CHECK((TestFlag(first.AIFlag, sound::attachcoupler) || TestFlag(second.AIFlag, sound::attachcoupler))); + CHECK((TestFlag(first.AIFlag(), sound::attachcoupler) || TestFlag(second.AIFlag(), sound::attachcoupler))); scenario.check(); } } diff --git a/tests/unit/test_crew.cpp b/tests/unit/test_crew.cpp index 4c97ee31e..630941543 100644 --- a/tests/unit/test_crew.cpp +++ b/tests/unit/test_crew.cpp @@ -203,7 +203,7 @@ TEST_CASE("crew: a locomotive under power left by its driver stops and stays bra CHECK(eu07.brakes.HandlePosition() == static_cast(eu07.brakes.driverValve->GetPos(bh_EB))); CHECK(eu07.CabActive == 0); CHECK(eu07.CabOccupied() == 0); - CHECK_FALSE(eu07.CabMaster); + CHECK_FALSE(eu07.CabMaster()); auto const stoppedafter{seconds_to_stop(train, 120.0)}; CAPTURE(stoppedafter); @@ -225,13 +225,13 @@ TEST_CASE("crew: what the AI held is let go when the driver leaves") { cab->signal_departure(true); cab->Sandbox(true); REQUIRE(cab->DepartureSignal); - REQUIRE(cab->SandDose); + REQUIRE(cab->SandDose()); crew::secure(cab.physics(), cab.physics()); CHECK(cab->WarningSignal() == 0); CHECK_FALSE(cab->DepartureSignal); - CHECK_FALSE(cab->SandDose); + CHECK_FALSE(cab->SandDose()); } TEST_CASE("crew: a train left by its driver is braked through the whole of it") { diff --git a/tests/unit/test_definition.cpp b/tests/unit/test_definition.cpp index eeffd49e0..b165b741a 100644 --- a/tests/unit/test_definition.cpp +++ b/tests/unit/test_definition.cpp @@ -10,10 +10,10 @@ TEST_CASE("definition: the wagon from data/wagon.json loads with its values") { vehicle wagon{definition::load("wagon")}; CHECK(wagon->Mass == doctest::Approx(42200.0)); - CHECK(wagon->Vmax == doctest::Approx(120.0)); + CHECK(wagon->Vmax() == doctest::Approx(120.0)); CHECK(wagon->Dim.L == doctest::Approx(26.8)); - CHECK(wagon->WheelDiameter == doctest::Approx(0.96)); - CHECK(wagon->NAxles == 4); + CHECK(wagon->WheelDiameter() == doctest::Approx(0.96)); + CHECK(wagon->NAxles() == 4); CHECK(wagon->brakes.config.maxCylinderPressure[3] == doctest::Approx(3.8)); CHECK(wagon->brakes.config.kind == TBrakeSystem::Pneumatic); } @@ -22,7 +22,7 @@ TEST_CASE("definition: keys set by the test reach the vehicle") { vehicle heavy{definition::load("wagon").set("Param", "M", 60000).set("Wheels", "D", 1.0)}; CHECK(heavy->Mass == doctest::Approx(60000.0)); - CHECK(heavy->WheelDiameter == doctest::Approx(1.0)); + CHECK(heavy->WheelDiameter() == doctest::Approx(1.0)); } TEST_CASE("definition: an unknown test vehicle is an error, not a silently empty one") { @@ -62,7 +62,7 @@ TEST_CASE("definition: lines the loader skips or trims: comments, a hash anywher physics::Vehicle wagon(0.0, "wagon", "test", 0); REQUIRE(wagon.LoadFIZ_Text(crlf)); CHECK(wagon.Mass == doctest::Approx(42200.0)); - CHECK(wagon.Vmax == doctest::Approx(120.0)); + CHECK(wagon.Vmax() == doctest::Approx(120.0)); CHECK(wagon.brakes.config.maxCylinderPressure[3] == doctest::Approx(3.8)); } diff --git a/tests/unit/test_derail_motion.cpp b/tests/unit/test_derail_motion.cpp index 70e6ec810..d114a33ad 100644 --- a/tests/unit/test_derail_motion.cpp +++ b/tests/unit/test_derail_motion.cpp @@ -417,10 +417,10 @@ TEST_CASE("derail motion: the vehicle leaves the track with physics.derailment n eu07vehicle.step(curve); } REQUIRE(eu07vehicle->Derailed == dr::outcome::overturned); - CHECK(eu07vehicle->DerailCause == dm::cause::overturned); - CHECK(eu07vehicle->DerailAcceleration > eu07_tipping); + CHECK(eu07vehicle->DerailCause() == dm::cause::overturned); + CHECK(eu07vehicle->DerailAcceleration() > eu07_tipping); CHECK(eu07vehicle->leaves_track()); - eu07vehicle->OffTrack.begin(leaving(eu07vehicle->V(), eu07vehicle->DerailCause, 1, eu07vehicle->DerailAcceleration), eu07(), ballast); + eu07vehicle->OffTrack.begin(leaving(eu07vehicle->V(), eu07vehicle->DerailCause(), 1, eu07vehicle->DerailAcceleration()), eu07(), ballast); CHECK_FALSE(eu07vehicle->leaves_track()); // tipping over on its outer wheels it hardly slows down auto const start{eu07vehicle->V()}; @@ -433,8 +433,8 @@ TEST_CASE("derail motion: the vehicle leaves the track with physics.derailment n eu07vehicle->repair_damage(); CHECK_FALSE(eu07vehicle->OffTrack.active()); CHECK_FALSE(eu07vehicle->leaves_track()); - CHECK(eu07vehicle->DerailCause == dm::cause::off_rails); - CHECK(eu07vehicle->DerailAcceleration == 0.0); + CHECK(eu07vehicle->DerailCause() == dm::cause::off_rails); + CHECK(eu07vehicle->DerailAcceleration() == 0.0); } SUBCASE("new: off the end of the track it slides on its wheels, straight on") { model_setting const physical{global_settings::derailment_model::physical}; @@ -443,7 +443,7 @@ TEST_CASE("derail motion: the vehicle leaves the track with physics.derailment n eu07vehicle.step(); REQUIRE(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed)); CHECK(eu07vehicle->Derailed == dr::outcome::off_rails); - CHECK(eu07vehicle->DerailCause == dm::cause::end_of_track); + CHECK(eu07vehicle->DerailCause() == dm::cause::end_of_track); CHECK(eu07vehicle->leaves_track()); } SUBCASE("new: a vehicle pulled off by a coupling, upright, to the side it was pulled to") { @@ -452,13 +452,13 @@ TEST_CASE("derail motion: the vehicle leaves the track with physics.derailment n pulled->pull_off(-1, 5.0, "test"); CHECK(pulled->DamageFlag.HasAll(VehicleDamage::derailed)); CHECK(pulled->Derailed == dr::outcome::off_rails); - CHECK(pulled->DerailCause == dm::cause::pulled_off); - CHECK(pulled->DerailSide == -1); + CHECK(pulled->DerailCause() == dm::cause::pulled_off); + CHECK(pulled->DerailSide() == -1); CHECK(pulled->leaves_track()); pulled->repair_damage(); - CHECK(pulled->DerailCause == dm::cause::off_rails); - CHECK(pulled->DerailAcceleration == 0.0); - CHECK(pulled->DerailSide == 0); + CHECK(pulled->DerailCause() == dm::cause::off_rails); + CHECK(pulled->DerailAcceleration() == 0.0); + CHECK(pulled->DerailSide() == 0); } } diff --git a/tests/unit/test_derailment_vehicle.cpp b/tests/unit/test_derailment_vehicle.cpp index 1dffe2f66..24efb30a8 100644 --- a/tests/unit/test_derailment_vehicle.cpp +++ b/tests/unit/test_derailment_vehicle.cpp @@ -253,13 +253,13 @@ TEST_CASE("derailment: monitor tells again on the same track after a repair") { for (int step = 0; step < 100; ++step) { eu07vehicle.step(curve); } - REQUIRE(eu07vehicle->derailment_reports == 1); + REQUIRE(eu07vehicle->derailment_reports() == 1); eu07vehicle->repair_damage(); CHECK_FALSE(eu07vehicle->derailment_reported.has_value()); for (int step = 0; step < 100; ++step) { eu07vehicle.step(curve); } - CHECK(eu07vehicle->derailment_reports == 2); + CHECK(eu07vehicle->derailment_reports() == 2); } TEST_CASE("derailment: monitor, the legacy draw decides and the log tells what the criteria would do") { @@ -277,7 +277,7 @@ TEST_CASE("derailment: monitor, the legacy draw decides and the log tells what t CHECK_FALSE(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed)); CHECK(eu07vehicle->Derailed == dr::outcome::none); // once on a track, however long it stays over the criteria - CHECK(eu07vehicle->derailment_reports == 1); + CHECK(eu07vehicle->derailment_reports() == 1); REQUIRE(eu07vehicle->derailment_reported.has_value()); CHECK(*eu07vehicle->derailment_reported == &curve.name); // and once more on the next one @@ -286,7 +286,7 @@ TEST_CASE("derailment: monitor, the legacy draw decides and the log tells what t for (int step = 0; step < 100; ++step) { eu07vehicle.step(next); } - CHECK(eu07vehicle->derailment_reports == 2); + CHECK(eu07vehicle->derailment_reports() == 2); CHECK_FALSE(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed)); SUBCASE("under the criteria nothing is told") { @@ -294,7 +294,7 @@ TEST_CASE("derailment: monitor, the legacy draw decides and the log tells what t for (int step = 0; step < 100; ++step) { slower.step(curve); } - CHECK(slower->derailment_reports == 0); + CHECK(slower->derailment_reports() == 0); } SUBCASE("far over the legacy threshold the legacy draw derails it, the legacy way") { vehicle faster{definition::fiz("4e_v1/4e"), 160.0}; diff --git a/tests/unit/test_diesel.cpp b/tests/unit/test_diesel.cpp index 5328c439b..0f49d27f2 100644 --- a/tests/unit/test_diesel.cpp +++ b/tests/unit/test_diesel.cpp @@ -95,7 +95,7 @@ TEST_CASE("diesel: the 214M railbus's torque converter, gears and retarder") { CHECK(railbus.MainCtrlPos() == 5); CHECK(railbus.eimic_real == doctest::Approx(1.0)); CHECK(railbus.torqueConverter.lockedUp); - CHECK(railbus.ScndCtrlActualPos == railbus.ScndCtrlPosNo); + CHECK(railbus.ScndCtrlActualPos == railbus.ScndCtrlPosNo()); struct position { double eimic; bool retarder; @@ -118,7 +118,7 @@ TEST_CASE("diesel: the 214M railbus's torque converter, gears and retarder") { scenario.wait(30.0); CHECK(railbus.Vel == doctest::Approx(0.0)); // the gearbox shifted down as the railbus slowed - CHECK(railbus.ScndCtrlActualPos < railbus.ScndCtrlPosNo); + CHECK(railbus.ScndCtrlActualPos < railbus.ScndCtrlPosNo()); scenario.check(); } @@ -130,7 +130,7 @@ TEST_CASE("diesel: the 214M railbus's speed control, up to the speed of a button scenario.add("21xm_v1/214ma", 1); REQUIRE(scenario.start_up()); auto &railbus{scenario.cab()}; - REQUIRE(railbus.SpeedCtrl); + REQUIRE(railbus.SpeedCtrl()); scenario.get_going(); scenario.full_power(10.0); scenario.act("speed control on"); diff --git a/tests/unit/test_dimmer.cpp b/tests/unit/test_dimmer.cpp index 2368b7ff6..4bfb230ca 100644 --- a/tests/unit/test_dimmer.cpp +++ b/tests/unit/test_dimmer.cpp @@ -63,7 +63,7 @@ TEST_CASE("dimmer: a DefaultPos past the end of the list starts the dimmer at it TEST_CASE("dimmer: without the modern dimmer a DefaultPos past the end of the list puts the dimmer at its last position") { vehicle cab{dimmer_list(nlohmann::ordered_json::array({plain, dimmed}), 7).set("Switches", "ModernDimmer", "No")}; - REQUIRE_FALSE(cab->enableModernDimmer); + REQUIRE_FALSE(cab->enableModernDimmer()); CHECK(cab->DimmerPosition() == 1); CHECK(cab->currentDimPosition().isDimmed); diff --git a/tests/unit/test_dynamic_brake_diesel.cpp b/tests/unit/test_dynamic_brake_diesel.cpp index 008a8fbe8..d8e6b05c1 100644 --- a/tests/unit/test_dynamic_brake_diesel.cpp +++ b/tests/unit/test_dynamic_brake_diesel.cpp @@ -85,7 +85,7 @@ TEST_CASE("diesel-electric dynamic brake: none without its definition") { controller_to(locomotive, 0); scenario.wait(15.0); CHECK(locomotive.eimic_real == doctest::Approx(-1.0)); - CHECK(locomotive.Ft == doctest::Approx(0.0)); + CHECK(locomotive.Ft() == doctest::Approx(0.0)); CHECK_FALSE(locomotive.brakes.electrodynamic.on); // coasting: braking with the power of the resistors above, it would lose more than 30 km/h CHECK(locomotive.Vel > speed - 12.0); @@ -114,7 +114,7 @@ TEST_CASE("diesel-electric dynamic brake: the BR285's controller") { CHECK(locomotive.DEDynamicBrake.level == doctest::Approx(1.0)); CHECK(locomotive.brakes.electrodynamic.on); REQUIRE(locomotive.Vel > 6.0); - CHECK(-locomotive.Ft == doctest::Approx(br285_limit(locomotive)).epsilon(0.01)); + CHECK(-locomotive.Ft() == doctest::Approx(br285_limit(locomotive)).epsilon(0.01)); CHECK(locomotive.Im > 0.0); CHECK(locomotive.EngineVoltage == doctest::Approx(0.0)); CHECK(locomotive.brakes.cylinderPressure < 0.1); @@ -141,16 +141,16 @@ TEST_CASE("diesel-electric dynamic brake: the BR285's controller") { // under the power limit the force holds REQUIRE(locomotive.Vel < 40.0); REQUIRE(locomotive.Vel > 6.0); - CHECK(-locomotive.Ft == doctest::Approx(150000.0).epsilon(0.01)); + CHECK(-locomotive.Ft() == doctest::Approx(150000.0).epsilon(0.01)); for (int i = 0; i < 120 && locomotive.Vel > 4.0; ++i) { scenario.wait(1.0); } // fading out - CHECK(-locomotive.Ft < 150000.0 * 0.6); + CHECK(-locomotive.Ft() < 150000.0 * 0.6); for (int i = 0; i < 120 && locomotive.Vel > 1.5; ++i) { scenario.wait(1.0); } - CHECK(locomotive.Ft == doctest::Approx(0.0)); + CHECK(locomotive.Ft() == doctest::Approx(0.0)); CHECK_FALSE(locomotive.brakes.electrodynamic.on); // it doesn't hold the train: the air brake does CHECK(locomotive.Vel > 0.1); @@ -177,7 +177,7 @@ TEST_CASE("diesel-electric dynamic brake: a resistor brake with its own lever") scenario.wait(5.0); // the master controller at a power position keeps it off CHECK(locomotive.DEDynamicBrake.level == doctest::Approx(0.0)); - CHECK(locomotive.Ft > 0.0); + CHECK(locomotive.Ft() > 0.0); CHECK_FALSE(locomotive.brakes.electrodynamic.on); scenario.act("power off"); @@ -185,7 +185,7 @@ TEST_CASE("diesel-electric dynamic brake: a resistor brake with its own lever") scenario.wait(4.0); CHECK(locomotive.DEDynamicBrake.level == doctest::Approx(1.0)); CHECK(locomotive.brakes.electrodynamic.on); - CHECK(-locomotive.Ft == doctest::Approx(st44_limit(locomotive)).epsilon(0.01)); + CHECK(-locomotive.Ft() == doctest::Approx(st44_limit(locomotive)).epsilon(0.01)); CHECK(locomotive.ShowCurrent(0) > 0.0); scenario.act("half the lever"); @@ -197,13 +197,13 @@ TEST_CASE("diesel-electric dynamic brake: a resistor brake with its own lever") REQUIRE(locomotive.Vel < 21.0); REQUIRE(locomotive.Vel > 10.0); // on the rising part, half the excitation - CHECK(-locomotive.Ft == doctest::Approx(0.5 * st44_limit(locomotive)).epsilon(0.01)); + CHECK(-locomotive.Ft() == doctest::Approx(0.5 * st44_limit(locomotive)).epsilon(0.01)); scenario.act("engine off"); locomotive.MainSwitch(false); scenario.wait(1.0); CHECK(locomotive.DEDynamicBrake.level == doctest::Approx(0.0)); - CHECK(locomotive.Ft == doctest::Approx(0.0)); + CHECK(locomotive.Ft() == doctest::Approx(0.0)); CHECK_FALSE(locomotive.brakes.electrodynamic.on); scenario.check(); } @@ -257,7 +257,7 @@ TEST_CASE("diesel-electric dynamic brake: without a fade it brings the vehicle t for (int i = 0; i < 5; ++i) { scenario.wait(1.0); CHECK(locomotive.V() == 0.0); - CHECK(locomotive.Ft == doctest::Approx(0.0)); + CHECK(locomotive.Ft() == doctest::Approx(0.0)); } CHECK(locomotive.DEDynamicBrake.level == doctest::Approx(1.0)); scenario.check(); diff --git a/tests/unit/test_elf_controller.cpp b/tests/unit/test_elf_controller.cpp index e754f3d1b..c50bc6eac 100644 --- a/tests/unit/test_elf_controller.cpp +++ b/tests/unit/test_elf_controller.cpp @@ -95,7 +95,7 @@ TEST_CASE("elf controller: without EIMCtrlMainEmergency the positions stay as th REQUIRE(unit.ready); REQUIRE(unit.charged); auto &physics{unit.cab()}; - CHECK_FALSE(physics.EIMCtrlMainEmergency); + CHECK_FALSE(physics.EIMCtrlMainEmergency()); CHECK(physics.EIMCtrlEmergencyPositions() == 0); CHECK(physics.MainCtrlPosNo == 4); CHECK(physics.MainCtrlNoPowerPos() == 3); @@ -113,7 +113,7 @@ TEST_CASE("elf controller: EIMCtrlMainEmergency shifts the positions up by the e REQUIRE(unit.ready); REQUIRE(unit.charged); auto &physics{unit.cab()}; - CHECK(physics.EIMCtrlMainEmergency); + CHECK(physics.EIMCtrlMainEmergency()); CHECK(physics.EIMCtrlEmergencyPositions() == 1); CHECK(physics.MainCtrlPosNo == 5); CHECK(physics.MainCtrlNoPowerPos() == 4); @@ -158,13 +158,13 @@ TEST_CASE("elf controller: EIMCtrlMainEmergency with the old MCPN gets its posit CHECK(car->MainCtrlPosNo == 5); CHECK(car->MainCtrlNoPowerPos() == 4); // DirChangeMaxPos=3 of the file, the old neutral, moves up with the positions - CHECK(car->MainCtrlMaxDirChangePos == 4); + CHECK(car->MainCtrlMaxDirChangePos() == 4); } TEST_CASE("elf controller: EIMCtrlMainEmergency leaves DirChangeMaxPos of the files updated for it alone") { vehicle car{definition::fiz("elf_v1/21we-a").set("Cntrl", "EIMCtrlMainEmergency", "Yes").set("Cntrl", "MCPN", 5).set("Cntrl", "DirChangeMaxPos", 4)}; CHECK(car->MainCtrlPosNo == 5); - CHECK(car->MainCtrlMaxDirChangePos == 4); + CHECK(car->MainCtrlMaxDirChangePos() == 4); } TEST_CASE("elf controller: the reverser works at the neutral shifted by EIMCtrlMainEmergency") { @@ -205,7 +205,7 @@ TEST_CASE("elf controller: an Elf with the emergency brake position leading one REQUIRE(unit.charged); auto &lead{unit.cab()}; auto &other{unit.car(3)}; - REQUIRE_FALSE(other.EIMCtrlMainEmergency); + REQUIRE_FALSE(other.EIMCtrlMainEmergency()); // neutral of the lead is neutral of the other CHECK(lead.MainCtrlPos() == 4); CHECK(other.MainCtrlPos() == other.MainCtrlNoPowerPos()); @@ -235,7 +235,7 @@ TEST_CASE("elf controller: an Elf without the emergency brake position leading o REQUIRE(unit.charged); auto &lead{unit.cab()}; auto &other{unit.car(3)}; - REQUIRE(other.EIMCtrlMainEmergency); + REQUIRE(other.EIMCtrlMainEmergency()); CHECK(lead.MainCtrlPos() == 3); CHECK(other.MainCtrlPos() == other.MainCtrlNoPowerPos()); SUBCASE("power") { @@ -295,15 +295,15 @@ void hold(elf &Unit, bool Hold) { auto mass{0.0}; auto axles{0}; for (std::size_t i = 0; i < Unit.unit.size(); ++i) { - mass += Unit.car(i).TotalMass; - axles += Unit.car(i).NAxles; + mass += Unit.car(i).TotalMass(); + axles += Unit.car(i).NAxles(); } auto const force{Unit.cab().brakes.holding.deceleration * mass}; for (std::size_t i = 0; i < Unit.unit.size(); ++i) { auto &car{Unit.car(i)}; auto const nmax{((car.brakes.config.pressureToForce * car.brakes.config.maxCylinderPressure[0] - car.brakes.config.cylinders.springForce) * car.brakes.config.cylinders.leverRatio[0] - car.brakes.config.cylinders.slackAdjusterForce) * car.brakes.config.cylinders.count * car.brakes.config.cylinders.riggingEfficiency}; - auto const fmax{nmax * car.brakes.distributor->GetFC(nmax / (car.NAxles * car.brakes.config.blocksPerAxle), car.brakes.blending.referenceSpeed) * 1000}; - auto position{Hold ? force * car.NAxles / axles / fmax : 0.0}; + auto const fmax{nmax * car.brakes.distributor->GetFC(nmax / (car.NAxles() * car.brakes.config.blocksPerAxle), car.brakes.blending.referenceSpeed) * 1000}; + auto position{Hold ? force * car.NAxles() / axles / fmax : 0.0}; if (position > 0.009) { auto const slack{(car.brakes.config.cylinders.slackAdjusterForce / car.brakes.config.cylinders.leverRatio[0] + car.brakes.config.cylinders.springForce) / (car.brakes.config.pressureToForce * car.brakes.config.maxCylinderPressure[0])}; position = slack + (1 - slack) * position; @@ -521,16 +521,16 @@ TEST_CASE("elf holding brake: the force of the motors at 1% against the holding auto mass{0.0}; auto powered{0}; for (std::size_t i = 0; i < unit.unit.size(); ++i) { - mass += unit.car(i).TotalMass; - powered += unit.car(i).NPoweredAxles > 0 ? 1 : 0; + mass += unit.car(i).TotalMass(); + powered += unit.car(i).NPoweredAxles() > 0 ? 1 : 0; } unit.set_controller(4); unit.unit.step(unit.line); unit.set_controller(3); unit.wait(5.0); auto const holding{cab.brakes.holding.deceleration * mass}; - MESSAGE("mass " << mass << " kg, holding " << holding << " N, cars with motors " << powered << ", demand " << cab.eimic_real << ", cab car Ft " << cab.Ft + MESSAGE("mass " << mass << " kg, holding " << holding << " N, cars with motors " << powered << ", demand " << cab.eimic_real << ", cab car Ft " << cab.Ft() << " N, Fful " << cab.inductionMotor.state.fullForce << " kN, speed " << cab.Vel << " km/h after 5 s"); CHECK(cab.eimic_real == doctest::Approx(0.01).epsilon(0.02)); - CHECK(cab.Ft * powered < 0.1 * holding); + CHECK(cab.Ft() * powered < 0.1 * holding); } diff --git a/tests/unit/test_engine_start.cpp b/tests/unit/test_engine_start.cpp index b58f0cf77..d8ecfe529 100644 --- a/tests/unit/test_engine_start.cpp +++ b/tests/unit/test_engine_start.cpp @@ -178,7 +178,7 @@ TEST_CASE("engine start: the switch of another vehicle is held for the vehicle's consist train; train.add(sn61(false).set("Cntrl", "IniCDelay", "2.0"), 1); auto &second{train.add(sn61(false).set("Cntrl", "IniCDelay", "2.0")).physics()}; - REQUIRE(second.InitialCtrlDelay == doctest::Approx(2.0)); + REQUIRE(second.InitialCtrlDelay() == doctest::Approx(2.0)); engine_start::remote_switch switchb; // without the battery the switch does nothing, however long it's held diff --git a/tests/unit/test_equipment_faults.cpp b/tests/unit/test_equipment_faults.cpp index bd65cacb4..d87d803a1 100644 --- a/tests/unit/test_equipment_faults.cpp +++ b/tests/unit/test_equipment_faults.cpp @@ -16,18 +16,18 @@ TEST_CASE("equipment faults: the number of a message comes back as it went in") TEST_CASE("equipment faults: the fault of the control opens the line contactors and holds the start until it clears") { test::vehicle loco{test::definition::fiz("4e_v1/4e")}; - auto const delay{loco->InitialCtrlDelay}; + auto const delay{loco->InitialCtrlDelay()}; loco->lineContactors.Close(); loco->SetEquipmentFaults(EquipmentFault::control); CHECK(loco->equipmentFaults.HasAll(EquipmentFault::control)); CHECK_FALSE(loco->lineContactors.IsClosed()); - CHECK(loco->InitialCtrlDelay > 100000000.0); + CHECK(loco->InitialCtrlDelay() > 100000000.0); // set again, it doesn't move the delay further loco->SetEquipmentFaults(EquipmentFault::control); - CHECK(loco->InitialCtrlDelay < 200000000.0); + CHECK(loco->InitialCtrlDelay() < 200000000.0); loco->SetEquipmentFaults({}); CHECK(loco->equipmentFaults.Empty()); - CHECK(loco->InitialCtrlDelay == doctest::Approx(delay)); + CHECK(loco->InitialCtrlDelay() == doctest::Approx(delay)); } TEST_CASE("equipment faults: the fault of the compressor moves its pressures out of reach, and back") { diff --git a/tests/unit/test_field_shunting.cpp b/tests/unit/test_field_shunting.cpp index ac44a4fdc..4c9793294 100644 --- a/tests/unit/test_field_shunting.cpp +++ b/tests/unit/test_field_shunting.cpp @@ -46,10 +46,10 @@ TEST_CASE("field shunting: the SU45 with its switch, off at full power and switc scenario.add("bdhpumn_v3/bdhpumn"); REQUIRE(scenario.start_up()); auto &su45{scenario.driver().controlling}; - REQUIRE(su45.AutoRelayType == 2); - REQUIRE(su45.FieldShuntSwitch); + REQUIRE(su45.AutoRelayType() == 2); + REQUIRE(su45.FieldShuntSwitch()); // the driver switches it on as the AI does, getting the locomotive ready - CHECK(su45.AutoRelayFlag); + CHECK(su45.AutoRelayFlag()); scenario.act("field shunting off"); CHECK(su45.AutoRelaySwitch(false)); scenario.get_going(); @@ -65,7 +65,7 @@ TEST_CASE("field shunting: the SU45 with its switch, off at full power and switc scenario.act("field shunting on"); CHECK(su45.AutoRelaySwitch(true)); scenario.wait(30.0); - CHECK(su45.ScndCtrlPos() == su45.ScndCtrlPosNo); + CHECK(su45.ScndCtrlPos() == su45.ScndCtrlPosNo()); scenario.act("field shunting off on the move"); CHECK(su45.AutoRelaySwitch(false)); scenario.wait(1.0); @@ -81,9 +81,9 @@ TEST_CASE("field shunting: a diesel-electric with AutoRelay=Optional alone shunt scenario.add("bdhpumn_v3/bdhpumn"); REQUIRE(scenario.start_up()); auto &su45{scenario.driver().controlling}; - REQUIRE(su45.AutoRelayType == 2); - REQUIRE_FALSE(su45.FieldShuntSwitch); - CHECK_FALSE(su45.AutoRelayFlag); + REQUIRE(su45.AutoRelayType() == 2); + REQUIRE_FALSE(su45.FieldShuntSwitch()); + CHECK_FALSE(su45.AutoRelayFlag()); scenario.get_going(); scenario.full_power(120.0); CHECK(su45.IsMainCtrlMaxPowerPos()); diff --git a/tests/unit/test_fiz.cpp b/tests/unit/test_fiz.cpp index 31087a141..51488f5de 100644 --- a/tests/unit/test_fiz.cpp +++ b/tests/unit/test_fiz.cpp @@ -26,11 +26,11 @@ TEST_CASE("fiz: every real vehicle loads and keeps its parameters") { trace.sample(0.0, real.physics()); // what every vehicle has, the rest of its parameters are in the golden trace CHECK(real->Mass > 0.0); - CHECK(real->TotalMass >= real->Mass); - CHECK(real->Vmax > 0.0); - CHECK(real->NAxles > 0); - CHECK(real->WheelDiameter > 0.0); - CHECK(real->NPoweredAxles <= real->NAxles); + CHECK(real->TotalMass() >= real->Mass); + CHECK(real->Vmax() > 0.0); + CHECK(real->NAxles() > 0); + CHECK(real->WheelDiameter() > 0.0); + CHECK(real->NPoweredAxles() <= real->NAxles()); trace.check(); } } @@ -42,7 +42,7 @@ TEST_CASE("fiz: changes made by a test reach the vehicle") { // a key the file doesn't have is added to its section CHECK(vehicle{definition{eu07}.set("Brake", "MaxBP", 3.5)}->brakes.config.maxCylinderPressure[3] == doctest::Approx(3.5)); // removing a key brings its default back - CHECK(vehicle{definition{eu07}.remove("Param", "Vmax")}->Vmax != doctest::Approx(125.0)); + CHECK(vehicle{definition{eu07}.remove("Param", "Vmax")}->Vmax() != doctest::Approx(125.0)); } namespace { diff --git a/tests/unit/test_genset.cpp b/tests/unit/test_genset.cpp index 36943bf84..b26654f8d 100644 --- a/tests/unit/test_genset.cpp +++ b/tests/unit/test_genset.cpp @@ -111,7 +111,7 @@ void notch_up(physics::Vehicle &Cab) { // the power at the wheels [kW] double wheel_power(physics::Vehicle const &Vehicle) { - return std::abs(Vehicle.Ft * Vehicle.V()) / 1000.0; + return std::abs(Vehicle.Ft() * Vehicle.V()) / 1000.0; } // one step of 0.01 s, acknowledging the vigilance once a second @@ -341,7 +341,7 @@ TEST_CASE("genset: running from the catenary is the same with the keys") { }; auto const record = [](values &Values) { return std::vector{ - {"Ft", [&Values](physics::Vehicle const &Vehicle) { Values.force.push_back(Vehicle.Ft); return Vehicle.Ft; }}, + {"Ft", [&Values](physics::Vehicle const &Vehicle) { Values.force.push_back(Vehicle.Ft()); return Vehicle.Ft(); }}, {"V", [&Values](physics::Vehicle const &Vehicle) { Values.speed.push_back(Vehicle.V()); return Vehicle.V(); }}, {"EngineVoltage", [&Values](physics::Vehicle const &Vehicle) { Values.voltage.push_back(Vehicle.EngineVoltage); return Vehicle.EngineVoltage; }}, {"Itot", [&Values](physics::Vehicle const &Vehicle) { Values.current.push_back(Vehicle.Itot); return Vehicle.Itot; }}, diff --git a/tests/unit/test_handover.cpp b/tests/unit/test_handover.cpp index dd5ed15ae..ec43a2b3a 100644 --- a/tests/unit/test_handover.cpp +++ b/tests/unit/test_handover.cpp @@ -38,11 +38,11 @@ TEST_CASE("handover: the horn the AI was sounding goes quiet (eu07/maszyna#511)" TEST_CASE("handover: sanding the AI started stops") { auto cab{cab_vehicle()}; cab->Sandbox(true); // the way the AI sands, bypassing the sanding button - REQUIRE(cab->SandDose); + REQUIRE(cab->SandDose()); handover::release_ai_controls(cab.physics(), cab.physics()); - CHECK_FALSE(cab->SandDose); + CHECK_FALSE(cab->SandDose()); } TEST_CASE("handover: sanding the player or the automatic system asked for goes on") { @@ -52,11 +52,11 @@ TEST_CASE("handover: sanding the player or the automatic system asked for goes o cab->SandboxAutoAllow(true); cab->SandboxAuto(true); } - REQUIRE(cab->SandDose); + REQUIRE(cab->SandDose()); handover::release_ai_controls(cab.physics(), cab.physics()); - CHECK(cab->SandDose); + CHECK(cab->SandDose()); } TEST_CASE("handover: the departure signal the AI was giving stops") { @@ -85,7 +85,7 @@ TEST_CASE("handover: nothing the AI didn't latch changes") { handover::release_ai_controls(cab.physics(), cab.physics()); CHECK(cab->WarningSignal() == 0); - CHECK_FALSE(cab->SandDose); + CHECK_FALSE(cab->SandDose()); CHECK_FALSE(cab->DepartureSignal); CHECK_FALSE(cab->brakes.distributor->Releaser()); } @@ -136,7 +136,7 @@ TEST_CASE("handover: the light selector already matching the lights stays") { TEST_CASE("handover: the headlight dimmer leaves the off position when the head lights are lit") { auto cab{cab_vehicle()}; - REQUIRE(cab->enableModernDimmer); + REQUIRE(cab->enableModernDimmer()); REQUIRE(cab->dimPositions.size() == 5); cab->SetDimmerPosition(2); // off, left there by the player before the AI took over @@ -163,7 +163,7 @@ TEST_CASE("handover: the headlight dimmer in any other position stays") { TEST_CASE("handover: a vehicle without the modern dimmer keeps its dimmer state") { vehicle wagon{definition::load("wagon")}; - REQUIRE_FALSE(wagon->enableModernDimmer); + REQUIRE_FALSE(wagon->enableModernDimmer()); CHECK(handover::dimmer_position(wagon.physics(), true) == wagon->DimmerPosition()); } diff --git a/tests/unit/test_horn.cpp b/tests/unit/test_horn.cpp index 65c600944..4c9fd7fb3 100644 --- a/tests/unit/test_horn.cpp +++ b/tests/unit/test_horn.cpp @@ -55,7 +55,7 @@ int const allhorns{horn::low | horn::high | 4}; TEST_CASE("horn: a pneumatic horn sounds on the air of the main reservoir only") { auto vehicle{horn_vehicle(test::definition::load("wagon"))}; - REQUIRE(vehicle->HornSupply == horn_supply::air); // the default + REQUIRE(vehicle->HornSupply() == horn_supply::air); // the default vehicle->air.SetPressureForTest(6.5); CHECK(vehicle->SoundingHorns(allhorns) == allhorns); @@ -75,7 +75,7 @@ TEST_CASE("horn: a vehicle without a main reservoir takes the horn air from the TEST_CASE("horn: an electric horn sounds on the low voltage, whatever the air") { auto vehicle{horn_vehicle(test::definition::load("wagon").set("Cntrl", "HornType", "Electric"))}; - REQUIRE(vehicle->HornSupply == horn_supply::electric); + REQUIRE(vehicle->HornSupply() == horn_supply::electric); REQUIRE(vehicle->Horn3Supply == horn_supply::electric); // the third horn follows the others unless told otherwise vehicle->air.SetPressureForTest(0.0); @@ -87,7 +87,7 @@ TEST_CASE("horn: an electric horn sounds on the low voltage, whatever the air") TEST_CASE("horn: the third horn can have a supply of its own, an electric horn of a diesel say") { auto vehicle{horn_vehicle(test::definition::load("wagon").set("Cntrl", "Horn3Type", "Electric"))}; - REQUIRE(vehicle->HornSupply == horn_supply::air); + REQUIRE(vehicle->HornSupply() == horn_supply::air); REQUIRE(vehicle->Horn3Supply == horn_supply::electric); vehicle->air.SetPressureForTest(0.0); diff --git a/tests/unit/test_loads.cpp b/tests/unit/test_loads.cpp index 123389155..ee35a6e2a 100644 --- a/tests/unit/test_loads.cpp +++ b/tests/unit/test_loads.cpp @@ -35,11 +35,11 @@ TEST_CASE("loads: the pantographs of an electric vehicle set up by the amount of TEST_CASE("loads: a load assigned, of one kind at a time, up to the vehicle's capacity, and emptied") { vehicle wagon{definition::fiz("3wl_v2/3wl")}; - auto const empty{wagon->TotalMass}; + auto const empty{wagon->TotalMass()}; REQUIRE(wagon->AssignLoad("coal", 10.f)); CHECK(wagon->LoadTypeChange()); CHECK(wagon->LoadType.name == "coal"); - CHECK(wagon->TotalMass > empty); + CHECK(wagon->TotalMass() > empty); // more of the same: the amount set, not added, and no more than the vehicle takes wagon->TakeLoadTypeChange(); REQUIRE(wagon->AssignLoad("coal", 1000.f)); diff --git a/tests/unit/test_pullee.cpp b/tests/unit/test_pullee.cpp index f4aacbfc2..3c8748795 100644 --- a/tests/unit/test_pullee.cpp +++ b/tests/unit/test_pullee.cpp @@ -76,7 +76,7 @@ TEST_CASE("pullee: a dead Vectron vents the brake pipe of the train hauling it, SUBCASE("as it is") { hauled_train train{vectron, 60.0, false}; REQUIRE((train.hauled->InactiveCabFlag & activation::emergencybrake) != 0); - REQUIRE_FALSE(train.hauled->PulleeMode); + REQUIRE_FALSE(train.hauled->PulleeMode()); train.run(120.0); CHECK(train.hauled->brakes.emergencyValve.flow > 0.0); CHECK(train.locomotive->brakePipe.Pressure() < 4.95); // the pipe sags although the locomotive keeps feeding it @@ -320,9 +320,9 @@ TEST_CASE("pullee: entering the mode lets go of the hand brake and the spring br SUBCASE("a locomotive standing braked, its spring brake switched on") { vehicle vectron{definition::fiz("vectron_v1/wariant_7w")}; REQUIRE(vectron->brakes.spring.activate); - REQUIRE_FALSE(vectron->PulleeMode); + REQUIRE_FALSE(vectron->PulleeMode()); CHECK(vectron->PulleeModeSwitch(true)); - CHECK(vectron->PulleeMode); + CHECK(vectron->PulleeMode()); CHECK_FALSE(vectron->brakes.spring.activate); // already in it CHECK_FALSE(vectron->PulleeModeSwitch(true)); @@ -355,14 +355,14 @@ TEST_CASE("pullee: the battery and the cabs of a vehicle prepared for hauling st CHECK(vectron->brakes.emergencyValve.flow == 0.0); REQUIRE(vectron->PulleeModeSwitch(false)); - CHECK_FALSE(vectron->PulleeMode); + CHECK_FALSE(vectron->PulleeMode()); CHECK(vectron->BatterySwitch(true)); CHECK(vectron->lowVoltage.IsBatteryOn()); CHECK(vectron->CabActivisation()); CHECK(vectron->CabActive == 1); // a vehicle driven from isn't one to haul CHECK_FALSE(vectron->PulleeModeSwitch(true)); - CHECK_FALSE(vectron->PulleeMode); + CHECK_FALSE(vectron->PulleeMode()); } TEST_CASE("pullee: a cab activated on a dead battery calls the emergency brake, which the mode keeps from happening") { diff --git a/tests/unit/test_speed_control.cpp b/tests/unit/test_speed_control.cpp index 9ce81b736..516334cbf 100644 --- a/tests/unit/test_speed_control.cpp +++ b/tests/unit/test_speed_control.cpp @@ -21,7 +21,7 @@ std::vector cruise() { {"SpeedCtrlStandby", [](auto const &M) { return M.SpeedCtrlUnit.Standby ? 1.0 : 0.0; }}, {"SpeedCtrlValue", [](auto const &M) { return M.SpeedCtrlValue; }}, {"eimic", [](auto const &M) { return M.eimic; }}, - {"eimicSpeedCtrl", [](auto const &M) { return M.eimicSpeedCtrl; }}, + {"eimicSpeedCtrl", [](auto const &M) { return M.eimicSpeedCtrl(); }}, {"eimic_real", [](auto const &M) { return M.eimic_real; }}, }; } @@ -73,8 +73,8 @@ TEST_CASE("speed control: the field shunting of the vehicles without a cruise co scenario scenario{std::string{"speed control/shunting/"} + path, motion() + traction() + cruise()}; scenario.add(path, 1); auto &loco{scenario.cab()}; - REQUIRE_FALSE(loco.SpeedCtrl); - REQUIRE_FALSE(loco.AutoRelayFlag); + REQUIRE_FALSE(loco.SpeedCtrl()); + REQUIRE_FALSE(loco.AutoRelayFlag()); REQUIRE(scenario.start_up()); scenario.get_going(); scenario.full_power(60.0); @@ -99,8 +99,8 @@ TEST_CASE("speed control: the field shunting of the vehicles without a cruise co scenario scenario{"speed control/shunting/su45_v2/301d", motion() + traction() + cruise()}; scenario.add("su45_v2/301d", 1); auto &loco{scenario.cab()}; - REQUIRE_FALSE(loco.SpeedCtrl); - REQUIRE(loco.AutoRelayFlag); + REQUIRE_FALSE(loco.SpeedCtrl()); + REQUIRE(loco.AutoRelayFlag()); REQUIRE(scenario.start_up()); scenario.get_going(); scenario.full_power(5.0); @@ -109,7 +109,7 @@ TEST_CASE("speed control: the field shunting of the vehicles without a cruise co scenario.wait(10.0); most = std::max(most, loco.ScndCtrlPos()); } - CHECK(most == loco.ScndCtrlPosNo); + CHECK(most == loco.ScndCtrlPosNo()); // the driver can't move it CHECK_FALSE(loco.DecScndCtrl(2)); CHECK_FALSE(loco.SpeedCtrlUnit.IsActive); @@ -126,8 +126,8 @@ TEST_CASE("speed control: the vehicles whose secondary controller is the cruise scenario scenario{"speed control/cruise/impuls_v1/31we-a_pr", motion() + traction() + cruise()}; scenario.add("impuls_v1/31we-a_pr", 1).add("impuls_v1/31we-b_pr").add("impuls_v1/31we-c_pr").add("impuls_v1/31we-d_pr"); auto &unit{scenario.cab()}; - REQUIRE(unit.SpeedCtrl); - REQUIRE(unit.ScndCtrlPosNo == 1); + REQUIRE(unit.SpeedCtrl()); + REQUIRE(unit.ScndCtrlPosNo() == 1); REQUIRE(scenario.start_up()); scenario.get_going(); scenario.full_power(40.0); @@ -151,9 +151,9 @@ TEST_CASE("speed control: the vehicles whose secondary controller is the cruise scenario scenario{"speed control/cruise/e186_v2/eu47", motion() + traction() + cruise()}; scenario.add("e186_v2/eu47", 1); auto &loco{scenario.cab()}; - REQUIRE(loco.SpeedCtrl); - REQUIRE(loco.SpeedCtrlTypeTime); - REQUIRE(loco.ScndCtrlPosNo == 4); + REQUIRE(loco.SpeedCtrl()); + REQUIRE(loco.SpeedCtrlTypeTime()); + REQUIRE(loco.ScndCtrlPosNo() == 4); REQUIRE(scenario.start_up()); scenario.get_going(); scenario.act("raise"); @@ -162,11 +162,11 @@ TEST_CASE("speed control: the vehicles whose secondary controller is the cruise } REQUIRE(loco.ScndCtrlPos() == 3); scenario.wait(10.0); - CHECK(loco.NewSpeed > 0.0); + CHECK(loco.NewSpeed() > 0.0); scenario.act("set"); CHECK(loco.DecScndCtrl(1)); scenario.wait(1.0); - CHECK(loco.SpeedCtrlValue == doctest::Approx(loco.NewSpeed)); + CHECK(loco.SpeedCtrlValue == doctest::Approx(loco.NewSpeed())); CHECK(loco.SpeedCtrlUnit.IsActive); scenario.full_power(60.0); CHECK(loco.Vel == doctest::Approx(loco.SpeedCtrlValue).epsilon(0.1)); @@ -185,9 +185,9 @@ TEST_CASE("speed control: the field shunting of the vehicles with a cruise contr scenario scenario{"speed control/both/6dg_v1/6dg", motion() + traction() + cruise(), test::track{}}; scenario.add("6dg_v1/6dg", 1); auto &loco{scenario.cab()}; - REQUIRE(loco.SpeedCtrl); - REQUIRE(loco.AutoRelayFlag); - REQUIRE(loco.ScndCtrlPosNo == 1); + REQUIRE(loco.SpeedCtrl()); + REQUIRE(loco.AutoRelayFlag()); + REQUIRE(loco.ScndCtrlPosNo() == 1); get_6dg_going(scenario); scenario.act("raise"); move_to(loco, dg_raise); @@ -209,8 +209,8 @@ TEST_CASE("speed control: the field shunting of the vehicles with a cruise contr scenario scenario{"speed control/both/st45_v2/301dd", motion() + traction() + cruise(), test::track{}}; scenario.add("st45_v2/301dd", 1); auto &loco{scenario.cab()}; - REQUIRE(loco.SpeedCtrl); - REQUIRE(loco.AutoRelayFlag); + REQUIRE(loco.SpeedCtrl()); + REQUIRE(loco.AutoRelayFlag()); REQUIRE(scenario.start_up()); scenario.get_going(); scenario.full_power(5.0); diff --git a/tests/unit/test_traction.cpp b/tests/unit/test_traction.cpp index 2073fae32..15b00e0fe 100644 --- a/tests/unit/test_traction.cpp +++ b/tests/unit/test_traction.cpp @@ -104,7 +104,7 @@ TEST_CASE("traction: the ET42 at the high current setting, its halves in series, CHECK(et42.CurrentSwitch(high) == high); // the relay takes the setting at the next step, with the controller at zero scenario.get_going(); - CHECK((et42.Imax == et42.ImaxHi) == high); + CHECK((et42.Imax == et42.ImaxHi()) == high); scenario.full_power(60.0); // at the high current setting the controller stops at the last series position: the halves' motors stay // in series, at half the voltage each, for a heavy start, and the train crawls @@ -154,7 +154,7 @@ TEST_CASE("traction: the field shunting relays of the diesel-electric locomotive CHECK(controlling.RelayType == relaytype); scenario.get_going(); scenario.full_power(120.0); - CHECK(controlling.ScndCtrlPos() == controlling.ScndCtrlPosNo); + CHECK(controlling.ScndCtrlPos() == controlling.ScndCtrlPosNo()); auto expected{shunting.begin()}; for (auto const position : {11, 10, 7, 3}) { CAPTURE(position); @@ -201,8 +201,8 @@ TEST_CASE("traction: the induction motor drive's speed control, its electrodynam scenario.get_going(); // the second controller of the EU47 sets the speed to hold (SpeedCtrlType=Time): position 2 keeps the speed // set, 3 raises it by 10 km/h every SpeedCtrlDelay, 4 sets the top speed, 1 lowers it, 0 drops it - REQUIRE(eu47.ScndCtrlPosNo == 4); - REQUIRE(eu47.SpeedCtrlTypeTime); + REQUIRE(eu47.ScndCtrlPosNo() == 4); + REQUIRE(eu47.SpeedCtrlTypeTime()); scenario.full_power(0.0); scenario.act("speed up"); for (int i = 0; i < 3; ++i) { @@ -227,7 +227,7 @@ TEST_CASE("traction: the induction motor drive's speed control, its electrodynam scenario.act("top speed"); eu47.IncScndCtrl(2); scenario.wait(5.0); - CHECK(eu47.SpeedCtrlValue == doctest::Approx(eu47.Vmax)); + CHECK(eu47.SpeedCtrlValue == doctest::Approx(eu47.Vmax())); scenario.act("speed control off"); while (eu47.DecScndCtrl(1)) { // down to zero diff --git a/tests/unit/test_uc_steps.cpp b/tests/unit/test_uc_steps.cpp index a25397b23..889774d48 100644 --- a/tests/unit/test_uc_steps.cpp +++ b/tests/unit/test_uc_steps.cpp @@ -56,7 +56,7 @@ bool on_step(double const Value, double const Step) { TEST_CASE("controls: the universal controller with CtrlValStep sets its power in whole steps") { test::track const line{0.15, 0.0}; vehicle railbus{definition::fiz("21xm_v1/214ma").set("UCList", "CtrlValStep", 0.05), 0.0, "test", 1}; - REQUIRE(railbus->UniCtrlValStep == doctest::Approx(0.05)); + REQUIRE(railbus->UniCtrlValStep() == doctest::Approx(0.05)); get_ready(railbus, line); // a tap on the raising position: one step at once, kept by the holding one @@ -104,7 +104,7 @@ TEST_CASE("controls: the universal controller with CtrlValStep sets its power in TEST_CASE("controls: the universal controller without CtrlValStep sets its power continuously, as before") { test::track const line{0.15, 0.0}; vehicle railbus{definition::fiz("21xm_v1/214ma"), 0.0, "test", 1}; - REQUIRE(railbus->UniCtrlValStep == 0.0); + REQUIRE(railbus->UniCtrlValStep() == 0.0); get_ready(railbus, line); // a tap moves it by 0.01, held it goes on at 0.15 a second after the initial delay move_to(railbus, raise); diff --git a/tests/unit/test_wheelslip.cpp b/tests/unit/test_wheelslip.cpp index 842eb31e2..934f40f05 100644 --- a/tests/unit/test_wheelslip.cpp +++ b/tests/unit/test_wheelslip.cpp @@ -22,7 +22,7 @@ braking_result brake_to_stop_then_stand(vehicle &Coach, track const &Braking, tr Coach.hold_brake_pipe(3.5); // service braking // a skidding wagon brakes on the sliding adhesion only, give it time for (auto step = 0; step < 60000; ++step) { // 600 s in 0.01 s steps - result.skidded |= Coach->SlippingWheels; + result.skidded |= Coach->SlippingWheels(); if (auto const speed{std::abs(Coach.speed())}; speed > 0.0 && speed < 0.1) { // almost stopped; a skidding wagon is still skidding at this point result.stopped = true; @@ -58,5 +58,5 @@ TEST_CASE("wheelslip: a wagon which stopped in a skid holds like one which stopp CHECK(std::abs(normal.speed()) < 0.1); CHECK(std::abs(skidding.speed()) < 0.1); - CHECK_FALSE(skidding->SlippingWheels); + CHECK_FALSE(skidding->SlippingWheels()); } diff --git a/tests/unit/vehicle.cpp b/tests/unit/vehicle.cpp index e508025d4..796005ddd 100644 --- a/tests/unit/vehicle.cpp +++ b/tests/unit/vehicle.cpp @@ -142,7 +142,7 @@ vehicle::vehicle(definition const &Definition, double Velocity, std::string cons // a driver keeps a vehicle on standby on its independent brake if (Cab != 0 && m_physics->brakes.config.localKind != TLocalBrake::ManualBrake && Velocity < 1.0) { m_physics->IncLocalBrakeLevel(LocalBrakePosNo); - if (m_physics->EIMCtrlEmergency) { + if (m_physics->EIMCtrlEmergency()) { m_physics->DecLocalBrakeLevel(1); } } @@ -240,16 +240,16 @@ double vehicle::move(track const &Track, double Dt, TLocation const &Location, d physics.brakes.equivalentPipePressure = Trainpipe; if (auto const diesel{physics.EngineType == DieselEngine || physics.EngineType == DieselElectric}; diesel && physics.EIMCtrlType > 0) { physics.CheckEIMIC(Dt); - if (physics.SpeedCtrl) { + if (physics.SpeedCtrl()) { physics.CheckSpeedCtrl(Dt); } - physics.eimic_real = std::min(physics.eimic, physics.eimicSpeedCtrl); + physics.eimic_real = std::min(physics.eimic, physics.eimicSpeedCtrl()); } if (physics.EngineType == ElectricInductionMotor) { // the share of the electric and pneumatic brake over the train (TDynamicObject's MED) isn't here physics.CheckEIMIC(Dt); physics.CheckSpeedCtrl(Dt); - physics.eimic_real = std::min(physics.eimic, physics.eimicSpeedCtrl); + physics.eimic_real = std::min(physics.eimic, physics.eimicSpeedCtrl()); } } diff --git a/utilities/motiontelemetry.cpp b/utilities/motiontelemetry.cpp index 8703cb41f..c263c23ea 100644 --- a/utilities/motiontelemetry.cpp +++ b/utilities/motiontelemetry.cpp @@ -100,7 +100,7 @@ void motiontelemetry::update() if (conf.fwdposbased) local_acc.z += glm::dot(acc, frontvector); else - local_acc.z += t->Occupied()->AccSVBased; + local_acc.z += t->Occupied()->AccSVBased(); local_acc /= 9.81; diff --git a/vehicle/ai/consist.cpp b/vehicle/ai/consist.cpp index 1de5dc1af..b982edce5 100644 --- a/vehicle/ai/consist.cpp +++ b/vehicle/ai/consist.cpp @@ -208,7 +208,7 @@ void TController::AutoRewident() if( OrderCurrentGet() & ( DriverOrder::obeyTrain | DriverOrder::bank ) ) { // 4. Przeliczanie siły hamowania - double const velstep = occupied->Vmax * 0.5 / BrakeAccTableSize; + double const velstep = occupied->Vmax() * 0.5 / BrakeAccTableSize; auto *d = pVehicles[0]; // pojazd na czele składu while (d) { // a vehicle with its brake cut out (by the inspector above or for a reason of its own) adds its mass only; @@ -334,8 +334,8 @@ bool TController::CheckVehicles(DriverOrders user) ++iVehicles; // jest jeden pojazd więcej pVehicles[VehicleEnd::rear] = p; // zapamiętanie ostatniego fLength += p->physics->Dim.L; // dodanie długości pojazdu - fMass += p->physics->TotalMass; // dodanie masy łącznie z ładunkiem - fVelMax = min_speed( fVelMax, p->physics->Vmax ); // ustalenie maksymalnej prędkości dla składu + fMass += p->physics->TotalMass(); // dodanie masy łącznie z ładunkiem + fVelMax = min_speed( fVelMax, p->physics->Vmax() ); // ustalenie maksymalnej prędkości dla składu // reset oerlikon brakes consist flag as different type was detected if( p->physics->brakes.config.subsystem != TBrakeSubSystem::ss_ESt && p->physics->brakes.config.subsystem != TBrakeSubSystem::ss_LSt ) { @@ -556,7 +556,7 @@ void TController::DirectionForward(bool forward) { // ustawienie jazdy do przodu dla true i do tyłu dla false (zależy od kabiny) ZeroSpeed( true ); // TODO: check if force switch is needed anymore here // HACK: make sure the master controller isn't set in position which prevents direction change - mvControlling->SetMainCtrlPos(std::min( mvControlling->MainCtrlPos(), mvControlling->MainCtrlMaxDirChangePos )); + mvControlling->SetMainCtrlPos(std::min( mvControlling->MainCtrlPos(), mvControlling->MainCtrlMaxDirChangePos() )); if( forward ) { // do przodu w obecnej kabinie @@ -574,7 +574,7 @@ void TController::DirectionForward(bool forward) iTableDirection = 0; } } - if( occupied->TrainType == train_type::sn61 ) { + if( occupied->TrainType() == train_type::sn61 ) { // specjalnie dla SN61 żeby nie zgasł while( mvControlling->RList[mvControlling->MainCtrlPos()].Mn == 0 && mvControlling->IncMainCtrl(1) ) { @@ -593,7 +593,7 @@ void TController::sync_consist_reversers() { auto const currentdirection { occupied->DirActive }; auto const fastforward { is_emu() && occupied->EngineType != TEngineType::ElectricInductionMotor - && occupied->Imin == occupied->IminHi }; + && occupied->Imin() == occupied->IminHi }; // move reverser all way in the opposite direction... for( auto idx = 0; idx < 3; ++idx ) { @@ -677,12 +677,12 @@ TController::determine_consist_state() { cue_action( driver_hint::cabactivation ); } else if (!occupied->AutomaticCabActivation - && ( occupied->CabActive == -occupied->CabOccupied() || !occupied->CabMaster || !occupied->lowVoltage.Is24vAvailable() ) ) + && ( occupied->CabActive == -occupied->CabOccupied() || !occupied->CabMaster() || !occupied->lowVoltage.Is24vAvailable() ) ) { cue_action( driver_hint::cabdeactivation ); } - int index = double(BrakeAccTableSize) * (occupied->Vel / occupied->Vmax); + int index = double(BrakeAccTableSize) * (occupied->Vel / occupied->Vmax()); index = std::min(BrakeAccTableSize, std::max(1, index)); fBrake_a0[0] = fBrake_a0[index]; fBrake_a1[0] = fBrake_a1[index]; @@ -716,7 +716,7 @@ TController::determine_consist_state() { { // sprawdzenie odhamowania wszystkich połączonych pojazdów auto *vehicle { p->physics }; auto const bp { std::max( 0.0, vehicle->brakes.cylinderPressure - ( vehicle->SpeedCtrlUnit.Parking ? vehicle->brakes.config.maxCylinderPressure[ 0 ] * vehicle->brakes.holding.deceleration : 0.0 ) ) }; - momentum += vehicle->TotalMass * vehicle->V() * ( p->DirectionGet() == iDirection ? 1 : -1 ); + momentum += vehicle->TotalMass() * vehicle->V() * ( p->DirectionGet() == iDirection ? 1 : -1 ); mostapplied = std::max( bp, mostapplied ); if( ( vehicle->brakes.config.kind != TBrakeSystem::Individual ) && ( vehicle->brakes.config.maxCylinderPressure[ 3 ] > 0.0 ) @@ -836,7 +836,7 @@ TController::determine_consist_state() { absaccs = 0; auto *d = pVehicles[ VehicleEnd::front ]; // pojazd na czele składu while( d ) { - absaccs += d->physics->TotalMass * d->physics->AccS() * ( d->DirectionGet() == iDirection ? 1 : -1 ); + absaccs += d->physics->TotalMass() * d->physics->AccS() * ( d->DirectionGet() == iDirection ? 1 : -1 ); d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } absaccs *= iDirection >= 0 ? 1 : -1; diff --git a/vehicle/ai/controls.cpp b/vehicle/ai/controls.cpp index e8cacff77..c996d3846 100644 --- a/vehicle/ai/controls.cpp +++ b/vehicle/ai/controls.cpp @@ -60,7 +60,7 @@ TController::increase_train_brake() { while (d) { // przeliczanie dodatkowego potrzebnego spadku ciśnienia if( ( d->physics->brakes.distributor->GetBrakeStatus() & b_dmg ) == 0 ) { - pos_corr -= ( std::min( 5.0, d->physics->brakes.distributor->GetCRP() ) - 5.0 ) * d->physics->TotalMass; + pos_corr -= ( std::min( 5.0, d->physics->brakes.distributor->GetCRP() ) - 5.0 ) * d->physics->TotalMass(); } d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła) } @@ -143,8 +143,8 @@ bool TController::IncBrake() } // NOTE: can't perform just test whether connected vehicle == nullptr, due to virtual couplers formed with nearby vehicles auto standalone { true }; - if( occupied->TrainType == train_type::et41 - || occupied->TrainType == train_type::et42 ) { + if( occupied->TrainType() == train_type::et41 + || occupied->TrainType() == train_type::et42 ) { // NOTE: we're doing simplified checks full of presuptions here. // they'll break if someone does strange thing like turning around the second unit if( occupied->Couplers[VehicleEnd::rear].CouplingFlag & Coupling::permanent @@ -236,7 +236,7 @@ bool TController::IncBrake() std::lerp( occupied->brakes.driverValve->GetPos( bh_EPR ), occupied->brakes.driverValve->GetPos( bh_EPB ), - std::clamp( -AccDesired / AccMax * occupied->AIHintLocalBrakeAccFactor, 0.0, 1.0 ) ) ); + std::clamp( -AccDesired / AccMax * occupied->AIHintLocalBrakeAccFactor(), 0.0, 1.0 ) ) ); OK = occupied->brakes.HandlePositionSmooth() != initialbrakeposition; } else if( occupied->brakes.HandlePositionSmooth() != occupied->brakes.driverValve->GetPos( bh_EPB ) ) { @@ -269,9 +269,9 @@ bool TController::IncBrakeEIM() { case 0: { if( occupied->brakes.blending.maxDeceleration != 9.81 ) { - auto const maxpos{occupied->EIMCtrlEmergency ? 0.9 : 1.0 }; + auto const maxpos{occupied->EIMCtrlEmergency() ? 0.9 : 1.0 }; auto const brakelimit{ -2.2 * AccDesired / fMedAmax - 1.0}; //additional limit when hinted is too low - auto const brakehinted{ -1.0 * occupied->AIHintLocalBrakeAccFactor * AccDesired / fMedAmax }; //preffered by AI + auto const brakehinted{ -1.0 * occupied->AIHintLocalBrakeAccFactor() * AccDesired / fMedAmax }; //preffered by AI auto const brakeposition{ maxpos * std::clamp(std::max(brakelimit, brakehinted), 0.0, 1.0)}; OK = brakeposition != occupied->brakes.IndependentPosition(); occupied->brakes.SetIndependentPosition(brakeposition); @@ -296,7 +296,7 @@ bool TController::IncBrakeEIM() break; } case 3: { - if( occupied->UniCtrlIntegratedLocalBrakeCtrl ) { + if( occupied->UniCtrlIntegratedLocalBrakeCtrl() ) { OK = occupied->MainCtrlPos() > 0; if( OK ) occupied->SetMainCtrlPos(0); @@ -398,7 +398,7 @@ bool TController::DecBrake() { std::lerp( occupied->brakes.driverValve->GetPos( bh_EPR ), occupied->brakes.driverValve->GetPos( bh_EPB ), - std::clamp( -AccDesired / AccMax * occupied->AIHintLocalBrakeAccFactor, 0.0, 1.0 ) ) ); + std::clamp( -AccDesired / AccMax * occupied->AIHintLocalBrakeAccFactor(), 0.0, 1.0 ) ) ); OK = occupied->brakes.HandlePositionSmooth() != initialbrakeposition; } else { @@ -437,7 +437,7 @@ void TController::LapBrake() { void TController::ZeroLocalBrake() { - if( occupied->UniCtrlIntegratedLocalBrakeCtrl ) { + if( occupied->UniCtrlIntegratedLocalBrakeCtrl() ) { while( DecBrakeEIM() ) { ; } @@ -455,7 +455,7 @@ bool TController::DecBrakeEIM() case 0: { if( occupied->brakes.blending.maxDeceleration != 9.81 ) { auto const desiredacceleration { ( occupied->Vel > EU07_AI_NOMOVEMENT ? AccDesired : std::max( 0.0, AccDesired ) ) }; - auto const brakeposition { std::clamp( -1.0 * occupied->AIHintLocalBrakeAccFactor * desiredacceleration / occupied->brakes.blending.maxDeceleration, 0.0, 1.0 ) }; + auto const brakeposition { std::clamp( -1.0 * occupied->AIHintLocalBrakeAccFactor() * desiredacceleration / occupied->brakes.blending.maxDeceleration, 0.0, 1.0 ) }; OK = brakeposition != occupied->brakes.IndependentPosition(); occupied->brakes.SetIndependentPosition(brakeposition); } @@ -478,9 +478,9 @@ bool TController::DecBrakeEIM() break; } case 3: { - OK = occupied->MainCtrlPos() < occupied->MainCtrlMaxDirChangePos; + OK = occupied->MainCtrlPos() < occupied->MainCtrlMaxDirChangePos(); if( OK ) - occupied->SetMainCtrlPos(occupied->MainCtrlMaxDirChangePos); + occupied->SetMainCtrlPos(occupied->MainCtrlMaxDirChangePos()); break; } } @@ -511,8 +511,8 @@ bool TController::IncSpeed() if (!IsAnyMotorOverloadRelayOpen && !mvControlling->protection.PressureSwitchTripped() && (mvControlling->IsMainCtrlNoPowerPos() || mvControlling->lineContactors.IsClosed()) && (Ready || drivingFlags.press)) { // youBy polecił dodać 2012-09-08 v367 // na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag) - auto const usehighoverloadrelaythreshold{mvControlling->TrainType != train_type::et42 // ET42 uses these variables for different purpose. TODO: fix this - && mvControlling->ImaxHi > mvControlling->ImaxLo && occupied->Vel < (mvControlling->IsMotorOverloadRelayHighThresholdOn() ? 30.0 : 20.0) && + auto const usehighoverloadrelaythreshold{mvControlling->TrainType() != train_type::et42 // ET42 uses these variables for different purpose. TODO: fix this + && mvControlling->ImaxHi() > mvControlling->ImaxLo() && occupied->Vel < (mvControlling->IsMotorOverloadRelayHighThresholdOn() ? 30.0 : 20.0) && iVehicles - ControlledEnginesCount > 0 // && ( std::fabs( mvControlling->Im ) > 0.85 * mvControlling->Imax ) && mvControlling->Imax * mvControlling->EngineVoltage * ControlledEnginesCount / @@ -524,14 +524,14 @@ bool TController::IncSpeed() // if the power station is heavily burdened, // if it generates enough traction force // to build up speed to 30/40 km/h for passenger/cargo train (10 km/h less if going uphill) - auto const sufficienttractionforce{std::abs(mvControlling->Ft) * ControlledEnginesCount > (IsHeavyCargoTrain ? 75 : 50) * 1000.0}; + auto const sufficienttractionforce{std::abs(mvControlling->Ft()) * ControlledEnginesCount > (IsHeavyCargoTrain ? 75 : 50) * 1000.0}; auto const sufficientacceleration{AbsAccS >= (IsHeavyCargoTrain ? 0.03 : IsCargoTrain ? 0.06 : 0.09)}; auto const seriesmodefieldshunting{mvControlling->ScndCtrlPos() > 0 && mvControlling->RList[mvControlling->MainCtrlPos()].Bn == 1}; auto const parallelmodefieldshunting{mvControlling->ScndCtrlPos() > 0 && mvControlling->RList[mvControlling->MainCtrlPos()].Bn > 1}; auto const minvoltage{(pantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? pantographUnit->EnginePowerSource.CollectorParameters.MinV : 0.0)}; auto const maxvoltage{(pantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? pantographUnit->EnginePowerSource.CollectorParameters.MaxV : 0.0)}; auto const seriesmodevoltage{std::lerp(minvoltage, maxvoltage, IsHeavyCargoTrain ? 0.35 : 0.40)}; - auto const useseriesmode = mvControlling->Imax > mvControlling->ImaxLo || true == usehighoverloadrelaythreshold || fVoltage < seriesmodevoltage || + auto const useseriesmode = mvControlling->Imax > mvControlling->ImaxLo() || true == usehighoverloadrelaythreshold || fVoltage < seriesmodevoltage || (true == sufficientacceleration && true == sufficienttractionforce && occupied->Vel <= (IsCargoTrain ? 40 : 30) + (seriesmodefieldshunting ? 5 : 0) - (fAccGravity < -0.025 ? 10 : 0)); // when not in series mode use the first available parallel mode configuration until 50/60 km/h for passenger/cargo train @@ -543,11 +543,11 @@ bool TController::IncSpeed() mvControlling->MainCtrlPos() == mvControlling->MainCtrlPosNo); // if needed enable high threshold for overload relay... - if (mvControlling->TrainType != train_type::et42) + if (mvControlling->TrainType() != train_type::et42) { // ET42 uses these variables for different purpose. TODO: fix this if (usehighoverloadrelaythreshold) { - if (mvControlling->Imax < mvControlling->ImaxHi) + if (mvControlling->Imax < mvControlling->ImaxHi()) { // to enable this setting we'll typically need the main controller in series mode (which is not guaranteed) if (mvControlling->RList[mvControlling->MainCtrlPos()].Bn > 1) @@ -567,7 +567,7 @@ bool TController::IncSpeed() // ...or disable high threshold for overload relay if no longer needed else { - if (mvControlling->IsMotorOverloadRelayHighThresholdOn() && std::fabs(mvControlling->Im) < mvControlling->ImaxLo) + if (mvControlling->IsMotorOverloadRelayHighThresholdOn() && std::fabs(mvControlling->Im) < mvControlling->ImaxLo()) { mvControlling->CurrentSwitch(false); // rozruch wysoki wyłącz } @@ -575,12 +575,12 @@ bool TController::IncSpeed() } double Vs = 99999; - if (usefieldshunting ? mvControlling->ScndCtrlPos() < mvControlling->ScndCtrlPosNo : mvControlling->MainCtrlPos() < mvControlling->MainCtrlPosNo) + if (usefieldshunting ? mvControlling->ScndCtrlPos() < mvControlling->ScndCtrlPosNo() : mvControlling->MainCtrlPos() < mvControlling->MainCtrlPosNo) { Vs = ESMVelocity(!usefieldshunting); } - if (std::abs(mvControlling->Im) < (fReady < 0.4 ? mvControlling->Imin : mvControlling->IminLo) || mvControlling->Vel > Vs) + if (std::abs(mvControlling->Im) < (fReady < 0.4 ? mvControlling->Imin() : mvControlling->IminLo) || mvControlling->Vel > Vs) { // Ra: wywalał nadmiarowy, bo Im może być ujemne; jak nie odhamowany, to nie przesadzać z prądem if (usefieldshunting) @@ -605,7 +605,7 @@ bool TController::IncSpeed() (mvControlling->RList[std::min(mvControlling->MainCtrlPos() + 1, mvControlling->MainCtrlPosNo)].Bn == 1 ? minvoltage : seriesmodevoltage) > (IsHeavyCargoTrain ? 100.0 : 75.0) * ControlledEnginesCount}; - OK = sufficientpowermargin && false == mvControlling->DelayCtrlFlag ? mvControlling->IncMainCtrl(1) : true; + OK = sufficientpowermargin && false == mvControlling->DelayCtrlFlag() ? mvControlling->IncMainCtrl(1) : true; // czekaj na 1 pozycji, zanim się nie włączą liniowe if (true == mvControlling->lineContactors.IsClosed()) { @@ -658,7 +658,7 @@ bool TController::IncSpeed() if( !IsAnyMotorOverloadRelayOpen && (Ready || drivingFlags.press || occupied->ShuntMode) ) { //{(BrakePress<=0.01*MaxBrakePress)} OK = IncSpeedEIM(); - if (mvControlling->SpeedCtrl && mvControlling->lineBreaker.IsClosed()) + if (mvControlling->SpeedCtrl() && mvControlling->lineBreaker.IsClosed()) { // cruise control auto const couplinginprogress{true == drivingFlags.connect && true == OrderCurrentGet().HasAll(DriverOrder::connect)}; @@ -679,7 +679,7 @@ bool TController::IncSpeed() case TEngineType::WheelsDriven: if (!mvControlling->CabActive) mvControlling->CabActivisation(); - if (sin(mvControlling->eAngle) > 0) + if (sin(mvControlling->eAngle()) > 0) mvControlling->IncMainCtrl(3 + 3 * floor(0.5 + fabs(AccDesired))); else mvControlling->DecMainCtrl(3 + 3 * floor(0.5 + fabs(AccDesired))); @@ -689,7 +689,7 @@ bool TController::IncSpeed() { // dla 2Ls150 można zmienić tryb pracy, jeśli jest w liniowym i nie daje rady (wymaga zerowania kierunku) // mvControlling->ShuntMode=(OrderList[OrderPos]&Shunt)||(fMass>224000.0); } - if (mvControlling->SpeedCtrl && mvControlling->lineBreaker.IsClosed()) {// cruise control + if (mvControlling->SpeedCtrl() && mvControlling->lineBreaker.IsClosed()) {// cruise control auto const couplinginprogress { true == drivingFlags.connect && true == OrderCurrentGet().HasAll(DriverOrder::connect) }; auto const SpeedCntrlVel { ( ActualProximityDist > std::max(50.0, fMaxProximityDist) || couplinginprogress ? @@ -708,7 +708,7 @@ bool TController::IncSpeed() if (true == Ready) { bool max = mvControlling->Vel > mvControlling->diesel.fullEngageMinVelocity - || (mvControlling->SpeedCtrl && mvControlling->ScndCtrlPos() > 0); + || (mvControlling->SpeedCtrl() && mvControlling->ScndCtrlPos() > 0); DizelPercentage = max ? 100 : 1; } break; @@ -774,7 +774,7 @@ bool TController::DecSpeed(bool force) case TEngineType::WheelsDriven: if (!mvControlling->CabActive) mvControlling->CabActivisation(); - if (sin(mvControlling->eAngle) < 0) + if (sin(mvControlling->eAngle()) < 0) mvControlling->IncMainCtrl(3 + 3 * floor(0.5 + fabs(AccDesired))); else mvControlling->DecMainCtrl(3 + 3 * floor(0.5 + fabs(AccDesired))); @@ -993,7 +993,7 @@ void TController::SpeedSet() { while( ( false == mvControlling->IsMainCtrlNoPowerPos() ) && ( mvControlling->RList[ mvControlling->MainCtrlPos() ].Bn > 1 ) ); // oporowa zapętla } - if( mvControlling->Imax < mvControlling->ImaxHi ) { // jeśli da się na wysokim + if( mvControlling->Imax < mvControlling->ImaxHi() ) { // jeśli da się na wysokim mvControlling->CurrentSwitch( true ); // rozruch wysoki (za to może się ślizgać) } if( ReactionTime > 0.1 ) { @@ -1012,7 +1012,7 @@ void TController::SpeedSet() { } // else // gdy nie jedzie ambitnie pod górę { // sprawdzenie, czy rozruch wysoki jest potrzebny - if( ( mvControlling->Imax > mvControlling->ImaxLo ) + if( ( mvControlling->Imax > mvControlling->ImaxLo() ) && ( occupied->Vel >= 30.0 ) ) { // jak się rozpędził // if (fAccGravity > -0.02) // a i pochylenie mnijsze niż 2‰ mvControlling->CurrentSwitch( false ); // rozruch wysoki wyłącz @@ -1040,7 +1040,7 @@ void TController::SpeedSet() { // jak prędkość większa niż procent maksymalnej na danym biegu, wrzucić wyższy if( velocity > 0.75 * motorparams.mfi ) { // ...presuming there is a higher gear - if( mvControlling->ScndCtrlPos() < mvControlling->ScndCtrlPosNo ) { + if( mvControlling->ScndCtrlPos() < mvControlling->ScndCtrlPosNo() ) { mvControlling->DecMainCtrl( 2 ); while( mvControlling->IncScndCtrl(1) && mvControlling->MotorParam[mvControlling->ScndCtrlPos()].mIsat == 0.0 ) { // jeśli bieg jałowy to kolejny @@ -1069,7 +1069,7 @@ void TController::SpeedSet() { void TController::SpeedCntrl(double DesiredSpeed) { - if( false == mvControlling->SpeedCtrl ) { return; } + if( false == mvControlling->SpeedCtrl() ) { return; } if (mvControlling->IsSpeedCtrlSeparate()) { @@ -1092,14 +1092,14 @@ void TController::SpeedCntrl(double DesiredSpeed) mvControlling->RunCommand(VehicleCommand::speedControl, DesiredSpeed, mvControlling->CabActive); } else - if (mvControlling->ScndCtrlPosNo == 1) + if (mvControlling->ScndCtrlPosNo() == 1) { mvControlling->IncScndCtrl(1); mvControlling->RunCommand(VehicleCommand::speedControl, DesiredSpeed, mvControlling->CabActive); } - else if (mvControlling->ScndCtrlPosNo > 1 && !occupied->SpeedCtrlTypeTime) + else if (mvControlling->ScndCtrlPosNo() > 1 && !occupied->SpeedCtrlTypeTime()) { - int DesiredPos = 1 + mvControlling->ScndCtrlPosNo * ((DesiredSpeed - 1.0) / mvControlling->Vmax); + int DesiredPos = 1 + mvControlling->ScndCtrlPosNo() * ((DesiredSpeed - 1.0) / mvControlling->Vmax()); while( mvControlling->ScndCtrlPos() > DesiredPos && true == mvControlling->DecScndCtrl(1) ) { ; } // all work is done in the condition loop while( mvControlling->ScndCtrlPos() < DesiredPos && true == mvControlling->IncScndCtrl(1) ) { ; } // all work is done in the condition loop } @@ -1175,24 +1175,24 @@ void TController::SetTimeControllers() } } */ - if( occupied->UniCtrlIntegratedLocalBrakeCtrl + if( occupied->UniCtrlIntegratedLocalBrakeCtrl() && occupied->brakes.IndependentPosition() > 0.95 ) { while( IncBrakeEIM() ) { ; } } //4. Check Speed Control System - if (occupied->EngineType == TEngineType::ElectricInductionMotor && occupied->ScndCtrlPosNo > 1 && occupied->SpeedCtrlTypeTime) + if (occupied->EngineType == TEngineType::ElectricInductionMotor && occupied->ScndCtrlPosNo() > 1 && occupied->SpeedCtrlTypeTime()) { double SpeedCntrlVel = ActualProximityDist > std::max(50.0, fMaxProximityDist) ? VelDesired : min_speed(VelDesired, VelNext); SpeedCntrlVel = 10 * std::floor(SpeedCntrlVel*0.1); - if (occupied->ScndCtrlPosNo == 4) + if (occupied->ScndCtrlPosNo() == 4) { - if (occupied->NewSpeed + 0.1 < SpeedCntrlVel) + if (occupied->NewSpeed() + 0.1 < SpeedCntrlVel) occupied->SetScndCtrlPos(3); - if (occupied->NewSpeed - 0.1 > SpeedCntrlVel) + if (occupied->NewSpeed() - 0.1 > SpeedCntrlVel) occupied->SetScndCtrlPos(1); } } @@ -1202,19 +1202,19 @@ void TController::SetTimeControllers() { DizelPercentage_Speed = DizelPercentage; //wstepnie procenty - auto MinVel{ std::min(mvControlling->torqueConverter.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->SpeedCtrl() && mvControlling->ScndCtrlPos() > 0) { if (mvControlling->ScndCtrlPos() > 0 && mvControlling->Vel < 1 + mvControlling->SpeedCtrlUnit.StartVelocity && DizelPercentage > 0) DizelPercentage_Speed = 101; //keep last position to start } else if (VelDesired > MinVel) //more power for faster ride { - auto const Factor{ 10 * mvControlling->Vmax / (mvControlling->Vmax + 3 * mvControlling->Vel) }; + auto const Factor{ 10 * mvControlling->Vmax() / (mvControlling->Vmax() + 3 * mvControlling->Vel) }; auto DesiredPercentage{ std::clamp( VelDesired > mvControlling->Vel ? (VelDesired - mvControlling->Vel) / Factor : 0, 0.0, 1.0) }; //correction for reaching desired velocity - if (VelDesired < 0.5 * mvControlling->Vmax //low velocity and reaching desired + if (VelDesired < 0.5 * mvControlling->Vmax() //low velocity and reaching desired && VelDesired - mvControlling->Vel < 10) { DesiredPercentage = std::min(DesiredPercentage, 0.75); } @@ -1258,18 +1258,18 @@ void TController::SetTimeControllers() } else //5.2. Analog direct controller - if (mvControlling->EngineType == TEngineType::DieselEngine && mvControlling->Vmax > 30) + if (mvControlling->EngineType == TEngineType::DieselEngine && mvControlling->Vmax() > 30) { int MaxPos = mvControlling->MainCtrlPosNo; int MinPos = MaxPos; for (int i = MaxPos; i > 1 && mvControlling->RList[i].Mn > 0; i--) MinPos = i; if (MaxPos > MinPos && mvControlling->MainCtrlPos() > 0 && AccDesired > 0) { - double Factor = 5 * mvControlling->Vmax / (mvControlling->Vmax + mvControlling->Vel); + double Factor = 5 * mvControlling->Vmax() / (mvControlling->Vmax() + mvControlling->Vel); int DesiredPos = MinPos + (MaxPos - MinPos)*(VelDesired > mvControlling->Vel ? (VelDesired - mvControlling->Vel) / Factor : 0); if (DesiredPos > MaxPos) DesiredPos = MaxPos; if (DesiredPos < MinPos) DesiredPos = MinPos; - if (!mvControlling->SlippingWheels) + if (!mvControlling->SlippingWheels()) { while (mvControlling->MainCtrlPos() > DesiredPos) mvControlling->DecMainCtrl(1); if (mvControlling->Vel>mvControlling->diesel.fullEngageMinVelocity) @@ -1361,7 +1361,7 @@ void TController::CheckTimeControllers() } } //4. Check Speed Control System - if (occupied->EngineType == TEngineType::ElectricInductionMotor && occupied->ScndCtrlPosNo > 1 && occupied->SpeedCtrlTypeTime && occupied->ScndCtrlPosNo == 4) + if (occupied->EngineType == TEngineType::ElectricInductionMotor && occupied->ScndCtrlPosNo() > 1 && occupied->SpeedCtrlTypeTime() && occupied->ScndCtrlPosNo() == 4) { occupied->SetScndCtrlPos(2); } diff --git a/vehicle/ai/driver.cpp b/vehicle/ai/driver.cpp index 5c5d33bf7..544c7e7e0 100644 --- a/vehicle/ai/driver.cpp +++ b/vehicle/ai/driver.cpp @@ -89,7 +89,7 @@ TController::TController(bool AI, TDynamicObject *NewControll, bool InitPsyche, fAccThreshold = is_emu() ? -0.55 : is_dmu() ? -0.45 : -0.2; /* // HACK: emu with induction motors need to start their braking a bit sooner than the ones with series motors - if( ( occupied->TrainType == train_type::emu ) + if( ( occupied->TrainType() == train_type::emu ) && ( mvControlling->EngineType == TEngineType::ElectricInductionMotor ) ) { fAccThreshold += 0.10; } @@ -281,7 +281,7 @@ double TController::BrakeAccFactor() const Factor += fBrakeReaction * (/*occupied->BrakeCtrlPosR*/ BrakeCtrlPosition < 0.5 ? 1.5 : 1) * occupied->Vel / ( std::max( 0.0, ActualProximityDist ) + 1 ) * ( ( AccDesired - AbsAccS ) / fAccThreshold ); } /* - if (occupied->TrainType == train_type::dmu && occupied->Vel > 40 && VelNext<40) + if (occupied->TrainType() == train_type::dmu && occupied->Vel > 40 && VelNext<40) Factor *= 1 + 0.25 * ( (1600 - VelNext * VelNext) / (occupied->Vel * occupied->Vel) ); */ return Factor; @@ -569,10 +569,10 @@ bool TController::is_car() const { return TestFlag( occupied->CategoryFlag, 2 ); } bool TController::is_emu() const { - return mvControlling->TrainType == train_type::emu; } + return mvControlling->TrainType() == train_type::emu; } bool TController::is_dmu() const { - return mvControlling->TrainType == train_type::dmu; } + return mvControlling->TrainType() == train_type::dmu; } bool TController::has_diesel_engine() const { return mvControlling->EngineType == TEngineType::DieselElectric || mvControlling->EngineType == TEngineType::DieselEngine; } diff --git a/vehicle/ai/force.cpp b/vehicle/ai/force.cpp index 338e8a0d6..2f0f80812 100644 --- a/vehicle/ai/force.cpp +++ b/vehicle/ai/force.cpp @@ -80,7 +80,7 @@ TController::control_tractive_and_braking_force() { return; // ...and don't touch any other controls } // if we're slipping leave the controls alone, there's a separate logic section trying to deal with it - if( true == mvControlling->SlippingWheels ) { + if( true == mvControlling->SlippingWheels() ) { return; } @@ -107,8 +107,8 @@ void TController::control_field_shunting() { if( aiControlled && mvControlling->EngineType == TEngineType::DieselElectric - && fieldshunting::has_switch( mvControlling->AutoRelayType, mvControlling->FieldShuntSwitch ) - && false == mvControlling->AutoRelayFlag ) { + && fieldshunting::has_switch( mvControlling->AutoRelayType(), mvControlling->FieldShuntSwitch() ) + && false == mvControlling->AutoRelayFlag() ) { mvControlling->AutoRelaySwitch( true ); } } @@ -216,7 +216,7 @@ void TController::control_uphill_start() { uphillStart.tractiveForce = 0.0; for( auto const *vehicle { pVehicles[ VehicleEnd::front ] }; vehicle != nullptr; vehicle = vehicle->Next() ) { // Ft is signed in the vehicle's own frame, and turned into the direction of travel as AbsAccS is - uphillStart.tractiveForce += std::max( 0.0, vehicle->physics->Ft * ( vehicle->DirectionGet() == iDirection ? 1 : -1 ) * ( iDirection >= 0 ? 1 : -1 ) ); + uphillStart.tractiveForce += std::max( 0.0, vehicle->physics->Ft() * ( vehicle->DirectionGet() == iDirection ? 1 : -1 ) * ( iDirection >= 0 ? 1 : -1 ) ); } uphillStart.holdingForce = fMass * -fAccGravity; uphill_start::situation const now { diff --git a/vehicle/ai/physicslog.cpp b/vehicle/ai/physicslog.cpp index a3526b117..0826b5226 100644 --- a/vehicle/ai/physicslog.cpp +++ b/vehicle/ai/physicslog.cpp @@ -65,11 +65,11 @@ std::string TController::physicslog_line() const { std::ostringstream line; line << std::fixed << std::setprecision( 4 ) << ElapsedTime << " " - << fabs(11.31 * occupied->WheelDiameter * occupied->nrot) << " " + << fabs(11.31 * occupied->WheelDiameter() * occupied->nrot()) << " " << mvControlling->AccS() << " " << occupied->Couplers[1].Dist << " " << occupied->Couplers[1].CForce << " " - << occupied->Ft << " " + << occupied->Ft() << " " << occupied->Ff << " " << occupied->Fb << " " << occupied->brakes.cylinderPressure << " " @@ -84,7 +84,7 @@ std::string TController::physicslog_line() const { << occupied->CommandIn.Value1 << " " << occupied->CommandIn.Value2 << " " << int(mvControlling->SecuritySystem.is_blinking()) << " " - << int(mvControlling->SlippingWheels) << " " + << int(mvControlling->SlippingWheels()) << " " << mvControlling->diesel.heat.Ts << " " << mvControlling->diesel.heat.To << " " << mvControlling->diesel.heat.temperatura1 << " " @@ -114,7 +114,7 @@ void TController::PhysicsLog() #endif #if LOGPRESS == 1 std::ostringstream line; - line << ElapsedTime << "\t" << fabs(11.31 * occupied->WheelDiameter * occupied->nrot) + line << ElapsedTime << "\t" << fabs(11.31 * occupied->WheelDiameter() * occupied->nrot()) << "\t"; line << mvControlling->AccS() << "\t"; line << occupied->brakePipe.Pressure() << "\t" << occupied->brakes.controlReservoirPressure << "\t" diff --git a/vehicle/ai/situation.cpp b/vehicle/ai/situation.cpp index abc3af4f6..8d99a00ad 100644 --- a/vehicle/ai/situation.cpp +++ b/vehicle/ai/situation.cpp @@ -99,7 +99,7 @@ TController::control_wheelslip() { // wheels grip again, the next notch slips again, and a heavy train on poor rails slips, grips and snatches over // and over, and may never get going (#187). a vehicle without sand starts as before auto const velocity { std::abs( occupied->Vel ) }; - if( mvControlling->SlippingWheels + if( mvControlling->SlippingWheels() && velocity < EU07_AI_SANDEDSTARTVELOCITY && false == mvControlling->IsMainCtrlNoPowerPos() && mvControlling->Sand > 0.0 ) { @@ -110,7 +110,7 @@ TController::control_wheelslip() { sandedStart.active = false; } // wheel slip - if( mvControlling->SlippingWheels ) { + if( mvControlling->SlippingWheels() ) { cue_action( driver_hint::sandingon ); // piasku! if( false == sandedStart.active ) { cue_action( driver_hint::tractiveforcedecrease ); @@ -125,13 +125,13 @@ TController::control_wheelslip() { cue_action( driver_hint::brakingforcedecrease ); ++iDriverFailCount; } - else if( ( std::fabs( mvControlling->Im ) > 0.75 * mvControlling->ImaxHi ) + else if( ( std::fabs( mvControlling->Im ) > 0.75 * mvControlling->ImaxHi() ) || ( sandedStart.active && false == mvControlling->IsMainCtrlNoPowerPos() ) ) { cue_action( driver_hint::sandingon ); // piaskujemy tory, coby się nie ślizgać } else { // deactivate sandbox if we aren't slipping - if( mvControlling->SandDose ) { + if( mvControlling->SandDose() ) { cue_action( driver_hint::sandingoff ); } } @@ -160,14 +160,14 @@ TController::control_pantographs() { // or the vehicle isn't shunting auto const shuntpantographsetup { OrderCurrentGet().HasAny( DriverOrder::shunt | DriverOrder::looseShunt ) ? - occupied->AIHintShuntPantstate : + occupied->AIHintShuntPantstate() : 0 }; // raise/lower pantographs as needed auto const useregularpantographlayout { pVehicle->Next(Coupling::control) == nullptr // standalone || is_emu() // special case - || mvControlling->TrainType == train_type::et41 }; // special case + || mvControlling->TrainType() == train_type::et41 }; // special case if( occupied->Vel > EU07_AI_NOMOVEMENT ) { @@ -193,7 +193,7 @@ TController::control_pantographs() { // shunting with the pantograph setup the .fiz suggests for it control_pantographs_setup( shuntpantographsetup ); } - else if( occupied->AIHintPantstate == 0 ) { + else if( occupied->AIHintPantstate() == 0 ) { // jazda na tylnym if( iDirection >= 0 && useregularpantographlayout ) { // jak jedzie w kierunku sprzęgu 0 @@ -236,7 +236,7 @@ TController::control_pantographs() { else { // use suggested pantograph setup if( occupied->Vel > 5 ) { - auto const pantographsetup{ occupied->AIHintPantstate }; + auto const pantographsetup{ occupied->AIHintPantstate() }; cue_action( pantographsetup & 1 << 0 ? driver_hint::frontpantographvalveon : driver_hint::frontpantographvalveoff ); cue_action( @@ -404,7 +404,7 @@ TController::control_handles() { case TEngineType::ElectricSeriesMotor: { // styczniki liniowe rozłączone yBARC if( false == mvControlling->lineContactors.IsClosed() - && false == mvControlling->DelayCtrlFlag + && false == mvControlling->DelayCtrlFlag() && mvControlling->MainCtrlPowerPos() > 1 ) { cue_action( driver_hint::mastercontrollersetzerospeed ); } @@ -428,7 +428,7 @@ TController::control_handles() { case TEngineType::DieselElectric: { // styczniki liniowe rozłączone yBARC if( false == mvControlling->lineContactors.IsClosed() - && false == mvControlling->DelayCtrlFlag + && false == mvControlling->DelayCtrlFlag() && mvControlling->MainCtrlPowerPos() > 1 ) { cue_action( driver_hint::mastercontrollersetzerospeed ); } diff --git a/vehicle/ai/speed.cpp b/vehicle/ai/speed.cpp index 3d758d35c..45b3cddc2 100644 --- a/vehicle/ai/speed.cpp +++ b/vehicle/ai/speed.cpp @@ -100,7 +100,7 @@ double TController::ESMVelocity(bool Main) for (int i = 0; i < 5; i++) { MS = mvControlling->MomentumF(IF, IF, SCPN); - Fmax = MS * mvControlling->RList[MCPN].Bn * mvControlling->RList[MCPN].Mn * 2 / mvControlling->WheelDiameter * mvControlling->Transmision.Ratio; + Fmax = MS * mvControlling->RList[MCPN].Bn * mvControlling->RList[MCPN].Mn * 2 / mvControlling->WheelDiameter() * mvControlling->Transmision.Ratio; if( Fmax != 0.0 ) { IF = 0.5 * IF * ( 1 + FrictionMax / Fmax ); } @@ -111,14 +111,14 @@ double TController::ESMVelocity(bool Main) } } IF = std::min(IF, mvControlling->Imax*fCurrentCoeff); - double R = mvControlling->RList[MCPN].R + mvControlling->CircuitRes + mvControlling->RList[MCPN].Mn*mvControlling->WindingRes; + double R = mvControlling->RList[MCPN].R + mvControlling->CircuitRes + mvControlling->RList[MCPN].Mn*mvControlling->WindingRes(); // SCPN may come from the .fiz (RList ScndAct) unchecked: read it with the bounds-safe accessor, as MomentumF() does auto const &motorparam{mvControlling->motor_param(SCPN)}; double pole = motorparam.fi * std::max(abs(IF) / (abs(IF) + motorparam.Isat) - motorparam.fi0, 0.0); double Us = abs(mvControlling->EngineVoltage) - IF*R; double ns = std::max(0.0, Us / (pole*mvControlling->RList[MCPN].Mn)); - ESMVel = ns * mvControlling->WheelDiameter*M_PI*3.6/mvControlling->Transmision.Ratio; + ESMVel = ns * mvControlling->WheelDiameter()*M_PI*3.6/mvControlling->Transmision.Ratio; return ESMVel; } @@ -493,7 +493,7 @@ TController::adjust_desired_speed_for_braking_curve( double const Vel ) { VelNext * braking_distance_multiplier( static_cast( VelNext ) ) ); // both plans of a pneumatic brake are made from the brake table of the consist; with none (in shunting it isn't // worked out) the braking curve is the constant deceleration over the distance left, as before them - braking_curve::brake_table const braketable { fBrake_a0, fBrake_a1, BrakeAccTableSize, occupied->Vmax }; + braking_curve::brake_table const braketable { fBrake_a0, fBrake_a1, BrakeAccTableSize, occupied->Vmax() }; // making for a passenger stop only the time the brake takes to fill: the look-ahead the horizon // keeps as its floor was set for the stops at a signal, and a vehicle that brakes with its // independent brake, which leaves the train brake handle where it is, kept braking earlier @@ -564,7 +564,7 @@ TController::adjust_desired_speed_for_final_approach( double const Vel ) { // cast iron blocks grip harder as the train comes to a stand braking_curve::shaped_demand( Vel, VelNext, stoppingroom, fAccGravity, - { fBrake_a0, fBrake_a1, BrakeAccTableSize, occupied->Vmax } ) : + { fBrake_a0, fBrake_a1, BrakeAccTableSize, occupied->Vmax() } ) : ( VelNext * VelNext - Vel * Vel ) / ( 25.92 * stoppingroom ) ); if( ( fAccGravity < -0.025 ) && ( AccDesired >= fAccGravity - 0.001 ) // no brake needed at all diff --git a/vehicle/brakesetting.cpp b/vehicle/brakesetting.cpp index 0d17d4311..7677ff19a 100644 --- a/vehicle/brakesetting.cpp +++ b/vehicle/brakesetting.cpp @@ -258,7 +258,7 @@ vehicle describe(physics::Vehicle const &Vehicle, bool const Driven) { // a locomotive has Power > 1, though it may be a dead one at the end of the train described.powered = Vehicle.Power >= 1.0; described.length = Vehicle.Dim.L; - described.mass = Vehicle.TotalMass; + described.mass = Vehicle.TotalMass(); described.cut_out = is_cut_out(Vehicle) && false == Vehicle.brakes.cutOutByInspector; described.driven = Driven; return described; diff --git a/vehicle/cab/auxiliarycommands.cpp b/vehicle/cab/auxiliarycommands.cpp index fa0482117..61d419fc6 100644 --- a/vehicle/cab/auxiliarycommands.cpp +++ b/vehicle/cab/auxiliarycommands.cpp @@ -629,7 +629,7 @@ void TTrain::OnCommand_watercircuitslinktoggle(TTrain *Train, command_data const if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->controlled->WaterCircuitsLink) + if (false == Train->controlled->WaterCircuitsLink()) { // turn on OnCommand_watercircuitslinkenable(Train, Command); @@ -650,7 +650,7 @@ void TTrain::OnCommand_watercircuitslinkenable(TTrain *Train, command_data const // visual feedback Train->ggWaterCircuitsLinkButton.UpdateValue(1.0, Train->dsbSwitch); - if (true == Train->controlled->WaterCircuitsLink) + if (true == Train->controlled->WaterCircuitsLink()) { return; } // already enabled @@ -667,7 +667,7 @@ void TTrain::OnCommand_watercircuitslinkdisable(TTrain *Train, command_data cons // visual feedback Train->ggWaterCircuitsLinkButton.UpdateValue(0.0, Train->dsbSwitch); - if (false == Train->controlled->WaterCircuitsLink) + if (false == Train->controlled->WaterCircuitsLink()) { return; } // already disabled diff --git a/vehicle/cab/brakecommands.cpp b/vehicle/cab/brakecommands.cpp index 19085f5e5..afb3a6fd4 100644 --- a/vehicle/cab/brakecommands.cpp +++ b/vehicle/cab/brakecommands.cpp @@ -186,7 +186,7 @@ void TTrain::OnCommand_independentbrakebailoff(TTrain *Train, command_data const { // TODO: check if this set of conditions can be simplified. // it'd be more flexible to have an attribute indicating whether bail off position is supported - if (Train->controlled->TrainType != train_type::emu && + if (Train->controlled->TrainType() != train_type::emu && (Train->controlled->EngineType == TEngineType::ElectricSeriesMotor || Train->controlled->EngineType == TEngineType::DieselElectric || Train->controlled->EngineType == TEngineType::ElectricInductionMotor) && Train->occupied->brakes.config.handlePositions > 0) @@ -722,7 +722,7 @@ void TTrain::OnCommand_epbrakecontroltoggle(TTrain *Train, command_data const &C if (istoggle) { // switch state - if (false == Train->occupied->EpFuse) + if (false == Train->occupied->EpFuse()) { // turn on // audio feedback @@ -748,7 +748,7 @@ void TTrain::OnCommand_epbrakecontroltoggle(TTrain *Train, command_data const &C } // visual feedback Train->ggEPFuseButton.UpdateValue(ispush ? 1.0f : // push or pushtoggle - Train->occupied->EpFuse ? 1.0f : + Train->occupied->EpFuse() ? 1.0f : 0.0f, // toggle Train->dsbSwitch); } @@ -916,7 +916,7 @@ void TTrain::OnCommand_mubrakingindicatortoggle(TTrain *Train, command_data cons } return; } - if (Train->controlled->TrainType != train_type::emu) + if (Train->controlled->TrainType() != train_type::emu) { // return; diff --git a/vehicle/cab/cabcommands.cpp b/vehicle/cab/cabcommands.cpp index 6d385f9d8..b51c7a03d 100644 --- a/vehicle/cab/cabcommands.cpp +++ b/vehicle/cab/cabcommands.cpp @@ -265,7 +265,7 @@ void TTrain::OnCommand_alerteracknowledge(TTrain *Train, command_data const &Com // visual feedback Train->ggSecurityResetButton.UpdateValue(1.0, Train->dsbSwitch); - if (Train->occupied->TrainType == train_type::emu || Train->occupied->DirActive != 0) + if (Train->occupied->TrainType() == train_type::emu || Train->occupied->DirActive != 0) Train->occupied->SecuritySystem.acknowledge_press(); } else if (Command.action == GLFW_RELEASE) @@ -273,7 +273,7 @@ void TTrain::OnCommand_alerteracknowledge(TTrain *Train, command_data const &Com // visual feedback Train->ggSecurityResetButton.UpdateValue(0.0); - if (Train->occupied->TrainType == train_type::emu || Train->occupied->DirActive != 0) + if (Train->occupied->TrainType() == train_type::emu || Train->occupied->DirActive != 0) Train->occupied->SecuritySystem.acknowledge_release(); } } diff --git a/vehicle/cab/controllercommands.cpp b/vehicle/cab/controllercommands.cpp index 469030669..2d9a402c3 100644 --- a/vehicle/cab/controllercommands.cpp +++ b/vehicle/cab/controllercommands.cpp @@ -87,7 +87,7 @@ void TTrain::OnCommand_jointcontrollerset(TTrain *Train, command_data const &Com if (Command.param1 >= 0.5) { Train->set_master_controller((Command.param1 * 2 - 1) * - (Train->controlled->CoupledCtrl ? Train->controlled->MainCtrlPosNo + Train->controlled->ScndCtrlPosNo : Train->controlled->MainCtrlPosNo)); + (Train->controlled->CoupledCtrl ? Train->controlled->MainCtrlPosNo + Train->controlled->ScndCtrlPosNo() : Train->controlled->MainCtrlPosNo)); Train->m_mastercontrollerinuse = true; // when SplitEDPneumaticBrake is active the joint controller's negative range // commands the dedicated dynamic-brake lever instead of the local pneumatic brake @@ -426,7 +426,7 @@ void TTrain::OnCommand_notchingrelaytoggle(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (false == Train->occupied->AutoRelayFlag) + if (false == Train->occupied->AutoRelayFlag()) { // turn on Train->occupied->AutoRelaySwitch(true); @@ -437,7 +437,7 @@ void TTrain::OnCommand_notchingrelaytoggle(TTrain *Train, command_data const &Co Train->occupied->AutoRelaySwitch(false); } // visual feedback - Train->ggAutoRelayButton.UpdateValue(Train->occupied->AutoRelayFlag ? 1.f : 0.f, Train->dsbSwitch); + Train->ggAutoRelayButton.UpdateValue(Train->occupied->AutoRelayFlag() ? 1.f : 0.f, Train->dsbSwitch); } } @@ -638,7 +638,7 @@ void TTrain::OnCommand_secondcontrollerdecreasefast(TTrain *Train, command_data void TTrain::OnCommand_secondcontrollerset(TTrain *Train, command_data const &Command) { - auto const targetposition{std::min(static_cast(Command.param1), Train->controlled->ScndCtrlPosNo)}; + auto const targetposition{std::min(static_cast(Command.param1), Train->controlled->ScndCtrlPosNo())}; // HACK: potentially animate push or pushtoggle control if (Train->ggScndCtrl.is_push()) { diff --git a/vehicle/cab/lightcommands.cpp b/vehicle/cab/lightcommands.cpp index edcbcef40..6976f6595 100644 --- a/vehicle/cab/lightcommands.cpp +++ b/vehicle/cab/lightcommands.cpp @@ -822,7 +822,7 @@ void TTrain::OnCommand_headlightdisablerearupper(TTrain *Train, command_data con void TTrain::OnCommand_modernlightdimmerincrease(TTrain *Train, command_data const &Command) { - if (!Train->occupied->enableModernDimmer) + if (!Train->occupied->enableModernDimmer()) return; // if modern dimmer is disabled, skip entire command if (Command.action == GLFW_PRESS) { @@ -841,7 +841,7 @@ void TTrain::OnCommand_modernlightdimmerincrease(TTrain *Train, command_data con } void TTrain::OnCommand_modernlightdimmerdecrease(TTrain *Train, command_data const &Command) { - if (!Train->occupied->enableModernDimmer) + if (!Train->occupied->enableModernDimmer()) return; // jeśli dimmer jest wyłączony, olewamy if (Command.action == GLFW_PRESS) @@ -1048,7 +1048,7 @@ void TTrain::OnCommand_endsignalstoggle(TTrain * /*Train*/, command_data const & void TTrain::OnCommand_headlightsdimtoggle(TTrain *Train, command_data const &Command) { - if (Train->DynamicObject->physics->enableModernDimmer) + if (Train->DynamicObject->physics->enableModernDimmer()) return; if (Command.action == GLFW_PRESS) { @@ -1069,7 +1069,7 @@ void TTrain::OnCommand_headlightsdimtoggle(TTrain *Train, command_data const &Co void TTrain::OnCommand_headlightsdimenable(TTrain *Train, command_data const &Command) { - if (Train->DynamicObject->physics->enableModernDimmer) + if (Train->DynamicObject->physics->enableModernDimmer()) return; if (Command.action == GLFW_PRESS) { @@ -1097,7 +1097,7 @@ void TTrain::OnCommand_headlightsdimenable(TTrain *Train, command_data const &Co void TTrain::OnCommand_headlightsdimdisable(TTrain *Train, command_data const &Command) { - if (Train->DynamicObject->physics->enableModernDimmer) // nie wiem dlaczego to tak dziala ze jest odwrocona logika + if (Train->DynamicObject->physics->enableModernDimmer()) // nie wiem dlaczego to tak dziala ze jest odwrocona logika return; if (Command.action == GLFW_PRESS) { diff --git a/vehicle/cab/powercommands.cpp b/vehicle/cab/powercommands.cpp index a48f1dc66..1aed10feb 100644 --- a/vehicle/cab/powercommands.cpp +++ b/vehicle/cab/powercommands.cpp @@ -468,7 +468,7 @@ void TTrain::OnCommand_motorconnectorsclose(TTrain *Train, command_data const &C void TTrain::OnCommand_motordisconnect(TTrain *Train, command_data const &Command) { - if (Train->controlled->TrainType == train_type::emu ? Train->controlled != Train->occupied : Train->iCabn != 0) + if (Train->controlled->TrainType() == train_type::emu ? Train->controlled != Train->occupied : Train->iCabn != 0) { // tylko w maszynowym return; @@ -485,7 +485,7 @@ void TTrain::OnCommand_motoroverloadrelaythresholdtoggle(TTrain *Train, command_ if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - if (true == Train->controlled->ShuntModeAllow ? false == Train->controlled->ShuntMode : false == Train->controlled->MotorOverloadRelayHighThreshold) + if (true == Train->controlled->ShuntModeAllow ? false == Train->controlled->ShuntMode : false == Train->controlled->MotorOverloadRelayHighThreshold()) { // turn on OnCommand_motoroverloadrelaythresholdsethigh(Train, Command); @@ -506,7 +506,7 @@ void TTrain::OnCommand_motoroverloadrelaythresholdsetlow(TTrain *Train, command_ // only reacting to press, so the switch doesn't flip back and forth if key is held down Train->controlled->CurrentSwitch(false); // visual feedback - Train->ggMaxCurrentCtrl.UpdateValue(Train->controlled->MotorOverloadRelayHighThreshold ? 1 : 0, Train->dsbSwitch); + Train->ggMaxCurrentCtrl.UpdateValue(Train->controlled->MotorOverloadRelayHighThreshold() ? 1 : 0, Train->dsbSwitch); } } @@ -518,7 +518,7 @@ void TTrain::OnCommand_motoroverloadrelaythresholdsethigh(TTrain *Train, command // only reacting to press, so the switch doesn't flip back and forth if key is held down Train->controlled->CurrentSwitch(true); // visual feedback - Train->ggMaxCurrentCtrl.UpdateValue(Train->controlled->MotorOverloadRelayHighThreshold ? 1 : 0, Train->dsbSwitch); + Train->ggMaxCurrentCtrl.UpdateValue(Train->controlled->MotorOverloadRelayHighThreshold() ? 1 : 0, Train->dsbSwitch); } } diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index 63f37ae1b..2796e640c 100644 --- a/vehicle/cab/setup.cpp +++ b/vehicle/cab/setup.cpp @@ -75,10 +75,10 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) {"localbrakesound2:", {rsSBHissU, internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, single, sound_parameters::amplitude, 100.0}}, {"brakesound:", {rsBrake, internal, -1, single, sound_parameters::amplitude | sound_parameters::frequency, 100.0}}, {"fadesound:", {rsFadeSound, internal, EU07_SOUND_CABCONTROLSCUTOFFRANGE, single, 0, 100.0}}, - {"runningnoise:", {rsRunningNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax}}, - {"resonancenoise:", {rsResonanceNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax}}, - {"windsound:", {rsWindSound, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax}}, - {"huntingnoise:", {rsHuntingNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax}}, + {"runningnoise:", {rsRunningNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax()}}, + {"resonancenoise:", {rsResonanceNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax()}}, + {"windsound:", {rsWindSound, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax()}}, + {"huntingnoise:", {rsHuntingNoise, internal, EU07_SOUND_GLOBALRANGE, single, sound_parameters::amplitude | sound_parameters::frequency, occupied->Vmax()}}, {"rainsound:", {m_rainsound, internal, -1, single, 0, 100.0}}, }; for (auto &[soundname, soundsource] : internalsounds) @@ -143,23 +143,23 @@ bool TTrain::LoadMMediaFile(std::string const &asFileName) } if (rsBrake) { - rsBrake->m_frequencyfactor /= static_cast(1 + occupied->Vmax); + rsBrake->m_frequencyfactor /= static_cast(1 + occupied->Vmax()); } if (rsResonanceNoise) { - rsResonanceNoise->m_frequencyfactor /= static_cast(1 + occupied->Vmax); + rsResonanceNoise->m_frequencyfactor /= static_cast(1 + occupied->Vmax()); } if (rsWindSound) { - rsWindSound->m_frequencyfactor /= static_cast(1 + occupied->Vmax); + rsWindSound->m_frequencyfactor /= static_cast(1 + occupied->Vmax()); } if (rsRunningNoise) { - rsRunningNoise->m_frequencyfactor /= static_cast(1 + occupied->Vmax); + rsRunningNoise->m_frequencyfactor /= static_cast(1 + occupied->Vmax()); } if (rsHuntingNoise) { - rsHuntingNoise->m_frequencyfactor /= static_cast(1 + occupied->Vmax); + rsHuntingNoise->m_frequencyfactor /= static_cast(1 + occupied->Vmax()); } } std::vector>> sounds = { @@ -587,11 +587,11 @@ void TTrain::clear_cab_controls() btLampkaNadmSil.Clear(4); btLampkaStyczn.Clear(5); btLampkaPoslizg.Clear(6); - btLampkaNadmPrzetw.Clear(controlled->TrainType == train_type::emu ? -1 : 7); // EN57 nie ma tej lampki - btLampkaPrzetwOff.Clear(controlled->TrainType == train_type::emu ? 7 : -1); // za to ma tę + btLampkaNadmPrzetw.Clear(controlled->TrainType() == train_type::emu ? -1 : 7); // EN57 nie ma tej lampki + btLampkaPrzetwOff.Clear(controlled->TrainType() == train_type::emu ? 7 : -1); // za to ma tę btLampkaNadmSpr.Clear(8); btLampkaNadmWent.Clear(9); - btLampkaWysRozr.Clear(controlled->TrainType == train_type::et22 ? -1 : 10); // ET22 nie ma tej lampki + btLampkaWysRozr.Clear(controlled->TrainType() == train_type::et22 ? -1 : 10); // ET22 nie ma tej lampki btLampkaOgrzewanieSkladu.Clear(11); // overheat indicator lamps btLampkaOilOverheat.Clear(-1); @@ -999,9 +999,9 @@ void TTrain::set_cab_controls(int const Cab) ggCompressorLocalButton.PutValue(controlled->air.compressor.LocalSwitchOn() ? 1.f : 0.f); ggCompressorListButton.PutValue(static_cast(occupied->air.compressor.ListPosition() - 1)); // motor overload relay threshold / shunt mode - ggMaxCurrentCtrl.PutValue(true == controlled->ShuntModeAllow ? (true == controlled->ShuntMode ? 1.f : 0.f) : controlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f); + ggMaxCurrentCtrl.PutValue(true == controlled->ShuntModeAllow ? (true == controlled->ShuntMode ? 1.f : 0.f) : controlled->MotorOverloadRelayHighThreshold() ? 1.f : 0.f); // automatic relays (AutoRelay) - ggAutoRelayButton.PutValue(occupied->AutoRelayFlag ? 1.f : 0.f); + ggAutoRelayButton.PutValue(occupied->AutoRelayFlag() ? 1.f : 0.f); // lights ggLightsButton.PutValue(static_cast(occupied->LightsPos() - 1)); @@ -1119,7 +1119,7 @@ void TTrain::set_cab_controls(int const Cab) // water heater ggWaterHeaterBreakerButton.PutValue(controlled->WaterHeater.breaker ? 1.f : 0.f); ggWaterHeaterButton.PutValue(controlled->WaterHeater.is_enabled ? 1.f : 0.f); - ggWaterCircuitsLinkButton.PutValue(controlled->WaterCircuitsLink ? 1.f : 0.f); + ggWaterCircuitsLinkButton.PutValue(controlled->WaterCircuitsLink() ? 1.f : 0.f); // fuel pump if (ggFuelPumpButton.type() != TGaugeType::push) { diff --git a/vehicle/cab/sounds.cpp b/vehicle/cab/sounds.cpp index 69b9287a8..2b7dac896 100644 --- a/vehicle/cab/sounds.cpp +++ b/vehicle/cab/sounds.cpp @@ -219,9 +219,9 @@ void TTrain::update_sounds(double const Deltatime) { auto const brakeforceratio{ - std::clamp(occupied->brakes.unitForce / std::max(1.0, occupied->BrakeForceR(1.0, occupied->Vel) / (occupied->NAxles * std::max(1, occupied->brakes.config.blocksPerAxle))), 0.0, 1.0)}; + std::clamp(occupied->brakes.unitForce / std::max(1.0, occupied->BrakeForceR(1.0, occupied->Vel) / (occupied->NAxles() * std::max(1, occupied->brakes.config.blocksPerAxle))), 0.0, 1.0)}; // HACK: in external view mute the sound rather than stop it, in case there's an opening bookend it'd (re)play on sound restart after returning inside - volume = FreeFlyModeFlag ? 0.0 : rsBrake->m_amplitudeoffset + std::sqrt(brakeforceratio * std::lerp(0.4, 1.0, occupied->Vel / (1 + occupied->Vmax))) * rsBrake->m_amplitudefactor; + volume = FreeFlyModeFlag ? 0.0 : rsBrake->m_amplitudeoffset + std::sqrt(brakeforceratio * std::lerp(0.4, 1.0, occupied->Vel / (1 + occupied->Vmax()))) * rsBrake->m_amplitudefactor; rsBrake->pitch(static_cast(rsBrake->m_frequencyoffset + occupied->Vel * rsBrake->m_frequencyfactor)); rsBrake->gain(static_cast(volume)); rsBrake->play(sound_flags::exclusive | sound_flags::looping); @@ -242,7 +242,7 @@ void TTrain::update_sounds(double const Deltatime) if (dsbSlipAlarm) { // alarm przy poslizgu dla 181/182 - BOMBARDIER - if (controlled->SlippingWheels && DynamicObject->GetVelocity() > 1.0) + if (controlled->SlippingWheels() && DynamicObject->GetVelocity() > 1.0) { dsbSlipAlarm->play(sound_flags::exclusive | sound_flags::looping); } @@ -429,11 +429,11 @@ void TTrain::update_sounds(double const Deltatime) void TTrain::update_sounds_resonancenoise(sound_source &Sound) const { // frequency calculation - auto const normalizer{occupied->Vmax * 0.01f}; + auto const normalizer{occupied->Vmax() * 0.01f}; auto const soundfrequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * occupied->Vel * normalizer}; // volume calculation - auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(occupied->Vel / (1 + occupied->Vmax), 1.0, 0.5); // scale base volume between 0.5-1.0 + auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(occupied->Vel / (1 + occupied->Vmax()), 1.0, 0.5); // scale base volume between 0.5-1.0 if (volume > 0.05) { @@ -448,16 +448,16 @@ void TTrain::update_sounds_resonancenoise(sound_source &Sound) const void TTrain::update_sounds_runningnoise(sound_source &Sound) { // frequency calculation - auto const normalizer{(true == Sound.is_combined() ? occupied->Vmax * 0.01f : 1.f)}; + auto const normalizer{(true == Sound.is_combined() ? occupied->Vmax() * 0.01f : 1.f)}; auto const soundfrequency{Sound.m_frequencyoffset + Sound.m_frequencyfactor * occupied->Vel * normalizer}; // volume calculation - auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(occupied->Vel / (1 + occupied->Vmax), 1.0, + auto volume = Sound.m_amplitudeoffset + Sound.m_amplitudefactor * std::lerp(occupied->Vel / (1 + occupied->Vmax()), 1.0, 0.5); // scale base volume between 0.5-1.0 - if (std::abs(occupied->nrot) > 0.01) + if (std::abs(occupied->nrot()) > 0.01) { // hamulce wzmagaja halas - auto const brakeforceratio{(std::clamp(occupied->brakes.unitForce / std::max(1.0, occupied->BrakeForceR(1.0, occupied->Vel) / (occupied->NAxles * std::max(1, occupied->brakes.config.blocksPerAxle))), 0.0, 1.0))}; + auto const brakeforceratio{(std::clamp(occupied->brakes.unitForce / std::max(1.0, occupied->BrakeForceR(1.0, occupied->Vel) / (occupied->NAxles() * std::max(1, occupied->brakes.config.blocksPerAxle))), 0.0, 1.0))}; volume *= 1 + 0.125 * brakeforceratio; } diff --git a/vehicle/cab/train.cpp b/vehicle/cab/train.cpp index 0a9394ac8..5173a40b5 100644 --- a/vehicle/cab/train.cpp +++ b/vehicle/cab/train.cpp @@ -171,7 +171,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("name", DynamicObject->asName); dict->insert("cab", occupied->CabOccupied()); dict->insert("cabactive", occupied->CabActive); - dict->insert("master", occupied->CabMaster); + dict->insert("master", occupied->CabMaster()); // basic systems state data dict->insert("battery", occupied->lowVoltage.Is24vAvailable()); dict->insert("linebreaker", controlled->lineBreaker.IsClosed()); @@ -216,7 +216,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("scnd_ctrl_actual_pos", controlled->ScndCtrlActualPos); dict->insert("brakectrl_pos", controlled->brakes.HandlePositionSmooth()); dict->insert("localbrake_pos", controlled->brakes.IndependentPosition()); - dict->insert("new_speed", occupied->NewSpeed); + dict->insert("new_speed", occupied->NewSpeed()); dict->insert("speedctrl", occupied->SpeedCtrlValue); dict->insert("speedctrlpower", occupied->SpeedCtrlUnit.DesiredPower); dict->insert("speedctrlactive", occupied->SpeedCtrlUnit.IsActive); @@ -261,9 +261,9 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("door_permit_right", occupied->Doors.instances[VehicleSide::right].open_permit); // movement data dict->insert("velocity", std::abs(occupied->Vel)); - dict->insert("tractionforce", std::abs(occupied->Ft)); - dict->insert("slipping_wheels", occupied->SlippingWheels); - dict->insert("sanding", occupied->SandDose); + dict->insert("tractionforce", std::abs(occupied->Ft())); + dict->insert("slipping_wheels", occupied->SlippingWheels()); + dict->insert("sanding", occupied->SandDose()); dict->insert("odometer", occupied->DistCounter()); // distance run in the session, km dict->insert("odometer_total", occupied->Odometer.km); // the vehicle's odometer, kept between the sessions // electric current data @@ -271,7 +271,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("voltage", std::abs(controlled->EngineVoltage)); dict->insert("im", std::abs(controlled->Im)); dict->insert("fuse", controlled->FuseFlag); - dict->insert("epfuse", occupied->EpFuse); + dict->insert("epfuse", occupied->EpFuse()); dict->insert("power_drawn", occupied->EnergyMeter.first); dict->insert("power_returned", occupied->EnergyMeter.second); @@ -416,7 +416,7 @@ TTrain::state_t TTrain::get_state() const static_cast(occupied->brakes.cylinderPressure), static_cast(pantographUnit->pantographAir.Pressure()), fHVoltage, - {fHCurrent[controlled->TrainType == train_type::emu ? 0 : 1], fHCurrent[2], fHCurrent[3]}, + {fHCurrent[controlled->TrainType() == train_type::emu ? 0 : 1], fHCurrent[2], fHCurrent[3]}, ggLVoltage.GetValue(), occupied->DistCounter(), static_cast(RadioChannel()), @@ -439,7 +439,7 @@ TTrain::state_t TTrain::get_state() const bool TTrain::is_eztoer() const { - return controlled->TrainType == train_type::emu && occupied->brakes.config.subsystem == TBrakeSubSystem::ss_ESt && controlled->lowVoltage.Is24vAvailable() == true && controlled->EpFuse == true && + return controlled->TrainType() == train_type::emu && occupied->brakes.config.subsystem == TBrakeSubSystem::ss_ESt && controlled->lowVoltage.Is24vAvailable() == true && controlled->EpFuse() == true && controlled->DirActive != 0; // od yB } @@ -447,7 +447,7 @@ bool TTrain::is_eztoer() const void TTrain::set_master_controller(double const Position) { - auto positionchange{std::min(static_cast(Position), controlled->CoupledCtrl ? controlled->MainCtrlPosNo + controlled->ScndCtrlPosNo : controlled->MainCtrlPosNo) - + auto positionchange{std::min(static_cast(Position), controlled->CoupledCtrl ? controlled->MainCtrlPosNo + controlled->ScndCtrlPosNo() : controlled->MainCtrlPosNo) - (controlled->CoupledCtrl ? controlled->MainCtrlPos() + controlled->ScndCtrlPos() : controlled->MainCtrlPos())}; while (positionchange < 0 && true == controlled->DecMainCtrl(1)) { @@ -515,7 +515,7 @@ void TTrain::set_train_brake_speed(TDynamicObject *Vehicle, int const Speed) void TTrain::set_paired_open_motor_connectors_button(bool const State) { - if (controlled->TrainType == train_type::et41 || controlled->TrainType == train_type::et42) + if (controlled->TrainType() == train_type::et41 || controlled->TrainType() == train_type::et42) { // crude implementation of the button affecting entire unit for multi-unit engines // TODO: rework it into part of standard command propagation system diff --git a/vehicle/cab/update.cpp b/vehicle/cab/update.cpp index 333a5bce3..84f80c4b4 100644 --- a/vehicle/cab/update.cpp +++ b/vehicle/cab/update.cpp @@ -186,7 +186,7 @@ void TTrain::updateLineBreakerState(double const Deltatime) // if the button disconnecting the line breaker is down prevent the timer from accumulating fMainRelayTimer = 0.0f; } - if (m_linebreakerstate == linebreaker::state::open && fMainRelayTimer > controlled->InitialCtrlDelay) + if (m_linebreakerstate == linebreaker::state::open && fMainRelayTimer > controlled->InitialCtrlDelay()) { // wlaczanie WSa z opoznieniem // mark the line breaker as ready to close; for electric series vehicles with impulse switch the setup is completed on button release @@ -245,13 +245,13 @@ void TTrain::updateDoorAndDirectionStates() m_doors = DynamicObject->Mechanik->ConsistDoorsOpen()[VehicleSide::right] || DynamicObject->Mechanik->ConsistDoorsOpen()[VehicleSide::left]; m_doorpermits = DynamicObject->Mechanik->ConsistDoorPermits()[VehicleSide::right] || DynamicObject->Mechanik->ConsistDoorPermits()[VehicleSide::left]; m_doorspermitleft = occupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right].open_permit && - (simulation::Time.data().wSecond % 2 < 1 || occupied->DoorsPermitLightBlinking < 1 || - occupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->ConsistDoorsOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right] || - (occupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->ConsistDoorsOnlyOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right])); + (simulation::Time.data().wSecond % 2 < 1 || occupied->DoorsPermitLightBlinking() < 1 || + occupied->DoorsPermitLightBlinking() < 2 && DynamicObject->Mechanik->ConsistDoorsOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right] || + (occupied->DoorsPermitLightBlinking() < 3 && DynamicObject->Mechanik->ConsistDoorsOnlyOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::left : VehicleSide::right])); m_doorspermitright = occupied->Doors.instances[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left].open_permit && - (simulation::Time.data().wSecond % 2 < 1 || occupied->DoorsPermitLightBlinking < 1 || - occupied->DoorsPermitLightBlinking < 2 && DynamicObject->Mechanik->ConsistDoorsOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left] || - (occupied->DoorsPermitLightBlinking < 3 && DynamicObject->Mechanik->ConsistDoorsOnlyOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left])); + (simulation::Time.data().wSecond % 2 < 1 || occupied->DoorsPermitLightBlinking() < 1 || + occupied->DoorsPermitLightBlinking() < 2 && DynamicObject->Mechanik->ConsistDoorsOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left] || + (occupied->DoorsPermitLightBlinking() < 3 && DynamicObject->Mechanik->ConsistDoorsOnlyOpen()[cab_to_end() == VehicleEnd::front ? VehicleSide::right : VehicleSide::left])); } m_dirforward = controlled->DirActive > 0; m_dirneutral = controlled->DirActive == 0; @@ -288,7 +288,7 @@ void TTrain::processReceivedCommands() void TTrain::returnMasterController(double const Deltatime) { // nie blokujemy AI - if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag() && (occupied->TrainType == train_type::et40 || occupied->TrainType == train_type::ep05 || occupied->HasCamshaft)) + if (DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag() && (occupied->TrainType() == train_type::et40 || occupied->TrainType() == train_type::ep05 || occupied->HasCamshaft)) { // dla ET40 i EU05 automatyczne cofanie nastawnika - i tak nie będzie to działać dobrze... // TODO: use deltatime to stabilize speed @@ -324,12 +324,12 @@ void TTrain::updateTachometer(double const Deltatime) // McZapkie: predkosc wyswietlana na tachometrze brana jest z obrotow kol auto const maxtacho{3.0}; - double maxSpeed = controlled->Vmax * 1.05; // zachowanie starej logiki jak nie ma definicji max tarczki + double maxSpeed = controlled->Vmax() * 1.05; // zachowanie starej logiki jak nie ma definicji max tarczki if (occupied->maxTachoSpeed != 0) { maxSpeed = occupied->maxTachoSpeed; } - fTachoVelocity = static_cast(std::min(std::abs(11.31 * controlled->WheelDiameter * controlled->nrot), maxSpeed)); + fTachoVelocity = static_cast(std::min(std::abs(11.31 * controlled->WheelDiameter() * controlled->nrot()), maxSpeed)); { // skacze osobna zmienna float ff = simulation::Time.data().wSecond; // skacze co sekunde - pol sekundy // pomiar, pol sekundy ustawienie @@ -437,7 +437,7 @@ void TTrain::updateUnitStates() fPress[i][2] = static_cast(p->physics->mainPipe.Pressure()); fPress[i][3] = static_cast(p->physics->brakes.controlReservoirPressure); fPress[i][4] = static_cast(p->physics->brakes.distributor->GetBRP()); - fPress[i][5] = static_cast((p->physics->TotalMass - p->physics->Mred) * 0.001); + fPress[i][5] = static_cast((p->physics->TotalMass() - p->physics->Mred()) * 0.001); fPress[i][6] = static_cast(p->physics->brakes.spring.pressure); bBrakes[i][0] = p->physics->brakes.spring.isActive; bBrakes[i][1] = p->physics->brakes.spring.shutOff; @@ -468,7 +468,7 @@ void TTrain::updateUnitStates() } bCompressors.emplace_back(p->physics->air.compressor.IsAllowed() || p->physics->air.compressor.config.start == start_t::automatic, p->physics->air.compressor.IsRunning(), i); } - bSlip[i] = p->physics->SlippingWheels; + bSlip[i] = p->physics->SlippingWheels(); if (in < 8 && p->physics->inductionMotor.traction.maxPower > 1) { fEIMParams[1 + in][0] = static_cast(p->physics->inductionMotor.state.maxForce); @@ -496,7 +496,7 @@ void TTrain::updateUnitStates() if (in < 8 && (p->physics->EngineType == TEngineType::DieselEngine || p->physics->EngineType == TEngineType::DieselElectric)) { fDieselParams[1 + in][0] = static_cast(p->physics->enrot * 60); - fDieselParams[1 + in][1] = static_cast(p->physics->nrot); + fDieselParams[1 + in][1] = static_cast(p->physics->nrot()); fDieselParams[1 + in][2] = static_cast(p->physics->RList[p->physics->MainCtrlPos()].R); fDieselParams[1 + in][3] = static_cast(p->physics->diesel.fill); fDieselParams[1 + in][4] = static_cast(p->physics->RList[p->physics->MainCtrlPos()].Mn); @@ -591,7 +591,7 @@ void TTrain::updateFeedbackGauges() const // Ra: sterowanie miernikiem: drugi amperomierz Console::ValueSet(4, fHCurrent[2]); // pierwszy amperomierz; dla EZT prąd całkowity - Console::ValueSet(5, fHCurrent[controlled->TrainType == train_type::emu ? 0 : 1]); + Console::ValueSet(5, fHCurrent[controlled->TrainType() == train_type::emu ? 0 : 1]); // Ra: prędkość na pin 43 - wyjście analogowe (to nie jest PWM); skakanie zapewnia mechanika napędu Console::ValueSet(6, fTachoVelocity); } @@ -607,15 +607,15 @@ void TTrain::updateConverterOverload(double const Deltatime) if (controlled->converter.IsRunning() == true) { fConverterTimer += static_cast(Deltatime); - if (controlled->air.compressor.IsRunning() == true && controlled->air.compressor.config.supply == physics::CompressorSupply::converterManual && (controlled->EngineType == TEngineType::ElectricSeriesMotor || controlled->TrainType == train_type::emu) && + if (controlled->air.compressor.IsRunning() == true && controlled->air.compressor.config.supply == physics::CompressorSupply::converterManual && (controlled->EngineType == TEngineType::ElectricSeriesMotor || controlled->TrainType() == train_type::emu) && DynamicObject->Controller == Humandriver // hunter-110212: poprawka dla EZT && DynamicObject->Mechanik != nullptr && false == DynamicObject->Mechanik->AIControllFlag()) { // hunter-091012: poprawka (zmiana warunku z CompressorPower /rozne od 0/ na /rowne 1/) if (fConverterTimer < fConverterPrzekaznik) { controlled->converter.Overload(); - if (controlled->TrainType != train_type::emu) - controlled->MainSwitch(false, controlled->TrainType == train_type::emu ? range_t::unit : range_t::local); + if (controlled->TrainType() != train_type::emu) + controlled->MainSwitch(false, controlled->TrainType() == train_type::emu ? range_t::unit : range_t::local); } else if (fConverterTimer >= fConverterPrzekaznik) { @@ -703,7 +703,7 @@ void TTrain::updateEngineGauges() else { int x; - if (controlled->TrainType == train_type::et42 && controlled->Imax == controlled->ImaxHi) + if (controlled->TrainType() == train_type::et42 && controlled->Imax == controlled->ImaxHi()) x = 1; else x = 2; @@ -761,10 +761,10 @@ void TTrain::updateEngineGauges() // sets the lamps of the wheel slip, the compressors, the dynamic brake permit and the active cab void TTrain::updateBasicLamps() { - if (controlled->SlippingWheels) + if (controlled->SlippingWheels()) { // Ra 2014-12: lokomotywy 181/182 dostają SlippingWheels po zahamowaniu powyżej 2.85 bara i buczały - double veldiff = (DynamicObject->GetVelocity() - fTachoVelocity) / controlled->Vmax; + double veldiff = (DynamicObject->GetVelocity() - fTachoVelocity) / controlled->Vmax(); // 1% Vmax rezerwy, żeby 181/182 nie buczały po zahamowaniu, ale to proteza if (veldiff < -0.01 && std::abs(controlled->Im) > 10.0) { @@ -783,7 +783,7 @@ void TTrain::updateBasicLamps() btCompressors.Turn(false); // Lampka zezwolenia na hamowanie ED - if (controlled->EpFuse) + if (controlled->EpFuse()) btEDenabled.Turn(true); else btEDenabled.Turn(false); @@ -845,7 +845,7 @@ void TTrain::updateCircuitLamps(double const Deltatime) btLampkaHamPosp.Turn(TestFlag(occupied->brakes.distributor->GetBrakeStatus(), 1)); // lampka drugiego stopnia hamowania // TODO: youBy wyciągnąć flagę wysokiego stopnia btLampkaNadmWent.Turn(controlled->RventRot < 5.0 && controlled->ResistorsFlagCheck()); // hunter-121211: lampka zanikowo-pradowego wentylatorow - btLampkaWysRozr.Turn(controlled->Imax >= controlled->ImaxHi); + btLampkaWysRozr.Turn(controlled->Imax >= controlled->ImaxHi()); btLampkaNapNastHam.Turn(controlled->DirActive != 0); // napiecie na nastawniku hamulcowym btLampkaSprezarka.Turn(controlled->air.compressor.IsRunning()); // mutopsitka dziala @@ -858,11 +858,11 @@ void TTrain::updateCircuitLamps(double const Deltatime) // - pokićkał ktoś? int scp = controlled->RList[controlled->MainCtrlPos()].ScndAct; scp = scp == 255 ? 0 : scp; // Ra: whatta hella is this? - btLampkaBoczniki.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlActualPos > 0 || scp > 0); - btLampkaBocznik1.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlPos() > 0 || controlled->ScndCtrlActualPos > 0 || scp > 0); - btLampkaBocznik2.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlPos() > 1 || controlled->ScndCtrlActualPos > 1 || scp > 1); - btLampkaBocznik3.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlPos() > 2 || controlled->ScndCtrlActualPos > 2 || scp > 2); - btLampkaBocznik4.Turn(!controlled->DelayCtrlFlag && controlled->ScndCtrlPos() > 3 || controlled->ScndCtrlActualPos > 3 || scp > 3); + btLampkaBoczniki.Turn(!controlled->DelayCtrlFlag() && controlled->ScndCtrlActualPos > 0 || scp > 0); + btLampkaBocznik1.Turn(!controlled->DelayCtrlFlag() && controlled->ScndCtrlPos() > 0 || controlled->ScndCtrlActualPos > 0 || scp > 0); + btLampkaBocznik2.Turn(!controlled->DelayCtrlFlag() && controlled->ScndCtrlPos() > 1 || controlled->ScndCtrlActualPos > 1 || scp > 1); + btLampkaBocznik3.Turn(!controlled->DelayCtrlFlag() && controlled->ScndCtrlPos() > 2 || controlled->ScndCtrlActualPos > 2 || scp > 2); + btLampkaBocznik4.Turn(!controlled->DelayCtrlFlag() && controlled->ScndCtrlPos() > 3 || controlled->ScndCtrlActualPos > 3 || scp > 3); // biegi dla motoraka btLampkaGear1.Turn(controlled->ScndCtrlActualPos == 1 && controlled->diesel.clutchState > 0); // bieg 1 @@ -889,7 +889,7 @@ void TTrain::updateCircuitLamps(double const Deltatime) // sets the lamps of the braking, the radio, the doors, the direction, the lights and the overheating, with the low voltage on void TTrain::updateTrainLamps() { - switch (controlled->TrainType) + switch (controlled->TrainType()) { // zależnie od typu lokomotywy case train_type::emu: @@ -940,7 +940,7 @@ void TTrain::updateTrainLamps() } btLampkaDoorLockOff.Turn(false == occupied->Doors.lock_enabled); btLampkaDepartureSignal.Turn(controlled->DepartureSignal); - btLampkaNapNastHam.Turn(controlled->DirActive != 0 && occupied->EpFuse); // napiecie na nastawniku hamulcowym + btLampkaNapNastHam.Turn(controlled->DirActive != 0 && occupied->EpFuse()); // napiecie na nastawniku hamulcowym // Wylaczanie lampek kierunku gdy jedziemy // Feature uruchamiany z fiz z sekcji Ctrl. wpisem HideDirStatusWhenMoving=Yes (domyslnie No) @@ -1113,10 +1113,10 @@ void TTrain::updateSecondUnitLamps(bool const lowvoltagepower) btLampkaStycznB.Turn(physics->LineContactorsLampLit()); // mozna prowadzic rozruch // hunter-271211: sygnalizacja poslizgu w pierwszym pojezdzie, gdy wystapi w drugim - if (physics->SlippingWheels) + if (physics->SlippingWheels()) { // Ra 2014-12: lokomotywy 181/182 dostają SlippingWheels po zahamowaniu powyżej 2.85 bara i buczały - auto const veldiff{(DynamicObject->GetVelocity() - fTachoVelocity) / controlled->Vmax}; + auto const veldiff{(DynamicObject->GetVelocity() - fTachoVelocity) / controlled->Vmax()}; if (veldiff < -0.01) { // 1% Vmax rezerwy, żeby 181/182 nie buczały po zahamowaniu, ale to proteza @@ -1182,7 +1182,7 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower) // joint master controller moves forward to adjust power and backward to adjust brakes auto const brakerangemultiplier{/* NOTE: scaling disabled as it was conflicting with associating sounds with control positions ( controlled->CoupledCtrl ? - controlled->MainCtrlPosNo + controlled->ScndCtrlPosNo : + controlled->MainCtrlPosNo + controlled->ScndCtrlPosNo() : controlled->MainCtrlPosNo ) / static_cast(LocalBrakePosNo) */ @@ -1232,7 +1232,7 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower) // Ra: od byte odejmowane boolean i konwertowane potem na double? if (false == ggScndCtrl.is_push()) { - ggScndCtrl.UpdateValue(static_cast(double(controlled->ScndCtrlPos() - (controlled->TrainType == train_type::et42 && controlled->brakes.electrodynamic.on))), dsbNastawnikBocz); + ggScndCtrl.UpdateValue(static_cast(double(controlled->ScndCtrlPos() - (controlled->TrainType() == train_type::et42 && controlled->brakes.electrodynamic.on))), dsbNastawnikBocz); } ggScndCtrl.Update(); } @@ -1254,13 +1254,13 @@ void TTrain::updateMasterControllers(bool const lowvoltagepower) } if (ggDirKey.SubModel != nullptr) { - if (controlled->TrainType != train_type::emu) + if (controlled->TrainType() != train_type::emu) { ggDirKey.UpdateValue(static_cast(double(controlled->DirActive)), dsbReverserKey); } else { - ggDirKey.UpdateValue(static_cast(double(controlled->DirActive) + double(controlled->Imin == controlled->IminHi)), dsbReverserKey); + ggDirKey.UpdateValue(static_cast(double(controlled->DirActive) + double(controlled->Imin() == controlled->IminHi)), dsbReverserKey); } ggDirKey.Update(); } @@ -1345,9 +1345,9 @@ void TTrain::updateCabSwitches(bool const lowvoltagepower) ggBrakeProfileR.Update(); ggBrakeOperationModeCtrl.Update(); ggWiperSw.Update(); - ggMaxCurrentCtrl.UpdateValue(true == controlled->ShuntModeAllow ? (true == controlled->ShuntMode ? 1.f : 0.f) : controlled->MotorOverloadRelayHighThreshold ? 1.f : 0.f); + ggMaxCurrentCtrl.UpdateValue(true == controlled->ShuntModeAllow ? (true == controlled->ShuntMode ? 1.f : 0.f) : controlled->MotorOverloadRelayHighThreshold() ? 1.f : 0.f); ggMaxCurrentCtrl.Update(); - ggAutoRelayButton.UpdateValue(occupied->AutoRelayFlag ? 1.f : 0.f); + ggAutoRelayButton.UpdateValue(occupied->AutoRelayFlag() ? 1.f : 0.f); ggAutoRelayButton.Update(); // NBMX wrzesien 2003 - drzwi ggDoorLeftPermitButton.Update(lowvoltagepower); diff --git a/vehicle/dynamic/lifecycle.cpp b/vehicle/dynamic/lifecycle.cpp index 114c279af..d1dc4653c 100644 --- a/vehicle/dynamic/lifecycle.cpp +++ b/vehicle/dynamic/lifecycle.cpp @@ -279,7 +279,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" if( physics->brakes.config.localKind != TLocalBrake::ManualBrake ) { if( fVel < 1.0 ) { physics->IncLocalBrakeLevel( LocalBrakePosNo ); - if ( physics->EIMCtrlEmergency ) { + if ( physics->EIMCtrlEmergency() ) { physics->DecLocalBrakeLevel(1); } } @@ -566,7 +566,7 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // McZapkie-250202 /* - iAxles = std::min( physics->NAxles, MaxAxles ); // ilość osi + iAxles = std::min( physics->NAxles(), MaxAxles ); // ilość osi */ // wczytywanie z pliku nazwatypu.mmd, w tym model erase_extension( asReplacableSkin ); @@ -717,12 +717,12 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" // McZapkie-250202 end. Track->AddDynamicObject(this); // wstawiamy do toru na pozycję 0, a potem przesuniemy // McZapkie: zmieniono na ilosc osi brane z chk - // iNumAxles=(physics->NAxles>3 ? 4 : 2 ); + // iNumAxles=(physics->NAxles()>3 ? 4 : 2 ); initial_track = MyTrack; iNumAxles = 2; // McZapkie-090402: odleglosc miedzy czopami skretu lub osiami fAxleDist = safe_clamp( - std::max( physics->BDist, physics->ADist ), + std::max( physics->BDist(), physics->ADist() ), 0.2, //żeby się dało wektory policzyć physics->Dim.L - 0.2 ); // nie mogą być za daleko bo będzie "walenie w mur" double fAxleDistHalf = fAxleDist * 0.5; @@ -738,13 +738,13 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" break; case 4: Axle0.Init(Track, this, iDirection ? 1 : -1); - Axle0.Move((iDirection ? fDist : -fDist) + (fAxleDistHalf + physics->ADist * 0.5), false); + Axle0.Move((iDirection ? fDist : -fDist) + (fAxleDistHalf + physics->ADist() * 0.5), false); Axle1.Init(Track, this, iDirection ? 1 : -1); - Axle1.Move((iDirection ? fDist : -fDist) - (fAxleDistHalf + physics->ADist * 0.5), false); + Axle1.Move((iDirection ? fDist : -fDist) - (fAxleDistHalf + physics->ADist() * 0.5), false); // Axle2.Init(Track,this,iDirection?1:-1); - // Axle2.Move((iDirection?fDist:-fDist)-(fAxleDistHalf-physics->ADist*0.5),false); + // Axle2.Move((iDirection?fDist:-fDist)-(fAxleDistHalf-physics->ADist()*0.5),false); // Axle3.Init(Track,this,iDirection?1:-1); - // Axle3.Move((iDirection?fDist:-fDist)+(fAxleDistHalf-physics->ADist*0.5),false); + // Axle3.Move((iDirection?fDist:-fDist)+(fAxleDistHalf-physics->ADist()*0.5),false); break; } // potrzebne do wyliczenia aktualnej pozycji; nie może być zero, bo nie przeliczy pozycji diff --git a/vehicle/dynamic/mmd.cpp b/vehicle/dynamic/mmd.cpp index f47093a8b..e77dacde2 100644 --- a/vehicle/dynamic/mmd.cpp +++ b/vehicle/dynamic/mmd.cpp @@ -370,7 +370,7 @@ bool TDynamicObject::loadModelsWheelKeyword( cParser &parser, std::string &token { //++iAnimatedAxles; pAnimations[i].smAnimated->WillBeAnimated(); // wyłączenie optymalizacji transformu pAnimations[i].yUpdate = std::bind( &TDynamicObject::UpdateAxle, this, std::placeholders::_1 ); - pAnimations[i].fMaxDist = Global.fDistanceFactor * physics->WheelDiameter * 200; + pAnimations[i].fMaxDist = Global.fDistanceFactor * physics->WheelDiameter() * 200; pAnimations[i].fMaxDist *= pAnimations[i].fMaxDist; } } @@ -381,8 +381,8 @@ bool TDynamicObject::loadModelsWheelKeyword( cParser &parser, std::string &token j = 1; k = 0; m = 0; // numer osi; kolejny znak; ile osi danego typu; która średnica - if (physics->WheelDiameterL != physics->WheelDiameter || - physics->WheelDiameterT != physics->WheelDiameter) + if (physics->WheelDiameterL != physics->WheelDiameter() || + physics->WheelDiameterT != physics->WheelDiameter()) { // obsługa różnych średnic, o ile występują while (i < iAnimType[ANIM_WHEELS] && j <= physics->AxleArangement.length()) @@ -1218,7 +1218,7 @@ bool TDynamicObject::loadSoundsBrakeKeyword( cParser &parser, std::string_view t rsBrake.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency ); rsBrake.owner( this ); // NOTE: can't pre-calculate amplitude normalization based on max brake force, as this varies depending on vehicle speed - rsBrake.m_frequencyfactor /= 1 + physics->Vmax; + rsBrake.m_frequencyfactor /= 1 + physics->Vmax(); } else if( token == "brake:" ) { @@ -1548,11 +1548,11 @@ bool TDynamicObject::loadSoundsOtherKeyword( cParser &parser, std::string_view t else if( token == "outernoise:" ) { // szum podczas jazdy: sound_source noisetemplate{ sound_placement::external, EU07_SOUND_RUNNINGNOISECUTOFFRANGE }; - noisetemplate.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, physics->Vmax ); + noisetemplate.deserialize( parser, sound_type::single, sound_parameters::amplitude | sound_parameters::frequency, physics->Vmax() ); noisetemplate.owner( this ); - noisetemplate.m_amplitudefactor /= 1 + physics->Vmax; - noisetemplate.m_frequencyfactor /= 1 + physics->Vmax; + noisetemplate.m_amplitudefactor /= 1 + physics->Vmax(); + noisetemplate.m_frequencyfactor /= 1 + physics->Vmax(); #ifdef EU07_SOUND_BOGIESOUNDS if( true == m_bogiesounds.empty() ) { // fallback for cases without specified noise locations, convert sound template to a single sound source @@ -1903,7 +1903,7 @@ bool TDynamicObject::loadInternalDataDeviceKeyword( cParser &parser, std::string rsSlippery.deserialize( parser, sound_type::single, sound_parameters::amplitude ); rsSlippery.owner( this ); - rsSlippery.m_amplitudefactor /= 1 + physics->Vmax; + rsSlippery.m_amplitudefactor /= 1 + physics->Vmax(); } else { return false; diff --git a/vehicle/dynamic/movement.cpp b/vehicle/dynamic/movement.cpp index 456033b0e..d26cb101b 100644 --- a/vehicle/dynamic/movement.cpp +++ b/vehicle/dynamic/movement.cpp @@ -261,7 +261,7 @@ bool TDynamicObject::FastUpdate(double dt) if (dt == 0.0) return true; // Ra: pauza double dDOMoveLen; - if (!physics->PhysicActivation) + if (!physics->PhysicActivation()) return true; // McZapkie: wylaczanie fizyki gdy nie potrzeba if (!bEnabled) @@ -279,7 +279,7 @@ bool TDynamicObject::FastUpdate(double dt) modelRot.z }; // McZapkie: parametry powinny byc pobierane z toru // ts.R=MyTrack->fRadius; - // ts.Len= std::max(physics->BDist,physics->ADist); + // ts.Len= std::max(physics->BDist(),physics->ADist()); // ts.dHtrack=Axle1.pPosition.y-Axle0.pPosition.y; // ts.dHrail=((Axle1.GetRoll())+(Axle0.GetRoll()))*0.5f; // tp.Width=MyTrack->fTrackWidth; diff --git a/vehicle/dynamic/offtrack.cpp b/vehicle/dynamic/offtrack.cpp index 5b6b16fc9..d5aeb6668 100644 --- a/vehicle/dynamic/offtrack.cpp +++ b/vehicle/dynamic/offtrack.cpp @@ -228,7 +228,7 @@ int TDynamicObject::outward_side() const { // buckle bends the line the other way more than the curve does (the criteria of derailment, physics/derailment.h) if( auto const design { std::sin( Axle1.vAngles.z - Axle0.vAngles.z ) }; std::abs( design ) >= 1e-4 ) { auto const outside { design > 0.0 ? -1 : 1 }; - return physics->DerailAcceleration < 0.0 ? -outside : outside; + return physics->DerailAcceleration() < 0.0 ? -outside : outside; } // a straight track: the path under the vehicle as it is, a buckle on it, turns from the rear axle to the front one auto const front { Axle0.PathDirection() }; @@ -328,16 +328,16 @@ void TDynamicObject::begin_off_track() { shape.centre_of_gravity = physics->centre_of_gravity(); shape.contact_spacing = derailment::contact_spacing( physics->TrackW ); shape.base = std::max( static_cast( fAxleDist ), 1.0 ); - shape.mass = physics->TotalMass; + shape.mass = physics->TotalMass(); derail_motion::start start; start.position = vPosition; start.front = vFront; start.line = track_front(); start.speed = physics->V(); - start.reason = physics->DerailCause; - start.outward = ( physics->DerailSide != 0 ? physics->DerailSide : outward_side() ); - start.acceleration = physics->DerailAcceleration; + start.reason = physics->DerailCause(); + start.outward = ( physics->DerailSide() != 0 ? physics->DerailSide() : outward_side() ); + start.acceleration = physics->DerailAcceleration(); // the terrain as far as it may slide, and some m_offtracktotal = 0.0; @@ -467,8 +467,8 @@ void TDynamicObject::pull_neighbours( double const Distance ) { auto const across { glm::dot( force, level_left_of( axis ) ) }; auto const angle { std::atan2( std::abs( across ), std::abs( glm::dot( force, axis ) ) ) }; auto const magnitude { glm::length( glm::dvec3 { force.x, 0.0, force.z } ) }; - auto const mass { other.TotalMass - other.Mred }; - auto const ratio { derail_motion::pull_ratio( magnitude, angle, mass, other.NAxles ) }; + auto const mass { other.TotalMass() - other.Mred() }; + auto const ratio { derail_motion::pull_ratio( magnitude, angle, mass, other.NAxles() ) }; if( false == m_pulledoff[ end ].update( ratio >= derailment::climbing_limit, Distance ) ) { continue; } diff --git a/vehicle/dynamic/sounds.cpp b/vehicle/dynamic/sounds.cpp index c751bbb24..7bb3a9ebb 100644 --- a/vehicle/dynamic/sounds.cpp +++ b/vehicle/dynamic/sounds.cpp @@ -65,7 +65,7 @@ void TDynamicObject::RenderSounds() { if( Global.iPause != 0 ) { return; } if( m_startjoltplayed - && ( std::abs(physics->AccSVBased) < 0.01 + && ( std::abs(physics->AccSVBased()) < 0.01 || GetVelocity() < 0.01 ) ) { // if the vehicle comes to a stop set the movement jolt to play when it starts moving again m_startjoltplayed = false; @@ -366,12 +366,12 @@ void TDynamicObject::renderAirReleaseSounds( double const dt, double const brake void TDynamicObject::renderSlipAndSandSounds() { // slipping wheels - if( physics->SlippingWheels ) { + if( physics->SlippingWheels() ) { if( physics->brakes.unitForce > 100.0 && GetVelocity() > 1.0 ) { - auto const velocitydifference{ GetVelocity() / physics->Vmax }; + auto const velocitydifference{ GetVelocity() / physics->Vmax() }; rsSlippery .gain( rsSlippery.m_amplitudeoffset + rsSlippery.m_amplitudefactor * velocitydifference ) .play( sound_flags::exclusive | sound_flags::looping ); @@ -382,7 +382,7 @@ void TDynamicObject::renderSlipAndSandSounds() { } // Dzwiek piasecznicy - if( physics->SandDose ) { + if( physics->SandDose() ) { sSand.play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -397,17 +397,17 @@ double TDynamicObject::renderBrakeFrictionSounds( double const dt ) { // brakes auto brakeforceratio{ 0.0 }; - if( //( false == occupied->SlippingWheels ) && + if( //( false == occupied->SlippingWheels() ) && physics->brakes.unitForce > 10.0 && physics->Vel > 0.05 ) { brakeforceratio = std::clamp( - physics->brakes.unitForce / std::max( 1.0, physics->BrakeForceR( 1.0, physics->Vel ) / ( physics->NAxles * std::max( 1, physics->brakes.config.blocksPerAxle ) ) ), + physics->brakes.unitForce / std::max( 1.0, physics->BrakeForceR( 1.0, physics->Vel ) / ( physics->NAxles() * std::max( 1, physics->brakes.config.blocksPerAxle ) ) ), 0.0, 1.0 ); rsBrake .pitch( rsBrake.m_frequencyoffset + physics->Vel * rsBrake.m_frequencyfactor ) - .gain( rsBrake.m_amplitudeoffset + std::sqrt( brakeforceratio * std::lerp( 0.4, 1.0, physics->Vel / (1 + physics->Vmax) ) ) * rsBrake.m_amplitudefactor ) + .gain( rsBrake.m_amplitudeoffset + std::sqrt( brakeforceratio * std::lerp( 0.4, 1.0, physics->Vel / (1 + physics->Vmax()) ) ) * rsBrake.m_amplitudefactor ) .play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -672,7 +672,7 @@ void TDynamicObject::renderRunningNoise( double const brakeforceratio ) { // frequency calculation auto const normalizer { ( true == bogiesound.is_combined() ? - physics->Vmax * 0.01f : + physics->Vmax() * 0.01f : 1.f ) }; frequency = bogiesound.m_frequencyoffset @@ -765,8 +765,8 @@ void TDynamicObject::renderWheelFlatSound() { if( GetVelocity() > 1.0 && physics->WheelFlat() > 5.0 ) { m_wheelflat - .pitch( m_wheelflat.m_frequencyoffset + std::abs( physics->nrot ) * m_wheelflat.m_frequencyfactor ) - .gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + physics->Vel / physics->Vmax + std::clamp( physics->WheelFlat() / 60.0, 0.0, 1.0 ) ) / 3.0 ) ) + .pitch( m_wheelflat.m_frequencyoffset + std::abs( physics->nrot() ) * m_wheelflat.m_frequencyfactor ) + .gain( m_wheelflat.m_amplitudeoffset + m_wheelflat.m_amplitudefactor * ( ( 1.0 + physics->Vel / physics->Vmax() + std::clamp( physics->WheelFlat() / 60.0, 0.0, 1.0 ) ) / 3.0 ) ) .play( sound_flags::exclusive | sound_flags::looping ); } else { @@ -817,7 +817,7 @@ void TDynamicObject::renderStartJoltSound() { // movement start jolt if( false == m_startjoltplayed ) { auto const velocity { GetVelocity() }; - if( ( physics->V() > 0.0 ? physics->AccSVBased > 0.1 : physics->AccSVBased < 0.1 ) + if( ( physics->V() > 0.0 ? physics->AccSVBased() > 0.1 : physics->AccSVBased() < 0.1 ) && velocity > 1.0 && velocity < 15.0 ) { m_startjolt.play( sound_flags::exclusive ); @@ -1350,7 +1350,7 @@ TDynamicObject::powertrain_sounds::renderTractionMotorSounds( physics::Vehicle c // generic traction motor sounds if( false == motors.empty() ) { - if( std::abs( Vehicle.nrot ) > 0.01 ) { + if( std::abs( Vehicle.nrot() ) > 0.01 ) { auto const &motor { motors.front() }; // frequency calculation @@ -1360,7 +1360,7 @@ TDynamicObject::powertrain_sounds::renderTractionMotorSounds( physics::Vehicle c // NOTE: we supply 1/100th of actual value, as the sound module converts does the opposite, converting received (typically) 0-1 values to 0-100 range normalizer = 60.f * 0.01f; } - auto const motorrevolutions { std::abs( Vehicle.nrot ) * Vehicle.Transmision.Ratio }; + auto const motorrevolutions { std::abs( Vehicle.nrot() ) * Vehicle.Transmision.Ratio }; frequency = motor.m_frequencyoffset + motor.m_frequencyfactor * motorrevolutions * normalizer; diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index 5b3599f3c..0cdd900bd 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -97,7 +97,7 @@ bool TDynamicObject::Update(double dt, double dt1) m_offtrackterrain.reset(); m_offtracksite.terrain( nullptr ); } - if (!physics->PhysicActivation && + if (!physics->PhysicActivation() && !MechInside) { // to drugie, bo będąc w maszynowym blokuje się fizyka // physics.derailment new: a vehicle off the track stopped along its heading still settles: it slides down a // slope, falls over, or comes to rest after the step its physics stopped in @@ -139,7 +139,7 @@ bool TDynamicObject::Update(double dt, double dt1) updateAxleClatter( dDOMoveLen ); // fragment z EXE Kursa - /* if (physics->TrainType==train_type::et42) + /* if (physics->TrainType()==train_type::et42) { if ((physics->DynamicBrakeType=dbrake_switch) && ((physics->BrakePress > @@ -202,7 +202,7 @@ void TDynamicObject::updateTrackParameters() if( ts.R != 0.0 ) { // sin(0) results in division by zero - ts.R = -0.5 * physics->BDist / sin( ts.R * 0.5 ); + ts.R = -0.5 * physics->BDist() / sin( ts.R * 0.5 ); } } } @@ -211,7 +211,7 @@ void TDynamicObject::updateTrackParameters() // ts.R=ComputeRadius(Axle1.pPosition,Axle2.pPosition,Axle3.pPosition,Axle0.pPosition); // Ra: składową pochylenia wzdłużnego mamy policzoną w jednostkowym wektorze // vFront - ts.Len = 1.0; // std::max(physics->BDist,physics->ADist); + ts.Len = 1.0; // std::max(physics->BDist(),physics->ADist()); ts.dHtrack = -vFront.y; // Axle1.pPosition.y-Axle0.pPosition.y; //wektor // między skrajnymi osiami // (!!!odwrotny) @@ -220,7 +220,7 @@ void TDynamicObject::updateTrackParameters() ts.uneven_curvature = glm::dot( 0.5 * ( Axle0.UnevenBend() + Axle1.UnevenBend() ), vLeft ); ts.uneven_cross = MyTrack->uneven_underway().cross; // a buckle of the track under the body: the mean of the curvatures at the outer axles, each over the wheelbase of its bogie - ts.buckle_curvature = 0.5 * ( Axle0.BuckleCurvature( physics->ADist ) + Axle1.BuckleCurvature( physics->ADist ) ); + ts.buckle_curvature = 0.5 * ( Axle0.BuckleCurvature( physics->ADist() ) + Axle1.BuckleCurvature( physics->ADist() ) ); // TTrackParam tp; tp.Width = MyTrack->fTrackWidth; // McZapkie-250202 @@ -242,12 +242,12 @@ void TDynamicObject::updateCouplingState() else { physics->SetInsideConsist(false); } - if( TestFlag( physics->AIFlag, sound::attachcoupler ) ) { + if( TestFlag( physics->AIFlag(), sound::attachcoupler ) ) { auto *driver{ ctOwner ? ctOwner : Mechanik }; if( driver != nullptr ) { driver->CheckVehicles( DriverOrder::connect ); } - ClearFlag( physics->AIFlag, sound::attachcoupler ); + physics->ClearAIFlag( sound::attachcoupler ); } } @@ -309,9 +309,9 @@ void TDynamicObject::updateDriver( double const dt1 ) physics->EngineType == TEngineType::DieselElectric) && physics->EIMCtrlType > 0) { physics->CheckEIMIC(dt1); - if (physics->SpeedCtrl) + if (physics->SpeedCtrl()) physics->CheckSpeedCtrl(dt1); - physics->eimic_real = std::min(physics->eimic,physics->eimicSpeedCtrl); + physics->eimic_real = std::min(physics->eimic,physics->eimicSpeedCtrl()); physics->SendCtrlToNext(VehicleCommand::integratedController, physics->eimic_real, physics->CabActive); } if( Mechanik->primary() @@ -353,7 +353,7 @@ void TDynamicObject::switchOffMainsWithoutBattery() */ && physics->EngineType != TEngineType::DieselEngine && physics->EngineType != TEngineType::WheelsDriven ) { // jeśli bateria wyłączona, a nie diesel ani drezyna reczna - if( physics->MainSwitch( false, physics->TrainType == train_type::emu ? range_t::unit : range_t::local ) ) { + if( physics->MainSwitch( false, physics->TrainType() == train_type::emu ? range_t::unit : range_t::local ) ) { // wyłączyć zasilanie // NOTE: we turn off entire EMU, but only the affected unit for other multi-unit consists physics->RaiseEventFlag(); @@ -362,8 +362,8 @@ void TDynamicObject::switchOffMainsWithoutBattery() // TODO: have this dependant on .fiz-driven flag // NOTE: moved to pantspeed calculation part a little later in the function. all remarks and todo still apply /* - physics->PantFront( false, ( physics->TrainType == train_type::emu ? range::unit : range::local ) ); - physics->PantRear( false, ( physics->TrainType == train_type::emu ? range::unit : range::local ) ); + physics->PantFront( false, ( physics->TrainType() == train_type::emu ? range::unit : range::local ) ); + physics->PantRear( false, ( physics->TrainType() == train_type::emu ? range::unit : range::local ) ); */ } } @@ -482,7 +482,7 @@ void TDynamicObject::applyJointJolt( int const axleindex ) // the arguments keep the order they had up to 26.05.1, 0 in place of the value and the figure in place of the // upper limit, so they work out as the old clamp worked them out up to 26.05.1: the headroom is // Vmax - (Vel + 0.32 Vmax) whatever its sign, and the bump is capped from above only - double const headroom = safe_clamp( 0.0, physics->Vmax, physics->Vmax - ( physics->Vel + physics->Vmax * 0.32f ) ); + double const headroom = safe_clamp( 0.0, physics->Vmax(), physics->Vmax() - ( physics->Vel + physics->Vmax() * 0.32f ) ); double const jolt = headroom * .05f * ( MyTrack->iDamageFlag * 0.25f ); if (MyTrack->eType == tt_Normal) { @@ -505,7 +505,7 @@ void TDynamicObject::updateWheelAngles( double const dt1 ) dWheelAngle[0] += 114.59155902616464175359630962821 * physics->V() * dt1 / physics->WheelDiameterL; // przednie toczne - dWheelAngle[1] += physics->nrot * dt1 * 360.0; // napędne + dWheelAngle[1] += physics->nrot() * dt1 * 360.0; // napędne dWheelAngle[2] += 114.59155902616464175359630962821 * physics->V() * dt1 / physics->WheelDiameterT; // tylne toczne @@ -778,7 +778,7 @@ void TDynamicObject::updatePantographMotion( int const i, TAnimPant *p, double c { double k; // tymczasowy kąt if( physics->pantographAir.Pressure() > ( - physics->TrainType == train_type::emu ? + physics->TrainType() == train_type::emu ? 2.45 : // Ra 2013-12: Niebugocław mówi, że w EZT podnoszą się przy 2.5 3.45 ) ) { // z EXE Kursa diff --git a/vehicle/dynamic/vehicletable.cpp b/vehicle/dynamic/vehicletable.cpp index 9643921c2..9d0e42a22 100644 --- a/vehicle/dynamic/vehicletable.cpp +++ b/vehicle/dynamic/vehicletable.cpp @@ -208,7 +208,7 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { auto const *physics { vehicle->physics }; if( physics->Vel < 0.01 ) { ++counts.standing[ kinds[ index ] ]; - if( ( false == road ) && physics->PhysicActivation ) { + if( ( false == road ) && physics->PhysicActivation() ) { // the test of physics::Vehicle::ComputeTotalForce(), part by part auto const moving = []( neighbour_data const &Neighbour ) { return ( Neighbour.vehicle != nullptr ) @@ -236,7 +236,7 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { ++counts.enabled; if( vehicle->physics->CategoryFlag & 2 ) { ++counts.road; } if( ( vehicle->Mechanik != nullptr ) && vehicle->Mechanik->AIControllFlag() ) { ++counts.ai; } - if( vehicle->physics->PhysicActivation || vehicle->MechInside ) { ++counts.active; } + if( vehicle->physics->PhysicActivation() || vehicle->MechInside ) { ++counts.active; } } Timer::subsystem.vehicles_prepare.start(); @@ -261,7 +261,7 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { std::size_t work { 0 }; for( std::size_t index = 0; index < m_items.size(); ++index ) { auto const *vehicle { m_items[ index ] }; - if( vehicle->physics->PhysicActivation || vehicle->MechInside ) { + if( vehicle->physics->PhysicActivation() || vehicle->MechInside ) { work += ( coarse[ index ] != 0 ? 1 : static_cast( std::max( Iterationcount, 1 ) ) ); } } @@ -374,7 +374,7 @@ derail_motion::contact_body contact_body_of( TDynamicObject const &Vehicle ) { auto const &physics { *Vehicle.physics }; derail_motion::contact_body body; - body.mass = physics.TotalMass; + body.mass = physics.TotalMass(); if( physics.OffTrack.active() ) { body.base = physics.OffTrack.base(); body.velocity = physics.OffTrack.velocity(); @@ -492,14 +492,14 @@ vehicle_table::update_off_track_contacts( double const Deltatime ) { } // one on the rails: along them into its speed, across them on its wheels, as a coupling pulls them off auto &otherPhysics { *other->physics }; - otherPhysics.SetV( otherPhysics.V() + glm::dot( impulse, otherbody.guide ) / std::max( otherPhysics.TotalMass, 1.0 ) ); + otherPhysics.SetV( otherPhysics.V() + glm::dot( impulse, otherbody.guide ) / std::max( otherPhysics.TotalMass(), 1.0 ) ); if( otherPhysics.DamageFlag.HasAll(VehicleDamage::derailed) ) { continue; } glm::dvec3 const otherleft { otherbody.guide.z, 0.0, -otherbody.guide.x }; auto const across { glm::dot( impulse, otherleft ) / Deltatime }; - auto const mass { otherPhysics.TotalMass - otherPhysics.Mred }; - auto const ratio { derail_motion::pull_ratio( std::abs( across ), 0.5 * std::numbers::pi, mass, otherPhysics.NAxles ) }; + auto const mass { otherPhysics.TotalMass() - otherPhysics.Mred() }; + auto const ratio { derail_motion::pull_ratio( std::abs( across ), 0.5 * std::numbers::pi, mass, otherPhysics.NAxles() ) }; // held over the window of the climbing as the bodies slide along each other, or a hit three times as hard // at once: the wheels jump the rail auto const sliding { glm::length( derail_motion::velocity_at( body, hit->point ) - otherbody.velocity ) * Deltatime }; diff --git a/vehicle/dynamic/visual.cpp b/vehicle/dynamic/visual.cpp index dbbe3bf06..7beef31e2 100644 --- a/vehicle/dynamic/visual.cpp +++ b/vehicle/dynamic/visual.cpp @@ -403,7 +403,7 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist) for (int i = 0; i < 4; ++i) if (smWahacze[i]) smWahacze[i]->SetRotate(float3(1, 0, 0), - fWahaczeAmp * cos(physics->eAngle)); + fWahaczeAmp * cos(physics->eAngle())); // cooling shutters // NOTE: shutters display _on state when they're closed, _off otherwise @@ -655,7 +655,7 @@ TDynamicObject::update_shake( double const Timedelta ) { if( std::abs( physics->enrot ) > 0.0 ) { // engine vibration shakevector.x += - std::sin(physics->eAngle * 4.0) * Timedelta * + std::sin(physics->eAngle() * 4.0) * Timedelta * EngineShake.scale // fade in with rpm above threshold * std::clamp( @@ -697,7 +697,7 @@ TDynamicObject::update_shake( double const Timedelta ) { shakevector += glm::dvec3( replaced.sway ? 0.0 : -physics->AccN() * Timedelta * 5.0 * Global.ShakingMultiplierRL, // highlight side sway -physics->AccVert() * Timedelta * Global.ShakingMultiplierUD, - -physics->AccSVBased * Timedelta * 1.5 * Global.ShakingMultiplierBF); // accent acceleration/deceleration + -physics->AccSVBased() * Timedelta * 1.5 * Global.ShakingMultiplierBF); // accent acceleration/deceleration // unevenness of the track under the outer axles auto const ride { 0.5 * ( Axle0.UnevenBend() + Axle1.UnevenBend() ) * ( physics->V() * physics->V() ) }; shakevector += glm::dvec3( diff --git a/vehicle/enginestart.cpp b/vehicle/enginestart.cpp index 88f3e1dfe..1366eb43f 100644 --- a/vehicle/enginestart.cpp +++ b/vehicle/enginestart.cpp @@ -85,7 +85,7 @@ void remote_switch::update(physics::Vehicle *Engine, bool const Closeheld, bool if (Closeheld && Engine->MainSwitchCheck()) { m_heldtime += Deltatime; } - if (m_heldtime > Engine->InitialCtrlDelay) { + if (m_heldtime > Engine->InitialCtrlDelay()) { m_ready = true; } if (m_ready && false == (Closesonrelease && Closeheld)) { diff --git a/vehicle/handover.cpp b/vehicle/handover.cpp index 7361c723a..c232eb155 100644 --- a/vehicle/handover.cpp +++ b/vehicle/handover.cpp @@ -18,7 +18,7 @@ void release_ai_controls(physics::Vehicle &Occupied, physics::Vehicle &Controlli // the AI's hornoff action touches the horn only while the AI drives Occupied.SetWarningSignal(0); // the AI drives the sandbox directly, bypassing the manual and automatic sanding states - if (Controlling.SandDose && false == (Controlling.SandDoseManual || Controlling.SandDoseAuto)) { + if (Controlling.SandDose() && false == (Controlling.SandDoseManual || Controlling.SandDoseAuto)) { Controlling.Sandbox(false); } if (Occupied.DepartureSignal) { @@ -54,7 +54,7 @@ int dimmer_position(physics::Vehicle const &Occupied, bool const Headlightson) { auto const count{static_cast(positions.size())}; auto const isoff{[&positions, count](int const Position) { return Position < 0 || Position >= count || positions[Position].isOff; }}; - if (false == Occupied.enableModernDimmer || false == Headlightson || false == isoff(current)) { + if (false == Occupied.enableModernDimmer() || false == Headlightson || false == isoff(current)) { return current; } if (false == isoff(Occupied.modernDimmerDefaultPosition)) { diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index d5ac18e45..76ca721d4 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -170,9 +170,9 @@ void ui::vehicleparams_panel::render_contents() physics.MainCtrlPos(), physics.MainCtrlActualPos, std::string(isdieselinshuntmode ? to_string(physics.AnPos(), 2) + STR(" (shunt mode)") : std::to_string(physics.ScndCtrlPos()) + "(" + std::to_string(physics.ScndCtrlActualPos) + ")").c_str(), // engine - physics.EnginePower, std::abs(physics.TrainType == train_type::emu ? physics.ShowCurrent(0) : physics.Im), + physics.EnginePower, std::abs(physics.TrainType() == train_type::emu ? physics.ShowCurrent(0) : physics.Im), // revolutions - std::abs(physics.enrot) * 60, std::abs(physics.nrot) * physics.Transmision.Ratio * 60, physics.RventRot * 60, std::abs(physics.MotorBlowers[VehicleEnd::front].revolutions), + std::abs(physics.enrot) * 60, std::abs(physics.nrot()) * physics.Transmision.Ratio * 60, physics.RventRot * 60, std::abs(physics.MotorBlowers[VehicleEnd::front].revolutions), std::abs(physics.MotorBlowers[VehicleEnd::rear].revolutions), physics.diesel.heat.rpmw, physics.diesel.heat.rpmw2); ImGui::TextUnformatted(buffer.data()); @@ -180,7 +180,7 @@ void ui::vehicleparams_panel::render_contents() if (isdieselenginepowered) { std::snprintf(buffer.data(), buffer.size(), STR_C("\nTemperatures:\n engine: %.2f, oil: %.2f, water: %.2f%c%.2f"), physics.diesel.heat.Ts, physics.diesel.heat.To, physics.diesel.heat.temperatura1, - (physics.WaterCircuitsLink ? '-' : '|'), physics.diesel.heat.temperatura2); + (physics.WaterCircuitsLink() ? '-' : '|'), physics.diesel.heat.temperatura2); ImGui::TextUnformatted(buffer.data()); } @@ -221,14 +221,14 @@ void ui::vehicleparams_panel::render_contents() STR_C("Forces:\n tractive: %.1f, brake: %.1f, friction: %.2f%s\nAcceleration:\n tangential: %.2f, normal: %.2f (path radius: %s)\nVelocity: %.2f, distance traveled: %.2f\nPosition: " "[%.2f, %.2f, %.2f]"), // forces - physics.Ft * 0.001f * + physics.Ft() * 0.001f * (physics.CabActive ? physics.CabActive : vehicle.ctOwner ? vehicle.ctOwner->Controlling()->CabActive : 1) + 0.001f, - physics.Fb * 0.001f, physics.Adhesive(physics.RunningTrack.friction), (physics.SlippingWheels ? " (!)" : ""), + physics.Fb * 0.001f, physics.Adhesive(physics.RunningTrack.friction), (physics.SlippingWheels() ? " (!)" : ""), // acceleration - physics.AccSVBased, physics.AccN() + 0.001f, std::string(std::abs(physics.RunningShape.R) > 10000.0 ? "~0" : to_string(physics.RunningShape.R, 0)).c_str(), + physics.AccSVBased(), physics.AccN() + 0.001f, std::string(std::abs(physics.RunningShape.R) > 10000.0 ? "~0" : to_string(physics.RunningShape.R, 0)).c_str(), // velocity vehicle.GetVelocity(), physics.DistCounter(), // position