mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-01 02:19:05 +01:00
Fix/sonar maintainability rebased (#209)
* refactor(sonar): use override instead of redundant virtual (cpp:S3471) * refactor(sonar): remove empty statements, one declaration per statement (cpp:S1116, cpp:S1659) * refactor(sonar): drop redundant lambda return types (cpp:S3574) * refactor(sonar): prefer using over typedef (cpp:S5416) * refactor(sonar): use =default for trivial special members (cpp:S3490) * refactor(sonar): use nullptr literal (cpp:S4962) * refactor(sonar): remove redundant access specifiers (cpp:S3539) * refactor(sonar): remove redundant casts (cpp:S1905) * refactor(sonar): use std::scoped_lock instead of std::lock_guard (cpp:S5997) * refactor(sonar): construct elements in place with emplace_back (cpp:S6003) * refactor(sonar): make narrowing conversions explicit (cpp:S5276) * refactor(sonar): mark unused parameters (cpp:S1172) Unused names are commented out; parameters used only on some platforms are marked [[maybe_unused]]. * refactor(sonar): declare non-mutating member functions const (cpp:S5817) Virtual functions are left untouched so overrides keep matching. * refactor(sonar): merge collapsible nested if statements (cpp:S1066) Comments that preceded the inner if are kept above the merged statement. * refactor(sonar): scope single-use variables in if init-statements (cpp:S6004) * fix(sonar): give polymorphic base classes virtual destructors (cpp:S1235) * refactor(sonar): use try_emplace for map insertion (cpp:S6030) * refactor(sonar): use auto where the type is spelled out on the right (cpp:S5827) * refactor(sonar): remove redundant parentheses (cpp:S1110) * refactor(sonar): document intentionally empty functions (cpp:S1186) * refactor(sonar): remove dead stores (cpp:S1854) Side effects (e.g. LISTLINE++) are kept. * refactor(sonar): remove unused variables, captures and private fields (cpp:S1481, cpp:S1068) * refactor(sonar): use structured bindings for pair access (cpp:S6005) * refactor(sonar): use range-based loops and ranges algorithms (cpp:S5566) * refactor(sonar): split chained assignments (cpp:S1121) * refactor(sonar): add default cases to switch statements (cpp:S3562) * refactor(sonar): use std::size for array lengths (cpp:S7127) * refactor(sonar): use std::ranges algorithms and std::erase(_if) (cpp:S6197) * refactor(sonar): access static members through the class (cpp:S2209) * refactor(sonar): add braces around nested if-else (cpp:S5261) * refactor(sonar): avoid side effects inside typeid operands (cpp:S5279) * refactor(sonar): drop top-level const from by-value return types (cpp:S5951) * refactor(sonar): declare variables separately from their type definitions (cpp:S3646) * refactor(sonar): declare loop counters in the for statement (cpp:S5955) * refactor(sonar): rely on class template argument deduction (cpp:S6012) * refactor(sonar): inherit base constructors instead of forwarding them (cpp:S5952) * refactor(sonar): rename locals that shadow outer declarations (cpp:S1117) Only local variables and definition parameters are renamed; shadowing struct fields and enumerators in headers are left for a separate change. * refactor(sonar): reduce enum qualification with using enum (cpp:S6177) Applied only where no unqualified name in the block could be captured by the introduced enumerators. * refactor(sonar): mark converting constructors explicit (cpp:S1709) sound_source and the gl::object conversion operators stay implicit; they are relied upon by copy-list-initialisation and GL calls. * refactor(sonar): initialise members in initialiser lists or declarations (cpp:S3230) * refactor(sonar): make read-only local references and pointers const (cpp:S5350) * refactor(sonar): take read-only pointer and reference parameters as const (cpp:S995) TTrain command handlers keep their signature, it is fixed by the handler table. * refactor(sonar): pass expensive-to-copy parameters by const reference (cpp:S1238) Signatures declared in files touched by PR 206 (Driver.h, EU07.cpp) and virtual overrides are left unchanged. * refactor(sonar): use transparent comparators for string-keyed maps (cpp:S6045) std::unordered_map instances and map types exposed in headers used by other modules are left as they are. * fix(sonar): do not use UI text as a printf format string (cpp:S5281) Text lines containing '%' would otherwise be interpreted as format specifiers by ImGui::TextColored. * refactor(sonar): use std::bind_front for callbacks (cpp:S5995) * refactor(sonar): drop const_cast on string literals passed to the Python C API (cpp:S859) * refactor(sonar): take read-only string parameters as std::string_view (cpp:S6009) The Windows messaging helpers keep std::string, they need c_str(). * refactor(sonar): make read-only global tables const (cpp:S5421) Mutable global state (flags, timers, singletons) is left as is. * refactor(sonar): replace single-case switch statements with if (cpp:S1301) * refactor(sonar): format UUIDs and log timestamps with std::format (cpp:S6494, cpp:S5945) * refactor(sonar): use std::array for local fixed-size arrays (cpp:S5945) Arrays that are class members or part of headers are left unchanged. * fix(sonar): test the bearing damage bit, not bit 0 (cpp:S872) 'DamageFlag & dtrain_bearing > 0' parsed as 'DamageFlag & (dtrain_bearing > 0)', i.e. DamageFlag & 1, so bearing friction reacted to the wrong damage flag. * refactor(sonar): assorted small fixes - empty() instead of size() comparisons (cpp:S1155) - member initialisers in declaration order (cpp:S3229) - no redundant c_str() when a std::string is accepted (cpp:S7121) - contains() on associative containers (cpp:S6171) - const reference instead of a copying range-for (cpp:S6032) - starts_with() for prefix checks (cpp:S6178) - no std::move on temporaries (cpp:S5274) - has_value() on std::optional (cpp:S7172) - bool literals for bool members (cpp:S5820) - inline only on the definition (cpp:S3548) - explicit base access specifier (cpp:S5965) - explicit element access instead of dereferencing an array (cpp:S7116) - rely on the C++20 rewritten operator!= (cpp:S6186) * refactor(sonar): more small fixes - std::format instead of iostream manipulators in to_string/to_hex_str (cpp:S6495); output verified identical, negative hex values keep the unsigned form - remove an empty compound statement (cpp:S108) - drop an always-false unsigned < 0 branch (cpp:S1768) - explicit lambda capture (cpp:S3608) - std::make_unique (cpp:S5950) * chore: strip stray carriage returns left in TTrain constructor comments * fix: keep quantize() in its own value type The S5276 change cast the result of the generic quantize<Type_>() to unsigned int, which truncated float/double callers (shadow angle slider, editor rotation snapping, AI speed control steps) and broke negative values. * fix(sonar): use integer loop counters in segment sampling (cpp:S2193) * refactor(sonar): clean up issues reported on PR 209 - remove locals left unused after the dead-store cleanup (cpp:S1481, cpp:S1854) - unnamed unused parameter (cpp:S1172) - single-use declarations moved into if init-statements (cpp:S6004) - auto for casted initialisers (cpp:S5827) - const references and pointers where nothing is modified (cpp:S5350) - rename structured bindings shadowed by inner declarations (cpp:S1117)
This commit is contained in:
@@ -357,21 +357,14 @@ end ; */
|
||||
/// <param name="i_mat">Friction material id (bp_* constant, optionally OR'ed with bp_MHS).</param>
|
||||
/// <param name="i_ba">Number of braked axles.</param>
|
||||
/// <param name="i_nbpa">Number of blocks per axle.</param>
|
||||
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<TBrakeCyl>();
|
||||
@@ -450,7 +443,7 @@ double TBrake::GetFC(double const Vel, double const N)
|
||||
|
||||
/// <summary>Returns the gauge pressure inside the brake cylinder.</summary>
|
||||
// cisnienie cylindra hamulcowego
|
||||
double TBrake::GetBCP()
|
||||
double TBrake::GetBCP() const
|
||||
{
|
||||
return BrakeCyl->P();
|
||||
}
|
||||
@@ -464,14 +457,14 @@ double TBrake::GetEDBCP()
|
||||
|
||||
/// <summary>Returns the auxiliary reservoir (ZP) pressure.</summary>
|
||||
// cisnienie zbiornika pomocniczego
|
||||
double TBrake::GetBRP()
|
||||
double TBrake::GetBRP() const
|
||||
{
|
||||
return BrakeRes->P();
|
||||
}
|
||||
|
||||
/// <summary>Returns the valve pre-chamber pressure.</summary>
|
||||
// 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)
|
||||
/// <summary>
|
||||
/// Returns the piston force from the cylinder pressure (BCA * 100 * P).
|
||||
/// </summary>
|
||||
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, ...).
|
||||
/// </summary>
|
||||
/// <param name="nEPS">EP intensity.</param>
|
||||
void TBrake::SetEPS(double const nEPS) {}
|
||||
void TBrake::SetEPS(double const nEPS) { /* no effect for this device type */ }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the anti-slip brake state flags. Bit 1 of <paramref name="state"/>
|
||||
@@ -572,7 +565,7 @@ void TBrake::ASB(int const state)
|
||||
}
|
||||
|
||||
/// <summary>Returns the raw BrakeStatus bitfield.</summary>
|
||||
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)
|
||||
/// <param name="nEPS">New EP intensity.</param>
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -854,11 +843,10 @@ void TESt::CheckReleaser(double const dt)
|
||||
/// </summary>
|
||||
/// <param name="BCP">Brake cylinder (or impulse-chamber) pressure.</param>
|
||||
/// <param name="dV1">In/out brake-pipe flow correction (unused in this base impl).</param>
|
||||
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)
|
||||
/// </summary>
|
||||
/// <param name="BP">Brake cylinder (or impulse) pressure.</param>
|
||||
/// <returns>Opening coefficient (0 closed, 1 fully open).</returns>
|
||||
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)
|
||||
/// </summary>
|
||||
/// <param name="BCP">Brake cylinder pressure.</param>
|
||||
/// <returns>Opening coefficient.</returns>
|
||||
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.
|
||||
/// </summary>
|
||||
/// <param name="i_crc">Characteristic value.</param>
|
||||
void TESt::EStParams(double const i_crc) {}
|
||||
void TESt::EStParams(double const /*i_crc*/) const { /* no effect for this device type */ }
|
||||
|
||||
/// <summary>Returns the control reservoir (ZS) pressure.</summary>
|
||||
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)
|
||||
/// </summary>
|
||||
/// <param name="BP">Cylinder pressure.</param>
|
||||
/// <returns>Opening coefficient.</returns>
|
||||
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)
|
||||
/// </summary>
|
||||
/// <param name="BCP">Cylinder pressure.</param>
|
||||
/// <returns>Opening coefficient.</returns>
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -2502,13 +2477,11 @@ void TKE::CheckReleaser(double const dt)
|
||||
/// </summary>
|
||||
/// <param name="BCP">Cylinder (or impulse-chamber) pressure.</param>
|
||||
/// <param name="dV1">In/out brake-pipe flow correction (unused here).</param>
|
||||
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)
|
||||
/// </summary>
|
||||
/// <param name="BP">Cylinder (or impulse) pressure.</param>
|
||||
/// <returns>Opening coefficient.</returns>
|
||||
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)
|
||||
/// </summary>
|
||||
/// <param name="BCP">Impulse-chamber pressure.</param>
|
||||
/// <returns>Opening coefficient.</returns>
|
||||
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)
|
||||
|
||||
/// <summary>Default reductor adjustment — no-op.</summary>
|
||||
/// <param name="nAdj">Pressure correction.</param>
|
||||
void TDriverHandle::SetReductor(double nAdj) {}
|
||||
void TDriverHandle::SetReductor(double nAdj) { /* no effect for this device type */ }
|
||||
|
||||
/// <summary>Default cab-gauge pressure — 0.</summary>
|
||||
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()
|
||||
/// </summary>
|
||||
/// <param name="pos">Continuous handle position.</param>
|
||||
/// <returns>Interpolated target pressure [bar].</returns>
|
||||
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<int>(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
|
||||
}
|
||||
/// <summary>Returns true if pos is within ±0.5 of i_pos (detent test).</summary>
|
||||
/// <param name="pos">Continuous handle position.</param>
|
||||
/// <param name="i_pos">Detent centre.</param>
|
||||
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)
|
||||
/// </summary>
|
||||
/// <param name="pos">Continuous handle position.</param>
|
||||
/// <returns>Target brake-pipe pressure [bar].</returns>
|
||||
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
|
||||
}
|
||||
|
||||
/// <summary>Returns true if pos is within ±0.5 of i_pos (detent test).</summary>
|
||||
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,
|
||||
}
|
||||
|
||||
/// <summary>Returns true if pos is within ±0.5 of i_pos (detent test).</summary>
|
||||
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,
|
||||
}
|
||||
|
||||
/// <summary>Returns true if pos is within ±0.5 of i_pos (detent test).</summary>
|
||||
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<int>(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<int>(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<int>(lround(i_bcp));
|
||||
|
||||
EPS = BEP_K[BCP + 1];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user