From 5e56a915151b377577bd27afc41dd6a6995f3c45 Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Sun, 29 Nov 2026 02:13:17 +0100 Subject: [PATCH] refactor(physics): the devices out of physics::Vehicle, the pantographs as components The types of the devices nested in physics::Vehicle (basic_device, the pumps, the fans, basic_valve, basic_pantograph, basic_door, door_data, water_heater, genset_device) move out of it into physics/components/devices.h, namespace physics, so the components of the vehicle can hold them. The pantographs and their air become components, with English names (physics/components/pantographs.h): Pantographs pantographs (ByEnd) pantographCircuit PantFrontVolt / PantRearVolt frontVoltage / rearVoltage, PantographVoltage supplyVoltage, PantAllDown allDown, PantSwitchType switchType, PantsPreset presets pantographAir PantVolume volume, PantPress pressure, PantCompFlag compressorRunning, PantographCompressorStart compressorStart, SmallCompressorPower compressorPower, PantsValve valve, bPantKurek3 connectedToMainReservoir, PantAutoValve autoValve, PantPressSwitchActive / PantPressLockActive pressureSwitchActive / pressureLockActive No string literal changed (checked over all the changed files). No change in behaviour: 1149/1149 tests, golden traces exact against staging 62f7a29b. --- application/driverhints.cpp | 28 +-- application/driveruipanels.cpp | 18 +- input/messaging.cpp | 2 +- physics/components/devices.h | 220 ++++++++++++++++++ physics/components/drive.cpp | 2 +- physics/components/electrics.cpp | 76 +++---- physics/components/fizsections.cpp | 18 +- physics/components/pantographs.h | 50 +++++ physics/vehicle.h | 222 +------------------ simulation/blackboxrecorder.cpp | 2 +- tests/unit/drive.cpp | 14 +- tests/unit/golden.cpp | 2 +- tests/unit/test_auxiliaries.cpp | 34 +-- tests/unit/test_commands.cpp | 16 +- tests/unit/test_door_wings.cpp | 2 +- tests/unit/test_genset.cpp | 18 +- tests/unit/test_loads.cpp | 4 +- tests/unit/test_mains_before_pantographs.cpp | 44 ++-- tests/unit/test_pressure_switch.cpp | 40 ++-- tests/unit/vehicle.cpp | 8 +- vehicle/ai/engine.cpp | 22 +- vehicle/ai/situation.cpp | 26 +-- vehicle/cab/pantographcommands.cpp | 46 ++-- vehicle/cab/setup.cpp | 22 +- vehicle/cab/train.cpp | 8 +- vehicle/cab/update.cpp | 6 +- vehicle/doorwings.h | 2 +- vehicle/dynamic/lifecycle.cpp | 4 +- vehicle/dynamic/sounds.cpp | 4 +- vehicle/dynamic/update.cpp | 82 +++---- vehicle/dynamic/vehicletable.cpp | 2 +- widgets/vehicleparams.cpp | 10 +- 32 files changed, 556 insertions(+), 498 deletions(-) create mode 100644 physics/components/devices.h create mode 100644 physics/components/pantographs.h diff --git a/application/driverhints.cpp b/application/driverhints.cpp index e41b12a39..ecd311e9e 100644 --- a/application/driverhints.cpp +++ b/application/driverhints.cpp @@ -224,46 +224,46 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) // pantographs case driver_hint::pantographairsourcesetmain: { if( AIControllFlag ) { - pantographUnit->bPantKurek3 = true; + pantographUnit->pantographAir.connectedToMainReservoir = true; } remove_hint( driver_hint::pantographairsourcesetauxiliary ); hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->bPantKurek3 == true; } ); + return pantographUnit->pantographAir.connectedToMainReservoir == true; } ); break; } case driver_hint::pantographairsourcesetauxiliary: { if( AIControllFlag ) { - pantographUnit->bPantKurek3 = false; + pantographUnit->pantographAir.connectedToMainReservoir = false; } remove_hint( driver_hint::pantographcompressoron ); hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->bPantKurek3 == false; } ); + return pantographUnit->pantographAir.connectedToMainReservoir == false; } ); break; } case driver_hint::pantographcompressoron: { if( AIControllFlag ) { - pantographUnit->PantCompFlag = true; + pantographUnit->pantographAir.compressorRunning = true; } remove_hint( driver_hint::pantographcompressoroff ); hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->PantCompFlag == true; } ); + return pantographUnit->pantographAir.compressorRunning == true; } ); break; } case driver_hint::pantographcompressoroff: { if( AIControllFlag ) { - pantographUnit->PantCompFlag = false; + pantographUnit->pantographAir.compressorRunning = false; } remove_hint( driver_hint::pantographcompressoron ); hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->PantCompFlag == false; } ); + return pantographUnit->pantographAir.compressorRunning == false; } ); break; } case driver_hint::pantographsvalveon: { @@ -274,7 +274,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->PantsValve.is_active == true; } ); + return pantographUnit->pantographAir.valve.is_active == true; } ); break; } case driver_hint::frontpantographvalveon: { @@ -285,7 +285,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [ this ]( float const Parameter ) { - return pantographUnit->Pantographs[VehicleEnd::front].valve.is_active == true || (Parameter > 0 && occupied->Vel > Parameter); }, + return pantographUnit->pantographs[VehicleEnd::front].valve.is_active == true || (Parameter > 0 && occupied->Vel > Parameter); }, Actionparameter ); break; } @@ -297,7 +297,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->Pantographs[VehicleEnd::front].valve.is_active == false; } ); + return pantographUnit->pantographs[VehicleEnd::front].valve.is_active == false; } ); break; } case driver_hint::rearpantographvalveon: { @@ -308,7 +308,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [ this ]( float const Parameter ) { - return pantographUnit->Pantographs[VehicleEnd::rear].valve.is_active == true || (Parameter > 0 && occupied->Vel > Parameter); }, + return pantographUnit->pantographs[VehicleEnd::rear].valve.is_active == true || (Parameter > 0 && occupied->Vel > Parameter); }, Actionparameter ); break; } @@ -320,7 +320,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->Pantographs[VehicleEnd::rear].valve.is_active == false; } ); + return pantographUnit->pantographs[VehicleEnd::rear].valve.is_active == false; } ); break; } // converter @@ -760,7 +760,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter ) hint( Action, [this](float const /*Parameter*/) { - return pantographUnit->PantPress >= (is_emu() ? (pantographUnit->PantPressLockActive ? 4.6 : 2.6) : 4.2); } ); + return pantographUnit->pantographAir.pressure >= (is_emu() ? (pantographUnit->pantographAir.pressureLockActive ? 4.6 : 2.6) : 4.2); } ); break; } case driver_hint::waitbrakecharge: { diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp index 7c956f019..21cfa1030 100644 --- a/application/driveruipanels.cpp +++ b/application/driveruipanels.cpp @@ -817,15 +817,15 @@ debug_panel::update_section_vehicle( std::vector &Output ) { STR_C("Devices: %c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%s%s\nPower transfers: %.0f@%.0f%s[%.0f]%s%.0f@%.0f :: %.0f@%.0f%s[%.0f]%s%.0f@%.0f"), // devices physics.Battery ? 'B' : '.', - physics.PantsValve.is_active ? '+' : '.', - physics.Pantographs[VehicleEnd::rear].valve.is_active ? 'O' : - physics.Pantographs[VehicleEnd::rear].valve.is_enabled ? 'o' : + physics.pantographAir.valve.is_active ? '+' : '.', + physics.pantographs[VehicleEnd::rear].valve.is_active ? 'O' : + physics.pantographs[VehicleEnd::rear].valve.is_enabled ? 'o' : '.', - physics.Pantographs[VehicleEnd::front].valve.is_active ? 'P' : - physics.Pantographs[VehicleEnd::front].valve.is_enabled ? 'p' : + physics.pantographs[VehicleEnd::front].valve.is_active ? 'P' : + physics.pantographs[VehicleEnd::front].valve.is_enabled ? 'p' : '.', - physics.PantPressLockActive ? '!' : - physics.PantPressSwitchActive ? '*' : + physics.pantographAir.pressureLockActive ? '!' : + physics.pantographAir.pressureSwitchActive ? '*' : '.', physics.WaterPump.is_active ? 'W' : false == physics.WaterPump.breaker ? '-' : @@ -951,8 +951,8 @@ debug_panel::update_section_vehicle( std::vector &Output ) { std::snprintf( m_buffer.data(), m_buffer.size(), STR_C(" pantograph: %.2f%cMT"), - physics.PantPress, - physics.bPantKurek3 ? '-' : '|' ); + physics.pantographAir.pressure, + physics.pantographAir.connectedToMainReservoir ? '-' : '|' ); textline += m_buffer.data(); } diff --git a/input/messaging.cpp b/input/messaging.cpp index f39f20962..c7950c737 100644 --- a/input/messaging.cpp +++ b/input/messaging.cpp @@ -329,7 +329,7 @@ WyslijNamiary([[maybe_unused]] TDynamicObject const *Vehicle) Vehicle->physics->ShowCurrent(p + 1); // amperomierze kolejnych grup // WriteLog("zapisalem prady"); r.iPar[30] = Vehicle->physics->WarningSignal; // trabienie - r.fPar[31] = Vehicle->physics->PantographVoltage; // napiecie WN + r.fPar[31] = Vehicle->physics->pantographCircuit.supplyVoltage; // napiecie WN // WriteLog("Parametry gotowe"); i <<= 2; // ilość bajtów r.cString[i] = char(j); // na końcu nazwa, żeby jakoś zidentyfikować diff --git a/physics/components/devices.h b/physics/components/devices.h new file mode 100644 index 000000000..4b225a27e --- /dev/null +++ b/physics/components/devices.h @@ -0,0 +1,220 @@ +/* +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 devices of a vehicle: pumps, fans, valves, pantographs, doors, the genset (nested in physics::Vehicle before) + +#pragma once + +#include +#include + +#include "physics/vehicletypes.h" + +namespace physics +{ + +/* TODO: implement + // communication cable, exchanging control signals with adjacent vehicle + struct jumper_cable { + // types + using flag_pair = std::pair; + // members + // booleans + // std::array flags {}; + // boolean pairs, exchanged data is swapped when connected to a matching end (front to front or back to back) + // TBD, TODO: convert to regular bool array for efficiency once it's working? + std::array flag_pairs {}; + // integers + // std::array values {}; + }; +*/ +// basic approximation of a generic device +// TBD: inheritance or composition? +struct basic_device +{ + // config + start_t start_type{start_t::manual}; + // ld inputs + bool is_enabled{false}; // device is allowed/requested to operate + bool is_disabled{false}; // device is requested to stop + // TODO: add remaining inputs; start conditions and potential breakers + // ld outputs + bool is_active{false}; // device is working +}; + +struct basic_light : public basic_device +{ + // config + float dimming{1.0f}; // light strength multiplier + // ld outputs + float intensity{0.0f}; // current light strength +}; + +struct cooling_fan : public basic_device +{ + // config + float speed{0.f}; // cooling fan rpm; either fraction of parent rpm, or absolute value if negative + float sustain_time{0.f}; // time of sustaining work of cooling fans after stop + float min_start_velocity{-1.f}; // minimal velocity of vehicle, when cooling fans activate + // ld outputs + float revolutions{0.f}; // current fan rpm + float stop_timer{0.f}; // current time, when shut off condition is active +}; + +// basic approximation of a fuel pump +struct fuel_pump : public basic_device +{ + // TODO: fuel consumption, optional automatic engine start after activation +}; + +// basic approximation of an oil pump +struct oil_pump : public basic_device +{ + // config + float pressure_minimum{0.f}; // lowest acceptable working pressure + float pressure_maximum{0.65f}; // oil pressure at maximum engine revolutions + // ld inputs + float resource_amount{1.f}; // amount of affected resource, compared to nominal value + // internal data + float pressure_target{0.f}; + // ld outputs + float pressure{0.f}; // current pressure +}; + +// the diesel generator set of a dual-mode vehicle: a second source of the traction circuit, next to the +// pantographs (eu07/maszyna#536). none unless the .fiz gives GensetPower +struct genset_device : public basic_device +{ + // config (Power: Genset*), revolutions in rev/s, the .fiz gives rpm + double power{0.0}; // GensetPower, electric output at full revolutions [kW]; 0 = no genset + double voltage_nominal{0.0}; // GensetVoltage, regulated DC voltage from the idle revolutions up [V] + double revolutions_idle{0.0}; // GensetIdleRPM + double revolutions_max{0.0}; // GensetMaxRPM + double start_time{8.0}; // GensetStartTime, from the start request to running at idle [s] + double spinup_time{3.0}; // GensetSpinUpTime, time constant of the revolutions [s] + double traction_share{1.0}; // GensetPmaxRatio, part of the power the traction may take + // state + double timer{0.0}; // of the start [s] + bool is_cranking{false}; + // ld outputs + double revolutions{0.0}; // [rev/s] + double voltage{0.0}; // [V] + bool fitted() const { return power > 0.0; } + // the power the genset gives at its present revolutions [kW] + double available_power() const { return revolutions_max > 0.0 ? power * std::clamp(revolutions / revolutions_max, 0.0, 1.0) : 0.0; } +}; +// basic approximation of a water pump +struct water_pump : public basic_device +{ + // ld inputs + // TODO: move to breaker list in the basic device once implemented + bool breaker{false}; // device is allowed to operate +}; + +// basic approximation of a solenoid valve +struct basic_valve : basic_device +{ + // config + bool solenoid{true}; // requires electric power to operate + bool spring{true}; // spring return or double acting actuator +}; + +// basic approximation of a pantograph +struct basic_pantograph +{ + // ld inputs + basic_valve valve; // associated pneumatic valve + // ld outputs + bool is_active{false}; // device is working + bool sound_event{false}; // indicates last state which generated sound event + double voltage{0.0}; +}; + +// basic approximation of doors +struct basic_door +{ + // config + // ld inputs + bool open_permit{false}; // door can be opened + bool local_open{false}; // local attempt to open the door + bool local_close{false}; // local attempt to close the door + bool remote_open{false}; // received remote signal to open the door + bool remote_close{false}; // received remote signal to close the door + // internal data + float auto_timer{-1.f}; // delay between activation of open state and closing state for automatic doors + float close_delay{0.f}; // delay between activation of closing state and actual closing + float open_delay{0.f}; // delay between activation of opening state and actual opening + float position{0.f}; // current shift of the door from the closed position + float step_position{0.f}; // current shift of the movable step from the retracted position + // ld outputs + bool is_closed{true}; // the door is fully closed + bool is_door_closed{true}; // the door is fully closed, step doesn't matter + bool is_closing{false}; // the door is currently closing + bool is_opening{false}; // the door is currently opening + bool is_open{false}; // the door is fully open + bool step_folding{false}; // the doorstep is currently closing + bool step_unfolding{false}; // the doorstep is currently opening +}; + +struct door_data +{ + // config + control_t open_control{control_t::passenger}; + float open_rate{1.f}; + float open_delay{0.f}; + control_t close_control{control_t::passenger}; + float close_rate{1.f}; + float close_delay{0.f}; + int type{2}; + float range{0.f}; // extent of primary move/rotation + float range_out{0.f}; // extent of shift outward, applicable for plug doors + int step_type{2}; + float step_rate{0.5f}; + float step_range{0.f}; + bool has_lock{false}; + bool has_warning{false}; + bool has_autowarning{false}; + float auto_duration{-1.f}; // automatic door closure delay period + float auto_velocity{-1.f}; // automatic door closure velocity threshold + bool auto_include_remote{false}; // automatic door closure applies also to remote control + bool permit_needed{false}; + bool closure_signal{false}; // the door closure lamp (SOD) of the cab signals the doors of the whole consist in three states + std::vector permit_presets; // permit presets selectable with preset switch + float voltage{0.f}; // power type required for door movement + // ld inputs + bool lock_enabled{true}; + bool step_enabled{true}; + bool remote_only{false}; // door ignores local control signals + // internal data + int permit_preset{-1}; // curent position of preset selection switch + // vehicle parts + BySide instances; // door on the right and left side of the vehicle + // ld outputs + bool is_locked{false}; + double doorLockSpeed = 10.0; // predkosc przy ktorej wyzwalana jest blokada drzwi +}; + +struct water_heater +{ + // config + struct heater_config_t + { + float temp_min{-1}; // lowest accepted temperature + float temp_max{-1}; // highest accepted temperature + }; + heater_config_t config; + // ld inputs + bool breaker{false}; // device is allowed to operate + bool is_enabled{false}; // device is requested to operate + // ld outputs + bool is_active{false}; // device is working + bool is_damaged{false}; // device is damaged +}; + +} // namespace physics diff --git a/physics/components/drive.cpp b/physics/components/drive.cpp index c1f64738e..b58e97963 100644 --- a/physics/components/drive.cpp +++ b/physics/components/drive.cpp @@ -259,7 +259,7 @@ public: void CheckVoltageRelays(physics::Vehicle &vehicle) const override { // update the state of voltage relays - auto const voltage{std::max(vehicle.GetTrainsetHighVoltage(), vehicle.PantographVoltage)}; + auto const voltage{std::max(vehicle.GetTrainsetHighVoltage(), vehicle.pantographCircuit.supplyVoltage)}; // where the line breaker holds without voltage (closed ahead of the pantographs) the undervoltage relay opens the // line contactors instead, see MotorConnectorsCheck(). it picks up again only with the master controller back // where a start begins, as the line breaker it stands in for wouldn't close on a running position either: at diff --git a/physics/components/electrics.cpp b/physics/components/electrics.cpp index c33e2e0c8..7e050f4f1 100644 --- a/physics/components/electrics.cpp +++ b/physics/components/electrics.cpp @@ -37,11 +37,11 @@ void physics::Vehicle::UpdatePantVolume(double dt) // check the pantograph compressor while at it // TODO: move the check to a separate method // automatic start if the pressure is too low - PantCompFlag |= PantPress < 4.2 && true == (Pantographs[VehicleEnd::front].is_active | Pantographs[VehicleEnd::rear].is_active) // TODO: any_pantograph_is_active method - && (PantographCompressorStart == start_t::automatic || PantographCompressorStart == start_t::manualwithautofallback); + pantographAir.compressorRunning |= pantographAir.pressure < 4.2 && true == (pantographs[VehicleEnd::front].is_active | pantographs[VehicleEnd::rear].is_active) // TODO: any_pantograph_is_active method + && (pantographAir.compressorStart == start_t::automatic || pantographAir.compressorStart == start_t::manualwithautofallback); auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable}; - PantCompFlag &= lowvoltagepower; + pantographAir.compressorRunning &= lowvoltagepower; if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector // tylko jeśli pantografujący && EnginePowerSource.CollectorParameters.CollectorsNo > 0) @@ -50,33 +50,33 @@ void physics::Vehicle::UpdatePantVolume(double dt) // Ra 2014-07: kurek trójdrogowy łączy spr.pom. z pantografami i wyłącznikiem ciśnieniowym WS // Ra 2014-07: zbiornika rozrządu nie pompuje się tu, tylko pantografy; potem można zamknąć // WS i odpalić resztę - if (PantAutoValve ? PantPress < mainPipe.pressure : bPantKurek3) // kurek zamyka połączenie z ZG + if (pantographAir.autoValve ? pantographAir.pressure < mainPipe.pressure : pantographAir.connectedToMainReservoir) // kurek zamyka połączenie z ZG { // zbiornik pantografu połączony ze zbiornikiem głównym - małą sprężarką się tego nie napompuje // Ra 2013-12: Niebugocław mówi, że w EZT nie ma potrzeby odcinać kurkiem - PantPress = mainPipe.pressure; + pantographAir.pressure = mainPipe.pressure; // ograniczenie ciśnienia do MaxPress (tylko w pantografach!) - PantPress = safe_clamp(mainPipe.pressure, 0.0, EnginePowerSource.CollectorParameters.MaxPress); - PantVolume = (PantPress + 1.0) * 0.1; // objętość, na wypadek odcięcia kurkiem + pantographAir.pressure = safe_clamp(mainPipe.pressure, 0.0, EnginePowerSource.CollectorParameters.MaxPress); + pantographAir.volume = (pantographAir.pressure + 1.0) * 0.1; // objętość, na wypadek odcięcia kurkiem } else { // zbiornik główny odcięty, można pompować pantografy - if (PantCompFlag) + if (pantographAir.compressorRunning) { // włączona mała sprężarka - PantVolume += dt + pantographAir.volume += dt // Ra 2013-12: Niebugocław mówi, że w EZT nabija 1.5 raz wolniej niż jak było 0.005 - * (TrainType == train_type::emu ? 0.003 : 0.005) / std::max(1.0, PantPress) * (0.45 - (0.1 / PantVolume / 10 - 0.1)) / 0.45; + * (TrainType == train_type::emu ? 0.003 : 0.005) / std::max(1.0, pantographAir.pressure) * (0.45 - (0.1 / pantographAir.volume / 10 - 0.1)) / 0.45; } - PantPress = safe_clamp(10.0 * PantVolume - 1.0, 0.0, EnginePowerSource.CollectorParameters.MaxPress); // tu by się przydała objętość zbiornika + pantographAir.pressure = safe_clamp(10.0 * pantographAir.volume - 1.0, 0.0, EnginePowerSource.CollectorParameters.MaxPress); // tu by się przydała objętość zbiornika } - if (!PantCompFlag && PantVolume > 0.1) - PantVolume -= dt * 0.0003 * std::max(1.0, PantPress * 0.5); // nieszczelności: 0.0003=0.3l/s + if (!pantographAir.compressorRunning && pantographAir.volume > 0.1) + pantographAir.volume -= dt * 0.0003 * std::max(1.0, pantographAir.pressure * 0.5); // nieszczelności: 0.0003=0.3l/s PantPressureSwitchCheck(); } else { // a tu coś dla SM42 i SM31, aby pokazywać na manometrze - PantPress = brakes.controlReservoirPressure; + pantographAir.pressure = brakes.controlReservoirPressure; } }; @@ -84,31 +84,31 @@ void physics::Vehicle::UpdatePantVolume(double dt) // primed again over 4.6 bar, where the pantographs' compressor stops at 4.8 void physics::Vehicle::PantPressureSwitchCheck() { - if (PantPress < EnginePowerSource.CollectorParameters.MinPress) + if (pantographAir.pressure < EnginePowerSource.CollectorParameters.MinPress) { // 3.5 wg http://www.transportszynowy.pl/eu06-07pneumat.php - if (true == PantPressSwitchActive) + if (true == pantographAir.pressureSwitchActive) { PantPressureSwitchTrip(); } } - else if (PantPress >= 4.6) + else if (pantographAir.pressure >= 4.6) { // NOTE: we require active low power source to prime the pressure switch // this is a work-around for potential isssues caused by the switch activating on otherwise idle vehicles, but should check whether it's accurate if (true == Power24vIsAvailable || true == Power110vIsAvailable) { // prime the pressure switch - PantPressSwitchActive = true; + pantographAir.pressureSwitchActive = true; // turn off the subsystems lock - PantPressLockActive = false; + pantographAir.pressureLockActive = false; } - if (PantPress >= 4.8) + if (pantographAir.pressure >= 4.8) { // Winger - automatyczne wylaczanie malej sprezarki // TODO: governor lock, disables usage until pressure drop below 3.8 (should really make compressor object we could reuse) - PantCompFlag = false; + pantographAir.compressorRunning = false; } } } @@ -132,12 +132,12 @@ void physics::Vehicle::PantPressureSwitchTrip() { // specialized variant for EMU -- pwr system disables converter and heating, // and prevents their activation until pressure switch is set again - PantPressLockActive = true; + pantographAir.pressureLockActive = true; // TODO: separate 'heating allowed' from actual heating flag, so we can disable it here without messing up heating toggle ConverterSwitch(false, range_t::unit); } // mark the pressure switch as spent - PantPressSwitchActive = false; + pantographAir.pressureSwitchActive = false; } void physics::Vehicle::UpdateBatteryVoltage(double dt) @@ -223,7 +223,7 @@ double physics::Vehicle::BatteryDrainLow(double dt, bool const converteractive) double sn3; double sn4; double sn5; - if (PantCompFlag) + if (pantographAir.compressorRunning) sn1 = dt * 0.0046; else sn1 = 0; @@ -276,7 +276,7 @@ void physics::Vehicle::MainsCheck(double const Deltatime) { case TPowerSource::CurrentCollector: { - localvoltage = std::max(localvoltage, PantographVoltage); + localvoltage = std::max(localvoltage, pantographCircuit.supplyVoltage); break; } case TPowerSource::Accumulator: @@ -405,7 +405,7 @@ double physics::Vehicle::LocalPowerVoltage(Coupling const kind) } case TPowerSource::CurrentCollector: { - localvoltage = PantographVoltage; + localvoltage = pantographCircuit.supplyVoltage; break; } case TPowerSource::Main: @@ -620,7 +620,7 @@ void physics::Vehicle::ConverterCheck(double const Timestep) } if (ConverterAllow && ConverterAllowLocal && false == ConvOvldFlag && - false == PantPressLockActive + false == pantographAir.pressureLockActive // HACK: allow carriages to operate converter without (missing) fuse prerequisite && (Power > 1.0 ? MainCircuitPowered() : GetTrainsetHighVoltage() > 0.0)) { @@ -694,7 +694,7 @@ void physics::Vehicle::HeatingCheck(double const /*Timestep*/) } case TPowerSource::CurrentCollector: { - voltage = PantographVoltage; + voltage = pantographCircuit.supplyVoltage; break; } case TPowerSource::PowerCable: @@ -730,12 +730,12 @@ void physics::Vehicle::PantographsCheck(double const /*Timestep*/) using enum start_t; { - auto const &valve{PantsValve}; + auto const &valve{pantographAir.valve}; auto const lowvoltagepower{valve.solenoid ? Power24vIsAvailable || Power110vIsAvailable : true}; auto const autostart{valve.start_type == automatic || valve.start_type == manualwithautofallback}; auto const manualcontrol{valve.start_type == manual || valve.start_type == manualwithautofallback}; - PantsValve.is_active = (valve.spring ? lowvoltagepower : true) // spring actuator needs power to maintain non-default state + pantographAir.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 && (valve.is_active || (autostart ? lowvoltagepower : !autostart ? lowvoltagepower && valve.is_enabled : @@ -743,7 +743,7 @@ void physics::Vehicle::PantographsCheck(double const /*Timestep*/) } size_t pant_id = 0; - for (auto &pantograph : Pantographs) + for (auto &pantograph : pantographs) { auto &valve{pantograph.valve}; @@ -753,13 +753,13 @@ 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 == PantAllDown : true) && + && (manualcontrol && lowvoltagepower ? false == pantographCircuit.allDown : true) && (Mains || false == PantographsRequireMains) // 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}; - pantograph.is_active = valve.is_active && PantsValve.is_active && pantographexists; + pantograph.is_active = valve.is_active && pantographAir.valve.is_active && pantographexists; pant_id++; } @@ -1069,7 +1069,7 @@ bool physics::Vehicle::GensetSwitch(bool const State, range_t const Notify) // genset of a dual-mode vehicle double physics::Vehicle::TractionSourceVoltage() const { - return GensetSelected() ? Genset.voltage : PantographVoltage; + return GensetSelected() ? Genset.voltage : pantographCircuit.supplyVoltage; } // the voltage the traction circuit gets: from the vehicle's own source, or through the train's high voltage line @@ -1137,7 +1137,7 @@ bool physics::Vehicle::OperatePantographsValve(operation_t const State, range_t if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0) { - auto &valve{PantsValve}; + auto &valve{pantographAir.valve}; switch (State) { @@ -1197,7 +1197,7 @@ bool physics::Vehicle::OperatePantographValve(VehicleEnd const End, operation_t if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.CollectorsNo > 0) { - auto &valve{Pantographs[End].valve}; + auto &valve{pantographs[End].valve}; switch (State) { @@ -1258,9 +1258,9 @@ bool physics::Vehicle::OperatePantographValve(VehicleEnd const End, operation_t bool physics::Vehicle::DropAllPantographs(bool const State, range_t const Notify) { - auto const initialstate{PantAllDown}; + auto const initialstate{pantographCircuit.allDown}; - PantAllDown = State; + pantographCircuit.allDown = State; if (Notify != range_t::local) { diff --git a/physics/components/fizsections.cpp b/physics/components/fizsections.cpp index 8eff86951..35d561f23 100644 --- a/physics/components/fizsections.cpp +++ b/physics/components/fizsections.cpp @@ -938,16 +938,16 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) // pantograph compressor { auto lookup = starts.find(extract_value("PantCompressorStart", line)); - PantographCompressorStart = lookup != starts.end() ? lookup->second : manual; + pantographAir.compressorStart = lookup != starts.end() ? lookup->second : manual; } // pantograph compressor valve - PantAutoValve = TrainType == train_type::emu; // legacy code behaviour, automatic valve was initially installed in all EMUs - extract_value(PantAutoValve, "PantAutoValve", line, ""); + pantographAir.autoValve = TrainType == train_type::emu; // legacy code behaviour, automatic valve was initially installed in all EMUs + extract_value(pantographAir.autoValve, "PantAutoValve", line, ""); // pantographs valve { auto lookup = starts.find(extract_value("PantEPValveStart", line)); - PantsValve.start_type = lookup != starts.end() ? lookup->second : automatic; // legacy code behaviour, there was no pantographs valve - extract_value(PantsValve.spring, "PantEPValveSpring", line, ""); + pantographAir.valve.start_type = lookup != starts.end() ? lookup->second : automatic; // legacy code behaviour, there was no pantographs valve + extract_value(pantographAir.valve.spring, "PantEPValveSpring", line, ""); } // pantograph valve configuration { @@ -957,7 +957,7 @@ void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line) extract_value(valvespring, "PantValveSpring", line, ""); auto valvesolenoid{true}; extract_value(valvesolenoid, "PantValveSolenoid", line, ""); - for (auto &pantograph : Pantographs) + for (auto &pantograph : pantographs) { pantograph.valve.spring = valvespring; pantograph.valve.solenoid = valvesolenoid; @@ -1468,12 +1468,12 @@ void physics::Vehicle::LoadFIZ_EngineDieselShared(std::string const &Input) void physics::Vehicle::LoadFIZ_Switches(std::string const &Input) { - extract_value(PantSwitchType, "Pantograph", Input, ""); + extract_value(pantographCircuit.switchType, "Pantograph", Input, ""); extract_value(ConvSwitchType, "Converter", Input, ""); extract_value(StLinSwitchType, "MotorConnectors", Input, ""); HeatingSwitchImpulse = ToLower(extract_value("TrainHeating", Input)) == "impulse"; // because people can't make up their minds whether it's "impulse" or "Impulse"... - PantSwitchType = ToLower(PantSwitchType); + pantographCircuit.switchType = ToLower(pantographCircuit.switchType); ConvSwitchType = ToLower(ConvSwitchType); StLinSwitchType = ToLower(StLinSwitchType); // universal reset buttons assignments @@ -1483,7 +1483,7 @@ void physics::Vehicle::LoadFIZ_Switches(std::string const &Input) extract_value(enableModernDimmer, "ModernDimmer", Input, ""); // pantograph presets { - auto &presets{PantsPreset.first}; + auto &presets{pantographCircuit.presets.first}; extract_value(presets, "PantographPresets", Input, "0|1|3|2"); std::erase(presets, '|'); } diff --git a/physics/components/pantographs.h b/physics/components/pantographs.h new file mode 100644 index 000000000..e4ee98505 --- /dev/null +++ b/physics/components/pantographs.h @@ -0,0 +1,50 @@ +/* +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 circuit and the air of the pantographs of a vehicle, held by physics::Vehicle as pantographCircuit and +// pantographAir beside its pantographs + +#pragma once + +#include +#include + +#include "physics/components/devices.h" + +namespace physics +{ + +// the circuit of the pantographs: their voltages, the kind of their switches, the presets of the cabs +struct PantographCircuit +{ + double frontVoltage = 0.0; // the voltage at the front pantograph + double rearVoltage = 0.0; // the voltage at the rear one + double supplyVoltage{0.0}; // the voltage supplied to the pantographs + bool allDown{false}; // the switch that lowers all of them + std::string switchType; // PantSwitchType: the kind of the switches of the cab + // the presets of the pantographs: the setups they can be switched to as chars, and the one selected in each cab + std::pair> presets{"0132", {0, 0}}; +}; + +// the air of the pantographs: their reservoir, the small compressor that fills it, the valves +struct PantographAir +{ + double volume = 0.48; // so that the raised pantographs drop soon with the compressor off + double pressure = 0.0; // in the reservoirs of the pantographs + bool compressorRunning = false; // the small compressor + start_t compressorStart{start_t::manual}; // PantCompressorStart + int compressorPower = 0; // SmallCompressorPower + basic_valve valve; + bool connectedToMainReservoir = true; // the three-way cock: to the main reservoir, or to the small compressor + bool autoValve{false}; // the kind of the valve of the small compressor fitted + bool pressureSwitchActive{false}; // the pressure switch, primed at the pressure set in the air of the pantographs + bool pressureLockActive{false}; // fires when the pressure switch trips by the pressure dropping below its level +}; + +} // namespace physics diff --git a/physics/vehicle.h b/physics/vehicle.h index b1016e644..183e55b9e 100644 --- a/physics/vehicle.h +++ b/physics/vehicle.h @@ -26,6 +26,8 @@ http://mozilla.org/MPL/2.0/. #include "physics/components/inductionmotor.h" #include "physics/components/braking.h" #include "physics/components/airsupply.h" +#include "physics/components/devices.h" +#include "physics/components/pantographs.h" class TractionDrive; @@ -615,206 +617,6 @@ namespace physics class Vehicle { // Ra: wrapper na kod pascalowy, przejmujący jego funkcje Q: 20160824 - juz nie wrapper a klasa bazowa :) - private: - // types - /* TODO: implement - // communication cable, exchanging control signals with adjacent vehicle - struct jumper_cable { - // types - using flag_pair = std::pair; - // members - // booleans - // std::array flags {}; - // boolean pairs, exchanged data is swapped when connected to a matching end (front to front or back to back) - // TBD, TODO: convert to regular bool array for efficiency once it's working? - std::array flag_pairs {}; - // integers - // std::array values {}; - }; - */ - // basic approximation of a generic device - // TBD: inheritance or composition? - struct basic_device - { - // config - start_t start_type{start_t::manual}; - // ld inputs - bool is_enabled{false}; // device is allowed/requested to operate - bool is_disabled{false}; // device is requested to stop - // TODO: add remaining inputs; start conditions and potential breakers - // ld outputs - bool is_active{false}; // device is working - }; - - struct basic_light : public basic_device - { - // config - float dimming{1.0f}; // light strength multiplier - // ld outputs - float intensity{0.0f}; // current light strength - }; - - struct cooling_fan : public basic_device - { - // config - float speed{0.f}; // cooling fan rpm; either fraction of parent rpm, or absolute value if negative - float sustain_time{0.f}; // time of sustaining work of cooling fans after stop - float min_start_velocity{-1.f}; // minimal velocity of vehicle, when cooling fans activate - // ld outputs - float revolutions{0.f}; // current fan rpm - float stop_timer{0.f}; // current time, when shut off condition is active - }; - - // basic approximation of a fuel pump - struct fuel_pump : public basic_device - { - // TODO: fuel consumption, optional automatic engine start after activation - }; - - // basic approximation of an oil pump - struct oil_pump : public basic_device - { - // config - float pressure_minimum{0.f}; // lowest acceptable working pressure - float pressure_maximum{0.65f}; // oil pressure at maximum engine revolutions - // ld inputs - float resource_amount{1.f}; // amount of affected resource, compared to nominal value - // internal data - float pressure_target{0.f}; - // ld outputs - float pressure{0.f}; // current pressure - }; - - // the diesel generator set of a dual-mode vehicle: a second source of the traction circuit, next to the - // pantographs (eu07/maszyna#536). none unless the .fiz gives GensetPower - struct genset_device : public basic_device - { - // config (Power: Genset*), revolutions in rev/s, the .fiz gives rpm - double power{0.0}; // GensetPower, electric output at full revolutions [kW]; 0 = no genset - double voltage_nominal{0.0}; // GensetVoltage, regulated DC voltage from the idle revolutions up [V] - double revolutions_idle{0.0}; // GensetIdleRPM - double revolutions_max{0.0}; // GensetMaxRPM - double start_time{8.0}; // GensetStartTime, from the start request to running at idle [s] - double spinup_time{3.0}; // GensetSpinUpTime, time constant of the revolutions [s] - double traction_share{1.0}; // GensetPmaxRatio, part of the power the traction may take - // state - double timer{0.0}; // of the start [s] - bool is_cranking{false}; - // ld outputs - double revolutions{0.0}; // [rev/s] - double voltage{0.0}; // [V] - bool fitted() const { return power > 0.0; } - // the power the genset gives at its present revolutions [kW] - double available_power() const { return revolutions_max > 0.0 ? power * std::clamp(revolutions / revolutions_max, 0.0, 1.0) : 0.0; } - }; - // basic approximation of a water pump - struct water_pump : public basic_device - { - // ld inputs - // TODO: move to breaker list in the basic device once implemented - bool breaker{false}; // device is allowed to operate - }; - - // basic approximation of a solenoid valve - struct basic_valve : basic_device - { - // config - bool solenoid{true}; // requires electric power to operate - bool spring{true}; // spring return or double acting actuator - }; - - // basic approximation of a pantograph - struct basic_pantograph - { - // ld inputs - basic_valve valve; // associated pneumatic valve - // ld outputs - bool is_active{false}; // device is working - bool sound_event{false}; // indicates last state which generated sound event - double voltage{0.0}; - }; - - // basic approximation of doors - struct basic_door - { - // config - // ld inputs - bool open_permit{false}; // door can be opened - bool local_open{false}; // local attempt to open the door - bool local_close{false}; // local attempt to close the door - bool remote_open{false}; // received remote signal to open the door - bool remote_close{false}; // received remote signal to close the door - // internal data - float auto_timer{-1.f}; // delay between activation of open state and closing state for automatic doors - float close_delay{0.f}; // delay between activation of closing state and actual closing - float open_delay{0.f}; // delay between activation of opening state and actual opening - float position{0.f}; // current shift of the door from the closed position - float step_position{0.f}; // current shift of the movable step from the retracted position - // ld outputs - bool is_closed{true}; // the door is fully closed - bool is_door_closed{true}; // the door is fully closed, step doesn't matter - bool is_closing{false}; // the door is currently closing - bool is_opening{false}; // the door is currently opening - bool is_open{false}; // the door is fully open - bool step_folding{false}; // the doorstep is currently closing - bool step_unfolding{false}; // the doorstep is currently opening - }; - - struct door_data - { - // config - control_t open_control{control_t::passenger}; - float open_rate{1.f}; - float open_delay{0.f}; - control_t close_control{control_t::passenger}; - float close_rate{1.f}; - float close_delay{0.f}; - int type{2}; - float range{0.f}; // extent of primary move/rotation - float range_out{0.f}; // extent of shift outward, applicable for plug doors - int step_type{2}; - float step_rate{0.5f}; - float step_range{0.f}; - bool has_lock{false}; - bool has_warning{false}; - bool has_autowarning{false}; - float auto_duration{-1.f}; // automatic door closure delay period - float auto_velocity{-1.f}; // automatic door closure velocity threshold - bool auto_include_remote{false}; // automatic door closure applies also to remote control - bool permit_needed{false}; - bool closure_signal{false}; // the door closure lamp (SOD) of the cab signals the doors of the whole consist in three states - std::vector permit_presets; // permit presets selectable with preset switch - float voltage{0.f}; // power type required for door movement - // ld inputs - bool lock_enabled{true}; - bool step_enabled{true}; - bool remote_only{false}; // door ignores local control signals - // internal data - int permit_preset{-1}; // curent position of preset selection switch - // vehicle parts - BySide instances; // door on the right and left side of the vehicle - // ld outputs - bool is_locked{false}; - double doorLockSpeed = 10.0; // predkosc przy ktorej wyzwalana jest blokada drzwi - }; - - struct water_heater - { - // config - struct heater_config_t - { - float temp_min{-1}; // lowest accepted temperature - float temp_max{-1}; // highest accepted temperature - }; - heater_config_t config; - // ld inputs - bool breaker{false}; // device is allowed to operate - bool is_enabled{false}; // device is requested to operate - // ld outputs - bool is_active{false}; // device is working - bool is_damaged{false}; // device is damaged - }; - public: std::string chkPath; bool reload_FIZ(); @@ -878,6 +680,9 @@ class Vehicle int wiperSwitchPos = 0; // pozycja przelacznika wycieraczek double WiperAngle = {45.0}; // kat pracy wycieraczek + ByEnd pantographs; + PantographCircuit pantographCircuit; // their voltages, switches, presets (physics/components/pantographs.h) + PantographAir pantographAir; // their reservoir, the small compressor, the valves TrainPipe brakePipe; // the brake pipe along the train TrainPipe mainPipe; // the main reservoir pipe along the train AirSupply air; // the compressor and the main reservoir (physics/components/airsupply.h) @@ -925,7 +730,6 @@ class Vehicle // 5% steps of the 6Dg), one at once when moved to a raising or lowering position, then one each time its SpeedUp / SpeedDown // covers a step; 0 (the default) changes it continuously double UniCtrlValStep{0.0}; - std::pair> PantsPreset{"0132", {0, 0}}; // pantograph preset switches; .first holds possible setups as chars, .second holds currently selected preset in each cab /*-sekcja parametrow dla lokomotywy elektrycznej*/ TSchemeTable RList; /*lista rezystorow rozruchowych i polaczen silnikow, dla dizla: napelnienia*/ @@ -1013,7 +817,6 @@ class Vehicle double RVentSpeed{0.5}; // rozpedzanie sie wentylatora obr/s^2} double RVentMinI{50.0}; // przy jakim pradzie sie wylaczaja} bool RVentForceOn{false}; // forced activation switch - int SmallCompressorPower = 0; /*Winger ZROBIC*/ bool Trafo = false; /*pojazd wyposażony w transformator*/ // the diesel engine, its torque converter and its retarder (physics/components/dieselengine.h) @@ -1149,14 +952,6 @@ class Vehicle bool SandDoseAutoAllow = true; /*zezwolenie na automatyczne piaskowanie*/ double Sand = 0.0; /*ilosc piasku*/ /*! przyrosty cisnienia w kroku czasowym*/ - double PantVolume = 0.48; /*objetosc spr. powietrza w ukl. pantografu*/ // aby podniesione pantografy opadły w krótkim czasie przy wyłączonej sprężarce - bool PantCompFlag = false; /*!o czy wlaczona sprezarka pantografow*/ - start_t PantographCompressorStart{start_t::manual}; - basic_valve PantsValve; - ByEnd Pantographs; - bool PantAllDown{false}; - double PantFrontVolt = 0.0; // pantograf pod napieciem? 'Winger 160404 - double PantRearVolt = 0.0; // 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 @@ -1297,10 +1092,6 @@ class Vehicle 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*/ - double PantographVoltage{0.0}; // voltage supplied to pantographs - double PantPress = 0.0; /*Cisnienie w zbiornikach pantografow*/ - bool PantPressSwitchActive{false}; // state of the pantograph pressure switch. gets primed at defined pressure level in pantograph air system - bool PantPressLockActive{false}; // pwr system state flag. fires when pressure switch activates by pantograph pressure dropping below defined level // 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}; @@ -1349,7 +1140,6 @@ class Vehicle 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 PantSwitchType; std::string ConvSwitchType; bool HeatingSwitchImpulse{false}; // the train heating switch springs back to its middle position std::string StLinSwitchType; @@ -1376,8 +1166,6 @@ class Vehicle double FrictConst2d = 0.0; double TotalMassxg = 0.0; /*TotalMass*g*/ - bool bPantKurek3 = true; // kurek trójdrogowy (pantografu): true=połączenie z ZG, false=połączenie z małą sprężarką // domyślnie zbiornik pantografu połączony jest ze zbiornikiem głównym - bool PantAutoValve{false}; // type of installed pantograph compressor valve int iProblem = 0; // flagi problemów z taborem, aby AI nie musiało porównywać; 0=może jechać ByEnd iLights; // bity zapalonych świateł tutaj, żeby dało się liczyć pobór prądu diff --git a/simulation/blackboxrecorder.cpp b/simulation/blackboxrecorder.cpp index e7821ddb6..3d95510c5 100644 --- a/simulation/blackboxrecorder.cpp +++ b/simulation/blackboxrecorder.cpp @@ -74,7 +74,7 @@ std::uint32_t devices_of(physics::Vehicle const &Occupied, physics::Vehicle cons 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) | - on(Controlling.Pantographs[VehicleEnd::front].is_active, device::pantograph_front) | on(Controlling.Pantographs[VehicleEnd::rear].is_active, device::pantograph_rear) | + 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.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) | diff --git a/tests/unit/drive.cpp b/tests/unit/drive.cpp index 08868a7a1..de9736557 100644 --- a/tests/unit/drive.cpp +++ b/tests/unit/drive.cpp @@ -108,14 +108,14 @@ void prepare_diesel(driven const &Driven) { // the pantographs' own air topped up by their compressor, and the pantographs raised void raise_pantographs(driven const &Driven) { auto &pantographs{Driven.pantographs}; - if (auto const enough{(pantographs.TrainType == train_type::emu ? 2.5 : 3.5) + 0.1}; pantographs.PantPress < enough) { - if (false == pantographs.PantAutoValve) { - pantographs.bPantKurek3 = false; // the pantographs on their own air + if (auto const enough{(pantographs.TrainType == train_type::emu ? 2.5 : 3.5) + 0.1}; pantographs.pantographAir.pressure < enough) { + if (false == pantographs.pantographAir.autoValve) { + pantographs.pantographAir.connectedToMainReservoir = false; // the pantographs on their own air } - pantographs.PantCompFlag = true; + pantographs.pantographAir.compressorRunning = true; } - else if (false == pantographs.bPantKurek3 || pantographs.PantPress <= pantographs.mainPipe.pressure) { - pantographs.PantCompFlag = false; + else if (false == pantographs.pantographAir.connectedToMainReservoir || pantographs.pantographAir.pressure <= pantographs.mainPipe.pressure) { + pantographs.pantographAir.compressorRunning = false; } Driven.cab.OperatePantographsValve(operation_t::enable); Driven.cab.OperatePantographValve(VehicleEnd::rear, operation_t::enable); @@ -184,7 +184,7 @@ bool start_up(driven Driven, track const &Track, double Seconds, trace *Trace) { if (collector) { raise_pantographs(Driven); } - if (false == collector || std::max(controlling.GetTrainsetHighVoltage(), controlling.PantographVoltage) > controlling.EnginePowerSource.CollectorParameters.MinV) { + if (false == collector || std::max(controlling.GetTrainsetHighVoltage(), controlling.pantographCircuit.supplyVoltage) > controlling.EnginePowerSource.CollectorParameters.MinV) { // a direction first, as in TController::PrepareDirection(): the relays reset only with one set for (int i = 0; i < 3 && cab.DirActive <= 0; ++i) { cab.DirectionForward(); diff --git a/tests/unit/golden.cpp b/tests/unit/golden.cpp index a011fb0a5..d668592c0 100644 --- a/tests/unit/golden.cpp +++ b/tests/unit/golden.cpp @@ -189,7 +189,7 @@ std::vector parameters() { {"Imax", [](auto const &M) { return M.Imax; }}, {"EIMCtrlType", [](auto const &M) { return M.EIMCtrlType; }}, {"Volume", [](auto const &M) { return M.brakes.reservoirAir; }}, - {"PantVolume", [](auto const &M) { return M.PantVolume; }}, + {"PantVolume", [](auto const &M) { return M.pantographAir.volume; }}, }; for (int i = 0; i < 5; ++i) { result.emplace_back(std::format("MaxBrakePress{}", i), [i](auto const &M) { return M.brakes.maxCylinderPressure[i]; }); diff --git a/tests/unit/test_auxiliaries.cpp b/tests/unit/test_auxiliaries.cpp index 4da5c1f51..66702750b 100644 --- a/tests/unit/test_auxiliaries.cpp +++ b/tests/unit/test_auxiliaries.cpp @@ -18,11 +18,11 @@ std::vector auxiliaries() { {"Battery", [](auto const &M) { return M.Battery ? 1.0 : 0.0; }}, {"ConverterFlag", [](auto const &M) { return M.ConverterFlag ? 1.0 : 0.0; }}, {"Power110vIsAvailable", [](auto const &M) { return M.Power110vIsAvailable ? 1.0 : 0.0; }}, - {"PantPress", [](auto const &M) { return M.PantPress; }}, - {"PantVolume", [](auto const &M) { return M.PantVolume; }}, - {"PantCompFlag", [](auto const &M) { return M.PantCompFlag ? 1.0 : 0.0; }}, - {"PantPressSwitchActive", [](auto const &M) { return M.PantPressSwitchActive ? 1.0 : 0.0; }}, - {"PantPressLockActive", [](auto const &M) { return M.PantPressLockActive ? 1.0 : 0.0; }}, + {"PantPress", [](auto const &M) { return M.pantographAir.pressure; }}, + {"PantVolume", [](auto const &M) { return M.pantographAir.volume; }}, + {"PantCompFlag", [](auto const &M) { return M.pantographAir.compressorRunning ? 1.0 : 0.0; }}, + {"PantPressSwitchActive", [](auto const &M) { return M.pantographAir.pressureSwitchActive ? 1.0 : 0.0; }}, + {"PantPressLockActive", [](auto const &M) { return M.pantographAir.pressureLockActive ? 1.0 : 0.0; }}, }; } @@ -40,7 +40,7 @@ TEST_CASE("auxiliaries: the battery drained by the lights and the pantographs' c eu07.ConverterSwitch(false); eu07.iLights[VehicleEnd::front] = 1 | 2 | 4; eu07.iLights[VehicleEnd::rear] = 16; - eu07.PantCompFlag = true; + eu07.pantographAir.compressorRunning = true; scenario.wait(30.0); CHECK(eu07.BatteryVoltage < 0.83 * eu07.NominalBatteryVoltage); CHECK(eu07.Mains); @@ -90,23 +90,23 @@ TEST_CASE("auxiliaries: the pantographs on their own tank, leaking until the pre auto &eu07{scenario.cab()}; // started up on the small compressor, the tank gets joined to the main reservoir, which primes the switch scenario.act("tank joined to the main reservoir"); - eu07.bPantKurek3 = true; + eu07.pantographAir.connectedToMainReservoir = true; scenario.wait(30.0); - REQUIRE(eu07.PantPressSwitchActive); + REQUIRE(eu07.pantographAir.pressureSwitchActive); scenario.act("tank cut off the main reservoir"); - eu07.bPantKurek3 = false; - eu07.PantCompFlag = false; + eu07.pantographAir.connectedToMainReservoir = false; + eu07.pantographAir.compressorRunning = false; scenario.wait(600.0); - CHECK(eu07.PantPress < eu07.EnginePowerSource.CollectorParameters.MinPress); - CHECK_FALSE(eu07.PantPressSwitchActive); + CHECK(eu07.pantographAir.pressure < eu07.EnginePowerSource.CollectorParameters.MinPress); + CHECK_FALSE(eu07.pantographAir.pressureSwitchActive); CHECK_FALSE(eu07.Mains); scenario.act("small compressor on"); - eu07.PantCompFlag = true; - for (int i = 0; i < 60 && eu07.PantCompFlag; ++i) { + eu07.pantographAir.compressorRunning = true; + for (int i = 0; i < 60 && eu07.pantographAir.compressorRunning; ++i) { scenario.wait(10.0); } - CHECK_FALSE(eu07.PantCompFlag); - CHECK(eu07.PantPress >= 4.6); // stopped at 4.8, leaking since - CHECK(eu07.PantPressSwitchActive); + CHECK_FALSE(eu07.pantographAir.compressorRunning); + CHECK(eu07.pantographAir.pressure >= 4.6); // stopped at 4.8, leaking since + CHECK(eu07.pantographAir.pressureSwitchActive); scenario.check(); } diff --git a/tests/unit/test_commands.cpp b/tests/unit/test_commands.cpp index 702e81ae1..859f73336 100644 --- a/tests/unit/test_commands.cpp +++ b/tests/unit/test_commands.cpp @@ -61,7 +61,7 @@ std::vector state() { {"DoorStep", [](auto const &M) { return flag(M.Doors.step_enabled); }}, {"DoorRemoteOnly", [](auto const &M) { return flag(M.Doors.remote_only); }}, {"DepartureSignal", [](auto const &M) { return flag(M.DepartureSignal); }}, - {"PantsValve", [](auto const &M) { return flag(M.PantsValve.is_enabled) + 2 * flag(M.PantsValve.is_disabled); }}, + {"PantsValve", [](auto const &M) { return flag(M.pantographAir.valve.is_enabled) + 2 * flag(M.pantographAir.valve.is_disabled); }}, {"MaxCurrentHigh", [](auto const &M) { return flag(M.MotorOverloadRelayHighThreshold); }}, {"Imin", [](auto const &M) { return M.Imin; }}, {"DamageFlag", [](auto const &M) { return M.DamageFlag.Bits(); }}, @@ -79,7 +79,7 @@ std::vector state() { auto const name{std::string{end == VehicleEnd::front ? "Front" : "Rear"}}; result.emplace_back("MotorBlowers" + name + "Enabled", [end](auto const &M) { return flag(M.MotorBlowers[end].is_enabled); }); result.emplace_back("MotorBlowers" + name + "Disabled", [end](auto const &M) { return flag(M.MotorBlowers[end].is_disabled); }); - result.emplace_back("Pant" + name + "Valve", [end](auto const &M) { return flag(M.Pantographs[end].valve.is_enabled) + 2 * flag(M.Pantographs[end].valve.is_disabled); }); + result.emplace_back("Pant" + name + "Valve", [end](auto const &M) { return flag(M.pantographs[end].valve.is_enabled) + 2 * flag(M.pantographs[end].valve.is_disabled); }); } for (auto const side : VehicleSides) { auto const name{std::string{side == VehicleSide::right ? "Right" : "Left"}}; @@ -408,9 +408,9 @@ TEST_CASE("commands: every switch of the cab, worked on a pair standing under th auto done{false}; auto channels{state()}; channels.insert(channels.end(), { - {"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.PantPress; }}, + {"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); }}, {"CompressorFlag", [](auto const &M) { return flag(M.air.compressor.running); }}, @@ -480,9 +480,9 @@ TEST_CASE("commands: travel along the train, turned round for a vehicle facing b } SUBCASE("a pantograph valve: the vehicles past one coupled by its control cable take the other pantograph") { consist.head->OperatePantographValve(VehicleEnd::front, operation_t::enable, range_t::consist); - CHECK(consist.head->Pantographs[VehicleEnd::front].valve.is_enabled); - CHECK(consist.middle->Pantographs[VehicleEnd::front].valve.is_enabled); - CHECK(consist.last->Pantographs[VehicleEnd::rear].valve.is_enabled); + CHECK(consist.head->pantographs[VehicleEnd::front].valve.is_enabled); + CHECK(consist.middle->pantographs[VehicleEnd::front].valve.is_enabled); + CHECK(consist.last->pantographs[VehicleEnd::rear].valve.is_enabled); } SUBCASE("sent backwards, it goes no further than the sender: nothing is coupled at its front") { consist.head->RunCommand(VehicleCommand::doorLock, 0, -1, Coupling::control); diff --git a/tests/unit/test_door_wings.cpp b/tests/unit/test_door_wings.cpp index b5249a739..12eae8193 100644 --- a/tests/unit/test_door_wings.cpp +++ b/tests/unit/test_door_wings.cpp @@ -79,7 +79,7 @@ TEST_CASE("door wings: the kinds of animation are named as DoorOpenMethod of the // in any letter case CHECK(door_wings::type_from_name("plug") == door_wings::plug_type); CHECK(door_wings::type_from_name("SHIFT") == door_wings::shift_type); - // the same numbers as physics::Vehicle::door_data::type + // the same numbers as physics::door_data::type CHECK(door_wings::shift_type == 1); CHECK(door_wings::rotate_type == 2); CHECK(door_wings::fold_type == 3); diff --git a/tests/unit/test_genset.cpp b/tests/unit/test_genset.cpp index d0beab879..b552ed158 100644 --- a/tests/unit/test_genset.cpp +++ b/tests/unit/test_genset.cpp @@ -133,8 +133,8 @@ TEST_CASE("genset: a vehicle without the keys has none and stays on the catenary CHECK(cab.TractionMode == traction_mode::catenary); CHECK_FALSE(cab.GensetSelected()); REQUIRE(test::start_up(test::driving(dragon6), wire)); - CHECK(cab.PantographVoltage > 2900.0); - CHECK(cab.TractionSupplyVoltage() == std::max(cab.GetTrainsetHighVoltage(), cab.PantographVoltage)); + CHECK(cab.pantographCircuit.supplyVoltage > 2900.0); + CHECK(cab.TractionSupplyVoltage() == std::max(cab.GetTrainsetHighVoltage(), cab.pantographCircuit.supplyVoltage)); CHECK(cab.TractionSupplyMinVoltage() == cab.EnginePowerSource.CollectorParameters.MinV); CHECK(cab.GensetTractionPowerLimit() == std::numeric_limits::max()); // a start request does nothing without a genset @@ -230,7 +230,7 @@ TEST_CASE("genset: started, it closes the line breaker without a catenary") { run(dragon6, 1.0); } REQUIRE(cab.Mains); - CHECK(cab.PantographVoltage == 0.0); + CHECK(cab.pantographCircuit.supplyVoltage == 0.0); dragon6.step(no_wire); CHECK(cab.EngineVoltage == 3000.0); CHECK(cab.MainCircuitPowered()); @@ -263,7 +263,7 @@ TEST_CASE("genset: on the genset position the catenary feeds nothing") { REQUIRE(cab.TractionModeSwitch(traction_mode::genset)); // 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.PantographVoltage > 2900.0); + REQUIRE(cab.pantographCircuit.supplyVoltage > 2900.0); CHECK_FALSE(cab.Mains); CHECK_FALSE(cab.MainSwitchCheck()); dragon6.step(wire); @@ -445,8 +445,8 @@ TEST_CASE("genset: the pantographs' pressure switch leaves the genset's line bre vehicle dragon6{dragon_genset(), 0.0, "test", 1}; auto &cab{dragon6.physics()}; REQUIRE(start_on_genset(dragon6)); - cab.PantPressSwitchActive = true; - cab.PantPress = 0.0; + cab.pantographAir.pressureSwitchActive = true; + cab.pantographAir.pressure = 0.0; cab.PantPressureSwitchCheck(); CHECK(cab.Mains); } @@ -456,8 +456,8 @@ TEST_CASE("genset: the pantographs' pressure switch leaves the genset's line bre REQUIRE(test::start_up(test::driving(dragon6), wire)); REQUIRE(cab.Mains); // the pressure switch looks at the voltage through the couplers, not the pantographs' - cab.PantPressSwitchActive = true; - cab.PantPress = 0.0; + cab.pantographAir.pressureSwitchActive = true; + cab.pantographAir.pressure = 0.0; cab.PantPressureSwitchCheck(); CHECK_FALSE(cab.Mains); } @@ -536,7 +536,7 @@ TEST_CASE("genset: one genset feeds the next car through the high voltage coupli train.run(10.0, no_wire); REQUIRE(first.Genset.is_active); CHECK(second.GetTrainsetHighVoltage() > 2900.0); - CHECK(second.PantographVoltage == 0.0); + CHECK(second.pantographCircuit.supplyVoltage == 0.0); // the second one, on its catenary position with the pantographs down, takes it as the catenary's second.BatterySwitch(true); train.run(10.0, no_wire); diff --git a/tests/unit/test_loads.cpp b/tests/unit/test_loads.cpp index 9440cd450..228ea5f5b 100644 --- a/tests/unit/test_loads.cpp +++ b/tests/unit/test_loads.cpp @@ -23,8 +23,8 @@ TEST_CASE("loads: the pantographs of an electric vehicle set up by the amount of vehicle et42{definition::fiz("et42_v2/112e-a")}; CHECK(et42->AssignLoad("pantstate", static_cast(amount))); CHECK(et42->DoubleTr == ((amount & 4) != 0 ? -1 : 1)); - CHECK(et42->Pantographs[VehicleEnd::front].valve.is_enabled == frontraised); - CHECK(et42->Pantographs[VehicleEnd::rear].valve.is_enabled == rearraised); + CHECK(et42->pantographs[VehicleEnd::front].valve.is_enabled == frontraised); + CHECK(et42->pantographs[VehicleEnd::rear].valve.is_enabled == rearraised); // the load itself stays as it was CHECK(et42->LoadAmount == doctest::Approx(0.0)); } diff --git a/tests/unit/test_mains_before_pantographs.cpp b/tests/unit/test_mains_before_pantographs.cpp index 3506966ad..374a8709a 100644 --- a/tests/unit/test_mains_before_pantographs.cpp +++ b/tests/unit/test_mains_before_pantographs.cpp @@ -26,7 +26,7 @@ test::definition ep05(bool const Mainsfirst) { // battery and cab on, direction set and the relays reset, the pantographs on the main reservoir's air void prepare(test::vehicle &Loco) { Loco.hold_main_reservoir(6.0); - Loco->bPantKurek3 = true; + Loco->pantographAir.connectedToMainReservoir = true; Loco->BatterySwitch(true); Loco->CabActivisation(); for (int i = 0; i < 3 && Loco->DirActive <= 0; ++i) { @@ -93,14 +93,14 @@ TEST_CASE("mains before pantographs: without the flag the line breaker needs the close_line_breaker(loco); CHECK_FALSE(loco->Mains); raise_pantograph(loco); - CHECK(loco->Pantographs[VehicleEnd::rear].is_active); - CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographs[VehicleEnd::rear].is_active); + CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); close_line_breaker(loco); CHECK(loco->Mains); // 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); + CHECK(loco->pantographs[VehicleEnd::rear].is_active); close_line_breaker(loco); REQUIRE(loco->Mains); loco->OperatePantographValve(VehicleEnd::rear, operation_t::disable); @@ -114,28 +114,28 @@ TEST_CASE("mains before pantographs: with the flag the pantographs rise only thr prepare(loco); // the pantographs stay down while the line breaker is open raise_pantograph(loco); - CHECK_FALSE(loco->Pantographs[VehicleEnd::rear].is_active); - CHECK(loco->PantographVoltage == 0.0); + CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); + 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); raise_pantograph(loco); - CHECK(loco->Pantographs[VehicleEnd::rear].is_active); - CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographs[VehicleEnd::rear].is_active); + CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); CHECK(loco->Mains); // 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->Pantographs[VehicleEnd::rear].is_active); - CHECK(loco->PantographVoltage == 0.0); + 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 close_line_breaker(loco); raise_pantograph(loco); - REQUIRE(loco->Pantographs[VehicleEnd::rear].is_active); + REQUIRE(loco->pantographs[VehicleEnd::rear].is_active); loco->OperatePantographValve(VehicleEnd::rear, operation_t::disable); loco.run(5.0, line); - CHECK_FALSE(loco->Pantographs[VehicleEnd::rear].is_active); + CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); CHECK(loco->Mains); } @@ -153,7 +153,7 @@ TEST_CASE("mains before pantographs: with the flag the driver's start-up gets th auto driven{test::driving(loco)}; REQUIRE(test::start_up(driven, line)); CHECK(loco->Mains); - CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); CHECK(test::is_ready(driven)); } @@ -165,7 +165,7 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres prepare(loco); close_line_breaker(loco); REQUIRE(loco->Mains); - REQUIRE(loco->PantographVoltage == 0.0); + REQUIRE(loco->pantographCircuit.supplyVoltage == 0.0); switch_auxiliaries_on(loco); REQUIRE(loco->ConverterAllow); REQUIRE(loco->air.compressor.allow); @@ -180,7 +180,7 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres // the pantograph up: the converter starts, and the compressor on its 110 V raise_pantograph(loco); - REQUIRE(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); CHECK(reservoir_gain(loco, 10.0, line) > 0.1); CHECK(loco->MainCircuitPowered()); CHECK(loco->ConverterFlag); @@ -192,17 +192,17 @@ TEST_CASE("mains before pantographs: with the flag the converter and the compres SUBCASE("the pantograph lowered again") { loco->OperatePantographValve(VehicleEnd::rear, operation_t::disable); loco.run(5.0, line); - REQUIRE_FALSE(loco->Pantographs[VehicleEnd::rear].is_active); + REQUIRE_FALSE(loco->pantographs[VehicleEnd::rear].is_active); } SUBCASE("no voltage in the catenary") { track = &dead; loco.run(5.0, dead); - REQUIRE(loco->Pantographs[VehicleEnd::rear].is_active); + REQUIRE(loco->pantographs[VehicleEnd::rear].is_active); } SUBCASE("the voltage in the catenary below the one the locomotive works on") { track = &weak; loco.run(5.0, weak); - REQUIRE(loco->PantographVoltage == doctest::Approx(weak.voltage)); + REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(weak.voltage)); } CHECK(reservoir_gain(loco, 10.0, *track) < 0.01); CHECK(loco->Mains); @@ -235,7 +235,7 @@ TEST_CASE("mains before pantographs: with the flag whatever else the main circui SUBCASE("nor do they run on a voltage below the one the locomotive works on") { raise_pantograph(loco, weak); - REQUIRE(loco->PantographVoltage == doctest::Approx(weak.voltage)); + REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(weak.voltage)); CHECK(reservoir_gain(loco, 10.0, weak) < 0.01); CHECK(loco->Mains); CHECK_FALSE(loco->air.compressor.running); @@ -245,7 +245,7 @@ TEST_CASE("mains before pantographs: with the flag whatever else the main circui } SUBCASE("with the voltage they do") { raise_pantograph(loco); - REQUIRE(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); CHECK(reservoir_gain(loco, 10.0, line) > 0.1); CHECK(loco->air.compressor.running); CHECK(loco->MotorBlowers[VehicleEnd::front].is_active); @@ -288,7 +288,7 @@ 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->Pantographs[VehicleEnd::rear].is_active); + CHECK(loco->pantographs[VehicleEnd::rear].is_active); CHECK_FALSE(loco->NoVoltRelay); CHECK_FALSE(loco->StLinFlag); CHECK(loco->Im == 0.0); @@ -296,7 +296,7 @@ TEST_CASE("mains before pantographs: with the flag the line contactors open when // the voltage back, with the master controller still where it was: the camshaft went down to zero and stays // there, the motors still cut off; the converter is back on its own test::drive(driven, line, 10.0); - REQUIRE(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + REQUIRE(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); REQUIRE(loco->MainCtrlPos == 5); CHECK(loco->Mains); CHECK(loco->ConverterFlag); diff --git a/tests/unit/test_pressure_switch.cpp b/tests/unit/test_pressure_switch.cpp index 5f787cee3..75304f5ae 100644 --- a/tests/unit/test_pressure_switch.cpp +++ b/tests/unit/test_pressure_switch.cpp @@ -50,7 +50,7 @@ void get_ready(test::vehicle &Loco, test::driven const &Driven) { } REQUIRE_FALSE(Loco->ControlPressureSwitch); REQUIRE(Loco->Mains); - REQUIRE(Loco->Pantographs[VehicleEnd::rear].is_active); + REQUIRE(Loco->pantographs[VehicleEnd::rear].is_active); } // the master controller taken to the given position a notch a second @@ -109,7 +109,7 @@ TEST_CASE("pressure switch: with the brake cylinders at 3.8 bar the EP05 takes n CHECK_FALSE(loco->StLinFlag); CHECK(loco->Im == 0.0); CHECK(loco->Mains); - CHECK(loco->Pantographs[VehicleEnd::rear].is_active); + CHECK(loco->pantographs[VehicleEnd::rear].is_active); } TEST_CASE("pressure switch: without its brake cylinder half the EP05 takes current with the brake cylinders at 3.8 bar") { @@ -149,7 +149,7 @@ TEST_CASE("pressure switch: without its brake cylinder half the brake pipe still CHECK(loco->Im == 0.0); // nothing else lets go without the other key CHECK(loco->Mains); - CHECK(loco->Pantographs[VehicleEnd::rear].is_active); + CHECK(loco->pantographs[VehicleEnd::rear].is_active); } TEST_CASE("pressure switch: an emergency application with the master controller on a power position opens the line breaker and drops the pantographs") { @@ -167,9 +167,9 @@ TEST_CASE("pressure switch: an emergency application with the master controller REQUIRE(loco->brakePipe.pressure < emergency_pressure); REQUIRE(loco->MainCtrlPos == 5); CHECK_FALSE(loco->Mains); - CHECK_FALSE(loco->Pantographs[VehicleEnd::front].is_active); - CHECK_FALSE(loco->Pantographs[VehicleEnd::rear].is_active); - CHECK(loco->PantographVoltage == 0.0); + 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(loco->Im == 0.0); @@ -177,7 +177,7 @@ TEST_CASE("pressure switch: an emergency application with the master controller loco->MainSwitch(true); test::drive(driven, line, 2.0); CHECK_FALSE(loco->Mains); - CHECK_FALSE(loco->Pantographs[VehicleEnd::rear].is_active); + CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); } TEST_CASE("pressure switch: an emergency application with the master controller at zero leaves the line breaker and the pantographs alone") { @@ -192,15 +192,15 @@ TEST_CASE("pressure switch: an emergency application with the master controller emergency_application(loco, driven); CHECK(loco->Mains); - CHECK(loco->Pantographs[VehicleEnd::rear].is_active); - CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographs[VehicleEnd::rear].is_active); + CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); CHECK(loco->Im == 0.0); // 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->Pantographs[VehicleEnd::rear].is_active); + CHECK_FALSE(loco->pantographs[VehicleEnd::rear].is_active); } TEST_CASE("pressure switch: a service application with the master controller on a power position doesn't open the line breaker") { @@ -219,7 +219,7 @@ TEST_CASE("pressure switch: a service application with the master controller on REQUIRE(lowest < 3.0); CHECK(lowest > emergency_pressure); CHECK(loco->Mains); - CHECK(loco->Pantographs[VehicleEnd::rear].is_active); + CHECK(loco->pantographs[VehicleEnd::rear].is_active); // the pressure switch has cut the motors off CHECK_FALSE(loco->StLinFlag); CHECK(loco->Im == 0.0); @@ -233,8 +233,8 @@ 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->Pantographs[VehicleEnd::rear].is_active); - CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + 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); @@ -249,8 +249,8 @@ TEST_CASE("pressure switch: where the pantographs don't hang on the line breaker emergency_application(loco, driven); CHECK_FALSE(loco->Mains); - CHECK(loco->Pantographs[VehicleEnd::rear].is_active); - CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + CHECK(loco->pantographs[VehicleEnd::rear].is_active); + CHECK(loco->pantographCircuit.supplyVoltage == doctest::Approx(test::catenary_3kv)); CHECK_FALSE(loco->StLinFlag); CHECK(loco->Im == 0.0); } @@ -264,20 +264,20 @@ TEST_CASE("pressure switch: after the emergency application the driver's start-u get_under_power(loco, driven, 5); emergency_application(loco, driven); REQUIRE_FALSE(loco->Mains); - REQUIRE_FALSE(loco->Pantographs[VehicleEnd::rear].is_active); - REQUIRE(loco->Pantographs[VehicleEnd::rear].valve.is_enabled); + 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->Pantographs[VehicleEnd::rear].is_active); - CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv)); + 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->Pantographs[VehicleEnd::rear].is_active); + 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 diff --git a/tests/unit/vehicle.cpp b/tests/unit/vehicle.cpp index 0c36df05f..4e98ed74f 100644 --- a/tests/unit/vehicle.cpp +++ b/tests/unit/vehicle.cpp @@ -225,15 +225,15 @@ double vehicle::move(track const &Track, double Dt, TLocation const &Location, d // what TDynamicObject::Update() does before the movement. a raised pantograph touches the wire at once, // the game animates its rise auto &physics{*m_physics}; - physics.PantFrontVolt = physics.Pantographs[VehicleEnd::front].is_active ? Track.voltage : 0.0; - physics.PantRearVolt = physics.Pantographs[VehicleEnd::rear].is_active ? Track.voltage : 0.0; + physics.pantographCircuit.frontVoltage = physics.pantographs[VehicleEnd::front].is_active ? Track.voltage : 0.0; + physics.pantographCircuit.rearVoltage = physics.pantographs[VehicleEnd::rear].is_active ? Track.voltage : 0.0; TTractionParam traction; traction.TractionVoltage = - physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? std::max(std::abs(physics.PantRearVolt), std::abs(physics.PantFrontVolt)) : 0.95 * physics.EnginePowerSource.MaxVoltage; + physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ? std::max(std::abs(physics.pantographCircuit.rearVoltage), std::abs(physics.pantographCircuit.frontVoltage)) : 0.95 * physics.EnginePowerSource.MaxVoltage; traction.TractionFreq = 0; traction.TractionMaxCurrent = 7500; traction.TractionResistivity = 0.3; - physics.PantographVoltage = traction.TractionVoltage; + physics.pantographCircuit.supplyVoltage = traction.TractionVoltage; if (m_cab != 0) { using enum TEngineType; // the driver's own vehicle, which gets the average pressure of the train's brake pipe diff --git a/vehicle/ai/engine.cpp b/vehicle/ai/engine.cpp index af3e9b1a1..5aedc3b66 100644 --- a/vehicle/ai/engine.cpp +++ b/vehicle/ai/engine.cpp @@ -102,21 +102,21 @@ bool TController::PrepareEngine() if( pantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { // if our pantograph unit isn't a pantograph-devoid fallback - if (pantographUnit->PantPress < sufficientpantographpressure) { + if (pantographUnit->pantographAir.pressure < sufficientpantographpressure) { // załączenie małej sprężarki - if( false == pantographUnit->PantAutoValve ) { + if( false == pantographUnit->pantographAir.autoValve ) { // odłączenie zbiornika głównego, bo z nim nie da rady napompować cue_action( driver_hint::pantographairsourcesetauxiliary ); } cue_action( driver_hint::pantographcompressoron ); // załączenie sprężarki pantografów - if( pantographUnit->PantCompFlag ) { + if( pantographUnit->pantographAir.compressorRunning ) { cue_action( driver_hint::waitpantographpressuretoolow ); } } else { // jeżeli jest wystarczające ciśnienie w pantografach - if( false == pantographUnit->bPantKurek3 - || pantographUnit->PantPress <= pantographUnit->mainPipe.pressure ) { // kurek przełączony albo główna już pompuje + if( false == pantographUnit->pantographAir.connectedToMainReservoir + || pantographUnit->pantographAir.pressure <= pantographUnit->mainPipe.pressure ) { // kurek przełączony albo główna już pompuje cue_action( driver_hint::pantographcompressoroff ); // sprężarkę pantografów można już wyłączyć } } @@ -130,7 +130,7 @@ bool TController::PrepareEngine() auto const ispoweravailable = mvControlling->EnginePowerSource.SourceType != TPowerSource::CurrentCollector - || std::max(mvControlling->GetTrainsetHighVoltage(), mvControlling->PantographVoltage) > mvControlling->EnginePowerSource.CollectorParameters.MinV; + || std::max(mvControlling->GetTrainsetHighVoltage(), mvControlling->pantographCircuit.supplyVoltage) > mvControlling->EnginePowerSource.CollectorParameters.MinV; // standing with the pantographs up and no voltage, nothing the driver does starts the vehicle. it says so, and keeps // trying: towed back under the wire, or with the power switched on, the vehicle gets prepared after all report_power_stall( ispoweravailable, sufficientpantographpressure ); @@ -235,17 +235,17 @@ TController::report_power_stall( bool const Poweravailable, double const Pantogr state.collector = mvControlling->EnginePowerSource.SourceType == TPowerSource::CurrentCollector; state.power = Poweravailable; state.standing = occupied->Vel < EU07_AI_NOMOVEMENT; - if( pantographUnit->PantPress >= Pantographpressure ) { + if( pantographUnit->pantographAir.pressure >= Pantographpressure ) { state.pantographs_up = - pantographUnit->Pantographs[ VehicleEnd::front ].is_active - || pantographUnit->Pantographs[ VehicleEnd::rear ].is_active; + pantographUnit->pantographs[ VehicleEnd::front ].is_active + || pantographUnit->pantographs[ VehicleEnd::rear ].is_active; } // the pantographs of the vehicle carrying them hold the wire they found above them if( auto const *carrier { pVehicle->FindPantographCarrier() }; carrier != nullptr && carrier->physics == pantographUnit ) { - auto const pantographcount { std::min( carrier->iAnimType[ ANIM_PANTS ], static_cast( carrier->physics->Pantographs.size() ) ) }; + auto const pantographcount { std::min( carrier->iAnimType[ ANIM_PANTS ], static_cast( carrier->physics->pantographs.size() ) ) }; for( auto index { 0 }; index < pantographcount; ++index ) { - if( true == carrier->physics->Pantographs[ index ].is_active + if( true == carrier->physics->pantographs[ index ].is_active && carrier->pants[ index ].fParamPants->hvPowerWire != nullptr ) { state.wire = true; } diff --git a/vehicle/ai/situation.cpp b/vehicle/ai/situation.cpp index 9ccb515d6..84b7de29e 100644 --- a/vehicle/ai/situation.cpp +++ b/vehicle/ai/situation.cpp @@ -142,14 +142,14 @@ TController::control_pantographs() { if( pantographUnit->EnginePowerSource.SourceType != TPowerSource::CurrentCollector ) { return; } - if( false == pantographUnit->PantAutoValve + if( false == pantographUnit->pantographAir.autoValve && occupied->mainPipe.pressure > 4.3 ) { // gdy główna sprężarka bezpiecznie nabije ciśnienie to można przestawić kurek na zasilanie pantografów z głównej pneumatyki cue_action( driver_hint::pantographairsourcesetmain ); } // uśrednione napięcie sieci: przy spadku poniżej wartości minimalnej opóźnić rozruch o losowy czas - fVoltage = 0.5 * (fVoltage + std::max( mvControlling->GetTrainsetHighVoltage(), mvControlling->PantographVoltage ) ); + fVoltage = 0.5 * (fVoltage + std::max( mvControlling->GetTrainsetHighVoltage(), mvControlling->pantographCircuit.supplyVoltage ) ); if( fVoltage < mvControlling->EnginePowerSource.CollectorParameters.MinV && fActionTime >= PrepareTime ) { // gdy rozłączenie WS z powodu niskiego napięcia // jeśli czas oczekiwania nie został ustawiony, losowy czas oczekiwania przed ponownym załączeniem jazdy @@ -178,10 +178,10 @@ TController::control_pantographs() { if( fOverhead2 > 0.0 || iOverheadDown ) { // jazda z opuszczonymi pantografami - if( pantographUnit->Pantographs[ VehicleEnd::front ].is_active ) { + if( pantographUnit->pantographs[ VehicleEnd::front ].is_active ) { cue_action( driver_hint::frontpantographvalveoff ); } - if( pantographUnit->Pantographs[ VehicleEnd::rear ].is_active ) { + if( pantographUnit->pantographs[ VehicleEnd::rear ].is_active ) { cue_action( driver_hint::rearpantographvalveoff ); } } @@ -197,18 +197,18 @@ TController::control_pantographs() { // jazda na tylnym if( iDirection >= 0 && useregularpantographlayout ) { // jak jedzie w kierunku sprzęgu 0 - if( pantographUnit->PantRearVolt == 0.0 + if( pantographUnit->pantographCircuit.rearVoltage == 0.0 // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( pantographUnit->PantographVoltage == 0.0 + && ( pantographUnit->pantographCircuit.supplyVoltage == 0.0 || pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { cue_action( driver_hint::rearpantographvalveon ); } } else { // jak jedzie w kierunku sprzęgu 0 - if( pantographUnit->PantFrontVolt == 0.0 + if( pantographUnit->pantographCircuit.frontVoltage == 0.0 // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( pantographUnit->PantographVoltage == 0.0 + && ( pantographUnit->pantographCircuit.supplyVoltage == 0.0 || pantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) { cue_action( driver_hint::frontpantographvalveon ); } @@ -218,14 +218,14 @@ TController::control_pantographs() { // opuszczenie przedniego po rozpędzeniu się o ile jest więcej niż jeden if (iDirection >= 0 && useregularpantographlayout) // jak jedzie w kierunku sprzęgu 0 { // poczekać na podniesienie tylnego - if (pantographUnit->PantFrontVolt != 0.0 && pantographUnit->PantRearVolt != 0.0) + if (pantographUnit->pantographCircuit.frontVoltage != 0.0 && pantographUnit->pantographCircuit.rearVoltage != 0.0) { // czy jest napięcie zasilające na tylnym? cue_action(driver_hint::frontpantographvalveoff); // opuszcza od sprzęgu 0 } } else { // poczekać na podniesienie przedniego - if (pantographUnit->PantRearVolt != 0.0 && pantographUnit->PantFrontVolt != 0.0) + if (pantographUnit->pantographCircuit.rearVoltage != 0.0 && pantographUnit->pantographCircuit.frontVoltage != 0.0) { // czy jest napięcie zasilające na przednim? cue_action(driver_hint::rearpantographvalveoff); // opuszcza od sprzęgu 1 } @@ -262,14 +262,14 @@ TController::control_pantographs() { if (iDirection >= 0 && useregularpantographlayout) { // jak jedzie w kierunku sprzęgu 0 - if (pantographUnit->PantFrontVolt == 0.0) + if (pantographUnit->pantographCircuit.frontVoltage == 0.0) { cue_action(driver_hint::frontpantographvalveon, 5); // discard the hint if speed exceeds 5 km/h } } else { - if (pantographUnit->PantRearVolt == 0.0) + if (pantographUnit->pantographCircuit.rearVoltage == 0.0) { cue_action(driver_hint::rearpantographvalveon, 5); // discard the hint if speed exceeds 5 km/h } @@ -291,7 +291,7 @@ TController::control_pantographs_setup( int const Setup ) { if( rear ) { cue_action( driver_hint::rearpantographvalveon ); } - if( auto const setuplive { ( front && pantographUnit->PantFrontVolt != 0.0 ) || ( rear && pantographUnit->PantRearVolt != 0.0 ) }; + if( auto const setuplive { ( front && pantographUnit->pantographCircuit.frontVoltage != 0.0 ) || ( rear && pantographUnit->pantographCircuit.rearVoltage != 0.0 ) }; false == setuplive ) { return; } diff --git a/vehicle/cab/pantographcommands.cpp b/vehicle/cab/pantographcommands.cpp index 24a043416..c83599f97 100644 --- a/vehicle/cab/pantographcommands.cpp +++ b/vehicle/cab/pantographcommands.cpp @@ -59,7 +59,7 @@ void TTrain::OnCommand_pantographtogglefront(TTrain *Train, command_data const & if (Command.action == GLFW_PRESS) { // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const &pantograph{Train->pantographUnit->Pantographs[VehicleEnd::front]}; + auto const &pantograph{Train->pantographUnit->pantographs[VehicleEnd::front]}; auto const state{pantograph.valve.is_enabled || pantograph.is_active}; // fallback for impulse switches if (state) { @@ -73,7 +73,7 @@ void TTrain::OnCommand_pantographtogglefront(TTrain *Train, command_data const & else if (Command.action == GLFW_RELEASE) { // impulse switches return automatically to neutral position - if (Train->occupied->PantSwitchType == "impulse") + if (Train->occupied->pantographCircuit.switchType == "impulse") { auto const ismanual{Train->iCabn == 0}; Train->occupied->OperatePantographValve(VehicleEnd::front, operation_t::none, ismanual ? range_t::local : range_t::consist); @@ -93,7 +93,7 @@ void TTrain::OnCommand_pantographtogglerear(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 - auto const &pantograph{Train->pantographUnit->Pantographs[VehicleEnd::rear]}; + auto const &pantograph{Train->pantographUnit->pantographs[VehicleEnd::rear]}; auto const state{pantograph.valve.is_enabled || pantograph.is_active}; // fallback for impulse switches if (state) { @@ -107,7 +107,7 @@ void TTrain::OnCommand_pantographtogglerear(TTrain *Train, command_data const &C else if (Command.action == GLFW_RELEASE) { // impulse switches return automatically to neutral position - if (Train->occupied->PantSwitchType == "impulse") + if (Train->occupied->pantographCircuit.switchType == "impulse") { auto const ismanual{Train->iCabn == 0}; Train->occupied->OperatePantographValve(VehicleEnd::rear, operation_t::none, ismanual ? range_t::local : range_t::consist); @@ -134,7 +134,7 @@ void TTrain::OnCommand_pantographraisefront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, + Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->pantographCircuit.switchType == "impulse" ? operation_t::enable_on : operation_t::enable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -163,7 +163,7 @@ void TTrain::OnCommand_pantographraiserear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->PantSwitchType == "impulse" ? operation_t::enable_on : operation_t::enable, + Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->pantographCircuit.switchType == "impulse" ? operation_t::enable_on : operation_t::enable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -182,7 +182,7 @@ void TTrain::OnCommand_pantographlowerfront(TTrain *Train, command_data const &C return; } // prevent operation without submodel outside of engine compartment - if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->PantSwitchType == "impulse" ? "pantfrontoff_sw:" : "pantfront_sw:")) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->pantographCircuit.switchType == "impulse" ? "pantfrontoff_sw:" : "pantfront_sw:")) { return; } @@ -192,7 +192,7 @@ void TTrain::OnCommand_pantographlowerfront(TTrain *Train, command_data const &C // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, + Train->occupied->OperatePantographValve(VehicleEnd::front, Train->occupied->pantographCircuit.switchType == "impulse" ? operation_t::disable_on : operation_t::disable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -211,7 +211,7 @@ void TTrain::OnCommand_pantographlowerrear(TTrain *Train, command_data const &Co return; } - if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->PantSwitchType == "impulse" ? "pantrearoff_sw:" : "pantrear_sw:")) + if (Train->iCabn != 0 && false == Train->m_controlmapper.contains(Train->occupied->pantographCircuit.switchType == "impulse" ? "pantrearoff_sw:" : "pantrear_sw:")) { return; } @@ -221,7 +221,7 @@ void TTrain::OnCommand_pantographlowerrear(TTrain *Train, command_data const &Co // only reacting to press, so the switch doesn't flip back and forth if key is held down // HACK: don't propagate pantograph commands issued from engine compartment, these are presumed to be manually moved levers auto const ismanual{Train->iCabn == 0}; - Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->PantSwitchType == "impulse" ? operation_t::disable_on : operation_t::disable, + Train->occupied->OperatePantographValve(VehicleEnd::rear, Train->occupied->pantographCircuit.switchType == "impulse" ? operation_t::disable_on : operation_t::disable, ismanual ? range_t::local : range_t::consist); } else if (Command.action == GLFW_RELEASE) @@ -254,9 +254,9 @@ void TTrain::OnCommand_pantographlowerall(TTrain *Train, command_data const &Com // two-state switch, only cares about press events if (Command.action == GLFW_PRESS) { - Train->pantographUnit->DropAllPantographs(false == Train->pantographUnit->PantAllDown); + Train->pantographUnit->DropAllPantographs(false == Train->pantographUnit->pantographCircuit.allDown); // visual feedback - Train->ggPantAllDownButton.UpdateValue(Train->pantographUnit->PantAllDown ? 1.0 : 0.0, Train->dsbSwitch); + Train->ggPantAllDownButton.UpdateValue(Train->pantographUnit->pantographCircuit.allDown ? 1.0 : 0.0, Train->dsbSwitch); } } else @@ -315,7 +315,7 @@ void TTrain::OnCommand_pantographtoggleselected(TTrain *Train, command_data cons Train->change_pantograph_selection(-1); // only reacting to press, so the switch doesn't flip back and forth if key is held down - auto const state{Train->pantographUnit->PantsValve.is_enabled || Train->pantographUnit->PantsValve.is_active}; // fallback for impulse switches + auto const state{Train->pantographUnit->pantographAir.valve.is_enabled || Train->pantographUnit->pantographAir.valve.is_active}; // fallback for impulse switches if (state) { OnCommand_pantographlowerselected(Train, Command); @@ -415,8 +415,8 @@ void TTrain::update_pantograph_valves() { using enum operation_t; - auto const &presets{occupied->PantsPreset.first}; - auto const &selection{occupied->PantsPreset.second[cab_to_end()]}; + auto const &presets{occupied->pantographCircuit.presets.first}; + auto const &selection{occupied->pantographCircuit.presets.second[cab_to_end()]}; auto const preset{presets[selection] - '0'}; auto const swapends{cab_to_end() != VehicleEnd::front}; @@ -430,8 +430,8 @@ void TTrain::update_pantograph_valves() void TTrain::change_pantograph_selection(int const Change) { - auto const &presets{occupied->PantsPreset.first}; - auto &selection{occupied->PantsPreset.second[cab_to_end()]}; + auto const &presets{occupied->pantographCircuit.presets.first}; + auto &selection{occupied->pantographCircuit.presets.second[cab_to_end()]}; auto const initialstate{selection}; selection = std::clamp(selection + Change, 0, std::max(static_cast(presets.size() - 1), 0)); @@ -525,7 +525,7 @@ void TTrain::OnCommand_pantographcompressorvalvetoggle(TTrain *Train, command_da if (Command.action == GLFW_PRESS) { // only react to press - if (Train->controlled->bPantKurek3 == false) + if (Train->controlled->pantographAir.connectedToMainReservoir == false) { // connect pantographs with primary tank OnCommand_pantographcompressorvalveenable(Train, Command); @@ -552,7 +552,7 @@ void TTrain::OnCommand_pantographcompressorvalveenable(TTrain *Train, command_da { // only react to press // connect pantographs with primary tank - Train->controlled->bPantKurek3 = true; + Train->controlled->pantographAir.connectedToMainReservoir = true; // visual feedback: Train->ggPantCompressorValve.UpdateValue(0.0); } @@ -572,7 +572,7 @@ void TTrain::OnCommand_pantographcompressorvalvedisable(TTrain *Train, command_d { // only react to press // connect pantograps with pantograph compressor - Train->controlled->bPantKurek3 = false; + Train->controlled->pantographAir.connectedToMainReservoir = false; // visual feedback: Train->ggPantCompressorValve.UpdateValue(1.0); } @@ -590,10 +590,10 @@ void TTrain::OnCommand_pantographcompressoractivate(TTrain *Train, command_data if (Command.action != GLFW_RELEASE) { // press or hold to activate - if (Train->pantographUnit->PantPress < 4.8 && true == Train->pantographUnit->Power24vIsAvailable) + if (Train->pantographUnit->pantographAir.pressure < 4.8 && true == Train->pantographUnit->Power24vIsAvailable) { // needs live power source and low enough pressure to work - Train->pantographUnit->PantCompFlag = true; + Train->pantographUnit->pantographAir.compressorRunning = true; } // visual feedback Train->ggPantCompressorButton.UpdateValue(1.0); @@ -601,7 +601,7 @@ void TTrain::OnCommand_pantographcompressoractivate(TTrain *Train, command_data else { // release to disable - Train->pantographUnit->PantCompFlag = false; + Train->pantographUnit->pantographAir.compressorRunning = false; // visual feedback Train->ggPantCompressorButton.UpdateValue(0.0); } diff --git a/vehicle/cab/setup.cpp b/vehicle/cab/setup.cpp index 53bf093ca..116d2b8dc 100644 --- a/vehicle/cab/setup.cpp +++ b/vehicle/cab/setup.cpp @@ -967,7 +967,7 @@ void TTrain::set_cab_controls(int const Cab) // front/end pantograph selection is relative to occupied cab if (ggPantSelectedButton.type() == TGaugeType::toggle) { - ggPantSelectedButton.PutValue(pantographUnit->PantsValve.is_enabled ? 1.f : 0.f); + ggPantSelectedButton.PutValue(pantographUnit->pantographAir.valve.is_enabled ? 1.f : 0.f); } else { @@ -979,15 +979,15 @@ void TTrain::set_cab_controls(int const Cab) } if (ggPantSelectedDownButton.type() == TGaugeType::toggle) { - ggPantSelectedDownButton.PutValue(pantographUnit->PantsValve.is_disabled ? 1.f : 0.f); + ggPantSelectedDownButton.PutValue(pantographUnit->pantographAir.valve.is_disabled ? 1.f : 0.f); } ggPantValvesButton.PutValue(0.5f); // auxiliary compressor - ggPantCompressorValve.PutValue(controlled->bPantKurek3 ? 0.f : // default setting is pantographs connected with primary tank + ggPantCompressorValve.PutValue(controlled->pantographAir.connectedToMainReservoir ? 0.f : // default setting is pantographs connected with primary tank 1.f); - ggPantCompressorButton.PutValue(pantographUnit->PantCompFlag ? 1.f : 0.f); + ggPantCompressorButton.PutValue(pantographUnit->pantographAir.compressorRunning ? 1.f : 0.f); // converter if (occupied->ConvSwitchType != "impulse") { @@ -1652,10 +1652,10 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con std::unordered_map const autoboolgauges = { {"doormode_sw:", &occupied->Doors.remote_only}, {"coolingfans_sw:", &controlled->RVentForceOn}, - {"pantfront_sw:", &pantographUnit->Pantographs[VehicleEnd::front].valve.is_enabled}, - {"pantrear_sw:", &pantographUnit->Pantographs[VehicleEnd::rear].valve.is_enabled}, - {"pantfrontoff_sw:", &pantographUnit->Pantographs[VehicleEnd::front].valve.is_disabled}, - {"pantrearoff_sw:", &pantographUnit->Pantographs[VehicleEnd::rear].valve.is_disabled}, + {"pantfront_sw:", &pantographUnit->pantographs[VehicleEnd::front].valve.is_enabled}, + {"pantrear_sw:", &pantographUnit->pantographs[VehicleEnd::rear].valve.is_enabled}, + {"pantfrontoff_sw:", &pantographUnit->pantographs[VehicleEnd::front].valve.is_disabled}, + {"pantrearoff_sw:", &pantographUnit->pantographs[VehicleEnd::rear].valve.is_disabled}, {"radio_sw:", &occupied->Radio}, {"radiofuse_sw:", &occupied->RadioFuse}, {"cablight_sw:", &Cabine[iCabn].bLight}, @@ -1678,7 +1678,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // TODO: move viable dedicated gauges to the automatic array std::unordered_map const autointgauges = { {"manualbrake:", &occupied->brakes.handBrakePosition}, - {"pantselect_sw:", &occupied->PantsPreset.second[cab_to_end()]}, + {"pantselect_sw:", &occupied->pantographCircuit.presets.second[cab_to_end()]}, }; { auto lookup = autointgauges.find(Label); @@ -1845,7 +1845,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // manometr zbiornika kontrolnego/rorzďż˝du auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&pantographUnit->PantPress); + gauge.AssignDouble(&pantographUnit->pantographAir.pressure); } else if (Label == "springbrakepress:") { @@ -1901,7 +1901,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con // pantograph tank pressure auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka gauge.Load(Parser, DynamicObject, 0.1); - gauge.AssignDouble(&pantographUnit->PantPress); + gauge.AssignDouble(&pantographUnit->pantographAir.pressure); } // yB - dla drugiej sekcji else if (Label == "hvbcurrent1:") diff --git a/vehicle/cab/train.cpp b/vehicle/cab/train.cpp index a805f7a06..2a54c74f7 100644 --- a/vehicle/cab/train.cpp +++ b/vehicle/cab/train.cpp @@ -180,7 +180,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("converter", occupied->Power110vIsAvailable); dict->insert("converter_overload", controlled->ConvOvldFlag); dict->insert("compress", controlled->air.compressor.running); - dict->insert("pant_compressor", pantographUnit->PantCompFlag); + dict->insert("pant_compressor", pantographUnit->pantographAir.compressorRunning); dict->insert("lights_front", occupied->iLights[VehicleEnd::front]); dict->insert("lights_rear", occupied->iLights[VehicleEnd::rear]); dict->insert("off_from_dimmer", occupied->currentDimPosition().isOff); @@ -242,7 +242,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("ca", occupied->SecuritySystem.is_vigilance_blinking()); dict->insert("shp", occupied->SecuritySystem.is_cabsignal_blinking()); dict->insert("distance_counter", m_distancecounter); - dict->insert("pantpress", std::abs(pantographUnit->PantPress)); + dict->insert("pantpress", std::abs(pantographUnit->pantographAir.pressure)); dict->insert("universal3", InstrumentLightActive); for (auto idx = 0; idx < ggUniversals.size(); idx++) { @@ -267,7 +267,7 @@ std::shared_ptr TTrain::GetTrainState(dictionary_source const dict->insert("odometer", occupied->DistCounter); // distance run in the session, km dict->insert("odometer_total", occupied->Odometer.km); // the vehicle's odometer, kept between the sessions // electric current data - dict->insert("traction_voltage", std::abs(pantographUnit->PantographVoltage)); + dict->insert("traction_voltage", std::abs(pantographUnit->pantographCircuit.supplyVoltage)); dict->insert("voltage", std::abs(controlled->EngineVoltage)); dict->insert("im", std::abs(controlled->Im)); dict->insert("fuse", controlled->FuseFlag); @@ -414,7 +414,7 @@ TTrain::state_t TTrain::get_state() const static_cast(occupied->air.mainReservoirPressure), static_cast(occupied->brakePipe.pressure), static_cast(occupied->brakes.cylinderPressure), - static_cast(pantographUnit->PantPress), + static_cast(pantographUnit->pantographAir.pressure), fHVoltage, {fHCurrent[controlled->TrainType == train_type::emu ? 0 : 1], fHCurrent[2], fHCurrent[3]}, ggLVoltage.GetValue(), diff --git a/vehicle/cab/update.cpp b/vehicle/cab/update.cpp index 5427dc0b5..0594899ee 100644 --- a/vehicle/cab/update.cpp +++ b/vehicle/cab/update.cpp @@ -361,7 +361,7 @@ void TTrain::updateVoltagesAndCurrents() // Ra 2014-09: napięcia i prądy muszą być ustalone najpierw, bo wysyłane są ewentualnie na PoKeys if (controlled->EngineType != TEngineType::DieselElectric && controlled->EngineType != TEngineType::ElectricInductionMotor) { // Ra 2014-09: czy taki rozdzia? ma sens? - fHVoltage = static_cast(std::max(controlled->PantographVoltage, + fHVoltage = static_cast(std::max(controlled->pantographCircuit.supplyVoltage, controlled->GetTrainsetHighVoltage())); // Winger czy to nie jest zle? } // *controlled->Mains); @@ -452,8 +452,8 @@ void TTrain::updateUnitStates() asCarName[i] = p->name(); if (p->physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && iUnitNo <= 8) { - bPants[iUnitNo - 1][VehicleEnd::front] = bPants[iUnitNo - 1][VehicleEnd::front] || p->physics->Pantographs[VehicleEnd::front].is_active; - bPants[iUnitNo - 1][VehicleEnd::rear] = bPants[iUnitNo - 1][VehicleEnd::rear] || p->physics->Pantographs[VehicleEnd::rear].is_active; + bPants[iUnitNo - 1][VehicleEnd::front] = bPants[iUnitNo - 1][VehicleEnd::front] || p->physics->pantographs[VehicleEnd::front].is_active; + bPants[iUnitNo - 1][VehicleEnd::rear] = bPants[iUnitNo - 1][VehicleEnd::rear] || p->physics->pantographs[VehicleEnd::rear].is_active; } // TBD, TODO: clean up compressor data arrangement? if (iUnitNo <= 8) diff --git a/vehicle/doorwings.h b/vehicle/doorwings.h index 4c9304445..259c85575 100644 --- a/vehicle/doorwings.h +++ b/vehicle/doorwings.h @@ -24,7 +24,7 @@ http://mozilla.org/MPL/2.0/. // in the main model and, when the low poly interior has a submodel of the same name, in the interior as well namespace door_wings { -// the kinds of wing animation, numbered as DoorOpenMethod of the .fiz (physics::Vehicle::door_data::type) +// the kinds of wing animation, numbered as DoorOpenMethod of the .fiz (physics::door_data::type) inline constexpr int shift_type{1}; inline constexpr int rotate_type{2}; inline constexpr int fold_type{3}; diff --git a/vehicle/dynamic/lifecycle.cpp b/vehicle/dynamic/lifecycle.cpp index 8fbf1592e..ddd6816e5 100644 --- a/vehicle/dynamic/lifecycle.cpp +++ b/vehicle/dynamic/lifecycle.cpp @@ -354,8 +354,8 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424" physics->brakePipe.pressure = 0.0; physics->mainPipe.reservoir->CreatePress(0.0); physics->mainPipe.pressure = 0.0; - physics->PantVolume = 0.1; - physics->PantPress = 0.0; + physics->pantographAir.volume = 0.1; + physics->pantographAir.pressure = 0.0; physics->air.compressedVolume = 0.0; } diff --git a/vehicle/dynamic/sounds.cpp b/vehicle/dynamic/sounds.cpp index a99610a14..d83e3afca 100644 --- a/vehicle/dynamic/sounds.cpp +++ b/vehicle/dynamic/sounds.cpp @@ -117,7 +117,7 @@ void TDynamicObject::renderAuxiliarySounds() { // NBMX dzwiek przetwornicy if( physics->ConverterFlag ) { if( physics->EngineType == TEngineType::ElectricSeriesMotor ) { - auto const voltage { std::max( physics->GetTrainsetHighVoltage(), physics->PantographVoltage ) }; + auto const voltage { std::max( physics->GetTrainsetHighVoltage(), physics->pantographCircuit.supplyVoltage ) }; if( voltage > 0.0 ) { // NOTE: we do sound modulation here to avoid sudden jump on voltage loss frequency = voltage / (physics->NominalVoltage * physics->RList[physics->RlistSize].Mn); @@ -187,7 +187,7 @@ void TDynamicObject::renderAuxiliarySounds() { } // Winger 160404 - dzwiek malej sprezarki - if( physics->PantCompFlag ) { + if( physics->pantographAir.compressorRunning ) { sSmallCompressor.play( sound_flags::exclusive | sound_flags::looping ); } else { diff --git a/vehicle/dynamic/update.cpp b/vehicle/dynamic/update.cpp index 8a74d47f5..2ec42d52c 100644 --- a/vehicle/dynamic/update.cpp +++ b/vehicle/dynamic/update.cpp @@ -257,7 +257,7 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) // napiecie sieci trakcyjnej if (physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { // dla EZT tylko silnikowy - tmpTraction.TractionVoltage = std::max( std::abs( physics->PantRearVolt ), std::abs( physics->PantFrontVolt ) ); + tmpTraction.TractionVoltage = std::max( std::abs( physics->pantographCircuit.rearVoltage ), std::abs( physics->pantographCircuit.frontVoltage ) ); // jeśli brak zasilania dłużej niż 0.2 sekundy (25km/h pod izolatorem daje 0.15s) // Ra 2F1H: prowizorka, trzeba przechować napięcie, żeby nie wywalało WS pod izolatorem if( tmpTraction.TractionVoltage > 0.0) { @@ -266,14 +266,14 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) else { NoVoltTime += dt1; if( NoVoltTime <= 0.2 ) { - tmpTraction.TractionVoltage = physics->PantographVoltage; + tmpTraction.TractionVoltage = physics->pantographCircuit.supplyVoltage; } else { // jeśli jedzie if( physics->Vel > 0.5 ) { // 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->pantographs[VehicleEnd::front].is_active + || physics->pantographs[VehicleEnd::rear].is_active ) { if( physics->Mains // 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 @@ -295,7 +295,7 @@ void TDynamicObject::updateTractionVoltage( double const dt1 ) tmpTraction.TractionMaxCurrent = 7500; // Ra: chyba za dużo? powinno wywalać przy 1500 tmpTraction.TractionResistivity = 0.3; - physics->PantographVoltage = tmpTraction.TractionVoltage; + physics->pantographCircuit.supplyVoltage = tmpTraction.TractionVoltage; } // the driver of the vehicle: the integrated controller, the brakes blended over a consist with induction motors, the AI @@ -938,7 +938,7 @@ void TDynamicObject::updateCurrentCollectors( double const dt1 ) } else { if( pantograph->hvPowerWire != nullptr - && true == physics->Pantographs[PantographEnd( idx )].is_active + && true == physics->pantographs[PantographEnd( idx )].is_active && pantograph->PantTraction - pantograph->PantWys < 0.01 ) { // tolerancja niedolegania ++activepantographs; } @@ -1037,8 +1037,8 @@ void TDynamicObject::updateCurrentCollectors( double const dt1 ) if (physics->EnginePowerSource.SourceType == TPowerSource::CurrentCollector && physics->EnginePowerSource.CollectorParameters.FakePower) { - physics->PantRearVolt = 0.95 * physics->EnginePowerSource.MaxVoltage; - physics->PantFrontVolt = 0.95 * physics->EnginePowerSource.MaxVoltage; + physics->pantographCircuit.rearVoltage = 0.95 * physics->EnginePowerSource.MaxVoltage; + physics->pantographCircuit.frontVoltage = 0.95 * physics->EnginePowerSource.MaxVoltage; } } @@ -1059,9 +1059,9 @@ void TDynamicObject::updatePantograph( int const i, double const fPantCurrent, d if (p->fAngleU > M_PI) p->fAngleU = M_PI; if (i & 1) // zgłoszono, że po połamaniu potrafi zostać zasilanie - physics->PantRearVolt = 0.0; + physics->pantographCircuit.rearVoltage = 0.0; else - physics->PantFrontVolt = 0.0; + physics->pantographCircuit.frontVoltage = 0.0; return; // reszta wtedy nie jest wykonywana } PantDiff = p->PantTraction - p->PantWys; // docelowy-aktualny @@ -1078,30 +1078,30 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d if (Global.bLiveTraction == false && p->hvPowerWire == nullptr ) { // jeśli nie ma drutu, może pooszukiwać - physics->PantFrontVolt = + physics->pantographCircuit.frontVoltage = p->PantWys >= 1.2 ? 0.95 * physics->EnginePowerSource.MaxVoltage : 0.0; } - else if( true == physics->Pantographs[VehicleEnd::front].is_active + else if( true == physics->pantographs[VehicleEnd::front].is_active && PantDiff < 0.01 ) // tolerancja niedolegania { if (p->hvPowerWire) { - auto const lastvoltage { physics->PantFrontVolt }; + auto const lastvoltage { physics->pantographCircuit.frontVoltage }; // TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage() if( lastvoltage == 0.0 ) { // HACK: retrieve the wire voltage for calculations down the road without blowing up the supply - physics->PantFrontVolt = p->hvPowerWire->VoltageGet( physics->PantographVoltage, 0.0 ); + physics->pantographCircuit.frontVoltage = p->hvPowerWire->VoltageGet( physics->pantographCircuit.supplyVoltage, 0.0 ); } else { - physics->PantFrontVolt = p->hvPowerWire->VoltageGet( physics->PantographVoltage, fPantCurrent ); - if( physics->PantFrontVolt > 0.0 ) { + physics->pantographCircuit.frontVoltage = p->hvPowerWire->VoltageGet( physics->pantographCircuit.supplyVoltage, fPantCurrent ); + if( physics->pantographCircuit.frontVoltage > 0.0 ) { fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf (unless it doesn't) } } // TODO: refactor reaction to voltage change to physics as sound event for specific pantograph if( lastvoltage == 0.0 - && physics->PantFrontVolt > 0.0 ) { + && physics->pantographCircuit.frontVoltage > 0.0 ) { for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z > 0 ) { // limit to pantographs located in the front half of the vehicle @@ -1111,40 +1111,40 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d } } else - physics->PantFrontVolt = 0.0; + physics->pantographCircuit.frontVoltage = 0.0; } else - physics->PantFrontVolt = 0.0; - ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->PantFrontVolt * fPantCurrent * dt1 / 3600000.0; + physics->pantographCircuit.frontVoltage = 0.0; + ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->pantographCircuit.frontVoltage * fPantCurrent * dt1 / 3600000.0; break; case 1: if( false == Global.bLiveTraction && nullptr == p->hvPowerWire ) { // jeśli nie ma drutu, może pooszukiwać - physics->PantRearVolt = + physics->pantographCircuit.rearVoltage = p->PantWys >= 1.2 ? 0.95 * physics->EnginePowerSource.MaxVoltage : 0.0; } - else if ( true == physics->Pantographs[VehicleEnd::rear].is_active + else if ( true == physics->pantographs[VehicleEnd::rear].is_active && PantDiff < 0.01 ) { if (p->hvPowerWire) { - auto const lastvoltage { physics->PantRearVolt }; + auto const lastvoltage { physics->pantographCircuit.rearVoltage }; // TODO: wyliczyć trzeba prąd przypadający na pantograf i wstawić do GetVoltage() if( lastvoltage == 0.0 ) { // HACK: retrieve the wire voltage for calculations down the road without blowing up the supply - physics->PantRearVolt = p->hvPowerWire->VoltageGet( physics->PantographVoltage, 0.0 ); + physics->pantographCircuit.rearVoltage = p->hvPowerWire->VoltageGet( physics->pantographCircuit.supplyVoltage, 0.0 ); } else { - physics->PantRearVolt = p->hvPowerWire->VoltageGet( physics->PantographVoltage, fPantCurrent ); - if( physics->PantRearVolt > 0.0 ) { + physics->pantographCircuit.rearVoltage = p->hvPowerWire->VoltageGet( physics->pantographCircuit.supplyVoltage, fPantCurrent ); + if( physics->pantographCircuit.rearVoltage > 0.0 ) { fCurrent -= fPantCurrent; // taki prąd płynie przez powyższy pantograf (unless it doesn't) } } // TODO: refactor reaction to voltage change to physics as sound event for specific pantograph if( lastvoltage == 0.0 - && physics->PantRearVolt > 0.0 ) { + && physics->pantographCircuit.rearVoltage > 0.0 ) { for( auto &pantograph : m_pantographsounds ) { if( pantograph.sPantUp.offset().z < 0 ) { // limit to pantographs located in the rear half of the vehicle @@ -1154,13 +1154,13 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d } } else - physics->PantRearVolt = 0.0; + physics->pantographCircuit.rearVoltage = 0.0; } else { // Global.iPause ^= 2; - physics->PantRearVolt = 0.0; + physics->pantographCircuit.rearVoltage = 0.0; } - ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->PantRearVolt * fPantCurrent * dt1 / 3600000.0; + ( fPantCurrent > 0.0 ? physics->EnergyMeter.first : physics->EnergyMeter.second ) += physics->pantographCircuit.rearVoltage * fPantCurrent * dt1 / 3600000.0; break; } // pozostałe na razie nie obsługiwane } @@ -1169,13 +1169,13 @@ void TDynamicObject::updatePantographVoltage( int const i, TAnimPant const *p, d void TDynamicObject::updatePantographMotion( int const i, TAnimPant *p, double const PantDiff, double const dt1 ) { double k; // tymczasowy kąt - if( physics->PantPress > ( + if( physics->pantographAir.pressure > ( physics->TrainType == train_type::emu ? 2.45 : // Ra 2013-12: Niebugocław mówi, że w EZT podnoszą się przy 2.5 3.45 ) ) { // z EXE Kursa // Ra: wysokość zależy od ciśnienia !!! - pantspeedfactor = 0.015 * physics->PantPress * dt1; + pantspeedfactor = 0.015 * physics->pantographAir.pressure * dt1; } else { pantspeedfactor = 0.0; @@ -1186,7 +1186,7 @@ void TDynamicObject::updatePantographMotion( int const i, TAnimPant *p, double c pantspeedfactor = std::max( 0.0, pantspeedfactor ); k = p->fAngleL; if( pantspeedfactor > 0.0 - && physics->Pantographs[i].is_active )// jeśli ma być podniesiony + && physics->pantographs[i].is_active )// jeśli ma być podniesiony { if (PantDiff > 0.001) // jeśli nie dolega do drutu { // jeśli poprzednia wysokość jest mniejsza niż pożądana, zwiększyć kąt dolnego @@ -1235,8 +1235,8 @@ void TDynamicObject::updatePantographMotion( int const i, TAnimPant *p, double c void TDynamicObject::playPantographDropSounds() { // TBD, TODO: generate sound event during physics update instead? - if( physics->Pantographs[VehicleEnd::front].sound_event != physics->Pantographs[ VehicleEnd::front ].is_active ) { - if( physics->Pantographs[ VehicleEnd::front ].is_active ) { + if( physics->pantographs[VehicleEnd::front].sound_event != physics->pantographs[ VehicleEnd::front ].is_active ) { + if( physics->pantographs[ VehicleEnd::front ].is_active ) { // pantograph moving up // TBD: add a sound? } @@ -1249,10 +1249,10 @@ void TDynamicObject::playPantographDropSounds() } } } - physics->Pantographs[ VehicleEnd::front ].sound_event = physics->Pantographs[ VehicleEnd::front ].is_active; + physics->pantographs[ VehicleEnd::front ].sound_event = physics->pantographs[ VehicleEnd::front ].is_active; } - if( physics->Pantographs[ VehicleEnd::rear ].sound_event != physics->Pantographs[ VehicleEnd::rear ].is_active ) { - if( physics->Pantographs[ VehicleEnd::rear ].is_active ) { + if( physics->pantographs[ VehicleEnd::rear ].sound_event != physics->pantographs[ VehicleEnd::rear ].is_active ) { + if( physics->pantographs[ VehicleEnd::rear ].is_active ) { // pantograph moving up // TBD: add a sound? } @@ -1265,7 +1265,7 @@ void TDynamicObject::playPantographDropSounds() } } } - physics->Pantographs[ VehicleEnd::rear ].sound_event = physics->Pantographs[ VehicleEnd::rear ].is_active; + physics->pantographs[ VehicleEnd::rear ].sound_event = physics->pantographs[ VehicleEnd::rear ].is_active; } } @@ -1394,7 +1394,7 @@ void TDynamicObject::pants_up() TDynamicObject *d = this; bool isAnyPantUp = false; while (d) { - for (auto &item : d->physics->Pantographs) + for (auto &item : d->physics->pantographs) { isAnyPantUp |= item.is_active; } @@ -1402,7 +1402,7 @@ void TDynamicObject::pants_up() } d = Prev(Coupling::control); while (d) { - for (auto &item : d->physics->Pantographs) + for (auto &item : d->physics->pantographs) { isAnyPantUp |= item.is_active; } diff --git a/vehicle/dynamic/vehicletable.cpp b/vehicle/dynamic/vehicletable.cpp index 6fb994068..447579c9d 100644 --- a/vehicle/dynamic/vehicletable.cpp +++ b/vehicle/dynamic/vehicletable.cpp @@ -724,7 +724,7 @@ vehicle_table::update_traction( TDynamicObject *Vehicle ) { for( int pantographindex = 0; pantographindex < Vehicle->iAnimType[ ANIM_PANTS ]; ++pantographindex ) { // pętla po pantografach auto *pantograph { Vehicle->pants[ pantographindex ].fParamPants }; - if( true == Vehicle->physics->Pantographs[ pantographindex ].is_active ) { + if( true == Vehicle->physics->pantographs[ pantographindex ].is_active ) { // jeśli pantograf podniesiony auto const pant0 { position + vLeft * pantograph->vPos.z + vUp * pantograph->vPos.y + vFront * pantograph->vPos.x }; if( pantograph->hvPowerWire != nullptr ) { diff --git a/widgets/vehicleparams.cpp b/widgets/vehicleparams.cpp index b53f23f01..edc3568b7 100644 --- a/widgets/vehicleparams.cpp +++ b/widgets/vehicleparams.cpp @@ -63,9 +63,9 @@ void ui::vehicleparams_panel::draw_mini(const physics::Vehicle &physics) { ImGui::Image((ImTextureID)(intptr_t)(tex.get_id()), ImVec2(x, y), ImVec2(0, 1), ImVec2(1, 0)); - if (physics.Pantographs[VehicleEnd::rear].is_active) + if (physics.pantographs[VehicleEnd::rear].is_active) draw_infobutton("╨╨╨", ImVec2(126, 10)); - if (physics.Pantographs[VehicleEnd::front].is_active) + if (physics.pantographs[VehicleEnd::front].is_active) draw_infobutton("╨╨╨", ImVec2(290, 10)); if (physics.Battery) @@ -148,8 +148,8 @@ 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.PantRearVolt > 0.0 ? 'O' : 'o') : '.'), - (physics.Pantographs[VehicleEnd::front].is_active ? (physics.PantFrontVolt > 0.0 ? 'P' : 'p') : '.'), (physics.PantPressLockActive ? '!' : (physics.PantPressSwitchActive ? '*' : '.')), + (physics.Battery ? 'B' : '.'), (physics.Mains ? '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' : '.')), @@ -213,7 +213,7 @@ void ui::vehicleparams_panel::render_contents() if (physics.EnginePowerSource.SourceType == TPowerSource::CurrentCollector) { - std::snprintf(buffer.data(), buffer.size(), STR_C(" pantograph: %.2f%cMT"), physics.PantPress, (physics.bPantKurek3 ? '-' : '|')); + std::snprintf(buffer.data(), buffer.size(), STR_C(" pantograph: %.2f%cMT"), physics.pantographAir.pressure, (physics.pantographAir.connectedToMainReservoir ? '-' : '|')); ImGui::TextUnformatted(buffer.data()); }