18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 12:16:02 +01:00

Merge remote-tracking branch 'origin/master' into feat/elf-master-controller-emergency-brake

# Conflicts:
#	McZapkie/Mover.cpp
This commit is contained in:
jerrrrycho
2026-11-09 15:30:38 +01:00
155 changed files with 8068 additions and 546 deletions

View File

@@ -17,6 +17,7 @@ http://mozilla.org/MPL/2.0/.
#include "utilities/parser.h"
#include "simulation/simulation.h"
#include <charconv>
#include <cmath>
#include <format>
//---------------------------------------------------------------------------
@@ -152,11 +153,23 @@ void TSecuritySystem::update(double dt, double vel, bool pwr, int cab)
velocity = vel;
cabactive = cab;
if (vigilance_enabled && velocity > AwareMinSpeed)
vigilance_timer += dt;
if (vigilance_suspended)
{
// the vigilance device is switched off: no time counts towards a new alarm, of the alerter or of the button held
// too long. an alarm already on, with the emergency braking it leads to, stays until it's acknowledged as usual
if (vigilance_timer <= AwareDelay)
vigilance_timer = 0.0;
if (press_timer <= MaxHoldTime)
press_timer = 0.0;
}
else
{
if (vigilance_enabled && velocity > AwareMinSpeed)
vigilance_timer += dt;
if (pressed && (!is_sifa || velocity > AwareMinSpeed))
press_timer += dt;
if (pressed && (!is_sifa || velocity > AwareMinSpeed))
press_timer += dt;
}
if (vigilance_timer > AwareDelay || press_timer > MaxHoldTime || cabsignal_active)
alert_timer += dt;
@@ -231,6 +244,11 @@ void TSecuritySystem::set_cabsignal_lock(bool v)
cabsignal_lock = v;
}
void TSecuritySystem::set_shunt_mode(bool const State)
{
vigilance_suspended = State && AwareOffInShuntMode;
}
bool TSecuritySystem::is_engine_blocked() const
{
if (!is_sifa)
@@ -260,6 +278,7 @@ void TSecuritySystem::load(std::string const &line, double Vmax)
extract_value(radiostop_enabled, "RadioStop", line, "");
extract_value(MagnetLocation, "MagnetLocation", line, "");
extract_value(CabDependent, "CabDependent", line, "");
extract_value(AwareOffInShuntMode, "AwareOffInShuntMode", line, "");
}
double TableInterpolation(std::map<double, double> &Map, double Parameter)
@@ -599,7 +618,8 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
}
auto &thiscoupler{Couplers[ConnectNo]};
auto &othercoupler = ConnectTo->Couplers[ConnectToNr != 2 ? ConnectToNr : thiscoupler.ConnectedNr];
auto const otherend{ConnectToNr != 2 ? ConnectToNr : thiscoupler.ConnectedNr};
auto &othercoupler = ConnectTo->Couplers[otherend];
auto const distance{CouplerDist(this, ConnectTo) - (thiscoupler.adapter_length + othercoupler.adapter_length)};
@@ -608,6 +628,18 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
return false;
}
// no multiple-unit control between an electric and a diesel locomotive, whoever asks for it: the scenario, the AI
// or the player (eu07/maszyna#520)
if (auto const compatible{CompatibleCoupling(ConnectNo, *ConnectTo, otherend, CouplingType)}; compatible != CouplingType)
{
WriteLog(std::format("Vehicles \"{}\" and \"{}\" can't share their control, coupled without the control connection", Name, ConnectTo->Name));
CouplingType = compatible;
if (CouplingType == coupling::faux)
{
return false;
}
}
// stykaja sie zderzaki i kompatybilne typy sprzegow, chyba że łączenie na starcie
if (thiscoupler.CouplingFlag == coupling::faux)
{
@@ -809,6 +841,19 @@ bool TMoverParameters::ChangeCab(int direction)
// rozruch wysoki (true) albo niski (false)
bool TMoverParameters::CurrentSwitch(bool const State)
{
// TBD, TODO: split off shunt mode toggle into a separate command? It doesn't make much sense to have these two together like that
// the diesels with a shunt mode have no motor overload relay threshold to switch, the switch sets their shunt mode alone.
// MaxCurrentSwitch() takes any change of the setting, so asked first it took the first move of the switch (eu07/maszyna#497)
if (true == ShuntModeAllow && (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric))
{
// dla 2Ls150 przed ustawieniem kierunku, for SM42/SP42 at the controller's zero position
if (EngineType == TEngineType::DieselEngine ? DirActive != 0 : false == IsMainCtrlNoPowerPos())
{
return false;
}
ShuntMode = State;
return true;
}
if (MaxCurrentSwitch(State))
{
@@ -818,20 +863,6 @@ bool TMoverParameters::CurrentSwitch(bool const State)
}
return true;
}
// TBD, TODO: split off shunt mode toggle into a separate command? It doesn't make much sense to have these two together like that
// dla 2Ls150
if (EngineType == TEngineType::DieselEngine && true == ShuntModeAllow && DirActive == 0)
{
// przed ustawieniem kierunku
ShuntMode = State;
return true;
}
// for SM42/SP42
if (EngineType == TEngineType::DieselElectric && true == ShuntModeAllow && IsMainCtrlNoPowerPos())
{
ShuntMode = State;
return true;
}
return false;
};
@@ -1206,6 +1237,59 @@ bool TMoverParameters::AutomaticCouplingSafe(int const End, TMoverParameters con
return false == Global.crash_damage || CollisionVelocity(End, Other, OtherEnd) <= SafeCollisionVelocity;
}
namespace
{
// the kind of traction a vehicle's engine stands for, as far as its multiple-unit control goes
enum class traction_kind
{
none,
electric,
diesel
};
traction_kind traction_of(TEngineType const Engine)
{
switch (Engine)
{
case TEngineType::ElectricSeriesMotor:
case TEngineType::ElectricInductionMotor:
return traction_kind::electric;
case TEngineType::DieselEngine:
case TEngineType::DieselElectric:
return traction_kind::diesel;
default:
return traction_kind::none;
}
}
} // namespace
bool TMoverParameters::ControlCouplingAllowed(int const End, TMoverParameters const &Other, int const OtherEnd) const
{
if (false == Global.control_coupling_engine_check)
{
return true;
}
// the same control system named on both couplers is the vehicle authors' word that they work together
if (auto const &controltype{Couplers[End].control_type}; false == controltype.empty() && controltype == Other.Couplers[OtherEnd].control_type)
{
return true;
}
auto const traction{traction_of(EngineType)};
auto const othertraction{traction_of(Other.EngineType)};
return traction == traction_kind::none || othertraction == traction_kind::none || traction == othertraction;
}
int TMoverParameters::CompatibleCoupling(int const End, TMoverParameters const &Other, int const OtherEnd, int const CouplingType) const
{
if ((CouplingType & coupling::control) == 0 || (CouplingType & coupling::permanent) != 0 || ControlCouplingAllowed(End, Other, OtherEnd))
{
return CouplingType;
}
return CouplingType & ~coupling::control;
}
int TMoverParameters::SoundingHorns(int const Signal) const
{
auto const supplied{[this](horn_supply const Supply) {
@@ -1631,6 +1715,8 @@ void TMoverParameters::compute_movement_(double const Deltatime)
BRVentilators = false;
}
// the master controller set directly, not through IncMainCtrl()/DecMainCtrl() (AI, consist): the locked shunt follows it as well
ScndCtrlResistiveLockCheck();
// automatyczny rozruch
if (EngineType == TEngineType::ElectricSeriesMotor && AutoRelayCheck())
{
@@ -2537,6 +2623,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
if (true == OK)
{
ScndCtrlResistiveLockCheck(); // e.g. from the last series position on to the resistive parallel ones
SendCtrlToNext("MainCtrl", MainCtrlPosForCoupled(), CabActive); //???
SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabActive);
}
@@ -2662,6 +2749,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
if (OK)
{
ScndCtrlResistiveLockCheck(); // the shunt drops when the master controller leaves a resistance-free position
/*OK:=*/SendCtrlToNext("MainCtrl", MainCtrlPosForCoupled(), CabActive); // hmmmm...???!!!
/*OK:=*/SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabActive);
}
@@ -2772,7 +2860,7 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed)
{
// if (RList[MainCtrlPos].R=0) and (MainCtrlPos>0) and (ScndCtrlPos<ScndCtrlPosNo) and
// (not CoupledCtrl) then
if (ScndCtrlPos < ScndCtrlPosNo && !CoupledCtrl)
if (ScndCtrlPos < ScndCtrlPosNo && !CoupledCtrl && !IsScndCtrlLockedByMainCtrl())
{
// TBD, TODO: refactor this validation as part of relay check routine (currently in tractionforce()
// TBD, TODO: diesel electric engine utilize scndctrlactualpos like the other types?
@@ -2843,7 +2931,7 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
}
else if (ScndCtrlPosNo > 0 && CabActive != 0)
{
if (ScndCtrlPos > 0 && !CoupledCtrl && (EngineType != TEngineType::DieselElectric || !AutoRelayFlag))
if (ScndCtrlPos > 0 && !CoupledCtrl && (EngineType != TEngineType::DieselElectric || !AutoRelayFlag) && !IsScndCtrlLockedByMainCtrl())
{
if (CtrlSpeed == 1)
{
@@ -2893,6 +2981,22 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
return OK;
}
bool TMoverParameters::IsScndCtrlLockedByMainCtrl() const
{
// ET21, ET22, EP09: the field shunting engages only on the resistance-free positions of the master controller (eu07/maszyna#402)
return ScndCtrlResistiveLock && (IsMainCtrlNoPowerPos() || RList[MainCtrlPos].R >= 0.01);
}
void TMoverParameters::ScndCtrlResistiveLockCheck()
{
// the shunt controller, locked in both directions on zero and the resistive positions, would otherwise stay engaged there once the
// master controller is taken back (or set from elsewhere, e.g. by the AI or another vehicle of the consist) with the shunt on
if (ScndCtrlPos > 0 && !CoupledCtrl && IsScndCtrlLockedByMainCtrl())
{
ScndCtrlPos = 0;
}
}
int TMoverParameters::GetVirtualScndPos() const
{
if (TrainType == dt_ET42 && DynamicBrakeFlag && !ScndCtrlPos)
@@ -3164,9 +3268,11 @@ void TMoverParameters::SecuritySystemReset(void) // zbijanie czuwaka/SHP
void TMoverParameters::SecuritySystemCheck(double dt)
{
bool isPower = Power24vIsAvailable || Power110vIsAvailable;
// the shunt mode of the SM42 switches its vigilance device (CA) off, on the vehicles with AwareOffInShuntMode=Yes (eu07/maszyna#457)
SecuritySystem.set_shunt_mode(ShuntMode);
SecuritySystem.update(dt, Vel, isPower, CabActive);
if (!Battery || !Radio)
if (!Battery || !Radio || !RadioFuse)
{ // wyłączenie baterii deaktywuje sprzęt
RadiostopSwitch(false);
}
@@ -4182,7 +4288,8 @@ bool TMoverParameters::SwitchEPBrake(int state)
OK = false;
if (BrakeHandle == TBrakeHandle::St113 && CabOccupied != 0)
{
if (state > 0)
// the handle works the EP contactors pneumatically, their supply is cut as the Oerlikon handle's is
if (state > 0 && EPBrakeControlPowered())
EpForce = Handle->GetEP(); // TODO: przetlumaczyc
else
EpForce = 0;
@@ -4194,6 +4301,11 @@ bool TMoverParameters::SwitchEPBrake(int state)
return OK;
}
bool TMoverParameters::EPBrakeControlPowered() const
{
return Power24vIsAvailable && DirActive != 0 && EpFuse;
}
// *************************************************************************************************
// Q: 20160711
// zwiększenie ciśnienia hamowania
@@ -4728,7 +4840,7 @@ void TMoverParameters::UpdatePipePressure(double dt)
if ((BrakeHandle == TBrakeHandle::FVel6 || BrakeHandle == TBrakeHandle::FVE408) && CabOccupied != 0)
{
if (Power24vIsAvailable && DirActive != 0 && EpFuse) // tu powinien byc jeszcze bezpiecznik EP i baterie -
if (EPBrakeControlPowered()) // tu powinien byc jeszcze bezpiecznik EP i baterie -
// temp = (Handle as TFVel6).GetCP
EpForce = Handle->GetEP();
else
@@ -4747,6 +4859,11 @@ void TMoverParameters::UpdatePipePressure(double dt)
// Ra 2014-11: na tym się wysypuje, ale nie wiem, w jakich warunkach
SendCtrlToNext("Brake", EpForce, CabActive);
}
else if (BrakeHandle == TBrakeHandle::St113 && CabOccupied != 0 && std::abs(EpForce) > 0.001 && !EPBrakeControlPowered())
{
// the EP brake switched on with the button drops out with the control's supply
SwitchEPBrake(0);
}
Pipe->Act();
PipePress = Pipe->P();
@@ -5169,6 +5286,7 @@ void TMoverParameters::ComputeTotalForce(double dt)
double TMoverParameters::BrakeForceR(double ratio, double velocity) const
{
double press = 0;
ratio = Hamulec->GetBrakeRatio(ratio);
if (MBPM > 2)
{
press = MaxBrakePress[1] + (MaxBrakePress[3] - MaxBrakePress[1]) * std::min(1.0, (TotalMass - Mass) / (MBPM - Mass));
@@ -5184,8 +5302,8 @@ double TMoverParameters::BrakeForceR(double ratio, double velocity) const
press = MaxBrakePress[3];
if (DynamicBrakeType == dbrake_automatic)
ratio = ratio + (1.5 - ratio) * std::min(1.0, Vel * 0.02);
if (BrakeDelayFlag & bdelay_R && BrakeMethod % 128 != bp_Cosid && BrakeMethod % 128 != bp_D1 && BrakeMethod % 128 != bp_D2 && Power < 1 && velocity < 40)
ratio = ratio / 2;
if (BrakeDelayFlag & bdelay_R && BrakeMethod % 128 != bp_Cosid && BrakeMethod % 128 != bp_D1 && BrakeMethod % 128 != bp_D2 && Power < 1)
ratio *= Hamulec->GetRapidRatio(velocity);
if (TrainType == dt_DMU && velocity < 30.0)
{
ratio -= 0.3;
@@ -5476,6 +5594,7 @@ double TMoverParameters::CouplerForce(int const End, double dt)
{
couplingtype &= ~coupling::control;
}
couplingtype = CompatibleCoupling(End, *othervehicle, otherend, couplingtype);
// too fast for the couplers to catch, the vehicles collide instead (and may derail, see CollisionDetect())
auto const safe{AutomaticCouplingSafe(End, *othervehicle, otherend)};
@@ -7312,6 +7431,60 @@ bool TMoverParameters::DropAllPantographs(bool const State, range_t const Notify
return State != initialstate;
}
namespace
{
// the setting of the universal controller one UniCtrlValStep further from Value towards Limit, never past it
double next_uc_step(double const Value, double const Limit, double const Step)
{
constexpr double epsilon{1e-6};
if (Limit > Value)
{
return std::min((std::floor(Value / Step + epsilon) + 1.0) * Step, Limit);
}
return std::max((std::ceil(Value / Step - epsilon) - 1.0) * Step, Limit);
}
// the universal controller with UniCtrlValStep: the setting the continuous ramp got to (Ramped) turned into whole steps.
// a move of the controller onto a position which changes the setting makes one step at once, the ramp then one step each
// time it covers a step's length; the steps stop at the position's set value (or its bound, past which the ramp doesn't go)
double stepped_uc_value(double const Current, double const Ramped, TUniversalCtrl const &Position, double const Step, bool const Moved, double &Progress)
{
if (Moved)
{
Progress = 0.0;
}
double const delta{Ramped - Current};
if (std::abs(delta) < 1e-9)
{
Progress = 0.0;
return Ramped;
}
double limit{0.0};
if (delta > 0.0)
{
limit = Position.SetCtrlVal > Current ? Position.SetCtrlVal : Position.MaxCtrlVal;
}
else
{
limit = Position.SetCtrlVal < Current ? Position.SetCtrlVal : Position.MinCtrlVal;
}
Progress = Moved ? Step : Progress + std::abs(delta);
double value{Current};
bool reached{std::abs(value - limit) < 1e-9};
while (!reached && Progress >= Step - 1e-9)
{
value = next_uc_step(value, limit, Step);
Progress -= Step;
reached = std::abs(value - limit) < 1e-9;
}
if (reached)
{
Progress = 0.0;
}
return safe_clamp(value, Position.MinCtrlVal, Position.MaxCtrlVal);
}
} // namespace
void TMoverParameters::CheckEIMIC(double dt)
{
double offset = EIMCtrlAdditionalZeros ? 1.0 : 0.0;
@@ -7442,11 +7615,14 @@ void TMoverParameters::CheckEIMIC(double dt)
if (MainCtrlActualPos != MainCtrlPos || LastRelayTime > InitialCtrlDelay)
{
eimic -= safe_clamp(-UniCtrlList[MainCtrlPos].SetCtrlVal + eimic, 0.0,
MainCtrlActualPos == MainCtrlPos ? dt * UniCtrlList[MainCtrlPos].SpeedDown : sign(UniCtrlList[MainCtrlPos].SpeedDown) * 0.01); // odejmuj do X
eimic += safe_clamp(UniCtrlList[MainCtrlPos].SetCtrlVal - eimic, 0.0,
MainCtrlActualPos == MainCtrlPos ? dt * UniCtrlList[MainCtrlPos].SpeedUp : sign(UniCtrlList[MainCtrlPos].SpeedUp) * 0.01); // dodawaj do X
eimic = safe_clamp(eimic, UniCtrlList[MainCtrlPos].MinCtrlVal, UniCtrlList[MainCtrlPos].MaxCtrlVal);
auto const &position{UniCtrlList[MainCtrlPos]};
double ramped{eimic};
ramped -= safe_clamp(-position.SetCtrlVal + ramped, 0.0,
MainCtrlActualPos == MainCtrlPos ? dt * position.SpeedDown : sign(position.SpeedDown) * 0.01); // odejmuj do X
ramped += safe_clamp(position.SetCtrlVal - ramped, 0.0,
MainCtrlActualPos == MainCtrlPos ? dt * position.SpeedUp : sign(position.SpeedUp) * 0.01); // dodawaj do X
ramped = safe_clamp(ramped, position.MinCtrlVal, position.MaxCtrlVal);
eimic = UniCtrlValStep > 0.0 ? stepped_uc_value(eimic, ramped, position, UniCtrlValStep, MainCtrlActualPos != MainCtrlPos, eimic_step_progress) : ramped;
}
if (MainCtrlActualPos == MainCtrlPos)
LastRelayTime += dt;
@@ -7871,6 +8047,9 @@ bool TMoverParameters::dizel_Update(double dt)
WaterHeaterCheck(dt);
OilPumpCheck(dt);
FuelPumpCheck(dt);
// the engine being started fires once the starter has turned it a while; one stopped meanwhile starts over
dizel_FiringCountdown = (Mains ? std::max(0.0, dizel_FiringCountdown - dt) : 0.0);
if (true == dizel_startup && true == dizel_StartupCheck())
{
dizel_ignition = true;
@@ -7885,6 +8064,7 @@ bool TMoverParameters::dizel_Update(double dt)
LastSwitchingTime = 0;
Mains = true;
dizel_spinup = true;
dizel_FiringCountdown = dizel_SmokeDelay;
enrot = std::max(enrot,
0.35 * ( // TODO: dac zaleznie od temperatury i baterii
EngineType == TEngineType::DieselEngine ? dizel_nmin : DElist[0].RPM / 60.0));
@@ -7896,7 +8076,8 @@ bool TMoverParameters::dizel_Update(double dt)
{
// knock out the engine if the fuel pump isn't feeding it
// TBD, TODO: grace period before the engine is starved for fuel and knocked out
MainSwitch(false);
// an engine started on its own stops on its own
MainSwitch(false, MainSwitchRange());
}
bool DU{false};
@@ -8187,7 +8368,13 @@ double TMoverParameters::dizel_Momentum(double Fill, double n, double dt)
if (enrot <= 0 && false == dizel_spinup)
{
MainSwitch(false);
// an engine stalling stops those started together with it, once. one already stopped, from its own switch or
// another vehicle's, or not started at all, has nothing to stop: it stays quiet, rather than stop every frame
// the engines started on their own or from the separate switches (eu07/maszyna#80)
if (true == Mains)
{
MainSwitch(false, MainSwitchRange());
}
enrot = 0;
}
@@ -8726,6 +8913,48 @@ bool TMoverParameters::signal_departure(bool const State, range_t const Notify)
return true;
}
// state of the door closure signalling (SOD) of this vehicle: open while a door isn't fully closed, released while
// the closed doors can be opened (a permit given, or, for doors that need none, no lock engaged), locked otherwise.
// doors the crew doesn't close (autonomous) aren't signalled, the same as for the door lights of the consist
door_closure_t TMoverParameters::door_closure() const
{
if (Doors.range == 0.f || Doors.close_control == control_t::autonomous)
{
return door_closure_t::none;
}
if (std::ranges::any_of(Doors.instances, [](basic_door const &Door) { return false == Door.is_closed; }))
{
return door_closure_t::open;
}
if (Doors.is_locked)
{
return door_closure_t::locked;
}
if (Doors.permit_needed && std::ranges::none_of(Doors.instances, [](basic_door const &Door) { return Door.open_permit; }))
{
return door_closure_t::locked;
}
return door_closure_t::released;
}
bool TMoverParameters::door_closure_lamp_lit(door_closure_t const Consist, bool const BlinkLit) const
{
return Doors.closure_signal ? door_closure_lamp(Consist, BlinkLit) : Doors.is_locked;
}
bool door_closure_lamp(door_closure_t const State, bool const BlinkLit)
{
switch (State)
{
case door_closure_t::locked:
return true;
case door_closure_t::released:
return BlinkLit;
default:
return false;
}
}
// automatic door controller update
void TMoverParameters::update_doors(double const Deltatime)
{
@@ -9475,6 +9704,52 @@ bool TMoverParameters::readDimmerList(std::string const &line)
return true;
}
int TMoverParameters::clampDimmerPosition(int const Position) const
{
if (dimPositions.empty())
{
return 0;
}
return std::clamp(Position, 0, static_cast<int>(dimPositions.size()) - 1);
}
TMoverParameters::dimPosition TMoverParameters::currentDimPosition() const
{
if (modernDimmerPosition < 0 || modernDimmerPosition >= static_cast<int>(dimPositions.size()))
{
return {};
}
return dimPositions[modernDimmerPosition];
}
bool TMoverParameters::stepDimmerPosition(int const Step)
{
if (dimPositions.empty())
{
return false;
}
auto const last{static_cast<int>(dimPositions.size()) - 1};
auto const current{clampDimmerPosition(modernDimmerPosition)};
auto next{current + Step};
if (next < 0 || next > last)
{
if (false == modernDimmerCanCycle)
{
next = current;
}
else
{
next = (next < 0 ? last : 0);
}
}
if (next == modernDimmerPosition)
{
return false;
}
modernDimmerPosition = next;
return true;
}
// parsowanie WWList
bool TMoverParameters::readWWList(std::string const &line)
{
@@ -9520,10 +9795,38 @@ bool TMoverParameters::readLightsList(std::string const &Input)
return false;
}
parser >> Lights[0][idx] >> Lights[1][idx];
// optional third column: the cab interior light the preset sets (eu07/maszyna#529). anything but a whole number
// (some rows carry stray notes after the two columns) leaves the cab light to its own switch
LightsCabLight[idx] = -1;
if (true == parser.getTokens(1, false))
{
std::string cablight;
parser >> cablight;
int flags{-1};
auto const [end, error]{std::from_chars(cablight.data(), cablight.data() + cablight.size(), flags)};
if (error == std::errc{} && end == cablight.data() + cablight.size() && flags >= 0)
{
LightsCabLight[idx] = flags;
}
}
return true;
}
std::optional<lights_preset_cablight> TMoverParameters::LightsPresetCabLight(int const Position) const
{
if (Position < 1 || Position > static_cast<int>(LightsCabLight.size()))
{
return std::nullopt;
}
auto const flags{LightsCabLight[Position - 1]};
if (flags < 0)
{
return std::nullopt;
}
return lights_preset_cablight{(flags & lights_preset_cablight::light_on) != 0, (flags & lights_preset_cablight::light_dimmed) != 0};
}
bool TMoverParameters::readCompressorList(std::string const &Input)
{
@@ -10276,6 +10579,9 @@ bool TMoverParameters::LoadFIZ_Parse(cParser &fizparser) // NOSONAR the former b
result = false;
// ustawiamy domyslna pozycje dimmera
// the DefaultPos of a short or an empty DimmerList would put the dimmer outside of it
modernDimmerDefaultPosition = clampDimmerPosition(modernDimmerDefaultPosition);
modernDimmerPosition = clampDimmerPosition(modernDimmerPosition);
if (!enableModernDimmer)
{
modernDimmerPosition = modernDimmerDefaultPosition;
@@ -10603,6 +10909,8 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line)
extract_value(Doors.auto_include_remote, "DoorAutoCloseRemote", line, "");
// operation permit
extract_value(Doors.permit_needed, "DoorNeedPermit", line, "");
// the door closure lamp (SOD) of the cab signals the doors of the whole consist
extract_value(Doors.closure_signal, "DoorClosureSignal", line, "");
{
auto permitpresets = Split(extract_value("DoorPermitList", line), '|');
for (auto const &permit : permitpresets)
@@ -10935,6 +11243,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
}
extract_value(ScndS, "ScndS", line, ""); // brak pozycji rownoleglej przy niskiej nastawie PSR
extract_value(ScndCtrlResistiveLock, "ScndCtrlResistiveLock", line, ""); // bocznikowanie tylko na pozycjach bezoporowych
extract_value(InitialCtrlDelay, "IniCDelay", line, "");
extract_value(CtrlDelay, "SCDelay", line, "");
@@ -11195,6 +11504,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input)
{
EngineType = LoadFIZ_EngineDecode(extract_value("EngineType", Input));
extract_value(JointEngineStart, "JointEngineStart", Input, "");
if (std::string transmission = extract_value("Trans", Input); false == transmission.empty())
{
@@ -11403,6 +11713,9 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input)
// oil pump
extract_value(OilPump.pressure_minimum, "OilMinPressure", Input, "");
extract_value(OilPump.pressure_maximum, "OilMaxPressure", Input, "");
// the time the starter turns the engine before it fires and smokes (eu07/maszyna#523)
extract_value(dizel_SmokeDelay, "SmokeDelay", Input, "0");
dizel_SmokeDelay = std::max(0.0, dizel_SmokeDelay);
// engine cooling factore
extract_value(dizel_heat.kw, "HeatKW", Input, "");
extract_value(dizel_heat.kv, "HeatKV", Input, "");
@@ -11428,7 +11741,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input)
// water heater
extract_value(WaterHeater.config.temp_min, "HeaterMinTemperature", Input, "");
extract_value(WaterHeater.config.temp_max, "HeaterMaxTemperature", Input, "");
float pf;
float pf{ 1235.f };
extract_value(pf, "NominalCoolingPower", Input, "1235");
dizel_heat.powerfactor = 1235 / pf;
}
@@ -11512,6 +11825,7 @@ void TMoverParameters::LoadFIZ_AI(std::string const &Input)
{
extract_value(AIHintPantstate, "Pantstate", Input, "");
extract_value(AIHintShuntPantstate, "ShuntPantstate", Input, "");
extract_value(AIHintPantUpIfIdle, "IdlePantUp", Input, "");
extract_value(AIHintLocalBrakeAccFactor, "LocalBrakeAccFactor", Input, "");
}
@@ -11553,6 +11867,8 @@ void TMoverParameters::LoadFIZ_UCList(std::string const &Input)
extract_value(UniCtrlIntegratedBrakeCtrl, "IntegratedBrake", Input, "");
extract_value(UniCtrlIntegratedLocalBrakeCtrl, "IntegratedLocBrake", Input, "");
extract_value(UniCtrlIntegratedBrakePNCtrl, "IntegratedBrakePN", Input, "");
extract_value(UniCtrlValStep, "CtrlValStep", Input, "");
UniCtrlValStep = std::max(UniCtrlValStep, 0.0);
}
void TMoverParameters::LoadFIZ_DList(std::string const &Input)