From 22ebc41d7080f9a0b9214ee5a5a0da6ff23aae0b Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sun, 29 Nov 2026 09:37:01 +0100 Subject: [PATCH] refactor(physics): the parts of the main circuit keep their state to themselves The line breaker, the line contactors, the protective relays and the converter (physics/components/maincircuit.h) become classes: what the .fiz defines is in their public `config`, their state is private, read through queries (IsClosed(), UndervoltageHolds(), IsRunning()) and changed through operations (Close(), ResetGround(), Switch()). The logic that concerns only them moves in: the initialisation of the main circuit, the ground relay, the pressure switch, the resets of the relays, and the whole step of the converter, which gets what it needs from the vehicle as plain values (ConverterSupply). The vehicle still decides when they act (the interlocks, the controller positions, the voltages); the parts don't take a physics::Vehicle. No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit. --- application/driverhints.cpp | 10 +- application/driveruipanels.cpp | 16 +- input/messaging.cpp | 4 +- physics/components/commands.cpp | 17 +- physics/components/controllers.cpp | 80 ++--- physics/components/diesel.cpp | 60 ++-- physics/components/drive.cpp | 38 ++- physics/components/electrics.cpp | 147 +++------ physics/components/fizsections.cpp | 36 +-- physics/components/maincircuit.h | 297 +++++++++++++++--- physics/components/pneumatics.cpp | 4 +- physics/components/traction.cpp | 20 +- physics/vehicle.h | 12 +- simulation/blackboxrecorder.cpp | 4 +- tests/unit/drive.cpp | 10 +- tests/unit/golden.cpp | 2 +- tests/unit/invariants.cpp | 8 +- tests/unit/scenario.cpp | 4 +- tests/unit/test_6dg_power_steps.cpp | 4 +- tests/unit/test_auxiliaries.cpp | 8 +- tests/unit/test_camshaft.cpp | 12 +- tests/unit/test_cntrl.cpp | 12 +- tests/unit/test_collisions.cpp | 4 +- tests/unit/test_commands.cpp | 10 +- tests/unit/test_compressor.cpp | 30 +- tests/unit/test_crew.cpp | 6 +- tests/unit/test_derailment_vehicle.cpp | 2 +- tests/unit/test_engine_shutdown.cpp | 10 +- tests/unit/test_engine_start.cpp | 34 +- tests/unit/test_field_shunting.cpp | 4 +- tests/unit/test_genset.cpp | 46 +-- tests/unit/test_line_contactors.cpp | 32 +- tests/unit/test_line_contactors_interlock.cpp | 60 ++-- tests/unit/test_linebreaker.cpp | 22 +- tests/unit/test_mains_before_pantographs.cpp | 86 ++--- tests/unit/test_oil_pump.cpp | 4 +- tests/unit/test_pressure_switch.cpp | 76 ++--- tests/unit/test_smoke.cpp | 6 +- tests/unit/test_speed_control.cpp | 10 +- tests/unit/test_traction.cpp | 8 +- vehicle/ai/consist.cpp | 14 +- vehicle/ai/controls.cpp | 18 +- vehicle/ai/engine.cpp | 6 +- vehicle/ai/situation.cpp | 4 +- vehicle/cab/auxiliarycommands.cpp | 16 +- vehicle/cab/powercommands.cpp | 14 +- vehicle/cab/setup.cpp | 8 +- vehicle/cab/train.cpp | 12 +- vehicle/cab/update.cpp | 62 ++-- vehicle/dynamic/sounds.cpp | 12 +- vehicle/dynamic/update.cpp | 12 +- vehicle/enginestart.cpp | 2 +- widgets/vehicleparams.cpp | 8 +- 53 files changed, 789 insertions(+), 654 deletions(-) diff --git a/application/driverhints.cpp b/application/driverhints.cpp index d59431dc6..0f49b1933 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -181,7 +181,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) Action, [this](float const /*Parameter*/) { auto const &device { occupied->OilPump }; - return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true || occupied->lineBreaker.closed; } ); + return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true || occupied->lineBreaker.IsClosed(); } ); break; } case driver_hint::oilpumpoff: { @@ -334,7 +334,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) []( TDynamicObject * Vehicle ) { auto *vehicle { Vehicle->physics }; if( vehicle->LineContactorsHeldByLocalConverterSwitch() ) { - vehicle->converter.allowLocal = true; } } ); + vehicle->converter.SetLocalSwitch(true); } } ); } remove_hint( driver_hint::converteroff ); hint( @@ -362,7 +362,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return occupied->converter.overloadRelayStart != start_t::manual || occupied->converter.overloaded == false; } ); + return occupied->converter.config.overloadRelayStart != start_t::manual || occupied->converter.IsOverloaded() == false; } ); break; } case driver_hint::maincircuitgroundreset: { @@ -372,7 +372,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return occupied->protection.groundStart != start_t::manual || occupied->protection.ground == true; } ); + return occupied->protection.config.groundStart != start_t::manual || occupied->protection.GroundHolds() == true; } ); break; } case driver_hint::tractionnmotoroverloadreset: { @@ -406,7 +406,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) Action, [this](float const /*Parameter*/) { // TBD, TODO: replace with consist-wide flag set true if any line breaker is closed? - return mvControlling->lineBreaker.closed == false; } ); + return mvControlling->lineBreaker.IsClosed() == false; } ); break; } // compressor diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 3e3ce61f0..493f65ce5 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -842,21 +842,21 @@ debug_panel::update_section_vehicle( std::vector &Output ) { physics.OilPump.is_active ? 'O' : physics.OilPump.is_enabled ? 'o' : '.', - physics.lineBreaker.closed ? 'M' : '.', + physics.lineBreaker.IsClosed() ? 'M' : '.', physics.FuseFlag ? '!' : '.', - physics.converter.running ? 'X' : - false == physics.converter.allowLocal ? '-' : - physics.converter.allow ? 'x' : + physics.converter.IsRunning() ? 'X' : + false == physics.converter.LocalSwitchOn() ? '-' : + physics.converter.IsAllowed() ? 'x' : '.', - physics.converter.overloaded ? '!' : '.', + physics.converter.IsOverloaded() ? '!' : '.', physics.air.compressor.running ? 'C' : false == physics.air.compressor.allowLocal ? '-' : physics.air.compressor.allow || (physics.air.compressor.start == start_t::automatic && physics.air.compressor.speed > 0.0) ? 'c' : '.', physics.air.compressor.governorLock ? '!' : '.', - physics.lineContactors.forcedOpen ? '-' : - physics.protection.pressureSwitch ? '!' : - physics.lineContactors.closed ? '+' : + physics.lineContactors.IsForcedOpen() ? '-' : + physics.protection.PressureSwitchTripped() ? '!' : + physics.lineContactors.IsClosed() ? '+' : '.', physics.trainHeating.on ? 'H' : physics.trainHeating.allow ? 'h' : diff --git a/input/messaging.cpp b/input/messaging.cpp index 283bd15e8..64a0a74f8 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -295,9 +295,9 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle) r.iPar[20] = Vehicle->physics->ScndCtrlActualPos; // Pozycja bocznikowania r.iPar[21] = Vehicle->physics->ScndCtrlActualPos; // Pozycja bocznikowania r.iPar[22] = Vehicle->physics->ResistorsFlag * 1 - + Vehicle->physics->converter.running * 2 + + Vehicle->physics->converter.IsRunning() * 2 + Vehicle->physics->air.compressor.running * 4 - + Vehicle->physics->lineBreaker.closed * 8 + + Vehicle->physics->lineBreaker.IsClosed() * 8 #ifdef EU07_USEOLDDOORCODE + Vehicle->physics->DoorLeftOpened * 16 + Vehicle->physics->DoorRightOpened * 32 diff --git a/physics/components/commands.cpp b/physics/components/commands.cpp index a5d6f6a2d..875431621 100644 --- a/physics/components/commands.cpp +++ b/physics/components/commands.cpp @@ -144,11 +144,11 @@ bool physics::Vehicle::RunControllerCommand(VehicleCommand const Command, double MainCtrlPos = position; if (DelayCtrlFlag) { - if (lineContactors.lastSwitchTime >= InitialCtrlDelay && MainCtrlPos == 1) - lineContactors.lastSwitchTime = 0; + if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay && MainCtrlPos == 1) + lineContactors.RestartSwitchTimer(); } - else if (lineContactors.lastSwitchTime > CtrlDelay) - lineContactors.lastSwitchTime = 0; + else if (lineContactors.TimeSinceSwitch() > CtrlDelay) + lineContactors.RestartSwitchTimer(); } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } @@ -157,8 +157,8 @@ bool physics::Vehicle::RunControllerCommand(VehicleCommand const Command, double if (ScndCtrlPosNo >= floor(CValue1)) { ScndCtrlPos = static_cast(floor(CValue1)); - if (lineContactors.lastSwitchTime > CtrlDelay) - lineContactors.lastSwitchTime = 0; + if (lineContactors.TimeSinceSwitch() > CtrlDelay) + lineContactors.RestartSwitchTimer(); } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } @@ -364,10 +364,7 @@ bool physics::Vehicle::RunAuxiliariesCommand(VehicleCommand const Command, doubl } else if (Command == VehicleCommand::converterSwitch) /*NBMX*/ { - if (converter.start == start_t::manual) - { - converter.allow = CValue1 > 0.0; - } + converter.Switch(CValue1 > 0.0); OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } else if (Command == VehicleCommand::batterySwitch) /*NBMX*/ diff --git a/physics/components/controllers.cpp b/physics/components/controllers.cpp index d88cdc6c8..4016f25a9 100644 --- a/physics/components/controllers.cpp +++ b/physics/components/controllers.cpp @@ -97,11 +97,11 @@ bool physics::Vehicle::IncMainCtrl(int CtrlSpeed) { if (DelayCtrlFlag) { - if (lineContactors.lastSwitchTime >= InitialCtrlDelay && MainCtrlPos == 1) - lineContactors.lastSwitchTime = 0; + if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay && MainCtrlPos == 1) + lineContactors.RestartSwitchTimer(); } - else if (lineContactors.lastSwitchTime > CtrlDelay) - lineContactors.lastSwitchTime = 0; + else if (lineContactors.TimeSinceSwitch() > CtrlDelay) + lineContactors.RestartSwitchTimer(); } return OK; } @@ -226,11 +226,11 @@ bool physics::Vehicle::DecMainCtrl(int CtrlSpeed) { if (DelayCtrlFlag) { - if (lineContactors.lastSwitchTime >= InitialCtrlDelay) - lineContactors.lastSwitchTime = 0; + if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay) + lineContactors.RestartSwitchTimer(); } - else if (lineContactors.lastSwitchTime > CtrlDownDelay) - lineContactors.lastSwitchTime = 0; + else if (lineContactors.TimeSinceSwitch() > CtrlDownDelay) + lineContactors.RestartSwitchTimer(); } return OK; } @@ -363,7 +363,7 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed) // TBD, TODO: refactor this validation as part of relay check routine (currently in tractionforce() // TBD, TODO: diesel electric engine utilize scndctrlactualpos like the other types? if (EngineType == TEngineType::DieselElectric && - (IsMainCtrlNoPowerPos() || fieldshunting::diesel_electric(AutoRelayType, FieldShuntSwitch, AutoRelayFlag) != fieldshunting::control::manual || ShuntMode || false == lineBreaker.closed)) + (IsMainCtrlNoPowerPos() || fieldshunting::diesel_electric(AutoRelayType, FieldShuntSwitch, AutoRelayFlag) != fieldshunting::control::manual || ShuntMode || false == lineBreaker.IsClosed())) { OK = false; } @@ -392,8 +392,8 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed) OK = false; // if OK then LastRelayTime:=0; // hunter-101012: poprawka - if (OK && lineContactors.lastSwitchTime > CtrlDelay) - lineContactors.lastSwitchTime = 0; + if (OK && lineContactors.TimeSinceSwitch() > CtrlDelay) + lineContactors.RestartSwitchTimer(); if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1 && MainCtrlPos > 0) { @@ -454,8 +454,8 @@ bool physics::Vehicle::DecScndCtrl(int CtrlSpeed) OK = false; // if OK then LastRelayTime:=0; // hunter-101012: poprawka - if (OK && lineContactors.lastSwitchTime > CtrlDownDelay) - lineContactors.lastSwitchTime = 0; + if (OK && lineContactors.TimeSinceSwitch() > CtrlDownDelay) + lineContactors.RestartSwitchTimer(); if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1) { @@ -549,7 +549,7 @@ bool physics::Vehicle::AutoRelayCheck(void) // yBARC - rozlaczenie stycznikow liniowych if (motorconnectorsoff || (HasCamshaft ? IsMainCtrlActualNoPowerPos() : IsMainCtrlNoPowerPos())) { - lineContactors.closed = false; + lineContactors.Open(); if (false == brakes.electrodynamic.on) { Im = 0; @@ -569,7 +569,7 @@ bool physics::Vehicle::AutoRelayCheck(void) // przejście dalej przez danie nastawnika na dalszą pozycję - tak to do // tej pory działało i na tym się opiera fizyka ET22-2k { - if (lineContactors.closed) + if (lineContactors.IsClosed()) { if (RList[MainCtrlActualPos].R == 0 && (ScndCtrlActualPos > 0 || ScndCtrlPos > 0) && (!CoupledCtrl || RList[MainCtrlActualPos].Relay == MainCtrlPos)) { // zmieniaj scndctrlactualpos @@ -585,7 +585,7 @@ bool physics::Vehicle::AutoRelayCheck(void) OK = AutoRelayLineContactorsStep(motorconnectorsoff); } if (OK) - lineContactors.lastSwitchTime = 0; + lineContactors.RestartSwitchTimer(); return OK; } @@ -598,7 +598,7 @@ bool physics::Vehicle::AutoRelayShuntStep(bool const ARFASI2) // scnd bez samoczynnego rozruchu if (ScndCtrlActualPos < ScndCtrlPos) { - if (lineContactors.lastSwitchTime > CtrlDelay && ARFASI2) + if (lineContactors.TimeSinceSwitch() > CtrlDelay && ARFASI2) { ++ScndCtrlActualPos; SetFlag(SoundFlag, sound::shuntfield); @@ -607,7 +607,7 @@ bool physics::Vehicle::AutoRelayShuntStep(bool const ARFASI2) } else if (ScndCtrlActualPos > ScndCtrlPos) { - if (lineContactors.lastSwitchTime > CtrlDownDelay && TrainType != train_type::emu) + if (lineContactors.TimeSinceSwitch() > CtrlDownDelay && TrainType != train_type::emu) { --ScndCtrlActualPos; SetFlag(SoundFlag, sound::shuntfield); @@ -640,7 +640,7 @@ bool physics::Vehicle::AutoRelayMainStep(bool const ARFASI) } else if (RList[MainCtrlActualPos].R > 0 && ScndCtrlActualPos > 0) { - if (lineContactors.lastSwitchTime > CtrlDownDelay) + if (lineContactors.TimeSinceSwitch() > CtrlDownDelay) { --ScndCtrlActualPos; // boczniki nie dzialaja na poz. oporowych SetFlag(SoundFlag, sound::shuntfield); @@ -681,7 +681,7 @@ bool physics::Vehicle::AutoRelayMainUp(bool const ARFASI) OK = true; } } - else if (lineContactors.lastSwitchTime > CtrlDelay && ARFASI) + else if (lineContactors.TimeSinceSwitch() > CtrlDelay && ARFASI) { OK = AutoRelayMainNotchUp(); } @@ -704,7 +704,7 @@ bool physics::Vehicle::AutoRelayMainNotchUp() DelayCtrlFlag = true; // tryb przejscia OK = true; } - else if (lineContactors.lastSwitchTime > 4 * CtrlDelay) // przejscie + else if (lineContactors.TimeSinceSwitch() > 4 * CtrlDelay) // przejscie { DelayCtrlFlag = false; @@ -753,7 +753,7 @@ bool physics::Vehicle::AutoRelayMainDown() SetFlag(SoundFlag, sound::parallel); } } - else if (lineContactors.lastSwitchTime > CtrlDownDelay) + else if (lineContactors.TimeSinceSwitch() > CtrlDownDelay) { if (TrainType != train_type::emu) // tutaj powinien być tryb sterowania wałem { @@ -779,9 +779,9 @@ bool physics::Vehicle::AutoRelayLineContactorsStep(bool const motorconnectorsoff { DelayCtrlFlag = true; - if (lineContactors.lastSwitchTime >= InitialCtrlDelay) + if (lineContactors.TimeSinceSwitch() >= InitialCtrlDelay) { - lineContactors.closed = true; + lineContactors.Close(); MainCtrlActualPos = 1; DelayCtrlFlag = false; SetFlag(SoundFlag, sound::relay | sound::loud); @@ -793,7 +793,7 @@ bool physics::Vehicle::AutoRelayLineContactorsStep(bool const motorconnectorsoff DelayCtrlFlag = false; } - if (false == lineContactors.closed && (MainCtrlActualPos > 0 || ScndCtrlActualPos > 0)) + if (false == lineContactors.IsClosed() && (MainCtrlActualPos > 0 || ScndCtrlActualPos > 0)) { OK |= CamshaftRunDown(); } @@ -813,7 +813,7 @@ bool physics::Vehicle::CamshaftRunDown() { OK = CamshaftRunDownEMU(); } - else if (lineContactors.lastSwitchTime > CtrlDownDelay) // wal kulakowy dwukierunkowy + else if (lineContactors.TimeSinceSwitch() > CtrlDownDelay) // wal kulakowy dwukierunkowy { if (ScndCtrlActualPos > 0) { @@ -830,7 +830,7 @@ bool physics::Vehicle::CamshaftRunDown() else if (HasCamshaft) { // wal kulakowy dwukierunkowy - if (lineContactors.lastSwitchTime > CtrlDownDelay) + if (lineContactors.TimeSinceSwitch() > CtrlDownDelay) { if (MainCtrlActualPos > 0) { @@ -863,7 +863,7 @@ bool physics::Vehicle::CamshaftRunDownEMU() else { - if (lineContactors.lastSwitchTime > CtrlDownDelay) + if (lineContactors.TimeSinceSwitch() > CtrlDownDelay) { if (MainCtrlActualPos < RlistSize) @@ -894,29 +894,29 @@ bool physics::Vehicle::MotorConnectorsCheck() // hunter-111211: wylacznik cisnieniowy // (on some vehicles it watches the brake pipe alone) - protection.pressureSwitch = protection.hasPressureSwitch && ((protection.pressureSwitchWatchesCylinders && brakes.cylinderPressure > 2.0) || brakePipe.pressure < 3.6); + protection.UpdatePressureSwitch(brakes.cylinderPressure, brakePipe.pressure); - if (true == protection.pressureSwitch) + if (true == protection.PressureSwitchTripped()) { return false; } // a line breaker closed ahead of the pantographs holds without voltage; what cuts the motors off there is its // undervoltage relay, which elsewhere opens the line breaker - auto const undervoltage{lineBreaker.pantographsRequireIt && false == protection.noVoltage}; + auto const undervoltage{lineBreaker.config.pantographsRequireIt && false == protection.UndervoltageHolds()}; - auto const connectorsoff{false == lineBreaker.closed || undervoltage || true == FuseFlag || true == lineContactors.forcedOpen || DirActive == 0}; + auto const connectorsoff{false == lineBreaker.IsClosed() || undervoltage || true == FuseFlag || true == lineContactors.IsForcedOpen() || DirActive == 0}; return false == connectorsoff && LineContactorsInterlockReleased(); } bool physics::Vehicle::LineContactorsInterlockReleased() const { - switch (lineContactors.interlock) + switch (lineContactors.config.interlock) { case line_contactors_interlock::converter: // the converter of this very vehicle, not the 110 V of the trainset: a section with its fans off doesn't start - return converter.running; + return converter.IsRunning(); case line_contactors_interlock::motor_blowers: return std::ranges::all_of(MotorBlowers, [this](auto const &Blower) { if (Blower.min_start_velocity < 0) @@ -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.lastSwitchTime > 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 @@ -1120,10 +1120,10 @@ void physics::Vehicle::EIMICFromFourPositions(double dt) } } if (MainCtrlActualPos == MainCtrlPos) - lineContactors.lastSwitchTime += dt; + lineContactors.AdvanceSwitchTimer(dt); else { - lineContactors.lastSwitchTime = 0; + lineContactors.RestartSwitchTimer(); MainCtrlActualPos = MainCtrlPos; } } @@ -1136,7 +1136,7 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak UniversalControllerTrainBrake(); } - if (MainCtrlActualPos != MainCtrlPos || lineContactors.lastSwitchTime > InitialCtrlDelay) + if (MainCtrlActualPos != MainCtrlPos || lineContactors.TimeSinceSwitch() > InitialCtrlDelay) { auto const &position{UniCtrlList[MainCtrlPos]}; double ramped{eimic}; @@ -1148,10 +1148,10 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak eimic = UniCtrlValStep > 0.0 ? stepped_uc_value(eimic, ramped, position, UniCtrlValStep, MainCtrlActualPos != MainCtrlPos, eimic_step_progress) : ramped; } if (MainCtrlActualPos == MainCtrlPos) - lineContactors.lastSwitchTime += dt; + lineContactors.AdvanceSwitchTimer(dt); else { - lineContactors.lastSwitchTime = 0; + lineContactors.RestartSwitchTimer(); MainCtrlActualPos = MainCtrlPos; } if (brakes.distributor->GetEDBCP() > 0.3 && eimic < 0 && !UniCtrlIntegratedLocalBrakeCtrl) // when braking with pneumatic brake diff --git a/physics/components/diesel.cpp b/physics/components/diesel.cpp index d7e7ecc85..decd11eb5 100644 --- a/physics/components/diesel.cpp +++ b/physics/components/diesel.cpp @@ -76,8 +76,8 @@ void physics::Vehicle::FuelPumpCheck(double const /*Timestep*/) FuelPump.is_active = true == (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) && false == FuelPump.is_disabled && (FuelPump.is_active || (FuelPump.start_type == manual ? FuelPump.is_enabled : - FuelPump.start_type == automatic ? diesel.startupRequested || lineBreaker.closed : - FuelPump.start_type == manualwithautofallback ? FuelPump.is_enabled || diesel.startupRequested || lineBreaker.closed : + FuelPump.start_type == automatic ? diesel.startupRequested || lineBreaker.IsClosed() : + FuelPump.start_type == manualwithautofallback ? FuelPump.is_enabled || diesel.startupRequested || lineBreaker.IsClosed() : false)); // shouldn't ever get this far but, eh } @@ -85,7 +85,7 @@ void physics::Vehicle::FuelPumpCheck(double const /*Timestep*/) void physics::Vehicle::OilPumpCheck(double const Timestep) { - OilPump.is_active = true == (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) && false == lineBreaker.closed && false == OilPump.is_disabled && + OilPump.is_active = true == (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable) && false == lineBreaker.IsClosed() && false == OilPump.is_disabled && (OilPump.is_active || (OilPump.start_type == start_t::manual ? OilPump.is_enabled : OilPump.start_type == start_t::automatic ? diesel.startupRequested : OilPump.start_type == start_t::manualwithautofallback ? OilPump.is_enabled || diesel.startupRequested : @@ -339,7 +339,7 @@ double physics::Vehicle::DieselElectricTargetRevolutions() if (EIMCtrlType > 0) // sterowanie cyfrowe tmp = (DElist[0].RPM + (DElist[MainCtrlPosNo].RPM - DElist[0].RPM) * std::max(0.0, eimic_real)) / 60.0; else - tmp = DElist[protection.pressureSwitch ? MainCtrlNoPowerPos() : MainCtrlPos].RPM / 60.0; + tmp = DElist[protection.PressureSwitchTripped() ? MainCtrlNoPowerPos() : MainCtrlPos].RPM / 60.0; if (true == trainHeating.allow && trainHeating.power > 0 && trainHeating.engineRpm > 0) { @@ -399,7 +399,7 @@ void physics::Vehicle::DieselElectricTractionForce(double tmp) PosRatio = currentgenpower / DElist[MainCtrlPosNo].GenPower; // stosunek mocy teraz do mocy max // NOTE: Mains in this context is working diesel engine - if (true == lineContactors.closed) + if (true == lineContactors.IsClosed()) Ft = DieselElectricForce(tmpV, power, PosRatio, tmp); else Ft = 0; // jak nastawnik na zero, to sila tez zero @@ -433,7 +433,7 @@ void physics::Vehicle::DieselElectricTractionForce(double tmp) // przekazniki bocznikowania, kazdy inny dla kazdej pozycji if (auto const fieldshuntingcontrol{fieldshunting::diesel_electric(AutoRelayType, FieldShuntSwitch, AutoRelayFlag)}; - false == lineContactors.closed || ShuntMode || fieldshuntingcontrol == fieldshunting::control::off) + false == lineContactors.IsClosed() || ShuntMode || fieldshuntingcontrol == fieldshunting::control::off) { ScndCtrlPos = 0; } @@ -448,7 +448,7 @@ void physics::Vehicle::DieselElectricTractionForce(double tmp) // tmp, the power the generator gives void physics::Vehicle::DieselElectricShuntForce(double const tmpV, double &tmp) { - if (true == lineContactors.closed) + if (true == lineContactors.IsClosed()) { EngineVoltage = SST[MainCtrlPos].Umax * AnPos + SST[MainCtrlPos].Umin * (1.0 - AnPos); // NOTE: very crude way to approximate power generated at current rpm instead of instant top output @@ -472,7 +472,7 @@ double physics::Vehicle::DieselElectricDigitalForce(double const tmpV, double &t tempImax = DElist[MainCtrlPosNo].Imax * eimic_positive; tempUmax = DElist[MainCtrlPosNo].Umax * std::min(eimic_positive, rpmratio); auto const tempPmax = DElist[MainCtrlPosNo].GenPower * std::min(eimic_positive, rpmratio); - if (true == lineContactors.closed) + if (true == lineContactors.IsClosed()) Ft = DieselElectricForce(tmpV, tempPmax, eimic_positive, tempPmax); else Ft = 0; // jak nastawnik na zero, to sila tez zero @@ -539,7 +539,7 @@ void physics::Vehicle::DieselElectricGenerator(double const tmp, double const te if (EngineVoltage > tempUmax || Im == 0) { // gdy wychodzi za duze napiecie albo przy biegu jalowym (jest cos takiego?) - EngineVoltage = tempUmax * (converter.running ? 1 : 0); + EngineVoltage = tempUmax * (converter.IsRunning() ? 1 : 0); } EnginePower = EngineVoltage * Im / 1000.0; @@ -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.closed && 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); } @@ -705,12 +705,12 @@ bool physics::Vehicle::dizel_AutoGearCheck(void) auto const VelDown{(motor_param(ScndCtrlActualPos).fi0 != 0.0 && eimic_real <= 0.0 ? motor_param(ScndCtrlActualPos).fi0 : motor_param(ScndCtrlActualPos).fi)}; - if (motor_param(ScndCtrlActualPos).AutoSwitch && lineBreaker.closed) + if (motor_param(ScndCtrlActualPos).AutoSwitch && lineBreaker.IsClosed()) { OK = dizel_GearShiftCheck(VelUp, VelDown); } - if (lineBreaker.closed) + if (lineBreaker.IsClosed()) { dizel_ClutchCheck(); } @@ -892,7 +892,7 @@ bool physics::Vehicle::dizel_Update(double dt) OilPumpCheck(dt); FuelPumpCheck(dt); // the engine being started fires once the starter has turned it a while; one stopped meanwhile starts over - diesel.firingCountdown = (lineBreaker.closed ? std::max(0.0, diesel.firingCountdown - dt) : 0.0); + diesel.firingCountdown = (lineBreaker.IsClosed() ? std::max(0.0, diesel.firingCountdown - dt) : 0.0); if (true == diesel.startupRequested && true == dizel_StartupCheck()) { @@ -907,7 +907,7 @@ bool physics::Vehicle::dizel_Update(double dt) // TODO: split engine and main circuit state indicator in two separate flags LastSwitchingTime = 0; Timer::subsystem.switching.note(Timer::switching_counter::diesel, this, &TypeName, &Name); - lineBreaker.closed = true; + lineBreaker.Close(); diesel.spinningUp = true; diesel.firingCountdown = diesel.smokeDelay; enrot = std::max(enrot, @@ -915,9 +915,9 @@ bool physics::Vehicle::dizel_Update(double dt) EngineType == TEngineType::DieselEngine ? diesel.minRevolutions : DElist[0].RPM / 60.0)); } - diesel.spinningUp = diesel.spinningUp && lineBreaker.closed && enrot < 0.95 * (EngineType == TEngineType::DieselEngine ? diesel.minRevolutions : DElist[0].RPM / 60.0); + diesel.spinningUp = diesel.spinningUp && lineBreaker.IsClosed() && enrot < 0.95 * (EngineType == TEngineType::DieselEngine ? diesel.minRevolutions : DElist[0].RPM / 60.0); - if (true == lineBreaker.closed && false == FuelPump.is_active) + if (true == lineBreaker.IsClosed() && false == FuelPump.is_active) { // knock out the engine if the fuel pump isn't feeding it // TBD, TODO: grace period before the engine is starved for fuel and knocked out @@ -948,7 +948,7 @@ double physics::Vehicle::dizel_fillcheck(int mcp, double dt) { auto realfill{0.0}; - if (true == lineBreaker.closed && MainCtrlPosNo > 0 && true == FuelPump.is_active) + if (true == lineBreaker.IsClosed() && MainCtrlPosNo > 0 && true == FuelPump.is_active) { if (true == diesel.ignitionRequested && LastSwitchingTime >= 0.9 * InitialCtrlDelay) @@ -1184,7 +1184,7 @@ double physics::Vehicle::dizel_Momentum(double Fill, double n, double dt) // an engine stalling stops those started together with it, once. one already stopped, from its own switch or // another vehicle's, or not started at all, has nothing to stop: it stays quiet, rather than stop every frame // the engines started on their own or from the separate switches (eu07/maszyna#80) - if (true == lineBreaker.closed) + if (true == lineBreaker.IsClosed()) { MainSwitch(false, MainSwitchRange()); } @@ -1203,22 +1203,22 @@ void physics::Vehicle::hydro_TCFillCheck(double dt) { // napelnianie przetwornika bool IsPower = EIMCtrlType > 0 ? eimic_real > 0.005 : MainCtrlPowerPos() > 0; - if (IsPower && lineBreaker.closed && enrot > diesel.minRevolutions * 0.9) + if (IsPower && lineBreaker.IsClosed() && enrot > diesel.minRevolutions * 0.9) torqueConverter.fill += torqueConverter.fillRateIncrease * dt; // oproznianie przetwornika - if ((!IsPower && Vel < diesel.converterReleaseVelocity) || !lineBreaker.closed || enrot < diesel.minRevolutions * 0.8) + if ((!IsPower && Vel < diesel.converterReleaseVelocity) || !lineBreaker.IsClosed() || enrot < diesel.minRevolutions * 0.8) torqueConverter.fill -= torqueConverter.fillRateDecrease * dt; // obcinanie zakresu torqueConverter.fill = std::clamp(torqueConverter.fill, 0.0, 1.0); // blokowanie sprzegla blokującego - if (Vel > torqueConverter.lockupSpeed && lineBreaker.closed && enrot > 0.9 * diesel.minRevolutions && IsPower) + if (Vel > torqueConverter.lockupSpeed && lineBreaker.IsClosed() && enrot > 0.9 * diesel.minRevolutions && IsPower) { torqueConverter.lockedUp = true; torqueConverter.lockupRate += torqueConverter.fillRateIncrease * dt; } // luzowanie sprzegla blokujacego - if (Vel < (IsPower ? torqueConverter.lockupSpeed : torqueConverter.unlockSpeed) || !lineBreaker.closed || enrot < 0.8 * diesel.minRevolutions) + if (Vel < (IsPower ? torqueConverter.lockupSpeed : torqueConverter.unlockSpeed) || !lineBreaker.IsClosed() || enrot < 0.8 * diesel.minRevolutions) { torqueConverter.lockedUp = false; torqueConverter.lockupRate -= torqueConverter.fillRateDecrease * dt; @@ -1266,7 +1266,7 @@ void physics::Vehicle::hydro_TCTorque() double physics::Vehicle::dizel_MomentumRetarder(double n, double dt) { - double RetarderRequest = lineBreaker.closed ? std::max(0.0, -eimic_real) : 0; + double RetarderRequest = lineBreaker.IsClosed() ? std::max(0.0, -eimic_real) : 0; if (retarder.withIndividual) RetarderRequest = LocalBrakeRatio(); if (Vel < retarder.minVelocity) @@ -1344,8 +1344,8 @@ void physics::Vehicle::dizel_Heat(double const dt) diesel.heat.Te = Global.AirTemperature; - auto const engineon{(lineBreaker.closed ? 1 : 0)}; - auto const engineoff{(lineBreaker.closed ? 0 : 1)}; + auto const engineon{(lineBreaker.IsClosed() ? 1 : 0)}; + auto const engineoff{(lineBreaker.IsClosed() ? 0 : 1)}; auto const rpm{enrot * 60}; // TODO: calculate this once and cache for further use, instead of doing it repeatedly all over the place auto const revolutionsfactor{EngineRPMRatio()}; @@ -1355,11 +1355,11 @@ void physics::Vehicle::dizel_Heat(double const dt) auto const gw2 = engineon * std::lerp(gwmin2, gwmax2, revolutionsfactor) + waterpump * 1000 + engineoff * 200; auto const gwO = std::lerp(gwmin, gwmax, revolutionsfactor); - diesel.heat.water.is_cold = diesel.heat.water.config.temp_min > 0 && diesel.heat.temperatura1 < diesel.heat.water.config.temp_min - (lineBreaker.closed ? 5 : 0); + diesel.heat.water.is_cold = diesel.heat.water.config.temp_min > 0 && diesel.heat.temperatura1 < diesel.heat.water.config.temp_min - (lineBreaker.IsClosed() ? 5 : 0); diesel.heat.water.is_hot = diesel.heat.water.config.temp_max > 0 && diesel.heat.temperatura1 > diesel.heat.water.config.temp_max - (diesel.heat.water.is_hot ? 8 : 0); - diesel.heat.water_aux.is_cold = diesel.heat.water_aux.config.temp_min > 0 && diesel.heat.temperatura2 < diesel.heat.water_aux.config.temp_min - (lineBreaker.closed ? 5 : 0); + diesel.heat.water_aux.is_cold = diesel.heat.water_aux.config.temp_min > 0 && diesel.heat.temperatura2 < diesel.heat.water_aux.config.temp_min - (lineBreaker.IsClosed() ? 5 : 0); diesel.heat.water_aux.is_hot = diesel.heat.water_aux.config.temp_max > 0 && diesel.heat.temperatura2 > diesel.heat.water_aux.config.temp_max - (diesel.heat.water_aux.is_hot ? 8 : 0); - diesel.heat.oil.is_cold = diesel.heat.oil.config.temp_min > 0 && diesel.heat.To < diesel.heat.oil.config.temp_min - (lineBreaker.closed ? 5 : 0); + diesel.heat.oil.is_cold = diesel.heat.oil.config.temp_min > 0 && diesel.heat.To < diesel.heat.oil.config.temp_min - (lineBreaker.IsClosed() ? 5 : 0); diesel.heat.oil.is_hot = diesel.heat.oil.config.temp_max > 0 && diesel.heat.To > diesel.heat.oil.config.temp_max - (diesel.heat.oil.is_hot ? 8 : 0); // engine overheat check diesel.heat.engine_is_hot = diesel.heat.engine_max_temp > 0 && diesel.heat.Ts > diesel.heat.engine_max_temp - (diesel.heat.engine_is_hot ? 8 : 0); @@ -1400,7 +1400,7 @@ void physics::Vehicle::dizel_Heat(double const dt) { // auxiliary water circuit setup diesel.heat.water_aux.is_warm = true == diesel.heat.cooling || - (true == lineBreaker.closed && lowVoltage.batteryVoltage > 0.75 * lowVoltage.nominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ + (true == lineBreaker.IsClosed() && lowVoltage.batteryVoltage > 0.75 * lowVoltage.nominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ && diesel.heat.water_aux.config.temp_cooling > 0 && diesel.heat.temperatura2 > diesel.heat.water_aux.config.temp_cooling - (diesel.heat.water_aux.is_warm ? 8 : 0)); auto const PTC2{(diesel.heat.water_aux.is_warm /*or PTC2p*/ ? 1 : 0)}; diesel.heat.rpmwz2 = static_cast(PTC2 * (diesel.heat.fan_speed >= 0 ? rpm * diesel.heat.fan_speed : diesel.heat.fan_speed * -1)); @@ -1423,7 +1423,7 @@ void physics::Vehicle::dizel_Heat(double const dt) diesel.heat.water.is_flowing = diesel.heat.water.config.temp_flow < 0 || diesel.heat.temperatura1 > diesel.heat.water.config.temp_flow - (diesel.heat.water.is_flowing ? 5 : 0); auto const obieg{(diesel.heat.water.is_flowing ? 1 : 0)}; diesel.heat.water.is_warm = - true == diesel.heat.cooling || (true == lineBreaker.closed && lowVoltage.batteryVoltage > 0.75 * lowVoltage.nominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ + true == diesel.heat.cooling || (true == lineBreaker.IsClosed() && lowVoltage.batteryVoltage > 0.75 * lowVoltage.nominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ && diesel.heat.water.config.temp_cooling > 0 && diesel.heat.temperatura1 > diesel.heat.water.config.temp_cooling - (diesel.heat.water.is_warm ? 8 : 0)); auto const PTC1{(diesel.heat.water.is_warm /*or PTC1p*/ ? 1 : 0)}; diesel.heat.rpmwz = static_cast(PTC1 * (diesel.heat.fan_speed >= 0 ? rpm * diesel.heat.fan_speed : diesel.heat.fan_speed * -1)); diff --git a/physics/components/drive.cpp b/physics/components/drive.cpp index 648c6cac4..309a040ba 100644 --- a/physics/components/drive.cpp +++ b/physics/components/drive.cpp @@ -109,7 +109,7 @@ namespace void updateRadiatorFans(physics::Vehicle &vehicle, double const dt) { auto &heat{vehicle.diesel.heat}; - if (true == vehicle.lineBreaker.closed) + if (true == vehicle.lineBreaker.IsClosed()) { heat.rpmw += static_cast(std::clamp(heat.rpmwz - heat.rpmw, -100.f, 50.f) * dt); heat.rpmw2 += static_cast(std::clamp(heat.rpmwz2 - heat.rpmw2, -100.f, 50.f) * dt); @@ -125,7 +125,7 @@ void updateRadiatorFans(physics::Vehicle &vehicle, double const dt) // else it needs the voltage of the source bool linePowerAvailable(physics::Vehicle const &vehicle) { - return vehicle.lineBreaker.pantographsRequireIt ? vehicle.lowVoltage.power24vAvailable || vehicle.lowVoltage.power110vAvailable : vehicle.EnginePowerSourceVoltage() > 0.5 * vehicle.EnginePowerSource.MaxVoltage; + return vehicle.lineBreaker.config.pantographsRequireIt ? vehicle.lowVoltage.power24vAvailable || vehicle.lowVoltage.power110vAvailable : vehicle.EnginePowerSourceVoltage() > 0.5 * vehicle.EnginePowerSource.MaxVoltage; } // a notch of the master controller of the drives without steps of their own (no engine, Dumb, diesel-electric, @@ -265,13 +265,14 @@ public: // where a start begins, as the line breaker it stands in for wouldn't close on a running position either: at // zero, or at the first position, which is the first resistance step, where the line contactors close on any // start, and where the AI waits for them rather than going back to zero - auto const novoltrelaypicksup{false == vehicle.lineBreaker.pantographsRequireIt || vehicle.protection.noVoltage || vehicle.MainCtrlPowerPos() <= 1}; + auto const novoltrelaypicksup{false == vehicle.lineBreaker.config.pantographsRequireIt || vehicle.protection.UndervoltageHolds() || vehicle.MainCtrlPowerPos() <= 1}; auto const &source{vehicle.EnginePowerSource}; - vehicle.protection.noVoltage = source.SourceType != TPowerSource::CurrentCollector || (voltage >= source.CollectorParameters.MinV && novoltrelaypicksup); - vehicle.protection.overvoltage = source.SourceType != TPowerSource::CurrentCollector || voltage <= source.CollectorParameters.MaxV || false == source.CollectorParameters.OVP; + vehicle.protection.SetVoltageRelays( + source.SourceType != TPowerSource::CurrentCollector || (voltage >= source.CollectorParameters.MinV && novoltrelaypicksup), + source.SourceType != TPowerSource::CurrentCollector || voltage <= source.CollectorParameters.MaxV || false == source.CollectorParameters.OVP); // wywalanie szybkiego z powodu niewłaściwego napięcia // (a line breaker closed ahead of the pantographs holds without voltage) - vehicle.EventFlag |= true == vehicle.lineBreaker.closed && ((false == vehicle.protection.noVoltage && false == vehicle.lineBreaker.pantographsRequireIt) || false == vehicle.protection.overvoltage) && + vehicle.EventFlag |= 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 } bool UpdateEngine(physics::Vehicle &vehicle, double /*dt*/) const override @@ -281,10 +282,10 @@ public: } void UpdateEngineVoltage(physics::Vehicle &vehicle, double const dt) const override { - vehicle.lineContactors.lastSwitchTime += dt; + vehicle.lineContactors.AdvanceSwitchTimer(dt); // potem ulepszyc! pantogtrafy! // Ra 2014-03: uwzględnienie kierunku jazdy w napięciu na silnikach, a powinien być zdefiniowany nawrotnik - vehicle.EngineVoltage = vehicle.lineBreaker.closed ? vehicle.EnginePowerSourceVoltage() : 0.0; + vehicle.EngineVoltage = vehicle.lineBreaker.IsClosed() ? vehicle.EnginePowerSourceVoltage() : 0.0; if (vehicle.CabActive == 0) { vehicle.EngineVoltage *= vehicle.DirActive; @@ -334,7 +335,7 @@ public: // nie wchodzić w funkcję bez potrzeby // (a line breaker closed ahead of the pantographs holds without voltage) // (the source by the traction selector of a dual-mode vehicle: the pantographs or the genset) - if (vehicle.lineBreaker.closed && ((vehicle.TractionSupplyVoltage() < vehicle.TractionSupplyMinVoltage() && false == vehicle.lineBreaker.pantographsRequireIt) || + 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 @@ -457,7 +458,7 @@ public: double UpdateEngineRevolutions(physics::Vehicle &vehicle, double const dt, double & /*transmission*/, double & /*moment*/) const override { double target{0.0}; - if (true == vehicle.lineBreaker.closed && true == vehicle.FuelPump.is_active) + if (true == vehicle.lineBreaker.IsClosed() && true == vehicle.FuelPump.is_active) { target = vehicle.DieselElectricTargetRevolutions(); } @@ -494,7 +495,7 @@ public: void UpdateVentilators(physics::Vehicle &vehicle, double const dt) const override { // NOTE: for this type RventRot is the speed of motor blowers; we also update radiator fans while at it - if (true == vehicle.lineBreaker.closed) + if (true == vehicle.lineBreaker.IsClosed()) { // TBD, TODO: currently ignores RVentType, fix this? vehicle.RventRot += std::clamp(vehicle.enrot - vehicle.RventRot, -100.0, 50.0) * dt; @@ -528,9 +529,18 @@ public: void CheckVoltageRelays(physics::Vehicle &vehicle) const override { // TODO: move this to the auto relay check when the electric engine code paths are unified - vehicle.lineContactors.closed |= vehicle.lineBreaker.closed && false == vehicle.lineContactors.closed && vehicle.MainCtrlPowerPos() == 1; - vehicle.lineContactors.closed &= vehicle.MotorConnectorsCheck(); - vehicle.lineContactors.closed &= vehicle.MainCtrlPowerPos() > 0; + if (vehicle.lineBreaker.IsClosed() && false == vehicle.lineContactors.IsClosed() && vehicle.MainCtrlPowerPos() == 1) + { + vehicle.lineContactors.Close(); + } + if (false == vehicle.MotorConnectorsCheck()) + { + vehicle.lineContactors.Open(); + } + if (false == (vehicle.MainCtrlPowerPos() > 0)) + { + vehicle.lineContactors.Open(); + } } bool UpdateEngine(physics::Vehicle &vehicle, double const dt) const override { diff --git a/physics/components/electrics.cpp b/physics/components/electrics.cpp index 178bcab4f..3f426e9d3 100644 --- a/physics/components/electrics.cpp +++ b/physics/components/electrics.cpp @@ -149,7 +149,7 @@ void physics::Vehicle::UpdateBatteryVoltage(double dt) // HACK: allow to draw power also from adjacent converter, applicable for EMUs // TODO: expand power cables system to include low voltage power transfers // HACK: emulate low voltage generator powered directly by the diesel engine - auto const converteractive{lowVoltage.power110vAvailable || (EngineType == DieselElectric && true == lineBreaker.closed) || (EngineType == DieselEngine && true == lineBreaker.closed)}; + auto const converteractive{lowVoltage.power110vAvailable || (EngineType == DieselElectric && true == lineBreaker.IsClosed()) || (EngineType == DieselEngine && true == lineBreaker.IsClosed())}; lowVoltage.batteryVoltage -= BatteryDrain(dt, converteractive); if (lowVoltage.nominalBatteryVoltage / lowVoltage.batteryVoltage > 1.57 && MainSwitch(false) && EngineType != DieselEngine && EngineType != WheelsDriven) @@ -200,7 +200,7 @@ double physics::Vehicle::BatteryDrainCharged(double dt, bool const converteracti sn2 = -(dt * 2.0); // szybki wzrost do 110V else sn2 = 0; - if (lineBreaker.closed) + if (lineBreaker.IsClosed()) sn3 = dt * 0.05; else sn3 = 0; @@ -231,7 +231,7 @@ double physics::Vehicle::BatteryDrainLow(double dt, bool const converteractive) sn2 = -(dt * 50); // szybki wzrost do 110V else sn2 = 0; - if (lineBreaker.closed) + if (lineBreaker.IsClosed()) sn3 = dt * 0.001; else sn3 = 0; @@ -295,34 +295,16 @@ void physics::Vehicle::MainsCheck(double const Deltatime) localvoltage = Genset.voltage; } // a line breaker closed ahead of the pantographs gets ready on the low voltage circuits - auto const maincircuitpowersupply{std::abs(localvoltage) > 0.1 || GetTrainsetHighVoltage() > 0.1 || (lineBreaker.pantographsRequireIt && (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable))}; + auto const maincircuitpowersupply{std::abs(localvoltage) > 0.1 || GetTrainsetHighVoltage() > 0.1 || (lineBreaker.config.pantographsRequireIt && (lowVoltage.power24vAvailable || lowVoltage.power110vAvailable))}; - if (true == maincircuitpowersupply) + // optional automatic circuit start, once the circuit is initialised + if (lineBreaker.UpdateInitialisation(maincircuitpowersupply, Deltatime) && lineBreaker.config.start != start_t::manual && false == (lineBreaker.IsClosed() || diesel.startupRequested)) { - // all is well - if (lineBreaker.initCountdown >= 0.0) - { - // NOTE: we ensure main circuit readiness meets condition MainsInitTimeCountdown < 0 - // this allows for simpler rejection of cases where MainsInitTime == 0 - lineBreaker.initCountdown -= Deltatime; - } - else - { - // optional automatic circuit start - if (lineBreaker.start != start_t::manual && false == (lineBreaker.closed || diesel.startupRequested)) - { - MainSwitch(true); - } - } - } - else - { - // no power supply - lineBreaker.initCountdown = lineBreaker.initTime; + MainSwitch(true); } // an emergency brake application made under power opens the line breaker, where the vehicle has such an interlock - if (lineBreaker.closed && EmergencyBrakeHoldsMainOff()) + if (lineBreaker.IsClosed() && EmergencyBrakeHoldsMainOff()) { MainSwitch(false, TrainType == train_type::emu ? range_t::unit : range_t::local); } @@ -335,13 +317,7 @@ void physics::Vehicle::LowVoltagePowerCheck(double const /*Deltatime*/) if (EngineType == TEngineType::ElectricSeriesMotor) { - protection.ground &= lowvoltagepower; - if (protection.groundStart != start_t::manual) - { - // NOTE: we're ignoring intricaties of battery and converter types as they're unlikely to be used - // TODO: generic check method which takes these into account - protection.ground |= lowvoltagepower; - } + protection.UpdateGround(lowvoltagepower); } } @@ -431,7 +407,7 @@ double physics::Vehicle::LocalPowerVoltage(Coupling const kind) case Coupling::power110v: { - if (converter.running) + if (converter.IsRunning()) { localvoltage = lowVoltage.nominalBatteryVoltage; } @@ -590,62 +566,16 @@ void physics::Vehicle::PowerCouplersCurrent(Coupling const kind, bool const loca // sprawdzanie przetwornicy void physics::Vehicle::ConverterCheck(double const Timestep) { - // TODO: move other converter checks here, to have it all in one place for potential device object - if (converter.start != start_t::disabled && converter.overloadRelayOffWithLineBreaker) - { - converter.overloaded |= !lineBreaker.closed && lowVoltage.power24vAvailable; - } - - switch (converter.start) - { - case start_t::disabled: - { - converter.allow = false; - // NOTE: if there's no converter in vehicle we can end the check here - return; - } - case start_t::automatic: - { - converter.allow = lineBreaker.closed; - break; - } - case start_t::direction: - { - converter.allow = DirActive != 0; - } - default: - { - break; - } - } - - if (converter.allow && converter.allowLocal && false == converter.overloaded && - false == pantographAir.pressureLockActive - // HACK: allow carriages to operate converter without (missing) fuse prerequisite - && (Power > 1.0 ? MainCircuitPowered() : GetTrainsetHighVoltage() > 0.0)) - { - // delay timer can be optionally configured, and is set anew whenever converter goes off - if (converter.startDelayTimer <= 0.0) - { - converter.running = true; - } - else - { - converter.startDelayTimer -= Timestep; - } - } - else - { - converter.running = false; - converter.startDelayTimer = static_cast(converter.startDelay); - } - - if (converter.overloadRelayStart == start_t::converter && false == (converter.allow && converter.allowLocal) && false == TestFlag(EngDmgFlag, 4)) - { - // reset converter overload relay if the converter was switched off, unless it's damaged - converter.overloaded = false; - } -}; + ConverterSupply supply; + supply.lineBreakerClosed = lineBreaker.IsClosed(); + supply.lowVoltage24v = lowVoltage.power24vAvailable; + supply.directionActive = DirActive != 0; + supply.pantographPressureLock = pantographAir.pressureLockActive; + // HACK: allow carriages to operate converter without (missing) fuse prerequisite + supply.highVoltage = Power > 1.0 ? MainCircuitPowered() : GetTrainsetHighVoltage() > 0.0; + supply.damaged = TestFlag(EngDmgFlag, 4); + converter.Update(supply, Timestep); +} // heating system status check void physics::Vehicle::HeatingCheck(double const /*Timestep*/) @@ -754,7 +684,7 @@ void physics::Vehicle::PantographsCheck(double const /*Timestep*/) valve.is_active = (valve.spring ? lowvoltagepower : true) // spring actuator needs power to maintain non-default state && (manualcontrol && lowvoltagepower ? false == valve.is_disabled : true) // needs power to change state, without it just pass through && (manualcontrol && lowvoltagepower ? false == pantographCircuit.allDown : true) && - (lineBreaker.closed || false == lineBreaker.pantographsRequireIt) // fed through the closed line breaker, where it comes first + (lineBreaker.IsClosed() || false == lineBreaker.config.pantographsRequireIt) // fed through the closed line breaker, where it comes first && (valve.is_active || (manualcontrol && lowvoltagepower && valve.is_enabled) || (autostart && lowvoltagepower)); // shouldn't ever get this far but, eh auto const pantographexists{EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.PhysicalLayout & 1 << pant_id}; @@ -805,7 +735,7 @@ void physics::Vehicle::GensetCheck(double const Deltatime) } else { - auto const demand{GensetSelected() && lineBreaker.closed ? std::clamp(inductionMotor.forceShare, 0.0, 1.0) : 0.0}; + auto const demand{GensetSelected() && lineBreaker.IsClosed() ? std::clamp(inductionMotor.forceShare, 0.0, 1.0) : 0.0}; auto const target{genset.is_active ? genset.revolutions_idle + (genset.revolutions_max - genset.revolutions_idle) * demand : 0.0}; genset.revolutions += (target - genset.revolutions) * std::min(1.0, Deltatime / genset.spinup_time); if (genset.revolutions < 0.001) @@ -920,7 +850,7 @@ bool physics::Vehicle::CompartmentLightsSwitchOff(bool State, range_t const Noti bool physics::Vehicle::MainSwitch(bool const State, range_t const Notify) { - bool const initialstate{lineBreaker.closed || diesel.startupRequested}; + bool const initialstate{lineBreaker.IsClosed() || diesel.startupRequested}; MainSwitch_(State); @@ -931,19 +861,19 @@ bool physics::Vehicle::MainSwitch(bool const State, range_t const Notify) SendCtrlToNext(VehicleCommand::mainSwitch, State ? 1 : 0, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control); } - return (lineBreaker.closed || diesel.startupRequested) != initialstate; + return (lineBreaker.IsClosed() || diesel.startupRequested) != initialstate; } void physics::Vehicle::MainSwitch_(bool const State) { - if (lineBreaker.closed == State || MainCtrlPosNo == 0) + if (lineBreaker.IsClosed() == State || MainCtrlPosNo == 0) { // nothing to do return; } - bool const initialstate{lineBreaker.closed}; + bool const initialstate{lineBreaker.IsClosed()}; if (false == State || true == MainSwitchCheck()) { @@ -959,18 +889,18 @@ void physics::Vehicle::MainSwitch_(bool const State) else { // additional check, as vehicles without pantographs won't fail relay checks earlier - lineBreaker.closed = true; + lineBreaker.Close(); } } else { - lineBreaker.closed = false; + lineBreaker.Open(); // potentially knock out the pumps if their switch doesn't force them on WaterPump.is_active &= WaterPump.is_enabled; FuelPump.is_active &= FuelPump.is_enabled; } - if (lineBreaker.closed != initialstate) + if (lineBreaker.IsClosed() != initialstate) { LastSwitchingTime = 0; Timer::subsystem.switching.note(Timer::switching_counter::mains, this, &TypeName, &Name); @@ -991,11 +921,11 @@ bool physics::Vehicle::MainSwitchCheck() const powerisavailable = Genset.is_active && Genset.voltage >= TractionSupplyMinVoltage(); } - return powerisavailable && (ScndCtrlPos == 0 || EngineType == ElectricInductionMotor) && lineBreaker.initCountdown <= 0.0 && - (converter.overloaded == false || converter.overloadRelayOffWithLineBreaker) && true == protection.ground && (true == protection.noVoltage || lineBreaker.pantographsRequireIt) && true == protection.overvoltage && + return powerisavailable && (ScndCtrlPos == 0 || EngineType == ElectricInductionMotor) && lineBreaker.IsInitialised() && + (converter.IsOverloaded() == false || converter.config.overloadRelayOffWithLineBreaker) && true == protection.GroundHolds() && (true == protection.UndervoltageHolds() || lineBreaker.config.pantographsRequireIt) && true == protection.OvervoltageHolds() && LastSwitchingTime > CtrlDelay && (HasCamshaft ? IsMainCtrlActualNoPowerPos() : - lineBreaker.closesOnlyAtNoPower ? IsMainCtrlNoPowerPos() : + lineBreaker.config.closesOnlyAtNoPower ? IsMainCtrlNoPowerPos() : true) && false == DamageFlag.HasAll(VehicleDamage::derailed) && false == TestFlag(EngDmgFlag, 1) && false == EmergencyBrakeHoldsMainOff(); } @@ -1007,19 +937,16 @@ bool physics::Vehicle::MainSwitchCheck() const bool physics::Vehicle::ConverterSwitch(bool State, range_t const Notify) { - auto const initialstate{converter.allow}; + auto const initialstate{converter.IsAllowed()}; - if (converter.start == start_t::manual) - { - converter.allow = State; - } + converter.Switch(State); if (Notify != range_t::local) { SendCtrlToNext(VehicleCommand::converterSwitch, State ? 1 : 0, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control); } - return converter.allow != initialstate; + return converter.IsAllowed() != initialstate; } bool physics::Vehicle::HeatingSwitch(bool const State, range_t const Notify) @@ -1116,11 +1043,11 @@ double physics::Vehicle::EnginePowerSourceVoltage() const // blowers, the traction motors bool physics::Vehicle::MainCircuitPowered() const { - if (false == lineBreaker.closed) + if (false == lineBreaker.IsClosed()) { return false; } - if (false == lineBreaker.pantographsRequireIt || EnginePowerSource.SourceType != TPowerSource::CurrentCollector) + if (false == lineBreaker.config.pantographsRequireIt || EnginePowerSource.SourceType != TPowerSource::CurrentCollector) { // the closed line breaker says it all: the undervoltage trip opens it without traction voltage, and an engine // which runs is its own supply diff --git a/physics/components/fizsections.cpp b/physics/components/fizsections.cpp index f75fb011f..3f7556b72 100644 --- a/physics/components/fizsections.cpp +++ b/physics/components/fizsections.cpp @@ -909,15 +909,15 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) {"Battery", battery}, {"Converter", converter}, {"Direction", direction}}; // main circuit - extract_value(lineBreaker.initTime, "MainInitTime", line, ""); + extract_value(lineBreaker.config.initTime, "MainInitTime", line, ""); { auto lookup = starts.find(extract_value("MainStart", line)); - lineBreaker.start = lookup != starts.end() ? lookup->second : manual; + lineBreaker.config.start = lookup != starts.end() ? lookup->second : manual; } - extract_value(lineBreaker.pantographsRequireIt, "PantRequiresMain", line, ""); + extract_value(lineBreaker.config.pantographsRequireIt, "PantRequiresMain", line, ""); // the brake pipe pressure of an emergency brake application, which opens the line breaker under power - extract_value(lineBreaker.emergencyOffPressure, "EmergencyBrakeMainOff", line, ""); - lineBreaker.emergencyOffPressure = std::max(0.0, lineBreaker.emergencyOffPressure); + extract_value(lineBreaker.config.emergencyOffPressure, "EmergencyBrakeMainOff", line, ""); + lineBreaker.config.emergencyOffPressure = std::max(0.0, lineBreaker.config.emergencyOffPressure); // battery { auto lookup = starts.find(extract_value("BatteryStart", line)); @@ -926,10 +926,10 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) // converter { auto lookup = starts.find(extract_value("ConverterStart", line)); - this->converter.start = lookup != starts.end() ? lookup->second : manual; + this->converter.config.start = lookup != starts.end() ? lookup->second : manual; } - extract_value(this->converter.startDelay, "ConverterStartDelay", line, ""); - extract_value(this->converter.overloadRelayOffWithLineBreaker, "ConverterOverloadWhenMainIsOff", line, TrainType == train_type::emu ? "yes" : "no"); + extract_value(this->converter.config.startDelay, "ConverterStartDelay", line, ""); + extract_value(this->converter.config.overloadRelayOffWithLineBreaker, "ConverterOverloadWhenMainIsOff", line, TrainType == train_type::emu ? "yes" : "no"); // compressor { auto lookup = starts.find(extract_value("CompressorStart", line)); @@ -995,7 +995,7 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) std::map> const interlocks{{"Converter", line_contactors_interlock::converter}, {"MotorBlowers", line_contactors_interlock::motor_blowers}}; auto lookup = interlocks.find(extract_value("LineContactorsInterlock", line)); - lineContactors.interlock = lookup != interlocks.end() ? lookup->second : line_contactors_interlock::none; + lineContactors.config.interlock = lookup != interlocks.end() ? lookup->second : line_contactors_interlock::none; } extract_value(LouvresOpenPressure, "LouvresOpenPressure", line, ""); // compartment lights @@ -1007,14 +1007,14 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) { auto lookup = starts.find(extract_value("GroundRelayStart", line)); auto const defaultstart{TrainType == train_type::emu ? automatic : manual}; - protection.groundStart = lookup != starts.end() ? lookup->second : defaultstart; + 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}; - this->converter.overloadRelayStart = lookup != starts.end() ? lookup->second : defaultstart; + this->converter.config.overloadRelayStart = lookup != starts.end() ? lookup->second : defaultstart; } } @@ -1183,7 +1183,7 @@ void physics::Vehicle::LoadFIZ_Engine(std::string const &Input) { EngineType = LoadFIZ_EngineDecode(extract_value("EngineType", Input)); - extract_value(lineBreaker.jointStart, "JointEngineStart", Input, ""); + extract_value(lineBreaker.config.jointStart, "JointEngineStart", Input, ""); if (std::string transmission = extract_value("Trans", Input); false == transmission.empty()) { @@ -1262,9 +1262,9 @@ 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.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.pressureSwitchWatchesCylinders, "PressureSwitchBrakeCylinder", Input, ""); + extract_value(protection.config.pressureSwitchWatchesCylinders, "PressureSwitchBrakeCylinder", Input, ""); } // Engine: of a diesel engine, its revolutions, gears, hydraulic transmission and retarder @@ -1469,13 +1469,13 @@ void physics::Vehicle::LoadFIZ_Switches(std::string const &Input) { extract_value(pantographCircuit.switchType, "Pantograph", Input, ""); - extract_value(converter.switchType, "Converter", Input, ""); - extract_value(lineContactors.switchType, "MotorConnectors", Input, ""); + extract_value(converter.config.switchType, "Converter", Input, ""); + extract_value(lineContactors.config.switchType, "MotorConnectors", Input, ""); trainHeating.switchImpulse = ToLower(extract_value("TrainHeating", Input)) == "impulse"; // because people can't make up their minds whether it's "impulse" or "Impulse"... pantographCircuit.switchType = ToLower(pantographCircuit.switchType); - converter.switchType = ToLower(converter.switchType); - lineContactors.switchType = ToLower(lineContactors.switchType); + converter.config.switchType = ToLower(converter.config.switchType); + lineContactors.config.switchType = ToLower(lineContactors.config.switchType); // universal reset buttons assignments extract_value(UniversalResetButtonFlag[0], "RelayResetButton1", Input, ""); extract_value(UniversalResetButtonFlag[1], "RelayResetButton2", Input, ""); diff --git a/physics/components/maincircuit.h b/physics/components/maincircuit.h index 3970b2835..39f083687 100644 --- a/physics/components/maincircuit.h +++ b/physics/components/maincircuit.h @@ -8,7 +8,12 @@ http://mozilla.org/MPL/2.0/. */ // the main circuit of a vehicle: the line breaker, the line contactors, the protective relays, the converter. Held by -// physics::Vehicle as lineBreaker, lineContactors, protection and converter +// physics::Vehicle as lineBreaker, lineContactors, protection and converter. +// +// each part holds its definition in `config`, filled from the .fiz and not changed after, and keeps its state to itself: +// the rest of the vehicle reads the state through the queries and changes it through the operations. what decides when +// they act (the interlocks of the cab, the controller positions, the voltages) stays with the vehicle, which hands the +// parts what they need as plain values #pragma once @@ -20,69 +25,265 @@ namespace physics { // the line breaker (the main switch) of the vehicle -struct LineBreaker +class LineBreaker { - bool closed = false; - double initTime{0.0}; // how long the main circuit initialises after it gets its power, before the breaker can close [s] + public: + struct Config + { + double initTime{0.0}; // how long the main circuit initialises after it gets its power, before the breaker can close [s] + start_t start{start_t::manual}; + // Engine:JointEngineStart: the line breaker / engine start switch of the cab works the vehicles in multiple too; when it + // doesn't, the cab has separate switches for them (mainb_*, mainc_*) + bool jointStart{true}; + // Cntrl.PantRequiresMain: the line breaker closes without traction voltage and holds without it, and the pantographs + // rise and stay up only while it's closed (EU05, EP05, ČD 181 family); off, the pantographs come first and the line + // breaker needs their voltage. what the main circuit feeds still needs the voltage (MainCircuitPowered()), and without + // it the undervoltage relay opens the line contactors (protection.UndervoltageHolds()) + bool pantographsRequireIt{false}; + bool closesOnlyAtNoPower{false}; // it closes only with the master controller at a position of no power + // Cntrl.EmergencyBrakeMainOff: the brake pipe pressure [bar] taken for an emergency brake application: below it, with + // the master controller on a power position, the line breaker opens and doesn't close again. where the pantographs + // stay up only through the closed line breaker (pantographsRequireIt) they drop with it (EP05). 0: an emergency + // application leaves the line breaker alone + double emergencyOffPressure{0.0}; + }; + Config config; + + bool IsClosed() const { return closed; } + void Close() { closed = true; } + void Open() { closed = false; } + + // how long the main circuit still initialises [s]; below zero once it's done + double RemainingInitTime() const { return initCountdown; } + // the main circuit is done initialising, the breaker may close + bool IsInitialised() const { return initCountdown <= 0.0; } + // the step of the supply of the main circuit: with it the initialisation counts down, without it it starts over. + // returns whether the circuit has its supply and was done initialising before this step, when it may start on its own + bool UpdateInitialisation(bool const supplied, double const dt) + { + if (false == supplied) + { + initCountdown = config.initTime; + return false; + } + // NOTE: readiness means a countdown below zero, which rules out at once the vehicles of no initialisation time + if (initCountdown >= 0.0) + { + initCountdown -= dt; + return false; + } + return true; + } + + private: + bool closed{false}; double initCountdown{0.0}; // how long it still initialises [s] - start_t start{start_t::manual}; - // Engine:JointEngineStart: the line breaker / engine start switch of the cab works the vehicles in multiple too; when it - // doesn't, the cab has separate switches for them (mainb_*, mainc_*) - bool jointStart{true}; - // Cntrl.PantRequiresMain: the line breaker closes without traction voltage and holds without it, and the pantographs - // rise and stay up only while it's closed (EU05, EP05, ČD 181 family); off, the pantographs come first and the line - // breaker needs their voltage. what the main circuit feeds still needs the voltage (MainCircuitPowered()), and without - // it the undervoltage relay opens the line contactors (protection.noVoltage) - bool pantographsRequireIt{false}; - bool closesOnlyAtNoPower{false}; // it closes only with the master controller at a position of no power - // Cntrl.EmergencyBrakeMainOff: the brake pipe pressure [bar] taken for an emergency brake application: below it, with - // the master controller on a power position, the line breaker opens and doesn't close again. where the pantographs - // stay up only through the closed line breaker (pantographsRequireIt) they drop with it (EP05). 0: an emergency - // application leaves the line breaker alone - double emergencyOffPressure{0.0}; }; // the line contactors of the traction motors -struct LineContactors +class LineContactors { - bool closed = false; - bool forcedOpen{false}; // the button that forces them open - std::string switchType; // StLinSwitchType: the kind of the switch of the cab - line_contactors_interlock interlock{line_contactors_interlock::none}; // what else they need to close - double lastSwitchTime = 0.0; // the time since they last switched [s] + public: + struct Config + { + std::string switchType; // StLinSwitchType: the kind of the switch of the cab + line_contactors_interlock interlock{line_contactors_interlock::none}; // what else they need to close + }; + Config config; + + bool IsClosed() const { return closed; } + void Close() { closed = true; } + void Open() { closed = false; } + + // the button of the cab that forces them open + bool IsForcedOpen() const { return forcedOpen; } + void ForceOpen(bool const State) { forcedOpen = State; } + + // the time since the master controller or the relays of the start last switched [s] + double TimeSinceSwitch() const { return lastSwitchTime; } + void RestartSwitchTimer() { lastSwitchTime = 0.0; } + void AdvanceSwitchTimer(double const dt) { lastSwitchTime += dt; } + + private: + bool closed{false}; + bool forcedOpen{false}; + double lastSwitchTime{0.0}; }; -// the protective relays and the pressure switch of the main circuit -struct ProtectionRelays +// the protective relays and the pressure switch of the main circuit. the relays hold (true) while all is well and drop +// (false) when they protect the circuit +class ProtectionRelays { - // the undervoltage relay: it switches off if the voltage drops below its threshold, which opens the line breaker; with - // lineBreaker.pantographsRequireIt it opens the line contactors instead, and switches back on only with the master + public: + struct Config + { + start_t groundStart{start_t::manual}; // how the ground relay is reset + bool hasPressureSwitch{true}; + // Engine:PressureSwitchBrakeCylinder: the pressure switch watches the brake cylinders (it cuts the start off above 2 bar + // there) as well as the brake pipe (below 3.6 bar). off, it's left with the brake pipe alone, and the vehicle takes + // current whatever the pressure in its brake cylinders (EP05) + bool pressureSwitchWatchesCylinders{true}; + }; + Config config; + + // the undervoltage relay: it drops if the voltage falls below its threshold, which opens the line breaker; with + // lineBreaker.config.pantographsRequireIt it opens the line contactors instead, and picks up again only with the master // controller at zero or the first position + bool UndervoltageHolds() const { return noVoltage; } + // the overvoltage relay, which drops above the voltage it's set to + bool OvervoltageHolds() const { return overvoltage; } + // the voltage relays as the drive of the vehicle judges them from the voltage of its supply + void SetVoltageRelays(bool const undervoltageHolds, bool const overvoltageHolds) + { + noVoltage = undervoltageHolds; + overvoltage = overvoltageHolds; + } + + // the ground relay, which drops to protect against damage from earths + bool GroundHolds() const { return ground; } + // the ground relay of a series motor vehicle in the step: it drops without the low voltage, and one that isn't reset + // by hand picks up again with it + void UpdateGround(bool const lowVoltagePower) + { + ground &= lowVoltagePower; + if (config.groundStart != start_t::manual) + { + // NOTE: we're ignoring intricaties of battery and converter types as they're unlikely to be used + // TODO: generic check method which takes these into account + ground |= lowVoltagePower; + } + } + // the reset of the ground relay, which needs the low voltage; returns whether it picked up + bool ResetGround(bool const lowVoltagePower) + { + auto const reset{false == ground && lowVoltagePower}; + ground |= lowVoltagePower; + return reset; + } + + // tripped while the brake pipe and/or the brake cylinders aren't at their working pressures + bool PressureSwitchTripped() const { return pressureSwitch; } + // the pressure switch in the step, from the pressures [bar] + void UpdatePressureSwitch(double const cylinderPressure, double const pipePressure) + { + pressureSwitch = config.hasPressureSwitch && ((config.pressureSwitchWatchesCylinders && cylinderPressure > 2.0) || pipePressure < 3.6); + } + + private: bool noVoltage{true}; - bool overvoltage{true}; // the overvoltage relay, which opens above the voltage it's set to - bool ground{true}; // the ground relay, which opens to protect against damage from earths - start_t groundStart{start_t::manual}; // how the ground relay is reset - bool pressureSwitch{false}; // tripped while the brake pipe and/or the brake cylinders aren't at their working pressures - bool hasPressureSwitch{true}; - // Engine:PressureSwitchBrakeCylinder: the pressure switch watches the brake cylinders (it cuts the start off above 2 bar - // there) as well as the brake pipe (below 3.6 bar). off, it's left with the brake pipe alone, and the vehicle takes - // current whatever the pressure in its brake cylinders (EP05) - bool pressureSwitchWatchesCylinders{true}; + bool overvoltage{true}; + bool ground{true}; + bool pressureSwitch{false}; +}; + +// what the converter of the vehicle needs to know in the step +struct ConverterSupply +{ + bool lineBreakerClosed{false}; + bool lowVoltage24v{false}; // the 24 V circuits have their power + bool directionActive{false}; // the reverser is set + bool pantographPressureLock{false}; // the pressure lock of the pantographs is on + bool highVoltage{false}; // the main circuit, or for a vehicle of no power of its own the train line, has its voltage + bool damaged{false}; // the converter is damaged }; // the converter of the vehicle -struct PowerConverter +class PowerConverter { - start_t start{start_t::manual}; // whether it is started by hand, or another way - float startDelay{0.0f}; // the delay before it starts, once its conditions are met [s] + public: + struct Config + { + start_t start{start_t::manual}; // whether it is started by hand, or another way + float startDelay{0.0f}; // the delay before it starts, once its conditions are met [s] + start_t overloadRelayStart{start_t::manual}; // whether its overload relay is reset by a button of its own + bool overloadRelayOffWithLineBreaker{false}; // ConverterOverloadRelayOffWhenMainIsOff + std::string switchType; // ConvSwitchType: the kind of the switch of the cab. TODO: the kinds of the switches belong to the cab definition + }; + Config config; + + bool IsRunning() const { return running; } + // it may run, as its switch (or its start) has it + bool IsAllowed() const { return allow; } + // the switch of the converter, where it is worked by hand; returns whether that changed it + bool Switch(bool const State) + { + auto const initialstate{allow}; + if (config.start == start_t::manual) + { + allow = State; + } + return allow != initialstate; + } + // the switch of the vehicle itself; most have none, so it allows + bool LocalSwitchOn() const { return allowLocal; } + void SetLocalSwitch(bool const State) { allowLocal = State; } + + // the overload relay of the converter and the heating + bool IsOverloaded() const { return overloaded; } + void Overload() { overloaded = true; } + // the reset of the overload relay, which needs the low voltage; returns whether it was tripped + bool ResetOverloadRelay(bool const lowVoltagePower) + { + auto const reset{overloaded && lowVoltagePower}; + overloaded &= false == lowVoltagePower; + return reset; + } + + // the converter in the step + void Update(ConverterSupply const &supply, double const dt) + { + if (config.start != start_t::disabled && config.overloadRelayOffWithLineBreaker) + { + overloaded |= false == supply.lineBreakerClosed && supply.lowVoltage24v; + } + switch (config.start) + { + case start_t::disabled: + allow = false; + // NOTE: if there's no converter in vehicle we can end the check here + return; + case start_t::automatic: + allow = supply.lineBreakerClosed; + break; + case start_t::direction: + allow = supply.directionActive; + break; + default: + break; + } + if (allow && allowLocal && false == overloaded && false == supply.pantographPressureLock && supply.highVoltage) + { + // delay timer can be optionally configured, and is set anew whenever converter goes off + if (startDelayTimer <= 0.0) + { + running = true; + } + else + { + startDelayTimer -= dt; + } + } + else + { + running = false; + startDelayTimer = static_cast(config.startDelay); + } + if (config.overloadRelayStart == start_t::converter && false == (allow && allowLocal) && false == supply.damaged) + { + // reset converter overload relay if the converter was switched off, unless it's damaged + overloaded = false; + } + } + + // for the tests of the parts it feeds: the converter running, or not, whatever its conditions + void SetRunningForTest(bool const State) { running = State; } + + private: + bool allow{false}; + bool allowLocal{true}; + bool running{false}; + bool overloaded{false}; double startDelayTimer{0.0}; // how long its conditions have been met - bool allow = false; // it may run - bool allowLocal{true}; // the switch of the vehicle itself; most have none, so it allows - bool running = false; - start_t overloadRelayStart{start_t::manual}; // whether its overload relay is reset by a button of its own - bool overloadRelayOffWithLineBreaker{false}; // ConverterOverloadRelayOffWhenMainIsOff - bool overloaded = false; // the overload relay of the converter and the heating tripped - std::string switchType; // ConvSwitchType: the kind of the switch of the cab. TODO: the kinds of the switches belong to the cab definition }; } // namespace physics diff --git a/physics/components/pneumatics.cpp b/physics/components/pneumatics.cpp index 62cd30bb3..886ce0cd7 100644 --- a/physics/components/pneumatics.cpp +++ b/physics/components/pneumatics.cpp @@ -518,7 +518,7 @@ bool physics::Vehicle::BrakeReleaser(int state) if (state != 0) { // additional limitations imposed by pressure switch - if (false == protection.pressureSwitch || false == ReleaserEnabledOnlyAtNoPowerPos || true == IsMainCtrlNoPowerPos()) + if (false == protection.PressureSwitchTripped() || false == ReleaserEnabledOnlyAtNoPowerPos || true == IsMainCtrlNoPowerPos()) { brakes.distributor->Releaser(state); } @@ -794,7 +794,7 @@ void physics::Vehicle::CompressorCheck(double dt) { case CompressorSupply::converter: { - air.compressor.allow = converter.allow; + air.compressor.allow = converter.IsAllowed(); break; } case CompressorSupply::engine: diff --git a/physics/components/traction.cpp b/physics/components/traction.cpp index cf25d9509..0feef1456 100644 --- a/physics/components/traction.cpp +++ b/physics/components/traction.cpp @@ -97,12 +97,12 @@ double physics::Vehicle::Current(double n, double U) } } - if (brakes.electrodynamic.on && !FuseFlag && brakes.electrodynamic.type == dbrake_automatic && lowVoltage.power110vAvailable && lineBreaker.closed) // hamowanie EP09 //TUHEX + if (brakes.electrodynamic.on && !FuseFlag && brakes.electrodynamic.type == dbrake_automatic && lowVoltage.power110vAvailable && lineBreaker.IsClosed()) // hamowanie EP09 //TUHEX { // TODO: zrobic bardziej uniwersalne nie tylko dla EP09 MotorCurrent = -std::max(motor_param(0).fi * (Vadd / (Vadd + motor_param(0).Isat) - motor_param(0).fi0), 0.) * n * 2.0 / brakes.electrodynamic.resistance; } - else if (RList[MainCtrlActualPos].Bn == 0 || false == lineContactors.closed) + else if (RList[MainCtrlActualPos].Bn == 0 || false == lineContactors.IsClosed()) { // wylaczone MotorCurrent = 0; @@ -447,7 +447,7 @@ bool physics::Vehicle::TractionModeSwitch(traction_mode const Mode, range_t cons { auto const initialstate{TractionMode}; // refused with the line breaker closed, and then not passed on either, so the train stays on one source - auto const accepted{false == lineBreaker.closed}; + auto const accepted{false == lineBreaker.IsClosed()}; if (Genset.fitted() && accepted) { @@ -668,7 +668,7 @@ void physics::Vehicle::VoltageRelaysCheck() void physics::Vehicle::DumbTractionForce(double const PosRatio) { - if (lineBreaker.closed && CabActive != 0) + if (lineBreaker.IsClosed() && CabActive != 0) { if (Vel > 0.1) { @@ -1461,12 +1461,11 @@ bool physics::Vehicle::RelayReset(int const Relays, range_t const Notify) bool reset{false}; if (TestFlag(Relays, relay_t::maincircuitground) && (EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) && - (protection.groundStart == start_t::manual || protection.groundStart == start_t::manualwithautofallback) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 && + (protection.config.groundStart == start_t::manual || protection.config.groundStart == start_t::manualwithautofallback) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 && !TestFlag(EngDmgFlag, 1)) { // NOTE: true means the relay is operational - reset |= !protection.ground && lowvoltagepower; - protection.ground |= lowvoltagepower; + reset |= protection.ResetGround(lowvoltagepower); } if (TestFlag(Relays, relay_t::tractionnmotoroverload) && (EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 && @@ -1479,15 +1478,14 @@ bool physics::Vehicle::RelayReset(int const Relays, range_t const Notify) FuseFlag &= !lowvoltagepower; } - if (TestFlag(Relays, relay_t::primaryconverteroverload) && converter.overloadRelayStart == start_t::manual + if (TestFlag(Relays, relay_t::primaryconverteroverload) && converter.config.overloadRelayStart == start_t::manual // && ( false == Mains ) - && false == converter.allow) + && false == converter.IsAllowed()) { // NOTE: false means the relay is operational // TODO: cleanup, flip the FuseFlag code to match other relays // TODO: check whether the power is required, TBD, TODO: make it configurable? - reset |= converter.overloaded && lowvoltagepower; - converter.overloaded &= !lowvoltagepower; + reset |= converter.ResetOverloadRelay(lowvoltagepower); } if (reset) diff --git a/physics/vehicle.h b/physics/vehicle.h index d106a243c..2cc62bc21 100644 --- a/physics/vehicle.h +++ b/physics/vehicle.h @@ -1516,13 +1516,13 @@ class Vehicle // the pressure switch, when fitted, cuts the start off and puts them out, otherwise they go out once the brakes are applied bool MainCircuitLampsEnabled() const { - return false == protection.pressureSwitch && (protection.hasPressureSwitch || brakes.cylinderPressure < 1.0); + return false == protection.PressureSwitchTripped() && (protection.config.hasPressureSwitch || brakes.cylinderPressure < 1.0); } // whether an emergency brake application holds the line breaker open: the brake pipe below the pressure taken for one // (EmergencyBrakeMainOffPressure) while the master controller is on a power position bool EmergencyBrakeHoldsMainOff() const { - return lineBreaker.emergencyOffPressure > 0.0 && brakePipe.pressure < lineBreaker.emergencyOffPressure && false == IsMainCtrlNoPowerPos(); + return lineBreaker.config.emergencyOffPressure > 0.0 && brakePipe.pressure < lineBreaker.config.emergencyOffPressure && false == IsMainCtrlNoPowerPos(); } // whether the lamp of the open line contactors is lit. on the electric locomotives it tells the start can be made, so // it goes out with the start cut off; on the diesel-electric ones (the SU45 and SU46 family) it just tells the @@ -1531,15 +1531,15 @@ class Vehicle { if (EngineType == TEngineType::DieselElectric) { - return false == lineContactors.closed; + return false == lineContactors.IsClosed(); } - return false == lineContactors.closed && MainCircuitLampsEnabled(); + return false == lineContactors.IsClosed() && MainCircuitLampsEnabled(); } // the vehicles the line breaker / engine start switch of this vehicle works, and its engine stopping on its own // stops: the whole consist, or with JointEngineStart=No this vehicle alone (eu07/maszyna#80) range_t MainSwitchRange() const { - return lineBreaker.jointStart ? range_t::consist : range_t::local; + return lineBreaker.config.jointStart ? range_t::consist : range_t::local; } // whether the pneumatic louvres of the motor fans are still closed, the main reservoir short of the pressure that opens them bool LouvresClosed() const @@ -1552,7 +1552,7 @@ class Vehicle // the AI driver doesn't leave it so: the converters of the other vehicles running, it would wait for the contactors forever bool LineContactorsHeldByLocalConverterSwitch() const { - return lineContactors.interlock == line_contactors_interlock::converter && false == converter.allowLocal; + return lineContactors.config.interlock == line_contactors_interlock::converter && false == converter.LocalSwitchOn(); } // whether the vehicle has a driver's cab: it has the driver's brake valve (BrakeHandle in the Cntrl. section of the // .fiz), which the wagons and most cars of the units without a cab don't (a few copy the Cntrl. section of the cab diff --git a/simulation/blackboxrecorder.cpp b/simulation/blackboxrecorder.cpp index 7af23b625..568e8ba97 100644 --- a/simulation/blackboxrecorder.cpp +++ b/simulation/blackboxrecorder.cpp @@ -73,9 +73,9 @@ blackbox::driver driver_of(TDynamicObject const &Vehicle) { std::uint32_t devices_of(physics::Vehicle const &Occupied, physics::Vehicle const &Controlling) { namespace device = blackbox::cab_devices; auto const on{[](bool const State, std::uint32_t const Bit) { return State ? Bit : 0u; }}; - return on(Occupied.lowVoltage.batteryOn || Controlling.lowVoltage.batteryOn, device::battery) | on(Controlling.lineBreaker.closed, device::main_breaker) | + return on(Occupied.lowVoltage.batteryOn || Controlling.lowVoltage.batteryOn, 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.running, device::converter) | on(Controlling.air.compressor.running, device::compressor) | on(Controlling.lineContactors.closed, device::line_contactors) | + on(Controlling.converter.IsRunning(), device::converter) | on(Controlling.air.compressor.running, 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(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) | diff --git a/tests/unit/drive.cpp b/tests/unit/drive.cpp index 74fcfb9d7..dbba5d1d5 100644 --- a/tests/unit/drive.cpp +++ b/tests/unit/drive.cpp @@ -89,8 +89,8 @@ bool is_ready(driven const &Driven) { auto const air{physics.air.mainReservoirVolume <= 0.0 || physics.mainPipe.pressure >= 4.5}; // the converter feeds the 110 V circuits (the electrodynamic brake's control among them); the AI switches // it on once the line breaker is closed, so a train already charged with air isn't ready before it runs - auto const converter{physics.converter.start != start_t::manual || physics.converter.running}; - return physics.lineBreaker.closed && air && converter; + auto const converter{physics.converter.config.start != start_t::manual || physics.converter.IsRunning()}; + return physics.lineBreaker.IsClosed() && air && converter; } namespace { @@ -174,7 +174,7 @@ bool start_up(driven Driven, track const &Track, double Seconds, trace *Trace) { if (diesel) { prepare_diesel(Driven); } - if (controlling.lineBreaker.pantographsRequireIt && false == controlling.lineBreaker.closed) { + if (controlling.lineBreaker.config.pantographsRequireIt && false == controlling.lineBreaker.IsClosed()) { // the pantographs rise only through the closed line breaker, which closes without their voltage for (int i = 0; i < 3 && cab.DirActive <= 0; ++i) { cab.DirectionForward(); @@ -189,7 +189,7 @@ bool start_up(driven Driven, track const &Track, double Seconds, trace *Trace) { for (int i = 0; i < 3 && cab.DirActive <= 0; ++i) { cab.DirectionForward(); } - if (false == controlling.lineBreaker.closed) { + if (false == controlling.lineBreaker.IsClosed()) { close_line_breaker(Driven); } else { @@ -210,7 +210,7 @@ void drive_cycle(driven Driven, track const &Track, trace &Trace) { auto &cab{Driven.cab}; auto &controlling{Driven.controlling}; if (false == start_up(Driven, Track, 300.0, &Trace)) { - MESSAGE("didn't get ready: Mains " << controlling.lineBreaker.closed << ", main reservoir " << controlling.mainPipe.pressure); + MESSAGE("didn't get ready: Mains " << controlling.lineBreaker.IsClosed() << ", main reservoir " << controlling.mainPipe.pressure); } Trace.mark("release brakes"); release_brakes(cab); diff --git a/tests/unit/golden.cpp b/tests/unit/golden.cpp index e1769511c..e252ff90f 100644 --- a/tests/unit/golden.cpp +++ b/tests/unit/golden.cpp @@ -55,7 +55,7 @@ std::vector motion() { std::vector traction() { return { - {"Mains", [](auto const &M) { return M.lineBreaker.closed ? 1.0 : 0.0; }}, + {"Mains", [](auto const &M) { return M.lineBreaker.IsClosed() ? 1.0 : 0.0; }}, {"DirActive", [](auto const &M) { return M.DirActive; }}, {"MainCtrlPos", [](auto const &M) { return M.MainCtrlPos; }}, {"MainCtrlActualPos", [](auto const &M) { return M.MainCtrlActualPos; }}, diff --git a/tests/unit/invariants.cpp b/tests/unit/invariants.cpp index 1942c476a..f85c88105 100644 --- a/tests/unit/invariants.cpp +++ b/tests/unit/invariants.cpp @@ -70,15 +70,15 @@ std::vector const &invariants() { [](auto const &M, double, auto const *) { return M.air.compressor.maxPressure <= 0.0 || M.air.mainReservoirPressure <= 1.01 * M.air.compressor.maxPressure + pressure_margin; }, [](auto const &M) { return values({{"Compressor", M.air.mainReservoirPressure}, {"MaxCompressor", M.air.compressor.maxPressure}}); }}, {"no motor current with the line breaker open", - [](auto const &M, double, auto const *) { return M.lineBreaker.closed || false == electric(M) || std::abs(M.Im) < 1.0; }, - [](auto const &M) { return values({{"Mains", M.lineBreaker.closed}, {"Im", M.Im}, {"Itot", M.Itot}}); }}, + [](auto const &M, double, auto const *) { return M.lineBreaker.IsClosed() || false == electric(M) || std::abs(M.Im) < 1.0; }, + [](auto const &M) { return values({{"Mains", M.lineBreaker.IsClosed()}, {"Im", M.Im}, {"Itot", M.Itot}}); }}, {"no motor current with the line contactors open, but for the dynamic brake", [](auto const &M, double, auto const *) { // the dynamic brake closes its own circuit of the motors and the resistors - return M.lineContactors.closed || M.brakes.electrodynamic.on || M.EngineType != TEngineType::ElectricSeriesMotor || std::abs(M.Im) < 1.0; + return M.lineContactors.IsClosed() || M.brakes.electrodynamic.on || M.EngineType != TEngineType::ElectricSeriesMotor || std::abs(M.Im) < 1.0; }, [](auto const &M) { - return values({{"StLinFlag", M.lineContactors.closed}, {"DynamicBrakeFlag", M.brakes.electrodynamic.on}, {"Im", M.Im}, {"MainCtrlActualPos", M.MainCtrlActualPos}}); + 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; }, diff --git a/tests/unit/scenario.cpp b/tests/unit/scenario.cpp index ecda46e3e..568ade19a 100644 --- a/tests/unit/scenario.cpp +++ b/tests/unit/scenario.cpp @@ -11,7 +11,7 @@ namespace { // switch is on when the controller leaves zero doesn't close its line contactors until the controller is back at zero bool start_cut_off(consist &Train) { for (std::size_t i = 0; i < Train.size(); ++i) { - if (Train[i].physics().protection.pressureSwitch) { + if (Train[i].physics().protection.PressureSwitchTripped()) { return true; } } @@ -74,7 +74,7 @@ void scenario::full_power(double Seconds) { wait(1.0); } controlling.IncMainCtrl(1); - for (int i = 0; i < 90 && false == controlling.lineContactors.closed; ++i) { + for (int i = 0; i < 90 && false == controlling.lineContactors.IsClosed(); ++i) { wait(1.0); } for (int i = 0; i < 60 && false == controlling.IsMainCtrlMaxPowerPos(); ++i) { diff --git a/tests/unit/test_6dg_power_steps.cpp b/tests/unit/test_6dg_power_steps.cpp index ed3f3c7fa..1df7f30ca 100644 --- a/tests/unit/test_6dg_power_steps.cpp +++ b/tests/unit/test_6dg_power_steps.cpp @@ -61,8 +61,8 @@ void get_ready(vehicle &Loco, test::track const &Track) { test::drive(driven, Track, 1.0); move_to(Loco, hold); test::drive(driven, Track, 5.0); - REQUIRE(Loco->lineBreaker.closed); // the engine running - REQUIRE(Loco->lineContactors.closed); // the line contactors closed + REQUIRE(Loco->lineBreaker.IsClosed()); // the engine running + REQUIRE(Loco->lineContactors.IsClosed()); // the line contactors closed REQUIRE(false == Loco->SpeedCtrlUnit.IsActive); // the demand of the controller drives, not the speed control REQUIRE(Loco->eimic == doctest::Approx(0.0)); } diff --git a/tests/unit/test_auxiliaries.cpp b/tests/unit/test_auxiliaries.cpp index 6334179c8..5df40fd95 100644 --- a/tests/unit/test_auxiliaries.cpp +++ b/tests/unit/test_auxiliaries.cpp @@ -16,7 +16,7 @@ std::vector auxiliaries() { return { {"BatteryVoltage", [](auto const &M) { return M.lowVoltage.batteryVoltage; }}, {"Battery", [](auto const &M) { return M.lowVoltage.batteryOn ? 1.0 : 0.0; }}, - {"ConverterFlag", [](auto const &M) { return M.converter.running ? 1.0 : 0.0; }}, + {"ConverterFlag", [](auto const &M) { return M.converter.IsRunning() ? 1.0 : 0.0; }}, {"Power110vIsAvailable", [](auto const &M) { return M.lowVoltage.power110vAvailable ? 1.0 : 0.0; }}, {"PantPress", [](auto const &M) { return M.pantographAir.pressure; }}, {"PantVolume", [](auto const &M) { return M.pantographAir.volume; }}, @@ -43,10 +43,10 @@ TEST_CASE("auxiliaries: the battery drained by the lights and the pantographs' c eu07.pantographAir.compressorRunning = true; scenario.wait(30.0); CHECK(eu07.lowVoltage.batteryVoltage < 0.83 * eu07.lowVoltage.nominalBatteryVoltage); - CHECK(eu07.lineBreaker.closed); + CHECK(eu07.lineBreaker.IsClosed()); scenario.wait(5000.0); CHECK(eu07.lowVoltage.batteryVoltage < eu07.lowVoltage.nominalBatteryVoltage / 1.57); - CHECK_FALSE(eu07.lineBreaker.closed); + CHECK_FALSE(eu07.lineBreaker.IsClosed()); scenario.act("start up again"); CHECK_FALSE(scenario.start_up()); CHECK(eu07.lowVoltage.batteryVoltage < eu07.lowVoltage.nominalBatteryVoltage / 1.57); @@ -99,7 +99,7 @@ TEST_CASE("auxiliaries: the pantographs on their own tank, leaking until the pre scenario.wait(600.0); CHECK(eu07.pantographAir.pressure < eu07.EnginePowerSource.CollectorParameters.MinPress); CHECK_FALSE(eu07.pantographAir.pressureSwitchActive); - CHECK_FALSE(eu07.lineBreaker.closed); + CHECK_FALSE(eu07.lineBreaker.IsClosed()); scenario.act("small compressor on"); eu07.pantographAir.compressorRunning = true; for (int i = 0; i < 60 && eu07.pantographAir.compressorRunning; ++i) { diff --git a/tests/unit/test_camshaft.cpp b/tests/unit/test_camshaft.cpp index 11b2784d6..2c8a580d9 100644 --- a/tests/unit/test_camshaft.cpp +++ b/tests/unit/test_camshaft.cpp @@ -70,20 +70,22 @@ definition skoda() { void running(physics::Vehicle &Locomotive, int const Direction, int const Position, int const Controller) { Locomotive.CabActive = 1; Locomotive.DirActive = Direction; - Locomotive.lineBreaker.closed = true; + Locomotive.lineBreaker.Close(); Locomotive.brakePipe.pressure = 5.0; // bar, the pressure switch lets the line contactors close Locomotive.brakes.cylinderPressure = 0.0; - Locomotive.lineContactors.closed = true; + Locomotive.lineContactors.Close(); Locomotive.MainCtrlActualPos = Position; Locomotive.MainCtrlPos = Controller; - Locomotive.lineContactors.lastSwitchTime = 10.0; + Locomotive.lineContactors.RestartSwitchTimer(); + Locomotive.lineContactors.AdvanceSwitchTimer(10.0); } // steps the camshaft as the physics does, each step once the delay since the previous one passed; returns where it // ended up int run_camshaft(physics::Vehicle &Locomotive, int const Steps) { for (int step = 0; step < Steps; ++step) { - Locomotive.lineContactors.lastSwitchTime = 10.0; + Locomotive.lineContactors.RestartSwitchTimer(); + Locomotive.lineContactors.AdvanceSwitchTimer(10.0); Locomotive.AutoRelayCheck(); } return Locomotive.MainCtrlActualPos; @@ -108,7 +110,7 @@ TEST_CASE("camshaft: running backwards, the camshaft goes back down from the las running(physics, -1, 22, 0); run_camshaft(physics, 30); CHECK(physics.MainCtrlActualPos == 0); - CHECK_FALSE(physics.lineContactors.closed); // the motors don't pull any more + CHECK_FALSE(physics.lineContactors.IsClosed()); // the motors don't pull any more } } diff --git a/tests/unit/test_cntrl.cpp b/tests/unit/test_cntrl.cpp index eb99d05b0..eba42f832 100644 --- a/tests/unit/test_cntrl.cpp +++ b/tests/unit/test_cntrl.cpp @@ -23,18 +23,18 @@ TEST_CASE("cntrl: the relays of a multiple unit start on their own, of other veh SUBCASE("multiple unit") { vehicle unit{definition::load("wagon").set("Param", "Type", "ezt")}; REQUIRE(unit->TrainType == train_type::emu); - CHECK(unit->protection.groundStart == start_t::automatic); - CHECK(unit->converter.overloadRelayStart == start_t::converter); // activates when the converter is switched off + CHECK(unit->protection.config.groundStart == start_t::automatic); + CHECK(unit->converter.config.overloadRelayStart == start_t::converter); // activates when the converter is switched off } SUBCASE("other vehicle") { vehicle wagon{definition::load("wagon")}; - CHECK(wagon->protection.groundStart == start_t::manual); - CHECK(wagon->converter.overloadRelayStart == start_t::manual); + CHECK(wagon->protection.config.groundStart == start_t::manual); + CHECK(wagon->converter.config.overloadRelayStart == start_t::manual); } SUBCASE("given in the definition") { vehicle unit{definition::load("wagon").set("Param", "Type", "ezt").set("Cntrl", "GroundRelayStart", "Manual").set("Cntrl", "ConverterOverloadRelayStart", "Automatic")}; - CHECK(unit->protection.groundStart == start_t::manual); - CHECK(unit->converter.overloadRelayStart == start_t::automatic); + CHECK(unit->protection.config.groundStart == start_t::manual); + CHECK(unit->converter.config.overloadRelayStart == start_t::automatic); } } diff --git a/tests/unit/test_collisions.cpp b/tests/unit/test_collisions.cpp index 108cf87e2..8bbb0a18b 100644 --- a/tests/unit/test_collisions.cpp +++ b/tests/unit/test_collisions.cpp @@ -596,7 +596,7 @@ TEST_CASE("collisions: a locomotive at its starting effort against a braked trai }; // the line contactors close at the first position, once their delay and the pressure switch let them locomotive->IncMainCtrl(1); - for (int i = 0; i < 90 && false == locomotive->lineContactors.closed; ++i) { + for (int i = 0; i < 90 && false == locomotive->lineContactors.IsClosed(); ++i) { test::drive(driver, line, 1.0); } for (int i = 0; i < 60 && false == locomotive->IsMainCtrlMaxPowerPos(); ++i) { @@ -1248,7 +1248,7 @@ TEST_CASE("collisions: a locomotive pushing a standing braked train at full powe }; // the line contactors close at the first position, once their delay and the pressure switch let them locomotive->IncMainCtrl(1); - for (int i = 0; i < 90 && false == locomotive->lineContactors.closed; ++i) { + for (int i = 0; i < 90 && false == locomotive->lineContactors.IsClosed(); ++i) { test::drive(driver, line, 1.0); } for (int i = 0; i < 60 && false == locomotive->IsMainCtrlMaxPowerPos(); ++i) { diff --git a/tests/unit/test_commands.cpp b/tests/unit/test_commands.cpp index 58ad83fa3..f4e2c4841 100644 --- a/tests/unit/test_commands.cpp +++ b/tests/unit/test_commands.cpp @@ -28,7 +28,7 @@ std::vector state() { std::vector result{ {"MainCtrlPos", [](auto const &M) { return M.MainCtrlPos; }}, {"ScndCtrlPos", [](auto const &M) { return M.ScndCtrlPos; }}, - {"LastRelayTime", [](auto const &M) { return M.lineContactors.lastSwitchTime; }}, + {"LastRelayTime", [](auto const &M) { return M.lineContactors.TimeSinceSwitch(); }}, {"eimic_real", [](auto const &M) { return M.eimic_real; }}, {"TUHEX_StageActual", [](auto const &M) { return M.TUHEX_StageActual; }}, {"TUHEX_Active", [](auto const &M) { return flag(M.TUHEX_Active); }}, @@ -46,14 +46,14 @@ std::vector state() { {"OilPumpDisabled", [](auto const &M) { return flag(M.OilPump.is_disabled); }}, {"CompartmentLightsEnabled", [](auto const &M) { return flag(M.CompartmentLights.is_enabled); }}, {"CompartmentLightsDisabled", [](auto const &M) { return flag(M.CompartmentLights.is_disabled); }}, - {"MainSwitch", [](auto const &M) { return flag(M.lineBreaker.closed); }}, + {"MainSwitch", [](auto const &M) { return flag(M.lineBreaker.IsClosed()); }}, {"Heating", [](auto const &M) { return flag(M.trainHeating.on); }}, {"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); }}, - {"ConverterAllow", [](auto const &M) { return flag(M.converter.allow); }}, + {"ConverterAllow", [](auto const &M) { return flag(M.converter.IsAllowed()); }}, {"Battery", [](auto const &M) { return flag(M.lowVoltage.batteryOn); }}, {"CompressorAllow", [](auto const &M) { return flag(M.air.compressor.allow); }}, {"CompressorListPos", [](auto const &M) { return M.air.compressor.listPosition; }}, @@ -411,8 +411,8 @@ TEST_CASE("commands: every switch of the cab, worked on a pair standing under th {"PantFrontActive", [](auto const &M) { return flag(M.pantographs[VehicleEnd::front].is_active); }}, {"PantRearActive", [](auto const &M) { return flag(M.pantographs[VehicleEnd::rear].is_active); }}, {"PantPress", [](auto const &M) { return M.pantographAir.pressure; }}, - {"GroundRelay", [](auto const &M) { return flag(M.protection.ground); }}, - {"ConverterFlag", [](auto const &M) { return flag(M.converter.running); }}, + {"GroundRelay", [](auto const &M) { return flag(M.protection.GroundHolds()); }}, + {"ConverterFlag", [](auto const &M) { return flag(M.converter.IsRunning()); }}, {"CompressorFlag", [](auto const &M) { return flag(M.air.compressor.running); }}, {"Compressor", [](auto const &M) { return M.air.mainReservoirPressure; }}, {"MainCtrlActualPos", [](auto const &M) { return M.MainCtrlActualPos; }}, diff --git a/tests/unit/test_compressor.cpp b/tests/unit/test_compressor.cpp index 13e667ceb..b9c8bc6fc 100644 --- a/tests/unit/test_compressor.cpp +++ b/tests/unit/test_compressor.cpp @@ -47,14 +47,14 @@ TEST_CASE("compressor: without a start delay the compressor starts with its powe run_compressor(vehicle, 1.0); REQUIRE_FALSE(vehicle->air.compressor.running); // no power, no compressor - vehicle->lineBreaker.closed = true; + vehicle->lineBreaker.Close(); run_compressor(vehicle, step); CHECK(vehicle->air.compressor.running); } TEST_CASE("compressor: the compressor starts the delay after getting its power") { auto vehicle{compressor_vehicle(5.0)}; - vehicle->lineBreaker.closed = true; + vehicle->lineBreaker.Close(); run_compressor(vehicle, 4.9); CHECK_FALSE(vehicle->air.compressor.running); @@ -68,15 +68,15 @@ TEST_CASE("compressor: the compressor starts the delay after getting its power") TEST_CASE("compressor: the delay starts over once the power is gone") { auto vehicle{compressor_vehicle(5.0)}; - vehicle->lineBreaker.closed = true; + vehicle->lineBreaker.Close(); run_compressor(vehicle, 10.0); REQUIRE(vehicle->air.compressor.running); - vehicle->lineBreaker.closed = false; // the engine stopped + vehicle->lineBreaker.Open(); // the engine stopped run_compressor(vehicle, 1.0); CHECK_FALSE(vehicle->air.compressor.running); - vehicle->lineBreaker.closed = true; // and started again + vehicle->lineBreaker.Close(); // and started again run_compressor(vehicle, 4.9); CHECK_FALSE(vehicle->air.compressor.running); run_compressor(vehicle, 0.2); @@ -85,7 +85,7 @@ TEST_CASE("compressor: the delay starts over once the power is gone") { TEST_CASE("compressor: a compressor fed from the low voltage waits from the low voltage coming on") { auto vehicle{compressor_vehicle(5.0, "")}; // the default supply: the converter, the 110 V - vehicle->lineBreaker.closed = true; // which alone doesn't feed it + vehicle->lineBreaker.Close(); // which alone doesn't feed it run_compressor(vehicle, 10.0); REQUIRE_FALSE(vehicle->air.compressor.running); @@ -98,7 +98,7 @@ TEST_CASE("compressor: a compressor fed from the low voltage waits from the low TEST_CASE("compressor: the pressure switch stops the compressor above the cut-out pressure") { auto vehicle{compressor_vehicle(0.0)}; - vehicle->lineBreaker.closed = true; + vehicle->lineBreaker.Close(); vehicle->air.compressedVolume = 8.5; // over MaxCP, in the reservoir of 1 m3 run_compressor(vehicle, step); CHECK(vehicle->air.compressor.governorLock); @@ -107,7 +107,7 @@ TEST_CASE("compressor: the pressure switch stops the compressor above the cut-ou TEST_CASE("compressor: without a pressure switch the air over the cut-out pressure is vented") { auto vehicle{compressor_vehicle(0.0, "Main", 8.0)}; // MinCP the same as MaxCP: no pressure switch - vehicle->lineBreaker.closed = true; + vehicle->lineBreaker.Close(); vehicle->air.compressedVolume = 8.5; run_compressor(vehicle, step); REQUIRE(vehicle->air.compressor.running); // nothing stops it @@ -116,13 +116,13 @@ TEST_CASE("compressor: without a pressure switch the air over the cut-out pressu TEST_CASE("compressor: an engine stopped before the delay passed counts the whole delay again") { auto vehicle{compressor_vehicle(30.0)}; - vehicle->lineBreaker.closed = true; // engine started + vehicle->lineBreaker.Close(); // engine started run_compressor(vehicle, 20.0); REQUIRE_FALSE(vehicle->air.compressor.running); - vehicle->lineBreaker.closed = false; // engine stopped, 10 s short of the delay + vehicle->lineBreaker.Open(); // engine stopped, 10 s short of the delay run_compressor(vehicle, 1.0); - vehicle->lineBreaker.closed = true; + vehicle->lineBreaker.Close(); run_compressor(vehicle, 15.0); // 36 s since the first start, but only 15 s since this one CHECK_FALSE(vehicle->air.compressor.running); @@ -134,7 +134,7 @@ TEST_CASE("compressor: the start delay holds back a compressor switched on by ha auto vehicle{compressor_vehicle(30.0)}; vehicle->air.compressor.start = start_t::manual; vehicle->air.compressor.allow = true; // switch in the cabinet on before the engine start - vehicle->lineBreaker.closed = true; + vehicle->lineBreaker.Close(); run_compressor(vehicle, 29.9); CHECK_FALSE(vehicle->air.compressor.running); @@ -175,12 +175,12 @@ definition generator_vehicle(double const ConverterDelay, double const Compresso TEST_CASE("compressor: fed from the converter it waits for the converter start delay") { vehicle loco{generator_vehicle(30.0, 0.0)}; REQUIRE(loco->air.compressor.supply == physics::CompressorSupply::converter); - REQUIRE(loco->converter.startDelay == doctest::Approx(30.0)); + REQUIRE(loco->converter.config.startDelay == doctest::Approx(30.0)); loco.run(1.0); // engine off CHECK_FALSE(loco->lowVoltage.power110vAvailable); - loco->lineBreaker.closed = true; // engine started + loco->lineBreaker.Close(); // engine started loco.run(25.0); CHECK_FALSE(loco->lowVoltage.power110vAvailable); CHECK_FALSE(loco->air.compressor.running); @@ -195,7 +195,7 @@ TEST_CASE("compressor: fed from the converter the start delay counts from the co REQUIRE(loco->air.compressor.startDelay == doctest::Approx(10.0)); loco.run(1.0); // engine off - loco->lineBreaker.closed = true; // engine started + loco->lineBreaker.Close(); // engine started loco.run(25.0); REQUIRE(loco->lowVoltage.power110vAvailable); // the converter is up CHECK_FALSE(loco->air.compressor.running); // but the compressor waits for its own delay as well diff --git a/tests/unit/test_crew.cpp b/tests/unit/test_crew.cpp index a850194fd..042f02c39 100644 --- a/tests/unit/test_crew.cpp +++ b/tests/unit/test_crew.cpp @@ -31,7 +31,7 @@ void get_under_way(consist &Train, int const Position, double const Seconds) { } test::drive(driver, line, 20.0); driver.controlling.IncMainCtrl(1); - for (int i = 0; i < 90 && false == driver.controlling.lineContactors.closed; ++i) { + for (int i = 0; i < 90 && false == driver.controlling.lineContactors.IsClosed(); ++i) { test::drive(driver, line, 1.0); } for (int i = 0; i < 60 && driver.controlling.MainCtrlPos < Position; ++i) { @@ -194,7 +194,7 @@ TEST_CASE("crew: a locomotive under power left by its driver stops and stays bra auto &eu07{train[0].physics()}; REQUIRE(train[0].speed() > 20.0); REQUIRE(eu07.MainCtrlPos > 0); - REQUIRE(eu07.lineBreaker.closed); + REQUIRE(eu07.lineBreaker.IsClosed()); crew::secure(eu07, eu07); @@ -213,7 +213,7 @@ TEST_CASE("crew: a locomotive under power left by its driver stops and stays bra // it keeps standing, also on a slope, with the engine as the driver left it train.run(120.0, track{0.15, 0.02, test::catenary_3kv}); CHECK(std::abs(train[0].speed()) <= 0.01); - CHECK(eu07.lineBreaker.closed); + CHECK(eu07.lineBreaker.IsClosed()); CHECK(eu07.Im == doctest::Approx(0.0)); } diff --git a/tests/unit/test_derailment_vehicle.cpp b/tests/unit/test_derailment_vehicle.cpp index 786d16f1b..b2c1e7759 100644 --- a/tests/unit/test_derailment_vehicle.cpp +++ b/tests/unit/test_derailment_vehicle.cpp @@ -59,7 +59,7 @@ TEST_CASE("derailment: a vehicle too fast in a curve") { } REQUIRE(eu07vehicle->DamageFlag.HasAll(VehicleDamage::derailed)); CHECK(eu07vehicle->Derailed == dr::outcome::overturned); - CHECK_FALSE(eu07vehicle->lineBreaker.closed); + CHECK_FALSE(eu07vehicle->lineBreaker.IsClosed()); // not stopped dead as the legacy model has it: it slows down at half of g on the 80 of its 96 t auto const start{eu07vehicle->V}; CHECK(start > 0.95 * (critical + 5.0) * kmh); diff --git a/tests/unit/test_engine_shutdown.cpp b/tests/unit/test_engine_shutdown.cpp index 4e54206ed..b96aa011c 100644 --- a/tests/unit/test_engine_shutdown.cpp +++ b/tests/unit/test_engine_shutdown.cpp @@ -27,7 +27,7 @@ TEST_CASE("engine shutdown: the shunter starts with the starter button") { auto shunter{running_shunter()}; REQUIRE(shunter->EngineType == TEngineType::DieselEngine); REQUIRE(shunter->FuelPump.start_type == start_t::automatic); - CHECK(shunter->lineBreaker.closed); + CHECK(shunter->lineBreaker.IsClosed()); CHECK(shunter->FuelPump.is_active); CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions); } @@ -36,11 +36,11 @@ TEST_CASE("engine shutdown: neither the fuel pump switch nor the battery switch auto shunter{running_shunter()}; shunter->FuelPumpSwitchOff(true, range_t::local); // the pump started automatically ignores its switch shunter.run(10.0); - CHECK(shunter->lineBreaker.closed); + CHECK(shunter->lineBreaker.IsClosed()); shunter->BatterySwitch(false); shunter.run(10.0); CHECK(shunter->lowVoltage.power110vAvailable); // the converter run by the engine keeps feeding the fuel pump - CHECK(shunter->lineBreaker.closed); + CHECK(shunter->lineBreaker.IsClosed()); CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions); } @@ -49,7 +49,7 @@ TEST_CASE("engine shutdown: the command opening the main circuit stops the engin REQUIRE(shunter->MainCircuitOpensWithStarterOnly()); // the cab passes the command on with only the starter button CHECK(shunter->MainSwitch(false)); shunter.run(20.0); - CHECK_FALSE(shunter->lineBreaker.closed); + CHECK_FALSE(shunter->lineBreaker.IsClosed()); CHECK_FALSE(shunter->FuelPump.is_active); CHECK(shunter->enrot == 0.0); } @@ -61,7 +61,7 @@ TEST_CASE("engine shutdown: the engine starts again after it was stopped") { REQUIRE(shunter->enrot == 0.0); shunter->MainSwitch(true); shunter.run(15.0); - CHECK(shunter->lineBreaker.closed); + CHECK(shunter->lineBreaker.IsClosed()); CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions); } diff --git a/tests/unit/test_engine_start.cpp b/tests/unit/test_engine_start.cpp index c45019b71..1f7e1c684 100644 --- a/tests/unit/test_engine_start.cpp +++ b/tests/unit/test_engine_start.cpp @@ -39,7 +39,7 @@ void prepare(consist &Train) { } bool running(physics::Vehicle const &Vehicle) { - return Vehicle.lineBreaker.closed && Vehicle.enrot > 0.5 * Vehicle.diesel.minRevolutions; + return Vehicle.lineBreaker.IsClosed() && Vehicle.enrot > 0.5 * Vehicle.diesel.minRevolutions; } // the time step of the train in the loops below @@ -65,8 +65,8 @@ TEST_CASE("engine start: the joint start is the default, and JointEngineStart=No consist train; auto const &joint{train.add(sn61(), 1).physics()}; auto const &separate{train.add(sn61(false)).physics()}; - CHECK(joint.lineBreaker.jointStart); - CHECK_FALSE(separate.lineBreaker.jointStart); + CHECK(joint.lineBreaker.config.jointStart); + CHECK_FALSE(separate.lineBreaker.config.jointStart); CHECK(joint.MainSwitchRange() == range_t::consist); CHECK(separate.MainSwitchRange() == range_t::local); } @@ -120,16 +120,16 @@ TEST_CASE("engine start: by default the cab's switch starts and stops the engine auto &first{train.add(sn61(), 1).physics()}; auto const &second{train.add(sn61()).physics()}; prepare(train); - REQUIRE_FALSE(first.lineBreaker.closed); - REQUIRE_FALSE(second.lineBreaker.closed); + REQUIRE_FALSE(first.lineBreaker.IsClosed()); + REQUIRE_FALSE(second.lineBreaker.IsClosed()); first.MainSwitch(true, first.MainSwitchRange()); train.run(15.0); CHECK(running(first)); CHECK(running(second)); first.MainSwitch(false, first.MainSwitchRange()); train.run(5.0); - CHECK_FALSE(first.lineBreaker.closed); - CHECK_FALSE(second.lineBreaker.closed); + CHECK_FALSE(first.lineBreaker.IsClosed()); + CHECK_FALSE(second.lineBreaker.IsClosed()); } TEST_CASE("engine start: with JointEngineStart=No each engine has its own switch") { @@ -142,8 +142,8 @@ TEST_CASE("engine start: with JointEngineStart=No each engine has its own switch first.MainSwitch(true, first.MainSwitchRange()); train.run(15.0); REQUIRE(running(first)); - CHECK_FALSE(second.lineBreaker.closed); - CHECK_FALSE(third.lineBreaker.closed); + CHECK_FALSE(second.lineBreaker.IsClosed()); + CHECK_FALSE(third.lineBreaker.IsClosed()); // the second one's switch, mainb_*, starts the second engine engine_start::remote_switch switchb; @@ -155,7 +155,7 @@ TEST_CASE("engine start: with JointEngineStart=No each engine has its own switch hold(train, switchb, engineb, 2.0); // past the SN61's delay of 1.5 s train.run(15.0); CHECK(running(second)); - CHECK_FALSE(third.lineBreaker.closed); + CHECK_FALSE(third.lineBreaker.IsClosed()); // and the third one's, mainc_*, the third hold(train, switchc, enginec, 2.0); train.run(15.0); @@ -164,12 +164,12 @@ TEST_CASE("engine start: with JointEngineStart=No each engine has its own switch // the switches open their own vehicles' circuits only CHECK(engine_start::remote_switch::open(second)); train.run(5.0); - CHECK_FALSE(second.lineBreaker.closed); + CHECK_FALSE(second.lineBreaker.IsClosed()); CHECK(running(first)); CHECK(running(third)); first.MainSwitch(false, first.MainSwitchRange()); train.run(5.0); - CHECK_FALSE(first.lineBreaker.closed); + CHECK_FALSE(first.lineBreaker.IsClosed()); CHECK(running(third)); CHECK_FALSE(engine_start::remote_switch::open(second)); // already stopped } @@ -184,7 +184,7 @@ TEST_CASE("engine start: the switch of another vehicle is held for the vehicle's // without the battery the switch does nothing, however long it's held hold(train, switchb, &second, 5.0); train.run(5.0); - CHECK_FALSE(second.lineBreaker.closed); + CHECK_FALSE(second.lineBreaker.IsClosed()); CHECK_FALSE(second.diesel.startupRequested); prepare(train); @@ -245,7 +245,7 @@ TEST_CASE("engine start: an engine stopping on its own stops the others only whe // the first one's fuel cut off, its engine stops first.FuelPump.is_disabled = true; train.run(15.0); - CHECK_FALSE(first.lineBreaker.closed); + CHECK_FALSE(first.lineBreaker.IsClosed()); CHECK(first.enrot == 0.0); // started on their own, the others keep running CHECK(running(second) == (false == joint)); @@ -275,7 +275,7 @@ TEST_CASE("engine start: an engine stopped from its own switch doesn't stop the // mainb_off CHECK(engine_start::remote_switch::open(second)); train.run(30.0); - CHECK_FALSE(second.lineBreaker.closed); + CHECK_FALSE(second.lineBreaker.IsClosed()); CHECK(second.enrot == 0.0); CHECK(running(first)); CHECK(running(third)); @@ -287,12 +287,12 @@ TEST_CASE("engine start: the stopped engine of the cab's vehicle doesn't stop th auto &first{train.add(sn61(), 1).physics()}; auto &second{train.add(sn61(false)).physics()}; prepare(train); - REQUIRE_FALSE(first.lineBreaker.closed); + REQUIRE_FALSE(first.lineBreaker.IsClosed()); // mainb_on engine_start::remote_switch switchb; hold(train, switchb, engine_start::engine(first, first, 2), 2.0); train.run(15.0); CHECK(running(second)); - CHECK_FALSE(first.lineBreaker.closed); + CHECK_FALSE(first.lineBreaker.IsClosed()); CHECK(first.enrot == 0.0); } diff --git a/tests/unit/test_field_shunting.cpp b/tests/unit/test_field_shunting.cpp index e1c2c9b8f..e761e59d7 100644 --- a/tests/unit/test_field_shunting.cpp +++ b/tests/unit/test_field_shunting.cpp @@ -55,7 +55,7 @@ TEST_CASE("field shunting: the SU45 with its switch, off at full power and switc scenario.get_going(); scenario.full_power(120.0); CHECK(su45.IsMainCtrlMaxPowerPos()); - CHECK(su45.lineContactors.closed); + CHECK(su45.lineContactors.IsClosed()); CHECK(su45.ScndCtrlPos == 0); CHECK_FALSE(su45.IncScndCtrl(1)); scenario.wait(1.0); @@ -87,7 +87,7 @@ TEST_CASE("field shunting: a diesel-electric with AutoRelay=Optional alone shunt scenario.get_going(); scenario.full_power(120.0); CHECK(su45.IsMainCtrlMaxPowerPos()); - CHECK(su45.lineContactors.closed); + CHECK(su45.lineContactors.IsClosed()); // over 50 km/h: the relays don't shunt, the driver does CHECK(su45.Vel > 50.0); CHECK(su45.ScndCtrlPos == 0); diff --git a/tests/unit/test_genset.cpp b/tests/unit/test_genset.cpp index b51264712..1c32112ba 100644 --- a/tests/unit/test_genset.cpp +++ b/tests/unit/test_genset.cpp @@ -80,7 +80,7 @@ bool start_on_genset(vehicle &Vehicle, track const &Track = no_wire, double cons wake(cab); cab.TractionModeSwitch(traction_mode::genset); cab.GensetSwitch(true); - if (false == cab.lineBreaker.closed) { + if (false == cab.lineBreaker.IsClosed()) { if (cab.MainSwitchCheck()) { close_line_breaker(cab); } @@ -90,7 +90,7 @@ bool start_on_genset(vehicle &Vehicle, track const &Track = no_wire, double cons cab.CompressorSwitch(true); } run(Vehicle, 1.0, Track); - if (cab.lineBreaker.closed && cab.converter.running && cab.mainPipe.pressure >= 4.5) { + if (cab.lineBreaker.IsClosed() && cab.converter.IsRunning() && cab.mainPipe.pressure >= 4.5) { // and the brakes let go test::release_brakes(cab); for (auto wait = 0; wait < 120 && cab.brakes.cylinderPressure > 0.05; ++wait) { @@ -193,13 +193,13 @@ TEST_CASE("genset: the selector moves only with the line breaker open") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; auto &cab{dragon6.physics()}; REQUIRE(test::start_up(test::driving(dragon6), wire)); - REQUIRE(cab.lineBreaker.closed); + REQUIRE(cab.lineBreaker.IsClosed()); CHECK_FALSE(cab.TractionModeSwitch(traction_mode::genset)); CHECK(cab.TractionMode == traction_mode::catenary); run(dragon6, 2.0, wire); - CHECK(cab.lineBreaker.closed); + CHECK(cab.lineBreaker.IsClosed()); cab.MainSwitch(false); - REQUIRE_FALSE(cab.lineBreaker.closed); + REQUIRE_FALSE(cab.lineBreaker.IsClosed()); CHECK(cab.TractionModeSwitch(traction_mode::genset)); CHECK(cab.GensetSelected()); CHECK(cab.TractionModeSwitch(traction_mode::catenary)); @@ -223,19 +223,19 @@ TEST_CASE("genset: started, it closes the line breaker without a catenary") { CHECK(cab.Genset.revolutions == cab.Genset.revolutions_idle); CHECK(cab.Genset.voltage == 3000.0); // the line breaker gets ready MainInitTime after the voltage came - for (auto second = 0; second < 10 && false == cab.lineBreaker.closed; ++second) { + for (auto second = 0; second < 10 && false == cab.lineBreaker.IsClosed(); ++second) { if (cab.MainSwitchCheck()) { close_line_breaker(cab); } run(dragon6, 1.0); } - REQUIRE(cab.lineBreaker.closed); + REQUIRE(cab.lineBreaker.IsClosed()); CHECK(cab.pantographCircuit.supplyVoltage == 0.0); dragon6.step(no_wire); CHECK(cab.EngineVoltage == 3000.0); CHECK(cab.MainCircuitPowered()); run(dragon6, 5.0); - CHECK(cab.lineBreaker.closed); + CHECK(cab.lineBreaker.IsClosed()); } TEST_CASE("genset: on the catenary position the genset feeds nothing") { @@ -248,7 +248,7 @@ TEST_CASE("genset: on the catenary position the genset feeds nothing") { CHECK(cab.TractionMode == traction_mode::catenary); CHECK_FALSE(cab.MainSwitchCheck()); close_line_breaker(cab); - CHECK_FALSE(cab.lineBreaker.closed); + CHECK_FALSE(cab.lineBreaker.IsClosed()); dragon6.step(no_wire); CHECK(cab.EngineVoltage == 0.0); CHECK(cab.TractionSupplyVoltage() == 0.0); @@ -264,7 +264,7 @@ TEST_CASE("genset: on the genset position the catenary feeds nothing") { // the pantographs up under the wire, the genset stopped: the line breaker never closes CHECK_FALSE(test::start_up(test::driving(dragon6), wire, 120.0)); REQUIRE(cab.pantographCircuit.supplyVoltage > 2900.0); - CHECK_FALSE(cab.lineBreaker.closed); + CHECK_FALSE(cab.lineBreaker.IsClosed()); CHECK_FALSE(cab.MainSwitchCheck()); dragon6.step(wire); CHECK(cab.EngineVoltage == 0.0); @@ -280,7 +280,7 @@ TEST_CASE("genset: the power at the wheels stays within the genset's") { auto revolutions{0.0}; auto over{0L}; auto step_count{0L}; - for (; step_count < 60000 && cab.Vel < 80.0 && cab.lineBreaker.closed; ++step_count) { + for (; step_count < 60000 && cab.Vel < 80.0 && cab.lineBreaker.IsClosed(); ++step_count) { step(dragon6, step_count); auto const power{wheel_power(cab)}; peak = std::max(peak, power); @@ -291,7 +291,7 @@ TEST_CASE("genset: the power at the wheels stays within the genset's") { } CAPTURE(step_count); CAPTURE(peak); - CHECK(cab.lineBreaker.closed); + CHECK(cab.lineBreaker.IsClosed()); CHECK(cab.Vel >= 80.0); CHECK(over == 0); CHECK(peak <= genset_traction_power * 1.02); @@ -382,13 +382,13 @@ TEST_CASE("genset: stopped, it opens the line breaker") { REQUIRE(cab.Genset.revolutions == doctest::Approx(cab.Genset.revolutions_idle)); cab.GensetSwitch(false); auto step_count{0L}; - for (; step_count < 1000 && cab.lineBreaker.closed; ++step_count) { + for (; step_count < 1000 && cab.lineBreaker.IsClosed(); ++step_count) { step(dragon6, step_count); } // coasting down from idle, the voltage falls to half, the undervoltage limit, in spinup_time * ln 2 auto const seconds{step_count * 0.01}; CAPTURE(seconds); - CHECK_FALSE(cab.lineBreaker.closed); + CHECK_FALSE(cab.lineBreaker.IsClosed()); CHECK(seconds == doctest::Approx(3.0 * std::log(2.0)).epsilon(0.05)); CHECK_FALSE(cab.Genset.is_active); // and it doesn't close again @@ -396,7 +396,7 @@ TEST_CASE("genset: stopped, it opens the line breaker") { close_line_breaker(cab); run(dragon6, 1.0); } - CHECK_FALSE(cab.lineBreaker.closed); + CHECK_FALSE(cab.lineBreaker.IsClosed()); // coasting down to a stop, with the time constant spinup_time CHECK(cab.Genset.revolutions < 0.01 * cab.Genset.revolutions_idle); CHECK(cab.Genset.voltage < 0.01 * cab.Genset.voltage_nominal); @@ -448,18 +448,18 @@ TEST_CASE("genset: the pantographs' pressure switch leaves the genset's line bre cab.pantographAir.pressureSwitchActive = true; cab.pantographAir.pressure = 0.0; cab.PantPressureSwitchCheck(); - CHECK(cab.lineBreaker.closed); + CHECK(cab.lineBreaker.IsClosed()); } SUBCASE("on the pantographs it opens the line breaker, the check the genset is spared") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; auto &cab{dragon6.physics()}; REQUIRE(test::start_up(test::driving(dragon6), wire)); - REQUIRE(cab.lineBreaker.closed); + REQUIRE(cab.lineBreaker.IsClosed()); // the pressure switch looks at the voltage through the couplers, not the pantographs' cab.pantographAir.pressureSwitchActive = true; cab.pantographAir.pressure = 0.0; cab.PantPressureSwitchCheck(); - CHECK_FALSE(cab.lineBreaker.closed); + CHECK_FALSE(cab.lineBreaker.IsClosed()); } } @@ -508,7 +508,7 @@ TEST_CASE("genset: braking electrodynamically on the genset sends nothing back") REQUIRE(braked.electrodynamic); CHECK(braked.lowest_current >= -1e-6); CHECK(braked.speed_lost > 5.0); - CHECK(dragon6->lineBreaker.closed); + CHECK(dragon6->lineBreaker.IsClosed()); } SUBCASE("on the catenary the same braking feeds the line, the check the genset is spared") { vehicle dragon6{dragon_genset(), 0.0, "test", 1}; @@ -543,12 +543,12 @@ TEST_CASE("genset: one genset feeds the next car through the high voltage coupli second.RelayReset(relay_t::maincircuitground | relay_t::tractionnmotoroverload | relay_t::primaryconverteroverload, range_t::local); CHECK(second.MainSwitchCheck()); second.MainSwitch(true, range_t::local); - CHECK(second.lineBreaker.closed); + CHECK(second.lineBreaker.IsClosed()); // stopped, the genset takes the voltage away first.GensetSwitch(false); train.run(30.0, no_wire); CHECK(second.GetTrainsetHighVoltage() < 1.0); - CHECK_FALSE(second.lineBreaker.closed); + CHECK_FALSE(second.lineBreaker.IsClosed()); } TEST_CASE("genset: the selector command travels along the train") { @@ -580,10 +580,10 @@ TEST_CASE("genset: a selector command refused with the line breaker closed isn't auto &first{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 1).physics()}; auto &second{train.add(dragon_genset().set("BuffCoupl", "AllowedFlag", 47), 0, coupling).physics()}; REQUIRE(test::start_up(test::driving(train), wire)); - REQUIRE(first.lineBreaker.closed); + REQUIRE(first.lineBreaker.IsClosed()); // the second one's line breaker opened by itself, the lead's is closed second.MainSwitch(false, range_t::local); - REQUIRE_FALSE(second.lineBreaker.closed); + REQUIRE_FALSE(second.lineBreaker.IsClosed()); CHECK_FALSE(first.TractionModeSwitch(traction_mode::genset, range_t::consist)); CHECK_FALSE(first.GensetSelected()); CHECK_FALSE(second.GensetSelected()); diff --git a/tests/unit/test_line_contactors.cpp b/tests/unit/test_line_contactors.cpp index 90f3ff2a1..4429189d6 100644 --- a/tests/unit/test_line_contactors.cpp +++ b/tests/unit/test_line_contactors.cpp @@ -9,7 +9,7 @@ namespace { test::vehicle locomotive(bool const Pressureswitch) { test::vehicle vehicle{test::definition::load("wagon").set("Engine", "PressureSwitch", Pressureswitch)}; - vehicle->lineContactors.closed = false; // the line contactors open + vehicle->lineContactors.Open(); // the line contactors open vehicle->brakePipe.pressure = 5.0; return vehicle; } @@ -18,16 +18,16 @@ test::vehicle locomotive(bool const Pressureswitch) { TEST_CASE("line contactors: with a pressure switch the lamp goes out with the start cut off") { auto vehicle{locomotive(true)}; - REQUIRE(vehicle->protection.hasPressureSwitch); + REQUIRE(vehicle->protection.config.hasPressureSwitch); vehicle->brakes.cylinderPressure = 1.5; // braked, the start can still be made vehicle->MotorConnectorsCheck(); // updates the pressure switch - REQUIRE_FALSE(vehicle->protection.pressureSwitch); + REQUIRE_FALSE(vehicle->protection.PressureSwitchTripped()); CHECK(vehicle->LineContactorsLampLit()); vehicle->brakes.cylinderPressure = 2.5; // the pressure switch cuts the start off vehicle->MotorConnectorsCheck(); - REQUIRE(vehicle->protection.pressureSwitch); + REQUIRE(vehicle->protection.PressureSwitchTripped()); CHECK_FALSE(vehicle->LineContactorsLampLit()); } @@ -43,7 +43,7 @@ TEST_CASE("line contactors: without a pressure switch the lamp goes out with the TEST_CASE("line contactors: closed contactors put the lamp out") { auto vehicle{locomotive(true)}; - vehicle->lineContactors.closed = true; + vehicle->lineContactors.Close(); CHECK_FALSE(vehicle->LineContactorsLampLit()); } @@ -85,19 +85,19 @@ test::vehicle diesel_electric() { TEST_CASE("line contactors: on a diesel-electric the lamp is lit at 0 and goes out on a power position") { auto vehicle{diesel_electric()}; REQUIRE(vehicle->EngineType == TEngineType::DieselElectric); - REQUIRE(vehicle->lineBreaker.closed); - REQUIRE_FALSE(vehicle->protection.pressureSwitch); - CHECK_FALSE(vehicle->lineContactors.closed); + REQUIRE(vehicle->lineBreaker.IsClosed()); + REQUIRE_FALSE(vehicle->protection.PressureSwitchTripped()); + CHECK_FALSE(vehicle->lineContactors.IsClosed()); CHECK(vehicle->LineContactorsLampLit()); vehicle->IncMainCtrl(1); vehicle.run(3.0); - CHECK(vehicle->lineContactors.closed); + CHECK(vehicle->lineContactors.IsClosed()); CHECK_FALSE(vehicle->LineContactorsLampLit()); vehicle->DecMainCtrl(1); vehicle.run(3.0); - CHECK_FALSE(vehicle->lineContactors.closed); + CHECK_FALSE(vehicle->lineContactors.IsClosed()); CHECK(vehicle->LineContactorsLampLit()); } @@ -107,12 +107,12 @@ TEST_CASE("line contactors: on a diesel-electric the lamp lights with the contac vehicle.run(1.0); vehicle->IncMainCtrl(1); vehicle.run(2.0); - REQUIRE(vehicle->lineContactors.closed); + REQUIRE(vehicle->lineContactors.IsClosed()); vehicle.hold_brake_pipe(2.5); // bar, below the 3.6 bar of the pressure switch vehicle.run(10.0); - REQUIRE(vehicle->protection.pressureSwitch); - CHECK_FALSE(vehicle->lineContactors.closed); + REQUIRE(vehicle->protection.PressureSwitchTripped()); + CHECK_FALSE(vehicle->lineContactors.IsClosed()); CHECK(vehicle->LineContactorsLampLit()); // it went out here CHECK_FALSE(vehicle->MainCircuitLampsEnabled()); // the ground relay and overload lamps still go out with the start cut off @@ -120,11 +120,11 @@ TEST_CASE("line contactors: on a diesel-electric the lamp lights with the contac // they close again only on the first one vehicle.hold_brake_pipe(5.0); vehicle.run(60.0); - REQUIRE_FALSE(vehicle->protection.pressureSwitch); - CHECK_FALSE(vehicle->lineContactors.closed); + REQUIRE_FALSE(vehicle->protection.PressureSwitchTripped()); + CHECK_FALSE(vehicle->lineContactors.IsClosed()); CHECK(vehicle->LineContactorsLampLit()); vehicle->DecMainCtrl(1); vehicle.run(3.0); - CHECK(vehicle->lineContactors.closed); + CHECK(vehicle->lineContactors.IsClosed()); CHECK_FALSE(vehicle->LineContactorsLampLit()); } diff --git a/tests/unit/test_line_contactors_interlock.cpp b/tests/unit/test_line_contactors_interlock.cpp index eb92812e2..94e658281 100644 --- a/tests/unit/test_line_contactors_interlock.cpp +++ b/tests/unit/test_line_contactors_interlock.cpp @@ -22,7 +22,7 @@ vehicle ready(std::string_view const Interlock) { loaded.set("Cntrl", "LineContactorsInterlock", std::string{Interlock}); } vehicle locomotive{loaded}; - locomotive->lineBreaker.closed = true; + locomotive->lineBreaker.Close(); locomotive->DirActive = 1; locomotive->brakePipe.pressure = 5.0; locomotive->brakes.cylinderPressure = 0.0; @@ -34,15 +34,15 @@ test::track const line{0.15, 0.0, test::catenary_3kv}; } // namespace TEST_CASE("line contactors interlock: read from the Cntrl. section, none by default") { - CHECK(ready("")->lineContactors.interlock == line_contactors_interlock::none); - CHECK(ready("Converter")->lineContactors.interlock == line_contactors_interlock::converter); - CHECK(ready("MotorBlowers")->lineContactors.interlock == line_contactors_interlock::motor_blowers); - CHECK(ready("Something")->lineContactors.interlock == line_contactors_interlock::none); + CHECK(ready("")->lineContactors.config.interlock == line_contactors_interlock::none); + CHECK(ready("Converter")->lineContactors.config.interlock == line_contactors_interlock::converter); + CHECK(ready("MotorBlowers")->lineContactors.config.interlock == line_contactors_interlock::motor_blowers); + CHECK(ready("Something")->lineContactors.config.interlock == line_contactors_interlock::none); } TEST_CASE("line contactors interlock: without one the converter and the blowers don't matter, as before") { auto locomotive{ready("")}; - locomotive->converter.running = false; + locomotive->converter.SetRunningForTest(false); for (auto &blower : locomotive->MotorBlowers) { blower.is_active = false; } @@ -51,12 +51,12 @@ TEST_CASE("line contactors interlock: without one the converter and the blowers TEST_CASE("line contactors interlock: on the converter, they close only with the vehicle's own converter running") { auto locomotive{ready("Converter")}; - locomotive->converter.running = false; + locomotive->converter.SetRunningForTest(false); locomotive->lowVoltage.power110vAvailable = true; // the 110 V from the other section doesn't run this one's fans CHECK_FALSE(locomotive->MotorConnectorsCheck()); - locomotive->converter.running = true; + locomotive->converter.SetRunningForTest(true); CHECK(locomotive->MotorConnectorsCheck()); - locomotive->lineBreaker.closed = false; // the other conditions still hold + locomotive->lineBreaker.Open(); // the other conditions still hold CHECK_FALSE(locomotive->MotorConnectorsCheck()); } @@ -124,10 +124,10 @@ bool blowers_run(physics::Vehicle const &Physics) { // the driver's first power position, held until the line contactors close (their delay, the pressure switch) bool close_line_contactors(test::driven const &Driven) { Driven.controlling.IncMainCtrl(1); - for (int i = 0; i < 30 && false == Driven.controlling.lineContactors.closed; ++i) { + for (int i = 0; i < 30 && false == Driven.controlling.lineContactors.IsClosed(); ++i) { test::drive(Driven, line, 1.0); } - return Driven.controlling.lineContactors.closed; + return Driven.controlling.lineContactors.IsClosed(); } // the brakes released and the cylinders empty enough for the pressure switch to let the vehicle start @@ -154,7 +154,7 @@ TEST_CASE("line contactors interlock: with blowers starting with the speed the v .set("Engine", "MotorBlowersSustainTime", 10.0), 0.0, "test", 1}; auto &physics{eu07.physics()}; - REQUIRE(physics.lineContactors.interlock == line_contactors_interlock::motor_blowers); + REQUIRE(physics.lineContactors.config.interlock == line_contactors_interlock::motor_blowers); REQUIRE(physics.MotorBlowers[VehicleEnd::front].min_start_velocity == doctest::Approx(5.0)); REQUIRE(physics.MotorBlowers[VehicleEnd::rear].sustain_time == doctest::Approx(10.0)); auto driven{test::driving(eu07)}; @@ -177,7 +177,7 @@ TEST_CASE("line contactors interlock: with blowers starting with the speed the v } REQUIRE(eu07.speed() >= 10.0); CHECK(blowers_run(physics)); - CHECK(physics.lineContactors.closed); + CHECK(physics.lineContactors.IsClosed()); // a stop longer than the blowers keep running for while (physics.DecMainCtrl(1)) { @@ -190,7 +190,7 @@ TEST_CASE("line contactors interlock: with blowers starting with the speed the v REQUIRE(std::abs(eu07.speed()) <= 0.1); test::drive(driven, line, 15.0); REQUIRE_FALSE(blowers_run(physics)); - REQUIRE_FALSE(physics.lineContactors.closed); + REQUIRE_FALSE(physics.lineContactors.IsClosed()); // and the vehicle starts again release(driven); @@ -223,7 +223,7 @@ TEST_CASE("line contactors interlock: a blower starting with the speed, switched // the switch of the rear blower: off, the contactors open and stay open, standing as well as later REQUIRE(physics.MotorBlowersSwitchOff(true, VehicleEnd::rear)); test::drive(driven, line, 2.0); - CHECK_FALSE(physics.lineContactors.closed); + CHECK_FALSE(physics.lineContactors.IsClosed()); CHECK(std::abs(physics.Im) < 0.5); while (physics.DecMainCtrl(1)) { // down to zero @@ -245,13 +245,13 @@ TEST_CASE("line contactors interlock: held by the local converter switch only wh // what the AI driver looks at to switch the converter of a section back on (TController, the converteron hint) auto interlocked{ready("Converter")}; CHECK_FALSE(interlocked->LineContactorsHeldByLocalConverterSwitch()); - interlocked->converter.allowLocal = false; + interlocked->converter.SetLocalSwitch(false); CHECK(interlocked->LineContactorsHeldByLocalConverterSwitch()); for (auto const *other : {"", "MotorBlowers"}) { CAPTURE(other); auto locomotive{ready(other)}; - locomotive->converter.allowLocal = false; + locomotive->converter.SetLocalSwitch(false); CHECK_FALSE(locomotive->LineContactorsHeldByLocalConverterSwitch()); } } @@ -264,13 +264,13 @@ TEST_CASE("line contactors interlock: the ET42 section with its fans switched of REQUIRE(test::start_up(driven, line)); auto &front{et42[0].physics()}; auto &rear{et42[1].physics()}; - REQUIRE(front.converter.running); - REQUIRE(rear.converter.running); + REQUIRE(front.converter.IsRunning()); + REQUIRE(rear.converter.IsRunning()); // the fans of the rear section switched off with its own switch, the 110 V of the front one still reaches it - rear.converter.allowLocal = false; + rear.converter.SetLocalSwitch(false); test::drive(driven, line, 2.0); - REQUIRE_FALSE(rear.converter.running); + REQUIRE_FALSE(rear.converter.IsRunning()); CHECK(rear.lowVoltage.power110vAvailable); test::release_brakes(driven.cab); @@ -280,23 +280,23 @@ TEST_CASE("line contactors interlock: the ET42 section with its fans switched of test::drive(driven, line, 20.0); driven.controlling.IncMainCtrl(1); // as the AI does, it waits at the first position for the contactors (their delay, the pressure switch) - for (int i = 0; i < 90 && false == front.lineContactors.closed; ++i) { + for (int i = 0; i < 90 && false == front.lineContactors.IsClosed(); ++i) { test::drive(driven, line, 1.0); } - CHECK(front.lineContactors.closed); - CHECK_FALSE(rear.lineContactors.closed); + CHECK(front.lineContactors.IsClosed()); + CHECK_FALSE(rear.lineContactors.IsClosed()); // the fans back on, the section starts too - rear.converter.allowLocal = true; + rear.converter.SetLocalSwitch(true); test::drive(driven, line, 10.0); - REQUIRE(rear.converter.running); - CHECK(rear.lineContactors.closed); + REQUIRE(rear.converter.IsRunning()); + CHECK(rear.lineContactors.IsClosed()); // and the fans switched off on the way open its line contactors again - rear.converter.allowLocal = false; + rear.converter.SetLocalSwitch(false); test::drive(driven, line, 2.0); - CHECK_FALSE(rear.lineContactors.closed); - CHECK(front.lineContactors.closed); + CHECK_FALSE(rear.lineContactors.IsClosed()); + CHECK(front.lineContactors.IsClosed()); } TEST_CASE("louvres: closed until the main reservoir reaches the pressure that opens them") { diff --git a/tests/unit/test_linebreaker.cpp b/tests/unit/test_linebreaker.cpp index d0a678c7d..55f637bf9 100644 --- a/tests/unit/test_linebreaker.cpp +++ b/tests/unit/test_linebreaker.cpp @@ -37,10 +37,10 @@ struct lever { } // TTrain::Update() void update() { - if (breaker == state::open && physics.lineBreaker.closed) { + if (breaker == state::open && physics.lineBreaker.IsClosed()) { breaker = state::closed; } - if (breaker == state::closed && false == physics.lineBreaker.closed) { + if (breaker == state::closed && false == physics.lineBreaker.IsClosed()) { breaker = state::open; } if (on && breaker == state::open && physics.MainSwitchCheck()) { @@ -71,16 +71,16 @@ TEST_CASE("line breaker: the EP05's lever goes off with the converter overload r test::track const line{0.15, 0.0, test::catenary_3kv}; auto const driver{test::driving(train)}; REQUIRE(test::start_up(driver, line)); - REQUIRE(ep05.lineBreaker.closed); - REQUIRE(ep05.converter.running); + REQUIRE(ep05.lineBreaker.IsClosed()); + REQUIRE(ep05.converter.IsRunning()); lever ws{ep05, state::closed, true}; // the converter overload relay knocks the line breaker out, as the cab does it when the converter is // switched on together with the compressor; the lever stays on - ep05.converter.overloaded = true; + ep05.converter.Overload(); ep05.MainSwitch(false, range_t::local); ws.update(); - REQUIRE_FALSE(ep05.lineBreaker.closed); + REQUIRE_FALSE(ep05.lineBreaker.IsClosed()); REQUIRE(ws.breaker == state::open); CHECK(ws.on); // with the relay tripped the breaker doesn't close @@ -93,7 +93,7 @@ TEST_CASE("line breaker: the EP05's lever goes off with the converter overload r ws.press(); CHECK(ws.on); ws.update(); - CHECK_FALSE(ep05.lineBreaker.closed); + CHECK_FALSE(ep05.lineBreaker.IsClosed()); ws.press(); CHECK_FALSE(ws.on); @@ -101,15 +101,15 @@ TEST_CASE("line breaker: the EP05's lever goes off with the converter overload r ep05.ConverterSwitch(false, range_t::local); test::drive(driver, line, 1.0); CHECK(ep05.RelayReset(relay_t::primaryconverteroverload, range_t::local)); - CHECK_FALSE(ep05.converter.overloaded); + CHECK_FALSE(ep05.converter.IsOverloaded()); ws.update(); - CHECK_FALSE(ep05.lineBreaker.closed); // the lever is off + CHECK_FALSE(ep05.lineBreaker.IsClosed()); // the lever is off ws.press(); ws.update(); - CHECK(ep05.lineBreaker.closed); + CHECK(ep05.lineBreaker.IsClosed()); CHECK(ws.breaker == state::closed); // and the next press opens it ws.press(); CHECK_FALSE(ws.on); - CHECK_FALSE(ep05.lineBreaker.closed); + CHECK_FALSE(ep05.lineBreaker.IsClosed()); } diff --git a/tests/unit/test_mains_before_pantographs.cpp b/tests/unit/test_mains_before_pantographs.cpp index 11d8b889a..fdbd4ca91 100644 --- a/tests/unit/test_mains_before_pantographs.cpp +++ b/tests/unit/test_mains_before_pantographs.cpp @@ -69,7 +69,7 @@ void get_under_power(test::vehicle &Loco, test::driven const &Driven, int const test::release_brakes(Driven.cab); test::drive(Driven, line, 20.0); // until the pressure switch lets the line contactors close - for (int i = 0; i < 120 && Loco->protection.pressureSwitch; ++i) { + for (int i = 0; i < 120 && Loco->protection.PressureSwitchTripped(); ++i) { test::drive(Driven, line, 1.0); } for (int i = 0; i < Position; ++i) { @@ -80,7 +80,7 @@ void get_under_power(test::vehicle &Loco, test::driven const &Driven, int const REQUIRE(Loco->MainCtrlPos == Position); REQUIRE(Loco->MainCtrlActualPos == Position); REQUIRE(Loco->RList[Position].R > 0.0); // a resistance position - REQUIRE(Loco->lineContactors.closed); + REQUIRE(Loco->lineContactors.IsClosed()); REQUIRE(std::abs(Loco->Im) > 10.0); } @@ -88,29 +88,29 @@ void get_under_power(test::vehicle &Loco, test::driven const &Driven, int const TEST_CASE("mains before pantographs: without the flag the line breaker needs the pantographs' voltage, as before") { test::vehicle loco{ep05(false), 0.0, "test", 1}; - REQUIRE_FALSE(loco->lineBreaker.pantographsRequireIt); + REQUIRE_FALSE(loco->lineBreaker.config.pantographsRequireIt); prepare(loco); close_line_breaker(loco); - CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); raise_pantograph(loco); CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); close_line_breaker(loco); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); // the pantographs stay up with the line breaker open, and the line breaker opens without voltage loco->MainSwitch(false); loco.run(2.0, line); CHECK(loco->pantographs[VehicleEnd::rear].is_active); close_line_breaker(loco); - REQUIRE(loco->lineBreaker.closed); + REQUIRE(loco->lineBreaker.IsClosed()); loco->OperatePantographValve(VehicleEnd::rear, operation_t::disable); loco.run(2.0, line); - CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); } TEST_CASE("mains before pantographs: with the flag the pantographs rise only through the closed line breaker") { test::vehicle loco{ep05(true), 0.0, "test", 1}; - REQUIRE(loco->lineBreaker.pantographsRequireIt); + REQUIRE(loco->lineBreaker.config.pantographsRequireIt); prepare(loco); // the pantographs stay down while the line breaker is open raise_pantograph(loco); @@ -118,15 +118,15 @@ TEST_CASE("mains before pantographs: with the flag the pantographs rise only thr CHECK(loco->pantographCircuit.supplyVoltage == 0.0); // the line breaker closes without voltage, and the pantograph rises through it close_line_breaker(loco); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); raise_pantograph(loco); CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); // opening the line breaker drops the pantograph, which stays down until the line breaker closes again loco->MainSwitch(false); loco.run(2.0, line); - CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == 0.0); // a pantograph lowered under the closed line breaker leaves it closed @@ -136,7 +136,7 @@ TEST_CASE("mains before pantographs: with the flag the pantographs rise only thr loco->OperatePantographValve(VehicleEnd::rear, operation_t::disable); loco.run(5.0, line); CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); } TEST_CASE("mains before pantographs: with the flag the line breaker still needs the battery") { @@ -144,7 +144,7 @@ TEST_CASE("mains before pantographs: with the flag the line breaker still needs loco.hold_main_reservoir(6.0); loco.run(2.0, line); close_line_breaker(loco); - CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); } TEST_CASE("mains before pantographs: with the flag the driver's start-up gets the locomotive ready") { @@ -152,7 +152,7 @@ TEST_CASE("mains before pantographs: with the flag the driver's start-up gets th test::vehicle loco{ep05(true), 0.0, "test", 1}; auto driven{test::driving(loco)}; REQUIRE(test::start_up(driven, line)); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); CHECK(test::is_ready(driven)); } @@ -164,17 +164,17 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres test::vehicle loco{ep05(true), 0.0, "test", 1}; prepare(loco); close_line_breaker(loco); - REQUIRE(loco->lineBreaker.closed); + REQUIRE(loco->lineBreaker.IsClosed()); REQUIRE(loco->pantographCircuit.supplyVoltage == 0.0); switch_auxiliaries_on(loco); - REQUIRE(loco->converter.allow); + REQUIRE(loco->converter.IsAllowed()); REQUIRE(loco->air.compressor.allow); // the line breaker closed on the battery, the pantographs down: there's nothing to run them on CHECK(reservoir_gain(loco, 20.0, line) < 0.01); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->MainCircuitPowered()); - CHECK_FALSE(loco->converter.running); + CHECK_FALSE(loco->converter.IsRunning()); CHECK_FALSE(loco->lowVoltage.power110vAvailable); CHECK_FALSE(loco->air.compressor.running); @@ -183,7 +183,7 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); CHECK(reservoir_gain(loco, 10.0, line) > 0.1); CHECK(loco->MainCircuitPowered()); - CHECK(loco->converter.running); + CHECK(loco->converter.IsRunning()); CHECK(loco->lowVoltage.power110vAvailable); CHECK(loco->air.compressor.running); @@ -205,9 +205,9 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(weak.voltage)); } CHECK(reservoir_gain(loco, 10.0, *track) < 0.01); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->MainCircuitPowered()); - CHECK_FALSE(loco->converter.running); + CHECK_FALSE(loco->converter.IsRunning()); CHECK_FALSE(loco->lowVoltage.power110vAvailable); CHECK_FALSE(loco->air.compressor.running); } @@ -220,7 +220,7 @@ TEST_CASE("mains before pantographs: with the flag whatever else the main circui REQUIRE(loco->HeatingPowerSource.SourceType == TPowerSource::Main); prepare(loco); close_line_breaker(loco); - REQUIRE(loco->lineBreaker.closed); + REQUIRE(loco->lineBreaker.IsClosed()); loco->CompressorSwitch(true); loco->MotorBlowersSwitch(true, VehicleEnd::front); loco->RVentForceOn = true; @@ -237,7 +237,7 @@ TEST_CASE("mains before pantographs: with the flag whatever else the main circui raise_pantograph(loco, weak); REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(weak.voltage)); CHECK(reservoir_gain(loco, 10.0, weak) < 0.01); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->air.compressor.running); CHECK_FALSE(loco->MotorBlowers[VehicleEnd::front].is_active); CHECK(loco->RventRot == 0.0); @@ -259,18 +259,18 @@ TEST_CASE("mains before pantographs: without the flag the converter and the comp prepare(loco); raise_pantograph(loco); close_line_breaker(loco); - REQUIRE(loco->lineBreaker.closed); + REQUIRE(loco->lineBreaker.IsClosed()); switch_auxiliaries_on(loco); CHECK(reservoir_gain(loco, 10.0, line) > 0.1); CHECK(loco->MainCircuitPowered()); - CHECK(loco->converter.running); + CHECK(loco->converter.IsRunning()); CHECK(loco->lowVoltage.power110vAvailable); CHECK(loco->air.compressor.running); // too low a voltage opens the line breaker, and they stop with it loco.run(5.0, weak); - CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->MainCircuitPowered()); - CHECK_FALSE(loco->converter.running); + CHECK_FALSE(loco->converter.IsRunning()); CHECK_FALSE(loco->lowVoltage.power110vAvailable); CHECK_FALSE(loco->air.compressor.running); } @@ -287,10 +287,10 @@ TEST_CASE("mains before pantographs: with the flag the line contactors open when // the voltage goes: the line breaker holds, the pantograph stays up, the motors are cut off test::drive(driven, dead, 3.0); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); - CHECK_FALSE(loco->protection.noVoltage); - CHECK_FALSE(loco->lineContactors.closed); + CHECK_FALSE(loco->protection.UndervoltageHolds()); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); // the voltage back, with the master controller still where it was: the camshaft went down to zero and stays @@ -298,10 +298,10 @@ TEST_CASE("mains before pantographs: with the flag the line contactors open when test::drive(driven, line, 10.0); REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); REQUIRE(loco->MainCtrlPos == 5); - CHECK(loco->lineBreaker.closed); - CHECK(loco->converter.running); - CHECK_FALSE(loco->protection.noVoltage); - CHECK_FALSE(loco->lineContactors.closed); + CHECK(loco->lineBreaker.IsClosed()); + CHECK(loco->converter.IsRunning()); + CHECK_FALSE(loco->protection.UndervoltageHolds()); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->MainCtrlActualPos == 0); CHECK(loco->Im == 0.0); @@ -311,13 +311,13 @@ TEST_CASE("mains before pantographs: with the flag the line contactors open when } REQUIRE(loco->MainCtrlPos == 0); test::drive(driven, line, 1.0); - CHECK(loco->protection.noVoltage); - CHECK_FALSE(loco->lineContactors.closed); + CHECK(loco->protection.UndervoltageHolds()); + CHECK_FALSE(loco->lineContactors.IsClosed()); for (int i = 0; i < 3; ++i) { loco->IncMainCtrl(1); test::drive(driven, line, 2.0); } - CHECK(loco->lineContactors.closed); + CHECK(loco->lineContactors.IsClosed()); CHECK(loco->MainCtrlActualPos == 3); CHECK(std::abs(loco->Im) > 10.0); } @@ -327,8 +327,8 @@ TEST_CASE("mains before pantographs: with the flag the line contactors open when } REQUIRE(loco->MainCtrlPos == 1); test::drive(driven, line, 2.0); - CHECK(loco->protection.noVoltage); - CHECK(loco->lineContactors.closed); + CHECK(loco->protection.UndervoltageHolds()); + CHECK(loco->lineContactors.IsClosed()); CHECK(loco->MainCtrlActualPos == 1); } } @@ -339,13 +339,13 @@ TEST_CASE("mains before pantographs: without the flag the line breaker opens whe get_under_power(loco, driven, 5); test::drive(driven, dead, 3.0); - CHECK_FALSE(loco->lineBreaker.closed); - CHECK_FALSE(loco->lineContactors.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); // and stays open with the voltage back test::drive(driven, line, 10.0); - CHECK_FALSE(loco->lineBreaker.closed); - CHECK_FALSE(loco->lineContactors.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->MainCtrlActualPos == 0); CHECK(loco->Im == 0.0); } diff --git a/tests/unit/test_oil_pump.cpp b/tests/unit/test_oil_pump.cpp index 7d7acb902..94e590208 100644 --- a/tests/unit/test_oil_pump.cpp +++ b/tests/unit/test_oil_pump.cpp @@ -21,7 +21,7 @@ TEST_CASE("oil pump: the pre-lubrication pump works before the engine start and loco->OilPumpCheck(0.01); CHECK(loco->OilPump.is_active); - loco->lineBreaker.closed = true; // engine started + loco->lineBreaker.Close(); // engine started loco->OilPumpCheck(0.01); CHECK_FALSE(loco->OilPump.is_active); } @@ -39,7 +39,7 @@ TEST_CASE("oil pump: the pump started with the engine start procedure stops once loco->OilPumpCheck(0.01); CHECK(loco->OilPump.is_active); - loco->lineBreaker.closed = true; + loco->lineBreaker.Close(); loco->OilPumpCheck(0.01); CHECK_FALSE(loco->OilPump.is_active); } diff --git a/tests/unit/test_pressure_switch.cpp b/tests/unit/test_pressure_switch.cpp index 8645b5165..2c30692d6 100644 --- a/tests/unit/test_pressure_switch.cpp +++ b/tests/unit/test_pressure_switch.cpp @@ -45,11 +45,11 @@ void get_ready(test::vehicle &Loco, test::driven const &Driven) { REQUIRE(test::start_up(Driven, line)); test::release_brakes(Driven.cab); test::drive(Driven, line, 20.0); - for (int i = 0; i < 120 && Loco->protection.pressureSwitch; ++i) { + for (int i = 0; i < 120 && Loco->protection.PressureSwitchTripped(); ++i) { test::drive(Driven, line, 1.0); } - REQUIRE_FALSE(Loco->protection.pressureSwitch); - REQUIRE(Loco->lineBreaker.closed); + REQUIRE_FALSE(Loco->protection.PressureSwitchTripped()); + REQUIRE(Loco->lineBreaker.IsClosed()); REQUIRE(Loco->pantographs[VehicleEnd::rear].is_active); } @@ -65,7 +65,7 @@ void notch_up(test::vehicle &Loco, test::driven const &Driven, int const Positio void get_under_power(test::vehicle &Loco, test::driven const &Driven, int const Position) { get_ready(Loco, Driven); notch_up(Loco, Driven, Position); - REQUIRE(Loco->lineContactors.closed); + REQUIRE(Loco->lineContactors.IsClosed()); REQUIRE(std::abs(Loco->Im) > 10.0); } @@ -87,14 +87,14 @@ void emergency_application(test::vehicle &Loco, test::driven const &Driven) { TEST_CASE("pressure switch: the keys are off by default") { test::vehicle loco{ep05({}), 0.0, "test", 1}; - CHECK(loco->protection.hasPressureSwitch); - CHECK(loco->protection.pressureSwitchWatchesCylinders); - CHECK(loco->lineBreaker.emergencyOffPressure == 0.0); + CHECK(loco->protection.config.hasPressureSwitch); + CHECK(loco->protection.config.pressureSwitchWatchesCylinders); + CHECK(loco->lineBreaker.config.emergencyOffPressure == 0.0); test::vehicle changed{ep05({.brakecylinder = false, .mainoff = true}), 0.0, "test", 1}; - CHECK(changed->protection.hasPressureSwitch); - CHECK_FALSE(changed->protection.pressureSwitchWatchesCylinders); - CHECK(changed->lineBreaker.emergencyOffPressure == doctest::Approx(emergency_pressure)); + CHECK(changed->protection.config.hasPressureSwitch); + CHECK_FALSE(changed->protection.config.pressureSwitchWatchesCylinders); + CHECK(changed->lineBreaker.config.emergencyOffPressure == doctest::Approx(emergency_pressure)); } TEST_CASE("pressure switch: with the brake cylinders at 3.8 bar the EP05 takes no current, as before") { @@ -102,13 +102,13 @@ TEST_CASE("pressure switch: with the brake cylinders at 3.8 bar the EP05 takes n auto driven{test::driving(loco)}; get_ready(loco, driven); apply_independent_brake(loco, driven); - CHECK(loco->protection.pressureSwitch); + CHECK(loco->protection.PressureSwitchTripped()); CHECK_FALSE(loco->MainCircuitLampsEnabled()); notch_up(loco, driven, 3); - CHECK_FALSE(loco->lineContactors.closed); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); } @@ -117,13 +117,13 @@ TEST_CASE("pressure switch: without its brake cylinder half the EP05 takes curre auto driven{test::driving(loco)}; get_ready(loco, driven); apply_independent_brake(loco, driven); - CHECK_FALSE(loco->protection.pressureSwitch); + CHECK_FALSE(loco->protection.PressureSwitchTripped()); // the lamps of the main circuit tell the start can be made CHECK(loco->MainCircuitLampsEnabled()); CHECK(loco->LineContactorsLampLit()); notch_up(loco, driven, 3); - CHECK(loco->lineContactors.closed); + CHECK(loco->lineContactors.IsClosed()); CHECK(loco->MainCtrlActualPos == 3); CHECK(std::abs(loco->Im) > 100.0); CHECK(loco->brakes.cylinderPressure == doctest::Approx(3.8).epsilon(0.03)); @@ -144,11 +144,11 @@ TEST_CASE("pressure switch: without its brake cylinder half the brake pipe still SUBCASE("an emergency application") { emergency_application(loco, driven); } - CHECK(loco->protection.pressureSwitch); - CHECK_FALSE(loco->lineContactors.closed); + CHECK(loco->protection.PressureSwitchTripped()); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); // nothing else lets go without the other key - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); } @@ -166,17 +166,17 @@ TEST_CASE("pressure switch: an emergency application with the master controller test::drive(driven, line, 10.0); REQUIRE(loco->brakePipe.pressure < emergency_pressure); REQUIRE(loco->MainCtrlPos == 5); - CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->pantographs[VehicleEnd::front].is_active); CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == 0.0); - CHECK_FALSE(loco->lineContactors.closed); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); // the line breaker doesn't close again while the master controller is where it was loco->MainSwitch(true); test::drive(driven, line, 2.0); - CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); } @@ -191,7 +191,7 @@ TEST_CASE("pressure switch: an emergency application with the master controller REQUIRE(loco->MainCtrlPos == 0); emergency_application(loco, driven); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); CHECK(loco->Im == 0.0); @@ -199,7 +199,7 @@ TEST_CASE("pressure switch: an emergency application with the master controller // and the master controller moved with the pipe empty is the same as the application made with it moved loco->IncMainCtrl(1); test::drive(driven, line, 2.0); - CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); } @@ -218,10 +218,10 @@ TEST_CASE("pressure switch: a service application with the master controller on MESSAGE("the lowest brake pipe pressure of the service application: " << lowest << " bar"); REQUIRE(lowest < 3.0); CHECK(lowest > emergency_pressure); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); // the pressure switch has cut the motors off - CHECK_FALSE(loco->lineContactors.closed); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); } @@ -232,26 +232,26 @@ TEST_CASE("pressure switch: without the key an emergency application leaves the emergency_application(loco, driven); REQUIRE(loco->MainCtrlPos == 5); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); // the pressure switch cuts the motors off - CHECK(loco->protection.pressureSwitch); - CHECK_FALSE(loco->lineContactors.closed); + CHECK(loco->protection.PressureSwitchTripped()); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); } TEST_CASE("pressure switch: where the pantographs don't hang on the line breaker the emergency application opens only the line breaker") { test::vehicle loco{ep05({.brakecylinder = false, .mainoff = true, .mainsfirst = false}), 0.0, "test", 1}; - REQUIRE_FALSE(loco->lineBreaker.pantographsRequireIt); + REQUIRE_FALSE(loco->lineBreaker.config.pantographsRequireIt); auto driven{test::driving(loco)}; get_under_power(loco, driven, 5); emergency_application(loco, driven); - CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); - CHECK_FALSE(loco->lineContactors.closed); + CHECK_FALSE(loco->lineContactors.IsClosed()); CHECK(loco->Im == 0.0); } @@ -263,33 +263,33 @@ TEST_CASE("pressure switch: after the emergency application the driver's start-u auto driven{test::driving(loco)}; get_under_power(loco, driven, 5); emergency_application(loco, driven); - REQUIRE_FALSE(loco->lineBreaker.closed); + REQUIRE_FALSE(loco->lineBreaker.IsClosed()); REQUIRE_FALSE(loco->pantographs[VehicleEnd::rear].is_active); REQUIRE(loco->pantographs[VehicleEnd::rear].valve.is_enabled); // with the brake pipe still empty REQUIRE(test::start_up(driven, line, 60.0)); CHECK(loco->MainCtrlPos == 0); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); REQUIRE(loco->brakePipe.pressure < emergency_pressure); // and it stays so test::drive(driven, line, 30.0); - CHECK(loco->lineBreaker.closed); + CHECK(loco->lineBreaker.IsClosed()); CHECK(loco->pantographs[VehicleEnd::rear].is_active); // the brakes released (the AI fills an emptied pipe with the releaser held, TController::control_releaser()), // the pressure switch lets the start be made test::release_brakes(driven.cab); - for (int i = 0; i < 180 && loco->protection.pressureSwitch; ++i) { + for (int i = 0; i < 180 && loco->protection.PressureSwitchTripped(); ++i) { loco->BrakeReleaser(loco->brakePipe.pressure < 3.0 ? 1 : 0); test::drive(driven, line, 1.0); } loco->BrakeReleaser(0); - REQUIRE_FALSE(loco->protection.pressureSwitch); + REQUIRE_FALSE(loco->protection.PressureSwitchTripped()); notch_up(loco, driven, 3); - CHECK(loco->lineBreaker.closed); - CHECK(loco->lineContactors.closed); + CHECK(loco->lineBreaker.IsClosed()); + CHECK(loco->lineContactors.IsClosed()); CHECK(std::abs(loco->Im) > 10.0); } diff --git a/tests/unit/test_smoke.cpp b/tests/unit/test_smoke.cpp index 5ee3a75f3..2ff88b209 100644 --- a/tests/unit/test_smoke.cpp +++ b/tests/unit/test_smoke.cpp @@ -102,10 +102,10 @@ namespace { // the locomotive's engine started the way the AI starts it, a second at a time, until it runs (Mains) bool start_engine(test::driven const &Driven, test::track const &Track) { - for (int second = 0; second < 120 && false == Driven.controlling.lineBreaker.closed; ++second) { + for (int second = 0; second < 120 && false == Driven.controlling.lineBreaker.IsClosed(); ++second) { test::start_up(Driven, Track, 1.0); } - return Driven.controlling.lineBreaker.closed; + return Driven.controlling.lineBreaker.IsClosed(); } } // namespace @@ -126,7 +126,7 @@ TEST_CASE("smoke: a real diesel smokes only once its engine has fired, SmokeDela CHECK(smoke::vehicle_spawn_count(locomotive.physics(), true, source, update) == 0.f); // it has fired since test::drive(driven, track, 3.0); - CHECK(locomotive->lineBreaker.closed); + CHECK(locomotive->lineBreaker.IsClosed()); CHECK(locomotive->diesel.firingCountdown == 0.0); CHECK(smoke::vehicle_spawn_count(locomotive.physics(), true, source, update) >= 1.f); } diff --git a/tests/unit/test_speed_control.cpp b/tests/unit/test_speed_control.cpp index 41047924b..d8ed80dcd 100644 --- a/tests/unit/test_speed_control.cpp +++ b/tests/unit/test_speed_control.cpp @@ -57,7 +57,7 @@ void get_6dg_going(scenario &Scenario) { Scenario.wait(1.0); move_to(loco, dg_hold); Scenario.wait(5.0); - REQUIRE(loco.lineContactors.closed); + REQUIRE(loco.lineContactors.IsClosed()); } } // namespace @@ -309,7 +309,7 @@ TEST_CASE("speed control apart: the 6Dg's cruise control on its own switch, the CHECK(higher == doctest::Approx(held + 10.0).epsilon(0.1)); count_shunting(scenario, loco, 60, shunted, unshunted); CHECK(loco.Vel == doctest::Approx(higher).epsilon(0.03)); - CHECK(loco.lineContactors.closed); + CHECK(loco.lineContactors.IsClosed()); CHECK(shunted > 0); CHECK(unshunted > 0); CHECK_FALSE(loco.IncScndCtrl(1)); // still not the driver's @@ -321,13 +321,13 @@ TEST_CASE("speed control apart: the 6Dg's cruise control on its own switch, the // it brakes down with the air (BrakeIntervention), which opens the line contactors (the pressure switch), and // they close again only through the first power position of the controller, as without the cruise control CHECK(loco.Vel < 35.0); - CHECK_FALSE(loco.lineContactors.closed); + CHECK_FALSE(loco.lineContactors.IsClosed()); scenario.act("controller to the first power position and back up"); move_to(loco, dg_lower); scenario.wait(2.0); move_to(loco, dg_raise); scenario.wait(60.0); - CHECK(loco.lineContactors.closed); + CHECK(loco.lineContactors.IsClosed()); CHECK(loco.Vel == doctest::Approx(30.0).epsilon(0.05)); CHECK(loco.ScndCtrlPos == 0); // out at this speed @@ -356,7 +356,7 @@ TEST_CASE("speed control apart: the ST45's cruise control on its own switch, wit CHECK(loco.SpeedCtrlValue == doctest::Approx(60.0)); scenario.wait(90.0); CHECK(loco.Vel == doctest::Approx(60.0).epsilon(0.03)); - CHECK(loco.lineContactors.closed); + CHECK(loco.lineContactors.IsClosed()); scenario.act("step up, power down"); loco.SpeedCtrlInc(); CHECK(loco.SpeedCtrlValue == doctest::Approx(65.0)); diff --git a/tests/unit/test_traction.cpp b/tests/unit/test_traction.cpp index 4b27a94a6..ec049c382 100644 --- a/tests/unit/test_traction.cpp +++ b/tests/unit/test_traction.cpp @@ -33,7 +33,7 @@ TEST_CASE("traction: every real powered vehicle started up, driven to full power test::drive_cycle(test::driving(real), test::track{0.15, 0.0, test::catenary_3kv}, trace); // every vehicle getting its line breaker closed runs off and is braked to a stop. the SM31 and the TEM2 // barely move (COVERAGE.md); the cars of a unit taking their power from another car don't start alone - if (real->lineBreaker.closed) { + if (real->lineBreaker.IsClosed()) { auto const crawls{path == "sm31_v1/411d" || path == "tem2_v2/tem2a"}; CHECK((real->DistCounter > 0.2 /* km */) != crawls); // but the road vehicle, which a minute of full service only slows down @@ -72,11 +72,11 @@ TEST_CASE("traction: the line breaker opened by the catenary lost, and by too hi scenario.get_going(); auto &controlling{scenario.driver().controlling}; scenario.full_power(10.0); - REQUIRE(controlling.lineBreaker.closed); + REQUIRE(controlling.lineBreaker.IsClosed()); scenario.act("catenary lost"); scenario.line().voltage = 0.0; scenario.wait(5.0); - CHECK_FALSE(controlling.lineBreaker.closed); + CHECK_FALSE(controlling.lineBreaker.IsClosed()); CHECK(controlling.Im == doctest::Approx(0.0)); scenario.act("catenary back"); scenario.line().voltage = test::catenary_3kv; @@ -86,7 +86,7 @@ TEST_CASE("traction: the line breaker opened by the catenary lost, and by too hi scenario.act("overvoltage"); scenario.line().voltage = controlling.EnginePowerSource.CollectorParameters.MaxV + 300.0; scenario.wait(5.0); - CHECK(controlling.lineBreaker.closed == (controlling.EngineType == TEngineType::ElectricSeriesMotor && false == controlling.EnginePowerSource.CollectorParameters.OVP)); + CHECK(controlling.lineBreaker.IsClosed() == (controlling.EngineType == TEngineType::ElectricSeriesMotor && false == controlling.EnginePowerSource.CollectorParameters.OVP)); scenario.line().voltage = test::catenary_3kv; stop(scenario); scenario.check(); diff --git a/vehicle/ai/consist.cpp b/vehicle/ai/consist.cpp index 64e2d1a6a..2ced8b5f1 100644 --- a/vehicle/ai/consist.cpp +++ b/vehicle/ai/consist.cpp @@ -823,17 +823,17 @@ TController::determine_consist_state() { [this, &islocalconverterswitchoff]( TDynamicObject * Vehicle ) { auto const *vehicle { Vehicle->physics }; islocalconverterswitchoff |= vehicle->LineContactorsHeldByLocalConverterSwitch(); - IsAnyConverterOverloadRelayOpen |= vehicle->converter.overloaded; + IsAnyConverterOverloadRelayOpen |= vehicle->converter.IsOverloaded(); IsAnyMotorOverloadRelayOpen |= vehicle->FuseFlag; - IsAnyGroundRelayOpen |= !vehicle->protection.ground; + IsAnyGroundRelayOpen |= !vehicle->protection.GroundHolds(); IsAnyCompressorPresent |= vehicle->air.compressor.speed > 0.0; IsAnyCompressorEnabled |= vehicle->air.compressor.speed > 0.0 ? (vehicle->air.compressor.allow || vehicle->air.compressor.start == start_t::automatic) && vehicle->air.compressor.allowLocal : false; IsAnyCompressorExplicitlyEnabled |= vehicle->air.compressor.speed > 0.0 ? vehicle->air.compressor.allow && vehicle->air.compressor.allowLocal : false; - IsAnyConverterPresent |= vehicle->converter.start != start_t::disabled; - IsAnyConverterEnabled |= ( vehicle->converter.allow || vehicle->converter.start == start_t::automatic ) && vehicle->converter.allowLocal; - IsAnyConverterExplicitlyEnabled |= vehicle->converter.allow && vehicle->converter.allowLocal; + IsAnyConverterPresent |= vehicle->converter.config.start != start_t::disabled; + IsAnyConverterEnabled |= ( vehicle->converter.IsAllowed() || vehicle->converter.config.start == start_t::automatic ) && vehicle->converter.LocalSwitchOn(); + IsAnyConverterExplicitlyEnabled |= vehicle->converter.IsAllowed() && vehicle->converter.LocalSwitchOn(); if( vehicle->Power > 0.01 ) { - IsAnyLineBreakerOpen |= !vehicle->lineBreaker.closed; } } ); + IsAnyLineBreakerOpen |= !vehicle->lineBreaker.IsClosed(); } } ); // siłę generują pojazdy na pochyleniu ale działa ona całość składu, więc a=F/m fAccGravity *= iDirection >= 0 ? 1 : -1; @@ -950,7 +950,7 @@ TController::determine_consist_state() { if( has_diesel_engine() ) { Ready = vehicle->Vel > EU07_AI_MOVEMENT // already moving - || false == vehicle->lineBreaker.closed // deadweight vehicle + || false == vehicle->lineBreaker.IsClosed() // deadweight vehicle || vehicle->enrot > 0.8 * (vehicle->EngineType == TEngineType::DieselEngine ? vehicle->diesel.minRevolutions : vehicle->DElist[0].RPM / 60.0); } p = p->Next(); // pojazd podłączony z tyłu (patrząc od czoła) diff --git a/vehicle/ai/controls.cpp b/vehicle/ai/controls.cpp index 37e7d314e..58b77d265 100644 --- a/vehicle/ai/controls.cpp +++ b/vehicle/ai/controls.cpp @@ -508,7 +508,7 @@ bool TController::IncSpeed() if( mvControlling->EnginePowerSource.SourceType == TPowerSource::Accumulator ) { fVoltage = mvControlling->lowVoltage.batteryVoltage; } - if (!IsAnyMotorOverloadRelayOpen && !mvControlling->protection.pressureSwitch && (mvControlling->IsMainCtrlNoPowerPos() || mvControlling->lineContactors.closed) && (Ready || drivingFlags.press)) { + 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 @@ -536,7 +536,7 @@ bool TController::IncSpeed() 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 // (if there's only one parallel mode configuration it'll be used regardless of current speed) - auto const usefieldshunting = mvControlling->lineContactors.closed && mvControlling->RList[mvControlling->MainCtrlPos].R < 0.01 && false == mvControlling->IsScndCtrlLockedByMainCtrl() && + auto const usefieldshunting = mvControlling->lineContactors.IsClosed() && mvControlling->RList[mvControlling->MainCtrlPos].R < 0.01 && false == mvControlling->IsScndCtrlLockedByMainCtrl() && (useseriesmode ? mvControlling->RList[mvControlling->MainCtrlPos].Bn == 1 : true == sufficientacceleration && true == sufficienttractionforce && occupied->Vel <= (IsCargoTrain ? 60 : 50) + (parallelmodefieldshunting ? 5 : 0) ? mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1 : @@ -607,7 +607,7 @@ bool TController::IncSpeed() OK = sufficientpowermargin && false == mvControlling->DelayCtrlFlag ? mvControlling->IncMainCtrl(1) : true; // czekaj na 1 pozycji, zanim się nie włączą liniowe - if (true == mvControlling->lineContactors.closed) + if (true == mvControlling->lineContactors.IsClosed()) { drivingFlags.incSpeed = true; } @@ -643,7 +643,7 @@ bool TController::IncSpeed() } break; case TEngineType::DieselElectric: - if (!IsAnyMotorOverloadRelayOpen && !mvControlling->protection.pressureSwitch && (mvControlling->IsMainCtrlNoPowerPos() || mvControlling->lineContactors.closed) && (Ready || drivingFlags.press)) { + 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) //{(BrakePress<=0.01*MaxBrakePress)} @@ -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.closed) + if (mvControlling->SpeedCtrl && mvControlling->lineBreaker.IsClosed()) { // cruise control auto const couplinginprogress{true == drivingFlags.connect && true == OrderCurrentGet().HasAll(DriverOrder::connect)}; @@ -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.closed) {// 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 ? @@ -725,7 +725,7 @@ bool TController::IncSpeed() } } // TODO: move this check to a more suitable place, or scrap it - if( false == mvControlling->lineBreaker.closed ) { + if( false == mvControlling->lineBreaker.IsClosed() ) { SpeedCntrl(0.0); mvControlling->DecScndCtrl( 2 ); cue_action( driver_hint::linebreakerclose ); @@ -935,7 +935,7 @@ void TController::SpeedSet() { } if( mvControlling->MainCtrlPos > 0 - && false == mvControlling->lineContactors.closed ) { + && false == mvControlling->lineContactors.IsClosed() ) { // jak niby jedzie, ale ma rozłączone liniowe to na zero i czekać na przewalenie kułakowego mvControlling->DecMainCtrl( 2 ); } @@ -1278,7 +1278,7 @@ void TController::SetTimeControllers() } } // 5.5 universal control for diesel electric vehicles - if (mvControlling->EngineType == TEngineType::DieselElectric && mvControlling->EIMCtrlType == 3 && AccDesired >= 0.0 && mvControlling->lineContactors.closed) + if (mvControlling->EngineType == TEngineType::DieselElectric && mvControlling->EIMCtrlType == 3 && AccDesired >= 0.0 && mvControlling->lineContactors.IsClosed()) { // NOTE: partial implementation for speedinc/dec // TBD, TODO: implement fully? diff --git a/vehicle/ai/engine.cpp b/vehicle/ai/engine.cpp index 661a3d7a8..b70f23289 100644 --- a/vehicle/ai/engine.cpp +++ b/vehicle/ai/engine.cpp @@ -86,7 +86,7 @@ bool TController::PrepareEngine() } } - if( mvControlling->lineBreaker.pantographsRequireIt + if( mvControlling->lineBreaker.config.pantographsRequireIt && IsAnyLineBreakerOpen ) { // the pantographs rise only through the closed line breaker, which closes without their voltage PrepareDirection(); @@ -307,7 +307,7 @@ bool TController::ReleaseEngine() { cue_action( driver_hint::frontpantographvalveoff ); cue_action( driver_hint::rearpantographvalveoff ); - if( false == mvControlling->lineBreaker.closed ) { + if( false == mvControlling->lineBreaker.IsClosed() ) { // finish vehicle shutdown if( has_diesel_engine() ) { // heating/cooling subsystem @@ -338,7 +338,7 @@ bool TController::ReleaseEngine() { occupied->DirActive == 0 // && ( false == IsAnyCompressorEnabled ) // && ( false == IsAnyConverterEnabled ) - && false == mvControlling->lineBreaker.closed + && false == mvControlling->lineBreaker.IsClosed() && false == occupied->lowVoltage.power24vAvailable }; if (OK) { diff --git a/vehicle/ai/situation.cpp b/vehicle/ai/situation.cpp index a6c7fbd78..af896e558 100644 --- a/vehicle/ai/situation.cpp +++ b/vehicle/ai/situation.cpp @@ -403,7 +403,7 @@ TController::control_handles() { switch( mvControlling->EngineType ) { case TEngineType::ElectricSeriesMotor: { // styczniki liniowe rozłączone yBARC - if( false == mvControlling->lineContactors.closed + if( false == mvControlling->lineContactors.IsClosed() && false == mvControlling->DelayCtrlFlag && mvControlling->MainCtrlPowerPos() > 1 ) { cue_action( driver_hint::mastercontrollersetzerospeed ); @@ -427,7 +427,7 @@ TController::control_handles() { } case TEngineType::DieselElectric: { // styczniki liniowe rozłączone yBARC - if( false == mvControlling->lineContactors.closed + if( false == mvControlling->lineContactors.IsClosed() && false == mvControlling->DelayCtrlFlag && mvControlling->MainCtrlPowerPos() > 1 ) { cue_action( driver_hint::mastercontrollersetzerospeed ); diff --git a/vehicle/cab/auxiliarycommands.cpp b/vehicle/cab/auxiliarycommands.cpp index 9bd043955..b2c8b50d3 100644 --- a/vehicle/cab/auxiliarycommands.cpp +++ b/vehicle/cab/auxiliarycommands.cpp @@ -682,9 +682,9 @@ void TTrain::OnCommand_convertertoggle(TTrain *Train, command_data const &Comman if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const overloadrelayisopen{(Train->Dynamic()->Mechanik != nullptr ? Train->Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : Train->occupied->converter.overloaded)}; + auto const overloadrelayisopen{(Train->Dynamic()->Mechanik != nullptr ? Train->Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : Train->occupied->converter.IsOverloaded())}; - if (Train->occupied->converter.switchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->occupied->lowVoltage.power110vAvailable && false == overloadrelayisopen) + if (Train->occupied->converter.config.switchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->occupied->lowVoltage.power110vAvailable && false == overloadrelayisopen) { // turn on OnCommand_converterenable(Train, Command); @@ -698,7 +698,7 @@ void TTrain::OnCommand_convertertoggle(TTrain *Train, command_data const &Comman else if (Command.action == GLFW_RELEASE) { // on button release... - if (Train->occupied->converter.switchType == "impulse") + if (Train->occupied->converter.config.switchType == "impulse") { // ...return switches to start position if applicable Train->ggConverterButton.UpdateValue(0.0, Train->dsbSwitch); @@ -717,7 +717,7 @@ void TTrain::OnCommand_converterenable(TTrain *Train, command_data const &Comman // impulse type switch has no effect if there's no power // NOTE: this is most likely setup wrong, but the whole thing is smoke and mirrors anyway - if (Train->occupied->converter.switchType != "impulse" || Train->controlled->lineBreaker.closed) + if (Train->occupied->converter.config.switchType != "impulse" || Train->controlled->lineBreaker.IsClosed()) { // won't start if the line breaker button is still held Train->occupied->ConverterSwitch(true); @@ -754,7 +754,7 @@ void TTrain::OnCommand_converterdisable(TTrain *Train, command_data const &Comma void TTrain::OnCommand_convertertogglelocal(TTrain *Train, command_data const &Command) { - if (Train->occupied->converter.start == start_t::automatic) + if (Train->occupied->converter.config.start == start_t::automatic) { // let the automatic thing do its automatic thing... return; @@ -767,13 +767,13 @@ void TTrain::OnCommand_convertertogglelocal(TTrain *Train, command_data const &C 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->converter.allowLocal && Train->ggConverterLocalButton.GetValue() < 0.5) + if (false == Train->occupied->converter.LocalSwitchOn() && Train->ggConverterLocalButton.GetValue() < 0.5) { // turn on // visual feedback Train->ggConverterLocalButton.UpdateValue(1.0, Train->dsbSwitch); // effect - Train->occupied->converter.allowLocal = true; + Train->occupied->converter.SetLocalSwitch(true); /* if( true == Train->controlled->ConverterSwitch( true, range::local ) ) { // side effects @@ -791,7 +791,7 @@ void TTrain::OnCommand_convertertogglelocal(TTrain *Train, command_data const &C // visual feedback Train->ggConverterLocalButton.UpdateValue(0.0, Train->dsbSwitch); // effect - Train->occupied->converter.allowLocal = false; + Train->occupied->converter.SetLocalSwitch(false); /* if( true == Train->controlled->ConverterSwitch( false, range::local ) ) { // side effects diff --git a/vehicle/cab/powercommands.cpp b/vehicle/cab/powercommands.cpp index f9d17ecf7..a48f1dc66 100644 --- a/vehicle/cab/powercommands.cpp +++ b/vehicle/cab/powercommands.cpp @@ -403,13 +403,13 @@ void TTrain::OnCommand_motorconnectorsopen(TTrain *Train, command_data const &Co if (Command.action == GLFW_PRESS) { // button works while it's held down but we can ignore repeats - if (false == Train->controlled->lineContactors.forcedOpen) + if (false == Train->controlled->lineContactors.IsForcedOpen()) { // open the connectors // visual feedback Train->ggStLinOffButton.UpdateValue(1.0, Train->dsbSwitch); - Train->controlled->lineContactors.forcedOpen = true; + Train->controlled->lineContactors.ForceOpen(true); Train->set_paired_open_motor_connectors_button(true); } else @@ -421,13 +421,13 @@ void TTrain::OnCommand_motorconnectorsopen(TTrain *Train, command_data const &Co else if (Command.action == GLFW_RELEASE) { // button released - if (Train->controlled->lineContactors.switchType != "toggle") + if (Train->controlled->lineContactors.config.switchType != "toggle") { // default button type (impulse) ceases its work on button release // visual feedback Train->ggStLinOffButton.UpdateValue(0.0, Train->dsbSwitch); - Train->controlled->lineContactors.forcedOpen = false; + Train->controlled->lineContactors.ForceOpen(false); Train->set_paired_open_motor_connectors_button(false); } } @@ -448,19 +448,19 @@ void TTrain::OnCommand_motorconnectorsclose(TTrain *Train, command_data const &C if (Command.action == GLFW_PRESS) { - if (Train->controlled->lineContactors.switchType == "toggle") + if (Train->controlled->lineContactors.config.switchType == "toggle") { // default type of button (impulse) has only one effect on press, but the toggle type can toggle the state // visual feedback Train->ggStLinOffButton.UpdateValue(0.0, Train->dsbSwitch); } - if (false == Train->controlled->lineContactors.forcedOpen) + if (false == Train->controlled->lineContactors.IsForcedOpen()) { return; } // already closed - Train->controlled->lineContactors.forcedOpen = false; + Train->controlled->lineContactors.ForceOpen(false); Train->set_paired_open_motor_connectors_button(false); } } diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index fe23cc0fe..47cc28267 100644 --- a/vehicle/cab/setup.cpp +++ b/vehicle/cab/setup.cpp @@ -930,7 +930,7 @@ void TTrain::set_cab_controls(int const Cab) } // motor connectors - ggStLinOffButton.PutValue(controlled->lineContactors.forcedOpen ? 1.f : 0.f); + ggStLinOffButton.PutValue(controlled->lineContactors.IsForcedOpen() ? 1.f : 0.f); // radio ggRadioChannelSelector.PutValue(static_cast((Dynamic()->Mechanik ? Dynamic()->Mechanik->iRadioChannel : 1) - 1)); // pantographs @@ -989,11 +989,11 @@ void TTrain::set_cab_controls(int const Cab) 1.f); ggPantCompressorButton.PutValue(pantographUnit->pantographAir.compressorRunning ? 1.f : 0.f); // converter - if (occupied->converter.switchType != "impulse") + if (occupied->converter.config.switchType != "impulse") { - ggConverterButton.PutValue(occupied->converter.allow ? 1.f : 0.f); + ggConverterButton.PutValue(occupied->converter.IsAllowed() ? 1.f : 0.f); } - ggConverterLocalButton.PutValue(occupied->converter.allowLocal ? 1.f : 0.f); + ggConverterLocalButton.PutValue(occupied->converter.LocalSwitchOn() ? 1.f : 0.f); // compressor ggCompressorButton.PutValue(controlled->air.compressor.allow ? 1.f : 0.f); ggCompressorLocalButton.PutValue(controlled->air.compressor.allowLocal ? 1.f : 0.f); diff --git a/vehicle/cab/train.cpp b/vehicle/cab/train.cpp index 99987edb7..c9581e0d2 100644 --- a/vehicle/cab/train.cpp +++ b/vehicle/cab/train.cpp @@ -174,11 +174,11 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("master", occupied->CabMaster); // basic systems state data dict->insert("battery", occupied->lowVoltage.power24vAvailable); - dict->insert("linebreaker", controlled->lineBreaker.closed); - dict->insert("main_init", controlled->lineBreaker.initCountdown < controlled->lineBreaker.initTime && controlled->lineBreaker.initCountdown > 0.0); - dict->insert("main_ready", false == controlled->lineBreaker.closed && fHVoltage > 0.0 && controlled->lineBreaker.initCountdown <= 0.0); + dict->insert("linebreaker", controlled->lineBreaker.IsClosed()); + dict->insert("main_init", controlled->lineBreaker.RemainingInitTime() < controlled->lineBreaker.config.initTime && controlled->lineBreaker.RemainingInitTime() > 0.0); + dict->insert("main_ready", false == controlled->lineBreaker.IsClosed() && fHVoltage > 0.0 && controlled->lineBreaker.IsInitialised()); dict->insert("converter", occupied->lowVoltage.power110vAvailable); - dict->insert("converter_overload", controlled->converter.overloaded); + dict->insert("converter_overload", controlled->converter.IsOverloaded()); dict->insert("compress", controlled->air.compressor.running); dict->insert("pant_compressor", pantographUnit->pantographAir.compressorRunning); dict->insert("lights_front", occupied->iLights[VehicleEnd::front]); @@ -521,11 +521,11 @@ void TTrain::set_paired_open_motor_connectors_button(bool const State) // TODO: rework it into part of standard command propagation system if (controlled->Couplers[VehicleEnd::front].Connected != nullptr && true == controlled->Couplers[VehicleEnd::front].CouplingFlag.HasAll(Coupling::permanent)) { - controlled->Couplers[VehicleEnd::front].Connected->lineContactors.forcedOpen = State; + controlled->Couplers[VehicleEnd::front].Connected->lineContactors.ForceOpen(State); } if (controlled->Couplers[VehicleEnd::rear].Connected != nullptr && true == controlled->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::permanent)) { - controlled->Couplers[VehicleEnd::rear].Connected->lineContactors.forcedOpen = State; + controlled->Couplers[VehicleEnd::rear].Connected->lineContactors.ForceOpen(State); } } } diff --git a/vehicle/cab/update.cpp b/vehicle/cab/update.cpp index 8a56054b5..86e2281ee 100644 --- a/vehicle/cab/update.cpp +++ b/vehicle/cab/update.cpp @@ -140,12 +140,12 @@ bool TTrain::Update(double const Deltatime) void TTrain::updateLineBreakerState(double const Deltatime) { // line breaker: - if (m_linebreakerstate == linebreaker::state::open && true == controlled->lineBreaker.closed) + if (m_linebreakerstate == linebreaker::state::open && true == controlled->lineBreaker.IsClosed()) { // crude way to sync state of the linebreaker with ai-issued commands m_linebreakerstate = linebreaker::state::closed; } - if (m_linebreakerstate == linebreaker::state::closed && false == (controlled->lineBreaker.closed || controlled->diesel.startupRequested)) + if (m_linebreakerstate == linebreaker::state::closed && false == (controlled->lineBreaker.IsClosed() || controlled->diesel.startupRequested)) { // crude way to catch cases where the main was knocked out // because the state of the line breaker isn't changed to match, we need to do it here manually @@ -153,7 +153,7 @@ void TTrain::updateLineBreakerState(double const Deltatime) } if (vehicle_cab::is_hold_coil_lever(ggMainOffButton) && hold_coil_lever::cuts_off(ggMainOffButton.GetDesiredValue())) { - if (true == controlled->lineBreaker.closed) + if (true == controlled->lineBreaker.IsClosed()) { // the line breaker was closed with the hold coil lever off, by the AI or through the control cable: // put the lever back on to match, like the line breaker state above @@ -482,11 +482,11 @@ void TTrain::updateUnitStates() fEIMParams[1 + in][8] = static_cast(p->physics->Itot); // p->physics->inductionMotor.state.lineCurrent; fEIMParams[1 + in][9] = static_cast(p->physics->EngineVoltage); fEIMParams[0][6] += fEIMParams[1 + in][8]; - bMains[in] = p->physics->lineBreaker.closed; + bMains[in] = p->physics->lineBreaker.IsClosed(); fCntVol[in] = static_cast(p->physics->lowVoltage.batteryVoltage); bFuse[in] = p->physics->FuseFlag; bBatt[in] = p->physics->lowVoltage.batteryOn; - bConv[in] = p->physics->converter.running; + bConv[in] = p->physics->converter.IsRunning(); bHeat[in] = p->physics->trainHeating.on; // bComp[in][2] = (p->physics->CompressorAllow || (p->physics->CompressorStart == start_t::automatic)); // bComp[in][3] = (p->physics->CompressorFlag); @@ -505,11 +505,11 @@ void TTrain::updateUnitStates() fDieselParams[1 + in][7] = p->physics->OilPump.pressure; fDieselParams[1 + in][8] = p->physics->diesel.heat.Ts; fDieselParams[1 + in][9] = static_cast(p->physics->retarder.fill); - bMains[in] = p->physics->lineBreaker.closed; + bMains[in] = p->physics->lineBreaker.IsClosed(); fCntVol[in] = static_cast(p->physics->lowVoltage.batteryVoltage); bFuse[in] = p->physics->FuseFlag; bBatt[in] = p->physics->lowVoltage.batteryOn; - bConv[in] = p->physics->converter.running; + bConv[in] = p->physics->converter.IsRunning(); bHeat[in] = p->physics->trainHeating.on; in++; iPowerNo = in; @@ -604,7 +604,7 @@ void TTrain::updateConverterOverload(double const Deltatime) //------------------ // hunter-261211: nadmiarowy przetwornicy i ogrzewania // Ra 15-01: to musi stąd wylecieć - zależności nie mogą być w kabinie - if (controlled->converter.running == true) + if (controlled->converter.IsRunning() == true) { fConverterTimer += static_cast(Deltatime); if (controlled->air.compressor.running == true && controlled->air.compressor.supply == physics::CompressorSupply::converterManual && (controlled->EngineType == TEngineType::ElectricSeriesMotor || controlled->TrainType == train_type::emu) && @@ -613,7 +613,7 @@ void TTrain::updateConverterOverload(double const Deltatime) { // hunter-091012: poprawka (zmiana warunku z CompressorPower /rozne od 0/ na /rowne 1/) if (fConverterTimer < fConverterPrzekaznik) { - controlled->converter.overloaded = true; + controlled->converter.Overload(); if (controlled->TrainType != train_type::emu) controlled->MainSwitch(false, controlled->TrainType == train_type::emu ? range_t::unit : range_t::local); } @@ -742,7 +742,7 @@ void TTrain::updateEngineGauges() fEngine[3] = static_cast(controlled->ShowEngineRotation(3)); if (ggMainGearStatus.SubModel) { - if (controlled->lineBreaker.closed) + if (controlled->lineBreaker.IsClosed()) ggMainGearStatus.UpdateValue(static_cast(1.1 - std::abs(controlled->diesel.automaticGearShift))); else ggMainGearStatus.UpdateValue(0.0); @@ -750,7 +750,7 @@ void TTrain::updateEngineGauges() } if (ggIgnitionKey.SubModel && ggIgnitionKey.GetDesiredValue() == 0.0) { - ggIgnitionKey.UpdateValue(controlled->lineBreaker.closed || controlled->diesel.startupRequested || fMainRelayTimer > 0.f || + ggIgnitionKey.UpdateValue(controlled->lineBreaker.IsClosed() || controlled->diesel.startupRequested || fMainRelayTimer > 0.f || (ggMainButton.SubModel != nullptr && ggMainButton.GetDesiredValue() > 0.95) || (ggMainOnButton.SubModel != nullptr && ggMainOnButton.GetDesiredValue() > 0.95)); } @@ -826,20 +826,20 @@ void TTrain::updateCircuitLamps(double const Deltatime) btLampkaSHP.Turn(occupied->SecuritySystem.is_cabsignal_blinking()); btLampkaCzuwakaSHP.Turn(btLampkaSHP.GetValue() || btLampkaCzuwaka.GetValue()); - btLampkaWylSzybki.Turn(m_linebreakerstate == linebreaker::state::closing || controlled->lineBreaker.closed); - btLampkaWylSzybkiOff.Turn(m_linebreakerstate != linebreaker::state::closing && !controlled->lineBreaker.closed); - btLampkaMainBreakerReady.Turn(controlled->lineBreaker.initCountdown <= 0.0 && m_linebreakerstate != linebreaker::state::closing && !controlled->lineBreaker.closed); - btLampkaMainBreakerBlinkingIfReady.Turn(m_linebreakerstate == linebreaker::state::closing || controlled->lineBreaker.closed || controlled->lineBreaker.initCountdown < 0.0 && simulation::Time.data().wMilliseconds > 500); + btLampkaWylSzybki.Turn(m_linebreakerstate == linebreaker::state::closing || controlled->lineBreaker.IsClosed()); + btLampkaWylSzybkiOff.Turn(m_linebreakerstate != linebreaker::state::closing && !controlled->lineBreaker.IsClosed()); + btLampkaMainBreakerReady.Turn(controlled->lineBreaker.IsInitialised() && m_linebreakerstate != linebreaker::state::closing && !controlled->lineBreaker.IsClosed()); + btLampkaMainBreakerBlinkingIfReady.Turn(m_linebreakerstate == linebreaker::state::closing || controlled->lineBreaker.IsClosed() || controlled->lineBreaker.RemainingInitTime() < 0.0 && simulation::Time.data().wMilliseconds > 500); btLampkaPrzetw.Turn(occupied->lowVoltage.power110vAvailable); btLampkaPrzetwOff.Turn(!occupied->lowVoltage.power110vAvailable); - btLampkaPrzetwAOff.Turn(!controlled->converter.running); - btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : controlled->converter.overloaded); + btLampkaPrzetwAOff.Turn(!controlled->converter.IsRunning()); + btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : controlled->converter.IsOverloaded()); - btLampkaOpory.Turn(controlled->lineContactors.closed && controlled->ResistorsFlagCheck()); + btLampkaOpory.Turn(controlled->lineContactors.IsClosed() && controlled->ResistorsFlagCheck()); btLampkaBezoporowa.Turn(controlled->ResistorsFlagCheck() || controlled->MainCtrlActualPos == 0); // do EU04 btLampkaStyczn.Turn(controlled->LineContactorsLampLit()); // mozna prowadzic rozruch - btLampkaPrzekRozn.Turn(!controlled->protection.ground && controlled->MainCircuitLampsEnabled()); // relay is off and needs a reset + btLampkaPrzekRozn.Turn(!controlled->protection.GroundHolds() && controlled->MainCircuitLampsEnabled()); // relay is off and needs a reset btLampkaNadmSil.Turn(controlled->FuseFlagCheck() && controlled->MainCircuitLampsEnabled()); // relay is off and needs a reset btLampkaUkrotnienie.Turn(controlled->Couplers[controlled->CabOccupied == 1 ? VehicleEnd::rear : VehicleEnd::front].CouplingFlag.HasAll(Coupling::control)); btLampkaHamPosp.Turn(TestFlag(occupied->brakes.distributor->GetBrakeStatus(), 1)); // lampka drugiego stopnia hamowania @@ -1103,8 +1103,8 @@ void TTrain::updateSecondUnitLamps(bool const lowvoltagepower) auto const *physics{tmp->physics}; - btLampkaWylSzybkiB.Turn(physics->lineBreaker.closed); - btLampkaWylSzybkiBOff.Turn(false == physics->lineBreaker.closed + btLampkaWylSzybkiB.Turn(physics->lineBreaker.IsClosed()); + btLampkaWylSzybkiBOff.Turn(false == physics->lineBreaker.IsClosed() /*&& ( physics->MainsInitTimeCountdown <= 0.0 )*/ /*&& ( fHVoltage != 0.0 )*/); @@ -1142,13 +1142,13 @@ void TTrain::updateSecondUnitLamps(bool const lowvoltagepower) { btLampkaHamowanie2zes.Turn(false); } - btLampkaNadmPrzetwB.Turn(physics->converter.overloaded); // nadmiarowy przetwornicy? - btLampkaPrzetwB.Turn(physics->converter.running); // zalaczenie przetwornicy - btLampkaPrzetwBOff.Turn(false == physics->converter.running); - btLampkaHVoltageB.Turn(physics->protection.noVoltage && physics->protection.overvoltage); + btLampkaNadmPrzetwB.Turn(physics->converter.IsOverloaded()); // nadmiarowy przetwornicy? + btLampkaPrzetwB.Turn(physics->converter.IsRunning()); // zalaczenie przetwornicy + btLampkaPrzetwBOff.Turn(false == physics->converter.IsRunning()); + btLampkaHVoltageB.Turn(physics->protection.UndervoltageHolds() && physics->protection.OvervoltageHolds()); btLampkaMalfunctionB.Turn(physics->diesel.heat.PA); // motor fuse indicator turns on if the fuse was blown in any unit under control - if (physics->lineBreaker.closed) + if (physics->lineBreaker.IsClosed()) { btLampkaNadmSil.Turn(btLampkaNadmSil.GetValue() || physics->FuseFlagCheck()); } @@ -1374,7 +1374,7 @@ void TTrain::updateHeatingAndInstrumentLights() { //--------- // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy - if (controlled->trainHeating.on == true && controlled->converter.overloaded == false) + if (controlled->trainHeating.on == true && controlled->converter.IsOverloaded() == false) btLampkaOgrzewanieSkladu.Turn(true); else btLampkaOgrzewanieSkladu.Turn(false); @@ -1383,7 +1383,7 @@ void TTrain::updateHeatingAndInstrumentLights() // lights auto const lightpower{(InstrumentLightType == 0 ? occupied->lowVoltage.power24vAvailable || occupied->lowVoltage.power110vAvailable : - InstrumentLightType == 1 ? controlled->lineBreaker.closed : + InstrumentLightType == 1 ? controlled->lineBreaker.IsClosed() : InstrumentLightType == 2 ? occupied->lowVoltage.power110vAvailable : InstrumentLightType == 3 ? occupied->lowVoltage.power24vAvailable || occupied->lowVoltage.power110vAvailable : InstrumentLightType == 4 ? occupied->lowVoltage.power24vAvailable || occupied->lowVoltage.power110vAvailable : @@ -1478,14 +1478,14 @@ void TTrain::updateAuxiliaryButtons(bool const lowvoltagepower) //------------ // the converter switches follow the vehicle when something else flips them (the AI driver, the other cab, // the pressure switch of an EMU), not only when the cab is entered (set_cab_controls()) - if (ggConverterButton.SubModel != nullptr && occupied->converter.switchType != "impulse" && occupied->converter.start == start_t::manual) + if (ggConverterButton.SubModel != nullptr && occupied->converter.config.switchType != "impulse" && occupied->converter.config.start == start_t::manual) { - ggConverterButton.UpdateValue(occupied->converter.allow ? 1.f : 0.f, dsbSwitch); + ggConverterButton.UpdateValue(occupied->converter.IsAllowed() ? 1.f : 0.f, dsbSwitch); } ggConverterButton.Update(); if (ggConverterLocalButton.SubModel != nullptr) { - ggConverterLocalButton.UpdateValue(occupied->converter.allowLocal ? 1.f : 0.f, dsbSwitch); + ggConverterLocalButton.UpdateValue(occupied->converter.LocalSwitchOn() ? 1.f : 0.f, dsbSwitch); } ggConverterLocalButton.Update(); ggConverterOffButton.Update(); diff --git a/vehicle/dynamic/sounds.cpp b/vehicle/dynamic/sounds.cpp index b9f948111..ca0f4b863 100644 --- a/vehicle/dynamic/sounds.cpp +++ b/vehicle/dynamic/sounds.cpp @@ -115,7 +115,7 @@ void TDynamicObject::renderAuxiliarySounds() { auto frequency{ 1.0 }; // NBMX dzwiek przetwornicy - if( physics->converter.running ) { + if( physics->converter.IsRunning() ) { if( physics->EngineType == TEngineType::ElectricSeriesMotor ) { auto const voltage { std::max( physics->GetTrainsetHighVoltage(), physics->pantographCircuit.supplyVoltage ) }; if( voltage > 0.0 ) { @@ -1096,9 +1096,9 @@ TDynamicObject::powertrain_sounds::renderIgnitionSounds( physics::Vehicle const // engine sounds // ignition - if( engine_state_last != Vehicle.lineBreaker.closed ) { + if( engine_state_last != Vehicle.lineBreaker.IsClosed() ) { - if( true == Vehicle.lineBreaker.closed ) { + if( true == Vehicle.lineBreaker.IsClosed() ) { // TODO: separate engine and main circuit // engine activation engine_shutdown.stop(); @@ -1124,7 +1124,7 @@ TDynamicObject::powertrain_sounds::renderIgnitionSounds( physics::Vehicle const .gain( linebreaker_open.m_amplitudeoffset + linebreaker_open.m_amplitudefactor * 1.f ) .play(); } - engine_state_last = Vehicle.lineBreaker.closed; + engine_state_last = Vehicle.lineBreaker.IsClosed(); } } @@ -1136,7 +1136,7 @@ TDynamicObject::powertrain_sounds::renderEngineSounds( physics::Vehicle const &V double volume { 0.0 }; // main engine sound - if( true == Vehicle.lineBreaker.closed ) { + if( true == Vehicle.lineBreaker.IsClosed() ) { if( std::abs(Vehicle.enrot) > 0.01 // McZapkie-280503: zeby dla dumb dzialal silnik na jalowych obrotach @@ -1238,7 +1238,7 @@ TDynamicObject::powertrain_sounds::renderEngineSounds( physics::Vehicle const &V } } - if (Vehicle.lineBreaker.closed) { + if (Vehicle.lineBreaker.IsClosed()) { float power = std::clamp(Vehicle.inductionMotor.forceShare, 0.0, 1.0); fake_engine diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index b59ab45aa..d859d7674 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -274,7 +274,7 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) // Ra 2014-07: doraźna blokada logowania zimnych lokomotyw - zrobić to trzeba inaczej if( physics->pantographs[VehicleEnd::front].is_active || physics->pantographs[VehicleEnd::rear].is_active ) { - if( physics->lineBreaker.closed // Ra 15-01: logować tylko, jeśli WS załączony + if( physics->lineBreaker.IsClosed() // Ra 15-01: logować tylko, jeśli WS załączony && physics->GetTrainsetHighVoltage() < 0.1f // yB 16-03: i nie jest to asynchron zasilany z daleka && false == physics->GensetSelected() ) { // nor a dual-mode vehicle running on its genset // Ra 15-01: bezwzględne współrzędne pantografu nie są dostępne więc lepiej się tego nie zaloguje @@ -420,7 +420,7 @@ void TDynamicObject::sumConsistBrakeForces( InductionBrakeState &state ) Nmax / (p->physics->NAxles * p->physics->brakes.blocksPerAxle), p->physics->brakes.blending.referenceSpeed) * 1000; // sila hamowania pn - state.FmaxED += p->physics->lineBreaker.closed && p->physics->DirActive != 0 && p->physics->inductionMotor.inverterRatio == 1.0 && + state.FmaxED += p->physics->lineBreaker.IsClosed() && p->physics->DirActive != 0 && p->physics->inductionMotor.inverterRatio == 1.0 && p->physics->inductionMotor.braking.maxForce * p->physics->NPoweredAxles > 0 ? p->physics->inductionMotor.braking.maxForce * 1000 : 0; // chwilowy max ED -> do rozdzialu sil @@ -734,7 +734,7 @@ void TDynamicObject::recordMedState( InductionBrakeState const &state, double co void TDynamicObject::switchOffMainsWithoutBattery() { // fragment "z EXE Kursa" - if( physics->lineBreaker.closed ) { // nie wchodzić w funkcję bez potrzeby + if( physics->lineBreaker.IsClosed() ) { // nie wchodzić w funkcję bez potrzeby if( false == (physics->lowVoltage.power24vAvailable || physics->lowVoltage.power110vAvailable) /* // NOTE: disabled on account of multi-unit setups, where the unmanned unit wouldn't be affected @@ -1512,7 +1512,7 @@ void TDynamicObject::Damage(char flag) if (flag & 2) //usterka sterowania { - physics->lineContactors.closed = false; + physics->lineContactors.Open(); if (physics->InitialCtrlDelay<100000000) physics->InitialCtrlDelay += 100000001; } @@ -1524,8 +1524,8 @@ void TDynamicObject::Damage(char flag) if (flag & 4) //blokada przetwornicy { - if( physics->converter.start != start_t::disabled ) { - physics->converter.overloaded = true; + if( physics->converter.config.start != start_t::disabled ) { + physics->converter.Overload(); } } else diff --git a/vehicle/enginestart.cpp b/vehicle/enginestart.cpp index ebac38066..99757effa 100644 --- a/vehicle/enginestart.cpp +++ b/vehicle/enginestart.cpp @@ -103,7 +103,7 @@ bool remote_switch::open(physics::Vehicle &Engine) { } bool remote_switch::is_running(physics::Vehicle const &Engine) { - return Engine.lineBreaker.closed || Engine.diesel.startupRequested; + return Engine.lineBreaker.IsClosed() || Engine.diesel.startupRequested; } } // namespace engine_start diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index 6bb8274b9..ecada0130 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -70,9 +70,9 @@ void ui::vehicleparams_panel::draw_mini(const physics::Vehicle &physics) if (physics.lowVoltage.batteryOn) draw_infobutton(STR_C("bat."), ImVec2(120, 55)); - if (physics.lineBreaker.closed) + if (physics.lineBreaker.IsClosed()) draw_infobutton(STR_C("main.")); - if (physics.converter.running) + if (physics.converter.IsRunning()) draw_infobutton(STR_C("conv.")); if (physics.air.compressor.running) draw_infobutton(STR_C("comp.")); @@ -148,12 +148,12 @@ void ui::vehicleparams_panel::render_contents() std::snprintf(buffer.data(), buffer.size(), STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s%s%s%.0f@%.0f"), // devices - (physics.lowVoltage.batteryOn ? 'B' : '.'), (physics.lineBreaker.closed ? 'M' : '.'), (physics.FuseFlag ? '!' : '.'), (physics.pantographs[VehicleEnd::rear].is_active ? (physics.pantographCircuit.rearVoltage > 0.0 ? 'O' : 'o') : '.'), + (physics.lowVoltage.batteryOn ? 'B' : '.'), (physics.lineBreaker.IsClosed() ? 'M' : '.'), (physics.FuseFlag ? '!' : '.'), (physics.pantographs[VehicleEnd::rear].is_active ? (physics.pantographCircuit.rearVoltage > 0.0 ? 'O' : 'o') : '.'), (physics.pantographs[VehicleEnd::front].is_active ? (physics.pantographCircuit.frontVoltage > 0.0 ? 'P' : 'p') : '.'), (physics.pantographAir.pressureLockActive ? '!' : (physics.pantographAir.pressureSwitchActive ? '*' : '.')), (physics.WaterPump.is_active ? 'W' : (false == physics.WaterPump.breaker ? '-' : (physics.WaterPump.is_enabled ? 'w' : '.'))), (true == physics.WaterHeater.is_damaged ? '!' : (physics.WaterHeater.is_active ? 'H' : (false == physics.WaterHeater.breaker ? '-' : (physics.WaterHeater.is_enabled ? 'h' : '.')))), (physics.FuelPump.is_active ? 'F' : (physics.FuelPump.is_enabled ? 'f' : '.')), (physics.OilPump.is_active ? 'O' : (physics.OilPump.is_enabled ? 'o' : '.')), - (false == physics.converter.allowLocal ? '-' : (physics.converter.allow ? (physics.converter.running ? 'X' : 'x') : '.')), (physics.converter.overloaded ? '!' : '.'), + (false == physics.converter.LocalSwitchOn() ? '-' : (physics.converter.IsAllowed() ? (physics.converter.IsRunning() ? 'X' : 'x') : '.')), (physics.converter.IsOverloaded() ? '!' : '.'), (physics.air.compressor.running ? 'C' : (false == physics.air.compressor.allowLocal ? '-' : ((physics.air.compressor.allow || physics.air.compressor.start == start_t::automatic) ? 'c' : '.'))), (physics.air.compressor.governorLock ? '!' : '.'), "", std::string(isdieselenginepowered ? STR(" oil pressure: ") + to_string(physics.OilPump.pressure, 2) : "").c_str(), // power transfers