diff --git a/Console.h b/Console.h
index e99beb4b..1f7f9e2b 100644
--- a/Console.h
+++ b/Console.h
@@ -20,7 +20,8 @@ class TLPT;
class TKeyTrans
{ // przekodowanie kodu naciśnięcia i zwolnienia klawisza
public:
- short int iDown, iUp;
+ short int iDown;
+ short int iUp;
};
class Console
diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h
index accbbbaa..228834b4 100644
--- a/McZapkie/MOVER.h
+++ b/McZapkie/MOVER.h
@@ -764,7 +764,7 @@ enum class TLocalBrake
HydraulicBrake
};
/// Brake delay parameter table (apply/release for passenger and freight).
-typedef double TBrakeDelayTable[4];
+using TBrakeDelayTable = double[4];
/// One row of the brake pressure / pipe pressure / flow-speed table for a brake handle position.
struct TBrakePressure
@@ -780,7 +780,7 @@ struct TBrakePressure
};
/// Brake pressure table indexed by handle position.
-typedef std::map TBrakePressureTable;
+using TBrakePressureTable = std::map;
/// Engine / drive type.
enum class TEngineType
@@ -989,11 +989,11 @@ struct TTransducer
struct TPowerParameters
{
/// Maximum source voltage [V].
- double MaxVoltage;
+ double MaxVoltage{0.0};
/// Maximum source current [A].
- double MaxCurrent;
+ double MaxCurrent{0.0};
/// Internal resistance [Ω].
- double IntR;
+ double IntR{0.001};
/// Type of source (selects which union member is meaningful).
TPowerSource SourceType;
union
@@ -1028,10 +1028,7 @@ struct TPowerParameters
};
};
inline TPowerParameters()
- {
- MaxVoltage = 0.0;
- MaxCurrent = 0.0;
- IntR = 0.001;
+ {
SourceType = TPowerSource::NotDefined;
PowerType = TPowerType::NoPower;
RPowerCable.PowerTrans = TPowerType::NoPower;
@@ -1048,7 +1045,7 @@ struct TScheme
bool AutoSwitch = false; /*czy dana pozycja nastawniana jest recznie czy autom.*/
int ScndAct = 0; /*jesli ma bocznik w nastawniku, to ktory bocznik na ktorej pozycji*/
};
-typedef TScheme TSchemeTable[ResArraySize + 1]; /*tablica rezystorow rozr.*/
+using TSchemeTable = TScheme[ResArraySize + 1]; /*tablica rezystorow rozr.*/
struct TDEScheme
{
double RPM = 0.0; /*obroty diesla*/
@@ -1056,13 +1053,13 @@ struct TDEScheme
double Umax = 0.0; /*napiecie maksymalne*/
double Imax = 0.0; /*prad maksymalny*/
};
-typedef TDEScheme TDESchemeTable[33]; /*tablica WWList dla silnikow spalinowych*/
+using TDESchemeTable = TDEScheme[33]; /*tablica WWList dla silnikow spalinowych*/
struct TFFScheme
{
double v = 0.0; // parametr wejsciowy
double freq = 0.0; // wyjscie: czestotliwosc falownika
};
-typedef TFFScheme TFFSchemeTable[33];
+using TFFSchemeTable = TFFScheme[33];
struct TWiperScheme
{
@@ -1071,7 +1068,7 @@ struct TWiperScheme
double interval = 0.0; // interwal pracy wycieraczki
double outBackDelay = 0.0; // czas po jakim wycieraczka zacznie wracac z konca do poczatku
};
-typedef TWiperScheme TWiperSchemeTable[16];
+using TWiperSchemeTable = TWiperScheme[16];
struct TShuntScheme
{
@@ -1080,33 +1077,23 @@ struct TShuntScheme
double Pmin = 0.0;
double Pmax = 0.0;
};
-typedef TShuntScheme TShuntSchemeTable[33];
+using TShuntSchemeTable = TShuntScheme[33];
struct TMPTRelay
{ /*lista przekaznikow bocznikowania*/
double Iup = 0.0;
double Idown = 0.0;
};
-typedef TMPTRelay TMPTRelayTable[MotorParametersArraySize + 1]; // indexed like MotorParam
+using TMPTRelayTable = TMPTRelay[MotorParametersArraySize + 1]; // indexed like MotorParam
struct TMotorParameters
{
- double mfi;
- double mIsat;
- double mfi0; // aproksymacja M(I) silnika} {dla dizla mIsat=przekladnia biegu
- double fi;
- double Isat;
- double fi0; // aproksymacja E(n)=fi*n} {dla dizla fi, mfi: predkosci przelozenia biegu <->
- bool AutoSwitch;
- TMotorParameters()
- {
- mfi = 0.0;
- mIsat = 0.0;
- mfi0 = 0.0;
- fi = 0.0;
- Isat = 0.0;
- fi0 = 0.0;
- AutoSwitch = false;
- }
+ double mfi{0.0};
+ double mIsat{0.0};
+ double mfi0{0.0}; // aproksymacja M(I) silnika} {dla dizla mIsat=przekladnia biegu
+ double fi{0.0};
+ double Isat{0.0};
+ double fi0{0.0}; // aproksymacja E(n)=fi*n} {dla dizla fi, mfi: predkosci przelozenia biegu <->
+ bool AutoSwitch{false};
};
struct TUniversalCtrl
@@ -1240,7 +1227,7 @@ struct TCoupling
{
return adapter_type != TCouplerType::NoCoupler;
}
- inline TCouplerType const type() const
+ inline TCouplerType type() const
{
return adapter_type == TCouplerType::NoCoupler ? CouplerType : adapter_type;
}
@@ -1465,7 +1452,8 @@ class TMoverParameters
{
float temp_min{-1}; // lowest accepted temperature
float temp_max{-1}; // highest accepted temperature
- } config;
+ };
+ heater_config_t config;
// ld inputs
bool breaker{false}; // device is allowed to operate
bool is_enabled{false}; // device is requested to operate
@@ -1500,12 +1488,17 @@ class TMoverParameters
float temp_cooling{-1}; // active cooling activation point
float temp_flow{-1}; // fluid flow activation point
bool shutters{false}; // the radiator has shutters to assist the cooling
- } config;
+ };
+ circuit_config_t config;
bool is_cold{false}; // fluid is too cold
bool is_warm{false}; // fluid is too hot
bool is_hot{false}; // fluid temperature crossed cooling threshold
bool is_flowing{false}; // fluid is being pushed through the circuit
- } water, water_aux, oil, engine;
+ };
+ fluid_circuit_t water;
+ fluid_circuit_t water_aux;
+ fluid_circuit_t oil;
+ fluid_circuit_t engine;
// output, state of affected devices
bool PA{false}; // malfunction flag
float rpmw{0.0}; // current main circuit fan revolutions
@@ -1889,9 +1882,9 @@ class TMoverParameters
double MED_Vmin = 0; // predkosc minimalna dla obliczen chwilowej sily hamowania EP w MED
double MED_Vref = 0; // predkosc referencyjna dla obliczen dostepnej sily hamowania EP w MED
double MED_amax{9.81}; // maksymalne opoznienie hamowania sluzbowego MED
- bool MED_EPVC = 0; // czy korekcja sily hamowania EP, gdy nie ma dostepnego ED
+ bool MED_EPVC = false; // czy korekcja sily hamowania EP, gdy nie ma dostepnego ED
double MED_EPVC_Time = 7; // czas korekcji sily hamowania EP, gdy nie ma dostepnego ED
- bool MED_Ncor = 0; // czy korekcja sily hamowania z uwzglednieniem nacisku
+ bool MED_Ncor = false; // czy korekcja sily hamowania z uwzglednieniem nacisku
double MED_MinBrakeReqED = 0; // minimalne zadanie sily hamowania uruchamiajace ED - ponizej tylko EP
double MED_FrED_factor = 1; // mnoznik sily hamowania ED do korekty blendingu
double MED_ED_Delay1 = 0; // opoznienie wdrazania hamowania ED (pierwszy raz)
@@ -2099,7 +2092,7 @@ class TMoverParameters
int CabActive = 0; // numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad
int CabOccupied = 0; // numer kabiny, w ktorej jest obsada (zwykle jedna na skład) // TODO: move to TController
bool CabMaster = false; // czy pojazd jest nadrzędny w składzie
- inline bool IsCabMaster()
+ inline bool IsCabMaster() const
{
return CabActive == CabOccupied && CabMaster;
} // czy aktualna kabina jest na pewno tą, z której można sterować
@@ -2294,8 +2287,7 @@ class TMoverParameters
bool AIHintPantUpIfIdle{true}; // whether raise both pantographs if idling for a while
double AIHintLocalBrakeAccFactor{1.05}; // suggested acceleration weight for local brake operation
- public:
- TMoverParameters(double VelInitial, std::string TypeNameInit, std::string NameInit, int Cab);
+ TMoverParameters(double VelInitial, std::string const &TypeNameInit, std::string const &NameInit, int Cab);
// obsługa sprzęgów
static double CouplerDist(TMoverParameters const *Left, TMoverParameters const *Right);
static double Distance(const TLocation &Loc1, const TLocation &Loc2, const TDimension &Dim1, const TDimension &Dim2);
@@ -2307,7 +2299,7 @@ class TMoverParameters
bool DirectionForward();
bool DirectionBackward(void); /*! kierunek ruchu*/
bool EIMDirectionChangeAllow(void) const;
- inline double IsVehicleEIMBrakingFactor()
+ inline double IsVehicleEIMBrakingFactor() const
{
return DynamicBrakeFlag && ResistorsFlag ? 0.0 : eimv[eimv_Ipoj] < 0 ? -1.0 : 1.0;
}
@@ -2319,32 +2311,32 @@ class TMoverParameters
bool CurrentSwitch(bool const State);
bool IsMotorOverloadRelayHighThresholdOn() const;
void UpdateBatteryVoltage(double dt);
- double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, TLocation const &NewLoc,
+ double ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam const &Track, TTractionParam const &ElectricTraction, TLocation const &NewLoc,
TRotation const &NewRot); // oblicza przesuniecie pojazdu
double FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track, TLocation const &NewLoc, TRotation const &NewRot); // oblicza przesuniecie pojazdu - wersja zoptymalizowana
void compute_movement_(double const Deltatime);
- double ShowEngineRotation(int VehN);
+ double ShowEngineRotation(int VehN) const;
// Q *******************************************************************************************
double GetTrainsetVoltage(int const Coupling = coupling::heating | coupling::highvoltage) const;
double GetTrainsetHighVoltage() const;
bool switch_physics(bool const State);
- double LocalBrakeRatio(void);
- double ManualBrakeRatio(void);
- double PipeRatio(void); /*ile napelniac*/
- double RealPipeRatio(void); /*jak szybko*/
+ double LocalBrakeRatio(void) const;
+ double ManualBrakeRatio(void) const;
+ double PipeRatio(void) const; /*ile napelniac*/
+ double RealPipeRatio(void) const; /*jak szybko*/
double BrakeVP(void) const;
double EngineRPMRatio() const; // returns current engine revolutions as percentage of max engine revolutions, in range 0-1
double EngineIdleRPM() const;
double EngineMaxRPM() const;
/*! przesylanie komend sterujacych*/
- bool SendCtrlToNext(std::string const CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype = coupling::control);
- bool SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype = coupling::control);
- double GetExternalCommand(std::string &Command);
- bool RunCommand(std::string Command, double CValue1, double CValue2, int const Couplertype = coupling::control);
+ bool SendCtrlToNext(std::string const &CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype = coupling::control);
+ bool SetInternalCommand(std::string const &NewCommand, double NewValue1, double NewValue2, int const Couplertype = coupling::control);
+ double GetExternalCommand(std::string &Command) const;
+ bool RunCommand(std::string const &Command, double CValue1, double CValue2, int const Couplertype = coupling::control);
bool RunInternalCommand();
- void PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation);
+ void PutCommand(std::string const &NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation);
bool CabActivisation(bool const Enforce = false);
bool CabDeactivisation(bool const Enforce = false);
bool CabActivisationAuto(bool const Enforce = false);
@@ -2363,7 +2355,7 @@ class TMoverParameters
/*! pomocniczy nastawnik:*/
bool IncScndCtrl(int CtrlSpeed);
bool DecScndCtrl(int CtrlSpeed);
- int GetVirtualScndPos();
+ int GetVirtualScndPos() const;
bool IsScndCtrlNoPowerPos() const;
bool IsScndCtrlMaxPowerPos() const;
@@ -2430,7 +2422,7 @@ class TMoverParameters
double TractionForce(double dt);
double FrictionForce() const;
double BrakeForceR(double ratio, double velocity);
- double BrakeForceP(double press, double velocity);
+ double BrakeForceP(double press, double velocity) const;
double BrakeForce(const TTrackParam &Track);
double CouplerForce(int const End, double dt);
void CollisionDetect(int const End, double const dt);
@@ -2488,8 +2480,8 @@ class TMoverParameters
/*funkcje uzalezniajace sile pociagowa od predkosci: v2n, n2r, current, momentum*/
double v2n(void);
double Current(double n, double U);
- double Momentum(double I);
- double MomentumF(double I, double Iw, int SCP);
+ double Momentum(double I) const;
+ double MomentumF(double I, double Iw, int SCP) const;
bool CutOffEngine(void); // odlaczenie udszkodzonych silnikow
/*funkcje automatycznego rozruchu np EN57*/
@@ -2526,7 +2518,7 @@ class TMoverParameters
/* funckje dla wagonow*/
bool AssignLoad(std::string const &Name, float const Amount = 0.f);
- bool LoadingDone(double LSpeed, std::string const &Loadname);
+ bool LoadingDone(double LSpeed, std::string_view Loadname);
bool PermitDoors(side const Door, bool const State = true, range_t const Notify = range_t::consist);
void PermitDoors_(side const Door, bool const State = true);
bool ChangeDoorPermitPreset(int const Change, range_t const Notify = range_t::consist);
@@ -2541,7 +2533,7 @@ class TMoverParameters
bool ChangeOffsetH(double DeltaOffset);
/*funkcje ladujace pliki opisujace pojazd*/
- bool LoadFIZ(std::string chkpath); // Q 20160717 bool LoadChkFile(std::string chkpath);
+ bool LoadFIZ(std::string const &chkpath); // Q 20160717 bool LoadChkFile(std::string chkpath);
bool CheckLocomotiveParameters(bool ReadyFlag, int Dir);
std::string EngineDescription(int what) const;
@@ -2577,10 +2569,10 @@ class TMoverParameters
void LoadFIZ_LightsList(std::string const &Input);
void LoadFIZ_DimmerList(std::string const &Input);
void LoadFIZ_CompressorList(std::string const &Input);
- void LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Input);
- TPowerType LoadFIZ_PowerDecode(std::string const &Power);
- TPowerSource LoadFIZ_SourceDecode(std::string const &Source);
- TEngineType LoadFIZ_EngineDecode(std::string const &Engine);
+ void LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const &Prefix, std::string const &Input);
+ TPowerType LoadFIZ_PowerDecode(std::string const &Power) const;
+ TPowerSource LoadFIZ_SourceDecode(std::string const &Source) const;
+ TEngineType LoadFIZ_EngineDecode(std::string const &Engine) const;
bool readMPT0(std::string const &line);
bool readMPT(std::string const &line); // Q 20160717
bool readMPTElectricSeries(std::string const &line);
diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp
index ff60c27c..16fe3066 100644
--- a/McZapkie/Mover.cpp
+++ b/McZapkie/Mover.cpp
@@ -256,7 +256,7 @@ void TSecuritySystem::load(std::string const &line, double Vmax)
double TableInterpolation(std::map &Map, double Parameter)
{
- if (Map.size() == 0)
+ if (Map.empty())
return 0.0;
if (Map.size() == 1)
return Map.begin()->second;
@@ -289,8 +289,11 @@ double TMoverParameters::Current(double n, double U)
// a takze wywala bezpiecznik nadmiarowy gdy za duzy prad lub za male napiecie
// jest takze mozliwosc uszkodzenia silnika wskutek nietypowych parametrow
- double R, MotorCurrent;
- double Rz, Delta, Isf;
+ double R;
+ double MotorCurrent;
+ double Rz;
+ double Delta;
+ double Isf;
double Mn; // przujmuje int, ale dla poprawnosci obliczeń
double Bn;
int SP = 0;
@@ -347,7 +350,6 @@ double TMoverParameters::Current(double n, double U)
Mn = RList[MainCtrlActualPos].Mn * RList[MainCtrlActualPos].Bn;
if (RList[MainCtrlActualPos].Bn > 1)
{
- Bn = 1;
R = CircuitRes;
}
}
@@ -429,7 +431,6 @@ double TMoverParameters::Current(double n, double U)
if (DynamicBrakeType == dbrake_switch && (BrakePress > 2.0 || PipePress < 3.6))
{
Im = 0;
- MotorCurrent = 0;
// Im:=0;
Itot = 0;
}
@@ -443,17 +444,13 @@ double TMoverParameters::Current(double n, double U)
if (MotorCurrent > 0)
{
- if (FuzzyLogic(abs(n), nmax * 1.1, p_elengproblem))
- if (MainSwitch(false))
- EventFlag = true; /*zbyt duze obroty - wywalanie wskutek ognia okreznego*/
- if (TestFlag(DamageFlag, dtrain_engine))
- if (FuzzyLogic(MotorCurrent, (double)ImaxLo / 10.0, p_elengproblem))
- if (MainSwitch(false))
- EventFlag = true; /*uszkodzony silnik (uplywy)*/
- if (FuzzyLogic(abs(Im), Imax * 2, p_elengproblem) || FuzzyLogic(abs(n), nmax * 1.11, p_elengproblem))
- /* or FuzzyLogic(Abs(U/Mn),2*NominalVoltage,1)) then */ /*poprawic potem*/
- if (SetFlag(DamageFlag, dtrain_engine))
- EventFlag = true;
+ if (FuzzyLogic(abs(n), nmax * 1.1, p_elengproblem) && MainSwitch(false))
+ EventFlag = true; /*zbyt duze obroty - wywalanie wskutek ognia okreznego*/
+ if (TestFlag(DamageFlag, dtrain_engine) && FuzzyLogic(MotorCurrent, (double)ImaxLo / 10.0, p_elengproblem) && MainSwitch(false))
+ EventFlag = true; /*uszkodzony silnik (uplywy)*/
+ /* or FuzzyLogic(Abs(U/Mn),2*NominalVoltage,1)) then */ /*poprawic potem*/
+ if ((FuzzyLogic(abs(Im), Imax * 2, p_elengproblem) || FuzzyLogic(abs(n), nmax * 1.11, p_elengproblem)) && SetFlag(DamageFlag, dtrain_engine))
+ EventFlag = true;
/*! dorobic grzanie oporow rozruchowych i silnika*/
}
@@ -463,36 +460,37 @@ double TMoverParameters::Current(double n, double U)
// *************************************************************************************************
// główny konstruktor
// *************************************************************************************************
-TMoverParameters::TMoverParameters(double VelInitial, std::string TypeNameInit, std::string NameInit, int Cab) : TypeName(TypeNameInit), Name(NameInit), CabOccupied(Cab)
+TMoverParameters::TMoverParameters(double VelInitial, std::string const &TypeNameInit, std::string const &NameInit, int Cab) : TypeName(TypeNameInit), Name(NameInit), CabOccupied(Cab)
{
WriteLog("------------------------------------------------------");
WriteLog("init default physic values for " + NameInit + ", [" + TypeNameInit + "]");
- Dim = TDimension();
// BrakeLevelSet(-2); //Pascal ustawia na 0, przestawimy na odcięcie (CHK jest jeszcze nie wczytane!)
iLights[0] = 0;
iLights[1] = 0; // światła zgaszone
// inicjalizacja stalych
- for (int b = 0; b < ResArraySize + 1; ++b)
+ for (auto &scheme : RList)
{
- RList[b] = TScheme();
+ scheme = TScheme();
}
RlistSize = 0;
- for (int b = 0; b < MotorParametersArraySize + 1; ++b)
+ for (auto &motorparam : MotorParam)
{
- MotorParam[b] = TMotorParameters();
+ motorparam = TMotorParameters();
}
- for (int b = 0; b < 2; ++b)
+ for (auto &cablights : Lights)
for (int k = 0; k < 17; ++k)
- Lights[b][k] = 0;
+ cablights[k] = 0;
- for (int b = 0; b < 4; ++b)
+ for (auto &compressorrow : CompressorList)
for (int k = 1; k < 9; ++k)
- CompressorList[b][k] = 0;
+ compressorrow[k] = 0;
CompressorList[0][0] = 0.0;
- CompressorList[1][0] = CompressorList[2][0] = CompressorList[3][0] = 1.0;
+ CompressorList[1][0] = 1.0;
+ CompressorList[2][0] = 1.0;
+ CompressorList[3][0] = 1.0;
for (int b = -1; b <= MainBrakeMaxPos; ++b)
{
@@ -506,9 +504,9 @@ TMoverParameters::TMoverParameters(double VelInitial, std::string TypeNameInit,
BrakePressureTable[-2].BrakePressureVal = -1.0;
BrakePressureTable[-2].FlowSpeedVal = 0.0;
}
- for (int b = 0; b < 4; ++b)
+ for (auto &delay : BrakeDelay)
{
- BrakeDelay[b] = 0.0;
+ delay = 0.0;
}
for (int b = 0; b < 2; ++b) // Ra: kto tu zrobił "for b:=1 to 2 do" ???
@@ -521,40 +519,40 @@ TMoverParameters::TMoverParameters(double VelInitial, std::string TypeNameInit,
Couplers[b].DmaxC = 0.1;
Couplers[b].FmaxC = 1000.0;
}
- for (int b = 0; b < 3; ++b)
+ for (auto &cylindermult : BrakeCylMult)
{
- BrakeCylMult[b] = 0.0;
+ cylindermult = 0.0;
}
- for (int b = 0; b < 26; ++b)
+ for (auto &eimcvalue : eimc)
{
- eimc[b] = 0.0;
+ eimcvalue = 0.0;
}
eimc[eimc_p_eped] = 1.5;
- for (int b = 0; b < 2; ++b)
+ for (auto &couplerentry : Couplers)
{
- Couplers[b].AllowedFlag = 3; // domyślnie hak i hamulec, inne trzeba włączyć jawnie w FIZ
- Couplers[b].CouplingFlag = 0;
- Couplers[b].Connected = nullptr;
- Couplers[b].ConnectedNr = 0; // Ra: to nie ma znaczenia jak nie podłączony
- Couplers[b].Render = false;
- Couplers[b].CForce = 0.0;
- Couplers[b].Dist = 0.0;
- Couplers[b].CheckCollision = false;
+ couplerentry.AllowedFlag = 3; // domyślnie hak i hamulec, inne trzeba włączyć jawnie w FIZ
+ couplerentry.CouplingFlag = 0;
+ couplerentry.Connected = nullptr;
+ couplerentry.ConnectedNr = 0; // Ra: to nie ma znaczenia jak nie podłączony
+ couplerentry.Render = false;
+ couplerentry.CForce = 0.0;
+ couplerentry.Dist = 0.0;
+ couplerentry.CheckCollision = false;
}
- for (int b = 0; b < 5; ++b)
+ for (auto &brakepress : MaxBrakePress)
{
- MaxBrakePress[b] = 0.0;
+ brakepress = 0.0;
}
Vel = abs(VelInitial);
V = VelInitial / 3.6;
- for (int b = 0; b < 21; b++)
+ for (auto &eimvvalue : eimv)
{
- eimv[b] = 0.0;
+ eimvvalue = 0.0;
}
RunningShape.Len = 1.0;
@@ -592,30 +590,29 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
return false;
}
- auto &coupler{Couplers[ConnectNo]};
- auto &othercoupler = ConnectTo->Couplers[(ConnectToNr != 2 ? ConnectToNr : coupler.ConnectedNr)];
- auto const distance{CouplerDist(this, ConnectTo) - (coupler.adapter_length + othercoupler.adapter_length)};
+ auto &thiscoupler{Couplers[ConnectNo]};
+ auto &othercoupler = ConnectTo->Couplers[ConnectToNr != 2 ? ConnectToNr : thiscoupler.ConnectedNr];
+ auto const distance{CouplerDist(this, ConnectTo) - (thiscoupler.adapter_length + othercoupler.adapter_length)};
- auto const couplercheck{Enforce || (distance <= dEpsilon && coupler.type() != TCouplerType::NoCoupler && coupler.type() == othercoupler.type())};
- if (false == couplercheck)
+ if (auto const couplercheck{Enforce || (distance <= dEpsilon && thiscoupler.type() != TCouplerType::NoCoupler && thiscoupler.type() == othercoupler.type())}; false == couplercheck)
{
return false;
}
// stykaja sie zderzaki i kompatybilne typy sprzegow, chyba że łączenie na starcie
- if (coupler.CouplingFlag == coupling::faux)
+ if (thiscoupler.CouplingFlag == coupling::faux)
{
// jeśli wcześniej nie było połączone, ustalenie z której strony rysować sprzęg
- coupler.Render = true; // tego rysować
+ thiscoupler.Render = true; // tego rysować
othercoupler.Render = false; // a tego nie
- };
- auto const couplingchange{CouplingType ^ coupler.CouplingFlag};
- coupler.Connected = ConnectTo;
- coupler.CouplingFlag = CouplingType; // ustawienie typu sprzęgu
+ }
+ auto const couplingchange{CouplingType ^ thiscoupler.CouplingFlag};
+ thiscoupler.Connected = ConnectTo;
+ thiscoupler.CouplingFlag = CouplingType; // ustawienie typu sprzęgu
if (ConnectToNr != 2)
{
- coupler.ConnectedNr = ConnectToNr; // 2=nic nie podłączone
+ thiscoupler.ConnectedNr = ConnectToNr; // 2=nic nie podłączone
}
othercoupler.Connected = this;
othercoupler.CouplingFlag = CouplingType;
@@ -628,14 +625,14 @@ bool TMoverParameters::Attach(int ConnectNo, int ConnectToNr, TMoverParameters *
std::vector> const soundmappings = {{coupling::coupler, sound::attachcoupler}, {coupling::brakehose, sound::attachbrakehose},
{coupling::mainhose, sound::attachmainhose}, {coupling::control, sound::attachcontrol},
{coupling::gangway, sound::attachgangway}, {coupling::heating, sound::attachheating}};
- for (auto const &soundmapping : soundmappings)
+ for (auto const &[mappingcoupling, mappingsound] : soundmappings)
{
- if ((couplingchange & soundmapping.first) != 0)
+ if ((couplingchange & mappingcoupling) != 0)
{
- soundflag |= soundmapping.second;
+ soundflag |= mappingsound;
}
}
- SetFlag(coupler.sounds, soundflag);
+ SetFlag(thiscoupler.sounds, soundflag);
}
return true;
@@ -659,44 +656,44 @@ int TMoverParameters::DettachStatus(int ConnectNo)
bool TMoverParameters::Dettach(int ConnectNo)
{ // rozlaczanie
- auto &coupler{Couplers[ConnectNo]};
- auto &othervehicle{coupler.Connected};
- auto &othercoupler{othervehicle->Couplers[coupler.ConnectedNr]};
+ auto &thiscoupler{Couplers[ConnectNo]};
+ auto &othervehicle{thiscoupler.Connected};
+ auto &othercoupler{othervehicle->Couplers[thiscoupler.ConnectedNr]};
if (othervehicle == nullptr)
{
return true;
} // nie ma nic, to odczepiono
- auto couplingchange{coupler.CouplingFlag}; // presume we'll uncouple all active flags
+ auto couplingchange{thiscoupler.CouplingFlag}; // presume we'll uncouple all active flags
auto const couplingstate{DettachStatus(ConnectNo)}; // stan sprzęgu
if (couplingstate < 0)
{
// gdy scisniete zderzaki, chyba ze zerwany sprzeg (wirtualnego nie odpinamy z drugiej strony)
- std::tie(coupler.Connected, coupler.ConnectedNr, coupler.CouplingFlag) = std::tie(othercoupler.Connected, othercoupler.ConnectedNr, othercoupler.CouplingFlag) =
- std::make_tuple(nullptr, -1, coupling::faux);
+ std::tie(othercoupler.Connected, othercoupler.ConnectedNr, othercoupler.CouplingFlag) = std::make_tuple(nullptr, -1, coupling::faux);
+ std::tie(thiscoupler.Connected, thiscoupler.ConnectedNr, thiscoupler.CouplingFlag) = std::make_tuple(nullptr, -1, coupling::faux);
}
else if (couplingstate > 0)
{ // odłączamy węże i resztę, pozostaje sprzęg fizyczny, który wymaga dociśnięcia (z wirtualnym nic)
- coupler.CouplingFlag &= coupling::coupler;
+ thiscoupler.CouplingFlag &= coupling::coupler;
othercoupler.CouplingFlag &= coupling::coupler;
}
// set sound event flag
- couplingchange ^= coupler.CouplingFlag; // remaining bits were removed from coupling
+ couplingchange ^= thiscoupler.CouplingFlag; // remaining bits were removed from coupling
if (couplingchange != 0)
{
int soundflag{sound::detach}; // HACK: use detach flag to indicate removal of listed coupling
std::vector> const soundmappings = {{coupling::coupler, sound::attachcoupler}, {coupling::brakehose, sound::attachbrakehose},
{coupling::mainhose, sound::attachmainhose}, {coupling::control, sound::attachcontrol},
{coupling::gangway, sound::attachgangway}, {coupling::heating, sound::attachheating}};
- for (auto const &soundmapping : soundmappings)
+ for (auto const &[mappingcoupling, mappingsound] : soundmappings)
{
- if ((couplingchange & soundmapping.first) != 0)
+ if ((couplingchange & mappingcoupling) != 0)
{
- soundflag |= soundmapping.second;
+ soundflag |= mappingsound;
}
}
- SetFlag(coupler.sounds, soundflag);
+ SetFlag(thiscoupler.sounds, soundflag);
}
return couplingstate < 0;
@@ -735,7 +732,7 @@ void TMoverParameters::BrakeLevelSet(double b)
fBrakeCtrlPos = Handle->GetPos(bh_MAX);
// TODO: verify whether BrakeCtrlPosR and fBrakeCtrlPos can be rolled into single variable
BrakeCtrlPosR = fBrakeCtrlPos;
- int x = static_cast(std::floor(fBrakeCtrlPos)); // jeśli odwołujemy się do BrakeCtrlPos w pośrednich, to musi być
+ auto x = static_cast(std::floor(fBrakeCtrlPos)); // jeśli odwołujemy się do BrakeCtrlPos w pośrednich, to musi być
// obcięte a nie zaokrągone
while (x > BrakeCtrlPos && BrakeCtrlPos < BrakeCtrlPosNo) // jeśli zwiększyło się o 1
if (!IncBrakeLevelOld()) // T_MoverParameters::
@@ -936,8 +933,11 @@ void TMoverParameters::UpdatePantVolume(double dt)
void TMoverParameters::UpdateBatteryVoltage(double dt)
{ // przeliczenie obciążenia baterii
- double sn1 = 0.0, sn2 = 0.0, sn3 = 0.0, sn4 = 0.0,
- sn5 = 0.0; // Ra: zrobić z tego amperomierz NN
+ double sn1 = 0.0;
+ double sn2 = 0.0;
+ double sn3 = 0.0;
+ double sn4 = 0.0;
+ double sn5 = 0.0; // Ra: zrobić z tego amperomierz NN
if (BatteryVoltage > 0 && EngineType != TEngineType::DieselEngine && EngineType != TEngineType::WheelsDriven && NominalBatteryVoltage > 0)
{
@@ -968,7 +968,7 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
sn5 = dt * 0.001;
else
sn5 = 0;
- };
+ }
if (NominalBatteryVoltage / BatteryVoltage >= 1.22 && Battery)
{ // 90V
if (PantCompFlag)
@@ -991,7 +991,7 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
sn5 = dt * 0.0010;
else
sn5 = 0;
- };
+ }
if (!Battery)
{
if (NominalBatteryVoltage / BatteryVoltage < 1.22)
@@ -1002,11 +1002,10 @@ void TMoverParameters::UpdateBatteryVoltage(double dt)
sn3 = dt * 0.000001;
sn4 = dt * 0.000001;
sn5 = dt * 0.000001; // bardzo powolny spadek przy wyłączonych bateriach
- };
+ }
BatteryVoltage -= sn1 + sn2 + sn3 + sn4 + sn5;
- if (NominalBatteryVoltage / BatteryVoltage > 1.57)
- if (MainSwitch(false) && EngineType != TEngineType::DieselEngine && EngineType != TEngineType::WheelsDriven)
- EventFlag = true; // wywalanie szybkiego z powodu zbyt niskiego napiecia
+ if (NominalBatteryVoltage / BatteryVoltage > 1.57 && MainSwitch(false) && EngineType != TEngineType::DieselEngine && EngineType != TEngineType::WheelsDriven)
+ EventFlag = true; // wywalanie szybkiego z powodu zbyt niskiego napiecia
if (BatteryVoltage > NominalBatteryVoltage)
BatteryVoltage = NominalBatteryVoltage; // wstrzymanie ładowania pow. 110V
if (BatteryVoltage < 0.01)
@@ -1062,7 +1061,7 @@ ZN //masa
// Q: 20160714
// Oblicza iloraz aktualnej pozycji do maksymalnej hamulca pomocnicznego
// *****************************************************************************
-double TMoverParameters::LocalBrakeRatio(void)
+double TMoverParameters::LocalBrakeRatio(void) const
{
double LBR;
if (BrakeHandle == TBrakeHandle::MHZ_EN57)
@@ -1086,7 +1085,7 @@ double TMoverParameters::LocalBrakeRatio(void)
// Q: 20160714
// Oblicza iloraz aktualnej pozycji do maksymalnej hamulca ręcznego
// *****************************************************************************
-double TMoverParameters::ManualBrakeRatio(void)
+double TMoverParameters::ManualBrakeRatio(void) const
{
double MBR;
@@ -1113,7 +1112,7 @@ double TMoverParameters::BrakeVP(void) const
// Q: 20160713
// Zwraca iloraz różnicy między przewodem kontrolnym i głównym oraz DeltaPipePress
// *****************************************************************************
-double TMoverParameters::RealPipeRatio(void)
+double TMoverParameters::RealPipeRatio(void) const
{
double rpp;
@@ -1128,7 +1127,7 @@ double TMoverParameters::RealPipeRatio(void)
// Q: 20160713
// Zwraca iloraz ciśnienia w przewodzie do DeltaPipePress
// *****************************************************************************
-double TMoverParameters::PipeRatio(void)
+double TMoverParameters::PipeRatio(void) const
{
double pr;
@@ -1188,27 +1187,27 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
return;
} // shouldn't normally happen but, eh
- auto &coupler{Couplers[End]};
+ auto const &thiscoupler{Couplers[End]};
auto *othervehicle{Neighbours[End].vehicle->MoverParameters};
auto const otherend{Neighbours[End].vehicle_end};
- auto &othercoupler{othervehicle->Couplers[otherend]};
+ auto const &othercoupler{othervehicle->Couplers[otherend]};
auto velocity{V};
auto othervehiclevelocity{othervehicle->V};
// calculate collision force and new velocities for involved vehicles
- auto const VirtualCoupling{(coupler.CouplingFlag == coupling::faux)};
+ auto const VirtualCoupling{(thiscoupler.CouplingFlag == coupling::faux)};
auto CCF{0.0};
switch (End)
{
case 0:
{
- CCF = ComputeCollision(velocity, othervehiclevelocity, TotalMass, othervehicle->TotalMass, (coupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
+ CCF = ComputeCollision(velocity, othervehiclevelocity, TotalMass, othervehicle->TotalMass, (thiscoupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
break; // yB: ej ej ej, a po
}
case 1:
{
- CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->TotalMass, TotalMass, (coupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
+ CCF = ComputeCollision(othervehiclevelocity, velocity, othervehicle->TotalMass, TotalMass, (thiscoupler.beta + othercoupler.beta) / 2.0, VirtualCoupling) / dt;
break;
}
default:
@@ -1219,13 +1218,13 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
if (Global.crash_damage)
{
- if (-coupler.Dist >= coupler.DmaxB && FuzzyLogic(std::abs(CCF), 5.0 * (coupler.FmaxC + 1.0), p_coupldmg))
+ if (-thiscoupler.Dist >= thiscoupler.DmaxB && FuzzyLogic(std::abs(CCF), 5.0 * (thiscoupler.FmaxC + 1.0), p_coupldmg))
{
// small chance to smash the coupler if it's hit with excessive force
damage_coupler(End);
}
- if (coupler.CouplingFlag == coupling::faux || true == TestFlag(othervehicle->DamageFlag, dtrain_out))
+ if (thiscoupler.CouplingFlag == coupling::faux || true == TestFlag(othervehicle->DamageFlag, dtrain_out))
{ // HACK: limit excessive speed derailment checks to vehicles which aren't part of the same consist
auto const safevelocitylimit{15.0};
auto const velocitydifference{glm::length(glm::angleAxis(Rot.Rz, glm::dvec3{0, 1, 0}) * V - glm::angleAxis(othervehicle->Rot.Rz, glm::dvec3{0, 1, 0}) * othervehicle->V) *
@@ -1276,9 +1275,9 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
void TMoverParameters::damage_coupler(int const End)
{
- auto &coupler{Couplers[End]};
+ auto &thiscoupler{Couplers[End]};
- if (coupler.type() == TCouplerType::Articulated)
+ if (thiscoupler.type() == TCouplerType::Articulated)
{
return;
} // HACK: don't break articulated couplings no matter what
@@ -1286,27 +1285,27 @@ void TMoverParameters::damage_coupler(int const End)
if (SetFlag(DamageFlag, dtrain_coupling))
EventFlag = true;
- if ((coupler.CouplingFlag & coupling::brakehose) == coupling::brakehose)
+ if ((thiscoupler.CouplingFlag & coupling::brakehose) == coupling::brakehose)
{
// hamowanie nagle - zerwanie przewodow hamulcowych
AlarmChainFlag = true;
}
- coupler.CouplingFlag = 0;
+ thiscoupler.CouplingFlag = 0;
- if (coupler.Connected != nullptr)
+ if (thiscoupler.Connected != nullptr)
{
switch (End)
{
// break connection with other vehicle, if there's any
case 0:
{
- coupler.Connected->Couplers[end::rear].CouplingFlag = coupling::faux;
+ thiscoupler.Connected->Couplers[end::rear].CouplingFlag = coupling::faux;
break;
}
case 1:
{
- coupler.Connected->Couplers[end::front].CouplingFlag = coupling::faux;
+ thiscoupler.Connected->Couplers[end::front].CouplingFlag = coupling::faux;
break;
}
default:
@@ -1353,10 +1352,8 @@ void TMoverParameters::Derail(DerailReason const Reason)
// *************************************************************************************************
// Oblicza przemieszczenie taboru
// *************************************************************************************************
-double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam &Track, TTractionParam &ElectricTraction, TLocation const &NewLoc, TRotation const &NewRot)
+double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShape &Shape, TTrackParam const &Track, TTractionParam const &ElectricTraction, TLocation const &NewLoc, TRotation const &NewRot)
{
- const double Vepsilon = 1e-5;
- const double Aepsilon = 1e-3; // ASBSpeed=0.8;
if (!TestFlag(DamageFlag, dtrain_out))
{ // Ra: to przepisywanie tu jest bez sensu
@@ -1377,12 +1374,11 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
if (CategoryFlag == 4)
OffsetTrackV = TotalMass / (Dim.L * Dim.W * 1000.0);
- else if (TestFlag(CategoryFlag, 1) && TestFlag(RunningTrack.CategoryFlag, 1))
- if (TestFlag(DamageFlag, dtrain_out))
- {
- OffsetTrackV = -0.2;
- OffsetTrackH = Sign(RunningShape.R) * 0.2;
- }
+ else if (TestFlag(CategoryFlag, 1) && TestFlag(RunningTrack.CategoryFlag, 1) && TestFlag(DamageFlag, dtrain_out))
+ {
+ OffsetTrackV = -0.2;
+ OffsetTrackH = Sign(RunningShape.R) * 0.2;
+ }
// TODO: investigate, seems supplied NewRot is always 0 although the code here suggests some actual values are expected
Loc = NewLoc;
@@ -1477,9 +1473,8 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
// Oblicza przemieszczenie taboru - uproszczona wersja
// *************************************************************************************************
-double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape, TTrackParam &Track, TLocation const &NewLoc, TRotation const &NewRot)
+double TMoverParameters::FastComputeMovement(double dt, const TTrackShape & /*Shape*/, TTrackParam & /*Track*/, TLocation const &NewLoc, TRotation const &NewRot)
{
- int b;
// T_MoverParameters::FastComputeMovement(dt, Shape, Track, NewLoc, NewRot);
Loc = NewLoc;
@@ -1520,7 +1515,7 @@ double TMoverParameters::FastComputeMovement(double dt, const TTrackShape &Shape
dL = (3.0 * V - Vprev) * dt / 2.0; // metoda Adamsa-Bashfortha
// ale jesli jest kolizja (zas. zach. pedu) to...
- for (b = 0; b < 2; b++)
+ for (int b = 0; b < 2; b++)
if (Couplers[b].CheckCollision)
CollisionDetect(b, dt); // zmienia niejawnie AccS, V !!!
} // liczone dL, predkosc i przyspieszenie
@@ -1548,24 +1543,21 @@ void TMoverParameters::compute_movement_(double const Deltatime)
RunInternalCommand();
// relay settings
- if (EngineType == TEngineType::ElectricSeriesMotor)
+ // adjust motor overload relay threshold
+ if (EngineType == TEngineType::ElectricSeriesMotor && ImaxHi > ImaxLo)
{
- // adjust motor overload relay threshold
- if (ImaxHi > ImaxLo)
- {
- if (MotorOverloadRelayHighThreshold)
- { // set high threshold
- if (TrainType != dt_ET42 ? RList[MainCtrlPos].Bn < 2 : MainCtrlPos == 0)
- {
- Imax = ImaxHi;
- }
+ if (MotorOverloadRelayHighThreshold)
+ { // set high threshold
+ if (TrainType != dt_ET42 ? RList[MainCtrlPos].Bn < 2 : MainCtrlPos == 0)
+ {
+ Imax = ImaxHi;
}
- else
- { // set low threshold
- if (TrainType != dt_ET42 || MainCtrlPos == 0)
- {
- Imax = ImaxLo;
- }
+ }
+ else
+ { // set low threshold
+ if (TrainType != dt_ET42 || MainCtrlPos == 0)
+ {
+ Imax = ImaxLo;
}
}
}
@@ -1573,10 +1565,9 @@ void TMoverParameters::compute_movement_(double const Deltatime)
// Uproszczona symulacja wentylatorow rezystora hamowania
// Prad oddawany na rezystor
- double Irh = abs(eimv[eimv_Pe]) - abs(eimv[eimv_Ipoj]);
// Wlacz wentylator jesli prad rekuperacji przekroczy maksymalny dla pasywnego chlodzenia rezystora
- if (Irh > Imaxrpc && eimv[eimv_Ipoj] < 0)
+ if (double Irh = abs(eimv[eimv_Pe]) - abs(eimv[eimv_Ipoj]); Irh > Imaxrpc && eimv[eimv_Ipoj] < 0)
{
BRVtimer = 0;
BRVentilators = true;
@@ -1589,20 +1580,14 @@ void TMoverParameters::compute_movement_(double const Deltatime)
}
// automatyczny rozruch
- if (EngineType == TEngineType::ElectricSeriesMotor)
+ if (EngineType == TEngineType::ElectricSeriesMotor && AutoRelayCheck())
{
- if (AutoRelayCheck())
- {
- SetFlag(SoundFlag, sound::relay);
- }
+ SetFlag(SoundFlag, sound::relay);
}
- if (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric)
+ if ((EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric) && dizel_Update(Deltatime))
{
- if (dizel_Update(Deltatime))
- {
- SetFlag(SoundFlag, sound::relay);
- }
+ SetFlag(SoundFlag, sound::relay);
}
// TODO: gather and move current calculations to dedicated method
@@ -1624,7 +1609,7 @@ void TMoverParameters::compute_movement_(double const Deltatime)
{
Compressor = 0;
CompressorFlag = false;
- };
+ }
if (VeselVolume > 0.0)
{
// sprężarka musi mieć jakąś niezerową wydajność żeby rozważać jej załączenie i pracę
@@ -1725,14 +1710,12 @@ void TMoverParameters::MainsCheck(double const Deltatime)
}
}
-void TMoverParameters::LowVoltagePowerCheck(double const Deltatime)
+void TMoverParameters::LowVoltagePowerCheck(double const /*Deltatime*/)
{
auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable};
- switch (EngineType)
- {
- case TEngineType::ElectricSeriesMotor:
+ if (EngineType == TEngineType::ElectricSeriesMotor)
{
GroundRelay &= lowvoltagepower;
if (GroundRelayStart != start_t::manual)
@@ -1741,16 +1724,10 @@ void TMoverParameters::LowVoltagePowerCheck(double const Deltatime)
// TODO: generic check method which takes these into account
GroundRelay |= lowvoltagepower;
}
- break;
- }
- default:
- {
- break;
- }
}
}
-void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const Coupling)
+void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, coupling const Coupling)
{
if (Coupling != coupling::highvoltage && Coupling != coupling::power110v && Coupling != coupling::power24v)
{
@@ -1795,17 +1772,9 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
}
}
// high voltage power sources
- switch (EnginePowerSource.SourceType)
- {
- case TPowerSource::CurrentCollector:
+ if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector)
{
localvoltage = std::max(localvoltage, PantographVoltage);
- break;
- }
- default:
- {
- break;
- }
}
break;
}
@@ -1845,9 +1814,9 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
for (auto side = 0; side < 2; ++side)
{
- auto &coupler{Couplers[side]};
+ auto const &thiscoupler{Couplers[side]};
// NOTE: in the loop we actually update the state of the coupler on the opposite end of the vehicle
- auto &oppositecoupler{Couplers[(side == end::front ? end::rear : end::front)]};
+ auto &oppositecoupler{Couplers[side == end::front ? end::rear : end::front]};
bool oppositecouplingispresent;
bool localpowerexportisenabled;
@@ -1885,9 +1854,9 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
}
}
- auto const *coupling = Coupling == coupling::highvoltage ? &coupler.power_high :
- Coupling == coupling::power110v ? &coupler.power_110v :
- Coupling == coupling::power24v ? &coupler.power_24v :
+ auto const *coupling = Coupling == coupling::highvoltage ? &thiscoupler.power_high :
+ Coupling == coupling::power110v ? &thiscoupler.power_110v :
+ Coupling == coupling::power24v ? &thiscoupler.power_24v :
nullptr;
auto *oppositecoupling = Coupling == coupling::highvoltage ? &oppositecoupler.power_high :
Coupling == coupling::power110v ? &oppositecoupler.power_110v :
@@ -1899,9 +1868,9 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
oppositecoupling->is_live = false;
oppositecoupling->is_local = localpowersource; // indicate power source
// draw from external source
- if (coupler.Connected != nullptr)
+ if (thiscoupler.Connected != nullptr)
{
- auto const &connectedcoupler{coupler.Connected->Couplers[coupler.ConnectedNr]};
+ auto const &connectedcoupler{thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr]};
auto const *connectedcoupling = Coupling == coupling::highvoltage ? &connectedcoupler.power_high :
Coupling == coupling::power110v ? &connectedcoupler.power_110v :
Coupling == coupling::power24v ? &connectedcoupler.power_24v :
@@ -1924,17 +1893,17 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
{
case coupling::highvoltage:
{
- couplervoltage = Couplers[end::front].power_high.voltage + Couplers[end::rear].power_high.voltage;
+ couplervoltage = static_cast(Couplers[end::front].power_high.voltage + Couplers[end::rear].power_high.voltage);
break;
}
case coupling::power110v:
{
- couplervoltage = Couplers[end::front].power_110v.voltage + Couplers[end::rear].power_110v.voltage;
+ couplervoltage = static_cast(Couplers[end::front].power_110v.voltage + Couplers[end::rear].power_110v.voltage);
break;
}
case coupling::power24v:
{
- couplervoltage = Couplers[end::front].power_24v.voltage + Couplers[end::rear].power_24v.voltage;
+ couplervoltage = static_cast(Couplers[end::front].power_24v.voltage + Couplers[end::rear].power_24v.voltage);
break;
}
default:
@@ -1948,23 +1917,21 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
Coupling == coupling::power24v ? &PowerCircuits[0].second :
nullptr;
- for (auto side = 0; side < 2; ++side)
+ for (auto &thiscoupler : Couplers)
{
-
- auto &coupler{Couplers[side]};
- auto *coupling = Coupling == coupling::highvoltage ? &coupler.power_high :
- Coupling == coupling::power110v ? &coupler.power_110v :
- Coupling == coupling::power24v ? &coupler.power_24v :
+ auto *coupling = Coupling == coupling::highvoltage ? &thiscoupler.power_high :
+ Coupling == coupling::power110v ? &thiscoupler.power_110v :
+ Coupling == coupling::power24v ? &thiscoupler.power_24v :
nullptr;
coupling->current = 0.0;
- if (coupler.Connected == nullptr)
+ if (thiscoupler.Connected == nullptr)
{
continue;
}
- auto const &connectedothercoupler{coupler.Connected->Couplers[(coupler.ConnectedNr == end::front ? end::rear : end::front)]};
+ auto const &connectedothercoupler{thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr == end::front ? end::rear : end::front]};
auto const *connectedothercoupling = Coupling == coupling::highvoltage ? &connectedothercoupler.power_high :
Coupling == coupling::power110v ? &connectedothercoupler.power_110v :
Coupling == coupling::power24v ? &connectedothercoupler.power_24v :
@@ -1994,7 +1961,7 @@ void TMoverParameters::PowerCouplersCheck(double const Deltatime, coupling const
}
}
-double TMoverParameters::ShowEngineRotation(int VehN)
+double TMoverParameters::ShowEngineRotation(int VehN) const
{ // Zwraca wartość prędkości obrotowej silnika wybranego pojazdu. Do 3 pojazdów (3×SN61).
int b;
switch (VehN)
@@ -2003,19 +1970,17 @@ double TMoverParameters::ShowEngineRotation(int VehN)
return std::abs(enrot);
case 2:
for (b = 0; b <= 1; ++b)
- if (TestFlag(Couplers[b].CouplingFlag, coupling::control))
- if (Couplers[b].Connected->Power > 0.01)
- return fabs(Couplers[b].Connected->enrot);
+ if (TestFlag(Couplers[b].CouplingFlag, coupling::control) && Couplers[b].Connected->Power > 0.01)
+ return fabs(Couplers[b].Connected->enrot);
break;
case 3: // to nie uwzględnia ewentualnego odwrócenia pojazdu w środku
for (b = 0; b <= 1; ++b)
- if (TestFlag(Couplers[b].CouplingFlag, coupling::control))
- if (Couplers[b].Connected->Power > 0.01)
- if (TestFlag(Couplers[b].Connected->Couplers[b].CouplingFlag, coupling::control))
- if (Couplers[b].Connected->Couplers[b].Connected->Power > 0.01)
- return fabs(Couplers[b].Connected->Couplers[b].Connected->enrot);
+ if (TestFlag(Couplers[b].CouplingFlag, coupling::control) && Couplers[b].Connected->Power > 0.01 && TestFlag(Couplers[b].Connected->Couplers[b].CouplingFlag, coupling::control) && Couplers[b].Connected->Couplers[b].Connected->Power > 0.01)
+ return fabs(Couplers[b].Connected->Couplers[b].Connected->enrot);
break;
- };
+ default:
+ break;
+ }
return 0.0;
};
@@ -2080,14 +2045,12 @@ void TMoverParameters::ConverterCheck(double const Timestep)
};
// heating system status check
-void TMoverParameters::HeatingCheck(double const Timestep)
+void TMoverParameters::HeatingCheck(double const /*Timestep*/)
{
// update heating devices
// TBD, TODO: move this to a separate method?
- switch (HeatingPowerSource.SourceType)
- {
- case TPowerSource::Generator:
+ if (HeatingPowerSource.SourceType == TPowerSource::Generator)
{
if (HeatingPowerSource.EngineGenerator.engine_revolutions != nullptr && HeatingPowerSource.EngineGenerator.revolutions_max > 0)
{
@@ -2106,12 +2069,6 @@ void TMoverParameters::HeatingCheck(double const Timestep)
std::clamp((absrevolutions - generator.revolutions_min) / (generator.revolutions_max - generator.revolutions_min), 0.0, 1.0))) *
sign(generator.revolutions);
}
- break;
- }
- default:
- {
- break;
- }
}
// quick check first to avoid unnecessary calls...
@@ -2166,7 +2123,7 @@ void TMoverParameters::HeatingCheck(double const Timestep)
}
// water pump status check
-void TMoverParameters::WaterPumpCheck(double const Timestep)
+void TMoverParameters::WaterPumpCheck(double const /*Timestep*/)
{
// NOTE: breaker override with start type is sm42 specific hack, replace with ability to define the presence of the breaker
WaterPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && true == WaterPump.breaker && false == WaterPump.is_disabled &&
@@ -2174,7 +2131,7 @@ void TMoverParameters::WaterPumpCheck(double const Timestep)
}
// water heater status check
-void TMoverParameters::WaterHeaterCheck(double const Timestep)
+void TMoverParameters::WaterHeaterCheck(double const /*Timestep*/)
{
WaterHeater.is_active = false == WaterHeater.is_damaged && true == (Power24vIsAvailable || Power110vIsAvailable) && true == WaterHeater.is_enabled && true == WaterHeater.breaker &&
@@ -2189,13 +2146,14 @@ void TMoverParameters::WaterHeaterCheck(double const Timestep)
}
// fuel pump status update
-void TMoverParameters::FuelPumpCheck(double const Timestep)
+void TMoverParameters::FuelPumpCheck(double const /*Timestep*/)
{
+ using enum start_t;
FuelPump.is_active = true == (Power24vIsAvailable || Power110vIsAvailable) && false == FuelPump.is_disabled &&
- (FuelPump.is_active || (FuelPump.start_type == start_t::manual ? FuelPump.is_enabled :
- FuelPump.start_type == start_t::automatic ? dizel_startup || Mains :
- FuelPump.start_type == start_t::manualwithautofallback ? FuelPump.is_enabled || dizel_startup || Mains :
+ (FuelPump.is_active || (FuelPump.start_type == manual ? FuelPump.is_enabled :
+ FuelPump.start_type == automatic ? dizel_startup || Mains :
+ FuelPump.start_type == manualwithautofallback ? FuelPump.is_enabled || dizel_startup || Mains :
false)); // shouldn't ever get this far but, eh
}
@@ -2218,11 +2176,11 @@ void TMoverParameters::OilPumpCheck(double const Timestep)
if (OilPump.pressure < OilPump.pressure_target)
{
// TODO: scale change rate from 0.01-0.05 with oil/engine temperature/idle time
- OilPump.pressure = std::min(OilPump.pressure_target, OilPump.pressure + (enrot > 5.0 ? 0.05 : 0.035) * Timestep);
+ OilPump.pressure = std::min(OilPump.pressure_target, static_cast(OilPump.pressure + (enrot > 5.0 ? 0.05 : 0.035) * Timestep));
}
if (OilPump.pressure > OilPump.pressure_target)
{
- OilPump.pressure = std::max(OilPump.pressure_target, OilPump.pressure - (enrot > 5.0 ? 0.05 : 0.035) * 0.5 * Timestep);
+ OilPump.pressure = std::max(OilPump.pressure_target, static_cast(OilPump.pressure - (enrot > 5.0 ? 0.05 : 0.035) * 0.5 * Timestep));
}
OilPump.pressure = std::clamp(OilPump.pressure, 0.f, 1.5f);
}
@@ -2239,7 +2197,7 @@ void TMoverParameters::MotorBlowersCheck(double const Timestep)
{
if (stop)
{
- blower.stop_timer += Timestep;
+ blower.stop_timer += static_cast(Timestep);
if (blower.stop_timer > blower.sustain_time)
{
disable = true;
@@ -2279,23 +2237,24 @@ void TMoverParameters::MotorBlowersCheck(double const Timestep)
if (revolutionstarget > 0.f)
{
auto const speedincreasecap{std::max(50.f, fan.speed * 0.05f * -1)}; // 5% of fixed revolution speed, or 50
- fan.revolutions += std::clamp(revolutionstarget - fan.revolutions, speedincreasecap * -2, speedincreasecap) * Timestep;
+ fan.revolutions += static_cast(std::clamp(revolutionstarget - fan.revolutions, speedincreasecap * -2, speedincreasecap) * Timestep);
}
else
{
- fan.revolutions *= std::max(0.0, 1.0 - Timestep);
+ fan.revolutions *= static_cast(std::max(0.0, 1.0 - Timestep));
}
}
}
-void TMoverParameters::PantographsCheck(double const Timestep)
+void TMoverParameters::PantographsCheck(double const /*Timestep*/)
{
+ using enum start_t;
{
- auto &valve{PantsValve};
+ auto const &valve{PantsValve};
auto const lowvoltagepower{valve.solenoid ? Power24vIsAvailable || Power110vIsAvailable : true};
- auto const autostart{valve.start_type == start_t::automatic || valve.start_type == start_t::manualwithautofallback};
- auto const manualcontrol{valve.start_type == start_t::manual || valve.start_type == start_t::manualwithautofallback};
+ 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
&& (manualcontrol && lowvoltagepower ? false == valve.is_disabled : true) // needs power to change state
@@ -2310,8 +2269,8 @@ void TMoverParameters::PantographsCheck(double const Timestep)
auto &valve{pantograph.valve};
auto const lowvoltagepower{valve.solenoid ? Power24vIsAvailable || Power110vIsAvailable : true};
- auto const autostart{valve.start_type == start_t::automatic || valve.start_type == start_t::manualwithautofallback};
- auto const manualcontrol{valve.start_type == start_t::manual || valve.start_type == start_t::manualwithautofallback};
+ auto const autostart{valve.start_type == automatic || valve.start_type == manualwithautofallback};
+ auto const manualcontrol{valve.start_type == manual || valve.start_type == manualwithautofallback};
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
@@ -2326,7 +2285,7 @@ void TMoverParameters::PantographsCheck(double const Timestep)
}
}
-void TMoverParameters::LightsCheck(double const Timestep)
+void TMoverParameters::LightsCheck(double const /*Timestep*/)
{
auto &light{CompartmentLights};
@@ -2437,7 +2396,6 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
while (RList[MainCtrlPos].R > 0.0 && IncMainCtrl(1))
{
// all work is done in the loop header
- ;
}
OK = false; // shouldn't this be part of the loop above?
// if (TrainType=dt_ET40) then
@@ -2449,21 +2407,18 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
{ // CtrlSpeed == 1
++MainCtrlPos;
OK = true;
- if (Imax == ImaxHi)
+ if (Imax == ImaxHi && RList[MainCtrlPos].Bn > 1)
{
- if (RList[MainCtrlPos].Bn > 1)
+ /* NOTE: disabled, relay configuration was moved to compute_movement_
+ if( true == MaxCurrentSwitch( false )) {
+ // wylaczanie wysokiego rozruchu
+ SetFlag( SoundFlag, sound::relay );
+ }
+ */
+ if (TrainType == dt_ET42)
{
- /* NOTE: disabled, relay configuration was moved to compute_movement_
- if( true == MaxCurrentSwitch( false )) {
- // wylaczanie wysokiego rozruchu
- SetFlag( SoundFlag, sound::relay );
- }
- */
- if (TrainType == dt_ET42)
- {
- --MainCtrlPos;
- OK = false;
- }
+ --MainCtrlPos;
+ OK = false;
}
}
//
@@ -2476,13 +2431,10 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
//}
}
- if (TrainType == dt_ET42 && true == DynamicBrakeFlag)
+ if (TrainType == dt_ET42 && true == DynamicBrakeFlag && MainCtrlPos > 20)
{
- if (MainCtrlPos > 20)
- {
- MainCtrlPos = 20;
- OK = false;
- }
+ MainCtrlPos = 20;
+ OK = false;
}
break;
}
@@ -2493,7 +2445,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
{
while (MainCtrlPos < MainCtrlPosNo && IncMainCtrl(1))
{
- ;
+ // all work is done in the loop header
}
}
else
@@ -2510,6 +2462,8 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
OK = AddPulseForce(CtrlSpeed);
break;
}
+ default:
+ break;
} // switch EngineType of
}
else
@@ -2644,6 +2598,8 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
}
break;
}
+ default:
+ break;
} // switch EngineType
}
}
@@ -2776,9 +2732,8 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed)
OK = false;
// if OK then LastRelayTime:=0;
// hunter-101012: poprawka
- if (OK)
- if (LastRelayTime > CtrlDelay)
- LastRelayTime = 0;
+ if (OK && LastRelayTime > CtrlDelay)
+ LastRelayTime = 0;
if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1 && MainCtrlPos > 0)
{
@@ -2793,7 +2748,7 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed)
if (OK && SpeedCtrl && ScndCtrlPos == 1 && EngineType == TEngineType::DieselEngine)
{
// NOTE: round() already adds 0.5, are the ones added here as well correct?
- SpeedCtrlValue = Round(Vel);
+ SpeedCtrlValue = static_cast(Round(Vel));
SpeedCtrlUnit.IsActive = true;
}
@@ -2839,9 +2794,8 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
OK = false;
// if OK then LastRelayTime:=0;
// hunter-101012: poprawka
- if (OK)
- if (LastRelayTime > CtrlDownDelay)
- LastRelayTime = 0;
+ if (OK && LastRelayTime > CtrlDownDelay)
+ LastRelayTime = 0;
if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1)
{
@@ -2866,13 +2820,10 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
return OK;
}
-int TMoverParameters::GetVirtualScndPos()
+int TMoverParameters::GetVirtualScndPos() const
{
- if (TrainType == dt_ET42)
- {
- if (DynamicBrakeFlag && !ScndCtrlPos)
- return -1;
- }
+ if (TrainType == dt_ET42 && DynamicBrakeFlag && !ScndCtrlPos)
+ return -1;
return ScndCtrlPos;
}
@@ -3032,8 +2983,7 @@ bool TMoverParameters::SandboxManual(bool const State, range_t const Notify)
bool TMoverParameters::SandboxAuto(bool const State, range_t const Notify)
{
bool result{false};
- bool NewState = State && SandDoseAutoAllow;
- if (SandDoseAuto != NewState)
+ if (bool NewState = State && SandDoseAutoAllow; SandDoseAuto != NewState)
{
if (SandDoseAuto == false)
{
@@ -3155,6 +3105,7 @@ void TMoverParameters::SecuritySystemCheck(double dt)
// *************************************************************************************************
bool TMoverParameters::BatterySwitch(bool State, range_t const Notify)
{
+ using enum range_t;
auto const initialstate{Battery};
// Ra: ukrotnienie załączania baterii jest jakąś fikcją...
@@ -3164,10 +3115,10 @@ bool TMoverParameters::BatterySwitch(bool State, range_t const Notify)
}
// switching batteries does not require activation
- if (Notify != range_t::local)
+ if (Notify != local)
{
- SendCtrlToNext("BatterySwitch", State ? 1 : 0, 1, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
- SendCtrlToNext("BatterySwitch", State ? 1 : 0, -1, Notify == range_t::unit ? coupling::control | coupling::permanent : coupling::control);
+ SendCtrlToNext("BatterySwitch", State ? 1 : 0, 1, Notify == unit ? coupling::control | coupling::permanent : coupling::control);
+ SendCtrlToNext("BatterySwitch", State ? 1 : 0, -1, Notify == unit ? coupling::control | coupling::permanent : coupling::control);
}
return Battery != initialstate;
@@ -3250,11 +3201,10 @@ bool TMoverParameters::DirectionBackward(void)
return false;
}
- if (DirActive == 1 && MainCtrlPos == 0 && TrainType == dt_EZT && EngineType != TEngineType::ElectricInductionMotor)
- if (MinCurrentSwitch(false))
- {
- return true;
- }
+ if (DirActive == 1 && MainCtrlPos == 0 && TrainType == dt_EZT && EngineType != TEngineType::ElectricInductionMotor && MinCurrentSwitch(false))
+ {
+ return true;
+ }
if (MainCtrlPosNo > 0 && DirActive > -1 && (CabActive != 0 || (InactiveCabFlag & activation::neutraldirection) == 0))
{
if (EngineType == TEngineType::WheelsDriven)
@@ -3662,6 +3612,7 @@ void TMoverParameters::MainSwitch_(bool const State)
bool TMoverParameters::MainSwitchCheck() const
{
+ using enum TEngineType;
// prevent the switch from working if there's no power
// TODO: consider whether it makes sense for diesel engines and such
@@ -3669,15 +3620,15 @@ bool TMoverParameters::MainSwitchCheck() const
switch (EngineType)
{
- case TEngineType::DieselElectric:
- case TEngineType::DieselEngine:
- case TEngineType::Dumb:
+ case DieselElectric:
+ case DieselEngine:
+ case Dumb:
{
powerisavailable = Power24vIsAvailable;
break;
}
- case TEngineType::ElectricSeriesMotor:
- case TEngineType::ElectricInductionMotor:
+ case ElectricSeriesMotor:
+ case ElectricInductionMotor:
{
// TODO: check whether we can simplify this check and skip the outer EngineType switch
powerisavailable = EnginePowerSourceVoltage() > 0.5 * EnginePowerSource.MaxVoltage;
@@ -3689,7 +3640,7 @@ bool TMoverParameters::MainSwitchCheck() const
}
}
- return powerisavailable && (ScndCtrlPos == 0 || EngineType == TEngineType::ElectricInductionMotor) && MainsInitTimeCountdown <= 0.0 &&
+ return powerisavailable && (ScndCtrlPos == 0 || EngineType == ElectricInductionMotor) && MainsInitTimeCountdown <= 0.0 &&
(ConvOvldFlag == false || ConverterOverloadRelayOffWhenMainIsOff) && true == GroundRelay && true == NoVoltRelay && true == OvervoltageRelay && LastSwitchingTime > CtrlDelay &&
(HasCamshaft ? IsMainCtrlActualNoPowerPos() :
LineBreakerClosesOnlyAtNoPowerPos ? IsMainCtrlNoPowerPos() :
@@ -3947,8 +3898,7 @@ double TMoverParameters::DynamicBrakeRatio(void) const
bool TMoverParameters::DynamicBrakeAvailable(void) const
{
double const vh0{eimc[eimc_p_Vh0]};
- double const vh1{eimc[eimc_p_Vh1]};
- if (vh1 <= 0.001)
+ if (double const vh1{eimc[eimc_p_Vh1]}; vh1 <= 0.001)
{
// brak zdefiniowanej strefy - ED dziala zawsze
return true;
@@ -4012,10 +3962,10 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch)
{
DynamicBrakeFlag = Switch;
DBS = true;
- for (int b = 0; b < 2; b++)
+ for (auto &thiscoupler : Couplers)
// with Couplers[b] do
- if (TestFlag(Couplers[b].CouplingFlag, coupling::control))
- Couplers[b].Connected->DynamicBrakeFlag = Switch;
+ if (TestFlag(thiscoupler.CouplingFlag, coupling::control))
+ thiscoupler.Connected->DynamicBrakeFlag = Switch;
// end;
// if (DynamicBrakeType=dbrake_passive) and (TrainType=dt_ET42) then
// begin
@@ -4345,7 +4295,7 @@ void TMoverParameters::CompressorCheck(double dt)
EmergencyValveOpen = Compressor > (EmergencyValveOpen ? EmergencyValveOff : EmergencyValveOn);
if (EmergencyValveOpen)
{
- float dV = PF(0, Compressor, EmergencyValveArea) * dt;
+ auto dV = static_cast(PF(0, Compressor, EmergencyValveArea) * dt);
CompressedVolume -= dV;
}
@@ -4357,9 +4307,8 @@ void TMoverParameters::CompressorCheck(double dt)
auto const MaxCompressorF{CompressorList[TCompressorList::cl_MaxFactor][CompressorListPos] * MaxCompressor};
auto const MinCompressorF{CompressorList[TCompressorList::cl_MinFactor][CompressorListPos] * MinCompressor};
auto const CompressorSpeedF{CompressorList[TCompressorList::cl_SpeedFactor][CompressorListPos] * CompressorSpeed};
- auto const AllowFactor{CompressorList[TCompressorList::cl_Allow][CompressorListPos]};
// checking the impact on the compressor allowance
- if (AllowFactor > 0.5)
+ if (auto const AllowFactor{CompressorList[TCompressorList::cl_Allow][CompressorListPos]}; AllowFactor > 0.5)
{
CompressorAllow = AllowFactor > 1.5;
}
@@ -4419,21 +4368,16 @@ void TMoverParameters::CompressorCheck(double dt)
}
// working compressor adds air to the air reservoir
- switch (CompressorPower)
- {
- case 3:
+ if (CompressorPower == 3)
{
// the compressor is coupled with the diesel engine, engine revolutions affect the output
CompressedVolume +=
CompressorSpeedF * (2.0 * MaxCompressorF - Compressor) / MaxCompressorF * EngineRPMRatio() * dt * (CompressorGovernorLock ? 0.0 : 1.0); // with the lock active air is vented out
- break;
}
- default:
+ else
{
// the compressor is a stand-alone device, working at steady pace
CompressedVolume += CompressorSpeedF * (2.0 * MaxCompressorF - Compressor) / MaxCompressorF * dt;
- break;
- }
}
if (pressureistoohigh && (false == governorlockispresent || CompressorPower == 3))
@@ -4451,14 +4395,11 @@ void TMoverParameters::CompressorCheck(double dt)
// tymczasowo tylko obciążenie sprężarki, tak z 5A na sprężarkę
// TODO: draw power from proper high- or low voltage circuit
- switch (CompressorPower)
- {
- case 3:
+ if (CompressorPower == 3)
{
// diesel-powered compressor doesn't draw power
- break;
}
- default:
+ else
{
// TODO: drain power from 110v circuit
/*
@@ -4466,8 +4407,6 @@ void TMoverParameters::CompressorCheck(double dt)
compressorowner->TotalCurrent += 0.0015 * compressorowner->PantographVoltage;
}
*/
- break;
- }
}
}
@@ -4483,8 +4422,6 @@ void TMoverParameters::UpdatePipePressure(double dt)
Pipe->Act();
}
- const double LBDelay = 100;
- const double kL = 0.5;
// double dV;
// TMoverParameters *c; // T_MoverParameters
double temp;
@@ -4575,6 +4512,7 @@ void TMoverParameters::UpdatePipePressure(double dt)
}
if (dpMainValve < 0) // && (PipePressureVal > 0.01) //50
+ {
if (Compressor > ScndPipePress)
{
CompressedVolume = CompressedVolume + dpMainValve / 1500.0;
@@ -4582,12 +4520,12 @@ void TMoverParameters::UpdatePipePressure(double dt)
}
else
Pipe2->Flow(dpMainValve);
+ }
}
// ulepszony hamulec bezp.
EmergencyValveFlow = 0.0;
- auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable};
// EngDmgFlag 32 (load destroyed) used to trigger this too; dropped, it has nothing to do with
// the emergency brake (a broken coupler sets AlarmChainFlag instead)
@@ -4640,11 +4578,11 @@ void TMoverParameters::UpdatePipePressure(double dt)
{
LocBrakePress = LocHandle->GetCP();
- for (int b = 0; b < 2; b++)
- if ((TrainType & (dt_ET41 | dt_ET42)) != 0 && Couplers[b].Connected != nullptr) // nie podoba mi się to rozwiązanie, chyba trzeba
- // dodać jakiś wpis do fizyki na to
- if ((Couplers[b].Connected->TrainType & (dt_ET41 | dt_ET42)) != 0 && (Couplers[b].CouplingFlag & 36) == 36)
- LocBrakePress = std::max(Couplers[b].Connected->LocHandle->GetCP(), LocBrakePress);
+ for (auto const &couplerentry : Couplers)
+ // nie podoba mi się to rozwiązanie, chyba trzeba
+ // dodać jakiś wpis do fizyki na to
+ if ((TrainType & (dt_ET41 | dt_ET42)) != 0 && couplerentry.Connected != nullptr && (couplerentry.Connected->TrainType & (dt_ET41 | dt_ET42)) != 0 && (couplerentry.CouplingFlag & 36) == 36)
+ LocBrakePress = std::max(couplerentry.Connected->LocHandle->GetCP(), LocBrakePress);
// if ((DynamicBrakeFlag) && (EngineType == ElectricInductionMotor))
//{
@@ -4657,10 +4595,12 @@ void TMoverParameters::UpdatePipePressure(double dt)
//(Hamulec as TLSt).SetLBP(LocBrakePress);
Hamulec->SetLBP(LocBrakePress);
if (BrakeValve == TBrakeValve::EStED)
+ {
if (MBPM < 2)
Hamulec->PLC(MaxBrakePress[LoadFlag]);
else
Hamulec->PLC(TotalMass - Mred);
+ }
break;
}
@@ -4732,7 +4672,7 @@ void TMoverParameters::UpdatePipePressure(double dt)
if (DCEMUED_EP_min_Im > 0.001 && abs(Im) > DCEMUED_EP_min_Im && DynamicBrakeEMUStatus)
temp1 = 0;
Hamulec->SetEPS(temp1);
- TUHEX_StageActual = EpForce;
+ TUHEX_StageActual = static_cast(EpForce);
TUHEX_Active = TUHEX_StageActual > 0;
// Ra 2014-11: na tym się wysypuje, ale nie wiem, w jakich warunkach
SendCtrlToNext("Brake", EpForce, CabActive);
@@ -4782,7 +4722,9 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
const double Spz = 0.5067;
TMoverParameters *c;
- double dv1, dv2, dV;
+ double dv1;
+ double dv2;
+ double dV;
UpdateSpringBrake(dt);
@@ -4790,32 +4732,29 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
dv2 = 0;
// sprzeg 1
- if (Couplers[0].Connected != nullptr)
- if (TestFlag(Couplers[0].CouplingFlag, ctrain_scndpneumatic))
- {
- c = Couplers[0].Connected; // skrot
- dv1 = 0.5 * dt * PF(ScndPipePress, c->ScndPipePress, Spz * 0.75);
- if (dv1 * dv1 > 0.00000000000001)
- c->switch_physics(true);
- c->Pipe2->Flow(-dv1);
- }
+ if (Couplers[0].Connected != nullptr && TestFlag(Couplers[0].CouplingFlag, ctrain_scndpneumatic))
+ {
+ c = Couplers[0].Connected; // skrot
+ dv1 = 0.5 * dt * PF(ScndPipePress, c->ScndPipePress, Spz * 0.75);
+ if (dv1 * dv1 > 0.00000000000001)
+ c->switch_physics(true);
+ c->Pipe2->Flow(-dv1);
+ }
// sprzeg 2
- if (Couplers[1].Connected != nullptr)
- if (TestFlag(Couplers[1].CouplingFlag, ctrain_scndpneumatic))
- {
- c = Couplers[1].Connected; // skrot
- dv2 = 0.5 * dt * PF(ScndPipePress, c->ScndPipePress, Spz * 0.75);
- if (dv2 * dv2 > 0.00000000000001)
- c->switch_physics(true);
- c->Pipe2->Flow(-dv2);
- }
- if (Couplers[1].Connected != nullptr && Couplers[0].Connected != nullptr)
- if (TestFlag(Couplers[0].CouplingFlag, ctrain_scndpneumatic) && TestFlag(Couplers[1].CouplingFlag, ctrain_scndpneumatic))
- {
- dV = 0.00025 * dt * PF(Couplers[0].Connected->ScndPipePress, Couplers[1].Connected->ScndPipePress, Spz * 0.25);
- Couplers[0].Connected->Pipe2->Flow(+dV);
- Couplers[1].Connected->Pipe2->Flow(-dV);
- }
+ if (Couplers[1].Connected != nullptr && TestFlag(Couplers[1].CouplingFlag, ctrain_scndpneumatic))
+ {
+ c = Couplers[1].Connected; // skrot
+ dv2 = 0.5 * dt * PF(ScndPipePress, c->ScndPipePress, Spz * 0.75);
+ if (dv2 * dv2 > 0.00000000000001)
+ c->switch_physics(true);
+ c->Pipe2->Flow(-dv2);
+ }
+ if (Couplers[1].Connected != nullptr && Couplers[0].Connected != nullptr && TestFlag(Couplers[0].CouplingFlag, ctrain_scndpneumatic) && TestFlag(Couplers[1].CouplingFlag, ctrain_scndpneumatic))
+ {
+ dV = 0.00025 * dt * PF(Couplers[0].Connected->ScndPipePress, Couplers[1].Connected->ScndPipePress, Spz * 0.25);
+ Couplers[0].Connected->Pipe2->Flow(+dV);
+ Couplers[1].Connected->Pipe2->Flow(-dV);
+ }
Pipe2->Flow(Hamulec->GetHPFlow(ScndPipePress, dt));
// NOTE: condition disabled to allow the air flow from the main hose to the main tank as well
@@ -4841,7 +4780,7 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
// yB: 20190906
// Aktualizacja ciśnienia w hamulcu sprezynowym
// *************************************************************************************************
-void TMoverParameters::UpdateSpringBrake(double dt)
+void TMoverParameters::UpdateSpringBrake(double /*dt*/)
{
double BP = SpringBrake.PNBrakeConnection ? BrakePress : 0;
double MSP = SpringBrake.ShuttOff ? 0 : SpringBrake.MaxSetPressure;
@@ -4875,30 +4814,29 @@ double TMoverParameters::GetDVc(double dt)
{
// T_MoverParameters *c;
TMoverParameters *c;
- double dv1, dv2; // , dV;
+ double dv1;
+ double dv2; // , dV;
dv1 = 0;
dv2 = 0;
// sprzeg 1
- if (Couplers[0].Connected != nullptr)
- if (TestFlag(Couplers[0].CouplingFlag, ctrain_pneumatic))
- { //*0.85
- c = Couplers[0].Connected; // skrot //0.08 //e/D * L/D = e/D^2 * L
- dv1 = 0.5 * dt * PF(PipePress, c->PipePress, Spg / (1.0 + 0.015 / Spg * Dim.L));
- if (dv1 * dv1 > 0.00000000000001)
- c->switch_physics(true);
- c->Pipe->Flow(-dv1);
- }
+ if (Couplers[0].Connected != nullptr && TestFlag(Couplers[0].CouplingFlag, ctrain_pneumatic))
+ { //*0.85
+ c = Couplers[0].Connected; // skrot //0.08 //e/D * L/D = e/D^2 * L
+ dv1 = 0.5 * dt * PF(PipePress, c->PipePress, Spg / (1.0 + 0.015 / Spg * Dim.L));
+ if (dv1 * dv1 > 0.00000000000001)
+ c->switch_physics(true);
+ c->Pipe->Flow(-dv1);
+ }
// sprzeg 2
- if (Couplers[1].Connected != nullptr)
- if (TestFlag(Couplers[1].CouplingFlag, ctrain_pneumatic))
- {
- c = Couplers[1].Connected; // skrot
- dv2 = 0.5 * dt * PF(PipePress, c->PipePress, Spg / (1.0 + 0.015 / Spg * Dim.L));
- if (dv2 * dv2 > 0.00000000000001)
- c->switch_physics(true);
- c->Pipe->Flow(-dv2);
- }
+ if (Couplers[1].Connected != nullptr && TestFlag(Couplers[1].CouplingFlag, ctrain_pneumatic))
+ {
+ c = Couplers[1].Connected; // skrot
+ dv2 = 0.5 * dt * PF(PipePress, c->PipePress, Spg / (1.0 + 0.015 / Spg * Dim.L));
+ if (dv2 * dv2 > 0.00000000000001)
+ c->switch_physics(true);
+ c->Pipe->Flow(-dv2);
+ }
// if ((Couplers[1].Connected != NULL) && (Couplers[0].Connected != NULL))
// if ((TestFlag(Couplers[0].CouplingFlag, ctrain_pneumatic)) &&
// (TestFlag(Couplers[1].CouplingFlag, ctrain_pneumatic)))
@@ -4919,11 +4857,13 @@ double TMoverParameters::GetDVc(double dt)
// *************************************************************************************************
void TMoverParameters::ComputeConstans(void)
{
- double BearingF, RollF, HideModifier;
+ double BearingF;
+ double RollF;
+ double HideModifier;
double Curvature; // Ra 2014-07: odwrotność promienia
TotalMassxg = TotalMass * g; // TotalMass*g
- BearingF = DamageFlag & dtrain_bearing > 0 ? 2.0 : 0;
+ BearingF = (DamageFlag & dtrain_bearing) != 0 ? 2.0 : 0;
HideModifier = 0; // int(Couplers[0].CouplingFlag>0)+int(Couplers[1].CouplingFlag>0);
@@ -4948,7 +4888,7 @@ void TMoverParameters::ComputeConstans(void)
// drag calculation
{
// NOTE: draft effect of previous vehicle is simplified and doesn't have much to do with reality
- auto const *previousvehicle{Couplers[(V >= 0.0 ? end::front : end::rear)].Connected};
+ auto const *previousvehicle{Couplers[V >= 0.0 ? end::front : end::rear].Connected};
auto dragarea{Dim.W * Dim.H};
if (previousvehicle)
{
@@ -5177,7 +5117,7 @@ double TMoverParameters::BrakeForceR(double ratio, double velocity)
return BrakeForceP(press * ratio, velocity);
}
-double TMoverParameters::BrakeForceP(double press, double velocity)
+double TMoverParameters::BrakeForceP(double press, double velocity) const
{
double BFP = 0;
double K = ((press * P2FTrans - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj) * BrakeRigEff;
@@ -5190,10 +5130,11 @@ double TMoverParameters::BrakeForceP(double press, double velocity)
// Q: 20160713
// oblicza siłę na styku koła i szyny
// *************************************************************************************************
-double TMoverParameters::BrakeForce(TTrackParam const &Track)
+double TMoverParameters::BrakeForce(TTrackParam const & /*Track*/)
{
- double K{0}, Fb{0}, sm{0};
+ double K{0};
+ double brakeforce{0};
switch (LocalBrake)
{
@@ -5250,11 +5191,11 @@ double TMoverParameters::BrakeForce(TTrackParam const &Track)
// Fb:=UnitBrakeForce*NBpA {ham. reczny dziala na jedna os}
// else //yB: to nie do konca ma sens, ponieważ ręczny w wagonie działa na jeden cylinder
// hamulcowy/wózek, dlatego potrzebne są oddzielnie liczone osie
- Fb = UnitBrakeForce * NBrakeAxles * std::max(1, NBpA);
+ brakeforce = UnitBrakeForce * NBrakeAxles * std::max(1, NBpA);
// u:=((BrakePress*P2FTrans)-BrakeCylSpring*BrakeCylMult[BCMFlag]/BrakeCylNo-0.83*BrakeSlckAdj/(BrakeCylNo))*BrakeCylNo;
// { end; }
- return Fb;
+ return brakeforce;
}
// *************************************************************************************************
@@ -5334,7 +5275,7 @@ double TMoverParameters::Adhesive(double staticfriction) const
double TMoverParameters::CouplerForce(int const End, double dt)
{
- auto &coupler{Couplers[End]};
+ auto &thiscoupler{Couplers[End]};
auto *othervehicle{Neighbours[End].vehicle->MoverParameters};
auto const otherend{Neighbours[End].vehicle_end};
auto &othercoupler{othervehicle->Couplers[otherend]};
@@ -5349,81 +5290,81 @@ double TMoverParameters::CouplerForce(int const End, double dt)
auto const absdV{std::abs(dV)};
// potentially generate sounds on clash or stretch
- if (newdistance < 0.0 && coupler.Dist > newdistance && dV < -0.1 && false == coupler.has_adapter())
+ if (newdistance < 0.0 && thiscoupler.Dist > newdistance && dV < -0.1 && false == thiscoupler.has_adapter())
{ // HACK: with adapter present we presume buffers won't clash
// 090503: dzwieki pracy zderzakow
- SetFlag(coupler.sounds, absdV > 5.0 ? sound::bufferclash | sound::loud : sound::bufferclash);
+ SetFlag(thiscoupler.sounds, absdV > 5.0 ? sound::bufferclash | sound::loud : sound::bufferclash);
}
- else if (coupler.CouplingFlag != coupling::faux && newdistance > 0.001 && coupler.Dist <= 0.001 && absdV > 0.005 && Vel > 1.0)
+ else if (thiscoupler.CouplingFlag != coupling::faux && newdistance > 0.001 && thiscoupler.Dist <= 0.001 && absdV > 0.005 && Vel > 1.0)
{
// 090503: dzwieki pracy sprzegu
- SetFlag(coupler.sounds, absdV > 0.035 ? sound::couplerstretch | sound::loud : sound::couplerstretch);
+ SetFlag(thiscoupler.sounds, absdV > 0.035 ? sound::couplerstretch | sound::loud : sound::couplerstretch);
}
- coupler.CheckCollision = false;
- coupler.Dist = 0.0;
+ thiscoupler.CheckCollision = false;
+ thiscoupler.Dist = 0.0;
double CF{0.0};
- if (coupler.CouplingFlag == coupling::faux && initialdistance > 0.05)
+ if (thiscoupler.CouplingFlag == coupling::faux && initialdistance > 0.05)
{ // arbitrary distance
// potentially reset auto coupling lock
- coupler.AutomaticCouplingAllowed = true;
+ thiscoupler.AutomaticCouplingAllowed = true;
}
- if (coupler.CouplingFlag != coupling::faux || initialdistance < 0)
+ if (thiscoupler.CouplingFlag != coupling::faux || initialdistance < 0)
{
- coupler.Dist = std::clamp(newdistance, coupler.has_adapter() ? 0 : -coupler.DmaxB, coupler.DmaxC);
+ thiscoupler.Dist = std::clamp(newdistance, thiscoupler.has_adapter() ? 0 : -thiscoupler.DmaxB, thiscoupler.DmaxC);
double BetaAvg = 0;
double Fmax = 0;
- if (coupler.CouplingFlag == coupling::faux)
+ if (thiscoupler.CouplingFlag == coupling::faux)
{
- BetaAvg = coupler.beta;
- Fmax = (coupler.FmaxC + coupler.FmaxB) * CouplerTune;
+ BetaAvg = thiscoupler.beta;
+ Fmax = (thiscoupler.FmaxC + thiscoupler.FmaxB) * CouplerTune;
}
else
{
// usrednij bo wspolny sprzeg
- BetaAvg = 0.5 * (coupler.beta + othercoupler.beta);
- Fmax = 0.5 * (coupler.FmaxC + coupler.FmaxB + othercoupler.FmaxC + othercoupler.FmaxB) * CouplerTune;
+ BetaAvg = 0.5 * (thiscoupler.beta + othercoupler.beta);
+ Fmax = 0.5 * (thiscoupler.FmaxC + thiscoupler.FmaxB + othercoupler.FmaxC + othercoupler.FmaxB) * CouplerTune;
}
- auto const distDelta{std::abs(newdistance) - std::abs(coupler.Dist)}; // McZapkie-191103: poprawka na histereze
+ auto const distDelta{std::abs(newdistance) - std::abs(thiscoupler.Dist)}; // McZapkie-191103: poprawka na histereze
if (newdistance > 0)
{
if (distDelta > 0)
{
- CF = -(coupler.SpringKC + othercoupler.SpringKC) * coupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
+ CF = -(thiscoupler.SpringKC + othercoupler.SpringKC) * thiscoupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
}
else
{
- CF = -(coupler.SpringKC + othercoupler.SpringKC) * coupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
+ CF = -(thiscoupler.SpringKC + othercoupler.SpringKC) * thiscoupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
}
// liczenie sily ze sprezystosci sprzegu
- if (newdistance > coupler.DmaxC + othercoupler.DmaxC)
+ if (newdistance > thiscoupler.DmaxC + othercoupler.DmaxC)
{
// zderzenie
- coupler.CheckCollision = true;
+ thiscoupler.CheckCollision = true;
}
- if (std::abs(CF) > coupler.FmaxC)
+ if (std::abs(CF) > thiscoupler.FmaxC)
{
// coupler is stretched with excessive force, may break
- coupler.stretch_duration += dt;
+ thiscoupler.stretch_duration += static_cast(dt);
// give coupler 1 sec of leeway to account for simulation glitches, before checking whether it breaks
// (arbitrary) chance to break grows from 10-100% over 10 sec period
- if (Global.crash_damage && coupler.stretch_duration > 1.f && Random() < coupler.stretch_duration * 0.1f * dt)
+ if (Global.crash_damage && thiscoupler.stretch_duration > 1.f && Random() < thiscoupler.stretch_duration * 0.1f * dt)
{
damage_coupler(End);
}
}
else
{
- coupler.stretch_duration = 0.f;
+ thiscoupler.stretch_duration = 0.f;
}
}
if (newdistance < 0)
@@ -5431,52 +5372,49 @@ double TMoverParameters::CouplerForce(int const End, double dt)
if (distDelta > 0)
{
- CF = -(coupler.SpringKB + othercoupler.SpringKB) * coupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
+ CF = -(thiscoupler.SpringKB + othercoupler.SpringKB) * thiscoupler.Dist / 2.0 * DirF(End) - Fmax * dV * BetaAvg;
}
else
{
- CF = -(coupler.SpringKB + othercoupler.SpringKB) * coupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
+ CF = -(thiscoupler.SpringKB + othercoupler.SpringKB) * thiscoupler.Dist / 2.0 * DirF(End) * BetaAvg - Fmax * dV * BetaAvg;
}
// liczenie sily ze sprezystosci zderzaka
- auto const collisiondistance{(coupler.has_adapter() || othercoupler.has_adapter() ?
- std::min(coupler.DmaxB, othercoupler.DmaxB) : // HACK: only take into account buffering ability of automatic coupler
- coupler.DmaxB + othercoupler.DmaxB)};
+ auto const collisiondistance{(thiscoupler.has_adapter() || othercoupler.has_adapter() ?
+ std::min(thiscoupler.DmaxB, othercoupler.DmaxB) : // HACK: only take into account buffering ability of automatic coupler
+ thiscoupler.DmaxB + othercoupler.DmaxB)};
if (-newdistance > collisiondistance)
{
// zderzenie
- coupler.CheckCollision = true;
+ thiscoupler.CheckCollision = true;
}
- if (-newdistance >= std::min(collisiondistance, dEpsilon))
- {
- if (coupler.type() == TCouplerType::Automatic && coupler.type() == othercoupler.type() && coupler.CouplingFlag == coupling::faux &&
- coupler.AutomaticCouplingAllowed &&
+ if (-newdistance >= std::min(collisiondistance, dEpsilon) && thiscoupler.type() == TCouplerType::Automatic && thiscoupler.type() == othercoupler.type() && thiscoupler.CouplingFlag == coupling::faux &&
+ thiscoupler.AutomaticCouplingAllowed &&
othercoupler.AutomaticCouplingAllowed)
+ {
+ // sprzeganie wagonow z samoczynnymi sprzegami
+ auto couplingtype{thiscoupler.AutomaticCouplingFlag & othercoupler.AutomaticCouplingFlag};
+ // potentially exclude incompatible control coupling
+ if (thiscoupler.control_type != othercoupler.control_type)
{
- // sprzeganie wagonow z samoczynnymi sprzegami
- auto couplingtype{coupler.AutomaticCouplingFlag & othercoupler.AutomaticCouplingFlag};
- // potentially exclude incompatible control coupling
- if (coupler.control_type != othercoupler.control_type)
- {
- couplingtype &= ~coupling::control;
- }
-
- if (Attach(End, otherend, othervehicle, couplingtype))
- {
- // HACK: we're reusing sound enum to mark whether vehicle was connected to another
- SetFlag(AIFlag, sound::attachcoupler);
- coupler.AutomaticCouplingAllowed = false;
- othercoupler.AutomaticCouplingAllowed = false;
- }
- /*
- coupler.CouplingFlag = ( coupler.AutomaticCouplingFlag & othercoupler.AutomaticCouplingFlag );
- SetFlag( coupler.sounds, sound::attachcoupler );
- */
+ couplingtype &= ~coupling::control;
}
+
+ if (Attach(End, otherend, othervehicle, couplingtype))
+ {
+ // HACK: we're reusing sound enum to mark whether vehicle was connected to another
+ SetFlag(AIFlag, sound::attachcoupler);
+ thiscoupler.AutomaticCouplingAllowed = false;
+ othercoupler.AutomaticCouplingAllowed = false;
+ }
+ /*
+ coupler.CouplingFlag = ( coupler.AutomaticCouplingFlag & othercoupler.AutomaticCouplingFlag );
+ SetFlag( coupler.sounds, sound::attachcoupler );
+ */
}
}
}
- if (coupler.CouplingFlag != coupling::faux)
+ if (thiscoupler.CouplingFlag != coupling::faux)
{
// uzgadnianie prawa Newtona
othervehicle->Couplers[1 - End].CForce = -CF;
@@ -5491,7 +5429,10 @@ double TMoverParameters::CouplerForce(int const End, double dt)
// *************************************************************************************************
double TMoverParameters::TractionForce(double dt)
{
- double PosRatio, dmoment, dtrans, tmp;
+ double PosRatio;
+ double dmoment;
+ double dtrans;
+ double tmp;
Ft = 0;
dtrans = 0;
@@ -5507,7 +5448,7 @@ double TMoverParameters::TractionForce(double dt)
if (EIMCtrlType > 0) // sterowanie cyfrowe
tmp = (DElist[0].RPM + (DElist[MainCtrlPosNo].RPM - DElist[0].RPM) * std::max(0.0, eimic_real)) / 60.0;
else
- tmp = DElist[(ControlPressureSwitch ? MainCtrlNoPowerPos() : MainCtrlPos)].RPM / 60.0;
+ tmp = DElist[ControlPressureSwitch ? MainCtrlNoPowerPos() : MainCtrlPos].RPM / 60.0;
if (true == HeatingAllow && HeatingPower > 0 && EngineHeatingRPM > 0)
{
@@ -5628,14 +5569,14 @@ double TMoverParameters::TractionForce(double dt)
{
// TBD, TODO: currently ignores RVentType, fix this?
RventRot += std::clamp(enrot - RventRot, -100.0, 50.0) * dt;
- dizel_heat.rpmw += std::clamp(dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f) * dt;
- dizel_heat.rpmw2 += std::clamp(dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f) * dt;
+ dizel_heat.rpmw += static_cast(std::clamp(dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f) * dt);
+ dizel_heat.rpmw2 += static_cast(std::clamp(dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f) * dt);
}
else
{
RventRot *= std::max(0.0, 1.0 - RVentSpeed * dt);
- dizel_heat.rpmw *= std::max(0.0, 1.0 - dizel_heat.rpmw * dt);
- dizel_heat.rpmw2 *= std::max(0.0, 1.0 - dizel_heat.rpmw2 * dt);
+ dizel_heat.rpmw *= static_cast(std::max(0.0, 1.0 - dizel_heat.rpmw * dt));
+ dizel_heat.rpmw2 *= static_cast(std::max(0.0, 1.0 - dizel_heat.rpmw2 * dt));
}
break;
}
@@ -5645,13 +5586,13 @@ double TMoverParameters::TractionForce(double dt)
// NOTE: we update only radiator fans, as vehicles with diesel engine don't have other ventilators
if (true == Mains)
{
- dizel_heat.rpmw += std::clamp(dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f) * dt;
- dizel_heat.rpmw2 += std::clamp(dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f) * dt;
+ dizel_heat.rpmw += static_cast(std::clamp(dizel_heat.rpmwz - dizel_heat.rpmw, -100.f, 50.f) * dt);
+ dizel_heat.rpmw2 += static_cast(std::clamp(dizel_heat.rpmwz2 - dizel_heat.rpmw2, -100.f, 50.f) * dt);
}
else
{
- dizel_heat.rpmw *= std::max(0.0, 1.0 - dizel_heat.rpmw * dt);
- dizel_heat.rpmw2 *= std::max(0.0, 1.0 - dizel_heat.rpmw2 * dt);
+ dizel_heat.rpmw *= static_cast(std::max(0.0, 1.0 - dizel_heat.rpmw * dt));
+ dizel_heat.rpmw2 *= static_cast(std::max(0.0, 1.0 - dizel_heat.rpmw2 * dt));
}
break;
}
@@ -5711,14 +5652,11 @@ double TMoverParameters::TractionForce(double dt)
case TEngineType::ElectricInductionMotor:
{
// TODO: check if we can use instead the code for electricseriesmotor
- if (Mains)
+ // nie wchodzić w funkcję bez potrzeby
+ if (Mains && (std::max(GetTrainsetHighVoltage(), PantographVoltage) < EnginePowerSource.CollectorParameters.MinV ||
+ std::max(GetTrainsetHighVoltage(), PantographVoltage) > EnginePowerSource.CollectorParameters.MaxV + 200))
{
- // nie wchodzić w funkcję bez potrzeby
- if (std::max(GetTrainsetHighVoltage(), PantographVoltage) < EnginePowerSource.CollectorParameters.MinV ||
- std::max(GetTrainsetHighVoltage(), PantographVoltage) > EnginePowerSource.CollectorParameters.MaxV + 200)
- {
- MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide
- }
+ MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide
}
break;
}
@@ -5765,9 +5703,8 @@ double TMoverParameters::TractionForce(double dt)
case TEngineType::WheelsDriven:
{
- if (EnginePowerSource.SourceType == TPowerSource::InternalSource)
- if (EnginePowerSource.PowerType == TPowerType::BioPower)
- Ft = Sign(sin(eAngle)) * PulseForce * Transmision.Ratio;
+ if (EnginePowerSource.SourceType == TPowerSource::InternalSource && EnginePowerSource.PowerType == TPowerType::BioPower)
+ Ft = Sign(sin(eAngle)) * PulseForce * Transmision.Ratio;
PulseForceTimer = PulseForceTimer + dt;
if (PulseForceTimer > CtrlDelay)
{
@@ -5936,7 +5873,6 @@ double TMoverParameters::TractionForce(double dt)
auto power = Power;
tempImax = DElist[MainCtrlPos].Imax;
tempUmax = DElist[MainCtrlPos].Umax;
- tempPmax = DElist[MainCtrlPos].GenPower;
if (true == Heating)
{
power -= HeatingPower;
@@ -6193,24 +6129,21 @@ double TMoverParameters::TractionForce(double dt)
}
}
// malenie
- if (MainCtrlPos < 12 && ScndCtrlPos > 0)
+ if (MainCtrlPos < 12 && ScndCtrlPos > 0 && Vel < 50.0)
{
- if (Vel < 50.0)
+ // above 50 km/h already active shunt field can be maintained until lower controller setting
+ if (ScndCtrlPos % 2 == 0)
{
- // above 50 km/h already active shunt field can be maintained until lower controller setting
- if (ScndCtrlPos % 2 == 0)
+ if (MPTRelay[ScndCtrlPos].Idown < Im)
{
- if (MPTRelay[ScndCtrlPos].Idown < Im)
- {
- --ScndCtrlPos;
- }
+ --ScndCtrlPos;
}
- else
+ }
+ else
+ {
+ if (MPTRelay[ScndCtrlPos + 1].Idown < Im && MPTRelay[ScndCtrlPos].Idown > Vel)
{
- if (MPTRelay[ScndCtrlPos + 1].Idown < Im && MPTRelay[ScndCtrlPos].Idown > Vel)
- {
- --ScndCtrlPos;
- }
+ --ScndCtrlPos;
}
}
}
@@ -6244,7 +6177,7 @@ double TMoverParameters::TractionForce(double dt)
if (true == Mains && !SecuritySystem.is_engine_blocked())
{
double ActiveInverters = 0.0;
- for (auto &inv : Inverters)
+ for (auto const &inv : Inverters)
{
if (inv.IsActive)
ActiveInverters += 1.0;
@@ -6296,6 +6229,8 @@ double TMoverParameters::TractionForce(double dt)
SpeedCtrlValue = Vmax;
SpeedCtrlTimer = 10;
break;
+ default:
+ break;
}
}
else if (ScndCtrlPosNo > 1)
@@ -6311,7 +6246,7 @@ double TMoverParameters::TractionForce(double dt)
SpeedCtrlTimer += dt;
if (SpeedCtrlTimer > SpeedCtrlDelay)
{
- int NewSCAP = (float)ScndCtrlPos / (float)ScndCtrlPosNo * Vmax;
+ auto NewSCAP = static_cast((float)ScndCtrlPos / (float)ScndCtrlPosNo * Vmax);
if (NewSCAP != SpeedCtrlValue)
{
SpeedCtrlValue = NewSCAP;
@@ -6350,7 +6285,7 @@ double TMoverParameters::TractionForce(double dt)
{
PosRatio = 0;
}
- PosRatio = Round(20.0 * PosRatio) / 20.0; // stopniowanie PN/ED
+ PosRatio = static_cast(Round(20.0 * PosRatio)) / 20.0; // stopniowanie PN/ED
if (PosRatio < 19.5 / 20.0)
PosRatio *= 0.9;
Hamulec->SetED(std::max(0.0, std::min(PosRatio, 1.0))); // ustalenie stopnia zmniejszenia ciśnienia
@@ -6397,7 +6332,6 @@ double TMoverParameters::TractionForce(double dt)
// (Hamulec as TLSt).SetLBP(LocBrakePress);
tmp = 4; // szybkie malenie, powolne wzrastanie
}
- dmoment = eimv[eimv_Fful];
// NOTE: the commands to operate the sandbox are likely to conflict with other similar ai decisions
// TODO: gather these in single place so they can be resolved together
if (SlippingWheels)
@@ -6501,9 +6435,8 @@ double TMoverParameters::TractionForce(double dt)
auto const tmpV{std::abs(eimv[eimv_fp])};
auto const useFFEDList = FFEDListSize > 0 && DynamicBrakeFlag;
auto const list = useFFEDList ? FFEDlist : FFlist;
- auto const listSize = useFFEDList ? FFEDListSize : FFListSize;
- if (listSize > 0 && std::abs(eimv[eimv_If]) > 1.0 && tmpV > 0.0001)
+ if (auto const listSize = useFFEDList ? FFEDListSize : FFListSize; listSize > 0 && std::abs(eimv[eimv_If]) > 1.0 && tmpV > 0.0001)
{
int i = 0;
@@ -6540,8 +6473,8 @@ double TMoverParameters::TractionForce(double dt)
eimv_pr = 0.0;
EnginePower = 0.0;
{
- for (int i = 0; i < 21; ++i)
- eimv[i] = 0.0;
+ for (auto &eimvvalue : eimv)
+ eimvvalue = 0.0;
}
Hamulec->SetED(0.0);
InverterFrequency = 0.0; //(Hamulec as TLSt).SetLBP(LocBrakePress);
@@ -6556,18 +6489,10 @@ double TMoverParameters::TractionForce(double dt)
}
} // case EngineType
- switch (EngineType)
- {
- case TEngineType::DieselElectric:
+ if (EngineType == TEngineType::DieselElectric)
{
// rough approximation of extra effort to overcome friction etc
EnginePower += EngineRPMRatio() * 0.15 * DElist[MainCtrlPosNo].GenPower;
- break;
- }
- default:
- {
- break;
- }
}
return Ft;
@@ -6579,7 +6504,8 @@ double TMoverParameters::TractionForce(double dt)
// *************************************************************************************************
double TMoverParameters::ComputeRotatingWheel(double WForce, double dt, double n) const
{
- double newn = 0, eps = 0;
+ double newn = 0;
+ double eps = 0;
if (n == 0 && WForce * Sign(V) < 0)
newn = 0;
else
@@ -6604,10 +6530,9 @@ bool TMoverParameters::FuseFlagCheck(void) const
if (Power > 0.01)
FFC = FuseFlag;
else // pobor pradu jezeli niema mocy
- for (int b = 0; b < 2; b++)
- if (TestFlag(Couplers[b].CouplingFlag, coupling::control))
- if (Couplers[b].Connected->Power > 0.01)
- FFC = Couplers[b].Connected->FuseFlagCheck();
+ for (auto &thiscoupler : Couplers)
+ if (TestFlag(thiscoupler.CouplingFlag, coupling::control) && thiscoupler.Connected->Power > 0.01)
+ FFC = thiscoupler.Connected->FuseFlagCheck();
return FFC;
}
@@ -6641,8 +6566,7 @@ void TMoverParameters::FuseOff(void)
bool TMoverParameters::UniversalResetButton(int const Button, range_t const Notify)
{
- auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable};
- if (false == lowvoltagepower)
+ if (auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable}; false == lowvoltagepower)
{
return false;
}
@@ -6665,43 +6589,34 @@ bool TMoverParameters::RelayReset(int const Relays, range_t const Notify)
auto const lowvoltagepower{Power24vIsAvailable || Power110vIsAvailable};
bool reset{false};
- if (TestFlag(Relays, relay_t::maincircuitground))
- {
- if ((EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) &&
+ if (TestFlag(Relays, relay_t::maincircuitground) && (EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) &&
(GroundRelayStart == start_t::manual || GroundRelayStart == start_t::manualwithautofallback) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 &&
!TestFlag(EngDmgFlag, 1))
- {
- // NOTE: true means the relay is operational
- reset |= !GroundRelay && lowvoltagepower;
- GroundRelay |= lowvoltagepower;
- }
+ {
+ // NOTE: true means the relay is operational
+ reset |= !GroundRelay && lowvoltagepower;
+ GroundRelay |= lowvoltagepower;
}
- if (TestFlag(Relays, relay_t::tractionnmotoroverload))
- {
- if ((EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 &&
+ if (TestFlag(Relays, relay_t::tractionnmotoroverload) && (EngineType == TEngineType::ElectricSeriesMotor || EngineType == TEngineType::DieselElectric) && IsMainCtrlNoPowerPos() && ScndCtrlPos == 0 && DirActive != 0 &&
!TestFlag(EngDmgFlag, 1))
- {
- // NOTE: false means the relay is operational
- // TODO: cleanup, flip the FuseFlag code to match other relays
- // TODO: check whether the power is required, TBD, TODO: make it configurable?
- reset |= FuseFlag && lowvoltagepower;
- FuseFlag &= !lowvoltagepower;
- }
+ {
+ // NOTE: false means the relay is operational
+ // TODO: cleanup, flip the FuseFlag code to match other relays
+ // TODO: check whether the power is required, TBD, TODO: make it configurable?
+ reset |= FuseFlag && lowvoltagepower;
+ FuseFlag &= !lowvoltagepower;
}
- if (TestFlag(Relays, relay_t::primaryconverteroverload))
- {
- if (ConverterOverloadRelayStart == start_t::manual
+ if (TestFlag(Relays, relay_t::primaryconverteroverload) && ConverterOverloadRelayStart == start_t::manual
// && ( false == Mains )
&& false == ConverterAllow)
- {
- // NOTE: false means the relay is operational
- // TODO: cleanup, flip the FuseFlag code to match other relays
- // TODO: check whether the power is required, TBD, TODO: make it configurable?
- reset |= ConvOvldFlag && lowvoltagepower;
- ConvOvldFlag &= !lowvoltagepower;
- }
+ {
+ // NOTE: false means the relay is operational
+ // TODO: cleanup, flip the FuseFlag code to match other relays
+ // TODO: check whether the power is required, TBD, TODO: make it configurable?
+ reset |= ConvOvldFlag && lowvoltagepower;
+ ConvOvldFlag &= !lowvoltagepower;
}
if (reset)
@@ -6725,7 +6640,8 @@ double TMoverParameters::v2n(void)
{
// przelicza predkosc liniowa na obrotowa
const double dmgn = 0.5;
- double n, deltan = 0;
+ double n;
+ double deltan = 0;
n = V / (M_PI * WheelDiameter); // predkosc obrotowa wynikajaca z liniowej [obr/s]
deltan = n - nrot; //"pochodna" prędkości obrotowej
@@ -6734,14 +6650,10 @@ double TMoverParameters::v2n(void)
SlippingWheels = false; // wygaszenie poslizgu */ //poslizg jest w innym miejscu wygaszany też
if (SlippingWheels) // nie ma zwiazku z predkoscia liniowa V
{ // McZapkie-221103: uszkodzenia kol podczas poslizgu
- if (deltan > dmgn)
- if (FuzzyLogic(deltan, dmgn, p_slippdmg))
- if (SetFlag(DamageFlag, dtrain_wheelwear)) // podkucie
- EventFlag = true;
- if (deltan < -dmgn)
- if (FuzzyLogic(-deltan, dmgn, p_slippdmg))
- if (SetFlag(DamageFlag, dtrain_thinwheel)) // wycieranie sie obreczy
- EventFlag = true;
+ if (deltan > dmgn && FuzzyLogic(deltan, dmgn, p_slippdmg) && SetFlag(DamageFlag, dtrain_wheelwear)) // podkucie
+ EventFlag = true;
+ if (deltan < -dmgn && FuzzyLogic(-deltan, dmgn, p_slippdmg) && SetFlag(DamageFlag, dtrain_thinwheel)) // wycieranie sie obreczy
+ EventFlag = true;
n = nrot; // predkosc obrotowa nie zalezy od predkosci liniowej
}
return n;
@@ -6751,15 +6663,14 @@ double TMoverParameters::v2n(void)
// Q: 20160714
// Oblicza moment siły wytwarzany przez silnik
// *************************************************************************************************
-double TMoverParameters::Momentum(double I)
+double TMoverParameters::Momentum(double I) const
{
// liczy moment sily wytwarzany przez silnik elektryczny}
int SP;
SP = ScndCtrlActualPos;
- if (ScndInMain)
- if (!(RList[MainCtrlActualPos].ScndAct == 255))
- SP = RList[MainCtrlActualPos].ScndAct;
+ if (ScndInMain && !(RList[MainCtrlActualPos].ScndAct == 255))
+ SP = RList[MainCtrlActualPos].ScndAct;
// Momentum:=mfi*I*(1-1.0/(Abs(I)/mIsat+1));
return motor_param(SP).mfi * I * (abs(I) / (abs(I) + motor_param(SP).mIsat) - motor_param(SP).mfi0);
@@ -6769,7 +6680,7 @@ double TMoverParameters::Momentum(double I)
// Q: 20160714
// Oblicza moment siły do sterowania wzbudzeniem
// *************************************************************************************************
-double TMoverParameters::MomentumF(double I, double Iw, int SCP)
+double TMoverParameters::MomentumF(double I, double Iw, int SCP) const
{
// umozliwia dokladne sterowanie wzbudzeniem
@@ -6783,13 +6694,10 @@ double TMoverParameters::MomentumF(double I, double Iw, int SCP)
bool TMoverParameters::CutOffEngine(void)
{
bool COE = false; // Ra: wartość domyślna, sprawdzić to trzeba
- if (NPoweredAxles > 0 && CabActive == 0 && EngineType == TEngineType::ElectricSeriesMotor)
+ if (NPoweredAxles > 0 && CabActive == 0 && EngineType == TEngineType::ElectricSeriesMotor && SetFlag(DamageFlag, -dtrain_engine))
{
- if (SetFlag(DamageFlag, -dtrain_engine))
- {
- NPoweredAxles = NPoweredAxles / 2; // bylo div czyli mod?
- COE = true;
- }
+ NPoweredAxles = NPoweredAxles / 2; // bylo div czyli mod?
+ COE = true;
}
return COE;
}
@@ -6852,10 +6760,9 @@ bool TMoverParameters::ResistorsFlagCheck(void) const
RFC = ResistorsFlag;
else // pobor pradu jezeli niema mocy
{
- for (int b = 0; b < 2; b++)
- if (TestFlag(Couplers[b].CouplingFlag, coupling::control))
- if (Couplers[b].Connected->Power > 0.01)
- RFC = Couplers[b].Connected->ResistorsFlagCheck();
+ for (auto &thiscoupler : Couplers)
+ if (TestFlag(thiscoupler.CouplingFlag, coupling::control) && thiscoupler.Connected->Power > 0.01)
+ RFC = thiscoupler.Connected->ResistorsFlagCheck();
}
return RFC;
}
@@ -6887,7 +6794,6 @@ bool TMoverParameters::AutoRelaySwitch(bool State)
bool TMoverParameters::AutoRelayCheck(void)
{
bool OK = false; // b:int;
- bool ARC = false;
auto const motorconnectorsoff{false == MotorConnectorsCheck()};
@@ -6944,16 +6850,13 @@ bool TMoverParameters::AutoRelayCheck(void)
}
else
{ // zmieniaj mainctrlactualpos
- if (DirActive < 0 && TrainType != dt_PseudoDiesel)
+ if (DirActive < 0 && TrainType != dt_PseudoDiesel && RList[MainCtrlActualPos + 1].Bn > BackwardsBranchesAllowed)
{
- if (RList[MainCtrlActualPos + 1].Bn > BackwardsBranchesAllowed)
- {
- return false; // nie poprawiamy przy konwersji
- // return ARC;// bbylo exit; //Ra: to powoduje, że EN57 nie wyłącza się przy IminLo
- }
+ return false; // nie poprawiamy przy konwersji
+ // return ARC;// bbylo exit; //Ra: to powoduje, że EN57 nie wyłącza się przy IminLo
}
// main bez samoczynnego rozruchu
- if (MainCtrlActualPos < sizeof(RList) / sizeof(TScheme) - 1 // crude guard against running out of current fixed table
+ if (MainCtrlActualPos < std::size(RList) - 1 // crude guard against running out of current fixed table
&& (RList[MainCtrlActualPos].Relay < MainCtrlPos || (RList[MainCtrlActualPos + 1].Relay == MainCtrlPos && MainCtrlActualPos < RlistSize) ||
(TrainType == dt_ET22 && DelayCtrlFlag)))
{
@@ -7048,12 +6951,12 @@ bool TMoverParameters::AutoRelayCheck(void)
--MainCtrlActualPos;
OK = true;
}
- if (MainCtrlActualPos > 0) // hunter-111211: poprawki
- if (RList[MainCtrlActualPos].R == 0)
- {
- // dzwieki schodzenia z bezoporowej}
- SetFlag(SoundFlag, sound::parallel);
- }
+ // hunter-111211: poprawki
+ if (MainCtrlActualPos > 0 && RList[MainCtrlActualPos].R == 0)
+ {
+ // dzwieki schodzenia z bezoporowej}
+ SetFlag(SoundFlag, sound::parallel);
+ }
}
}
else if (RList[MainCtrlActualPos].R > 0 && ScndCtrlActualPos > 0)
@@ -7205,40 +7108,41 @@ bool TMoverParameters::OperatePantographsValve(operation_t const State, range_t
switch (State)
{
- case operation_t::none:
+ using enum operation_t;
+ case none:
{
valve.is_enabled = false;
valve.is_disabled = false;
break;
}
- case operation_t::enable:
+ case enable:
{
valve.is_enabled = true;
valve.is_disabled = false;
break;
}
- case operation_t::disable:
+ case disable:
{
valve.is_enabled = false;
valve.is_disabled = true;
break;
}
- case operation_t::enable_on:
+ case enable_on:
{
valve.is_enabled = true;
break;
}
- case operation_t::enable_off:
+ case enable_off:
{
valve.is_enabled = false;
break;
}
- case operation_t::disable_on:
+ case disable_on:
{
valve.is_disabled = true;
break;
}
- case operation_t::disable_off:
+ case disable_off:
{
valve.is_disabled = false;
break;
@@ -7264,40 +7168,41 @@ bool TMoverParameters::OperatePantographValve(end const End, operation_t const S
switch (State)
{
- case operation_t::none:
+ using enum operation_t;
+ case none:
{
valve.is_enabled = false;
valve.is_disabled = false;
break;
}
- case operation_t::enable:
+ case enable:
{
valve.is_enabled = true;
valve.is_disabled = false;
break;
}
- case operation_t::disable:
+ case disable:
{
valve.is_enabled = false;
valve.is_disabled = true;
break;
}
- case operation_t::enable_on:
+ case enable_on:
{
valve.is_enabled = true;
break;
}
- case operation_t::enable_off:
+ case enable_off:
{
valve.is_enabled = false;
break;
}
- case operation_t::disable_on:
+ case disable_on:
{
valve.is_disabled = true;
break;
}
- case operation_t::disable_off:
+ case disable_off:
{
valve.is_disabled = false;
break;
@@ -7390,6 +7295,8 @@ void TMoverParameters::CheckEIMIC(double dt)
case 7: // TMax
eimic += std::clamp(1.0 - eimic, 0.0, dt * 0.14); // dodawaj do 1, max
break;
+ default:
+ break;
}
if (MainCtrlPos >= 3 && eimic < 0)
eimic = 0;
@@ -7419,6 +7326,8 @@ void TMoverParameters::CheckEIMIC(double dt)
if (eimic < 0)
eimic = 0;
break;
+ default:
+ break;
}
}
if (MainCtrlActualPos == MainCtrlPos)
@@ -7537,11 +7446,8 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
{
SpeedCtrlUnit.Standby = false;
}
- if (!SpeedCtrlUnit.BrakeIntervention)
- {
- if (Hamulec->GetEDBCP() > 0.4 || PipePress < HighPipePress - 0.2)
- SpeedCtrlUnit.Standby = true;
- }
+ if (!SpeedCtrlUnit.BrakeIntervention && (Hamulec->GetEDBCP() > 0.4 || PipePress < HighPipePress - 0.2))
+ SpeedCtrlUnit.Standby = true;
if (EIMCtrlType >= 3 && UniCtrlList[MainCtrlPos].SpeedUp <= 0)
{
accfactor = 0.0;
@@ -7554,11 +7460,8 @@ void TMoverParameters::CheckSpeedCtrl(double dt)
{
if (!SpeedCtrlUnit.Standby)
{
- if (SpeedCtrlUnit.ManualStateOverride)
- {
- if (eimic > 0.0009)
- eimic = 1.0;
- }
+ if (SpeedCtrlUnit.ManualStateOverride && eimic > 0.0009)
+ eimic = 1.0;
double error = std::max(SpeedCtrlValue + SpeedCtrlUnit.Offset, 0.0) - Vel;
double factorP = error > 0 ? SpeedCtrlUnit.FactorPpos : SpeedCtrlUnit.FactorPneg;
double eSCP = std::clamp(factorP * error, -1.2, 1.0); // P module
@@ -7965,7 +7868,7 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt)
else
dizel_nreg_min = dizel_nmin;
}
- if (dizel_vel2nmax_Table.size() > 0 && !hydro_TC_Lockup)
+ if (!dizel_vel2nmax_Table.empty() && !hydro_TC_Lockup)
{
dizel_nreg_max = std::min(std::min(dizel_nreg_max, enrot) + dizel_nreg_acc * dt, TableInterpolation(dizel_vel2nmax_Table, Vel));
}
@@ -8034,30 +7937,36 @@ double TMoverParameters::dizel_fillcheck(int mcp, double dt)
// Q: 20160715
// Oblicza moment siły wytwarzany przez silnik spalinowy
// *************************************************************************************************
-double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
+double TMoverParameters::dizel_Momentum(double Fill, double n, double dt)
{ // liczy moment sily wytwarzany przez silnik spalinowy}
- double Moment = 0, enMoment = 0, gearMoment = 0, eps = 0, newn = 0, friction = 0, neps = 0;
- double TorqueH = 0, TorqueL = 0, TorqueC = 0;
+ double Moment = 0;
+ double enMoment = 0;
+ double gearMoment = 0;
+ double eps = 0;
+ double newn = 0;
+ double friction = 0;
+ double TorqueH = 0;
+ double TorqueL = 0;
+ double TorqueC = 0;
n = n * CabActive;
if (motor_param(ScndCtrlActualPos).mIsat < 0.001 || DirActive == 0)
n = enrot;
friction = dizel_engagefriction;
hydro_TC_nIn = enrot; // wal wejsciowy przetwornika momentu
hydro_TC_nOut = dizel_n_old; // wal wyjsciowy przetwornika momentu
- neps = (n - dizel_n_old) / dt; // przyspieszenie katowe walu wejsciowego skrzyni biegow
if (enrot > 0)
{
if (dizel_Momentum_Table.size() > 1)
{
- Moment = TableInterpolation(dizel_Momentum_Table, enrot) * dizel_fill - dizel_Mstand;
+ Moment = TableInterpolation(dizel_Momentum_Table, enrot) * Fill - dizel_Mstand;
}
else
{
- Moment = (dizel_Mmax - (dizel_Mmax - dizel_Mnmax) * square((enrot - dizel_nMmax) / (dizel_nMmax - dizel_nmax))) * dizel_fill - dizel_Mstand;
+ Moment = (dizel_Mmax - (dizel_Mmax - dizel_Mnmax) * square((enrot - dizel_nMmax) / (dizel_nMmax - dizel_nmax))) * Fill - dizel_Mstand;
}
Mm = Moment;
- dizel_FuelConsumptionActual = dizel_FuelConsumption * enrot * dizel_fill;
+ dizel_FuelConsumptionActual = dizel_FuelConsumption * enrot * Fill;
dizel_FuelConsumptedTotal += dizel_FuelConsumptionActual * dt / 3600.0;
if (hydro_R && hydro_R_Placement == 2)
Moment -= dizel_MomentumRetarder(enrot, dt);
@@ -8188,7 +8097,6 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
{
dizel_engagedeltaomega = 0;
gearMoment = Moment;
- enMoment = 0;
double enrot_min = enrot - (std::min(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) - Moment) / dizel_AIM * dt;
double enrot_max = enrot + (std::min(TorqueC, TorqueL + abs(hydro_TC_TorqueIn)) + Moment) / dizel_AIM * dt;
enrot = safe_clamp(n, enrot_min, enrot_max);
@@ -8244,8 +8152,7 @@ double TMoverParameters::dizel_MomentumRetarder(double n, double dt)
}
double Moment = hydro_R_MaxTorque;
- double pwr = Moment * std::abs(n) * M_PI * 2 * 0.001;
- if (pwr > hydro_R_MaxPower)
+ if (double pwr = Moment * std::abs(n) * M_PI * 2 * 0.001; pwr > hydro_R_MaxPower)
Moment = Moment * hydro_R_MaxPower / pwr;
double moment_in = n * n * hydro_R_TorqueInIn;
Moment = std::min(moment_in, Moment * hydro_R_Fill);
@@ -8259,8 +8166,16 @@ double TMoverParameters::dizel_MomentumRetarder(double n, double dt)
void TMoverParameters::dizel_HeatSet(float const Value)
{
- dizel_heat.Te = // TODO: don't include ambient temperature, pull it from environment data instead
- dizel_heat.Ts = dizel_heat.To = dizel_heat.Tsr = dizel_heat.Twy = dizel_heat.Tsr2 = dizel_heat.Twy2 = dizel_heat.temperatura1 = dizel_heat.temperatura2 = Value;
+ // TODO: don't include ambient temperature, pull it from environment data instead
+ dizel_heat.Te = Value;
+ dizel_heat.Ts = Value;
+ dizel_heat.To = Value;
+ dizel_heat.Tsr = Value;
+ dizel_heat.Twy = Value;
+ dizel_heat.Tsr2 = Value;
+ dizel_heat.Twy2 = Value;
+ dizel_heat.temperatura1 = Value;
+ dizel_heat.temperatura2 = Value;
}
// calculates diesel engine temperature and heat transfers
@@ -8314,13 +8229,13 @@ void TMoverParameters::dizel_Heat(double const dt)
// silnik oddaje czesc ciepla do wody chlodzacej, a takze pewna niewielka czesc do otoczenia, modyfikowane przez okienko
auto const Qs{(Qd - dizel_heat.kfs * (dizel_heat.Ts - dizel_heat.Tsr) - dizel_heat.kfe * /* ( 0.3 + 0.7 * ( dizel_heat.okienko ? 1 : 0 ) ) * */ (dizel_heat.Ts - dizel_heat.Te))};
auto const dTss{Qs / Cs};
- dizel_heat.Ts += dTss * dt;
+ dizel_heat.Ts += static_cast(dTss * dt);
// oil heat transfers
// olej oddaje cieplo do wody gdy krazy przez wymiennik ciepla == wlaczona pompka lub silnik
auto const dTo{(dizel_heat.auxiliary_water_circuit ? (dizel_heat.kfo * (dizel_heat.Ts - dizel_heat.To) - dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr2)) / (gwO * Co) :
(dizel_heat.kfo * (dizel_heat.Ts - dizel_heat.To) - dizel_heat.kfo2 * (dizel_heat.To - dizel_heat.Tsr)) / (gwO * Co))};
- dizel_heat.To += dTo * dt;
+ dizel_heat.To += static_cast(dTo * dt);
// heater
/*
@@ -8339,7 +8254,7 @@ void TMoverParameters::dizel_Heat(double const dt)
(true == Mains && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */
&& dizel_heat.water_aux.config.temp_cooling > 0 && dizel_heat.temperatura2 > dizel_heat.water_aux.config.temp_cooling - (dizel_heat.water_aux.is_warm ? 8 : 0));
auto const PTC2{(dizel_heat.water_aux.is_warm /*or PTC2p*/ ? 1 : 0)};
- dizel_heat.rpmwz2 = PTC2 * (dizel_heat.fan_speed >= 0 ? rpm * dizel_heat.fan_speed : dizel_heat.fan_speed * -1);
+ dizel_heat.rpmwz2 = static_cast(PTC2 * (dizel_heat.fan_speed >= 0 ? rpm * dizel_heat.fan_speed : dizel_heat.fan_speed * -1));
dizel_heat.zaluzje2 = dizel_heat.water_aux.config.shutters ? PTC2 == 1 : true; // no shutters is an equivalent to having them open
auto const zaluzje2{(dizel_heat.zaluzje2 ? 1 : 0)};
// auxiliary water circuit heat transfer values
@@ -8351,8 +8266,8 @@ void TMoverParameters::dizel_Heat(double const dt)
// auxiliary water circuit heat transfers finalization
// NOTE: since primary circuit doesn't read data from the auxiliary one, we can pretty safely finalize auxiliary updates before touching the primary circuit
auto const Twe2{dizel_heat.Twy2 + dTch2 * dt};
- dizel_heat.Twy2 = Twe2 + dTs2 * dt;
- dizel_heat.Tsr2 = 0.5 * (dizel_heat.Twy2 + Twe2);
+ dizel_heat.Twy2 = static_cast(Twe2 + dTs2 * dt);
+ dizel_heat.Tsr2 = static_cast(0.5 * (dizel_heat.Twy2 + Twe2));
dizel_heat.temperatura2 = dizel_heat.Twy2;
}
// primary water circuit setup
@@ -8362,7 +8277,7 @@ void TMoverParameters::dizel_Heat(double const dt)
true == dizel_heat.cooling || (true == Mains && BatteryVoltage > 0.75 * NominalBatteryVoltage /* && !bezpompy && !awaria_chlodzenia && !WS10 */
&& dizel_heat.water.config.temp_cooling > 0 && dizel_heat.temperatura1 > dizel_heat.water.config.temp_cooling - (dizel_heat.water.is_warm ? 8 : 0));
auto const PTC1{(dizel_heat.water.is_warm /*or PTC1p*/ ? 1 : 0)};
- dizel_heat.rpmwz = PTC1 * (dizel_heat.fan_speed >= 0 ? rpm * dizel_heat.fan_speed : dizel_heat.fan_speed * -1);
+ dizel_heat.rpmwz = static_cast(PTC1 * (dizel_heat.fan_speed >= 0 ? rpm * dizel_heat.fan_speed : dizel_heat.fan_speed * -1));
dizel_heat.zaluzje1 = dizel_heat.water.config.shutters ? PTC1 == 1 : true; // no shutters is an equivalent to having them open
auto const zaluzje1{(dizel_heat.zaluzje1 ? 1 : 0)};
// primary water circuit heat transfer values
@@ -8373,8 +8288,8 @@ void TMoverParameters::dizel_Heat(double const dt)
auto const dTch{Qch / (gw * Cw)};
// primary water circuit heat transfers finalization
auto const Twe{dizel_heat.Twy + dTch * dt};
- dizel_heat.Twy = Twe + dTs * dt;
- dizel_heat.Tsr = 0.5 * (dizel_heat.Twy + Twe);
+ dizel_heat.Twy = static_cast(Twe + dTs * dt);
+ dizel_heat.Tsr = static_cast(0.5 * (dizel_heat.Twy + Twe));
dizel_heat.temperatura1 = dizel_heat.Twy;
/*
fuelConsumed = fuelConsumed + ( Ge * 0.5 );
@@ -8422,10 +8337,10 @@ void TMoverParameters::dizel_Heat(double const dt)
*/
}
-bool TMoverParameters::AssignLoad(std::string const &Name, float const Amount)
+bool TMoverParameters::AssignLoad(std::string const &Loadname, float const Amount)
{
- if (Name == "pantstate")
+ if (Loadname == "pantstate")
{
if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector)
{
@@ -8465,40 +8380,38 @@ bool TMoverParameters::AssignLoad(std::string const &Name, float const Amount)
}
}
- if (Name.empty())
+ if (Loadname.empty())
{
// empty the vehicle if requested
- LoadTypeChange = LoadType.name != Name;
+ LoadTypeChange = LoadType.name != Loadname;
LoadType = load_attributes();
LoadAmount = 0.f;
return true;
}
// can't mix load types, at least for the time being
- if (LoadAmount > 0 && LoadType.name != Name)
+ if (LoadAmount > 0 && LoadType.name != Loadname)
{
return false;
}
- for (auto const &loadattributes : LoadAttributes)
+ auto const loadattributes = std::ranges::find_if(LoadAttributes, [&](auto const &attributes) { return attributes.name == Loadname; });
+ if (loadattributes == std::end(LoadAttributes))
{
- if (Name == loadattributes.name)
- {
- LoadTypeChange = LoadType.name != Name;
- LoadType = loadattributes;
- LoadAmount = std::clamp(Amount, 0.f, MaxLoad);
- ComputeMass();
- return true;
- }
+ // didn't find matching load configuration, this type is unsupported
+ return false;
}
- // didn't find matching load configuration, this type is unsupported
- return false;
+ LoadTypeChange = LoadType.name != Loadname;
+ LoadType = *loadattributes;
+ LoadAmount = std::clamp(Amount, 0.f, MaxLoad);
+ ComputeMass();
+ return true;
}
// *************************************************************************************************
// Q: 20160713
// Test zakończenia załadunku / rozładunku
// *************************************************************************************************
-bool TMoverParameters::LoadingDone(double const LSpeed, std::string const &Loadname)
+bool TMoverParameters::LoadingDone(double const LSpeed, std::string_view Loadname)
{
if (LSpeed == 0.0)
@@ -8555,7 +8468,7 @@ bool TMoverParameters::LoadingDone(double const LSpeed, std::string const &Loadn
if (LoadAmount >= MaxLoad * (1.0 + OverLoadFactor) || CommandIn.Value1 <= 0)
{
LoadStatus = 4; // skończony załadunek
- LoadAmount = std::min(MaxLoad * (1.0 + OverLoadFactor), LoadAmount);
+ LoadAmount = std::min(static_cast(MaxLoad * (1.0 + OverLoadFactor)), LoadAmount);
}
ComputeMass();
}
@@ -8794,10 +8707,10 @@ void TMoverParameters::update_doors(double const Deltatime)
if (false == door.step_unfolding // no wait if no doorstep
|| Doors.step_type == 2)
{ // no wait for rotating doorstep
- door.open_delay += Deltatime;
+ door.open_delay += static_cast(Deltatime);
if (door.open_delay > Doors.open_delay)
{
- door.position = std::min(Doors.range, door.position + Doors.open_rate * Deltatime);
+ door.position = std::min(Doors.range, static_cast(door.position + Doors.open_rate * Deltatime));
}
}
door.close_delay = 0.f;
@@ -8805,10 +8718,10 @@ void TMoverParameters::update_doors(double const Deltatime)
if (true == door.is_closing)
{
// close door
- door.close_delay += Deltatime;
+ door.close_delay += static_cast(Deltatime);
if (door.close_delay > Doors.close_delay)
{
- door.position = std::max(0.f, door.position - Doors.close_rate * Deltatime);
+ door.position = std::max(0.f, static_cast(door.position - Doors.close_rate * Deltatime));
}
door.open_delay = 0.f;
}
@@ -8816,7 +8729,7 @@ void TMoverParameters::update_doors(double const Deltatime)
if (door.step_unfolding)
{
// unfold left doorstep
- door.step_position = std::min(1.f, door.step_position + Doors.step_rate * Deltatime);
+ door.step_position = std::min(1.f, static_cast(door.step_position + Doors.step_rate * Deltatime));
}
if (door.step_folding)
{
@@ -8826,12 +8739,12 @@ void TMoverParameters::update_doors(double const Deltatime)
// multi-unit vehicles typically fold the doorstep only after closing the door
if (door.position <= 0.f)
{
- door.step_position = std::max(0.f, door.step_position - Doors.step_rate * Deltatime);
+ door.step_position = std::max(0.f, static_cast(door.step_position - Doors.step_rate * Deltatime));
}
}
else
{
- door.step_position = std::max(0.f, door.step_position - Doors.step_rate * Deltatime);
+ door.step_position = std::max(0.f, static_cast(door.step_position - Doors.step_rate * Deltatime));
}
}
}
@@ -8854,7 +8767,7 @@ void TMoverParameters::update_doors(double const Deltatime)
if (door.auto_timer > 0.f)
{
- door.auto_timer -= Deltatime;
+ door.auto_timer -= static_cast(Deltatime);
}
// if there's load exchange in progress, reset the timer(s) for already open doors
if (door.auto_timer != -1.f && (LoadStatus & (2 | 1)) != 0)
@@ -8908,9 +8821,7 @@ bool TMoverParameters::ChangeOffsetH(double DeltaOffset)
std::string TMoverParameters::EngineDescription(int what) const
{
std::string outstr{"OK"};
- switch (what)
- {
- case 0:
+ if (what == 0)
{
if (DamageFlag == 255)
{
@@ -8960,13 +8871,10 @@ std::string TMoverParameters::EngineDescription(int what) const
outstr = "DERAILED";
}
}
- break;
}
- default:
+ else
{
outstr = "Invalid qualifier";
- break;
- }
}
return outstr;
}
@@ -8978,22 +8886,21 @@ std::string TMoverParameters::EngineDescription(int what) const
double TMoverParameters::GetTrainsetVoltage(int const Coupling) const
{ // ABu: funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT
// TBD, TODO: call once per vehicle update, return cached results?
- double voltages[] = {0.0, 0.0};
+ std::array voltages{0.0, 0.0};
for (int end = end::front; end <= end::rear; ++end)
{
if (Couplers[end].Connected == nullptr)
{
continue;
}
- auto const &coupler{Couplers[end]};
- auto const fullcoupling{coupler.CouplingFlag | (TestFlag(coupler.CouplingFlag, coupler.PowerCoupling) ? coupler.PowerFlag : 0)};
- if ((fullcoupling & Coupling) == 0)
+ auto const &thiscoupler{Couplers[end]};
+ if (auto const fullcoupling{thiscoupler.CouplingFlag | (TestFlag(thiscoupler.CouplingFlag, thiscoupler.PowerCoupling) ? thiscoupler.PowerFlag : 0)}; (fullcoupling & Coupling) == 0)
{
continue;
}
- auto *connectedpowercoupling = (Coupling & (coupling::highvoltage | coupling::heating)) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_high :
- (Coupling & coupling::power110v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_110v :
- (Coupling & coupling::power24v) != 0 ? &coupler.Connected->Couplers[coupler.ConnectedNr].power_24v :
+ auto const *connectedpowercoupling = (Coupling & (coupling::highvoltage | coupling::heating)) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_high :
+ (Coupling & coupling::power110v) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_110v :
+ (Coupling & coupling::power24v) != 0 ? &thiscoupler.Connected->Couplers[thiscoupler.ConnectedNr].power_24v :
nullptr;
if (connectedpowercoupling != nullptr && connectedpowercoupling->is_live)
{
@@ -9032,15 +8939,25 @@ bool TMoverParameters::switch_physics(bool const State) // DO PRZETLUMACZENIA NA
// FUNKCJE PARSERA WCZYTYWANIA PLIKU FIZYKI POJAZDU
// *************************************************************************************************
bool startBPT;
-bool startMPT, startMPT0;
-bool startRLIST, startUCLIST;
-bool startDIZELMOMENTUMLIST, startDIZELV2NMAXLIST, startHYDROTCLIST, startPMAXLIST;
-bool startDLIST, startFFLIST, startWWLIST, startWiperList, startDimmerList, startFFEDLIST;
+bool startMPT;
+bool startMPT0;
+bool startRLIST;
+bool startUCLIST;
+bool startDIZELMOMENTUMLIST;
+bool startDIZELV2NMAXLIST;
+bool startHYDROTCLIST;
+bool startPMAXLIST;
+bool startDLIST;
+bool startFFLIST;
+bool startWWLIST;
+bool startWiperList;
+bool startDimmerList;
+bool startFFEDLIST;
bool startLIGHTSLIST;
bool startCOMPRESSORLIST;
int LISTLINE;
-bool issection(std::string const &Name, std::string const &Input)
+bool issection(std::string_view Name, std::string_view Input)
{
return Input.compare(0, Name.size(), Name) == 0;
@@ -9050,10 +8967,10 @@ int s2NPW(std::string s)
{ // wylicza ilosc osi napednych z opisu ukladu osi
const char A = 64;
int NPW = 0;
- for (std::size_t k = 0; k < s.size(); ++k)
+ for (char const chentry : s)
{
- if (s[k] >= (char)65 && s[k] <= (char)90)
- NPW += s[k] - A;
+ if (chentry >= (char)65 && chentry <= (char)90)
+ NPW += chentry - A;
}
return NPW;
}
@@ -9062,10 +8979,10 @@ int s2NNW(std::string s)
{ // wylicza ilosc osi nienapedzanych z opisu ukladu osi
const char Zero = 48;
int NNW = 0;
- for (std::size_t k = 0; k < s.size(); ++k)
+ for (char const ch : s)
{
- if (s[k] >= (char)49 && s[k] <= (char)57)
- NNW += s[k] - Zero;
+ if (ch >= (char)49 && ch <= (char)57)
+ NNW += ch - Zero;
}
return NNW;
}
@@ -9101,18 +9018,13 @@ bool TMoverParameters::readMPT0(std::string const &line)
{
return false;
}
- switch (EngineType)
- {
- case TEngineType::DieselEngine:
+ if (EngineType == TEngineType::DieselEngine)
{
parser >> MotorParam[idx].mIsat >> MotorParam[idx].fi0 >> MotorParam[idx].fi >> MotorParam[idx].mfi0 >> MotorParam[idx].mfi >> MotorParam[idx].Isat;
- break;
}
- default:
+ else
{
parser >> MotorParam[idx].mfi >> MotorParam[idx].mIsat >> MotorParam[idx].mfi0 >> MotorParam[idx].fi >> MotorParam[idx].Isat >> MotorParam[idx].fi0;
- break;
- }
}
if (true == parser.getTokens(1, false))
{
@@ -9274,7 +9186,7 @@ bool TMoverParameters::readRList(std::string const &Input)
return false;
}
auto idx = LISTLINE++;
- if (idx >= sizeof(RList) / sizeof(TScheme))
+ if (idx >= std::size(RList))
{
WriteLog("Read RList: number of entries exceeded capacity of the data table");
return false;
@@ -9299,7 +9211,7 @@ bool TMoverParameters::readUCList(std::string const &line)
cParser parser(line);
parser.getTokens(10, false);
auto idx = LISTLINE++;
- if (idx >= sizeof(UniCtrlList) / sizeof(TUniversalCtrl))
+ if (idx >= std::size(UniCtrlList))
{
WriteLog("Read UCList: number of entries exceeded capacity of the data table");
return false;
@@ -9317,7 +9229,7 @@ bool TMoverParameters::readDList(std::string const &line)
cParser parser(line);
parser.getTokens(3, false);
auto idx = LISTLINE++;
- if (idx >= sizeof(RList) / sizeof(TScheme))
+ if (idx >= std::size(RList))
{
WriteLog("Read DList: number of entries exceeded capacity of the data table");
return false;
@@ -9337,7 +9249,7 @@ bool TMoverParameters::readDMList(std::string const &line)
WriteLog("Read DMList: arguments missing in line " + std::to_string(LISTLINE + 1));
return false;
}
- auto idx = LISTLINE++;
+ ++LISTLINE;
double x = 0.0;
double y = 0.0;
parser >> x >> y;
@@ -9357,7 +9269,7 @@ bool TMoverParameters::readV2NMAXList(std::string const &line)
WriteLog("Read V2nmaxList: arguments missing in line " + std::to_string(LISTLINE + 1));
return false;
}
- auto idx = LISTLINE++;
+ ++LISTLINE;
double x = 0.0;
double y = 0.0;
parser >> x >> y;
@@ -9377,7 +9289,7 @@ bool TMoverParameters::readHTCList(std::string const &line)
WriteLog("Read HTCList: arguments missing in line " + std::to_string(LISTLINE + 1));
return false;
}
- auto idx = LISTLINE++;
+ ++LISTLINE;
double x = 0.0;
double y = 0.0;
parser >> x >> y;
@@ -9397,7 +9309,7 @@ bool TMoverParameters::readPmaxList(std::string const &line)
WriteLog("Read PmaxList: arguments missing in line " + std::to_string(LISTLINE + 1));
return false;
}
- auto idx = LISTLINE++;
+ ++LISTLINE;
double x = 0.0;
double y = 0.0;
parser >> x >> y;
@@ -9417,7 +9329,7 @@ bool TMoverParameters::readFFList(std::string const &line)
return false;
}
int idx = LISTLINE++;
- if (idx >= sizeof(FFlist) / sizeof(TFFScheme))
+ if (idx >= std::size(FFlist))
{
WriteLog("Read FList: number of entries exceeded capacity of the data table");
return false;
@@ -9437,7 +9349,7 @@ bool TMoverParameters::readFFEDList(std::string const &line)
return false;
}
int idx = LISTLINE++;
- if (idx >= sizeof(FFEDlist) / sizeof(TFFScheme))
+ if (idx >= std::size(FFEDlist))
{
WriteLog("Read FList: number of entries exceeded capacity of the data table");
return false;
@@ -9457,7 +9369,7 @@ bool TMoverParameters::readWiperList(std::string const &line)
return false;
}
int idx = LISTLINE++;
- if (idx >= sizeof(WiperList) / sizeof(TWiperScheme))
+ if (idx >= std::size(WiperList))
{
WriteLog("Read WiperList: number of entries exceeded capacity of the data table");
return false;
@@ -9474,7 +9386,7 @@ bool TMoverParameters::readDimmerList(std::string const &line)
WriteLog("Read DimmerList: arguments missing in line " + std::to_string(LISTLINE + 1));
return false;
}
- int idx = LISTLINE++;
+ ++LISTLINE;
dimPosition dps;
parser >> dps.isHighBeam >> dps.isDimmed >> dps.isOff;
@@ -9493,7 +9405,7 @@ bool TMoverParameters::readWWList(std::string const &line)
return false;
}
int idx = LISTLINE++;
- if (idx >= sizeof(DElist) / sizeof(TDEScheme))
+ if (idx >= std::size(DElist))
{
WriteLog("Read WWList: number of entries exceeded capacity of the data table");
return false;
@@ -9557,42 +9469,43 @@ bool TMoverParameters::readCompressorList(std::string const &Input)
// *************************************************************************************************
void TMoverParameters::BrakeValveDecode(std::string const &Valve)
{
+ using enum TBrakeValve;
- std::map valvetypes{{"W", TBrakeValve::W},
- {"W_Lu_L", TBrakeValve::W_Lu_L},
- {"W_Lu_XR", TBrakeValve::W_Lu_XR},
- {"W_Lu_VI", TBrakeValve::W_Lu_VI},
- {"K", TBrakeValve::K},
- {"Kg", TBrakeValve::Kg},
- {"Kp", TBrakeValve::Kp},
- {"Kss", TBrakeValve::Kss},
- {"Kkg", TBrakeValve::Kkg},
- {"Kkp", TBrakeValve::Kkp},
- {"Kks", TBrakeValve::Kks},
- {"Hikp1", TBrakeValve::Hikp1},
- {"Hikss", TBrakeValve::Hikss},
- {"Hikg1", TBrakeValve::Hikg1},
- {"KE", TBrakeValve::KE},
- {"SW", TBrakeValve::SW},
- {"EStED", TBrakeValve::EStED},
- {"NESt3", TBrakeValve::NESt3},
- {"ESt3", TBrakeValve::ESt3},
- {"LSt", TBrakeValve::LSt},
- {"ESt4", TBrakeValve::ESt4},
- {"ESt3AL2", TBrakeValve::ESt3AL2},
- {"EP1", TBrakeValve::EP1},
- {"EP2", TBrakeValve::EP2},
- {"M483", TBrakeValve::M483},
- {"CV1_L_TR", TBrakeValve::CV1_L_TR},
- {"CV1", TBrakeValve::CV1},
- {"CV1_R", TBrakeValve::CV1_R}};
+ std::map> valvetypes{{"W", W},
+ {"W_Lu_L", W_Lu_L},
+ {"W_Lu_XR", W_Lu_XR},
+ {"W_Lu_VI", W_Lu_VI},
+ {"K", K},
+ {"Kg", Kg},
+ {"Kp", Kp},
+ {"Kss", Kss},
+ {"Kkg", Kkg},
+ {"Kkp", Kkp},
+ {"Kks", Kks},
+ {"Hikp1", Hikp1},
+ {"Hikss", Hikss},
+ {"Hikg1", Hikg1},
+ {"KE", KE},
+ {"SW", SW},
+ {"EStED", EStED},
+ {"NESt3", NESt3},
+ {"ESt3", ESt3},
+ {"LSt", LSt},
+ {"ESt4", ESt4},
+ {"ESt3AL2", ESt3AL2},
+ {"EP1", EP1},
+ {"EP2", EP2},
+ {"M483", M483},
+ {"CV1_L_TR", CV1_L_TR},
+ {"CV1", CV1},
+ {"CV1_R", CV1_R}};
auto lookup = valvetypes.find(Valve);
- BrakeValve = lookup != valvetypes.end() ? lookup->second : TBrakeValve::Other;
+ BrakeValve = lookup != valvetypes.end() ? lookup->second : Other;
- if (BrakeValve == TBrakeValve::Other && contains(Valve, "ESt"))
+ if (BrakeValve == Other && contains(Valve, "ESt"))
{
- BrakeValve = TBrakeValve::ESt3;
+ BrakeValve = ESt3;
}
}
@@ -9601,32 +9514,36 @@ void TMoverParameters::BrakeValveDecode(std::string const &Valve)
// *************************************************************************************************
void TMoverParameters::BrakeSubsystemDecode()
{
- BrakeSubsystem = TBrakeSubSystem::ss_None;
+ using enum TBrakeSubSystem;
+ BrakeSubsystem = ss_None;
switch (BrakeValve)
{
- case TBrakeValve::W:
- case TBrakeValve::W_Lu_L:
- case TBrakeValve::W_Lu_VI:
- case TBrakeValve::W_Lu_XR:
- BrakeSubsystem = TBrakeSubSystem::ss_W;
+ using enum TBrakeValve;
+ case W:
+ case W_Lu_L:
+ case W_Lu_VI:
+ case W_Lu_XR:
+ BrakeSubsystem = ss_W;
break;
- case TBrakeValve::ESt3:
- case TBrakeValve::ESt3AL2:
- case TBrakeValve::ESt4:
- case TBrakeValve::EP2:
- case TBrakeValve::EP1:
- BrakeSubsystem = TBrakeSubSystem::ss_ESt;
+ case ESt3:
+ case ESt3AL2:
+ case ESt4:
+ case EP2:
+ case EP1:
+ BrakeSubsystem = ss_ESt;
break;
- case TBrakeValve::KE:
- BrakeSubsystem = TBrakeSubSystem::ss_KE;
+ case KE:
+ BrakeSubsystem = ss_KE;
break;
- case TBrakeValve::CV1:
- case TBrakeValve::CV1_L_TR:
- BrakeSubsystem = TBrakeSubSystem::ss_Dako;
+ case CV1:
+ case CV1_L_TR:
+ BrakeSubsystem = ss_Dako;
break;
- case TBrakeValve::LSt:
- case TBrakeValve::EStED:
- BrakeSubsystem = TBrakeSubSystem::ss_LSt;
+ case LSt:
+ case EStED:
+ BrakeSubsystem = ss_LSt;
+ break;
+ default:
break;
}
}
@@ -9637,12 +9554,9 @@ void TMoverParameters::BrakeSubsystemDecode()
// TDynamicObject::Init()
// Po niej wykonywana jest CreateBrakeSys(), ktora jest odpowiednikiem CheckLocomotiveParameters()
// *************************************************************************************************
-bool TMoverParameters::LoadFIZ(std::string chkpath)
+bool TMoverParameters::LoadFIZ(std::string const &chkpath)
{
chkPath = chkpath; // assign class path for reloading
- const int param_ok = 1;
- const int wheels_ok = 2;
- const int dimensions_ok = 4;
ConversionError = 666;
LISTLINE = 0;
@@ -9810,7 +9724,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Param.", inputline))
{
startBPT = false;
- fizlines.emplace("Param", inputline);
+ fizlines.try_emplace("Param", inputline);
LoadFIZ_Param(inputline);
continue;
}
@@ -9818,7 +9732,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Load:", inputline))
{
startBPT = false;
- fizlines.emplace("Load", inputline);
+ fizlines.try_emplace("Load", inputline);
LoadFIZ_Load(inputline);
continue;
}
@@ -9826,7 +9740,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Dimensions:", inputline))
{
startBPT = false;
- fizlines.emplace("Dimensions", inputline);
+ fizlines.try_emplace("Dimensions", inputline);
LoadFIZ_Dimensions(inputline);
continue;
}
@@ -9834,7 +9748,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Wheels:", inputline))
{
startBPT = false;
- fizlines.emplace("Wheels", inputline);
+ fizlines.try_emplace("Wheels", inputline);
LoadFIZ_Wheels(inputline);
continue;
}
@@ -9842,7 +9756,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Brake:", inputline))
{
startBPT = false;
- fizlines.emplace("Brake", inputline);
+ fizlines.try_emplace("Brake", inputline);
LoadFIZ_Brake(inputline);
continue;
}
@@ -9851,7 +9765,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
{
startBPT = false;
- fizlines.emplace("Doors", inputline);
+ fizlines.try_emplace("Doors", inputline);
LoadFIZ_Doors(inputline);
continue;
}
@@ -9860,7 +9774,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
{
startBPT = false;
- fizlines.emplace("BuffCoupl", inputline);
+ fizlines.try_emplace("BuffCoupl", inputline);
LoadFIZ_BuffCoupl(inputline, 0);
continue;
}
@@ -9869,7 +9783,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
{
startBPT = false;
- fizlines.emplace("BuffCoupl1", inputline);
+ fizlines.try_emplace("BuffCoupl1", inputline);
LoadFIZ_BuffCoupl(inputline, 1);
continue;
}
@@ -9878,7 +9792,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
{
startBPT = false;
- fizlines.emplace("BuffCoupl2", inputline);
+ fizlines.try_emplace("BuffCoupl2", inputline);
LoadFIZ_BuffCoupl(inputline, 2);
continue;
}
@@ -9887,7 +9801,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
{
startBPT = false;
- fizlines.emplace("TurboPos", inputline);
+ fizlines.try_emplace("TurboPos", inputline);
LoadFIZ_TurboPos(inputline);
continue;
}
@@ -9897,7 +9811,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
startBPT = true;
LISTLINE = 0;
- fizlines.emplace("Cntrl", inputline);
+ fizlines.try_emplace("Cntrl", inputline);
LoadFIZ_Cntrl(inputline);
continue;
}
@@ -9905,7 +9819,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Headlights:", inputline))
{
startBPT = false;
- fizlines.emplace("Headlights", inputline);
+ fizlines.try_emplace("Headlights", inputline);
LoadFIZ_Headlights(inputline);
continue;
}
@@ -9915,7 +9829,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
startBPT = false;
LISTLINE = 0;
- fizlines.emplace("Blending", inputline);
+ fizlines.try_emplace("Blending", inputline);
LoadFIZ_Blending(inputline);
continue;
}
@@ -9925,7 +9839,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
startBPT = false;
LISTLINE = 0;
- fizlines.emplace("DCEMUED", inputline);
+ fizlines.try_emplace("DCEMUED", inputline);
LoadFIZ_DCEMUED(inputline);
continue;
}
@@ -9935,7 +9849,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
startBPT = false;
LISTLINE = 0;
- fizlines.emplace("SpringBrake", inputline);
+ fizlines.try_emplace("SpringBrake", inputline);
LoadFIZ_SpringBrake(inputline);
continue;
}
@@ -9944,7 +9858,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
{
startBPT = false;
- fizlines.emplace("Light", inputline);
+ fizlines.try_emplace("Light", inputline);
LoadFIZ_Light(inputline);
continue;
}
@@ -9952,7 +9866,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Security:", inputline))
{
startBPT = false;
- fizlines.emplace("Security", inputline);
+ fizlines.try_emplace("Security", inputline);
SecuritySystem.load(inputline, Vmax);
extract_value(EmergencyBrakeWarningSignal, "EmergencyBrakeWarningSignal", inputline, "");
continue;
@@ -9962,7 +9876,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
{
startBPT = false;
- fizlines.emplace("Clima", inputline);
+ fizlines.try_emplace("Clima", inputline);
LoadFIZ_Clima(inputline);
continue;
}
@@ -9970,7 +9884,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Power:", inputline))
{
startBPT = false;
- fizlines.emplace("Power", inputline);
+ fizlines.try_emplace("Power", inputline);
LoadFIZ_Power(inputline);
continue;
}
@@ -9978,7 +9892,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("SpeedControl:", inputline))
{
startBPT = false;
- fizlines.emplace("SpeedControl", inputline);
+ fizlines.try_emplace("SpeedControl", inputline);
LoadFIZ_SpeedControl(inputline);
continue;
}
@@ -9986,7 +9900,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Engine:", inputline))
{
startBPT = false;
- fizlines.emplace("Engine", inputline);
+ fizlines.try_emplace("Engine", inputline);
LoadFIZ_Engine(inputline);
continue;
}
@@ -9994,7 +9908,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Switches:", inputline))
{
startBPT = false;
- fizlines.emplace("Switches", inputline);
+ fizlines.try_emplace("Switches", inputline);
LoadFIZ_Switches(inputline);
continue;
}
@@ -10004,7 +9918,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
startBPT = false;
startMPT = true;
LISTLINE = 0;
- fizlines.emplace("MotorParamTable", inputline);
+ fizlines.try_emplace("MotorParamTable", inputline);
LoadFIZ_MotorParamTable(inputline);
continue;
}
@@ -10020,7 +9934,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Circuit:", inputline))
{
startBPT = false;
- fizlines.emplace("Circuit", inputline);
+ fizlines.try_emplace("Circuit", inputline);
LoadFIZ_Circuit(inputline);
continue;
}
@@ -10028,7 +9942,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("AI:", inputline))
{
startBPT = false;
- fizlines.emplace("AI", inputline);
+ fizlines.try_emplace("AI", inputline);
LoadFIZ_AI(inputline);
continue;
}
@@ -10036,7 +9950,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("RList:", inputline))
{
startBPT = false;
- fizlines.emplace("RList", inputline);
+ fizlines.try_emplace("RList", inputline);
startRLIST = true;
LISTLINE = 0;
LoadFIZ_RList(inputline);
@@ -10046,7 +9960,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("UCList:", inputline))
{
startBPT = false;
- fizlines.emplace("UCList", inputline);
+ fizlines.try_emplace("UCList", inputline);
startUCLIST = true;
LISTLINE = 0;
LoadFIZ_UCList(inputline);
@@ -10056,7 +9970,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("DList:", inputline))
{
startBPT = false;
- fizlines.emplace("DList", inputline);
+ fizlines.try_emplace("DList", inputline);
startDLIST = true;
LISTLINE = 0;
LoadFIZ_DList(inputline);
@@ -10066,7 +9980,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("DMList:", inputline))
{
startBPT = false;
- fizlines.emplace("DMList", inputline);
+ fizlines.try_emplace("DMList", inputline);
startDIZELMOMENTUMLIST = true;
LISTLINE = 0;
continue;
@@ -10075,7 +9989,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("HTCList:", inputline))
{
startBPT = false;
- fizlines.emplace("HTCList", inputline);
+ fizlines.try_emplace("HTCList", inputline);
startHYDROTCLIST = true;
LISTLINE = 0;
continue;
@@ -10084,7 +9998,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("PmaxList:", inputline))
{
startBPT = false;
- fizlines.emplace("PmaxList", inputline);
+ fizlines.try_emplace("PmaxList", inputline);
startPMAXLIST = true;
LISTLINE = 0;
continue;
@@ -10093,7 +10007,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("V2NList:", inputline))
{
startBPT = false;
- fizlines.emplace("V2NList", inputline);
+ fizlines.try_emplace("V2NList", inputline);
startDIZELV2NMAXLIST = true;
LISTLINE = 0;
continue;
@@ -10129,7 +10043,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("WiperList:", inputline))
{
startBPT = false;
- fizlines.emplace("WiperList", inputline);
+ fizlines.try_emplace("WiperList", inputline);
startWiperList = true;
LISTLINE = 0;
LoadFIZ_WiperList(inputline);
@@ -10142,7 +10056,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
dimPositions.clear(); // uzywamy customowej listy
startBPT = false;
startDimmerList = true;
- fizlines.emplace("DimmerList", inputline);
+ fizlines.try_emplace("DimmerList", inputline);
LoadFIZ_DimmerList(inputline);
continue;
}
@@ -10150,7 +10064,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("LightsList:", inputline))
{
startBPT = false;
- fizlines.emplace("LightsList", inputline);
+ fizlines.try_emplace("LightsList", inputline);
startLIGHTSLIST = true;
LISTLINE = 0;
LoadFIZ_LightsList(inputline);
@@ -10160,7 +10074,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("CompressorList:", inputline))
{
startBPT = false;
- fizlines.emplace("CompressorList", inputline);
+ fizlines.try_emplace("CompressorList", inputline);
startCOMPRESSORLIST = true;
LISTLINE = 0;
LoadFIZ_CompressorList(inputline);
@@ -10288,7 +10202,7 @@ void TMoverParameters::LoadFIZ_Param(std::string const &line)
extract_value(LightPower, "LightP", line, "0");
{
- std::map categories{{"train", 1}, {"road", 2}, {"unimog", 3}, {"ship", 4}, {"airplane,", 8}};
+ std::map> categories{{"train", 1}, {"road", 2}, {"unimog", 3}, {"ship", 4}, {"airplane,", 8}};
std::string category;
extract_value(category, "Category", line, "none");
auto lookup = categories.find(category);
@@ -10300,7 +10214,7 @@ void TMoverParameters::LoadFIZ_Param(std::string const &line)
}
{
- std::map types{
+ std::map> types{
{"pseudodiesel", dt_PseudoDiesel},
{"ezt", dt_EZT},
{"dmu", dt_DMU},
@@ -10383,7 +10297,7 @@ void TMoverParameters::LoadFIZ_Dimensions(std::string const &line)
if (Dim.H <= 2.0)
{
// gdyby nie było parametru, lepsze to niż zero
- Floor = Dim.H;
+ Floor = static_cast(Dim.H);
}
else
{
@@ -10485,7 +10399,7 @@ void TMoverParameters::LoadFIZ_Brake(std::string const &line)
extract_value(BrakeVVolume, "BVV", line, "");
{
- std::map brakemethods{{"P10-Bg", bp_P10Bg}, {"P10-Bgu", bp_P10Bgu}, {"FR513", bp_FR513}, {"FR510", bp_FR510}, {"Cosid", bp_Cosid},
+ std::map> brakemethods{{"P10-Bg", bp_P10Bg}, {"P10-Bgu", bp_P10Bgu}, {"FR513", bp_FR513}, {"FR510", bp_FR510}, {"Cosid", bp_Cosid},
{"P10yBg", bp_P10yBg}, {"P10yBgu", bp_P10yBgu}, {"Disk1", bp_D1}, {"Disk1+Mg", bp_D1 + bp_MHS}, {"Disk2", bp_D2}};
auto lookup = brakemethods.find(extract_value("BM", line));
BrakeMethod = lookup != brakemethods.end() ? lookup->second : 0;
@@ -10529,7 +10443,7 @@ void TMoverParameters::LoadFIZ_Brake(std::string const &line)
extract_value(HandleUnlock, "HandlePipeUnlockPos", line, "-3");
extract_value(EmergencyCutsOffHandle, "EmergencyCutsOffHandle", line, "");
{
- std::map compressorpowers{
+ std::map> compressorpowers{
{"Main", 0},
// 1: default, powered by converter, with manual state control
{"Converter", 2},
@@ -10572,7 +10486,7 @@ void TMoverParameters::LoadFIZ_Brake(std::string const &line)
void TMoverParameters::LoadFIZ_Doors(std::string const &line)
{
- std::map doorcontrols{
+ std::map> doorcontrols{
{"Passenger", control_t::passenger}, {"AutomaticCtrl", control_t::autonomous}, {"DriverCtrl", control_t::driver}, {"Conductor", control_t::conductor}, {"Mixed", control_t::mixed}};
// opening method
{
@@ -10600,7 +10514,7 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line)
{
// HACK: legacy position indices start from 1, so we deduct 1 to arrive at proper index into the array
extract_value(Doors.permit_preset, "DoorPermitListDefault", line, "1");
- Doors.permit_preset = std::min(Doors.permit_presets.size(), Doors.permit_preset) - 1;
+ Doors.permit_preset = std::min(static_cast(Doors.permit_presets.size()), Doors.permit_preset) - 1;
}
}
@@ -10612,7 +10526,7 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line)
extract_value(Doors.range, "DoorMaxShiftR", line, "");
extract_value(Doors.range_out, "DoorMaxShiftPlug", line, "");
- std::map doortypes{
+ std::map> doortypes{
{"Shift", 1},
{"Rotate", 2},
{"Fold", 3},
@@ -10654,59 +10568,59 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line)
void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Index)
{
- TCoupling *coupler;
+ TCoupling *thiscoupler;
if (Index == 2)
{
- coupler = &Couplers[1];
+ thiscoupler = &Couplers[1];
}
else
{
- coupler = &Couplers[0];
+ thiscoupler = &Couplers[0];
}
- std::map couplertypes{
+ std::map> couplertypes{
{"Automatic", TCouplerType::Automatic}, {"Screw", TCouplerType::Screw}, {"Chain", TCouplerType::Chain}, {"Bare", TCouplerType::Bare}, {"Articulated", TCouplerType::Articulated},
};
auto lookup = couplertypes.find(extract_value("CType", line));
- coupler->CouplerType = lookup != couplertypes.end() ? lookup->second : TCouplerType::NoCoupler;
+ thiscoupler->CouplerType = lookup != couplertypes.end() ? lookup->second : TCouplerType::NoCoupler;
- extract_value(coupler->SpringKC, "kC", line, "");
- extract_value(coupler->DmaxC, "DmaxC", line, "");
- extract_value(coupler->FmaxC, "FmaxC", line, "");
- extract_value(coupler->SpringKB, "kB", line, "");
- extract_value(coupler->DmaxB, "DmaxB", line, "");
- extract_value(coupler->FmaxB, "FmaxB", line, "");
- extract_value(coupler->beta, "beta", line, "");
- extract_value(coupler->AutomaticCouplingFlag, "AutomaticFlag", line, "");
- extract_value(coupler->AllowedFlag, "AllowedFlag", line, "");
- if (coupler->AllowedFlag < 0)
+ extract_value(thiscoupler->SpringKC, "kC", line, "");
+ extract_value(thiscoupler->DmaxC, "DmaxC", line, "");
+ extract_value(thiscoupler->FmaxC, "FmaxC", line, "");
+ extract_value(thiscoupler->SpringKB, "kB", line, "");
+ extract_value(thiscoupler->DmaxB, "DmaxB", line, "");
+ extract_value(thiscoupler->FmaxB, "FmaxB", line, "");
+ extract_value(thiscoupler->beta, "beta", line, "");
+ extract_value(thiscoupler->AutomaticCouplingFlag, "AutomaticFlag", line, "");
+ extract_value(thiscoupler->AllowedFlag, "AllowedFlag", line, "");
+ if (thiscoupler->AllowedFlag < 0)
{
- coupler->AllowedFlag = -coupler->AllowedFlag | coupling::permanent;
+ thiscoupler->AllowedFlag = -thiscoupler->AllowedFlag | coupling::permanent;
}
- extract_value(coupler->PowerCoupling, "PowerCoupling", line, "");
- extract_value(coupler->PowerFlag, "PowerFlag", line, "");
- extract_value(coupler->control_type, "ControlType", line, "");
+ extract_value(thiscoupler->PowerCoupling, "PowerCoupling", line, "");
+ extract_value(thiscoupler->PowerFlag, "PowerFlag", line, "");
+ extract_value(thiscoupler->control_type, "ControlType", line, "");
- if (coupler->CouplerType != TCouplerType::NoCoupler && coupler->CouplerType != TCouplerType::Bare && coupler->CouplerType != TCouplerType::Articulated)
+ if (thiscoupler->CouplerType != TCouplerType::NoCoupler && thiscoupler->CouplerType != TCouplerType::Bare && thiscoupler->CouplerType != TCouplerType::Articulated)
{
- coupler->SpringKC *= 1000;
- coupler->FmaxC *= 1000;
- coupler->SpringKB *= 1000;
- coupler->FmaxB *= 1000;
+ thiscoupler->SpringKC *= 1000;
+ thiscoupler->FmaxC *= 1000;
+ thiscoupler->SpringKB *= 1000;
+ thiscoupler->FmaxB *= 1000;
}
- else if (coupler->CouplerType == TCouplerType::Bare)
+ else if (thiscoupler->CouplerType == TCouplerType::Bare)
{
- coupler->SpringKC = 50.0 * Mass + Ftmax / 0.05;
- coupler->DmaxC = 0.05;
- coupler->FmaxC = 100.0 * Mass + 2 * Ftmax;
- coupler->SpringKB = 60.0 * Mass + Ftmax / 0.05;
- coupler->DmaxB = 0.05;
- coupler->FmaxB = 50.0 * Mass + 2.0 * Ftmax;
- coupler->beta = 0.3;
+ thiscoupler->SpringKC = 50.0 * Mass + Ftmax / 0.05;
+ thiscoupler->DmaxC = 0.05;
+ thiscoupler->FmaxC = 100.0 * Mass + 2 * Ftmax;
+ thiscoupler->SpringKB = 60.0 * Mass + Ftmax / 0.05;
+ thiscoupler->DmaxB = 0.05;
+ thiscoupler->FmaxB = 50.0 * Mass + 2.0 * Ftmax;
+ thiscoupler->beta = 0.3;
}
- else if (coupler->CouplerType == TCouplerType::Articulated)
+ else if (thiscoupler->CouplerType == TCouplerType::Articulated)
{
/*
coupler->SpringKC = 60.0 * Mass + 1000;
@@ -10717,13 +10631,13 @@ void TMoverParameters::LoadFIZ_BuffCoupl(std::string const &line, int const Inde
coupler->FmaxB = 4000000.0 + 2.0 * Ftmax;
coupler->beta = 0.55;
*/
- coupler->SpringKC = 4500 * 1000;
- coupler->DmaxC = 0.05;
- coupler->FmaxC = 850 * 1000;
- coupler->SpringKB = 9200 * 1000;
- coupler->DmaxB = 0.05;
- coupler->FmaxB = 320 * 1000;
- coupler->beta = 0.55;
+ thiscoupler->SpringKC = 4500 * 1000;
+ thiscoupler->DmaxC = 0.05;
+ thiscoupler->FmaxC = 850 * 1000;
+ thiscoupler->SpringKB = 9200 * 1000;
+ thiscoupler->DmaxB = 0.05;
+ thiscoupler->FmaxB = 320 * 1000;
+ thiscoupler->beta = 0.55;
}
if (Index == 0)
@@ -10743,12 +10657,14 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
{
{
- std::map brakesystems{{"Pneumatic", TBrakeSystem::Pneumatic}, {"ElectroPneumatic", TBrakeSystem::ElectroPneumatic}};
+ using enum TBrakeSystem;
+ std::map> brakesystems{{"Pneumatic", Pneumatic}, {"ElectroPneumatic", ElectroPneumatic}};
auto lookup = brakesystems.find(extract_value("BrakeSystem", line));
- BrakeSystem = lookup != brakesystems.end() ? lookup->second : TBrakeSystem::Individual;
+ BrakeSystem = lookup != brakesystems.end() ? lookup->second : Individual;
}
if (BrakeSystem != TBrakeSystem::Individual)
{
+ using enum TBrakeHandle;
extract_value(BrakeCtrlPosNo, "BCPN", line, "");
for (int idx = 0; idx < 4; ++idx)
@@ -10758,7 +10674,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
}
// brakedelays, brakedelayflag
{
- std::map brakedelays{{"GPR", bdelay_G + bdelay_P + bdelay_R},
+ std::map> brakedelays{{"GPR", bdelay_G + bdelay_P + bdelay_R},
{"PR", bdelay_P + bdelay_R},
{"GP", bdelay_G + bdelay_P},
{"R", bdelay_R},
@@ -10766,7 +10682,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
{"G", bdelay_G},
{"GPR+Mg", bdelay_G + bdelay_P + bdelay_R + bdelay_M},
{"PR+Mg", bdelay_P + bdelay_R + bdelay_M}};
- std::map brakedelayflags{{"R", bdelay_R}, {"P", bdelay_P}, {"G", bdelay_G}};
+ std::map> brakedelayflags{{"R", bdelay_R}, {"P", bdelay_P}, {"G", bdelay_G}};
std::string brakedelay;
extract_value(brakedelay, "BrakeDelays", line, "");
auto lookup = brakedelays.find(brakedelay);
@@ -10776,18 +10692,18 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
}
// brakeopmode
{
- std::map brakeopmodes{{"PN", bom_PS + bom_PN}, {"PNEP", bom_PS + bom_PN + bom_EP}, {"PNEPMED", bom_PS + bom_PN + bom_EP + bom_MED}};
+ std::map> brakeopmodes{{"PN", bom_PS + bom_PN}, {"PNEP", bom_PS + bom_PN + bom_EP}, {"PNEPMED", bom_PS + bom_PN + bom_EP + bom_MED}};
auto lookup = brakeopmodes.find(extract_value("BrakeOpModes", line));
BrakeOpModes = lookup != brakeopmodes.end() ? lookup->second : 0;
}
// brakehandle
{
- std::map brakehandles{
- {"FV4a", TBrakeHandle::FV4a}, {"test", TBrakeHandle::testH}, {"D2", TBrakeHandle::D2}, {"MHZ_EN57", TBrakeHandle::MHZ_EN57}, {"MHZ_K5P", TBrakeHandle::MHZ_K5P},
- {"MHZ_K8P", TBrakeHandle::MHZ_K8P}, {"MHZ_6P", TBrakeHandle::MHZ_6P}, {"M394", TBrakeHandle::M394}, {"Knorr", TBrakeHandle::Knorr}, {"Westinghouse", TBrakeHandle::West},
- {"FVel6", TBrakeHandle::FVel6}, {"FVE408", TBrakeHandle::FVE408}, {"St113", TBrakeHandle::St113}};
+ std::map> brakehandles{
+ {"FV4a", FV4a}, {"test", testH}, {"D2", D2}, {"MHZ_EN57", MHZ_EN57}, {"MHZ_K5P", MHZ_K5P},
+ {"MHZ_K8P", MHZ_K8P}, {"MHZ_6P", MHZ_6P}, {"M394", M394}, {"Knorr", Knorr}, {"Westinghouse", West},
+ {"FVel6", FVel6}, {"FVE408", FVE408}, {"St113", St113}};
auto lookup = brakehandles.find(extract_value("BrakeHandle", line));
- BrakeHandle = lookup != brakehandles.end() ? lookup->second : TBrakeHandle::NoHandle;
+ BrakeHandle = lookup != brakehandles.end() ? lookup->second : NoHandle;
}
extract_value(Handle_AutomaticOverload, "HAO", line, "");
extract_value(Handle_ManualOverload, "HMO", line, "");
@@ -10797,9 +10713,9 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
extract_value(Handle_OverloadPressureDecrease, "OPD", line, "");
// brakelochandle
{
- std::map locbrakehandles{{"FD1", TBrakeHandle::FD1}, {"Knorr", TBrakeHandle::Knorr}, {"Westinghouse", TBrakeHandle::West}};
+ std::map> locbrakehandles{{"FD1", FD1}, {"Knorr", Knorr}, {"Westinghouse", West}};
auto lookup = locbrakehandles.find(extract_value("LocBrakeHandle", line));
- BrakeLocHandle = lookup != locbrakehandles.end() ? lookup->second : TBrakeHandle::NoHandle;
+ BrakeLocHandle = lookup != locbrakehandles.end() ? lookup->second : NoHandle;
}
// mbpm
@@ -10839,9 +10755,10 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
// localbrake
{
- std::map localbrakes{{"ManualBrake", TLocalBrake::ManualBrake}, {"PneumaticBrake", TLocalBrake::PneumaticBrake}, {"HydraulicBrake", TLocalBrake::HydraulicBrake}};
+ using enum TLocalBrake;
+ std::map> localbrakes{{"ManualBrake", ManualBrake}, {"PneumaticBrake", PneumaticBrake}, {"HydraulicBrake", HydraulicBrake}};
auto lookup = localbrakes.find(extract_value("LocalBrake", line));
- LocalBrake = lookup != localbrakes.end() ? lookup->second : TLocalBrake::NoBrake;
+ LocalBrake = lookup != localbrakes.end() ? lookup->second : NoBrake;
}
// mbrake
extract_value(MBrake, "ManualBrake", line, "");
@@ -10851,7 +10768,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
// dynamicbrake
{
- std::map dynamicbrakes{{"Passive", dbrake_passive}, {"Switch", dbrake_switch}, {"Reversal", dbrake_reversal}, {"Automatic", dbrake_automatic}};
+ std::map> dynamicbrakes{{"Passive", dbrake_passive}, {"Switch", dbrake_switch}, {"Reversal", dbrake_reversal}, {"Automatic", dbrake_automatic}};
auto lookup = dynamicbrakes.find(extract_value("DynamicBrake", line));
DynamicBrakeType = lookup != dynamicbrakes.end() ? lookup->second : dbrake_none;
extract_value(DynamicBrakeAmpmeters, "DBAM", line, "");
@@ -10874,8 +10791,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
extract_value(ScndInMain, "SCIM", line, "");
extract_value(MainCtrlMaxDirChangePos, "DirChangeMaxPos", line, "");
- auto const autorelay{ToLower(extract_value("AutoRelay", line))};
- if (autorelay == "optional")
+ if (auto const autorelay{ToLower(extract_value("AutoRelay", line))}; autorelay == "optional")
{
AutoRelayType = 2;
}
@@ -10925,7 +10841,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
extract_value(shouldHoldBatteryButton, "SBBBH", line, "");
extract_value(BatteryButtonHoldTime, "BBHT", line, "");
- std::map starts{{"Disabled", start_t::disabled}, {"Manual", start_t::manual}, {"Automatic", start_t::automatic}, {"Mixed", start_t::manualwithautofallback},
+ std::map> starts{{"Disabled", start_t::disabled}, {"Manual", start_t::manual}, {"Automatic", start_t::automatic}, {"Mixed", start_t::manualwithautofallback},
{"Battery", start_t::battery}, {"Converter", start_t::converter}, {"Direction", start_t::direction}};
// main circuit
@@ -10998,7 +10914,8 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
// traction motor fans
{
auto lookup = starts.find(extract_value("MotorBlowersStart", line));
- MotorBlowers[end::front].start_type = MotorBlowers[end::rear].start_type = lookup != starts.end() ? lookup->second : start_t::manual;
+ MotorBlowers[end::rear].start_type = lookup != starts.end() ? lookup->second : start_t::manual;
+ MotorBlowers[end::front].start_type = MotorBlowers[end::rear].start_type;
}
// compartment lights
{
@@ -11078,7 +10995,7 @@ void TMoverParameters::LoadFIZ_Light(std::string const &line)
extract_value(NominalVoltage, "Volt", line, "");
extract_value(BatteryVoltage, "LMaxVoltage", line, "");
- NominalBatteryVoltage = BatteryVoltage;
+ NominalBatteryVoltage = static_cast(BatteryVoltage);
}
void TMoverParameters::LoadFIZ_Clima(std::string const &line)
@@ -11156,8 +11073,7 @@ void TMoverParameters::LoadFIZ_Engine(std::string const &Input)
EngineType = LoadFIZ_EngineDecode(extract_value("EngineType", Input));
- std::string transmission = extract_value("Trans", Input);
- if (false == transmission.empty())
+ if (std::string transmission = extract_value("Trans", Input); false == transmission.empty())
{
// transmission type. moved here because more than one engine type has this entry
auto ratios = Split(transmission, ':'); // e.g. 18:79
@@ -11422,7 +11338,7 @@ void TMoverParameters::LoadFIZ_Switches(std::string const &Input)
{
auto &presets{PantsPreset.first};
extract_value(presets, "PantographPresets", Input, "0|1|3|2");
- presets.erase(std::remove(std::begin(presets), std::end(presets), '|'), std::end(presets));
+ std::erase(presets, '|');
}
}
@@ -11481,8 +11397,7 @@ void TMoverParameters::LoadFIZ_RList(std::string const &Input)
extract_value(RlistSize, "Size", Input, "");
- auto const venttype{ToLower(extract_value("RVent", Input))};
- if (venttype == "automatic")
+ if (auto const venttype{ToLower(extract_value("RVent", Input))}; venttype == "automatic")
{
RVentType = 2;
@@ -11579,7 +11494,7 @@ void TMoverParameters::LoadFIZ_CompressorList(std::string const &Input)
extract_value(CompressorListDefPos, "Default", Input, "");
}
-void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Line)
+void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const &Prefix, std::string const &Line)
{
switch (Powerparameters.SourceType)
@@ -11603,8 +11518,7 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete
// prime mover for the generator
auto &generatorparameters{Powerparameters.EngineGenerator};
- auto const enginetype{LoadFIZ_EngineDecode(extract_value(Prefix + "GeneratorEngine", Line))};
- if (enginetype == TEngineType::Main)
+ if (auto const enginetype{LoadFIZ_EngineDecode(extract_value(Prefix + "GeneratorEngine", Line))}; enginetype == TEngineType::Main)
{
generatorparameters.engine_revolutions = &enrot;
}
@@ -11700,51 +11614,53 @@ void TMoverParameters::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparamete
}
}
-TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Power)
+TPowerType TMoverParameters::LoadFIZ_PowerDecode(std::string const &Powertype) const
{
+ using enum TPowerType;
- std::map powertypes{
- {"BioPower", TPowerType::BioPower}, {"MechPower", TPowerType::MechPower}, {"ElectricPower", TPowerType::ElectricPower}, {"SteamPower", TPowerType::SteamPower}};
- auto lookup = powertypes.find(Power);
- return lookup != powertypes.end() ? lookup->second : TPowerType::NoPower;
+ std::map> powertypes{
+ {"BioPower", BioPower}, {"MechPower", MechPower}, {"ElectricPower", ElectricPower}, {"SteamPower", SteamPower}};
+ auto lookup = powertypes.find(Powertype);
+ return lookup != powertypes.end() ? lookup->second : NoPower;
}
-TPowerSource TMoverParameters::LoadFIZ_SourceDecode(std::string const &Source)
+TPowerSource TMoverParameters::LoadFIZ_SourceDecode(std::string const &Source) const
{
+ using enum TPowerSource;
- std::map powersources{{"Transducer", TPowerSource::Transducer}, {"Generator", TPowerSource::Generator},
- {"Accu", TPowerSource::Accumulator}, // legacy compatibility leftover. TODO: check if we can get rid of it
- {"Accumulator", TPowerSource::Accumulator}, {"CurrentCollector", TPowerSource::CurrentCollector},
- {"PowerCable", TPowerSource::PowerCable}, {"Heater", TPowerSource::Heater},
- {"Internal", TPowerSource::InternalSource}, {"Main", TPowerSource::Main}};
+ std::map> powersources{{"Transducer", Transducer}, {"Generator", Generator},
+ {"Accu", Accumulator}, // legacy compatibility leftover. TODO: check if we can get rid of it
+ {"Accumulator", Accumulator}, {"CurrentCollector", CurrentCollector},
+ {"PowerCable", PowerCable}, {"Heater", Heater},
+ {"Internal", InternalSource}, {"Main", Main}};
auto lookup = powersources.find(Source);
- return lookup != powersources.end() ? lookup->second : TPowerSource::NotDefined;
+ return lookup != powersources.end() ? lookup->second : NotDefined;
}
-TEngineType TMoverParameters::LoadFIZ_EngineDecode(std::string const &Engine)
+TEngineType TMoverParameters::LoadFIZ_EngineDecode(std::string const &Engine) const
{
+ using enum TEngineType;
- std::map enginetypes{{"ElectricSeriesMotor", TEngineType::ElectricSeriesMotor},
- {"DieselEngine", TEngineType::DieselEngine},
- {"SteamEngine", TEngineType::SteamEngine},
- {"WheelsDriven", TEngineType::WheelsDriven},
- {"Dumb", TEngineType::Dumb},
- {"DieselElectric", TEngineType::DieselElectric},
- {"DumbDE", TEngineType::DieselElectric},
- {"ElectricInductionMotor", TEngineType::ElectricInductionMotor},
- {"Main", TEngineType::Main}};
+ std::map> enginetypes{{"ElectricSeriesMotor", ElectricSeriesMotor},
+ {"DieselEngine", DieselEngine},
+ {"SteamEngine", SteamEngine},
+ {"WheelsDriven", WheelsDriven},
+ {"Dumb", Dumb},
+ {"DieselElectric", DieselElectric},
+ {"DumbDE", DieselElectric},
+ {"ElectricInductionMotor", ElectricInductionMotor},
+ {"Main", Main}};
auto lookup = enginetypes.find(Engine);
- return lookup != enginetypes.end() ? lookup->second : TEngineType::None;
+ return lookup != enginetypes.end() ? lookup->second : None;
}
// *************************************************************************************************
// Q: 20160717
// *************************************************************************************************
-bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
+bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int /*Dir*/)
{
WriteLog("check locomotive parameters...");
- int b;
bool OK = true;
AutoRelayFlag = AutoRelayType == 1;
@@ -11779,9 +11695,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
// WriteLogSS("aa ok", BoolToYN(OK));
}
- if (BrakeSystem == TBrakeSystem::Individual)
- if (BrakeSubsystem != TBrakeSubSystem::ss_None)
- OK = false; //!
+ if (BrakeSystem == TBrakeSystem::Individual && BrakeSubsystem != TBrakeSubSystem::ss_None)
+ OK = false; //!
if (BrakeVVolume == 0 && MaxBrakePress[3] > 0 && BrakeSystem != TBrakeSystem::Individual)
{
@@ -11890,35 +11805,36 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
switch (BrakeHandle)
{
- case TBrakeHandle::FV4a:
+ using enum TBrakeHandle;
+ case FV4a:
Handle = std::make_shared();
break;
- case TBrakeHandle::MHZ_EN57:
- case TBrakeHandle::MHZ_K8P:
+ case MHZ_EN57:
+ case MHZ_K8P:
Handle = std::make_shared();
break;
- case TBrakeHandle::FVel6:
+ case FVel6:
Handle = std::make_shared();
break;
- case TBrakeHandle::FVE408:
+ case FVE408:
Handle = std::make_shared();
break;
- case TBrakeHandle::testH:
+ case testH:
Handle = std::make_shared();
break;
- case TBrakeHandle::M394:
+ case M394:
Handle = std::make_shared();
break;
- case TBrakeHandle::Knorr:
+ case Knorr:
Handle = std::make_shared();
break;
- case TBrakeHandle::St113:
+ case St113:
Handle = std::make_shared();
break;
- case TBrakeHandle::MHZ_K5P:
+ case MHZ_K5P:
Handle = std::make_shared();
break;
- case TBrakeHandle::MHZ_6P:
+ case MHZ_6P:
Handle = std::make_shared();
break;
default:
@@ -12094,9 +12010,9 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
BrakeOpModeFlag = bom_PN;
// yB: jesli pojazdy nie maja zadeklarowanych czasow, to wsadz z przepisow +-16,(6)%
- int DefBrakeTable[8] = {15, 4, 25, 25, 13, 3, 12, 2};
+ std::array const DefBrakeTable{15, 4, 25, 25, 13, 3, 12, 2};
- for (b = 1; b < 4; b++)
+ for (int b = 1; b < 4; b++)
{
if (BrakeDelay[b] == 0)
BrakeDelay[b] = DefBrakeTable[b];
@@ -12137,7 +12053,7 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
// Q: 20160714
// Wstawia komendę z parametrem, od sprzęgu i w lokalizacji do pojazdu
// *************************************************************************************************
-void TMoverParameters::PutCommand(std::string NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation)
+void TMoverParameters::PutCommand(std::string const &NewCommand, double NewValue1, double NewValue2, const TLocation &NewLocation)
{
CommandLast = NewCommand; // zapamiętanie komendy
@@ -12152,7 +12068,7 @@ void TMoverParameters::PutCommand(std::string NewCommand, double NewValue1, doub
// Q: 20160714
// Pobiera komendę z parametru funkcji oraz wartość zmiennej jako return
// *************************************************************************************************
-double TMoverParameters::GetExternalCommand(std::string &Command)
+double TMoverParameters::GetExternalCommand(std::string &Command) const
{
Command = CommandOut;
return ValueOut;
@@ -12162,7 +12078,7 @@ double TMoverParameters::GetExternalCommand(std::string &Command)
// Q: 20160714
// Ustawienie komendy wraz z parametrami
// *************************************************************************************************
-bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValue1, double NewValue2, int const Couplertype)
+bool TMoverParameters::SetInternalCommand(std::string const &NewCommand, double NewValue1, double NewValue2, int const Couplertype)
{
bool SIC;
if (CommandIn.Command == NewCommand && CommandIn.Value1 == NewValue1 && CommandIn.Value2 == NewValue2 && CommandIn.Coupling == Couplertype)
@@ -12184,7 +12100,7 @@ bool TMoverParameters::SetInternalCommand(std::string NewCommand, double NewValu
// Q: 20160714
// wysyłanie komendy w kierunku dir (1=przód, -1=tył) do kolejnego pojazdu (jednego)
// *************************************************************************************************
-bool TMoverParameters::SendCtrlToNext(std::string const CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype)
+bool TMoverParameters::SendCtrlToNext(std::string const &CtrlCommand, double const ctrlvalue, double const dir, int const Couplertype)
{
bool OK;
int d; // numer sprzęgu w kierunku którego wysyłamy
@@ -12193,24 +12109,21 @@ bool TMoverParameters::SendCtrlToNext(std::string const CtrlCommand, double cons
// Ra: problem jest również, jeśli AI będzie na końcu składu
OK = true; // ( dir != 0 ); // experimentally disabled
d = (1 + static_cast(Sign(dir))) / 2; // dir=-1=>d=0, dir=1=>d=1 - wysyłanie tylko w tył
- if (OK)
+ // musi być wybrana niezerowa kabina
+ if (OK && Couplers[d].Connected != nullptr && TestFlag(Couplers[d].CouplingFlag, Couplertype))
{
- // musi być wybrana niezerowa kabina
- if (Couplers[d].Connected != nullptr && TestFlag(Couplers[d].CouplingFlag, Couplertype))
- {
- if (Couplers[d].ConnectedNr != d)
- {
- // jeśli ten nastpęny jest zgodny z aktualnym
- if (Couplers[d].Connected->SetInternalCommand(CtrlCommand, ctrlvalue, dir, Couplertype))
- OK = Couplers[d].Connected->RunInternalCommand() && OK; // tu jest rekurencja
- }
- else
- {
- // jeśli następny jest ustawiony przeciwnie, zmieniamy kierunek
- if (Couplers[d].Connected->SetInternalCommand(CtrlCommand, ctrlvalue, -dir, Couplertype))
- OK = Couplers[d].Connected->RunInternalCommand() && OK; // tu jest rekurencja
- }
+ if (Couplers[d].ConnectedNr != d)
+ {
+ // jeśli ten nastpęny jest zgodny z aktualnym
+ if (Couplers[d].Connected->SetInternalCommand(CtrlCommand, ctrlvalue, dir, Couplertype))
+ OK = Couplers[d].Connected->RunInternalCommand() && OK; // tu jest rekurencja
+ }
+ else
+ {
+ // jeśli następny jest ustawiony przeciwnie, zmieniamy kierunek
+ if (Couplers[d].Connected->SetInternalCommand(CtrlCommand, ctrlvalue, -dir, Couplertype))
+ OK = Couplers[d].Connected->RunInternalCommand() && OK; // tu jest rekurencja
}
}
return OK;
@@ -12227,7 +12140,7 @@ bool TMoverParameters::SendCtrlToNext(std::string const CtrlCommand, double cons
// Komenda musi być zdefiniowana tutaj, a jeśli się wywołuje funkcję, to ona nie może
// sama przesyłać do kolejnych pojazdów. Należy też się zastanowić, czy dla uzyskania
// jakiejś zmiany (np. IncMainCtrl) lepiej wywołać funkcję, czy od razu wysłać komendę.
-bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CValue2, int const Couplertype)
+bool TMoverParameters::RunCommand(std::string const &Command, double CValue1, double CValue2, int const Couplertype)
{
bool OK{false};
@@ -12279,7 +12192,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
if (DCEMUED_EP_min_Im > 0.001 && abs(Im) > DCEMUED_EP_min_Im && DynamicBrakeEMUStatus)
temp1 = 0;
Hamulec->SetEPS(temp1);
- TUHEX_StageActual = CValue1;
+ TUHEX_StageActual = static_cast(CValue1);
TUHEX_Active = TUHEX_StageActual > 0;
if (CValue1 < 0.001)
DynamicBrakeEMUStatus = true;
@@ -12289,7 +12202,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
} // youby - odluzniacz hamulcow, przyda sie
else if (Command == "BrakeReleaser")
{
- OK = BrakeReleaser(Round(CValue1)); // samo się przesyła dalej
+ OK = BrakeReleaser(static_cast(Round(CValue1))); // samo się przesyła dalej
// OK:=SendCtrlToNext(command,CValue1,CValue2); //to robiło kaskadę 2^n
}
else if (Command == "WaterPumpBreakerSwitch")
@@ -12500,7 +12413,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
}
else if (Command == "RelayReset")
{
- RelayReset(CValue1, range_t::local);
+ RelayReset(static_cast(CValue1), range_t::local);
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "ConverterSwitch") /*NBMX*/
@@ -12538,14 +12451,13 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
else if (Command == "DoorPermit")
{
- auto const left{CValue2 > 0 ? 1 : 2};
- auto const right{3 - left};
+ auto const leftside{CValue2 > 0 ? 1 : 2};
- if (std::abs(static_cast(CValue1)) & right)
+ if (auto const rightside{3 - leftside}; std::abs(static_cast(CValue1)) & rightside)
{
PermitDoors_(side::right, CValue1 > 0);
}
- if (std::abs(static_cast(CValue1)) & left)
+ if (std::abs(static_cast(CValue1)) & leftside)
{
PermitDoors_(side::left, CValue1 > 0);
}
@@ -12554,50 +12466,42 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
}
else if (Command == "DoorOpen") /*NBMX*/
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
- if (Doors.open_control == control_t::conductor || Doors.open_control == control_t::driver || Doors.open_control == control_t::mixed)
+ // ignore remote command if the door is only operated locally
+ if ((Doors.open_control == control_t::conductor || Doors.open_control == control_t::driver || Doors.open_control == control_t::mixed) && (Power24vIsAvailable || Power110vIsAvailable))
{
- // ignore remote command if the door is only operated locally
- if (Power24vIsAvailable || Power110vIsAvailable)
+
+ auto const leftside{CValue2 > 0 ? 1 : 2};
+
+ if (auto const rightside{3 - leftside}; static_cast(CValue1) & rightside)
{
-
- auto const left{CValue2 > 0 ? 1 : 2};
- auto const right{3 - left};
-
- if (static_cast(CValue1) & right)
- {
- Doors.instances[side::right].remote_open = true;
- Doors.instances[side::right].remote_close = false;
- }
- if (static_cast(CValue1) & left)
- {
- Doors.instances[side::left].remote_open = true;
- Doors.instances[side::left].remote_close = false;
- }
+ Doors.instances[side::right].remote_open = true;
+ Doors.instances[side::right].remote_close = false;
+ }
+ if (static_cast(CValue1) & leftside)
+ {
+ Doors.instances[side::left].remote_open = true;
+ Doors.instances[side::left].remote_close = false;
}
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else if (Command == "DoorClose") /*NBMX*/
{ // Ra: uwzględnić trzeba jeszcze zgodność sprzęgów
- if (Doors.close_control == control_t::conductor || Doors.close_control == control_t::driver || Doors.close_control == control_t::mixed)
+ // ignore remote command if the door is only operated locally
+ if ((Doors.close_control == control_t::conductor || Doors.close_control == control_t::driver || Doors.close_control == control_t::mixed) && (Power24vIsAvailable || Power110vIsAvailable))
{
- // ignore remote command if the door is only operated locally
- if (Power24vIsAvailable || Power110vIsAvailable)
+
+ auto const leftside{CValue2 > 0 ? 1 : 2};
+
+ if (auto const rightside{3 - leftside}; static_cast(CValue1) & rightside)
{
-
- auto const left{CValue2 > 0 ? 1 : 2};
- auto const right{3 - left};
-
- if (static_cast(CValue1) & right)
- {
- Doors.instances[side::right].remote_close = true;
- Doors.instances[side::right].remote_open = false;
- }
- if (static_cast(CValue1) & left)
- {
- Doors.instances[side::left].remote_close = true;
- Doors.instances[side::left].remote_open = false;
- }
+ Doors.instances[side::right].remote_close = true;
+ Doors.instances[side::right].remote_open = false;
+ }
+ if (static_cast(CValue1) & leftside)
+ {
+ Doors.instances[side::left].remote_close = true;
+ Doors.instances[side::left].remote_open = false;
}
}
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
@@ -12628,9 +12532,8 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
auto const inputcab{(static_cast(CValue1) & 0x40) != 0 ? 1 : 0};
auto const inputoperation{static_cast(CValue1) & ~(0x80 | 0x40)};
auto const noswap{TrainType == dt_EZT || TrainType == dt_ET41};
- auto swap{false == noswap && TestFlag(Couplers[(CValue2 == -1 ? end::rear : end::front)].CouplingFlag, coupling::control)};
- auto const reversed{inputcab != (CabActive != -1 ? 1 : 0)};
- if (reversed)
+ auto swap{false == noswap && TestFlag(Couplers[CValue2 == -1 ? end::rear : end::front].CouplingFlag, coupling::control)};
+ if (auto const reversed{inputcab != (CabActive != -1 ? 1 : 0)}; reversed)
{
swap = !swap;
} // TODO: check whether this part has RL equivalent
@@ -12673,8 +12576,7 @@ bool TMoverParameters::RunCommand(std::string Command, double CValue1, double CV
}
else if (Command == "BrakeDelay")
{
- auto const brakesetting = static_cast(std::floor(CValue1));
- if (true == Hamulec->SetBDF(brakesetting))
+ if (auto const brakesetting = static_cast(std::floor(CValue1)); true == Hamulec->SetBDF(brakesetting))
{
BrakeDelayFlag = brakesetting;
OK = true;
@@ -12795,7 +12697,7 @@ bool TMoverParameters::RunInternalCommand()
// *************************************************************************************************
double TMoverParameters::ShowCurrentP(int AmpN) const
{
- int b, Bn;
+ int Bn;
bool Grupowy;
// ClearPendingExceptions;
@@ -12819,11 +12721,10 @@ double TMoverParameters::ShowCurrentP(int AmpN) const
else // pobor pradu jezeli niema mocy
{
int current = 0;
- for (b = 0; b < 2; b++)
+ for (int b = 0; b < 2; b++)
// with Couplers[b] do
- if (TestFlag(Couplers[b].CouplingFlag, coupling::control))
- if (Couplers[b].Connected->Power > 0.01)
- current = static_cast(Couplers[b].Connected->ShowCurrent(AmpN));
+ if (TestFlag(Couplers[b].CouplingFlag, coupling::control) && Couplers[b].Connected->Power > 0.01)
+ current = static_cast(Couplers[b].Connected->ShowCurrent(AmpN));
return current;
}
}
@@ -12833,8 +12734,7 @@ bool TMoverParameters::reload_FIZ()
WriteLog("[DEV] Reloading FIZ for " + Name);
// pause simulation
Global.iPause |= 0b1000;
- bool result = LoadFIZ(chkPath);
- if (result == true)
+ if (bool result = LoadFIZ(chkPath); result == true)
{
// jesli sie udalo przeladowac FIZ
Global.iPause &= 0b0111;
diff --git a/McZapkie/Oerlikon_ESt.cpp b/McZapkie/Oerlikon_ESt.cpp
index 9559d305..17fa79ee 100644
--- a/McZapkie/Oerlikon_ESt.cpp
+++ b/McZapkie/Oerlikon_ESt.cpp
@@ -211,7 +211,7 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr
double dV{ 0.0 };
double dV1{ 0.0 };
- double const nastG = static_cast(BrakeDelayFlag & bdelay_G);
+ auto const nastG = static_cast(BrakeDelayFlag & bdelay_G);
// sprawdzanie stanu
CheckState(BCP, dV1);
@@ -294,8 +294,9 @@ double TNESt3::GetPF( double const PP, double const dt, double const Vel ) // pr
return dV - dV1;
}
-void TNESt3::EStParams( double const i_crc ) // parametry charakterystyczne dla ESt
+void TNESt3::EStParams( double const /*i_crc*/ ) const // parametry charakterystyczne dla ESt
{
+ // no effect for this device type
}
void TNESt3::Init( double const PP, double const HPP, double const LPP, double const BP, int const BDF )
@@ -318,7 +319,9 @@ void TNESt3::Init( double const PP, double const HPP, double const LPP, double c
Zamykajacy = false;
- if ( typeid(*FM) == typeid(TDisk1) || typeid(*FM) == typeid(TDisk2) ) // jesli zeliwo to schodz
+ auto const &frictionmaterial { *FM };
+ auto const &frictionmaterialtype { typeid( frictionmaterial ) };
+ if ( frictionmaterialtype == typeid(TDisk1) || frictionmaterialtype == typeid(TDisk2) ) // jesli zeliwo to schodz
RapidStaly = true;
else
RapidStaly = false;
@@ -331,9 +334,8 @@ double TNESt3::GetCRP()
// return Miedzypoj.P;
}
-void TNESt3::CheckState(double const BCP, double &dV1) // glowny przyrzad rozrzadczy
+void TNESt3::CheckState(double const BCP, double & /*dV1*/) // glowny przyrzad rozrzadczy
{
- double const BVP{ BrakeRes->P() }; //-> tu ma byc komora rozprezna
double const VVP{ ValveRes->P() };
double const CVP{ CntrlRes->P() };
double const MPP{ Miedzypoj->P() };
@@ -355,14 +357,14 @@ void TNESt3::CheckState(double const BCP, double &dV1) // glowny przyrzad rozrza
if( ( BrakeStatus & b_hld ) == 0 )
SoundFlag |= sf_CylU;
- if (VVP + 0.10 < CVP && BCP < 0.25) // poczatek hamowania
- if (false == Przys_blok)
- {
- ValveRes->CreatePress(0.1 * VVP);
- SoundFlag |= sf_Acc;
- ValveRes->Act();
- Przys_blok = true;
- }
+ // poczatek hamowania
+ if (VVP + 0.10 < CVP && BCP < 0.25 && false == Przys_blok)
+ {
+ ValveRes->CreatePress(0.1 * VVP);
+ SoundFlag |= sf_Acc;
+ ValveRes->Act();
+ Przys_blok = true;
+ }
if (BCP > 0.5)
Zamykajacy = true;
@@ -384,7 +386,7 @@ void TNESt3::CheckReleaser(double const dt) // odluzniacz
}
}
-double TNESt3::CVs(double const BP) // napelniacz sterujacego
+double TNESt3::CVs(double const /*BP*/) const // napelniacz sterujacego
{
double const CVP{ CntrlRes->P() };
double const MPP{ Miedzypoj->P() };
@@ -398,7 +400,7 @@ double TNESt3::CVs(double const BP) // napelniacz sterujacego
return Nozzles[dSm];
}
-double TNESt3::BVs(double const BCP) // napelniacz pomocniczego
+double TNESt3::BVs(double const BCP) const // napelniacz pomocniczego
{
double const CVP{ CntrlRes->P() };
double const MPP{ Miedzypoj->P() };
@@ -637,9 +639,9 @@ void TNESt3::SetSize( int const size, std::string const ¶ms ) // ustawianie
Nozzles[dSm] = 0.9;
// przeliczanie z mm^2 na l/m
- for (int i = 0; i < dMAX; ++i)
+ for (auto &nozzle : Nozzles)
{
- Nozzles[i] = d2A(Nozzles[i]); //(/1000^2*pi/4*1000)
+ nozzle = d2A(nozzle); //(/1000^2*pi/4*1000)
}
for (int i = 1; i < 4; ++i)
{
diff --git a/McZapkie/Oerlikon_ESt.h b/McZapkie/Oerlikon_ESt.h
index c1269185..224ffecd 100644
--- a/McZapkie/Oerlikon_ESt.h
+++ b/McZapkie/Oerlikon_ESt.h
@@ -70,38 +70,32 @@ static int const P_ed = 5;
class TPrzekladnik : public TReservoir // przekladnik (powtarzacz)
{
- private:
public:
std::shared_ptr BrakeRes;
std::shared_ptr Next;
- TPrzekladnik() : TReservoir() {};
+ using TReservoir::TReservoir;
virtual void Update(double dt);
};
class TRura : public TPrzekladnik // nieprzekladnik, rura laczaca
{
- private:
public:
- TRura() : TPrzekladnik() {};
- virtual double P(void) /*override*/;
- virtual void Update(double dt) /*override*/;
+ using TPrzekladnik::TPrzekladnik;
+ double P(void) override;
+ void Update(double dt) override;
};
class TPrzeciwposlizg : public TRura // przy napelnianiu - rura, przy poslizgu - upust
{
private:
- bool Poslizg;
+ bool Poslizg{false};
public:
void SetPoslizg(bool flag);
- void Update(double dt) /*override*/;
- inline TPrzeciwposlizg() : TRura()
- {
- Poslizg = false;
- }
+ void Update(double dt) override;
};
// przekladnik dwustopniowy
@@ -117,10 +111,8 @@ class TRapid : public TPrzekladnik {
public:
void SetRapidParams(double mult, double size);
void SetRapidStatus(bool rs);
- void Update(double dt) /*override*/;
- inline TRapid() :
- TPrzekladnik()
- {}
+ void Update(double dt) override;
+ using TPrzekladnik::TPrzekladnik;
};
// AL2
@@ -131,10 +123,8 @@ class TPrzekCiagly : public TPrzekladnik {
public:
void SetMult(double m);
- void Update(double dt) /*override*/;
- inline TPrzekCiagly() :
- TPrzekladnik()
- {}
+ void Update(double dt) override;
+ using TPrzekladnik::TPrzekladnik;
};
// podwojny zawor zwrotny
@@ -145,20 +135,15 @@ class TPrzek_PZZ : public TPrzekladnik {
public:
void SetLBP(double P);
- void Update(double dt) /*override*/;
- inline TPrzek_PZZ() :
- TPrzekladnik()
- {}
+ void Update(double dt) override;
+ using TPrzekladnik::TPrzekladnik;
};
class TPrzekZalamany : public TPrzekladnik // Knicksventil
{
- private:
public:
- TPrzekZalamany() :
- TPrzekladnik()
- {}
+ using TPrzekladnik::TPrzekladnik;
};
// przy napelnianiu - rura, przy hamowaniu - upust
@@ -169,10 +154,8 @@ class TPrzekED : public TRura {
public:
void SetP(double P);
- void Update(double dt) /*override*/;
- inline TPrzekED() :
- TRura()
- {}
+ void Update(double dt) override;
+ using TRura::TRura;
};
class TNESt3 : public TBrake {
@@ -206,22 +189,20 @@ class TNESt3 : public TBrake {
double LBP = 0.0; // cisnienie hamulca pomocniczego
public:
- inline TNESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
- TBrake( i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
- {}
- void Init( double const PP, double const HPP, double const LPP, double const BP, int const BDF ) /*override*/;
- virtual double GetPF( double const PP, double const dt, double const Vel ) /*override*/; // przeplyw miedzy komora wstepna i PG
- void EStParams(double i_crc); // parametry charakterystyczne dla ESt
- virtual double GetCRP() /*override*/;
+ using TBrake::TBrake;
+ void Init( double const PP, double const HPP, double const LPP, double const BP, int const BDF ) override;
+ double GetPF( double const PP, double const dt, double const Vel ) override; // przeplyw miedzy komora wstepna i PG
+ void EStParams(double i_crc) const; // parametry charakterystyczne dla ESt
+ double GetCRP() override;
void CheckState(double const BCP, double &dV1); // glowny przyrzad rozrzadczy
void CheckReleaser(double const dt); // odluzniacz
- double CVs(double const BP); // napelniacz sterujacego
- double BVs(double const BCP); // napelniacz pomocniczego
+ double CVs(double const BP) const; // napelniacz sterujacego
+ double BVs(double const BCP) const; // napelniacz pomocniczego
void SetSize( int const size, std::string const ¶ms ); // ustawianie dysz (rozmiaru ZR), przekladniki
- void PLC(double const mass); // wspolczynnik cisnienia przystawki wazacej
- void SetLP(double const TM, double const LM, double const TBP); // parametry przystawki wazacej
- virtual void ForceEmptiness() /*override*/; // wymuszenie bycia pustym
- void SetLBP(double const P); // cisnienie z hamulca pomocniczego
+ void PLC(double const mass) override; // wspolczynnik cisnienia przystawki wazacej
+ void SetLP(double const TM, double const LM, double const TBP) override; // parametry przystawki wazacej
+ void ForceEmptiness() override; // wymuszenie bycia pustym
+ void SetLBP(double const P) override; // cisnienie z hamulca pomocniczego
};
extern double d2A( double const d );
diff --git a/McZapkie/friction.h b/McZapkie/friction.h
index 067a61b9..c58895a9 100644
--- a/McZapkie/friction.h
+++ b/McZapkie/friction.h
@@ -41,6 +41,7 @@ class TFricMat
public:
virtual double GetFC(double N, double Vel);
+ virtual ~TFricMat() = default;
};
@@ -49,7 +50,7 @@ class TP10Bg: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
@@ -59,7 +60,7 @@ class TP10Bgu: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
@@ -69,7 +70,7 @@ class TP10yBg: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
@@ -79,7 +80,7 @@ class TP10yBgu: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
@@ -89,7 +90,7 @@ class TP10: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
@@ -99,7 +100,7 @@ class TFR513: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
@@ -109,7 +110,7 @@ class TFR510: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
@@ -119,7 +120,7 @@ class TCosid: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
@@ -129,7 +130,7 @@ class TDisk1: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
@@ -139,7 +140,7 @@ class TDisk2: public TFricMat
{
public:
- double GetFC(double N, double Vel)/*override*/;
+ double GetFC(double N, double Vel) override;
};
diff --git a/McZapkie/hamulce.cpp b/McZapkie/hamulce.cpp
index 64a7fb85..c0a7d2a0 100644
--- a/McZapkie/hamulce.cpp
+++ b/McZapkie/hamulce.cpp
@@ -357,21 +357,14 @@ end ; */
/// Friction material id (bp_* constant, optionally OR'ed with bp_MHS).
/// Number of braked axles.
/// Number of blocks per axle.
-TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa)
+TBrake::TBrake(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) :
+ BCN(i_bcn), BCM(1), BCA(i_bcn * i_bcr * i_bcr * M_PI), BrakeDelays(i_BD), MaxBP(i_mbp), BA(i_ba), NBpA(i_nbpa), SizeBR(i_brc * 0.0128)
{
// inherited:: Create;
- MaxBP = i_mbp;
- BCN = i_bcn;
- BCM = 1;
- BCA = i_bcn * i_bcr * i_bcr * M_PI;
- BA = i_ba;
- NBpA = i_nbpa;
- BrakeDelays = i_BD;
BrakeDelayFlag = bdelay_P;
// 210.88
// SizeBR:=i_bcn*i_bcr*i_bcr*i_bcd*40.17*MaxBP/(5-MaxBP); //objetosc ZP w stosunku do cylindra
// 14" i cisnienia 4.2 atm
- SizeBR = i_brc * 0.0128;
SizeBC = i_bcn * i_bcr * i_bcr * i_bcd * 210.88 * MaxBP / 4.2; // objetosc CH w stosunku do cylindra 14" i cisnienia 4.2 atm
BrakeCyl = std::make_shared();
@@ -450,7 +443,7 @@ double TBrake::GetFC(double const Vel, double const N)
/// Returns the gauge pressure inside the brake cylinder.
// cisnienie cylindra hamulcowego
-double TBrake::GetBCP()
+double TBrake::GetBCP() const
{
return BrakeCyl->P();
}
@@ -464,14 +457,14 @@ double TBrake::GetEDBCP()
/// Returns the auxiliary reservoir (ZP) pressure.
// cisnienie zbiornika pomocniczego
-double TBrake::GetBRP()
+double TBrake::GetBRP() const
{
return BrakeRes->P();
}
/// Returns the valve pre-chamber pressure.
// cisnienie komory wstepnej
-double TBrake::GetVRP()
+double TBrake::GetVRP() const
{
return ValveRes->P();
}
@@ -516,7 +509,7 @@ double TBrake::GetHPFlow(double const HP, double const dt)
///
/// Returns the piston force from the cylinder pressure (BCA * 100 * P).
///
-double TBrake::GetBCF()
+double TBrake::GetBCF() const
{
return BCA * 100 * BrakeCyl->P();
}
@@ -558,7 +551,7 @@ bool TBrake::Releaser() const
/// support the EP brake (TWest, TEStEP1/2, ...).
///
/// EP intensity.
-void TBrake::SetEPS(double const nEPS) {}
+void TBrake::SetEPS(double const nEPS) { /* no effect for this device type */ }
///
/// Sets the anti-slip brake state flags. Bit 1 of
@@ -572,7 +565,7 @@ void TBrake::ASB(int const state)
}
/// Returns the raw BrakeStatus bitfield.
-int TBrake::GetStatus()
+int TBrake::GetStatus() const
{
return BrakeStatus;
}
@@ -674,14 +667,14 @@ double TWest::GetPF(double const PP, double const dt, double const Vel)
BCP = BrakeCyl->P();
if ((BrakeStatus & b_hld) == b_hld)
+ {
if (VVP + 0.03 < BVP)
BrakeStatus |= b_on;
else if (VVP > BVP + 0.1)
BrakeStatus &= ~(b_on | b_hld);
else if (VVP > BVP)
BrakeStatus &= ~b_on;
- else
- ;
+ }
else if (VVP + 0.25 < BVP)
BrakeStatus |= b_on | b_hld;
@@ -707,7 +700,6 @@ double TWest::GetPF(double const PP, double const dt, double const Vel)
temp = BVP * int(EPS > 0);
dv = PF(temp, LBP, 0.0015) * dt * EPS * EPS * int(LBP * EPS < MaxBP * LoadC);
LBP = LBP - dv;
- dv = 0;
// przeplyw ZP <-> silowniki
if ((BrakeStatus & b_on) == b_on && (TareBP < 0.1 || BCP < MaxBP * LoadC))
@@ -781,20 +773,15 @@ void TWest::SetLBP(double const P)
/// New EP intensity.
void TWest::SetEPS(double const nEPS)
{
- double BCP;
- BCP = BrakeCyl->P();
if (nEPS > 0)
DCV = true;
- else if (nEPS == 0)
+ else if (nEPS == 0 && EPS != 0)
{
- if (EPS != 0)
- {
- if (LBP > 0.4)
- LBP = BrakeCyl->P();
- if (LBP < 0.15)
- LBP = 0;
- }
+ if (LBP > 0.4)
+ LBP = BrakeCyl->P();
+ if (LBP < 0.15)
+ LBP = 0;
}
EPS = nEPS;
}
@@ -838,12 +825,14 @@ void TESt::CheckReleaser(double const dt)
// odluzniacz
if ((BrakeStatus & b_rls) == b_rls)
+ {
if (CVP - VVP < 0)
BrakeStatus &= ~b_rls;
else
{
CntrlRes->Flow(+PF(CVP, 0, 0.1) * dt);
}
+ }
}
///
@@ -854,11 +843,10 @@ void TESt::CheckReleaser(double const dt)
///
/// Brake cylinder (or impulse-chamber) pressure.
/// In/out brake-pipe flow correction (unused in this base impl).
-void TESt::CheckState(double const BCP, double &dV1)
+void TESt::CheckState(double const BCP, double & /*dV1*/)
{
double const VVP{ValveRes->P()};
- double const BVP{BrakeRes->P()};
double const CVP{CntrlRes->P()};
// sprawdzanie stanu
@@ -927,7 +915,7 @@ void TESt::CheckState(double const BCP, double &dV1)
///
/// Brake cylinder (or impulse) pressure.
/// Opening coefficient (0 closed, 1 fully open).
-double TESt::CVs(double const BP)
+double TESt::CVs(double const BP) const
{
double VVP;
double BVP;
@@ -958,7 +946,7 @@ double TESt::CVs(double const BP)
///
/// Brake cylinder pressure.
/// Opening coefficient.
-double TESt::BVs(double const BCP)
+double TESt::BVs(double const BCP) const
{
double VVP;
double BVP;
@@ -1000,11 +988,8 @@ double TESt::GetPF(double const PP, double const dt, double const Vel)
double CVP;
BVP = BrakeRes->P();
- VVP = ValveRes->P();
BCP = BrakeCyl->P();
- CVP = CntrlRes->P() - 0.0;
- dv = 0;
dV1 = 0;
// sprawdzanie stanu
@@ -1086,7 +1071,7 @@ void TESt::Init(double const PP, double const HPP, double const LPP, double cons
/// derived variants and currently a no-op.
///
/// Characteristic value.
-void TESt::EStParams(double const i_crc) {}
+void TESt::EStParams(double const /*i_crc*/) const { /* no effect for this device type */ }
/// Returns the control reservoir (ZS) pressure.
double TESt::GetCRP()
@@ -1160,7 +1145,6 @@ double TEStEP2::GetPF(double const PP, double const dt, double const Vel)
BCP = ImplsRes->P();
CVP = CntrlRes->P(); // 110115 - konsultacje warszawa1
- dv = 0;
dV1 = 0;
// odluzniacz
@@ -1168,14 +1152,14 @@ double TEStEP2::GetPF(double const PP, double const dt, double const Vel)
// sprawdzanie stanu
if ((BrakeStatus & b_hld) == b_hld && BCP > 0.25)
+ {
if (VVP + 0.003 + BCP / BVM < CVP - 0.12)
BrakeStatus |= b_on; // hamowanie stopniowe;
else if (VVP - 0.003 + BCP / BVM > CVP - 0.12)
BrakeStatus &= ~(b_on | b_hld); // luzowanie;
else if (VVP + BCP / BVM > CVP - 0.12)
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
- else
- ;
+ }
else if (VVP + 0.10 < CVP - 0.12 && BCP < 0.25) // poczatek hamowania
{
// if ((BrakeStatus & 1) == 0)
@@ -1343,9 +1327,9 @@ void TEStEP1::SetEPS(double const nEPS)
double TESt3::GetPF(double const PP, double const dt, double const Vel)
{
double BVP{BrakeRes->P()};
- double VVP{ValveRes->P()};
+ double VVP;
double BCP{BrakeCyl->P()};
- double CVP{CntrlRes->P() - 0.0};
+ double CVP;
double dv{0.0};
double dV1{0.0};
@@ -1420,11 +1404,8 @@ double TESt4R::GetPF(double const PP, double const dt, double const Vel)
double CVP;
BVP = BrakeRes->P();
- VVP = ValveRes->P();
BCP = ImplsRes->P();
- CVP = CntrlRes->P();
- dv = 0;
dV1 = 0;
// sprawdzanie stanu
@@ -1543,11 +1524,9 @@ double TESt3AL2::GetPF(double const PP, double const dt, double const Vel)
double CVP;
BVP = BrakeRes->P();
- VVP = ValveRes->P();
BCP = ImplsRes->P();
CVP = CntrlRes->P() - 0.0;
- dv = 0;
dV1 = 0;
// sprawdzanie stanu
@@ -1715,8 +1694,7 @@ double TLSt::GetPF(double const PP, double const dt, double const Vel)
SoundFlag |= sf_CylU;
}
// equivalent of checkreleaser() in the base class?
- bool is_releasing = BrakeStatus & b_rls || UniversalFlag & TUniversalBrake::ub_Release;
- if (is_releasing)
+ if (bool is_releasing = BrakeStatus & b_rls || UniversalFlag & TUniversalBrake::ub_Release; is_releasing)
{
if (CVP < 0.0)
{
@@ -1934,14 +1912,14 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
else if (VVP + (BCP - 0.1) / BVM < CVP - 0.05 && BCP > 0.25) // zatrzymanie luzowania
BrakeStatus |= b_hld;
- if (VVP + 0.10 < CVP && BCP < 0.25) // poczatek hamowania
- if (!Przys_blok)
- {
- ValveRes->CreatePress(0.75 * VVP);
- SoundFlag |= sf_Acc;
- ValveRes->Act();
- Przys_blok = true;
- }
+ // poczatek hamowania
+ if (VVP + 0.10 < CVP && BCP < 0.25 && !Przys_blok)
+ {
+ ValveRes->CreatePress(0.75 * VVP);
+ SoundFlag |= sf_Acc;
+ ValveRes->Act();
+ Przys_blok = true;
+ }
if (BCP > 0.5)
Zamykajacy = true;
@@ -2069,7 +2047,6 @@ double TEStED::GetPF(double const PP, double const dt, double const Vel)
void TEStED::Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF)
{
TLSt::Init(PP, HPP, LPP, BP, BDF);
- int i;
ValveRes->CreatePress(PP);
BrakeCyl->CreatePress(BP);
@@ -2104,7 +2081,7 @@ void TEStED::Init(double const PP, double const HPP, double const LPP, double co
Nozzles[6] = 0.9;
{
- for (i = 0; i < 11; ++i)
+ for (int i = 0; i < 11; ++i)
{
Nozzles[i] = Nozzles[i] * Nozzles[i] * 3.14159 / 4000;
}
@@ -2165,14 +2142,14 @@ void TCV1::CheckState(double const BCP, double &dV1)
// sprawdzanie stanu
if ((BrakeStatus & b_hld) == b_hld)
+ {
if (VVP + 0.003 + BCP / BVM < CVP)
BrakeStatus |= b_on; // hamowanie stopniowe;
else if (VVP - 0.003 + BCP * 1.0 / BVM > CVP)
BrakeStatus &= ~(b_on | b_hld); // luzowanie;
else if (VVP + BCP * 1.0 / BVM > CVP)
BrakeStatus &= ~b_on; // zatrzymanie napelaniania;
- else
- ;
+ }
else if (VVP + 0.10 < CVP && BCP < 0.1) // poczatek hamowania
{
BrakeStatus |= b_on | b_hld;
@@ -2188,7 +2165,7 @@ void TCV1::CheckState(double const BCP, double &dV1)
///
/// Cylinder pressure.
/// Opening coefficient.
-double TCV1::CVs(double const BP)
+double TCV1::CVs(double const BP) const
{
// przeplyw ZS <-> PG
if (BP > 0.05)
@@ -2204,7 +2181,7 @@ double TCV1::CVs(double const BP)
///
/// Cylinder pressure.
/// Opening coefficient.
-double TCV1::BVs(double const BCP)
+double TCV1::BVs(double const BCP) const
{
double VVP;
double BVP;
@@ -2243,11 +2220,9 @@ double TCV1::GetPF(double const PP, double const dt, double const Vel)
double CVP;
BVP = BrakeRes->P();
- VVP = std::min(ValveRes->P(), BVP + 0.05);
BCP = BrakeCyl->P();
CVP = CntrlRes->P();
- dv = 0;
dV1 = 0;
// sprawdzanie stanu
@@ -2402,11 +2377,9 @@ double TCV1L_TR::GetPF(double const PP, double const dt, double const Vel)
double CVP;
BVP = BrakeRes->P();
- VVP = std::min(ValveRes->P(), BVP + 0.05);
BCP = ImplsRes->P();
CVP = CntrlRes->P();
- dv = 0;
dV1 = 0;
// sprawdzanie stanu
@@ -2488,10 +2461,12 @@ void TKE::CheckReleaser(double const dt)
// odluzniacz
if (true == ((BrakeStatus & b_rls) == b_rls))
+ {
if (CVP - VVP < 0)
BrakeStatus &= ~b_rls;
else
CntrlRes->Flow(+PF(CVP, 0, 0.1) * dt);
+ }
}
///
@@ -2502,13 +2477,11 @@ void TKE::CheckReleaser(double const dt)
///
/// Cylinder (or impulse-chamber) pressure.
/// In/out brake-pipe flow correction (unused here).
-void TKE::CheckState(double const BCP, double &dV1)
+void TKE::CheckState(double const BCP, double & /*dV1*/)
{
double VVP;
- double BVP;
double CVP;
- BVP = BrakeRes->P();
VVP = ValveRes->P();
CVP = CntrlRes->P();
@@ -2578,13 +2551,11 @@ void TKE::CheckState(double const BCP, double &dV1)
///
/// Cylinder (or impulse) pressure.
/// Opening coefficient.
-double TKE::CVs(double const BP)
+double TKE::CVs(double const BP) const
{
double VVP;
- double BVP;
double CVP;
- BVP = BrakeRes->P();
CVP = CntrlRes->P();
VVP = ValveRes->P();
@@ -2604,7 +2575,7 @@ double TKE::CVs(double const BP)
///
/// Impulse-chamber pressure.
/// Opening coefficient.
-double TKE::BVs(double const BCP)
+double TKE::BVs(double const /*BCP*/) const
{
double VVP;
double BVP;
@@ -2651,7 +2622,6 @@ double TKE::GetPF(double const PP, double const dt, double const Vel)
IMP = ImplsRes->P();
CVP = CntrlRes->P();
- dv = 0;
dV1 = 0;
// sprawdzanie stanu
@@ -2694,7 +2664,8 @@ double TKE::GetPF(double const PP, double const dt, double const Vel)
ImplsRes->Flow(-dv);
// rapid
- if (!(typeid(*FM) == typeid(TDisk1) || typeid(*FM) == typeid(TDisk2))) // jesli zeliwo to schodz
+ auto const &frictionmaterial{*FM};
+ if (auto const &frictionmaterialtype{typeid(frictionmaterial)}; !(frictionmaterialtype == typeid(TDisk1) || frictionmaterialtype == typeid(TDisk2))) // jesli zeliwo to schodz
RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R && (RV < 0 || (Vel > RV && RapidStatus) || Vel > RV + 20);
else // jesli tarczowki, to zostan
RapidStatus = (BrakeDelayFlag & bdelay_R) == bdelay_R;
@@ -2872,7 +2843,7 @@ void TDriverHandle::Init(double Press)
/// Default reductor adjustment — no-op.
/// Pressure correction.
-void TDriverHandle::SetReductor(double nAdj) {}
+void TDriverHandle::SetReductor(double nAdj) { /* no effect for this device type */ }
/// Default cab-gauge pressure — 0.
double TDriverHandle::GetCP()
@@ -2969,9 +2940,8 @@ double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
if (lround(i_bcp) == -1)
{
CP = CP + 5 * std::min(std::abs(LimPP - CP), 0.2) * PR(CP, LimPP) * dt / 2;
- if (CP < RP + 0.03)
- if (TP < 5)
- TP = TP + dt;
+ if (CP < RP + 0.03 && TP < 5)
+ TP = TP + dt;
// if(cp+0.03<5.4)then
if (RP + 0.03 < 5.4 || CP + 0.03 < 5.4) // fala
dpMainValve = PF(std::min(HP, 17.1), PP, ActFlowSpeed / LBDelay) * dt;
@@ -3037,11 +3007,10 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
int const LBDelay{100};
double const xpM{0.3}; // mnoznik membrany komory pod
- ep = PP / 2.0 * 1.5 + ep / 2.0 * 0.5; // SPKS!!
- for (int idx = 0; idx < 5; ++idx)
+ for (auto &soundvalue : Sounds)
{
- Sounds[idx] = 0;
+ soundvalue = 0;
}
// na wszelki wypadek, zeby nie wyszlo poza zakres
@@ -3134,13 +3103,9 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
}
}
- if (EQ(i_bcp, 0))
+ if (EQ(i_bcp, 0) && TP > 2)
{
-
- if (TP > 2)
- {
- dpMainValve *= 1.5;
- }
+ dpMainValve *= 1.5;
}
ep = dpPipe;
@@ -3239,16 +3204,16 @@ double TFV4aM::GetRP()
///
/// Continuous handle position.
/// Interpolated target pressure [bar].
-double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji;
+double TFV4aM::LPP_RP(double pos) const // cisnienie z zaokraglonej pozycji;
{
- int const i_pos = 2 + std::floor(pos); // zaokraglone w dol
+ auto const i_pos = static_cast(2 + std::floor(pos)); // zaokraglone w dol
return BPT[i_pos][1] + (BPT[i_pos + 1][1] - BPT[i_pos][1]) * (pos + 2 - i_pos); // interpolacja liniowa
}
/// Returns true if pos is within ±0.5 of i_pos (detent test).
/// Continuous handle position.
/// Detent centre.
-bool TFV4aM::EQ(double pos, double i_pos)
+bool TFV4aM::EQ(double pos, double i_pos) const
{
return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
}
@@ -3279,12 +3244,11 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep
double DP;
double pom;
- for (int idx = 0; idx < 5; ++idx)
+ for (auto &soundvalue : Sounds)
{
- Sounds[idx] = 0;
+ soundvalue = 0;
}
- DP = 0;
i_bcp = std::clamp(i_bcp, -0.999, 9.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
@@ -3425,7 +3389,7 @@ double TMHZ_EN57::GetEP(double pos)
///
/// Continuous handle position.
/// Target brake-pipe pressure [bar].
-double TMHZ_EN57::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji;
+double TMHZ_EN57::LPP_RP(double pos) const // cisnienie z zaokraglonej pozycji;
{
if (pos > 8.5)
return 5.0 - 0.15 * pos - 0.35;
@@ -3456,7 +3420,7 @@ void TMHZ_EN57::SetParams(bool AO, bool MO, double OverP, double, double OMP, do
}
/// Returns true if pos is within ±0.5 of i_pos (detent test).
-bool TMHZ_EN57::EQ(double pos, double i_pos)
+bool TMHZ_EN57::EQ(double pos, double i_pos) const
{
return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
}
@@ -3484,14 +3448,12 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double dpMainValve;
double ActFlowSpeed;
double DP;
- double pom;
- for (int idx = 0; idx < 5; ++idx)
+ for (auto &soundvalue : Sounds)
{
- Sounds[idx] = 0;
+ soundvalue = 0;
}
- DP = 0;
i_bcp = std::clamp(i_bcp, -0.999, 2.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
@@ -3512,7 +3474,6 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
LimCP = 3.4;
else // luzowanie
LimCP = 5.0;
- pom = CP;
LimCP = std::min(LimCP, HP); // pozycja + czasowy lub zasilanie
ActFlowSpeed = 4;
@@ -3636,7 +3597,7 @@ void TMHZ_K5P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP,
}
/// Returns true if pos is within ±0.5 of i_pos (detent test).
-bool TMHZ_K5P::EQ(double pos, double i_pos)
+bool TMHZ_K5P::EQ(double pos, double i_pos) const
{
return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
}
@@ -3663,14 +3624,12 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double dpMainValve;
double ActFlowSpeed;
double DP;
- double pom;
- for (int idx = 0; idx < 5; ++idx)
+ for (auto &soundvalue : Sounds)
{
- Sounds[idx] = 0;
+ soundvalue = 0;
}
- DP = 0;
i_bcp = std::clamp(i_bcp, -0.999, 3.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
@@ -3691,7 +3650,6 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
LimCP = 3.4;
else // luzowanie
LimCP = 5.0;
- pom = CP;
LimCP = std::min(LimCP, HP); // pozycja + czasowy lub zasilanie
ActFlowSpeed = 4;
@@ -3815,7 +3773,7 @@ void TMHZ_6P::SetParams(bool AO, bool MO, double OverP, double FSF, double OMP,
}
/// Returns true if pos is within ±0.5 of i_pos (detent test).
-bool TMHZ_6P::EQ(double pos, double i_pos)
+bool TMHZ_6P::EQ(double pos, double i_pos) const
{
return pos <= i_pos + 0.5 && pos > i_pos - 0.5;
}
@@ -3844,7 +3802,7 @@ double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double ActFlowSpeed;
int BCP;
- BCP = lround(i_bcp);
+ BCP = static_cast(lround(i_bcp));
if (BCP < -1)
BCP = 1;
@@ -3855,6 +3813,7 @@ double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
if (BCP == 0)
LimPP = LimPP + RedAdj;
if (BCP != 2)
+ {
if (CP < LimPP)
CP = CP + 4 * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
// cp:=cp+6*(2+int(bcp<0))*std::min(abs(Limpp-cp),0.05)*PR(cp,Limpp)*dt //zbiornik
@@ -3863,6 +3822,7 @@ double TM394::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
CP = CP - 0.2 * dt / 100;
else
CP = CP + 4 * (1 + int(BCP != 3) + int(BCP > 4)) * std::min(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
+ }
LimPP = CP;
dpPipe = std::min(HP, LimPP);
@@ -3937,7 +3897,7 @@ double TH14K1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
//{ (10, 0), (4, 1), (0, 1), (4, 0), (4, -1), (15, -1) };
double const NomPress = 5.0;
- int BCP = std::lround(i_bcp);
+ auto BCP = static_cast(std::lround(i_bcp));
if (i_bcp < -1)
{
BCP = 1;
@@ -4034,7 +3994,7 @@ double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
CP = PP;
- BCP = lround(i_bcp);
+ BCP = static_cast(lround(i_bcp));
EPS = BEP_K[BCP + 1];
diff --git a/McZapkie/hamulce.h b/McZapkie/hamulce.h
index a05a3635..3074a2e7 100644
--- a/McZapkie/hamulce.h
+++ b/McZapkie/hamulce.h
@@ -272,10 +272,11 @@ class TReservoir
/// Default constructor — creates a 1 L reservoir at zero pressure.
TReservoir() = default;
+ virtual ~TReservoir() = default;
};
/// Pointer typedef for a reservoir instance.
-typedef TReservoir *PReservoir;
+using PReservoir = TReservoir *;
///
/// Brake cylinder reservoir — overrides pressure functions to model the
@@ -290,15 +291,15 @@ class TBrakeCyl : public TReservoir
/// Returns absolute pressure inside the brake cylinder (P() * 0.1).
///
/// Absolute cylinder pressure.
- virtual double pa() /*override*/;
+ double pa() override;
///
/// Returns gauge pressure inside the brake cylinder, modelling the
/// piston-stroke pressure curve (dead volume, linear stroke, fully extended).
///
/// Cylinder pressure in bar.
- virtual double P() /*override*/;
+ double P() override;
/// Default constructor.
- TBrakeCyl() : TReservoir() {};
+ using TReservoir::TReservoir;
};
///
@@ -399,7 +400,7 @@ class TBrake
/// Returns the piston force produced by the brake cylinder pressure.
///
/// Force in arbitrary engine units (BCA * 100 * P).
- double GetBCF(); // sila tlokowa z tloka
+ double GetBCF() const; // sila tlokowa z tloka
///
/// Computes the airflow drawn from the high-pressure (8 bar / main) line for one step.
///
@@ -408,16 +409,16 @@ class TBrake
/// Net flow from the high-pressure line.
virtual double GetHPFlow(double const HP, double const dt); // przeplyw - 8 bar
/// Returns brake cylinder gauge pressure [bar].
- double GetBCP(); // cisnienie cylindrow hamulcowych
+ double GetBCP() const; // cisnienie cylindrow hamulcowych
///
/// Returns brake cylinder pressure originating only from the pneumatic
/// (main) brake — used to drive the ED (electrodynamic) brake e.g. in EP09.
///
virtual double GetEDBCP(); // cisnienie tylko z hamulca zasadniczego, uzywane do hamulca ED w EP09
/// Returns auxiliary reservoir (ZP) pressure [bar].
- double GetBRP(); // cisnienie zbiornika pomocniczego
+ double GetBRP() const; // cisnienie zbiornika pomocniczego
/// Returns valve pre-chamber pressure [bar].
- double GetVRP(); // cisnienie komory wstepnej rozdzielacza
+ double GetVRP() const; // cisnienie komory wstepnej rozdzielacza
/// Returns control reservoir (ZS) pressure [bar]; defaults to the auxiliary reservoir for valves without a dedicated ZS.
virtual double GetCRP(); // cisnienie zbiornika sterujacego
///
@@ -441,7 +442,7 @@ class TBrake
virtual void SetEPS(double const nEPS); // hamulec EP
/// Sets the rapid step ratio. Default no-op; overridden where supported.
/// Rapid ratio.
- virtual void SetRM(double const RMR) {}; // ustalenie przelozenia rapida
+ virtual void SetRM(double const RMR) { /* no effect for this device type */ } // ustalenie przelozenia rapida
/// Sets the velocity threshold for the rapid step.
/// Velocity threshold (same unit as Vel passed to GetPF).
virtual void SetRV(double const RVR)
@@ -455,20 +456,20 @@ class TBrake
/// Tare (empty) mass.
/// Loaded mass.
/// Brake cylinder pressure for the tare mass.
- virtual void SetLP(double const TM, double const LM, double const TBP) {}; // parametry przystawki wazacej
+ virtual void SetLP(double const TM, double const LM, double const TBP) { /* no effect for this device type */ } // parametry przystawki wazacej
/// Sets the auxiliary (local) brake target pressure.
/// Local brake pressure [bar].
- virtual void SetLBP(double const P) {}; // cisnienie z hamulca pomocniczego
+ virtual void SetLBP(double const P) { /* no effect for this device type */ } // cisnienie z hamulca pomocniczego
/// Updates the load-weighing pressure coefficient based on current vehicle mass.
/// Current vehicle mass.
- virtual void PLC(double const mass) {}; // wspolczynnik cisnienia przystawki wazacej
+ virtual void PLC(double const mass) { /* no effect for this device type */ } // wspolczynnik cisnienia przystawki wazacej
///
/// Engages the anti-slip brake function (set hold and/or release flags).
///
/// Two-bit value: bit1 = hold (b_asb), bit0 = release (b_asb_unbrake).
void ASB(int state); // hamulec przeciwposlizgowy
/// Returns the raw BrakeStatus flags (for sound/visual cues).
- int GetStatus(); // flaga statusu, moze sie przydac do odglosow
+ int GetStatus() const; // flaga statusu, moze sie przydac do odglosow
/// Sets the anti-slip target pressure.
/// Pressure [bar].
void SetASBP(double const Press); // ustalenie cisnienia pp
@@ -497,13 +498,14 @@ class TBrake
/// brake when ED braking is sufficient. Default no-op; overridden where supported.
///
/// ED brake intensity (0..1).
- virtual void SetED(double const EDstate) {}; // stan hamulca ED do luzowania
+ virtual void SetED(double const EDstate) { /* no effect for this device type */ } // stan hamulca ED do luzowania
/// Sets the universal-button flags (see TUniversalBrake).
/// Combined ub_* flags.
virtual void SetUniversalFlag(int flag)
{
UniversalFlag = flag;
} // przycisk uniwersalny
+ virtual ~TBrake() = default;
};
///
@@ -537,26 +539,26 @@ class TWest : public TBrake
/// Low pressure.
/// Initial cylinder pressure.
/// Initial brake delay flag.
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/;
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override;
/// Sets the auxiliary brake target pressure and engages the DCV when above cylinder.
/// Pressure [bar].
- void SetLBP(double const P); // cisnienie z hamulca pomocniczego
+ void SetLBP(double const P) override; // cisnienie z hamulca pomocniczego
/// One-step distributor advance (Westinghouse logic).
/// Net flow exchanged with the brake pipe.
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Returns the high-pressure flow drawn during the last GetPF step.
- double GetHPFlow(double const HP, double const dt) /*override*/;
+ double GetHPFlow(double const HP, double const dt) override;
/// Recomputes the load-weighing pressure coefficient for the current mass.
/// Vehicle mass.
- void PLC(double const mass); // wspolczynnik cisnienia przystawki wazacej
+ void PLC(double const mass) override; // wspolczynnik cisnienia przystawki wazacej
/// Sets the EP brake state and toggles the DCV / latches LBP from cylinder pressure on release.
/// New EP intensity.
- void SetEPS(double const nEPS) /*override*/; // stan hamulca EP
+ void SetEPS(double const nEPS) override; // stan hamulca EP
/// Stores the load-weighing parameters (TareM, LoadM, TareBP).
- void SetLP(double const TM, double const LM, double const TBP); // parametry przystawki wazacej
+ void SetLP(double const TM, double const LM, double const TBP) override; // parametry przystawki wazacej
/// Constructs the distributor by forwarding all parameters to TBrake.
- inline TWest(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {}
+ using TBrake::TBrake;
};
///
@@ -567,7 +569,6 @@ class TWest : public TBrake
class TESt : public TBrake
{
- private:
protected:
/// Control reservoir (ZS) — long-term reference pressure.
std::shared_ptr CntrlRes; // zbiornik sterujący
@@ -576,15 +577,15 @@ class TESt : public TBrake
public:
/// Initialises the ESt distributor; sizes the control reservoir (15 l) and computes BVM.
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/;
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override;
/// One-step distributor advance for the ESt baseline.
/// Net flow exchanged with the brake pipe.
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Sets ESt-specific characteristic parameters (placeholder; used by some variants).
/// Characteristic value.
- void EStParams(double i_crc); // parametry charakterystyczne dla ESt
+ void EStParams(double i_crc) const; // parametry charakterystyczne dla ESt
/// Returns the control reservoir (ZS) pressure.
- double GetCRP() /*override*/;
+ double GetCRP() override;
///
/// Updates BrakeStatus (b_on/b_hld) according to the relations between
/// pre-chamber, cylinder and control reservoir pressures (the main slide valve).
@@ -602,16 +603,16 @@ class TESt : public TBrake
///
/// Cylinder pressure (or impulse-chamber pressure).
/// Dimensionless opening coefficient.
- double CVs(double BP); // napelniacz sterujacego
+ double CVs(double BP) const; // napelniacz sterujacego
///
/// Returns the effective opening factor of the auxiliary-reservoir filling
/// slide valve (ZP <-> pre-chamber path).
///
/// Brake cylinder pressure.
/// Dimensionless opening coefficient.
- double BVs(double BCP); // napelniacz pomocniczego
+ double BVs(double BCP) const; // napelniacz pomocniczego
/// Vents the valve, brake and control reservoirs to zero.
- void ForceEmptiness() /*override*/; // wymuszenie bycia pustym
+ void ForceEmptiness() override; // wymuszenie bycia pustym
/// Constructs the ESt distributor and creates the control reservoir.
inline TESt(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
@@ -627,16 +628,15 @@ class TESt : public TBrake
class TESt3 : public TESt
{
- private:
// double CylFlowSpeed[2][2]; //zmienna nie uzywana
public:
/// One-step distributor advance for ESt3 (G/P-dependent fill/release curves).
/// Net flow exchanged with the brake pipe.
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Constructs the ESt3 distributor.
- inline TESt3(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {}
+ using TESt::TESt;
};
///
@@ -660,13 +660,13 @@ class TESt3AL2 : public TESt3
public:
/// Initialises the impulse chamber on top of the ESt initialisation.
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/;
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override;
/// One-step distributor advance for ESt3/AL2 with load-weighing relay.
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Recomputes LoadC for the current vehicle mass.
- void PLC(double const mass); // wspolczynnik cisnienia przystawki wazacej
+ void PLC(double const mass) override; // wspolczynnik cisnienia przystawki wazacej
/// Stores the load-weighing parameters.
- void SetLP(double const TM, double const LM, double const TBP); // parametry przystawki wazacej
+ void SetLP(double const TM, double const LM, double const TBP) override; // parametry przystawki wazacej
/// Constructs the distributor and creates the impulse chamber.
inline TESt3AL2(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt3(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
@@ -695,9 +695,9 @@ class TESt4R : public TESt
public:
/// Initialises the ESt4R; sizes the impulse chamber and selects the R delay.
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/;
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override;
/// One-step distributor advance for ESt4R (rapid step active above velocity threshold).
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Constructs the distributor and creates the impulse chamber.
inline TESt4R(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
@@ -713,7 +713,6 @@ class TESt4R : public TESt
class TLSt : public TESt4R
{
- private:
// double CylFlowSpeed[2][2]; // zmienna nie używana
protected:
@@ -726,24 +725,24 @@ class TLSt : public TESt4R
public:
/// Initialises the LSt; resizes the valve and impulse reservoirs and presets pressures.
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/;
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override;
/// Sets the auxiliary brake target pressure for the DCV.
- void SetLBP(double const P); // cisnienie z hamulca pomocniczego
+ void SetLBP(double const P) override; // cisnienie z hamulca pomocniczego
/// Sets the rapid step ratio (RM = 1 - RMR).
/// Reduction ratio (0 disables rapid, > 0 enables).
- void SetRM(double const RMR); // ustalenie przelozenia rapida
+ void SetRM(double const RMR) override; // ustalenie przelozenia rapida
/// One-step distributor advance for LSt (DCV + rapid + ED release).
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Computes the high-pressure inflow (replenishes the auxiliary reservoir from the main line).
- double GetHPFlow(double const HP, double const dt) /*override*/; // przeplyw - 8 bar
+ double GetHPFlow(double const HP, double const dt) override; // przeplyw - 8 bar
/// Returns the brake-cylinder reference pressure used by the ED brake controller (CVP-BCP * BVM).
- virtual double GetEDBCP(); // cisnienie tylko z hamulca zasadniczego, uzywane do hamulca ED w EP09
+ double GetEDBCP() override; // cisnienie tylko z hamulca zasadniczego, uzywane do hamulca ED w EP09
/// Sets the ED brake state used to relax the pneumatic brake.
/// ED intensity (0..1).
- virtual void SetED(double const EDstate); // stan hamulca ED do luzowania
+ void SetED(double const EDstate) override; // stan hamulca ED do luzowania
/// Constructs the LSt distributor.
- inline TLSt(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TESt4R(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {}
+ using TESt4R::TESt4R;
};
///
@@ -774,15 +773,15 @@ class TEStED : public TLSt
public:
/// Initialises the EStED — sets up Miedzypoj, ImplsRes and the nozzle characteristics.
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/;
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override;
/// One-step distributor advance for EStED (full EP09 logic with intermediate reservoir).
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Returns ED-brake reference pressure (ImplsRes pressure scaled by load coefficient).
- double GetEDBCP() /*override*/; // cisnienie tylko z hamulca zasadniczego, uzywane do hamulca ED
+ double GetEDBCP() override; // cisnienie tylko z hamulca zasadniczego, uzywane do hamulca ED
/// Recomputes LoadC for the current vehicle mass.
- void PLC(double const mass); // wspolczynnik cisnienia przystawki wazacej
+ void PLC(double const mass) override; // wspolczynnik cisnienia przystawki wazacej
/// Stores the load-weighing parameters.
- void SetLP(double const TM, double const LM, double const TBP); // parametry przystawki wazacej
+ void SetLP(double const TM, double const LM, double const TBP) override; // parametry przystawki wazacej
/// Constructs the distributor and creates the intermediate reservoir.
inline TEStED(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TLSt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
@@ -812,21 +811,21 @@ class TEStEP2 : public TLSt
public:
/// Initialises the EP2-equipped distributor (impulse chamber, P delay).
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/; // inicjalizacja
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override; // inicjalizacja
/// One-step distributor advance with EP2 EP brake logic.
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Recomputes LoadC for the current vehicle mass.
- void PLC(double const mass); // wspolczynnik cisnienia przystawki wazacej
+ void PLC(double const mass) override; // wspolczynnik cisnienia przystawki wazacej
/// Sets EP intensity; if EP is active and LBP < cylinder pressure, latches LBP from cylinder.
- void SetEPS(double const nEPS) /*override*/; // stan hamulca EP
+ void SetEPS(double const nEPS) override; // stan hamulca EP
/// Stores the load-weighing parameters.
- void SetLP(double const TM, double const LM, double const TBP); // parametry przystawki wazacej
+ void SetLP(double const TM, double const LM, double const TBP) override; // parametry przystawki wazacej
/// EP brake flow integration step. Override in EP1 for proportional control.
/// Time step [s].
void virtual EPCalc(double dt);
/// Constructs the EP2 distributor.
- inline TEStEP2(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TLSt(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa) {}
+ using TLSt::TLSt;
};
///
@@ -839,15 +838,13 @@ class TEStEP1 : public TEStEP2
public:
/// Proportional EP flow integration step (uses fractional part of EPS as the EP target).
- void EPCalc(double dt);
+ void EPCalc(double dt) override;
/// Stores the EP intensity.
/// Target EP value (integer part = direction, fractional part = magnitude).
void SetEPS(double const nEPS) override; // stan hamulca EP
/// Constructs the EP1 distributor.
- inline TEStEP1(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TEStEP2(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
- {
- }
+ using TEStEP2::TEStEP2;
};
///
@@ -867,21 +864,21 @@ class TCV1 : public TBrake
public:
/// Initialises the CV1 distributor (sizes ZS, sets pressures, computes BVM).
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/;
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override;
/// One-step distributor advance for the CV1 baseline.
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Returns the control reservoir (ZS) pressure.
- double GetCRP() /*override*/;
+ double GetCRP() override;
/// Updates BrakeStatus based on pre-chamber/cylinder/control reservoir relations and the releaser.
/// Cylinder (or impulse) pressure.
/// In/out brake pipe flow correction.
void CheckState(double const BCP, double &dV1);
/// Returns the ZS-filling slide valve opening factor for the given cylinder pressure.
- double CVs(double const BP);
+ double CVs(double const BP) const;
/// Returns the ZP-filling slide valve opening factor for the given cylinder pressure.
- double BVs(double const BCP);
+ double BVs(double const BCP) const;
/// Vents valve, brake and control reservoirs to zero.
- void ForceEmptiness() /*override*/; // wymuszenie bycia pustym
+ void ForceEmptiness() override; // wymuszenie bycia pustym
/// Constructs the CV1 distributor and creates the control reservoir.
inline TCV1(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
@@ -922,13 +919,13 @@ class TCV1L_TR : public TCV1
public:
/// Initialises the CV1-L-TR (sizes the impulse chamber on top of CV1::Init).
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/;
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override;
/// One-step distributor advance for CV1-L-TR (impulse chamber + DCV).
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Sets the auxiliary brake target pressure for the DCV.
- void SetLBP(double const P); // cisnienie z hamulca pomocniczego
+ void SetLBP(double const P) override; // cisnienie z hamulca pomocniczego
/// Computes the high-pressure (8 bar) inflow used to replenish the auxiliary reservoir.
- double GetHPFlow(double const HP, double const dt) /*override*/; // przeplyw - 8 bar
+ double GetHPFlow(double const HP, double const dt) override; // przeplyw - 8 bar
/// Constructs the CV1-L-TR and creates the impulse chamber.
inline TCV1L_TR(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TCV1(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
@@ -971,31 +968,31 @@ class TKE : public TBrake
public:
/// Initialises the KE distributor (control / impulse / auxiliary reservoirs and BVM).
- void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) /*override*/;
+ void Init(double const PP, double const HPP, double const LPP, double const BP, int const BDF) override;
/// Sets the rapid step ratio (RM = 1 - RMR).
- void SetRM(double const RMR); // ustalenie przelozenia rapida
+ void SetRM(double const RMR) override; // ustalenie przelozenia rapida
/// One-step distributor advance for the KE distributor.
- double GetPF(double const PP, double const dt, double const Vel) /*override*/; // przeplyw miedzy komora wstepna i PG
+ double GetPF(double const PP, double const dt, double const Vel) override; // przeplyw miedzy komora wstepna i PG
/// Computes the high-pressure (8 bar) inflow used to replenish the auxiliary reservoir.
- double GetHPFlow(double const HP, double const dt) /*override*/; // przeplyw - 8 bar
+ double GetHPFlow(double const HP, double const dt) override; // przeplyw - 8 bar
/// Returns the control reservoir (ZS) pressure.
- double GetCRP() /*override*/;
+ double GetCRP() override;
/// Updates BrakeStatus from cylinder/pre-chamber/control reservoir pressures (KE-specific thresholds).
void CheckState(double const BCP, double &dV1);
/// Drives the releaser logic for KE — bleeds the control reservoir while engaged.
void CheckReleaser(double const dt); // odluzniacz
/// ZS-filling slide valve opening factor for the given cylinder pressure.
- double CVs(double const BP); // napelniacz sterujacego
+ double CVs(double const BP) const; // napelniacz sterujacego
/// ZP-filling slide valve opening factor for the given cylinder pressure.
- double BVs(double const BCP); // napelniacz pomocniczego
+ double BVs(double const BCP) const; // napelniacz pomocniczego
/// Recomputes LoadC for the current vehicle mass.
- void PLC(double const mass); // wspolczynnik cisnienia przystawki wazacej
+ void PLC(double const mass) override; // wspolczynnik cisnienia przystawki wazacej
/// Stores the load-weighing parameters.
- void SetLP(double const TM, double const LM, double const TBP); // parametry przystawki wazacej
+ void SetLP(double const TM, double const LM, double const TBP) override; // parametry przystawki wazacej
/// Sets the auxiliary brake target pressure for the DCV.
- void SetLBP(double const P); // cisnienie z hamulca pomocniczego
+ void SetLBP(double const P) override; // cisnienie z hamulca pomocniczego
/// Vents valve, brake, control, impulse and secondary auxiliary reservoirs to zero.
- void ForceEmptiness() /*override*/; // wymuszenie bycia pustym
+ void ForceEmptiness() override; // wymuszenie bycia pustym
/// Constructs the KE distributor and creates the control / impulse / secondary reservoirs.
inline TKE(double i_mbp, double i_bcr, double i_bcd, double i_brc, int i_bcn, int i_BD, int i_mat, int i_ba, int i_nbpa) : TBrake(i_mbp, i_bcr, i_bcd, i_brc, i_bcn, i_BD, i_mat, i_ba, i_nbpa)
@@ -1077,7 +1074,7 @@ class TDriverHandle
/// Unbrake over-pressure [bar].
/// Overload (assimilation) max pressure [bar].
/// Overload pressure decay rate [bar/s].
- virtual void SetParams(bool AO, bool MO, double, double, double OMP, double OPD) {}; // ustawianie jakichs parametrow dla zaworu
+ virtual void SetParams(bool AO, bool MO, double, double, double OMP, double OPD) { /* no effect for this device type */ } // ustawianie jakichs parametrow dla zaworu
/// Sets the manual overcharge button state.
/// True while the button is pressed.
virtual void OvrldButton(bool Active); // przycisk recznego przeladowania/asymilacji
@@ -1089,6 +1086,7 @@ class TDriverHandle
{
memset(Sounds, 0, sizeof(Sounds));
}
+ virtual ~TDriverHandle() = default;
};
///
@@ -1107,12 +1105,12 @@ class TFV4a : public TDriverHandle
public:
/// Computes brake pipe flow for the FV4a handle (uses BPT[] table).
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises CP and RP to the supplied pressure.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Default constructor.
- inline TFV4a() : TDriverHandle() {}
+ using TDriverHandle::TDriverHandle;
};
///
@@ -1143,27 +1141,27 @@ class TFV4aM : public TDriverHandle
/// Returns the brake pipe pressure target interpolated from BPT[] for the given handle position.
///
/// Handle position.
- double LPP_RP(double pos);
+ double LPP_RP(double pos) const;
/// Returns true if pos is within ±0.5 of i_pos (detent comparison).
- bool EQ(double pos, double i_pos);
+ bool EQ(double pos, double i_pos) const;
public:
/// Computes brake pipe flow for the FV4a/M handle (interpolated BPT, wave modelling, accelerator).
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises CP and RP.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Sets the reductor adjustment offset.
- void SetReductor(double nAdj) /*override*/;
+ void SetReductor(double nAdj) override;
/// Returns Sounds[i] (or 0 if i > 4).
- double GetSound(int i) /*override*/;
+ double GetSound(int i) override;
/// Returns pos_table[i].
- double GetPos(int i) /*override*/;
+ double GetPos(int i) override;
/// Returns the time chamber pressure (TP).
- double GetCP();
+ double GetCP() override;
/// Returns the regulator pressure (5 + TP*0.08 + RedAdj).
- double GetRP();
+ double GetRP() override;
/// Default constructor.
- inline TFV4aM() : TDriverHandle() {}
+ using TDriverHandle::TDriverHandle;
};
///
@@ -1193,32 +1191,31 @@ class TMHZ_EN57 : public TDriverHandle
static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 };
/// Returns the brake pipe pressure target for the given handle position (piecewise).
- double LPP_RP(double pos);
+ double LPP_RP(double pos) const;
/// Returns true if pos is within ±0.5 of i_pos.
- bool EQ(double pos, double i_pos);
+ bool EQ(double pos, double i_pos) const;
public:
/// Computes brake pipe flow for MHZ_EN57 (covers handle positions -1..10 with EP/pneumatic mix).
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises CP.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Sets the reductor adjustment offset.
- void SetReductor(double nAdj) /*override*/;
+ void SetReductor(double nAdj) override;
/// Returns Sounds[i] (or 0 if i > 4).
- double GetSound(int i) /*override*/;
+ double GetSound(int i) override;
/// Returns pos_table[i].
- double GetPos(int i) /*override*/;
+ double GetPos(int i) override;
/// Returns the regulator pressure (RP).
- double GetCP() /*override*/;
+ double GetCP() override;
/// Returns the regulator target (5 + RedAdj).
- double GetRP() /*override*/;
+ double GetRP() override;
/// Returns EP brake intensity for the given handle position.
- double GetEP(double pos);
+ double GetEP(double pos) override;
/// Configures handle parameters (auto/manual overcharge, over-pressure, overcharge dynamics).
- void SetParams(bool AO, bool MO, double OverP, double, double OMP, double OPD);
+ void SetParams(bool AO, bool MO, double OverP, double, double OMP, double OPD) override;
/// Default constructor.
- inline TMHZ_EN57(void) : TDriverHandle() {}
-};
+ using TDriverHandle::TDriverHandle;};
///
/// MHZ_K5P — Knorr 5-position combined brake handle.
@@ -1232,7 +1229,6 @@ class TMHZ_K5P : public TDriverHandle
/// Time chamber pressure [bar].
double TP = 0.0; // zbiornik czasowy
/// Reductor reservoir pressure [bar].
- double RP = 0.0; // zbiornik redukcyjny
/// Reductor adjustment offset.
double RedAdj = 0.0; // dostosowanie reduktora cisnienia (krecenie kapturkiem)
/// True while filling-stroke / release wave is active.
@@ -1249,29 +1245,28 @@ class TMHZ_K5P : public TDriverHandle
static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 };
/// Returns true if pos is within ±0.5 of i_pos.
- bool EQ(double pos, double i_pos);
+ bool EQ(double pos, double i_pos) const;
public:
/// Computes brake pipe flow for the K5P 5-position handle (release / cut-off / brake / emergency).
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises CP and enables the time chambers.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Sets the reductor adjustment offset.
- void SetReductor(double nAdj) /*override*/;
+ void SetReductor(double nAdj) override;
/// Returns Sounds[i] (or 0 if i > 4).
- double GetSound(int i) /*override*/;
+ double GetSound(int i) override;
/// Returns pos_table[i].
- double GetPos(int i) /*override*/;
+ double GetPos(int i) override;
/// Returns CP.
- double GetCP() /*override*/;
+ double GetCP() override;
/// Returns the regulator target (5 + TP + RedAdj).
- double GetRP() /*override*/;
+ double GetRP() override;
/// Configures handle parameters (auto/manual overcharge, over-pressure, filling-stroke factor, overcharge dynamics).
- void SetParams(bool AO, bool MO, double, double, double OMP, double OPD); /*ovveride*/
+ void SetParams(bool AO, bool MO, double, double, double OMP, double OPD) override;
/// Default constructor.
- inline TMHZ_K5P(void) : TDriverHandle() {}
-};
+ using TDriverHandle::TDriverHandle;};
///
/// MHZ_6P — 6-position combined brake handle (similar logic to K5P with one more detent).
@@ -1285,7 +1280,6 @@ class TMHZ_6P : public TDriverHandle
/// Time chamber pressure [bar].
double TP = 0.0; // zbiornik czasowy
/// Reductor reservoir pressure [bar].
- double RP = 0.0; // zbiornik redukcyjny
/// Reductor adjustment offset.
double RedAdj = 0.0; // dostosowanie reduktora cisnienia (krecenie kapturkiem)
/// True while filling-stroke / release wave is active.
@@ -1302,29 +1296,28 @@ class TMHZ_6P : public TDriverHandle
static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 };
/// Returns true if pos is within ±0.5 of i_pos.
- bool EQ(double pos, double i_pos);
+ bool EQ(double pos, double i_pos) const;
public:
/// Computes brake pipe flow for the 6P handle.
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises CP and enables the time chambers.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Sets the reductor adjustment offset.
- void SetReductor(double nAdj) /*override*/;
+ void SetReductor(double nAdj) override;
/// Returns Sounds[i] (or 0 if i > 4).
- double GetSound(int i) /*override*/;
+ double GetSound(int i) override;
/// Returns pos_table[i].
- double GetPos(int i) /*override*/;
+ double GetPos(int i) override;
/// Returns CP.
- double GetCP() /*override*/;
+ double GetCP() override;
/// Returns the regulator target (5 + TP + RedAdj).
- double GetRP() /*override*/;
+ double GetRP() override;
/// Configures handle parameters (auto/manual overcharge, over-pressure, filling-stroke factor, overcharge dynamics).
- void SetParams(bool AO, bool MO, double, double, double OMP, double OPD); /*ovveride*/
+ void SetParams(bool AO, bool MO, double, double, double OMP, double OPD) override;
/// Default constructor.
- inline TMHZ_6P(void) : TDriverHandle() {}
-};
+ using TDriverHandle::TDriverHandle;};
/* FBS2= class(TTDriverHandle)
private
@@ -1372,17 +1365,17 @@ class TM394 : public TDriverHandle
public:
/// Computes brake pipe flow for the M394 handle (uses BPT_394).
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises CP and enables the time chamber.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Sets the reductor adjustment offset.
- void SetReductor(double nAdj) /*override*/;
+ void SetReductor(double nAdj) override;
/// Returns CP.
- double GetCP() /*override*/;
+ double GetCP() override;
/// Returns max(5, CP) + RedAdj.
- double GetRP() /*override*/;
+ double GetRP() override;
/// Returns pos_table[i].
- double GetPos(int i) /*override*/;
+ double GetPos(int i) override;
/// Default constructor — sets the maximum handle position to 5.
inline TM394(void) : TDriverHandle()
@@ -1411,17 +1404,17 @@ class TH14K1 : public TDriverHandle
public:
/// Computes brake pipe flow for the H14K1 handle.
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises CP and enables the time chambers.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Sets the reductor adjustment offset.
- void SetReductor(double nAdj) /*override*/;
+ void SetReductor(double nAdj) override;
/// Returns CP.
- double GetCP() /*override*/;
+ double GetCP() override;
/// Returns the regulator target (5 + RedAdj).
- double GetRP() /*override*/;
+ double GetRP() override;
/// Returns pos_table[i].
- double GetPos(int i) /*override*/;
+ double GetPos(int i) override;
/// Default constructor — sets the maximum handle position to 4.
inline TH14K1(void) : TDriverHandle()
@@ -1450,21 +1443,20 @@ class TSt113 : public TH14K1
public:
/// Computes brake pipe flow for the St113 handle (with EP).
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Returns CP.
- double GetCP() /*override*/;
+ double GetCP() override;
/// Returns the regulator target (5 + RedAdj).
- double GetRP() /*override*/;
+ double GetRP() override;
/// Returns the current EP intensity.
- double GetEP() /*override*/;
+ double GetEP() override;
/// Returns pos_table[i].
- double GetPos(int i) /*override*/;
+ double GetPos(int i) override;
/// Enables the time chambers (no pressure init).
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Default constructor.
- inline TSt113(void) : TH14K1() {}
-};
+ using TH14K1::TH14K1;};
///
/// Test handle — minimal implementation used during development for verifying
@@ -1479,13 +1471,12 @@ class Ttest : public TDriverHandle
public:
/// Computes brake pipe flow using the FV4a-style BPT table for testing.
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises CP.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Default constructor.
- inline Ttest(void) : TDriverHandle() {}
-};
+ using TDriverHandle::TDriverHandle;};
///
/// FD1 auxiliary brake handle — directly drives the cylinder pressure between
@@ -1505,18 +1496,17 @@ class TFD1 : public TDriverHandle
double Speed = 0.0; // szybkosc dzialania
/// Computes the auxiliary brake outflow for this step.
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises MaxBP and the action speed.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Returns the currently commanded cylinder pressure (BP).
- double GetCP() /*override*/;
+ double GetCP() override;
/// Sets the action speed multiplier.
void SetSpeed(double nSpeed);
// procedure Init(press: real; MaxBP: real); overload;
/// Default constructor.
- inline TFD1(void) : TDriverHandle() {}
-};
+ using TDriverHandle::TDriverHandle;};
///
/// H1405 — Knorr auxiliary brake handle (continuous, independent brake).
@@ -1532,16 +1522,15 @@ class TH1405 : public TDriverHandle
public:
/// Computes the auxiliary brake outflow for this step (proportional to handle deflection).
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Initialises MaxBP and enables the time chamber.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Returns the currently commanded cylinder pressure (BP).
- double GetCP() /*override*/;
+ double GetCP() override;
// procedure Init(press: real; MaxBP: real); overload;
/// Default constructor.
- inline TH1405(void) : TDriverHandle() {}
-};
+ using TDriverHandle::TDriverHandle;};
///
/// FVel6 — combined EP + pneumatic brake handle (Czech, 6+1 positions).
@@ -1559,23 +1548,22 @@ class TFVel6 : public TDriverHandle
public:
/// Computes brake pipe flow for FVel6 (continuous EP brake plus pneumatic emergency).
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Returns CP.
- double GetCP() /*override*/;
+ double GetCP() override;
/// Returns the regulator target (constant 5 bar).
- double GetRP() /*override*/;
+ double GetRP() override;
/// Returns the current EP intensity.
- double GetEP() /*override*/;
+ double GetEP() override;
/// Returns pos_table[i].
- double GetPos(int i) /*override*/;
+ double GetPos(int i) override;
/// Returns Sounds[i] (or 0 if i > 2).
- double GetSound(int i) /*override*/;
+ double GetSound(int i) override;
/// Enables the time chambers.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Default constructor.
- inline TFVel6(void) : TDriverHandle() {}
-};
+ using TDriverHandle::TDriverHandle;};
///
/// FVE408 — newer combined EP + pneumatic brake handle (10 positions).
@@ -1594,23 +1582,22 @@ class TFVE408 : public TDriverHandle
public:
/// Computes brake pipe flow for the FVE408 handle.
- double GetPF(double i_bcp, double PP, double HP, double dt, double ep) /*override*/;
+ double GetPF(double i_bcp, double PP, double HP, double dt, double ep) override;
/// Returns CP.
- double GetCP() /*override*/;
+ double GetCP() override;
/// Returns the current EP intensity.
- double GetEP() /*override*/;
+ double GetEP() override;
/// Returns the regulator target (constant 5 bar).
- double GetRP() /*override*/;
+ double GetRP() override;
/// Returns pos_table[i].
- double GetPos(int i) /*override*/;
+ double GetPos(int i) override;
/// Returns Sounds[i] (or 0 if i > 2).
- double GetSound(int i) /*override*/;
+ double GetSound(int i) override;
/// Enables the time chamber, disables the EP-time chamber.
- void Init(double Press) /*override*/;
+ void Init(double Press) override;
/// Default constructor.
- inline TFVE408(void) : TDriverHandle() {}
-};
+ using TDriverHandle::TDriverHandle;};
///
/// Pneumatic flow rate from one pressure to another through an orifice of area S.
diff --git a/application/applicationmode.h b/application/applicationmode.h
index feea3bdb..4f32fc5f 100644
--- a/application/applicationmode.h
+++ b/application/applicationmode.h
@@ -25,19 +25,19 @@ public:
virtual bool update() = 0;
// draws mode-specific user interface
inline
- void render_ui() {
+ void render_ui() const {
if( m_userinterface != nullptr ) {
m_userinterface->render(); } }
inline
- void begin_ui_frame() {
+ void begin_ui_frame() const {
if( m_userinterface != nullptr ) {
m_userinterface->begin_ui_frame(); } }
inline
- void set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) {
+ void set_progress( float const Progress = 0.f, float const Subtaskprogress = 0.f ) const {
if( m_userinterface != nullptr ) {
m_userinterface->set_progress( Progress, Subtaskprogress ); } }
inline
- void set_tooltip( std::string const &Tooltip ) {
+ void set_tooltip( std::string const &Tooltip ) const {
if( m_userinterface != nullptr ) {
m_userinterface->set_tooltip( Tooltip ); } }
// maintenance method, called when the mode is activated
diff --git a/application/driverhints.cpp b/application/driverhints.cpp
index afa654cf..bcfd7dbd 100644
--- a/application/driverhints.cpp
+++ b/application/driverhints.cpp
@@ -38,7 +38,7 @@ void
TController::remove_hint( driver_hint const Value ) {
m_hints.remove_if(
- [=]( auto const &Hint ) {
+ [Value]( auto const &Hint ) {
return std::get(Hint) == Value; } );
}
@@ -87,7 +87,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::batteryoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == true; } );
break;
}
@@ -98,7 +98,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::batteryon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->BatteryStart != start_t::manual || mvOccupied->Power24vIsAvailable == false; } );
break;
}
@@ -111,7 +111,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::cabdeactivation );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->AutomaticCabActivation || mvOccupied->IsCabMaster(); } );
break;
}
@@ -122,7 +122,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::cabactivation );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->AutomaticCabActivation || (mvOccupied->CabMaster == false && mvOccupied->CabActive == 0); } );
break;
}
@@ -134,7 +134,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::radiooff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->Radio == true; } );
break;
}
@@ -144,7 +144,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const Parameter) {
return iRadioChannel == static_cast(Parameter); },
Actionparameter );
break;
@@ -156,7 +156,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::radioon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->Radio == false; } );
break;
}
@@ -168,7 +168,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::oilpumpoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvOccupied->OilPump };
return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true || mvOccupied->Mains; } );
break;
@@ -180,7 +180,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::oilpumpon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvOccupied->OilPump };
return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
break;
@@ -193,7 +193,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::fuelpumpoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvOccupied->FuelPump };
return device.start_type != start_t::manual || device.is_enabled == true || device.is_active == true; } );
break;
@@ -205,7 +205,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::fuelpumpon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvOccupied->FuelPump };
return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
break;
@@ -218,7 +218,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::pantographairsourcesetauxiliary );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvPantographUnit->bPantKurek3 == true; } );
break;
}
@@ -229,7 +229,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::pantographcompressoron );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvPantographUnit->bPantKurek3 == false; } );
break;
}
@@ -240,7 +240,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::pantographcompressoroff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvPantographUnit->PantCompFlag == true; } );
break;
}
@@ -251,7 +251,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::pantographcompressoron );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvPantographUnit->PantCompFlag == false; } );
break;
}
@@ -262,7 +262,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::pantographsvalveoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvPantographUnit->PantsValve.is_active == true; } );
break;
}
@@ -273,7 +273,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::frontpantographvalveoff );
hint(
Action,
- [ this ]( float const Parameter ) -> bool {
+ [ this ]( float const Parameter ) {
return mvPantographUnit->Pantographs[end::front].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); },
Actionparameter );
break;
@@ -285,7 +285,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::frontpantographvalveon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvPantographUnit->Pantographs[end::front].valve.is_active == false; } );
break;
}
@@ -296,7 +296,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::rearpantographvalveoff );
hint(
Action,
- [ this ]( float const Parameter ) -> bool {
+ [ this ]( float const Parameter ) {
return mvPantographUnit->Pantographs[end::rear].valve.is_active == true || (Parameter > 0 && mvOccupied->Vel > Parameter); },
Actionparameter );
break;
@@ -308,7 +308,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::rearpantographvalveon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvPantographUnit->Pantographs[end::rear].valve.is_active == false; } );
break;
}
@@ -320,7 +320,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::converteroff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyConverterEnabled == true; } );
break;
}
@@ -331,7 +331,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::converteron );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyConverterExplicitlyEnabled == false; } );
break;
}
@@ -342,7 +342,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->ConverterOverloadRelayStart != start_t::manual || mvOccupied->ConvOvldFlag == false; } );
break;
}
@@ -352,7 +352,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->GroundRelayStart != start_t::manual || mvOccupied->GroundRelay == true; } );
break;
}
@@ -362,7 +362,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->FuseFlag == false; } );
break;
}
@@ -374,7 +374,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::linebreakeropen );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyLineBreakerOpen == false; } );
break;
}
@@ -385,7 +385,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::linebreakerclose );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
// TBD, TODO: replace with consist-wide flag set true if any line breaker is closed?
return mvControlling->Mains == false; } );
break;
@@ -398,7 +398,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::compressoroff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyCompressorEnabled == true; } );
break;
}
@@ -409,7 +409,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::compressoron );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyCompressorExplicitlyEnabled == false; } );
break;
}
@@ -421,7 +421,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::frontmotorblowersoff );
hint(
Action,
- [this]( float const Parameter ) -> bool {
+ [this]( float const /*Parameter*/ ) {
auto const &device { mvOccupied->MotorBlowers[ end::front ] };
return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } );
break;
@@ -434,7 +434,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::rearmotorblowersoff );
hint(
Action,
- [this]( float const Parameter ) -> bool {
+ [this]( float const /*Parameter*/ ) {
auto const &device { mvOccupied->MotorBlowers[ end::rear ] };
return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false); } );
break;
@@ -447,7 +447,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::springbrakeoff );
hint(
Action,
- [this]( float const Parameter ) -> bool {
+ [this]( float const /*Parameter*/ ) {
return mvOccupied->SpringBrake.Activate == true; } );
break;
}
@@ -458,7 +458,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::springbrakeon );
hint(
Action,
- [this]( float const Parameter ) -> bool {
+ [this]( float const /*Parameter*/ ) {
return mvOccupied->SpringBrake.Activate == false; } );
break;
}
@@ -470,7 +470,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::manualbrakoff );
hint(
Action,
- [this]( float const Parameter ) -> bool {
+ [this]( float const /*Parameter*/ ) {
return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == ManualBrakePosNo; } );
break;
}
@@ -481,7 +481,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::manualbrakon );
hint(
Action,
- [this]( float const Parameter ) -> bool {
+ [this]( float const /*Parameter*/ ) {
return mvOccupied->LocalBrake != TLocalBrake::ManualBrake || mvOccupied->MBrake == false || mvOccupied->ManualBrakePos == 0; } );
break;
}
@@ -490,33 +490,31 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
if( AIControllFlag ) {
while( mvControlling->RList[mvControlling->MainCtrlPos].Mn == 0
&& mvControlling->IncMainCtrl(1) ) {
- ;
+ // all work is done in the loop header
}
}
remove_master_controller_hints();
hint(
Action,
- [this]( float const Parameter ) -> bool {
+ [this]( float const /*Parameter*/ ) {
return mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0; } );
break;
}
case driver_hint::mastercontrollersetseriesmode: {
- if( AIControllFlag ) {
- if( mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1 ) {
- // limit yourself to series mode
- if( mvControlling->ScndCtrlPos ) {
- mvControlling->DecScndCtrl( 2 );
- }
- while( mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1
- && mvControlling->DecMainCtrl(1) ) {
- ; // all work is performed in the header
- }
+ if (AIControllFlag && mvControlling->RList[ mvControlling->MainCtrlPos ].Bn > 1) {
+ // limit yourself to series mode
+ if( mvControlling->ScndCtrlPos ) {
+ mvControlling->DecScndCtrl( 2 );
+ }
+ while( mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1
+ && mvControlling->DecMainCtrl(1) ) {
+ // all work is performed in the header
}
}
remove_master_controller_hints();
hint(
Action,
- [this]( float const Parameter ) -> bool {
+ [this]( float const /*Parameter*/ ) {
return mvControlling->RList[mvControlling->MainCtrlPos].Bn < 2; } );
break;
}
@@ -527,7 +525,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_master_controller_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvControlling->IsMainCtrlNoPowerPos() && mvControlling->IsScndCtrlNoPowerPos(); } );
break;
}
@@ -535,15 +533,15 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
if( AIControllFlag ) {
while( false == mvControlling->EIMDirectionChangeAllow()
&& mvControlling->DecMainCtrl(1) ) {
- ;
+ // all work is done in the loop header
}
}
remove_master_controller_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvControlling->EIMDirectionChangeAllow(); },
- mvControlling->MainCtrlMaxDirChangePos );
+ static_cast(mvControlling->MainCtrlMaxDirChangePos) );
break;
}
case driver_hint::tractiveforcedecrease: {
@@ -553,13 +551,13 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_master_controller_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const Parameter) {
return std::abs(mvControlling->Ft) <= Parameter; },
- std::min(
+ static_cast(std::min(
0.0,
std::max(
std::abs( mvControlling->Ft ) * 0.95,
- std::abs( mvControlling->Ft ) - 5.0 ) ) );
+ std::abs( mvControlling->Ft ) - 5.0 ) )) );
break;
}
case driver_hint::tractiveforceincrease: {
@@ -575,21 +573,19 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return AccDesired <= EU07_AI_NOACCELERATION || (false == Ready && false == mvOccupied->ShuntMode) || AccDesired - AbsAccS <= 0.05 ||
(mvOccupied->EIMCtrlType > 0 ? mvControlling->eimic_real >= 1.0 : mvControlling->IsScndCtrlMaxPowerPos() && mvControlling->IsMainCtrlMaxPowerPos()); } );
break;
}
case driver_hint::bufferscompress: {
- if( AIControllFlag ) {
- if( std::abs( mvControlling->Ft ) < 50000.0 ) {
- IncSpeed();
- }
+ if (AIControllFlag && std::abs( mvControlling->Ft ) < 50000.0) {
+ IncSpeed();
}
remove_master_controller_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return std::abs(mvControlling->Ft) > 30.0 || (OrderCurrentGet() & Disconnect) == 0; } );
break;
}
@@ -601,7 +597,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_master_controller_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvControlling->IsScndCtrlNoPowerPos(); } );
break;
}
@@ -613,7 +609,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::waterpumpoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvControlling->WaterPump };
return device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false) || device.is_active == true; } );
break;
@@ -625,7 +621,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::waterpumpon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvControlling->WaterPump };
return device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
break;
@@ -637,7 +633,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::waterpumpbreakeroff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvControlling->WaterPump };
return device.breaker == true; } );
break;
@@ -649,7 +645,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::waterpumpbreakeron );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvControlling->WaterPump };
return device.breaker == false; } );
break;
@@ -661,7 +657,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::waterheateroff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvControlling->WaterHeater };
return device.is_enabled == true; } );
break;
@@ -673,7 +669,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::waterheateron );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvControlling->WaterHeater };
return device.is_enabled == false; } );
break;
@@ -685,7 +681,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::waterheaterbreakeroff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvControlling->WaterHeater };
return device.breaker == true; } );
break;
@@ -697,7 +693,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::waterheaterbreakeron );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvControlling->WaterHeater };
return device.breaker == false; } );
break;
@@ -709,7 +705,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::watercircuitslinkoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == true; } );
break;
}
@@ -720,7 +716,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::watercircuitslinkon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvControlling->dizel_heat.auxiliary_water_circuit == false || mvControlling->WaterCircuitsLink == false; } );
break;
}
@@ -728,7 +724,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
// NOTE: this action doesn't have AI component
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return false == IsHeatingTemperatureTooLow; } );
break;
}
@@ -736,7 +732,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
// NOTE: this action doesn't have AI component
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvControlling->ScndPipePress > 4.5 || mvControlling->VeselVolume == 0.0; } );
break;
}
@@ -744,7 +740,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
// NOTE: this action doesn't have AI component
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvPantographUnit->PantPress >= (is_emu() ? (mvPantographUnit->PantPressLockActive ? 4.6 : 2.6) : 4.2); } );
break;
}
@@ -752,7 +748,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
// NOTE: this action doesn't have AI component
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return ExchangeTime <= 0; } );
break;
}
@@ -760,7 +756,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
// NOTE: this action doesn't have AI component
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAtPassengerStop == false; } );
break;
}
@@ -773,19 +769,16 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
// driver_hint_brakingforcesetzero
// driver_hint_brakingforcelap
case driver_hint::trainbrakesetpipeunlock: {
- if( AIControllFlag ) {
- if( mvOccupied->HandleUnlock != -3 ) {
- while( BrakeCtrlPosition >= mvOccupied->HandleUnlock
- && BrakeLevelAdd(-1) ) {
- // all work is done in the header
- ;
- }
+ if (AIControllFlag && mvOccupied->HandleUnlock != -3) {
+ while( BrakeCtrlPosition >= mvOccupied->HandleUnlock
+ && BrakeLevelAdd(-1) ) {
+ // all work is done in the header
}
}
remove_train_brake_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->HandleUnlock == -3 || BrakeCtrlPosition == mvOccupied->HandleUnlock; } );
break;
}
@@ -797,7 +790,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_train_brake_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2) || (mvOccupied->Handle->Time && mvOccupied->Handle->GetCP() > mvOccupied->HighPipePress - 0.05); } );
// return ( BrakeCtrlPosition == gbh_RP ); } );
break;
@@ -815,7 +808,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_train_brake_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsConsistBraked /*|| ( ( OrderCurrentGet() & Disconnect ) == 0 ) */; } );
break;
}
@@ -830,9 +823,9 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_train_brake_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const Parameter) {
return std::abs(mvControlling->Fb) <= Parameter; },
- std::min( 0.0, 0.95 * std::abs( mvControlling->Fb ) ) ); // keep hint until 5% decrease
+ static_cast(std::min( 0.0, 0.95 * std::abs( mvControlling->Fb ) )) ); // keep hint until 5% decrease
break;
}
case driver_hint::brakingforceincrease: {
@@ -846,23 +839,25 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_train_brake_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const Parameter) {
return std::abs(mvControlling->Fb) > Parameter || is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_EB), 0.2); },
- std::max(
+ static_cast(std::max(
0.0,
std::max(
std::abs( mvControlling->Fb ) * 1.05,
- std::abs( mvControlling->Fb ) + 5.0 ) ) );
+ std::abs( mvControlling->Fb ) + 5.0 ) )) );
break;
}
case driver_hint::brakingforcesetzero: { // releases both train and independent brake
if( AIControllFlag ) {
- while( true == DecBrake() ) { ; }
+ while( true == DecBrake() ) {
+ // all work is done in the loop condition
+ }
}
remove_train_brake_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return Ready && fReady < 0.4 && is_equal(mvOccupied->fBrakeCtrlPos, mvOccupied->Handle->GetPos(bh_RP), 0.2); } );
break;
}
@@ -877,18 +872,16 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
// independent brake
case driver_hint::independentbrakeapply: {
- if( AIControllFlag ) {
- if( mvOccupied->LocalBrakePosA < 1.0 ) {
- mvOccupied->IncLocalBrakeLevel( LocalBrakePosNo );
- if (mvOccupied->EIMCtrlEmergency) {
- mvOccupied->DecLocalBrakeLevel(1);
+ if (AIControllFlag && mvOccupied->LocalBrakePosA < 1.0) {
+ mvOccupied->IncLocalBrakeLevel( LocalBrakePosNo );
+ if (mvOccupied->EIMCtrlEmergency) {
+ mvOccupied->DecLocalBrakeLevel(1);
}
- }
}
remove_hint( driver_hint::independentbrakerelease );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const Parameter) {
return mvOccupied->LocalBrakePosA >= Parameter; },
( LocalBrakePosNo - ( mvOccupied->EIMCtrlEmergency ? 1 : 0 ) ) / LocalBrakePosNo );
break;
@@ -900,7 +893,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::independentbrakeapply );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->LocalBrakePosA < 0.05; } );
break;
}
@@ -912,7 +905,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_reverser_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->DirActive * mvOccupied->CabActive > 0; } );
break;
}
@@ -923,7 +916,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_reverser_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->DirActive * mvOccupied->CabActive < 0; } );
break;
}
@@ -936,7 +929,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_reverser_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return iDirection == iDirectionOrder; } );
break;
}
@@ -947,7 +940,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_reverser_hints();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->DirActive == 0; } );
break;
}
@@ -959,7 +952,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::sandingoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvControlling->Sand == 0 || mvControlling->SandDose == true || mvControlling->SlippingWheels == false; } );
break;
}
@@ -970,7 +963,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::sandingon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvControlling->Sand == 0 || mvControlling->SandDose == false; } );
break;
}
@@ -980,7 +973,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
}
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvControlling->ASBType != 1 || (mvControlling->Hamulec->GetBrakeStatus() & b_asb) != 0 || mvControlling->SlippingWheels == false; } );
break;
}
@@ -992,7 +985,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::hornoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
// NOTE: we provide slightly larger horn activation window for human driver
return fWarningDuration + 5.0 < 0.05 || mvOccupied->WarningSignal != 0; } );
break;
@@ -1019,7 +1012,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
// TODO: remove other door lock hints
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->Doors.has_lock == false || mvOccupied->Doors.lock_enabled == true; } );
break;
}
@@ -1031,7 +1024,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::departuresignaloff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == true || mvOccupied->Vel > 5.0; } );
break;
}
@@ -1042,7 +1035,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::departuresignalon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->Doors.has_warning == false || mvOccupied->Doors.has_autowarning == true || mvOccupied->DepartureSignal == false; } );
break;
}
@@ -1055,7 +1048,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::doorrightclose );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyDoorOpen[side::right] == true; } );
break;
}
@@ -1067,7 +1060,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::doorrightopen );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyDoorOpen[side::right] == false; } );
break;
}
@@ -1079,7 +1072,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::doorleftclose );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyDoorOpen[side::left] == true; } );
break;
}
@@ -1091,7 +1084,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::doorleftopen );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyDoorOpen[side::left] == false; } );
break;
}
@@ -1102,7 +1095,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::doorrightpermitoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyDoorPermitActive[side::right] == true; } );
break;
}
@@ -1113,7 +1106,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::doorrightpermiton );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyDoorPermitActive[side::right] == false; } );
break;
}
@@ -1124,7 +1117,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::doorleftpermitoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyDoorPermitActive[side::left] == true; } );
break;
}
@@ -1135,7 +1128,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::doorleftpermiton );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return IsAnyDoorPermitActive[side::left] == false; } );
break;
}
@@ -1148,7 +1141,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::consistlightsoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvOccupied->CompartmentLights };
return Global.fLuminance * ConsistShade > 0.40 || device.start_type != start_t::manual || (device.is_enabled == true && device.is_disabled == false) || device.is_active == true; } );
break;
@@ -1161,7 +1154,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::consistlightson );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const &device { mvOccupied->CompartmentLights };
return Global.fLuminance * ConsistShade < 0.35 || device.start_type != start_t::manual || (device.is_enabled == false && device.is_active == false); } );
break;
@@ -1174,7 +1167,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::consistheatingoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->HeatingAllow == true; } );
break;
}
@@ -1185,52 +1178,48 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::consistheatingon );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return mvOccupied->HeatingAllow == false; } );
break;
}
case driver_hint::securitysystemreset: {
- if( AIControllFlag ) {
- if (mvOccupied->SecuritySystem.is_blinking())
- mvOccupied->SecuritySystemReset();
- }
+ if (AIControllFlag && mvOccupied->SecuritySystem.is_blinking())
+ mvOccupied->SecuritySystemReset();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return !mvOccupied->SecuritySystem.is_vigilance_blinking(); } );
break;
}
case driver_hint::shpsystemreset: {
- if( AIControllFlag ) {
- if (mvOccupied->SecuritySystem.is_cabsignal_blinking())
- mvOccupied->SecuritySystem.cabsignal_reset();
- }
+ if (AIControllFlag && mvOccupied->SecuritySystem.is_cabsignal_blinking())
+ mvOccupied->SecuritySystem.cabsignal_reset();
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return !mvOccupied->SecuritySystem.is_cabsignal_blinking(); } );
break;
}
case driver_hint::couplingadapterattach: {
// TODO: run also for potential settings-based virtual assistant
if( AIControllFlag ) {
- pVehicles[ end::front ]->attach_coupler_adapter( Actionparameter );
+ pVehicles[ end::front ]->attach_coupler_adapter( static_cast(Actionparameter) );
}
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const Parameter) {
auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] };
return device.type() == TCouplerType::Automatic; } );
break;
}
case driver_hint::couplingadapterremove: {
if( AIControllFlag || Global.AITrainman ) {
- pVehicles[ end::front ]->remove_coupler_adapter( Actionparameter );
+ pVehicles[ end::front ]->remove_coupler_adapter( static_cast(Actionparameter) );
}
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const Parameter) {
auto const &device { pVehicles[ end::front ]->MoverParameters->Couplers[ static_cast( Parameter ) ] };
return false == device.has_adapter(); } );
break;
@@ -1245,7 +1234,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::lightsoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return pVehicles[end::front]->has_signal_pc1_on(); } );
break;
}
@@ -1258,7 +1247,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::lightsoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return pVehicles[end::front]->has_signal_pc2_on(); } );
break;
}
@@ -1275,7 +1264,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::lightsoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear };
auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear };
return pVehicles[consistfront]->has_signal_on(activeend, light::headlight_right) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, light::headlight_left); } );
@@ -1290,7 +1279,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::lightsoff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return pVehicles[end::rear]->has_signal_pc5_on(); } );
break;
}
@@ -1304,7 +1293,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::headcodetb1 );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
auto const activeend { mvOccupied->CabActive >= 0 ? end::front : end::rear };
auto const consistfront { mvOccupied->DirActive >= 0 ? end::front : end::rear };
return pVehicles[consistfront]->has_signal_on(activeend, 0) && pVehicles[1 - consistfront]->has_signal_on(1 - activeend, 0); } );
@@ -1318,7 +1307,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::releaseroff );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return true == mvOccupied->Hamulec->Releaser(); } );
break;
}
@@ -1329,7 +1318,7 @@ TController::cue_action( driver_hint const Action, float const Actionparameter )
remove_hint( driver_hint::releaseron );
hint(
Action,
- [this](float const Parameter) -> bool {
+ [this](float const /*Parameter*/) {
return false == mvOccupied->Hamulec->Releaser(); } );
break;
}
diff --git a/application/driverhints.h b/application/driverhints.h
index 7b6130c2..140fe5f9 100644
--- a/application/driverhints.h
+++ b/application/driverhints.h
@@ -12,7 +12,7 @@ enum class driver_hint {
#ifdef DRIVER_HINT_CONTENT
#define DRIVER_HINT_DEF(a, b) b,
-const char *driver_hints_texts[] =
+const char *const driver_hints_texts[] =
{
#include "application/driverhints_def.h"
};
diff --git a/application/driveruipanels.cpp b/application/driveruipanels.cpp
index 729b854c..e318d356 100644
--- a/application/driveruipanels.cpp
+++ b/application/driveruipanels.cpp
@@ -52,7 +52,7 @@ drivingaid_panel::update() {
|| controlled->Mechanik == nullptr ) { return; }
auto const *mover = controlled->MoverParameters;
- auto const *driver = controlled->Mechanik;
+ auto const *vehicledriver = controlled->Mechanik;
auto const *owner = controlled->ctOwner != nullptr ? controlled->ctOwner : controlled->Mechanik;
{ // throttle, velocity, speed limits and grade
@@ -61,8 +61,7 @@ drivingaid_panel::update() {
// grade
std::string gradetext;
auto const reverser { ( mover->DirActive > 0 ? 1 : -1 ) };
- auto const grade { controlled->VectorFront().y * 100 * ( controlled->DirectionGet() == reverser ? 1 : -1 ) * reverser };
- if( std::abs( grade ) >= 0.25 ) {
+ if( auto const grade { controlled->VectorFront().y * 100 * ( controlled->DirectionGet() == reverser ? 1 : -1 ) * reverser }; std::abs( grade ) >= 0.25 ) {
std::snprintf(
m_buffer.data(), m_buffer.size(),
STR_C(" Grade: %.1f%%%%"),
@@ -87,8 +86,7 @@ drivingaid_panel::update() {
// then take into account speed change ahead, compare it with speed after potentially clearing last limit
// lower of these two takes priority; otherwise limit lasts at least until potential last limit is cleared
auto const noactivespeedlimit { owner->VelLimitLastDist.second < 0 };
- auto const speedatproximitydistance { min_speed( schedulespeedlimit, static_cast( owner->VelNext ) ) };
- if( speedatproximitydistance == nextspeedlimit ) {
+ if( auto const speedatproximitydistance { min_speed( schedulespeedlimit, static_cast( owner->VelNext ) ) }; speedatproximitydistance == nextspeedlimit ) {
if( noactivespeedlimit ) {
nextspeedlimit = speedatproximitydistance;
nextspeedlimitdistance = owner->ActualProximityDist;
@@ -142,8 +140,8 @@ drivingaid_panel::update() {
std::snprintf(
m_buffer.data(), m_buffer.size(),
STR_C("Throttle: %3d+%d %c%s"),
- mover->EIMCtrlType > 0 ? std::max(0, static_cast(100.4 * mover->eimic_real)) : driver->Controlling()->MainCtrlPos,
- mover->EIMCtrlType > 0 ? driver->Controlling()->MainCtrlPos : driver->Controlling()->ScndCtrlPos,
+ mover->EIMCtrlType > 0 ? std::max(0, static_cast(100.4 * mover->eimic_real)) : vehicledriver->Controlling()->MainCtrlPos,
+ mover->EIMCtrlType > 0 ? vehicledriver->Controlling()->MainCtrlPos : vehicledriver->Controlling()->ScndCtrlPos,
mover->SpeedCtrlUnit.IsActive ? 'T' :
mover->DirActive > 0 ? 'D' :
mover->DirActive < 0 ? 'R' :
@@ -253,12 +251,7 @@ scenario_panel::render() {
if( size_min.x > 0 ) {
ImGui::SetNextWindowSizeConstraints( ImVec2S( size_min.x, size_min.y ), ImVec2S( size_max.x, size_max.y ) );
}
- auto const panelname { (
- title.empty() ?
- m_name :
- title )
- + "###" + m_name };
- if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
+ if( auto const panelname { ( title.empty() ? m_name : title ) + "###" + m_name }; true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
// potential assignment section
auto const *owner { (
m_nearest->Mechanik != nullptr && m_nearest->Mechanik->primary() ?
@@ -274,21 +267,19 @@ scenario_panel::render() {
}
// current task
for( auto const &line : text_lines ) {
- ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() );
+ ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), "%s", line.data.c_str() );
}
// hints
- if( owner != nullptr ) {
- if( true == ImGui::CollapsingHeader( STR_C("Hints"), ImGuiTreeNodeFlags_DefaultOpen ) ) {
- for( auto const &hint : owner->m_hints ) {
- auto const isdone { std::get( hint )( std::get( hint ) ) };
- auto const hintcolor{ (
- isdone ?
- colors::uitextgreen :
- Global.UITextColor ) };
- ImGui::PushStyleColor( ImGuiCol_Text, { hintcolor.r, hintcolor.g, hintcolor.b, hintcolor.a } );
- ImGui::TextWrapped( Translations.lookup_c(driver_hints_texts[(size_t)std::get( hint )], true), std::get( hint ) );
- ImGui::PopStyleColor();
- }
+ if (owner != nullptr && true == ImGui::CollapsingHeader( STR_C("Hints"), ImGuiTreeNodeFlags_DefaultOpen )) {
+ for( auto const &hint : owner->m_hints ) {
+ auto const isdone { std::get( hint )( std::get( hint ) ) };
+ auto const hintcolor{ (
+ isdone ?
+ colors::uitextgreen :
+ Global.UITextColor ) };
+ ImGui::PushStyleColor( ImGuiCol_Text, { hintcolor.r, hintcolor.g, hintcolor.b, hintcolor.a } );
+ ImGui::TextWrapped( Translations.lookup_c(driver_hints_texts[(size_t)std::get( hint )], true), std::get( hint ) );
+ ImGui::PopStyleColor();
}
}
}
@@ -364,8 +355,7 @@ timetable_panel::update() {
//odejmij lokomotywy czynne, a przynajmniej aktualną
consistmass -= owner->pVehicle->MoverParameters->TotalMass;
// subtract potential other half of a two-part vehicle
- auto const *previous { owner->pVehicle->Prev( coupling::permanent ) };
- if( previous != nullptr ) { consistmass -= previous->MoverParameters->TotalMass; }
+ if( auto const *previous { owner->pVehicle->Prev( coupling::permanent ) }; previous != nullptr ) { consistmass -= previous->MoverParameters->TotalMass; }
auto const *next { owner->pVehicle->Next( coupling::permanent ) };
if( next != nullptr ) { consistmass -= next->MoverParameters->TotalMass; }
}
@@ -428,13 +418,13 @@ timetable_panel::update() {
&& i < table.StationIndex
&& ( tableline->Ah < 0 // pass-through, always valid
|| tableline->is_maintenance // maintenance stop, always valid
- || time.wHour * 60 + time.wMinute + time.wSecond * 0.0167 >= tableline->Dh * 60 + tableline->Dm ) ) };
+ || time.wHour * 60 + time.wMinute + time.wSecond * 0.0167 >= static_cast(tableline->Dh * 60) + tableline->Dm ) ) };
auto const loadchangeinprogress { ( static_cast(std::ceil(-1.0 * owner->fStopTime)) > 0 ) };
auto const isatpassengerstop { true == owner->IsAtPassengerStop && vehicle->MoverParameters->Vel < 1.0 };
auto const traveltime { (
i < 2 ? " " :
- tableline->Ah >= 0 ? to_minutes_str( CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Ah, tableline->Am ), false, 3 ) :
- to_minutes_str( std::max( 0.0, CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Dh, tableline->Dm ) - 0.5 ), false, 3 ) ) };
+ tableline->Ah >= 0 ? to_minutes_str( static_cast(CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Ah, tableline->Am )), false, 3 ) :
+ to_minutes_str( static_cast(std::max( 0.0, CompareTime( table.TimeTable[ i - 1 ].Dh, table.TimeTable[ i - 1 ].Dm, tableline->Dh, tableline->Dm ) - 0.5 )), false, 3 ) ) };
auto const linecolor { (
i != table.StationStart ? Global.UITextColor :
loadchangeinprogress ? colors::uitextred :
@@ -486,19 +476,14 @@ timetable_panel::render() {
if( size_min.x > 0 ) {
ImGui::SetNextWindowSizeConstraints( ImVec2S( size_min.x * horizontalScale, size_min.y ), ImVec2S( size_max.x * horizontalScale, size_max.y ) );
}
- auto const panelname { (
- title.empty() ?
- m_name :
- title )
- + "###" + m_name };
- if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
+ if( auto const panelname { ( title.empty() ? m_name : title ) + "###" + m_name }; true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
for( auto const &line : text_lines ) {
- ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() );
+ ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), "%s", line.data.c_str() );
}
if( is_expanded ) {
ImGui::PushStyleVar( ImGuiStyleVar_ItemSpacing, ImVec2( 1, 0 ) );
for( auto const &line : m_tablelines ) {
- ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() );
+ ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), "%s", line.data.c_str() );
}
ImGui::PopStyleVar();
}
@@ -576,25 +561,16 @@ debug_panel::render() {
if( size_min.x > 0 ) {
ImGui::SetNextWindowSizeConstraints( ImVec2S( size_min.x, size_min.y ), ImVec2S( size_max.x, size_max.y ) );
}
- auto const panelname { (
- title.empty() ?
- m_name :
- title )
- + "###" + m_name };
- if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
+ if( auto const panelname { ( title.empty() ? m_name : title ) + "###" + m_name }; true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
// header section
for( auto const &line : text_lines ) {
- ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), line.data.c_str() );
+ ImGui::TextColored( ImVec4( line.color.r, line.color.g, line.color.b, line.color.a ), "%s", line.data.c_str() );
}
// sections
ImGui::Separator();
- if( true == render_section( "Vehicle", m_vehiclelines ) ) {
- if( DebugModeFlag && m_input.mover && m_input.mover->DamageFlag != 0 ) {
- if( true == ImGui::Button( "Stop and repair consist" ) ) {
- command_relay relay;
- relay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
- }
- }
+ if (true == render_section( "Vehicle", m_vehiclelines ) && DebugModeFlag && m_input.mover && m_input.mover->DamageFlag != 0 && true == ImGui::Button( "Stop and repair consist" )) {
+ command_relay commandrelay;
+ commandrelay.post(user_command::resetconsist, 0.0, 0.0, GLFW_PRESS, 0, glm::vec3(0.0f), &m_input.vehicle->name());
}
render_section( "Vehicle Engine", m_enginelines );
render_section( "Vehicle AI", m_ailines );
@@ -611,13 +587,13 @@ debug_panel::render() {
render_section_developer(); // Developer tools
#ifdef WITH_UART
if(true == render_section( "UART", m_uartlines)) {
- int ports_num = UartStatus.available_ports.size();
- char **avlports = new char*[ports_num];
+ auto ports_num = static_cast(UartStatus.available_ports.size());
+ auto avlports = new char*[ports_num];
for (int i=0; i < ports_num; i++) {
avlports[i] = (char *) UartStatus.available_ports[i].c_str();
}
ImGui::Combo("Port", &UartStatus.selected_port_index, avlports, ports_num);
- ImGui::Combo("Baud", &UartStatus.selected_baud_index, uart_baudrates_list, uart_baudrates_list_num);
+ ImGui::Combo("Baud", &UartStatus.selected_baud_index, uart_baudrates_list, static_cast(uart_baudrates_list_num));
ImGui::Checkbox("Enabled", &UartStatus.enabled);
}
#endif
@@ -625,8 +601,8 @@ debug_panel::render() {
ImGui::Separator();
bool flag = DebugModeFlag;
if (ImGui::Checkbox("Debug Mode", &flag)) {
- command_relay relay;
- relay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
+ command_relay commandrelay;
+ commandrelay.post(user_command::debugtoggle, 0.0, 0.0, GLFW_RELEASE, 0);
}
}
@@ -647,8 +623,8 @@ debug_panel::render_section_scenario() {
auto fogrange = std::log( Global.fFogEnd );
if( ImGui::SliderFloat(
( to_string( std::exp( fogrange ), 0, 5 ) + " m###fogend" ).c_str(), &fogrange, std::log( 10.0f ), std::log( 50000.0f ), "Fog distance" ) ) {
- command_relay relay;
- relay.post(
+ command_relay commandrelay;
+ commandrelay.post(
user_command::setweather,
std::clamp( std::exp( fogrange ), 10.0f, 50000.0f ),
Global.Overcast,
@@ -661,8 +637,8 @@ debug_panel::render_section_scenario() {
(to_string(Airtemperature, 1) + " deg C###Airtemperature").c_str(),
&Airtemperature, -35.0f, 40.0f, "Air Temperature"))
{
- command_relay relay;
- relay.post(
+ command_relay commandrelay;
+ commandrelay.post(
user_command::settemperature,
std::clamp(Airtemperature, -35.0f, 40.0f),
Global.Overcast,
@@ -673,8 +649,8 @@ debug_panel::render_section_scenario() {
{
if( ImGui::SliderFloat(
( to_string( Global.Overcast, 2, 5 ) + " (" + Global.Weather + ")###overcast" ).c_str(), &Global.Overcast, 0.0f, 2.0f, "Cloud cover" ) ) {
- command_relay relay;
- relay.post(
+ command_relay commandrelay;
+ commandrelay.post(
user_command::setweather,
Global.fFogEnd,
std::clamp( Global.Overcast, 0.0f, 2.0f ),
@@ -685,8 +661,8 @@ debug_panel::render_section_scenario() {
{
if( ImGui::SliderFloat(
( to_string( Global.fMoveLight, 0, 5 ) + " (" + Global.Season + ")###movelight" ).c_str(), &Global.fMoveLight, 0.0f, 364.0f, "Day of year" ) ) {
- command_relay relay;
- relay.post(
+ command_relay commandrelay;
+ commandrelay.post(
user_command::setdatetime,
std::clamp( Global.fMoveLight, 0.0f, 365.0f ),
simulation::Time.data().wHour * 60 + simulation::Time.data().wMinute,
@@ -695,10 +671,8 @@ debug_panel::render_section_scenario() {
}
// dynamic material update checkbox
ImGui::Checkbox( "Update Item Materials", &Global.UpdateMaterials );
- if( DebugModeFlag ) {
- if( ImGui::Checkbox( "Force Daylight", &Global.FakeLight ) ) {
- simulation::Environment.on_daylight_change();
- }
+ if (DebugModeFlag && ImGui::Checkbox( "Force Daylight", &Global.FakeLight )) {
+ simulation::Environment.on_daylight_change();
}
// advanced options, only visible in debug mode
if( DebugModeFlag ) {
@@ -713,8 +687,8 @@ debug_panel::render_section_scenario() {
+ ":"
+ std::string( std::to_string( int( 100 + simulation::Time.data().wMinute ) ).substr( 1, 2 ) ) ) };
if( ImGui::SliderInt( ( timestring + " (" + Global.Period + ")###simulationtime" ).c_str(), &time, 0, 1439, "Time of day" ) ) {
- command_relay relay;
- relay.post(
+ command_relay commandrelay;
+ commandrelay.post(
user_command::setdatetime,
Global.fMoveLight,
std::clamp( time, 0, 1439 ),
@@ -903,7 +877,7 @@ debug_panel::update_section_vehicle( std::vector &Output ) {
mover.LoadFlag,
mover.LocalBrakePosA,
mover.LocalBrakePosAEIM,
- mover.ManualBrakePos / static_cast(ManualBrakePosNo),
+ static_cast(mover.ManualBrakePos) / static_cast(ManualBrakePosNo),
mover.SpringBrake.Activate ? 1.f : 0.f,
// cylinders
mover.BrakePress,
@@ -981,11 +955,11 @@ debug_panel::update_section_vehicle( std::vector &Output ) {
if (!std::isnan(last_time)) {
double dt = Timer::GetTime() - last_time;
- AccN_jerk_graph.update((mover.AccN - last_AccN) / dt);
- AccN_acc_graph.update(mover.AccN);
+ AccN_jerk_graph.update(static_cast((mover.AccN - last_AccN) / dt));
+ AccN_acc_graph.update(static_cast(mover.AccN));
}
- last_AccN = mover.AccN;
+ last_AccN = static_cast(mover.AccN);
last_time = Timer::GetTime();
}
@@ -1002,7 +976,7 @@ void debug_panel::graph_data::update(float val) {
void debug_panel::graph_data::render() {
ImGui::PushID(this);
ImGui::SliderFloat(STR_C("##Range"), &range, 0.5f, 60.0f, "%.1f");
- ImGui::PlotLines("##plot", data.data(), data.size(), pos, nullptr, 0.0f, range, ImVec2(0, 100));
+ ImGui::PlotLines("##plot", data.data(), static_cast(data.size()), static_cast(pos), nullptr, 0.0f, range, ImVec2(0, 100));
ImGui::PopID();
}
@@ -1047,9 +1021,9 @@ debug_panel::update_vehicle_brake() const {
{ bdelay_R, "R" },
{ bdelay_M, "+Mg" } };
- for( auto const &delay : delays ) {
- if( ( mover.BrakeDelayFlag & delay.first ) == delay.first ) {
- brakedelay += delay.second;
+ for( auto const &[delayflag, delayname] : delays ) {
+ if( ( mover.BrakeDelayFlag & delayflag ) == delayflag ) {
+ brakedelay += delayname;
}
}
@@ -1057,7 +1031,7 @@ debug_panel::update_vehicle_brake() const {
}
void
-debug_panel::update_section_engine( std::vector &Output ) {
+debug_panel::update_section_engine( std::vector &Output ) const {
if( m_input.vehicle == nullptr ) { return; }
if( m_input.mover == nullptr ) { return; }
@@ -1072,9 +1046,9 @@ debug_panel::update_section_engine( std::vector &Output ) {
for( int i = 0; i <= 20; ++i ) {
std::string parameters =
- mover.eimc_labels[ i ] + to_string( mover.eimc[ i ], 2, 9 )
+ TMoverParameters::eimc_labels[ i ] + to_string( mover.eimc[ i ], 2, 9 )
+ " | "
- + mover.eimv_labels[ i ] + to_string( mover.eimv[ i ], 2, 9 );
+ + TMoverParameters::eimv_labels[ i ] + to_string( mover.eimv[ i ], 2, 9 );
if( i < 10 ) {
parameters +=
@@ -1084,7 +1058,7 @@ debug_panel::update_section_engine( std::vector &Output ) {
parameters += " med:";
}
else if( i >= 13 ) {
- parameters += " | " + vehicle.MED_labels[ i - 13 ] + to_string( vehicle.MED[ 0 ][ i - 13 ], 2, 9 );
+ parameters += " | " + TDynamicObject::MED_labels[ i - 13 ] + to_string( vehicle.MED[ 0 ][ i - 13 ], 2, 9 );
}
Output.emplace_back( parameters, Global.UITextColor );
@@ -1112,8 +1086,8 @@ debug_panel::update_section_engine( std::vector &Output ) {
{ "cdesi: ", mover.dizel_engagestate },
{ "cdelt: ", mover.dizel_engagedeltaomega },
{ "gears: ", mover.dizel_automaticgearstatus} };
- for( auto const ¶meter : paramvalues ) {
- parameterstext += "\n" + parameter.first + to_string( parameter.second, 2, 9 );
+ for( auto const &[parametername, parametervalue] : paramvalues ) {
+ parameterstext += "\n" + parametername + to_string( parametervalue, 2, 9 );
}
Output.emplace_back( parameterstext, Global.UITextColor );
@@ -1130,15 +1104,15 @@ debug_panel::update_section_engine( std::vector &Output ) {
{ "hRtTq: ", mover.hydro_R_Torque }
};
- for( auto const ¶meter : hydrovalues ) {
- parameterstext += "\n" + parameter.first + to_string( parameter.second, 2, 9 );
+ for( auto const &[parametername, parametervalue] : hydrovalues ) {
+ parameterstext += "\n" + parametername + to_string( parametervalue, 2, 9 );
}
Output.emplace_back( parameterstext, Global.UITextColor );
}
}
void
-debug_panel::update_section_ai( std::vector &Output ) {
+debug_panel::update_section_ai( std::vector &Output ) const {
if( m_input.mover == nullptr ) { return; }
if( m_input.mechanik == nullptr ) { return; }
@@ -1202,14 +1176,14 @@ debug_panel::update_section_ai( std::vector &Output ) {
{ mover.RunningTrack.Velmax, "track" } };
std::string restrictionstext;
- for( auto const &restriction : restrictions ) {
- if( restriction.first < 0.0 ) { continue; }
+ for( auto const &[restrictionspeed, restrictionsource] : restrictions ) {
+ if( restrictionspeed < 0.0 ) { continue; }
if( false == restrictionstext.empty() ) {
restrictionstext += ", ";
}
restrictionstext +=
- to_string( restriction.first, 0 )
- + " (" + restriction.second + ")";
+ to_string( restrictionspeed, 0 )
+ + " (" + restrictionsource + ")";
}
if( false == restrictionstext.empty() ) {
@@ -1262,7 +1236,7 @@ debug_panel::update_section_ai( std::vector &Output ) {
}
void
-debug_panel::update_section_scantable( std::vector &Output ) {
+debug_panel::update_section_scantable( std::vector &Output ) const {
if( m_input.mechanik == nullptr ) { return; }
@@ -1284,8 +1258,8 @@ debug_panel::update_section_scantable( std::vector &Output ) {
#ifdef WITH_UART
void
-debug_panel::update_section_uart( std::vector &Output ) {
- uart_status *status = &UartStatus;
+debug_panel::update_section_uart( std::vector &Output ) const {
+ uart_status const *status = &UartStatus;
Output.emplace_back(
("Port: " + status->port_name).c_str(),
@@ -1312,7 +1286,7 @@ debug_panel::update_section_uart( std::vector &Output ) {
#endif
void
-debug_panel::update_section_scenario( std::vector &Output ) {
+debug_panel::update_section_scenario( std::vector &Output ) const {
auto textline =
"vehicles: " + to_string( Timer::subsystem.sim_dynamics.average(), 2 ) + " msec"
@@ -1326,7 +1300,7 @@ debug_panel::update_section_scenario( std::vector &Output ) {
+ to_string( simulation::Environment.wind_azimuth(), 0 ) // ma być azymut, czyli 0 na północy i rośnie na wschód
+ " "
+ std::string( "N NEE SES SWW NW" )
- .substr( 0 + 2 * std::floor( std::fmod( 8 + ( glm::radians( simulation::Environment.wind_azimuth() ) + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 )
+ .substr( static_cast( 2 * std::floor( std::fmod( 8 + ( glm::radians( simulation::Environment.wind_azimuth() ) + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ) ), 2 )
+ ", " + to_string( glm::length( simulation::Environment.wind() ), 1 ) + " m/s";
textline += "\nAir temperature: " + to_string( Global.AirTemperature, 1 ) + " deg C";
@@ -1340,36 +1314,36 @@ debug_panel::update_section_eventqueue( std::vector &Output ) {
// current event queue
auto const time { Timer::GetTime() };
- auto const *event { simulation::Events.begin() };
+ auto const *queuedevent { simulation::Events.begin() };
auto const searchfilter { std::string( m_eventsearch.data() ) };
Output.emplace_back( "Delay: Event:", Global.UITextColor );
- while( event != nullptr
+ while( queuedevent != nullptr
&& Output.size() < 30 ) {
- if( false == event->m_ignored
- && false == event->m_passive
+ if( false == queuedevent->m_ignored
+ && false == queuedevent->m_passive
&& ( false == m_eventqueueactivevehicleonly
- || event->m_activator == m_input.vehicle ) ) {
+ || queuedevent->m_activator == m_input.vehicle ) ) {
- auto const label { event->m_name + ( event->m_activator ? " (by: " + event->m_activator->asName + ")" : "" ) };
+ auto const label { queuedevent->m_name + ( queuedevent->m_activator ? " (by: " + queuedevent->m_activator->asName + ")" : "" ) };
if( false == searchfilter.empty()
&& false == contains(label, searchfilter) ) {
- event = event->m_next;
+ queuedevent = queuedevent->m_next;
continue;
}
- auto const delay { " " + to_string( std::max( 0.0, event->m_launchtime - time ), 1 ) };
+ auto const delay { " " + to_string( std::max( 0.0, queuedevent->m_launchtime - time ), 1 ) };
textline =
delay.substr( delay.length() - 6 )
+ " "
- + label + ( event->m_sibling ? " (joint event)" : "" );
+ + label + ( queuedevent->m_sibling ? " (joint event)" : "" );
Output.emplace_back( textline, Global.UITextColor );
}
- event = event->m_next;
+ queuedevent = queuedevent->m_next;
}
if( Output.size() == 1 ) {
// event queue can be empty either because no event got through active filters, or because it is genuinely empty
@@ -1378,7 +1352,7 @@ debug_panel::update_section_eventqueue( std::vector &Output ) {
}
void
-debug_panel::update_section_powergrid( std::vector &Output ) {
+debug_panel::update_section_powergrid( std::vector &Output ) const {
auto const lowpowercolor { glm::vec4( 164.0f / 255.0f, 132.0f / 255.0f, 84.0f / 255.0f, 1.f ) };
auto const nopowercolor { glm::vec4( 164.0f / 255.0f, 84.0f / 255.0f, 84.0f / 255.0f, 1.f ) };
@@ -1420,7 +1394,7 @@ debug_panel::update_section_powergrid( std::vector &Output ) {
}
void
-debug_panel::update_section_camera( std::vector &Output ) {
+debug_panel::update_section_camera( std::vector &Output ) const {
if( m_input.camera == nullptr ) { return; }
@@ -1440,13 +1414,13 @@ debug_panel::update_section_camera( std::vector &Output ) {
+ to_string( 180.0 - glm::degrees( camera.Angle.y ), 0 ) // ma być azymut, czyli 0 na północy i rośnie na wschód
+ " "
+ std::string( "S SEE NEN NWW SW" )
- .substr( 0 + 2 * floor( fmod( 8 + ( camera.Angle.y + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ), 2 );
+ .substr( static_cast( 2 * floor( fmod( 8 + ( camera.Angle.y + 0.5 * M_PI_4 ) / M_PI_4, 8 ) ) ), 2 );
Output.emplace_back( textline, Global.UITextColor );
}
void
-debug_panel::update_section_renderer( std::vector &Output ) {
+debug_panel::update_section_renderer( std::vector &Output ) const {
// gfx renderer data
auto textline =
@@ -1526,7 +1500,7 @@ debug_panel::render_section( std::string const &Header, std::vector c
}
bool
-debug_panel::render_section( std::vector const &Lines ) {
+debug_panel::render_section( std::vector const &Lines ) const {
for( auto const &line : Lines ) {
ImGui::PushStyleColor( ImGuiCol_Text, { line.color.r, line.color.g, line.color.b, line.color.a } );
@@ -1537,7 +1511,7 @@ debug_panel::render_section( std::vector const &Lines ) {
return true;
}
-bool debug_panel::render_section_developer()
+bool debug_panel::render_section_developer() const
{
if (false == ImGui::CollapsingHeader("Developer tools"))
return false;
@@ -1553,7 +1527,7 @@ bool debug_panel::render_section_developer()
}
bool
-debug_panel::render_section_settings() {
+debug_panel::render_section_settings() const {
if( false == ImGui::CollapsingHeader( "Settings" ) ) { return false; }
@@ -1563,9 +1537,9 @@ debug_panel::render_section_settings() {
// reflection fidelity
ImGui::SliderInt( ( std::to_string( Global.reflectiontune.fidelity ) + "###reflectionfidelity" ).c_str(), &Global.reflectiontune.fidelity, 0, 2, "Reflection fidelity" );
ImGui::SliderInt( ( std::to_string( Global.gfx_shadow_rank_cutoff ) + "###shadowrankcutoff" ).c_str(), &Global.gfx_shadow_rank_cutoff, 1, 3, "Shadow ranks" );
- if( ImGui::SliderFloat( ( to_string( std::abs( Global.gfx_shadow_angle_min ), 2 ) + "###shadowanglecutoff" ).c_str(), &Global.gfx_shadow_angle_min, -1.0, -0.2, "Shadow angle cutoff" ) ) {
+ if( ImGui::SliderFloat( ( to_string( std::abs( Global.gfx_shadow_angle_min ), 2 ) + "###shadowanglecutoff" ).c_str(), &Global.gfx_shadow_angle_min, -1.0, -0.2f, "Shadow angle cutoff" ) ) {
Global.gfx_shadow_angle_min = quantize( Global.gfx_shadow_angle_min, 0.05f );
- };
+ }
if( DebugModeFlag ) {
// sky sliders
{
@@ -1595,8 +1569,8 @@ debug_panel::render_section_settings() {
if (simulation::Train) {
float val = simulation::Train->get_radiovolume();
if( ImGui::SliderFloat( ( std::to_string( static_cast( val * 100 ) ) + "%###volumeradio" ).c_str(), &val, 0.0f, 1.0f, "Vehicle radio volume" ) ) {
- command_relay relay;
- relay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
+ command_relay commandrelay;
+ commandrelay.post(user_command::radiovolumeset, val, 0.0, GLFW_PRESS, 0);
}
}
@@ -1635,12 +1609,7 @@ transcripts_panel::render() {
if( size_min.x > 0 ) {
ImGui::SetNextWindowSizeConstraints( ImVec2S( size_min.x, size_min.y ), ImVec2S( size_max.x, size_max.y ) );
}
- auto const panelname { (
- title.empty() ?
- m_name :
- title )
- + "###" + m_name };
- if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
+ if( auto const panelname { ( title.empty() ? m_name : title ) + "###" + m_name }; true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
// header section
for( auto const &line : text_lines ) {
ImGui::TextWrapped( "%s", line.data.c_str() );
diff --git a/application/driveruipanels.h b/application/driveruipanels.h
index da4cad87..96b9ac1c 100644
--- a/application/driveruipanels.h
+++ b/application/driveruipanels.h
@@ -54,7 +54,6 @@ public:
private:
// members
- std::array m_buffer;
TDynamicObject const *m_nearest { nullptr };
};
@@ -81,42 +80,41 @@ private:
// methods
// generate and send section data to provided output
void update_section_vehicle( std::vector &Output );
- void update_section_engine( std::vector &Output );
- void update_section_ai( std::vector &Output );
- void update_section_scantable( std::vector &Output );
- void update_section_scenario( std::vector &Output );
+ void update_section_engine( std::vector &Output ) const;
+ void update_section_ai( std::vector &Output ) const;
+ void update_section_scantable( std::vector &Output ) const;
+ void update_section_scenario( std::vector &Output ) const;
void update_section_eventqueue( std::vector &Output );
- void update_section_powergrid( std::vector &Output );
- void update_section_camera( std::vector &Output );
- void update_section_renderer( std::vector