diff --git a/application/driverhints.cpp b/application/driverhints.cpp index ecd311e9e..661f4d33d 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->Mains; } ); + return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true || occupied->lineBreaker.closed; } ); 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->ConverterAllowLocal = true; } } ); + vehicle->converter.allowLocal = 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->ConverterOverloadRelayStart != start_t::manual || occupied->ConvOvldFlag == false; } ); + return occupied->converter.overloadRelayStart != start_t::manual || occupied->converter.overloaded == 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->GroundRelayStart != start_t::manual || occupied->GroundRelay == true; } ); + return occupied->protection.groundStart != start_t::manual || occupied->protection.ground == 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->Mains == false; } ); + return mvControlling->lineBreaker.closed == false; } ); break; } // compressor diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 21cfa1030..8ec1a9997 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.Mains ? 'M' : '.', + physics.lineBreaker.closed ? 'M' : '.', physics.FuseFlag ? '!' : '.', - physics.ConverterFlag ? 'X' : - false == physics.ConverterAllowLocal ? '-' : - physics.ConverterAllow ? 'x' : + physics.converter.running ? 'X' : + false == physics.converter.allowLocal ? '-' : + physics.converter.allow ? 'x' : '.', - physics.ConvOvldFlag ? '!' : '.', + physics.converter.overloaded ? '!' : '.', 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.StLinSwitchOff ? '-' : - physics.ControlPressureSwitch ? '!' : - physics.StLinFlag ? '+' : + physics.lineContactors.forcedOpen ? '-' : + physics.protection.pressureSwitch ? '!' : + physics.lineContactors.closed ? '+' : '.', physics.Heating ? 'H' : physics.HeatingAllow ? 'h' : diff --git a/input/messaging.cpp b/input/messaging.cpp index c7950c737..283bd15e8 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->ConverterFlag * 2 + + Vehicle->physics->converter.running * 2 + Vehicle->physics->air.compressor.running * 4 - + Vehicle->physics->Mains * 8 + + Vehicle->physics->lineBreaker.closed * 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 51b577a2b..42c0885da 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 (LastRelayTime >= InitialCtrlDelay && MainCtrlPos == 1) - LastRelayTime = 0; + if (lineContactors.lastSwitchTime >= InitialCtrlDelay && MainCtrlPos == 1) + lineContactors.lastSwitchTime = 0; } - else if (LastRelayTime > CtrlDelay) - LastRelayTime = 0; + else if (lineContactors.lastSwitchTime > CtrlDelay) + lineContactors.lastSwitchTime = 0; } 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 (LastRelayTime > CtrlDelay) - LastRelayTime = 0; + if (lineContactors.lastSwitchTime > CtrlDelay) + lineContactors.lastSwitchTime = 0; } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } @@ -364,9 +364,9 @@ bool physics::Vehicle::RunAuxiliariesCommand(VehicleCommand const Command, doubl } else if (Command == VehicleCommand::converterSwitch) /*NBMX*/ { - if (ConverterStart == start_t::manual) + if (converter.start == start_t::manual) { - ConverterAllow = CValue1 > 0.0; + converter.allow = CValue1 > 0.0; } OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); } diff --git a/physics/components/controllers.cpp b/physics/components/controllers.cpp index d68f39594..ea780ab4e 100644 --- a/physics/components/controllers.cpp +++ b/physics/components/controllers.cpp @@ -97,11 +97,11 @@ bool physics::Vehicle::IncMainCtrl(int CtrlSpeed) { if (DelayCtrlFlag) { - if (LastRelayTime >= InitialCtrlDelay && MainCtrlPos == 1) - LastRelayTime = 0; + if (lineContactors.lastSwitchTime >= InitialCtrlDelay && MainCtrlPos == 1) + lineContactors.lastSwitchTime = 0; } - else if (LastRelayTime > CtrlDelay) - LastRelayTime = 0; + else if (lineContactors.lastSwitchTime > CtrlDelay) + lineContactors.lastSwitchTime = 0; } return OK; } @@ -226,11 +226,11 @@ bool physics::Vehicle::DecMainCtrl(int CtrlSpeed) { if (DelayCtrlFlag) { - if (LastRelayTime >= InitialCtrlDelay) - LastRelayTime = 0; + if (lineContactors.lastSwitchTime >= InitialCtrlDelay) + lineContactors.lastSwitchTime = 0; } - else if (LastRelayTime > CtrlDownDelay) - LastRelayTime = 0; + else if (lineContactors.lastSwitchTime > CtrlDownDelay) + lineContactors.lastSwitchTime = 0; } 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 == Mains)) + (IsMainCtrlNoPowerPos() || fieldshunting::diesel_electric(AutoRelayType, FieldShuntSwitch, AutoRelayFlag) != fieldshunting::control::manual || ShuntMode || false == lineBreaker.closed)) { OK = false; } @@ -392,8 +392,8 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed) OK = false; // if OK then LastRelayTime:=0; // hunter-101012: poprawka - if (OK && LastRelayTime > CtrlDelay) - LastRelayTime = 0; + if (OK && lineContactors.lastSwitchTime > CtrlDelay) + lineContactors.lastSwitchTime = 0; 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 && LastRelayTime > CtrlDownDelay) - LastRelayTime = 0; + if (OK && lineContactors.lastSwitchTime > CtrlDownDelay) + lineContactors.lastSwitchTime = 0; 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())) { - StLinFlag = false; + lineContactors.closed = false; if (false == DynamicBrakeFlag) { 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 (StLinFlag) + if (lineContactors.closed) { 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) - LastRelayTime = 0; + lineContactors.lastSwitchTime = 0; return OK; } @@ -598,7 +598,7 @@ bool physics::Vehicle::AutoRelayShuntStep(bool const ARFASI2) // scnd bez samoczynnego rozruchu if (ScndCtrlActualPos < ScndCtrlPos) { - if (LastRelayTime > CtrlDelay && ARFASI2) + if (lineContactors.lastSwitchTime > CtrlDelay && ARFASI2) { ++ScndCtrlActualPos; SetFlag(SoundFlag, sound::shuntfield); @@ -607,7 +607,7 @@ bool physics::Vehicle::AutoRelayShuntStep(bool const ARFASI2) } else if (ScndCtrlActualPos > ScndCtrlPos) { - if (LastRelayTime > CtrlDownDelay && TrainType != train_type::emu) + if (lineContactors.lastSwitchTime > 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 (LastRelayTime > CtrlDownDelay) + if (lineContactors.lastSwitchTime > 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 (LastRelayTime > CtrlDelay && ARFASI) + else if (lineContactors.lastSwitchTime > CtrlDelay && ARFASI) { OK = AutoRelayMainNotchUp(); } @@ -704,7 +704,7 @@ bool physics::Vehicle::AutoRelayMainNotchUp() DelayCtrlFlag = true; // tryb przejscia OK = true; } - else if (LastRelayTime > 4 * CtrlDelay) // przejscie + else if (lineContactors.lastSwitchTime > 4 * CtrlDelay) // przejscie { DelayCtrlFlag = false; @@ -753,7 +753,7 @@ bool physics::Vehicle::AutoRelayMainDown() SetFlag(SoundFlag, sound::parallel); } } - else if (LastRelayTime > CtrlDownDelay) + else if (lineContactors.lastSwitchTime > 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 (LastRelayTime >= InitialCtrlDelay) + if (lineContactors.lastSwitchTime >= InitialCtrlDelay) { - StLinFlag = true; + lineContactors.closed = true; 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 == StLinFlag && (MainCtrlActualPos > 0 || ScndCtrlActualPos > 0)) + if (false == lineContactors.closed && (MainCtrlActualPos > 0 || ScndCtrlActualPos > 0)) { OK |= CamshaftRunDown(); } @@ -813,7 +813,7 @@ bool physics::Vehicle::CamshaftRunDown() { OK = CamshaftRunDownEMU(); } - else if (LastRelayTime > CtrlDownDelay) // wal kulakowy dwukierunkowy + else if (lineContactors.lastSwitchTime > CtrlDownDelay) // wal kulakowy dwukierunkowy { if (ScndCtrlActualPos > 0) { @@ -830,7 +830,7 @@ bool physics::Vehicle::CamshaftRunDown() else if (HasCamshaft) { // wal kulakowy dwukierunkowy - if (LastRelayTime > CtrlDownDelay) + if (lineContactors.lastSwitchTime > CtrlDownDelay) { if (MainCtrlActualPos > 0) { @@ -863,7 +863,7 @@ bool physics::Vehicle::CamshaftRunDownEMU() else { - if (LastRelayTime > CtrlDownDelay) + if (lineContactors.lastSwitchTime > 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) - ControlPressureSwitch = HasControlPressureSwitch && ((PressureSwitchBrakeCylinder && brakes.cylinderPressure > 2.0) || brakePipe.pressure < 3.6); + protection.pressureSwitch = protection.hasPressureSwitch && ((protection.pressureSwitchWatchesCylinders && brakes.cylinderPressure > 2.0) || brakePipe.pressure < 3.6); - if (true == ControlPressureSwitch) + if (true == protection.pressureSwitch) { 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{PantographsRequireMains && false == NoVoltRelay}; + auto const undervoltage{lineBreaker.pantographsRequireIt && false == protection.noVoltage}; - auto const connectorsoff{false == Mains || undervoltage || true == FuseFlag || true == StLinSwitchOff || DirActive == 0}; + auto const connectorsoff{false == lineBreaker.closed || undervoltage || true == FuseFlag || true == lineContactors.forcedOpen || DirActive == 0}; return false == connectorsoff && LineContactorsInterlockReleased(); } bool physics::Vehicle::LineContactorsInterlockReleased() const { - switch (LineContactorsInterlock) + switch (lineContactors.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 ConverterFlag; + return converter.running; 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 || LastRelayTime > InitialCtrlDelay) + else if (MainCtrlActualPos != MainCtrlPos || lineContactors.lastSwitchTime > 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) - LastRelayTime += dt; + lineContactors.lastSwitchTime += dt; else { - LastRelayTime = 0; + lineContactors.lastSwitchTime = 0; MainCtrlActualPos = MainCtrlPos; } } @@ -1136,7 +1136,7 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak UniversalControllerTrainBrake(); } - if (MainCtrlActualPos != MainCtrlPos || LastRelayTime > InitialCtrlDelay) + if (MainCtrlActualPos != MainCtrlPos || lineContactors.lastSwitchTime > 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) - LastRelayTime += dt; + lineContactors.lastSwitchTime += dt; else { - LastRelayTime = 0; + lineContactors.lastSwitchTime = 0; 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 c80ecd863..9ed1ad4ff 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 == (Power24vIsAvailable || Power110vIsAvailable) && false == FuelPump.is_disabled && (FuelPump.is_active || (FuelPump.start_type == manual ? FuelPump.is_enabled : - FuelPump.start_type == automatic ? diesel.startupRequested || Mains : - FuelPump.start_type == manualwithautofallback ? FuelPump.is_enabled || diesel.startupRequested || Mains : + FuelPump.start_type == automatic ? diesel.startupRequested || lineBreaker.closed : + FuelPump.start_type == manualwithautofallback ? FuelPump.is_enabled || diesel.startupRequested || lineBreaker.closed : 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 == (Power24vIsAvailable || Power110vIsAvailable) && false == Mains && false == OilPump.is_disabled && + OilPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && false == lineBreaker.closed && 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[ControlPressureSwitch ? MainCtrlNoPowerPos() : MainCtrlPos].RPM / 60.0; + tmp = DElist[protection.pressureSwitch ? MainCtrlNoPowerPos() : MainCtrlPos].RPM / 60.0; if (true == HeatingAllow && HeatingPower > 0 && EngineHeatingRPM > 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 == StLinFlag) + if (true == lineContactors.closed) 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 == StLinFlag || ShuntMode || fieldshuntingcontrol == fieldshunting::control::off) + false == lineContactors.closed || 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 == StLinFlag) + if (true == lineContactors.closed) { 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 == StLinFlag) + if (true == lineContactors.closed) 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 * (ConverterFlag ? 1 : 0); + EngineVoltage = tempUmax * (converter.running ? 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 (Mains && DirActive != 0 && false == FuseFlag && false == SlippingWheels && nopower) + if (lineBreaker.closed && 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 && Mains) + if (motor_param(ScndCtrlActualPos).AutoSwitch && lineBreaker.closed) { OK = dizel_GearShiftCheck(VelUp, VelDown); } - if (Mains) + if (lineBreaker.closed) { 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 = (Mains ? std::max(0.0, diesel.firingCountdown - dt) : 0.0); + diesel.firingCountdown = (lineBreaker.closed ? 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); - Mains = true; + lineBreaker.closed = true; 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 && Mains && enrot < 0.95 * (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); - if (true == Mains && false == FuelPump.is_active) + if (true == lineBreaker.closed && 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 == Mains && MainCtrlPosNo > 0 && true == FuelPump.is_active) + if (true == lineBreaker.closed && 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 == Mains) + if (true == lineBreaker.closed) { 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 && Mains && enrot > diesel.minRevolutions * 0.9) + if (IsPower && lineBreaker.closed && enrot > diesel.minRevolutions * 0.9) torqueConverter.fill += torqueConverter.fillRateIncrease * dt; // oproznianie przetwornika - if ((!IsPower && Vel < diesel.converterReleaseVelocity) || !Mains || enrot < diesel.minRevolutions * 0.8) + if ((!IsPower && Vel < diesel.converterReleaseVelocity) || !lineBreaker.closed || 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 && Mains && enrot > 0.9 * diesel.minRevolutions && IsPower) + if (Vel > torqueConverter.lockupSpeed && lineBreaker.closed && enrot > 0.9 * diesel.minRevolutions && IsPower) { torqueConverter.lockedUp = true; torqueConverter.lockupRate += torqueConverter.fillRateIncrease * dt; } // luzowanie sprzegla blokujacego - if (Vel < (IsPower ? torqueConverter.lockupSpeed : torqueConverter.unlockSpeed) || !Mains || enrot < 0.8 * diesel.minRevolutions) + if (Vel < (IsPower ? torqueConverter.lockupSpeed : torqueConverter.unlockSpeed) || !lineBreaker.closed || 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 = Mains ? std::max(0.0, -eimic_real) : 0; + double RetarderRequest = lineBreaker.closed ? 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{(Mains ? 1 : 0)}; - auto const engineoff{(Mains ? 0 : 1)}; + auto const engineon{(lineBreaker.closed ? 1 : 0)}; + auto const engineoff{(lineBreaker.closed ? 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 - (Mains ? 5 : 0); + 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_hot = diesel.heat.water.config.temp_max > 0 && diesel.heat.temperatura1 > diesel.heat.water.config.temp_max - (diesel.heat.water.is_hot ? 8 : 0); - diesel.heat.water_aux.is_cold = diesel.heat.water_aux.config.temp_min > 0 && diesel.heat.temperatura2 < diesel.heat.water_aux.config.temp_min - (Mains ? 5 : 0); + diesel.heat.water_aux.is_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_hot = diesel.heat.water_aux.config.temp_max > 0 && diesel.heat.temperatura2 > diesel.heat.water_aux.config.temp_max - (diesel.heat.water_aux.is_hot ? 8 : 0); - diesel.heat.oil.is_cold = diesel.heat.oil.config.temp_min > 0 && diesel.heat.To < diesel.heat.oil.config.temp_min - (Mains ? 5 : 0); + diesel.heat.oil.is_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_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 == Mains && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ + (true == lineBreaker.closed && BatteryVoltage > 0.75 * 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 == Mains && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ + true == diesel.heat.cooling || (true == lineBreaker.closed && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */ && diesel.heat.water.config.temp_cooling > 0 && diesel.heat.temperatura1 > diesel.heat.water.config.temp_cooling - (diesel.heat.water.is_warm ? 8 : 0)); auto const PTC1{(diesel.heat.water.is_warm /*or PTC1p*/ ? 1 : 0)}; diesel.heat.rpmwz = static_cast(PTC1 * (diesel.heat.fan_speed >= 0 ? rpm * diesel.heat.fan_speed : diesel.heat.fan_speed * -1)); diff --git a/physics/components/drive.cpp b/physics/components/drive.cpp index b58e97963..938b66069 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.Mains) + if (true == vehicle.lineBreaker.closed) { 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.PantographsRequireMains ? vehicle.Power24vIsAvailable || vehicle.Power110vIsAvailable : vehicle.EnginePowerSourceVoltage() > 0.5 * vehicle.EnginePowerSource.MaxVoltage; + return vehicle.lineBreaker.pantographsRequireIt ? vehicle.Power24vIsAvailable || vehicle.Power110vIsAvailable : 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,13 @@ 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.PantographsRequireMains || vehicle.NoVoltRelay || vehicle.MainCtrlPowerPos() <= 1}; + auto const novoltrelaypicksup{false == vehicle.lineBreaker.pantographsRequireIt || vehicle.protection.noVoltage || vehicle.MainCtrlPowerPos() <= 1}; auto const &source{vehicle.EnginePowerSource}; - vehicle.NoVoltRelay = source.SourceType != TPowerSource::CurrentCollector || (voltage >= source.CollectorParameters.MinV && novoltrelaypicksup); - vehicle.OvervoltageRelay = source.SourceType != TPowerSource::CurrentCollector || voltage <= source.CollectorParameters.MaxV || false == source.CollectorParameters.OVP; + 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; // wywalanie szybkiego z powodu niewłaściwego napięcia // (a line breaker closed ahead of the pantographs holds without voltage) - vehicle.EventFlag |= true == vehicle.Mains && ((false == vehicle.NoVoltRelay && false == vehicle.PantographsRequireMains) || false == vehicle.OvervoltageRelay) && + vehicle.EventFlag |= true == vehicle.lineBreaker.closed && ((false == vehicle.protection.noVoltage && false == vehicle.lineBreaker.pantographsRequireIt) || false == vehicle.protection.overvoltage) && 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 +281,10 @@ public: } void UpdateEngineVoltage(physics::Vehicle &vehicle, double const dt) const override { - vehicle.LastRelayTime += dt; + vehicle.lineContactors.lastSwitchTime += dt; // potem ulepszyc! pantogtrafy! // Ra 2014-03: uwzględnienie kierunku jazdy w napięciu na silnikach, a powinien być zdefiniowany nawrotnik - vehicle.EngineVoltage = vehicle.Mains ? vehicle.EnginePowerSourceVoltage() : 0.0; + vehicle.EngineVoltage = vehicle.lineBreaker.closed ? vehicle.EnginePowerSourceVoltage() : 0.0; if (vehicle.CabActive == 0) { vehicle.EngineVoltage *= vehicle.DirActive; @@ -334,7 +334,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.Mains && ((vehicle.TractionSupplyVoltage() < vehicle.TractionSupplyMinVoltage() && false == vehicle.PantographsRequireMains) || + if (vehicle.lineBreaker.closed && ((vehicle.TractionSupplyVoltage() < vehicle.TractionSupplyMinVoltage() && false == vehicle.lineBreaker.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 +457,7 @@ public: double UpdateEngineRevolutions(physics::Vehicle &vehicle, double const dt, double & /*transmission*/, double & /*moment*/) const override { double target{0.0}; - if (true == vehicle.Mains && true == vehicle.FuelPump.is_active) + if (true == vehicle.lineBreaker.closed && true == vehicle.FuelPump.is_active) { target = vehicle.DieselElectricTargetRevolutions(); } @@ -494,7 +494,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.Mains) + if (true == vehicle.lineBreaker.closed) { // TBD, TODO: currently ignores RVentType, fix this? vehicle.RventRot += std::clamp(vehicle.enrot - vehicle.RventRot, -100.0, 50.0) * dt; @@ -528,9 +528,9 @@ 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.StLinFlag |= vehicle.Mains && false == vehicle.StLinFlag && vehicle.MainCtrlPowerPos() == 1; - vehicle.StLinFlag &= vehicle.MotorConnectorsCheck(); - vehicle.StLinFlag &= vehicle.MainCtrlPowerPos() > 0; + vehicle.lineContactors.closed |= vehicle.lineBreaker.closed && false == vehicle.lineContactors.closed && vehicle.MainCtrlPowerPos() == 1; + vehicle.lineContactors.closed &= vehicle.MotorConnectorsCheck(); + vehicle.lineContactors.closed &= vehicle.MainCtrlPowerPos() > 0; } bool UpdateEngine(physics::Vehicle &vehicle, double const dt) const override { diff --git a/physics/components/electrics.cpp b/physics/components/electrics.cpp index 7e050f4f1..20e734075 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{Power110vIsAvailable || (EngineType == DieselElectric && true == Mains) || (EngineType == DieselEngine && true == Mains)}; + auto const converteractive{Power110vIsAvailable || (EngineType == DieselElectric && true == lineBreaker.closed) || (EngineType == DieselEngine && true == lineBreaker.closed)}; BatteryVoltage -= BatteryDrain(dt, converteractive); if (NominalBatteryVoltage / 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 (Mains) + if (lineBreaker.closed) 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 (Mains) + if (lineBreaker.closed) sn3 = dt * 0.001; else sn3 = 0; @@ -295,21 +295,21 @@ 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 || (PantographsRequireMains && (Power24vIsAvailable || Power110vIsAvailable))}; + auto const maincircuitpowersupply{std::abs(localvoltage) > 0.1 || GetTrainsetHighVoltage() > 0.1 || (lineBreaker.pantographsRequireIt && (Power24vIsAvailable || Power110vIsAvailable))}; if (true == maincircuitpowersupply) { // all is well - if (MainsInitTimeCountdown >= 0.0) + 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 - MainsInitTimeCountdown -= Deltatime; + lineBreaker.initCountdown -= Deltatime; } else { // optional automatic circuit start - if (MainsStart != start_t::manual && false == (Mains || diesel.startupRequested)) + if (lineBreaker.start != start_t::manual && false == (lineBreaker.closed || diesel.startupRequested)) { MainSwitch(true); } @@ -318,11 +318,11 @@ void physics::Vehicle::MainsCheck(double const Deltatime) else { // no power supply - MainsInitTimeCountdown = MainsInitTime; + lineBreaker.initCountdown = lineBreaker.initTime; } // an emergency brake application made under power opens the line breaker, where the vehicle has such an interlock - if (Mains && EmergencyBrakeHoldsMainOff()) + if (lineBreaker.closed && EmergencyBrakeHoldsMainOff()) { MainSwitch(false, TrainType == train_type::emu ? range_t::unit : range_t::local); } @@ -335,12 +335,12 @@ void physics::Vehicle::LowVoltagePowerCheck(double const /*Deltatime*/) if (EngineType == TEngineType::ElectricSeriesMotor) { - GroundRelay &= lowvoltagepower; - if (GroundRelayStart != start_t::manual) + 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 - GroundRelay |= lowvoltagepower; + protection.ground |= lowvoltagepower; } } } @@ -431,7 +431,7 @@ double physics::Vehicle::LocalPowerVoltage(Coupling const kind) case Coupling::power110v: { - if (ConverterFlag) + if (converter.running) { localvoltage = NominalBatteryVoltage; } @@ -591,27 +591,27 @@ void physics::Vehicle::PowerCouplersCurrent(Coupling const kind, bool const loca 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 (ConverterStart != start_t::disabled && ConverterOverloadRelayOffWhenMainIsOff) + if (converter.start != start_t::disabled && converter.overloadRelayOffWithLineBreaker) { - ConvOvldFlag |= !Mains && Power24vIsAvailable; + converter.overloaded |= !lineBreaker.closed && Power24vIsAvailable; } - switch (ConverterStart) + switch (converter.start) { case start_t::disabled: { - ConverterAllow = false; + converter.allow = false; // NOTE: if there's no converter in vehicle we can end the check here return; } case start_t::automatic: { - ConverterAllow = Mains; + converter.allow = lineBreaker.closed; break; } case start_t::direction: { - ConverterAllow = DirActive != 0; + converter.allow = DirActive != 0; } default: { @@ -619,31 +619,31 @@ void physics::Vehicle::ConverterCheck(double const Timestep) } } - if (ConverterAllow && ConverterAllowLocal && false == ConvOvldFlag && + 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 (ConverterStartDelayTimer <= 0.0) + if (converter.startDelayTimer <= 0.0) { - ConverterFlag = true; + converter.running = true; } else { - ConverterStartDelayTimer -= Timestep; + converter.startDelayTimer -= Timestep; } } else { - ConverterFlag = false; - ConverterStartDelayTimer = static_cast(ConverterStartDelay); + converter.running = false; + converter.startDelayTimer = static_cast(converter.startDelay); } - if (ConverterOverloadRelayStart == start_t::converter && false == (ConverterAllow && ConverterAllowLocal) && false == TestFlag(EngDmgFlag, 4)) + 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 - ConvOvldFlag = false; + converter.overloaded = false; } }; @@ -754,7 +754,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) && - (Mains || false == PantographsRequireMains) // fed through the closed line breaker, where it comes first + (lineBreaker.closed || false == lineBreaker.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 +805,7 @@ void physics::Vehicle::GensetCheck(double const Deltatime) } else { - auto const demand{GensetSelected() && Mains ? std::clamp(inductionMotor.forceShare, 0.0, 1.0) : 0.0}; + auto const demand{GensetSelected() && lineBreaker.closed ? 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 +920,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{Mains || diesel.startupRequested}; + bool const initialstate{lineBreaker.closed || diesel.startupRequested}; MainSwitch_(State); @@ -931,19 +931,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 (Mains || diesel.startupRequested) != initialstate; + return (lineBreaker.closed || diesel.startupRequested) != initialstate; } void physics::Vehicle::MainSwitch_(bool const State) { - if (Mains == State || MainCtrlPosNo == 0) + if (lineBreaker.closed == State || MainCtrlPosNo == 0) { // nothing to do return; } - bool const initialstate{Mains}; + bool const initialstate{lineBreaker.closed}; if (false == State || true == MainSwitchCheck()) { @@ -959,18 +959,18 @@ void physics::Vehicle::MainSwitch_(bool const State) else { // additional check, as vehicles without pantographs won't fail relay checks earlier - Mains = true; + lineBreaker.closed = true; } } else { - Mains = false; + lineBreaker.closed = false; // 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 (Mains != initialstate) + if (lineBreaker.closed != initialstate) { LastSwitchingTime = 0; Timer::subsystem.switching.note(Timer::switching_counter::mains, this, &TypeName, &Name); @@ -991,11 +991,11 @@ bool physics::Vehicle::MainSwitchCheck() const powerisavailable = Genset.is_active && Genset.voltage >= TractionSupplyMinVoltage(); } - return powerisavailable && (ScndCtrlPos == 0 || EngineType == ElectricInductionMotor) && MainsInitTimeCountdown <= 0.0 && - (ConvOvldFlag == false || ConverterOverloadRelayOffWhenMainIsOff) && true == GroundRelay && (true == NoVoltRelay || PantographsRequireMains) && true == OvervoltageRelay && + 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 && LastSwitchingTime > CtrlDelay && (HasCamshaft ? IsMainCtrlActualNoPowerPos() : - LineBreakerClosesOnlyAtNoPowerPos ? IsMainCtrlNoPowerPos() : + lineBreaker.closesOnlyAtNoPower ? IsMainCtrlNoPowerPos() : true) && false == DamageFlag.HasAll(VehicleDamage::derailed) && false == TestFlag(EngDmgFlag, 1) && false == EmergencyBrakeHoldsMainOff(); } @@ -1007,11 +1007,11 @@ bool physics::Vehicle::MainSwitchCheck() const bool physics::Vehicle::ConverterSwitch(bool State, range_t const Notify) { - auto const initialstate{ConverterAllow}; + auto const initialstate{converter.allow}; - if (ConverterStart == start_t::manual) + if (converter.start == start_t::manual) { - ConverterAllow = State; + converter.allow = State; } if (Notify != range_t::local) @@ -1019,7 +1019,7 @@ bool physics::Vehicle::ConverterSwitch(bool State, range_t const Notify) SendCtrlToNext(VehicleCommand::converterSwitch, State ? 1 : 0, CabActive, Notify == range_t::unit ? Coupling::control | Coupling::permanent : Coupling::control); } - return ConverterAllow != initialstate; + return converter.allow != initialstate; } bool physics::Vehicle::HeatingSwitch(bool const State, range_t const Notify) @@ -1116,11 +1116,11 @@ double physics::Vehicle::EnginePowerSourceVoltage() const // blowers, the traction motors bool physics::Vehicle::MainCircuitPowered() const { - if (false == Mains) + if (false == lineBreaker.closed) { return false; } - if (false == PantographsRequireMains || EnginePowerSource.SourceType != TPowerSource::CurrentCollector) + if (false == lineBreaker.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 35d561f23..ea183719c 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(MainsInitTime, "MainInitTime", line, ""); + extract_value(lineBreaker.initTime, "MainInitTime", line, ""); { auto lookup = starts.find(extract_value("MainStart", line)); - MainsStart = lookup != starts.end() ? lookup->second : manual; + lineBreaker.start = lookup != starts.end() ? lookup->second : manual; } - extract_value(PantographsRequireMains, "PantRequiresMain", line, ""); + extract_value(lineBreaker.pantographsRequireIt, "PantRequiresMain", line, ""); // the brake pipe pressure of an emergency brake application, which opens the line breaker under power - extract_value(EmergencyBrakeMainOffPressure, "EmergencyBrakeMainOff", line, ""); - EmergencyBrakeMainOffPressure = std::max(0.0, EmergencyBrakeMainOffPressure); + extract_value(lineBreaker.emergencyOffPressure, "EmergencyBrakeMainOff", line, ""); + lineBreaker.emergencyOffPressure = std::max(0.0, lineBreaker.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)); - ConverterStart = lookup != starts.end() ? lookup->second : manual; + this->converter.start = lookup != starts.end() ? lookup->second : manual; } - extract_value(ConverterStartDelay, "ConverterStartDelay", line, ""); - extract_value(ConverterOverloadRelayOffWhenMainIsOff, "ConverterOverloadWhenMainIsOff", line, TrainType == train_type::emu ? "yes" : "no"); + extract_value(this->converter.startDelay, "ConverterStartDelay", line, ""); + extract_value(this->converter.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)); - LineContactorsInterlock = lookup != interlocks.end() ? lookup->second : line_contactors_interlock::none; + lineContactors.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}; - GroundRelayStart = lookup != starts.end() ? lookup->second : defaultstart; + protection.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}; - ConverterOverloadRelayStart = lookup != starts.end() ? lookup->second : defaultstart; + this->converter.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(JointEngineStart, "JointEngineStart", Input, ""); + extract_value(lineBreaker.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(HasControlPressureSwitch, "PressureSwitch", Input, TrainType != train_type::emu ? "yes" : "no"); + extract_value(protection.hasPressureSwitch, "PressureSwitch", Input, TrainType != train_type::emu ? "yes" : "no"); // its brake cylinder half; the brake pipe one stays - extract_value(PressureSwitchBrakeCylinder, "PressureSwitchBrakeCylinder", Input, ""); + extract_value(protection.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(ConvSwitchType, "Converter", Input, ""); - extract_value(StLinSwitchType, "MotorConnectors", Input, ""); + extract_value(converter.switchType, "Converter", Input, ""); + extract_value(lineContactors.switchType, "MotorConnectors", Input, ""); HeatingSwitchImpulse = 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); - ConvSwitchType = ToLower(ConvSwitchType); - StLinSwitchType = ToLower(StLinSwitchType); + converter.switchType = ToLower(converter.switchType); + lineContactors.switchType = ToLower(lineContactors.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 new file mode 100644 index 000000000..3970b2835 --- /dev/null +++ b/physics/components/maincircuit.h @@ -0,0 +1,88 @@ +/* +This Source Code Form is subject to the +terms of the Mozilla Public License, v. +2.0. If a copy of the MPL was not +distributed with this file, You can +obtain one at +http://mozilla.org/MPL/2.0/. +*/ + +// the 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 + +#pragma once + +#include + +#include "physics/vehicletypes.h" + +namespace physics +{ + +// the line breaker (the main switch) of the vehicle +struct 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] + 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 +{ + 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] +}; + +// the protective relays and the pressure switch of the main circuit +struct 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 + // controller at zero or the first position + 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}; +}; + +// the converter of the vehicle +struct 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] + 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 37b421f57..c1e9fcd8a 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 == ControlPressureSwitch || false == ReleaserEnabledOnlyAtNoPowerPos || true == IsMainCtrlNoPowerPos()) + if (false == protection.pressureSwitch || false == ReleaserEnabledOnlyAtNoPowerPos || true == IsMainCtrlNoPowerPos()) { brakes.distributor->Releaser(state); } @@ -794,7 +794,7 @@ void physics::Vehicle::CompressorCheck(double dt) { case CompressorSupply::converter: { - air.compressor.allow = ConverterAllow; + air.compressor.allow = converter.allow; break; } case CompressorSupply::engine: diff --git a/physics/components/traction.cpp b/physics/components/traction.cpp index ffbb6fae5..acddd1fa8 100644 --- a/physics/components/traction.cpp +++ b/physics/components/traction.cpp @@ -97,12 +97,12 @@ double physics::Vehicle::Current(double n, double U) } } - if (DynamicBrakeFlag && !FuseFlag && DynamicBrakeType == dbrake_automatic && Power110vIsAvailable && Mains) // hamowanie EP09 //TUHEX + if (DynamicBrakeFlag && !FuseFlag && DynamicBrakeType == dbrake_automatic && Power110vIsAvailable && lineBreaker.closed) // 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 / DynamicBrakeRes; } - else if (RList[MainCtrlActualPos].Bn == 0 || false == StLinFlag) + else if (RList[MainCtrlActualPos].Bn == 0 || false == lineContactors.closed) { // 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 == Mains}; + auto const accepted{false == lineBreaker.closed}; if (Genset.fitted() && accepted) { @@ -668,7 +668,7 @@ void physics::Vehicle::VoltageRelaysCheck() void physics::Vehicle::DumbTractionForce(double const PosRatio) { - if (Mains && CabActive != 0) + if (lineBreaker.closed && CabActive != 0) { if (Vel > 0.1) { @@ -1461,12 +1461,12 @@ 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) && - (GroundRelayStart == start_t::manual || GroundRelayStart == start_t::manualwithautofallback) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 && + (protection.groundStart == start_t::manual || protection.groundStart == start_t::manualwithautofallback) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 && !TestFlag(EngDmgFlag, 1)) { // NOTE: true means the relay is operational - reset |= !GroundRelay && lowvoltagepower; - GroundRelay |= lowvoltagepower; + reset |= !protection.ground && lowvoltagepower; + protection.ground |= lowvoltagepower; } if (TestFlag(Relays, relay_t::tractionnmotoroverload) && (EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 && @@ -1479,15 +1479,15 @@ bool physics::Vehicle::RelayReset(int const Relays, range_t const Notify) FuseFlag &= !lowvoltagepower; } - if (TestFlag(Relays, relay_t::primaryconverteroverload) && ConverterOverloadRelayStart == start_t::manual + if (TestFlag(Relays, relay_t::primaryconverteroverload) && converter.overloadRelayStart == start_t::manual // && ( false == Mains ) - && false == ConverterAllow) + && false == converter.allow) { // 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 |= ConvOvldFlag && lowvoltagepower; - ConvOvldFlag &= !lowvoltagepower; + reset |= converter.overloaded && lowvoltagepower; + converter.overloaded &= !lowvoltagepower; } if (reset) diff --git a/physics/vehicle.h b/physics/vehicle.h index 183e55b9e..45436c2ac 100644 --- a/physics/vehicle.h +++ b/physics/vehicle.h @@ -28,6 +28,7 @@ http://mozilla.org/MPL/2.0/. #include "physics/components/airsupply.h" #include "physics/components/devices.h" #include "physics/components/pantographs.h" +#include "physics/components/maincircuit.h" class TractionDrive; @@ -680,6 +681,10 @@ class Vehicle int wiperSwitchPos = 0; // pozycja przelacznika wycieraczek double WiperAngle = {45.0}; // kat pracy wycieraczek + LineBreaker lineBreaker; // the main circuit (physics/components/maincircuit.h) + LineContactors lineContactors; + ProtectionRelays protection; + PowerConverter converter; ByEnd pantographs; PantographCircuit pantographCircuit; // their voltages, switches, presets (physics/components/pantographs.h) PantographAir pantographAir; // their reservoir, the small compressor, the valves @@ -952,16 +957,7 @@ class Vehicle bool SandDoseAutoAllow = true; /*zezwolenie na automatyczne piaskowanie*/ double Sand = 0.0; /*ilosc piasku*/ /*! przyrosty cisnienia w kroku czasowym*/ - // TODO converter parameters, for when we start cleaning up physics parameters - start_t ConverterStart{start_t::manual}; // whether converter is started manually, or by other means - float ConverterStartDelay{0.0f}; // delay (in seconds) before the converter is started, once its activation conditions are met - double ConverterStartDelayTimer{0.0}; // helper, for tracking whether converter start delay passed - bool ConverterAllow = false; /*zezwolenie na prace przetwornicy NBMX*/ - bool ConverterAllowLocal{true}; // local device state override (most units don't have this fitted so it's set to true not to intefere) - bool ConverterFlag = false; /*! czy wlaczona przetwornica NBMX*/ bool BRVentilators = false; /* Czy rezystor hamowania pracuje */ - start_t ConverterOverloadRelayStart{start_t::manual}; // whether overload relay reset responds to dedicated button - bool ConverterOverloadRelayOffWhenMainIsOff{false}; fuel_pump FuelPump; oil_pump OilPump; genset_device Genset; // of a dual-mode vehicle, fitted() only with GensetPower @@ -1006,30 +1002,6 @@ class Vehicle double OffsetTrackV = 0.0; /*przesuniecie poz. i pion. w/m osi toru*/ /*-zmienne dla lokomotyw*/ - bool Mains = false; /*polozenie glownego wylacznika*/ - double MainsInitTime{0.0}; // config, initialization time (in seconds) of the main circuit after it receives power, before it can be closed - double MainsInitTimeCountdown{0.0}; // current state of main circuit initialization, remaining time (in seconds) until it's ready - start_t MainsStart{start_t::manual}; - // config, Engine:JointEngineStart. whether the cab's line breaker / engine start switch works the vehicles in multiple - // too; when it doesn't, the cab has separate switches for them (mainb_*, mainc_*) - bool JointEngineStart{true}; - // config, .fiz 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 (NoVoltRelay) - bool PantographsRequireMains{false}; - bool LineBreakerClosesOnlyAtNoPowerPos{false}; - bool ControlPressureSwitch{false}; // activates if the main pipe and/or brake cylinder pressure aren't within operational levels - bool HasControlPressureSwitch{true}; - // config, .fiz Engine:PressureSwitchBrakeCylinder. whether 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 PressureSwitchBrakeCylinder{true}; - // config, .fiz 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 (PantographsRequireMains) they drop with it (EP05). - // 0: an emergency application leaves the line breaker alone - double EmergencyBrakeMainOffPressure{0.0}; bool ReleaserEnabledOnlyAtNoPowerPos{false}; int MainCtrlPos = 0; /*polozenie glownego nastawnika*/ int ScndCtrlPos = 0; /*polozenie dodatkowego nastawnika*/ @@ -1080,22 +1052,11 @@ class Vehicle int MainCtrlActualPos = 0; /*wskaznik RList*/ int ScndCtrlActualPos = 0; /*wskaznik MotorParam*/ bool DelayCtrlFlag = false; // czy czekanie na 1. pozycji na załączenie? - double LastRelayTime = 0.0; /*czas ostatniego przelaczania stycznikow*/ bool AutoRelayFlag = false; /*mozna zmieniac jesli AutoRelayType=2*/ bool FuseFlag = false; /*!o bezpiecznik nadmiarowy*/ - bool ConvOvldFlag = false; /*! nadmiarowy przetwornicy i ogrzewania*/ - bool GroundRelay{true}; // switches off to protect against damage from earths - start_t GroundRelayStart{start_t::manual}; // relay activation method - bool StLinFlag = false; /*!o styczniki liniowe*/ - bool StLinSwitchOff{false}; // state of the button forcing motor connectors open - line_contactors_interlock LineContactorsInterlock{line_contactors_interlock::none}; // what else the line contactors need to close double LouvresOpenPressure{5.0}; // main reservoir pressure [bar] at which the pneumatic louvres of the motor fans open (ET22) bool ResistorsFlag = false; /*!o jazda rezystorowa*/ double RventRot = 0.0; /*!s obroty wentylatorow rozruchowych*/ - // switches off if the power level drops below threshold, which opens the line breaker; with PantographsRequireMains - // it opens the line contactors instead, and switches back on only with the master controller at zero or the first position - bool NoVoltRelay{true}; - bool OvervoltageRelay{true}; // switches off if the power level goes above threshold bool s_CAtestebrake = false; // hunter-091012: zmienna dla testu ca std::array, 4> PowerCircuits; // 24v, 110v, 3x400v and 3000v power circuits, voltage from local sources and current draw pairs @@ -1139,10 +1100,7 @@ class Vehicle bool DoorRightOpened = false; double DoorRightOpenTimer{-1.0}; // right door closing timer for automatic door type #endif - // TODO: move these switch types where they belong, cabin definition - std::string ConvSwitchType; bool HeatingSwitchImpulse{false}; // the train heating switch springs back to its middle position - std::string StLinSwitchType; bool Heating = false; // ogrzewanie 'Winger 020304 bool HeatingAllow{false}; // heating switch // TODO: wrap heating in a basic device @@ -1587,13 +1545,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 == ControlPressureSwitch && (HasControlPressureSwitch || brakes.cylinderPressure < 1.0); + return false == protection.pressureSwitch && (protection.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 EmergencyBrakeMainOffPressure > 0.0 && brakePipe.pressure < EmergencyBrakeMainOffPressure && false == IsMainCtrlNoPowerPos(); + return lineBreaker.emergencyOffPressure > 0.0 && brakePipe.pressure < lineBreaker.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 @@ -1602,15 +1560,15 @@ class Vehicle { if (EngineType == TEngineType::DieselElectric) { - return false == StLinFlag; + return false == lineContactors.closed; } - return false == StLinFlag && MainCircuitLampsEnabled(); + return false == lineContactors.closed && 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 JointEngineStart ? range_t::consist : range_t::local; + return lineBreaker.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 @@ -1623,7 +1581,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 LineContactorsInterlock == line_contactors_interlock::converter && false == ConverterAllowLocal; + return lineContactors.interlock == line_contactors_interlock::converter && false == converter.allowLocal; } // 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 3d95510c5..fe22a6964 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.Battery || Controlling.Battery, device::battery) | on(Controlling.Mains, device::main_breaker) | + return on(Occupied.Battery || Controlling.Battery, device::battery) | on(Controlling.lineBreaker.closed, 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.ConverterFlag, device::converter) | on(Controlling.air.compressor.running, device::compressor) | on(Controlling.StLinFlag, device::line_contactors) | + on(Controlling.converter.running, device::converter) | on(Controlling.air.compressor.running, device::compressor) | on(Controlling.lineContactors.closed, 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 de9736557..74fcfb9d7 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.ConverterStart != start_t::manual || physics.ConverterFlag}; - return physics.Mains && air && converter; + auto const converter{physics.converter.start != start_t::manual || physics.converter.running}; + return physics.lineBreaker.closed && 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.PantographsRequireMains && false == controlling.Mains) { + if (controlling.lineBreaker.pantographsRequireIt && false == controlling.lineBreaker.closed) { // 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.Mains) { + if (false == controlling.lineBreaker.closed) { 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.Mains << ", main reservoir " << controlling.mainPipe.pressure); + MESSAGE("didn't get ready: Mains " << controlling.lineBreaker.closed << ", 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 d668592c0..36d6010bc 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.Mains ? 1.0 : 0.0; }}, + {"Mains", [](auto const &M) { return M.lineBreaker.closed ? 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 ed3458f88..c0141c5ca 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.Mains || false == electric(M) || std::abs(M.Im) < 1.0; }, - [](auto const &M) { return values({{"Mains", M.Mains}, {"Im", M.Im}, {"Itot", M.Itot}}); }}, + [](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}}); }}, {"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.StLinFlag || M.DynamicBrakeFlag || M.EngineType != TEngineType::ElectricSeriesMotor || std::abs(M.Im) < 1.0; + return M.lineContactors.closed || M.DynamicBrakeFlag || M.EngineType != TEngineType::ElectricSeriesMotor || std::abs(M.Im) < 1.0; }, [](auto const &M) { - return values({{"StLinFlag", M.StLinFlag}, {"DynamicBrakeFlag", M.DynamicBrakeFlag}, {"Im", M.Im}, {"MainCtrlActualPos", M.MainCtrlActualPos}}); + return values({{"StLinFlag", M.lineContactors.closed}, {"DynamicBrakeFlag", M.DynamicBrakeFlag}, {"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 b26300a35..ecda46e3e 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().ControlPressureSwitch) { + if (Train[i].physics().protection.pressureSwitch) { 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.StLinFlag; ++i) { + for (int i = 0; i < 90 && false == controlling.lineContactors.closed; ++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 e2f834ac8..ed3f3c7fa 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->Mains); // the engine running - REQUIRE(Loco->StLinFlag); // the line contactors closed + REQUIRE(Loco->lineBreaker.closed); // the engine running + REQUIRE(Loco->lineContactors.closed); // 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 66702750b..de33f2ffb 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.BatteryVoltage; }}, {"Battery", [](auto const &M) { return M.Battery ? 1.0 : 0.0; }}, - {"ConverterFlag", [](auto const &M) { return M.ConverterFlag ? 1.0 : 0.0; }}, + {"ConverterFlag", [](auto const &M) { return M.converter.running ? 1.0 : 0.0; }}, {"Power110vIsAvailable", [](auto const &M) { return M.Power110vIsAvailable ? 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.BatteryVoltage < 0.83 * eu07.NominalBatteryVoltage); - CHECK(eu07.Mains); + CHECK(eu07.lineBreaker.closed); scenario.wait(5000.0); CHECK(eu07.BatteryVoltage < eu07.NominalBatteryVoltage / 1.57); - CHECK_FALSE(eu07.Mains); + CHECK_FALSE(eu07.lineBreaker.closed); scenario.act("start up again"); CHECK_FALSE(scenario.start_up()); CHECK(eu07.BatteryVoltage < eu07.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.Mains); + CHECK_FALSE(eu07.lineBreaker.closed); 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 236c80f14..11b2784d6 100644 --- a/tests/unit/test_camshaft.cpp +++ b/tests/unit/test_camshaft.cpp @@ -70,20 +70,20 @@ definition skoda() { void running(physics::Vehicle &Locomotive, int const Direction, int const Position, int const Controller) { Locomotive.CabActive = 1; Locomotive.DirActive = Direction; - Locomotive.Mains = true; + Locomotive.lineBreaker.closed = true; Locomotive.brakePipe.pressure = 5.0; // bar, the pressure switch lets the line contactors close Locomotive.brakes.cylinderPressure = 0.0; - Locomotive.StLinFlag = true; + Locomotive.lineContactors.closed = true; Locomotive.MainCtrlActualPos = Position; Locomotive.MainCtrlPos = Controller; - Locomotive.LastRelayTime = 10.0; + Locomotive.lineContactors.lastSwitchTime = 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.LastRelayTime = 10.0; + Locomotive.lineContactors.lastSwitchTime = 10.0; Locomotive.AutoRelayCheck(); } return Locomotive.MainCtrlActualPos; @@ -108,7 +108,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.StLinFlag); // the motors don't pull any more + CHECK_FALSE(physics.lineContactors.closed); // the motors don't pull any more } } diff --git a/tests/unit/test_cntrl.cpp b/tests/unit/test_cntrl.cpp index 4df03f31d..eb99d05b0 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->GroundRelayStart == start_t::automatic); - CHECK(unit->ConverterOverloadRelayStart == start_t::converter); // activates when the converter is switched off + CHECK(unit->protection.groundStart == start_t::automatic); + CHECK(unit->converter.overloadRelayStart == start_t::converter); // activates when the converter is switched off } SUBCASE("other vehicle") { vehicle wagon{definition::load("wagon")}; - CHECK(wagon->GroundRelayStart == start_t::manual); - CHECK(wagon->ConverterOverloadRelayStart == start_t::manual); + CHECK(wagon->protection.groundStart == start_t::manual); + CHECK(wagon->converter.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->GroundRelayStart == start_t::manual); - CHECK(unit->ConverterOverloadRelayStart == start_t::automatic); + CHECK(unit->protection.groundStart == start_t::manual); + CHECK(unit->converter.overloadRelayStart == start_t::automatic); } } diff --git a/tests/unit/test_collisions.cpp b/tests/unit/test_collisions.cpp index 24dc4d545..108cf87e2 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->StLinFlag; ++i) { + for (int i = 0; i < 90 && false == locomotive->lineContactors.closed; ++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->StLinFlag; ++i) { + for (int i = 0; i < 90 && false == locomotive->lineContactors.closed; ++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 859f73336..0fc6ea4c5 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.LastRelayTime; }}, + {"LastRelayTime", [](auto const &M) { return M.lineContactors.lastSwitchTime; }}, {"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.Mains); }}, + {"MainSwitch", [](auto const &M) { return flag(M.lineBreaker.closed); }}, {"Heating", [](auto const &M) { return flag(M.Heating); }}, {"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.ConverterAllow); }}, + {"ConverterAllow", [](auto const &M) { return flag(M.converter.allow); }}, {"Battery", [](auto const &M) { return flag(M.Battery); }}, {"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.GroundRelay); }}, - {"ConverterFlag", [](auto const &M) { return flag(M.ConverterFlag); }}, + {"GroundRelay", [](auto const &M) { return flag(M.protection.ground); }}, + {"ConverterFlag", [](auto const &M) { return flag(M.converter.running); }}, {"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 033bd4775..e65935672 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->Mains = true; + vehicle->lineBreaker.closed = true; 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->Mains = true; + vehicle->lineBreaker.closed = true; 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->Mains = true; + vehicle->lineBreaker.closed = true; run_compressor(vehicle, 10.0); REQUIRE(vehicle->air.compressor.running); - vehicle->Mains = false; // the engine stopped + vehicle->lineBreaker.closed = false; // the engine stopped run_compressor(vehicle, 1.0); CHECK_FALSE(vehicle->air.compressor.running); - vehicle->Mains = true; // and started again + vehicle->lineBreaker.closed = true; // 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->Mains = true; // which alone doesn't feed it + vehicle->lineBreaker.closed = true; // 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->Mains = true; + vehicle->lineBreaker.closed = true; 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->Mains = true; + vehicle->lineBreaker.closed = true; 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->Mains = true; // engine started + vehicle->lineBreaker.closed = true; // engine started run_compressor(vehicle, 20.0); REQUIRE_FALSE(vehicle->air.compressor.running); - vehicle->Mains = false; // engine stopped, 10 s short of the delay + vehicle->lineBreaker.closed = false; // engine stopped, 10 s short of the delay run_compressor(vehicle, 1.0); - vehicle->Mains = true; + vehicle->lineBreaker.closed = true; 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->Mains = true; + vehicle->lineBreaker.closed = true; 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->ConverterStartDelay == doctest::Approx(30.0)); + REQUIRE(loco->converter.startDelay == doctest::Approx(30.0)); loco.run(1.0); // engine off CHECK_FALSE(loco->Power110vIsAvailable); - loco->Mains = true; // engine started + loco->lineBreaker.closed = true; // engine started loco.run(25.0); CHECK_FALSE(loco->Power110vIsAvailable); 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->Mains = true; // engine started + loco->lineBreaker.closed = true; // engine started loco.run(25.0); REQUIRE(loco->Power110vIsAvailable); // 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 b0d0e1659..a850194fd 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.StLinFlag; ++i) { + for (int i = 0; i < 90 && false == driver.controlling.lineContactors.closed; ++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.Mains); + REQUIRE(eu07.lineBreaker.closed); 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.Mains); + CHECK(eu07.lineBreaker.closed); CHECK(eu07.Im == doctest::Approx(0.0)); } diff --git a/tests/unit/test_derailment_vehicle.cpp b/tests/unit/test_derailment_vehicle.cpp index 606d1c83f..786d16f1b 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->Mains); + CHECK_FALSE(eu07vehicle->lineBreaker.closed); // 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 e9629c4ed..a3cab4002 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->Mains); + CHECK(shunter->lineBreaker.closed); 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->Mains); + CHECK(shunter->lineBreaker.closed); shunter->BatterySwitch(false); shunter.run(10.0); CHECK(shunter->Power110vIsAvailable); // the converter run by the engine keeps feeding the fuel pump - CHECK(shunter->Mains); + CHECK(shunter->lineBreaker.closed); 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->Mains); + CHECK_FALSE(shunter->lineBreaker.closed); 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->Mains); + CHECK(shunter->lineBreaker.closed); 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 cf9aa4e42..c45019b71 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.Mains && Vehicle.enrot > 0.5 * Vehicle.diesel.minRevolutions; + return Vehicle.lineBreaker.closed && 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.JointEngineStart); - CHECK_FALSE(separate.JointEngineStart); + CHECK(joint.lineBreaker.jointStart); + CHECK_FALSE(separate.lineBreaker.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.Mains); - REQUIRE_FALSE(second.Mains); + REQUIRE_FALSE(first.lineBreaker.closed); + REQUIRE_FALSE(second.lineBreaker.closed); 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.Mains); - CHECK_FALSE(second.Mains); + CHECK_FALSE(first.lineBreaker.closed); + CHECK_FALSE(second.lineBreaker.closed); } 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.Mains); - CHECK_FALSE(third.Mains); + CHECK_FALSE(second.lineBreaker.closed); + CHECK_FALSE(third.lineBreaker.closed); // 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.Mains); + CHECK_FALSE(third.lineBreaker.closed); // 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.Mains); + CHECK_FALSE(second.lineBreaker.closed); CHECK(running(first)); CHECK(running(third)); first.MainSwitch(false, first.MainSwitchRange()); train.run(5.0); - CHECK_FALSE(first.Mains); + CHECK_FALSE(first.lineBreaker.closed); 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.Mains); + CHECK_FALSE(second.lineBreaker.closed); 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.Mains); + CHECK_FALSE(first.lineBreaker.closed); 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.Mains); + CHECK_FALSE(second.lineBreaker.closed); 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.Mains); + REQUIRE_FALSE(first.lineBreaker.closed); // 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.Mains); + CHECK_FALSE(first.lineBreaker.closed); CHECK(first.enrot == 0.0); } diff --git a/tests/unit/test_field_shunting.cpp b/tests/unit/test_field_shunting.cpp index e61783b0e..e1c2c9b8f 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.StLinFlag); + CHECK(su45.lineContactors.closed); 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.StLinFlag); + CHECK(su45.lineContactors.closed); // 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 b552ed158..595abff6e 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.Mains) { + if (false == cab.lineBreaker.closed) { 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.Mains && cab.ConverterFlag && cab.mainPipe.pressure >= 4.5) { + if (cab.lineBreaker.closed && cab.converter.running && 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.Mains); + REQUIRE(cab.lineBreaker.closed); CHECK_FALSE(cab.TractionModeSwitch(traction_mode::genset)); CHECK(cab.TractionMode == traction_mode::catenary); run(dragon6, 2.0, wire); - CHECK(cab.Mains); + CHECK(cab.lineBreaker.closed); cab.MainSwitch(false); - REQUIRE_FALSE(cab.Mains); + REQUIRE_FALSE(cab.lineBreaker.closed); 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.Mains; ++second) { + for (auto second = 0; second < 10 && false == cab.lineBreaker.closed; ++second) { if (cab.MainSwitchCheck()) { close_line_breaker(cab); } run(dragon6, 1.0); } - REQUIRE(cab.Mains); + REQUIRE(cab.lineBreaker.closed); CHECK(cab.pantographCircuit.supplyVoltage == 0.0); dragon6.step(no_wire); CHECK(cab.EngineVoltage == 3000.0); CHECK(cab.MainCircuitPowered()); run(dragon6, 5.0); - CHECK(cab.Mains); + CHECK(cab.lineBreaker.closed); } 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.Mains); + CHECK_FALSE(cab.lineBreaker.closed); 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.Mains); + CHECK_FALSE(cab.lineBreaker.closed); 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.Mains; ++step_count) { + for (; step_count < 60000 && cab.Vel < 80.0 && cab.lineBreaker.closed; ++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.Mains); + CHECK(cab.lineBreaker.closed); 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.Mains; ++step_count) { + for (; step_count < 1000 && cab.lineBreaker.closed; ++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.Mains); + CHECK_FALSE(cab.lineBreaker.closed); 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.Mains); + CHECK_FALSE(cab.lineBreaker.closed); // 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.Mains); + CHECK(cab.lineBreaker.closed); } 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.Mains); + REQUIRE(cab.lineBreaker.closed); // 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.Mains); + CHECK_FALSE(cab.lineBreaker.closed); } } @@ -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->Mains); + CHECK(dragon6->lineBreaker.closed); } 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.Mains); + CHECK(second.lineBreaker.closed); // stopped, the genset takes the voltage away first.GensetSwitch(false); train.run(30.0, no_wire); CHECK(second.GetTrainsetHighVoltage() < 1.0); - CHECK_FALSE(second.Mains); + CHECK_FALSE(second.lineBreaker.closed); } 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.Mains); + REQUIRE(first.lineBreaker.closed); // the second one's line breaker opened by itself, the lead's is closed second.MainSwitch(false, range_t::local); - REQUIRE_FALSE(second.Mains); + REQUIRE_FALSE(second.lineBreaker.closed); 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 749cf8644..90f3ff2a1 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->StLinFlag = false; // the line contactors open + vehicle->lineContactors.closed = false; // 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->HasControlPressureSwitch); + REQUIRE(vehicle->protection.hasPressureSwitch); vehicle->brakes.cylinderPressure = 1.5; // braked, the start can still be made vehicle->MotorConnectorsCheck(); // updates the pressure switch - REQUIRE_FALSE(vehicle->ControlPressureSwitch); + REQUIRE_FALSE(vehicle->protection.pressureSwitch); CHECK(vehicle->LineContactorsLampLit()); vehicle->brakes.cylinderPressure = 2.5; // the pressure switch cuts the start off vehicle->MotorConnectorsCheck(); - REQUIRE(vehicle->ControlPressureSwitch); + REQUIRE(vehicle->protection.pressureSwitch); 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->StLinFlag = true; + vehicle->lineContactors.closed = true; 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->Mains); - REQUIRE_FALSE(vehicle->ControlPressureSwitch); - CHECK_FALSE(vehicle->StLinFlag); + REQUIRE(vehicle->lineBreaker.closed); + REQUIRE_FALSE(vehicle->protection.pressureSwitch); + CHECK_FALSE(vehicle->lineContactors.closed); CHECK(vehicle->LineContactorsLampLit()); vehicle->IncMainCtrl(1); vehicle.run(3.0); - CHECK(vehicle->StLinFlag); + CHECK(vehicle->lineContactors.closed); CHECK_FALSE(vehicle->LineContactorsLampLit()); vehicle->DecMainCtrl(1); vehicle.run(3.0); - CHECK_FALSE(vehicle->StLinFlag); + CHECK_FALSE(vehicle->lineContactors.closed); 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->StLinFlag); + REQUIRE(vehicle->lineContactors.closed); vehicle.hold_brake_pipe(2.5); // bar, below the 3.6 bar of the pressure switch vehicle.run(10.0); - REQUIRE(vehicle->ControlPressureSwitch); - CHECK_FALSE(vehicle->StLinFlag); + REQUIRE(vehicle->protection.pressureSwitch); + CHECK_FALSE(vehicle->lineContactors.closed); 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->ControlPressureSwitch); - CHECK_FALSE(vehicle->StLinFlag); + REQUIRE_FALSE(vehicle->protection.pressureSwitch); + CHECK_FALSE(vehicle->lineContactors.closed); CHECK(vehicle->LineContactorsLampLit()); vehicle->DecMainCtrl(1); vehicle.run(3.0); - CHECK(vehicle->StLinFlag); + CHECK(vehicle->lineContactors.closed); CHECK_FALSE(vehicle->LineContactorsLampLit()); } diff --git a/tests/unit/test_line_contactors_interlock.cpp b/tests/unit/test_line_contactors_interlock.cpp index f7f6d69a9..24e025f09 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->Mains = true; + locomotive->lineBreaker.closed = true; 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("")->LineContactorsInterlock == line_contactors_interlock::none); - CHECK(ready("Converter")->LineContactorsInterlock == line_contactors_interlock::converter); - CHECK(ready("MotorBlowers")->LineContactorsInterlock == line_contactors_interlock::motor_blowers); - CHECK(ready("Something")->LineContactorsInterlock == line_contactors_interlock::none); + 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); } TEST_CASE("line contactors interlock: without one the converter and the blowers don't matter, as before") { auto locomotive{ready("")}; - locomotive->ConverterFlag = false; + locomotive->converter.running = 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->ConverterFlag = false; + locomotive->converter.running = false; locomotive->Power110vIsAvailable = true; // the 110 V from the other section doesn't run this one's fans CHECK_FALSE(locomotive->MotorConnectorsCheck()); - locomotive->ConverterFlag = true; + locomotive->converter.running = true; CHECK(locomotive->MotorConnectorsCheck()); - locomotive->Mains = false; // the other conditions still hold + locomotive->lineBreaker.closed = false; // 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.StLinFlag; ++i) { + for (int i = 0; i < 30 && false == Driven.controlling.lineContactors.closed; ++i) { test::drive(Driven, line, 1.0); } - return Driven.controlling.StLinFlag; + return Driven.controlling.lineContactors.closed; } // 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.LineContactorsInterlock == line_contactors_interlock::motor_blowers); + REQUIRE(physics.lineContactors.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.StLinFlag); + CHECK(physics.lineContactors.closed); // 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.StLinFlag); + REQUIRE_FALSE(physics.lineContactors.closed); // 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.StLinFlag); + CHECK_FALSE(physics.lineContactors.closed); 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->ConverterAllowLocal = false; + interlocked->converter.allowLocal = false; CHECK(interlocked->LineContactorsHeldByLocalConverterSwitch()); for (auto const *other : {"", "MotorBlowers"}) { CAPTURE(other); auto locomotive{ready(other)}; - locomotive->ConverterAllowLocal = false; + locomotive->converter.allowLocal = 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.ConverterFlag); - REQUIRE(rear.ConverterFlag); + REQUIRE(front.converter.running); + REQUIRE(rear.converter.running); // the fans of the rear section switched off with its own switch, the 110 V of the front one still reaches it - rear.ConverterAllowLocal = false; + rear.converter.allowLocal = false; test::drive(driven, line, 2.0); - REQUIRE_FALSE(rear.ConverterFlag); + REQUIRE_FALSE(rear.converter.running); CHECK(rear.Power110vIsAvailable); 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.StLinFlag; ++i) { + for (int i = 0; i < 90 && false == front.lineContactors.closed; ++i) { test::drive(driven, line, 1.0); } - CHECK(front.StLinFlag); - CHECK_FALSE(rear.StLinFlag); + CHECK(front.lineContactors.closed); + CHECK_FALSE(rear.lineContactors.closed); // the fans back on, the section starts too - rear.ConverterAllowLocal = true; + rear.converter.allowLocal = true; test::drive(driven, line, 10.0); - REQUIRE(rear.ConverterFlag); - CHECK(rear.StLinFlag); + REQUIRE(rear.converter.running); + CHECK(rear.lineContactors.closed); // and the fans switched off on the way open its line contactors again - rear.ConverterAllowLocal = false; + rear.converter.allowLocal = false; test::drive(driven, line, 2.0); - CHECK_FALSE(rear.StLinFlag); - CHECK(front.StLinFlag); + CHECK_FALSE(rear.lineContactors.closed); + CHECK(front.lineContactors.closed); } 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 6b132e08e..d0a678c7d 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.Mains) { + if (breaker == state::open && physics.lineBreaker.closed) { breaker = state::closed; } - if (breaker == state::closed && false == physics.Mains) { + if (breaker == state::closed && false == physics.lineBreaker.closed) { 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.Mains); - REQUIRE(ep05.ConverterFlag); + REQUIRE(ep05.lineBreaker.closed); + REQUIRE(ep05.converter.running); 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.ConvOvldFlag = true; + ep05.converter.overloaded = true; ep05.MainSwitch(false, range_t::local); ws.update(); - REQUIRE_FALSE(ep05.Mains); + REQUIRE_FALSE(ep05.lineBreaker.closed); 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.Mains); + CHECK_FALSE(ep05.lineBreaker.closed); 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.ConvOvldFlag); + CHECK_FALSE(ep05.converter.overloaded); ws.update(); - CHECK_FALSE(ep05.Mains); // the lever is off + CHECK_FALSE(ep05.lineBreaker.closed); // the lever is off ws.press(); ws.update(); - CHECK(ep05.Mains); + CHECK(ep05.lineBreaker.closed); CHECK(ws.breaker == state::closed); // and the next press opens it ws.press(); CHECK_FALSE(ws.on); - CHECK_FALSE(ep05.Mains); + CHECK_FALSE(ep05.lineBreaker.closed); } diff --git a/tests/unit/test_mains_before_pantographs.cpp b/tests/unit/test_mains_before_pantographs.cpp index 374a8709a..7fd62fa35 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->ControlPressureSwitch; ++i) { + for (int i = 0; i < 120 && Loco->protection.pressureSwitch; ++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->StLinFlag); + REQUIRE(Loco->lineContactors.closed); 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->PantographsRequireMains); + REQUIRE_FALSE(loco->lineBreaker.pantographsRequireIt); prepare(loco); close_line_breaker(loco); - CHECK_FALSE(loco->Mains); + CHECK_FALSE(loco->lineBreaker.closed); 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->Mains); + CHECK(loco->lineBreaker.closed); // 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->Mains); + REQUIRE(loco->lineBreaker.closed); loco->OperatePantographValve(VehicleEnd::rear, operation_t::disable); loco.run(2.0, line); - CHECK_FALSE(loco->Mains); + CHECK_FALSE(loco->lineBreaker.closed); } 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->PantographsRequireMains); + REQUIRE(loco->lineBreaker.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->Mains); + CHECK(loco->lineBreaker.closed); raise_pantograph(loco); CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); - CHECK(loco->Mains); + CHECK(loco->lineBreaker.closed); // 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->Mains); + CHECK_FALSE(loco->lineBreaker.closed); 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->Mains); + CHECK(loco->lineBreaker.closed); } 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->Mains); + CHECK_FALSE(loco->lineBreaker.closed); } 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->Mains); + CHECK(loco->lineBreaker.closed); 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->Mains); + REQUIRE(loco->lineBreaker.closed); REQUIRE(loco->pantographCircuit.supplyVoltage == 0.0); switch_auxiliaries_on(loco); - REQUIRE(loco->ConverterAllow); + REQUIRE(loco->converter.allow); 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->Mains); + CHECK(loco->lineBreaker.closed); CHECK_FALSE(loco->MainCircuitPowered()); - CHECK_FALSE(loco->ConverterFlag); + CHECK_FALSE(loco->converter.running); CHECK_FALSE(loco->Power110vIsAvailable); 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->ConverterFlag); + CHECK(loco->converter.running); CHECK(loco->Power110vIsAvailable); 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->Mains); + CHECK(loco->lineBreaker.closed); CHECK_FALSE(loco->MainCircuitPowered()); - CHECK_FALSE(loco->ConverterFlag); + CHECK_FALSE(loco->converter.running); CHECK_FALSE(loco->Power110vIsAvailable); 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->Mains); + REQUIRE(loco->lineBreaker.closed); 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->Mains); + CHECK(loco->lineBreaker.closed); 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->Mains); + REQUIRE(loco->lineBreaker.closed); switch_auxiliaries_on(loco); CHECK(reservoir_gain(loco, 10.0, line) > 0.1); CHECK(loco->MainCircuitPowered()); - CHECK(loco->ConverterFlag); + CHECK(loco->converter.running); CHECK(loco->Power110vIsAvailable); 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->Mains); + CHECK_FALSE(loco->lineBreaker.closed); CHECK_FALSE(loco->MainCircuitPowered()); - CHECK_FALSE(loco->ConverterFlag); + CHECK_FALSE(loco->converter.running); CHECK_FALSE(loco->Power110vIsAvailable); 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->Mains); + CHECK(loco->lineBreaker.closed); CHECK(loco->pantographs[VehicleEnd::rear].is_active); - CHECK_FALSE(loco->NoVoltRelay); - CHECK_FALSE(loco->StLinFlag); + CHECK_FALSE(loco->protection.noVoltage); + CHECK_FALSE(loco->lineContactors.closed); 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->Mains); - CHECK(loco->ConverterFlag); - CHECK_FALSE(loco->NoVoltRelay); - CHECK_FALSE(loco->StLinFlag); + CHECK(loco->lineBreaker.closed); + CHECK(loco->converter.running); + CHECK_FALSE(loco->protection.noVoltage); + CHECK_FALSE(loco->lineContactors.closed); 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->NoVoltRelay); - CHECK_FALSE(loco->StLinFlag); + CHECK(loco->protection.noVoltage); + CHECK_FALSE(loco->lineContactors.closed); for (int i = 0; i < 3; ++i) { loco->IncMainCtrl(1); test::drive(driven, line, 2.0); } - CHECK(loco->StLinFlag); + CHECK(loco->lineContactors.closed); 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->NoVoltRelay); - CHECK(loco->StLinFlag); + CHECK(loco->protection.noVoltage); + CHECK(loco->lineContactors.closed); 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->Mains); - CHECK_FALSE(loco->StLinFlag); + CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineContactors.closed); CHECK(loco->Im == 0.0); // and stays open with the voltage back test::drive(driven, line, 10.0); - CHECK_FALSE(loco->Mains); - CHECK_FALSE(loco->StLinFlag); + CHECK_FALSE(loco->lineBreaker.closed); + CHECK_FALSE(loco->lineContactors.closed); 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 aaac2e871..130145b29 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->Mains = true; // engine started + loco->lineBreaker.closed = true; // 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->Mains = true; + loco->lineBreaker.closed = true; 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 75304f5ae..8645b5165 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->ControlPressureSwitch; ++i) { + for (int i = 0; i < 120 && Loco->protection.pressureSwitch; ++i) { test::drive(Driven, line, 1.0); } - REQUIRE_FALSE(Loco->ControlPressureSwitch); - REQUIRE(Loco->Mains); + REQUIRE_FALSE(Loco->protection.pressureSwitch); + REQUIRE(Loco->lineBreaker.closed); 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->StLinFlag); + REQUIRE(Loco->lineContactors.closed); 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->HasControlPressureSwitch); - CHECK(loco->PressureSwitchBrakeCylinder); - CHECK(loco->EmergencyBrakeMainOffPressure == 0.0); + CHECK(loco->protection.hasPressureSwitch); + CHECK(loco->protection.pressureSwitchWatchesCylinders); + CHECK(loco->lineBreaker.emergencyOffPressure == 0.0); test::vehicle changed{ep05({.brakecylinder = false, .mainoff = true}), 0.0, "test", 1}; - CHECK(changed->HasControlPressureSwitch); - CHECK_FALSE(changed->PressureSwitchBrakeCylinder); - CHECK(changed->EmergencyBrakeMainOffPressure == doctest::Approx(emergency_pressure)); + CHECK(changed->protection.hasPressureSwitch); + CHECK_FALSE(changed->protection.pressureSwitchWatchesCylinders); + CHECK(changed->lineBreaker.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->ControlPressureSwitch); + CHECK(loco->protection.pressureSwitch); CHECK_FALSE(loco->MainCircuitLampsEnabled()); notch_up(loco, driven, 3); - CHECK_FALSE(loco->StLinFlag); + CHECK_FALSE(loco->lineContactors.closed); CHECK(loco->Im == 0.0); - CHECK(loco->Mains); + CHECK(loco->lineBreaker.closed); 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->ControlPressureSwitch); + CHECK_FALSE(loco->protection.pressureSwitch); // 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->StLinFlag); + CHECK(loco->lineContactors.closed); 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->ControlPressureSwitch); - CHECK_FALSE(loco->StLinFlag); + CHECK(loco->protection.pressureSwitch); + CHECK_FALSE(loco->lineContactors.closed); CHECK(loco->Im == 0.0); // nothing else lets go without the other key - CHECK(loco->Mains); + CHECK(loco->lineBreaker.closed); 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->Mains); + CHECK_FALSE(loco->lineBreaker.closed); 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->StLinFlag); + CHECK_FALSE(loco->lineContactors.closed); 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->Mains); + CHECK_FALSE(loco->lineBreaker.closed); 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->Mains); + CHECK(loco->lineBreaker.closed); 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->Mains); + CHECK_FALSE(loco->lineBreaker.closed); 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->Mains); + CHECK(loco->lineBreaker.closed); CHECK(loco->pantographs[VehicleEnd::rear].is_active); // the pressure switch has cut the motors off - CHECK_FALSE(loco->StLinFlag); + CHECK_FALSE(loco->lineContactors.closed); 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->Mains); + CHECK(loco->lineBreaker.closed); 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->ControlPressureSwitch); - CHECK_FALSE(loco->StLinFlag); + CHECK(loco->protection.pressureSwitch); + CHECK_FALSE(loco->lineContactors.closed); 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->PantographsRequireMains); + REQUIRE_FALSE(loco->lineBreaker.pantographsRequireIt); auto driven{test::driving(loco)}; get_under_power(loco, driven, 5); emergency_application(loco, driven); - CHECK_FALSE(loco->Mains); + CHECK_FALSE(loco->lineBreaker.closed); CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); - CHECK_FALSE(loco->StLinFlag); + CHECK_FALSE(loco->lineContactors.closed); 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->Mains); + REQUIRE_FALSE(loco->lineBreaker.closed); 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->Mains); + CHECK(loco->lineBreaker.closed); 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->Mains); + CHECK(loco->lineBreaker.closed); 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->ControlPressureSwitch; ++i) { + for (int i = 0; i < 180 && loco->protection.pressureSwitch; ++i) { loco->BrakeReleaser(loco->brakePipe.pressure < 3.0 ? 1 : 0); test::drive(driven, line, 1.0); } loco->BrakeReleaser(0); - REQUIRE_FALSE(loco->ControlPressureSwitch); + REQUIRE_FALSE(loco->protection.pressureSwitch); notch_up(loco, driven, 3); - CHECK(loco->Mains); - CHECK(loco->StLinFlag); + CHECK(loco->lineBreaker.closed); + CHECK(loco->lineContactors.closed); CHECK(std::abs(loco->Im) > 10.0); } diff --git a/tests/unit/test_smoke.cpp b/tests/unit/test_smoke.cpp index 7f204927c..5ee3a75f3 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.Mains; ++second) { + for (int second = 0; second < 120 && false == Driven.controlling.lineBreaker.closed; ++second) { test::start_up(Driven, Track, 1.0); } - return Driven.controlling.Mains; + return Driven.controlling.lineBreaker.closed; } } // 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->Mains); + CHECK(locomotive->lineBreaker.closed); 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 09647c188..41047924b 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.StLinFlag); + REQUIRE(loco.lineContactors.closed); } } // 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.StLinFlag); + CHECK(loco.lineContactors.closed); 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.StLinFlag); + CHECK_FALSE(loco.lineContactors.closed); 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.StLinFlag); + CHECK(loco.lineContactors.closed); 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.StLinFlag); + CHECK(loco.lineContactors.closed); 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 8ae1d1f9f..5fd81fd95 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->Mains) { + if (real->lineBreaker.closed) { 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.Mains); + REQUIRE(controlling.lineBreaker.closed); scenario.act("catenary lost"); scenario.line().voltage = 0.0; scenario.wait(5.0); - CHECK_FALSE(controlling.Mains); + CHECK_FALSE(controlling.lineBreaker.closed); 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.Mains == (controlling.EngineType == TEngineType::ElectricSeriesMotor && false == controlling.EnginePowerSource.CollectorParameters.OVP)); + CHECK(controlling.lineBreaker.closed == (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 ed08ac78d..30176ce2f 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->ConvOvldFlag; + IsAnyConverterOverloadRelayOpen |= vehicle->converter.overloaded; IsAnyMotorOverloadRelayOpen |= vehicle->FuseFlag; - IsAnyGroundRelayOpen |= !vehicle->GroundRelay; + IsAnyGroundRelayOpen |= !vehicle->protection.ground; 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->ConverterStart != start_t::disabled; - IsAnyConverterEnabled |= ( vehicle->ConverterAllow || vehicle->ConverterStart == start_t::automatic ) && vehicle->ConverterAllowLocal; - IsAnyConverterExplicitlyEnabled |= vehicle->ConverterAllow && vehicle->ConverterAllowLocal; + 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; if( vehicle->Power > 0.01 ) { - IsAnyLineBreakerOpen |= !vehicle->Mains; } } ); + IsAnyLineBreakerOpen |= !vehicle->lineBreaker.closed; } } ); // 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->Mains // deadweight vehicle + || false == vehicle->lineBreaker.closed // 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 d488e2c53..c2cc203c2 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->BatteryVoltage; } - if (!IsAnyMotorOverloadRelayOpen && !mvControlling->ControlPressureSwitch && (mvControlling->IsMainCtrlNoPowerPos() || mvControlling->StLinFlag) && (Ready || drivingFlags.press)) { + if (!IsAnyMotorOverloadRelayOpen && !mvControlling->protection.pressureSwitch && (mvControlling->IsMainCtrlNoPowerPos() || mvControlling->lineContactors.closed) && (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->StLinFlag && mvControlling->RList[mvControlling->MainCtrlPos].R < 0.01 && false == mvControlling->IsScndCtrlLockedByMainCtrl() && + auto const usefieldshunting = mvControlling->lineContactors.closed && 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->StLinFlag) + if (true == mvControlling->lineContactors.closed) { drivingFlags.incSpeed = true; } @@ -643,7 +643,7 @@ bool TController::IncSpeed() } break; case TEngineType::DieselElectric: - if (!IsAnyMotorOverloadRelayOpen && !mvControlling->ControlPressureSwitch && (mvControlling->IsMainCtrlNoPowerPos() || mvControlling->StLinFlag) && (Ready || drivingFlags.press)) { + if (!IsAnyMotorOverloadRelayOpen && !mvControlling->protection.pressureSwitch && (mvControlling->IsMainCtrlNoPowerPos() || mvControlling->lineContactors.closed) && (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->Mains) + if (mvControlling->SpeedCtrl && mvControlling->lineBreaker.closed) { // 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->Mains) {// cruise control + if (mvControlling->SpeedCtrl && mvControlling->lineBreaker.closed) {// 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->Mains ) { + if( false == mvControlling->lineBreaker.closed ) { SpeedCntrl(0.0); mvControlling->DecScndCtrl( 2 ); cue_action( driver_hint::linebreakerclose ); @@ -935,7 +935,7 @@ void TController::SpeedSet() { } if( mvControlling->MainCtrlPos > 0 - && false == mvControlling->StLinFlag ) { + && false == mvControlling->lineContactors.closed ) { // 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->StLinFlag) + if (mvControlling->EngineType == TEngineType::DieselElectric && mvControlling->EIMCtrlType == 3 && AccDesired >= 0.0 && mvControlling->lineContactors.closed) { // NOTE: partial implementation for speedinc/dec // TBD, TODO: implement fully? diff --git a/vehicle/ai/engine.cpp b/vehicle/ai/engine.cpp index 5aedc3b66..33884cac8 100644 --- a/vehicle/ai/engine.cpp +++ b/vehicle/ai/engine.cpp @@ -86,7 +86,7 @@ bool TController::PrepareEngine() } } - if( mvControlling->PantographsRequireMains + if( mvControlling->lineBreaker.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->Mains ) { + if( false == mvControlling->lineBreaker.closed ) { // 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->Mains + && false == mvControlling->lineBreaker.closed && false == occupied->Power24vIsAvailable }; if (OK) { diff --git a/vehicle/ai/situation.cpp b/vehicle/ai/situation.cpp index 84b7de29e..a6c7fbd78 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->StLinFlag + if( false == mvControlling->lineContactors.closed && 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->StLinFlag + if( false == mvControlling->lineContactors.closed && false == mvControlling->DelayCtrlFlag && mvControlling->MainCtrlPowerPos() > 1 ) { cue_action( driver_hint::mastercontrollersetzerospeed ); diff --git a/vehicle/cab/auxiliarycommands.cpp b/vehicle/cab/auxiliarycommands.cpp index dac2aea49..cb7540cc8 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->ConvOvldFlag)}; + auto const overloadrelayisopen{(Train->Dynamic()->Mechanik != nullptr ? Train->Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : Train->occupied->converter.overloaded)}; - if (Train->occupied->ConvSwitchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->occupied->Power110vIsAvailable && false == overloadrelayisopen) + if (Train->occupied->converter.switchType != "impulse" ? Train->ggConverterButton.GetValue() < 0.5 : false == Train->occupied->Power110vIsAvailable && 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->ConvSwitchType == "impulse") + if (Train->occupied->converter.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->ConvSwitchType != "impulse" || Train->controlled->Mains) + if (Train->occupied->converter.switchType != "impulse" || Train->controlled->lineBreaker.closed) { // 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->ConverterStart == start_t::automatic) + if (Train->occupied->converter.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->ConverterAllowLocal && Train->ggConverterLocalButton.GetValue() < 0.5) + if (false == Train->occupied->converter.allowLocal && Train->ggConverterLocalButton.GetValue() < 0.5) { // turn on // visual feedback Train->ggConverterLocalButton.UpdateValue(1.0, Train->dsbSwitch); // effect - Train->occupied->ConverterAllowLocal = true; + Train->occupied->converter.allowLocal = 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->ConverterAllowLocal = false; + Train->occupied->converter.allowLocal = false; /* if( true == Train->controlled->ConverterSwitch( false, range::local ) ) { // side effects diff --git a/vehicle/cab/powercommands.cpp b/vehicle/cab/powercommands.cpp index dc4dc14ff..6d15e634d 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->StLinSwitchOff) + if (false == Train->controlled->lineContactors.forcedOpen) { // open the connectors // visual feedback Train->ggStLinOffButton.UpdateValue(1.0, Train->dsbSwitch); - Train->controlled->StLinSwitchOff = true; + Train->controlled->lineContactors.forcedOpen = 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->StLinSwitchType != "toggle") + if (Train->controlled->lineContactors.switchType != "toggle") { // default button type (impulse) ceases its work on button release // visual feedback Train->ggStLinOffButton.UpdateValue(0.0, Train->dsbSwitch); - Train->controlled->StLinSwitchOff = false; + Train->controlled->lineContactors.forcedOpen = 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->StLinSwitchType == "toggle") + if (Train->controlled->lineContactors.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->StLinSwitchOff) + if (false == Train->controlled->lineContactors.forcedOpen) { return; } // already closed - Train->controlled->StLinSwitchOff = false; + Train->controlled->lineContactors.forcedOpen = false; Train->set_paired_open_motor_connectors_button(false); } } diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index 116d2b8dc..118a6ff30 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->StLinSwitchOff ? 1.f : 0.f); + ggStLinOffButton.PutValue(controlled->lineContactors.forcedOpen ? 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->ConvSwitchType != "impulse") + if (occupied->converter.switchType != "impulse") { - ggConverterButton.PutValue(occupied->ConverterAllow ? 1.f : 0.f); + ggConverterButton.PutValue(occupied->converter.allow ? 1.f : 0.f); } - ggConverterLocalButton.PutValue(occupied->ConverterAllowLocal ? 1.f : 0.f); + ggConverterLocalButton.PutValue(occupied->converter.allowLocal ? 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 2a54c74f7..d0c889eb2 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->Power24vIsAvailable); - dict->insert("linebreaker", controlled->Mains); - dict->insert("main_init", controlled->MainsInitTimeCountdown < controlled->MainsInitTime && controlled->MainsInitTimeCountdown > 0.0); - dict->insert("main_ready", false == controlled->Mains && fHVoltage > 0.0 && controlled->MainsInitTimeCountdown <= 0.0); + 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("converter", occupied->Power110vIsAvailable); - dict->insert("converter_overload", controlled->ConvOvldFlag); + dict->insert("converter_overload", controlled->converter.overloaded); 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->StLinSwitchOff = State; + controlled->Couplers[VehicleEnd::front].Connected->lineContactors.forcedOpen = State; } if (controlled->Couplers[VehicleEnd::rear].Connected != nullptr && true == controlled->Couplers[VehicleEnd::rear].CouplingFlag.HasAll(Coupling::permanent)) { - controlled->Couplers[VehicleEnd::rear].Connected->StLinSwitchOff = State; + controlled->Couplers[VehicleEnd::rear].Connected->lineContactors.forcedOpen = State; } } } diff --git a/vehicle/cab/update.cpp b/vehicle/cab/update.cpp index 0594899ee..32a0fab22 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->Mains) + if (m_linebreakerstate == linebreaker::state::open && true == controlled->lineBreaker.closed) { // 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->Mains || controlled->diesel.startupRequested)) + if (m_linebreakerstate == linebreaker::state::closed && false == (controlled->lineBreaker.closed || 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 (is_hold_coil_lever(ggMainOffButton) && hold_coil_lever::cuts_off(ggMainOffButton.GetDesiredValue())) { - if (true == controlled->Mains) + if (true == controlled->lineBreaker.closed) { // 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->Mains; + bMains[in] = p->physics->lineBreaker.closed; fCntVol[in] = static_cast(p->physics->BatteryVoltage); bFuse[in] = p->physics->FuseFlag; bBatt[in] = p->physics->Battery; - bConv[in] = p->physics->ConverterFlag; + bConv[in] = p->physics->converter.running; bHeat[in] = p->physics->Heating; // 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->Mains; + bMains[in] = p->physics->lineBreaker.closed; fCntVol[in] = static_cast(p->physics->BatteryVoltage); bFuse[in] = p->physics->FuseFlag; bBatt[in] = p->physics->Battery; - bConv[in] = p->physics->ConverterFlag; + bConv[in] = p->physics->converter.running; bHeat[in] = p->physics->Heating; 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->ConverterFlag == true) + if (controlled->converter.running == 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->ConvOvldFlag = true; + controlled->converter.overloaded = true; 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->Mains) + if (controlled->lineBreaker.closed) 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->Mains || controlled->diesel.startupRequested || fMainRelayTimer > 0.f || + ggIgnitionKey.UpdateValue(controlled->lineBreaker.closed || 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->Mains); - btLampkaWylSzybkiOff.Turn(m_linebreakerstate != linebreaker::state::closing && !controlled->Mains); - btLampkaMainBreakerReady.Turn(controlled->MainsInitTimeCountdown <= 0.0 && m_linebreakerstate != linebreaker::state::closing && !controlled->Mains); - btLampkaMainBreakerBlinkingIfReady.Turn(m_linebreakerstate == linebreaker::state::closing || controlled->Mains || controlled->MainsInitTimeCountdown < 0.0 && simulation::Time.data().wMilliseconds > 500); + 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); btLampkaPrzetw.Turn(occupied->Power110vIsAvailable); btLampkaPrzetwOff.Turn(!occupied->Power110vIsAvailable); - btLampkaPrzetwAOff.Turn(!controlled->ConverterFlag); - btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : controlled->ConvOvldFlag); + btLampkaPrzetwAOff.Turn(!controlled->converter.running); + btLampkaNadmPrzetw.Turn(Dynamic()->Mechanik ? Dynamic()->Mechanik->IsAnyConverterOverloadRelayOpen : controlled->converter.overloaded); - btLampkaOpory.Turn(controlled->StLinFlag && controlled->ResistorsFlagCheck()); + btLampkaOpory.Turn(controlled->lineContactors.closed && controlled->ResistorsFlagCheck()); btLampkaBezoporowa.Turn(controlled->ResistorsFlagCheck() || controlled->MainCtrlActualPos == 0); // do EU04 btLampkaStyczn.Turn(controlled->LineContactorsLampLit()); // mozna prowadzic rozruch - btLampkaPrzekRozn.Turn(!controlled->GroundRelay && controlled->MainCircuitLampsEnabled()); // relay is off and needs a reset + btLampkaPrzekRozn.Turn(!controlled->protection.ground && 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->Mains); - btLampkaWylSzybkiBOff.Turn(false == physics->Mains + btLampkaWylSzybkiB.Turn(physics->lineBreaker.closed); + btLampkaWylSzybkiBOff.Turn(false == physics->lineBreaker.closed /*&& ( physics->MainsInitTimeCountdown <= 0.0 )*/ /*&& ( fHVoltage != 0.0 )*/); @@ -1142,13 +1142,13 @@ void TTrain::updateSecondUnitLamps(bool const lowvoltagepower) { btLampkaHamowanie2zes.Turn(false); } - btLampkaNadmPrzetwB.Turn(physics->ConvOvldFlag); // nadmiarowy przetwornicy? - btLampkaPrzetwB.Turn(physics->ConverterFlag); // zalaczenie przetwornicy - btLampkaPrzetwBOff.Turn(false == physics->ConverterFlag); - btLampkaHVoltageB.Turn(physics->NoVoltRelay && physics->OvervoltageRelay); + 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); btLampkaMalfunctionB.Turn(physics->diesel.heat.PA); // motor fuse indicator turns on if the fuse was blown in any unit under control - if (physics->Mains) + if (physics->lineBreaker.closed) { 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->Heating == true && controlled->ConvOvldFlag == false) + if (controlled->Heating == true && controlled->converter.overloaded == false) btLampkaOgrzewanieSkladu.Turn(true); else btLampkaOgrzewanieSkladu.Turn(false); @@ -1383,7 +1383,7 @@ void TTrain::updateHeatingAndInstrumentLights() // lights auto const lightpower{(InstrumentLightType == 0 ? occupied->Power24vIsAvailable || occupied->Power110vIsAvailable : - InstrumentLightType == 1 ? controlled->Mains : + InstrumentLightType == 1 ? controlled->lineBreaker.closed : InstrumentLightType == 2 ? occupied->Power110vIsAvailable : InstrumentLightType == 3 ? occupied->Power24vIsAvailable || occupied->Power110vIsAvailable : InstrumentLightType == 4 ? occupied->Power24vIsAvailable || occupied->Power110vIsAvailable : @@ -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->ConvSwitchType != "impulse" && occupied->ConverterStart == start_t::manual) + if (ggConverterButton.SubModel != nullptr && occupied->converter.switchType != "impulse" && occupied->converter.start == start_t::manual) { - ggConverterButton.UpdateValue(occupied->ConverterAllow ? 1.f : 0.f, dsbSwitch); + ggConverterButton.UpdateValue(occupied->converter.allow ? 1.f : 0.f, dsbSwitch); } ggConverterButton.Update(); if (ggConverterLocalButton.SubModel != nullptr) { - ggConverterLocalButton.UpdateValue(occupied->ConverterAllowLocal ? 1.f : 0.f, dsbSwitch); + ggConverterLocalButton.UpdateValue(occupied->converter.allowLocal ? 1.f : 0.f, dsbSwitch); } ggConverterLocalButton.Update(); ggConverterOffButton.Update(); diff --git a/vehicle/dynamic/sounds.cpp b/vehicle/dynamic/sounds.cpp index d83e3afca..144d8e776 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->ConverterFlag ) { + if( physics->converter.running ) { 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.Mains ) { + if( engine_state_last != Vehicle.lineBreaker.closed ) { - if( true == Vehicle.Mains ) { + if( true == Vehicle.lineBreaker.closed ) { // 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.Mains; + engine_state_last = Vehicle.lineBreaker.closed; } } @@ -1136,7 +1136,7 @@ TDynamicObject::powertrain_sounds::renderEngineSounds( physics::Vehicle const &V double volume { 0.0 }; // main engine sound - if( true == Vehicle.Mains ) { + if( true == Vehicle.lineBreaker.closed ) { 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.Mains) { + if (Vehicle.lineBreaker.closed) { 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 2ec42d52c..6e929c902 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->Mains // Ra 15-01: logować tylko, jeśli WS załączony + if( physics->lineBreaker.closed // 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->Mains && p->physics->DirActive != 0 && p->physics->inductionMotor.inverterRatio == 1.0 && + state.FmaxED += p->physics->lineBreaker.closed && 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->Mains ) { // nie wchodzić w funkcję bez potrzeby + if( physics->lineBreaker.closed ) { // nie wchodzić w funkcję bez potrzeby if( false == (physics->Power24vIsAvailable || physics->Power110vIsAvailable) /* // 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->StLinFlag = false; + physics->lineContactors.closed = false; if (physics->InitialCtrlDelay<100000000) physics->InitialCtrlDelay += 100000001; } @@ -1524,8 +1524,8 @@ void TDynamicObject::Damage(char flag) if (flag & 4) //blokada przetwornicy { - if( physics->ConverterStart != start_t::disabled ) { - physics->ConvOvldFlag = true; + if( physics->converter.start != start_t::disabled ) { + physics->converter.overloaded = true; } } else diff --git a/vehicle/enginestart.cpp b/vehicle/enginestart.cpp index c221119f4..ebac38066 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.Mains || Engine.diesel.startupRequested; + return Engine.lineBreaker.closed || Engine.diesel.startupRequested; } } // namespace engine_start diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index edc3568b7..321cee7de 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.Battery) draw_infobutton(STR_C("bat."), ImVec2(120, 55)); - if (physics.Mains) + if (physics.lineBreaker.closed) draw_infobutton(STR_C("main.")); - if (physics.ConverterFlag) + if (physics.converter.running) 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.Battery ? 'B' : '.'), (physics.Mains ? 'M' : '.'), (physics.FuseFlag ? '!' : '.'), (physics.pantographs[VehicleEnd::rear].is_active ? (physics.pantographCircuit.rearVoltage > 0.0 ? 'O' : 'o') : '.'), + (physics.Battery ? 'B' : '.'), (physics.lineBreaker.closed ? '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.ConverterAllowLocal ? '-' : (physics.ConverterAllow ? (physics.ConverterFlag ? 'X' : 'x') : '.')), (physics.ConvOvldFlag ? '!' : '.'), + (false == physics.converter.allowLocal ? '-' : (physics.converter.allow ? (physics.converter.running ? 'X' : 'x') : '.')), (physics.converter.overloaded ? '!' : '.'), (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