18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 03:37:09 +01:00
Files
maszyna/physics/components/fizsections.cpp
Hirek ef8a1fdbfd refactor(physics): six more of what the rest only reads are private, under names of their own
The mass of the empty vehicle, the braking force, the outcome of a derailment,
the departure signal, the traction mode of a dual-mode vehicle and the moment
of the motors are private to physics::Vehicle like the 53 before them, read
through Mass(), Fb(), Derailed(), DepartureSignal(), TractionMode() and Mm().
Inside the class they are emptyMass, brakingForce, derailOutcome,
departureSignalOn, tractionModeSetting and motorMoment, as the plain camelCase
names were taken by locals there.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
2026-11-29 13:23:53 +01:00

1836 lines
76 KiB
C++

/*
This Source Code Form is subject to the
terms of the Mozilla Public License, v.
2.0. If a copy of the MPL was not
distributed with this file, You can
obtain one at
http://mozilla.org/MPL/2.0/.
*/
// reading the vehicle definition (.fiz): the sections and their keywords
#include "stdafx.h"
#include "physics/vehicle.h"
#include "vehicle/DynObj.h"
#include "physics/oerlikonest.h"
#include "utilities/Globals.h"
#include "utilities/Logs.h"
#include "utilities/Timer.h"
#include "utilities/parser.h"
#include "simulation/simulation.h"
#include "vehicle/fieldshunting.h"
#include <algorithm>
#include <charconv>
#include <cmath>
#include <format>
#include <functional>
#include <limits>
#include <utility>
#include <vector>
#include "physics/components/internal.h"
int s2NPW(std::string s)
{ // wylicza ilosc osi napednych z opisu ukladu osi
const char A = 64;
int NPW = 0;
for (char const chentry : s)
{
if (chentry >= (char)65 && chentry <= (char)90)
NPW += chentry - A;
}
return NPW;
}
int s2NNW(std::string s)
{ // wylicza ilosc osi nienapedzanych z opisu ukladu osi
const char Zero = 48;
int NNW = 0;
for (char const ch : s)
{
if (ch >= (char)49 && ch <= (char)57)
NNW += ch - Zero;
}
return NNW;
}
void physics::Vehicle::LoadFIZ_Param(std::string const &line)
{
extract_value(emptyMass, "M", line, "0");
extract_value(mred, "Mred", line, "0");
extract_value(vmax, "Vmax", line, "0");
extract_value(Power, "PWR", line, "0");
extract_value(SandCapacity, "SandCap", line, "0");
extract_value(trainHeating.config.power, "HeatingP", line, "0");
extract_value(LightPower, "LightP", line, "0");
{
std::map<std::string, int, std::less<>> 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);
CategoryFlag = lookup != categories.end() ? lookup->second : 0;
if (CategoryFlag == 0)
{
ErrorLog("Unknown vehicle category: \"" + category + "\".");
}
}
{
std::map<std::string, train_type, std::less<>> types{
{"pseudodiesel", train_type::pseudodiesel},
{"ezt", train_type::emu},
{"dmu", train_type::dmu},
{"sn61", train_type::sn61},
{"et22", train_type::et22},
{"et40", train_type::et40},
{"et41", train_type::et41},
{"et42", train_type::et42},
{"ep05", train_type::ep05},
{"181", train_type::skoda181},
{"182", train_type::skoda181} // na razie tak
};
std::string type;
extract_value(type, "Type", line, "none");
auto lookup = types.find(ToLower(type));
trainType = lookup != types.end() ? lookup->second : train_type::generic;
}
if (trainType == train_type::emu)
{
IminLo = 1;
IminHi = 2;
imin = 1;
}
}
void physics::Vehicle::LoadFIZ_Load(std::string const &line)
{
auto const acceptedloads{Split(extract_value("LoadAccepted", line), ',')};
if (acceptedloads.empty())
{
return;
}
auto const minoffsets{Split(extract_value("LoadMinOffset", line), ',')};
auto minoffset{0.f};
auto minoffsetsiterator{std::begin(minoffsets)};
// NOTE: last (if any) offset parameter retrieved from the list applies to the remainder of the list
// TBD, TODO: include other load parameters in this system
for (auto &load : acceptedloads)
{
if (minoffsetsiterator != std::end(minoffsets))
{
minoffset = std::stof(*minoffsetsiterator);
++minoffsetsiterator;
}
LoadAttributes.emplace_back(ToLower(load), minoffset);
}
extract_value(maxLoad, "MaxLoad", line, "");
extract_value(LoadQuantity, "LoadQ", line, "");
extract_value(OverLoadFactor, "OverLoadFactor", line, "");
extract_value(LoadSpeed, "LoadSpeed", line, "");
extract_value(UnLoadSpeed, "UnLoadSpeed", line, "");
}
void physics::Vehicle::LoadFIZ_Headlights(std::string const &line)
{
extract_value(refR, "LampRed", line, "");
extract_value(refG, "LampGreen", line, "");
extract_value(refB, "LampBlue", line, "");
extract_value(dimMultiplier, "DimmedMultiplier", line, "");
extract_value(normMultiplier, "NormalMultiplier", line, "");
extract_value(highDimMultiplier, "HighbeamDimmedMultiplier", line, "");
extract_value(highMultiplier, "HighBeamMultiplier", line, "");
}
void physics::Vehicle::LoadFIZ_Dimensions(std::string const &line)
{
extract_value(Dim.L, "L", line, "");
extract_value(Dim.H, "H", line, "");
extract_value(Dim.W, "W", line, "");
// height of the centre of gravity of the empty vehicle [m], for the criteria of derailment
extract_value(CentreOfGravity, "CoGH", line, "");
extract_value(Cx, "Cx", line, "0.3");
if (Dim.H <= 2.0)
{
// gdyby nie było parametru, lepsze to niż zero
Floor = static_cast<float>(Dim.H);
}
else
{
// zgodność wsteczna
Floor = 0.0;
}
extract_value(Floor, "Floor", line, "");
}
void physics::Vehicle::LoadFIZ_Wheels(std::string const &line)
{
extract_value(wheelDiameter, "D", line, "");
WheelDiameterL = wheelDiameter; // gdyby nie było parametru, lepsze to niż zero
extract_value(WheelDiameterL, "Dl", line, "");
WheelDiameterT = wheelDiameter; // gdyby nie było parametru, lepsze to niż zero
extract_value(WheelDiameterT, "Dt", line, "");
extract_value(TrackW, "Tw", line, "");
extract_value(AxleInertialMoment, "AIM", line, "");
extract_value(AxleArangement, "Axle", line, "");
nPoweredAxles = s2NPW(AxleArangement);
nAxles = nPoweredAxles + s2NNW(AxleArangement);
BearingType = extract_value("BearingType", line) == "Roll" ? 1 : 0;
extract_value(aDist, "Ad", line, "");
extract_value(bDist, "Bd", line, "");
if (AxleInertialMoment <= 0.0)
{
/*
AxleInertialMoment = 1.0;
*/
// approximation formula by youby
auto const k = 472.0; // arbitrary constant
AxleInertialMoment = k / 4.0 * std::pow(wheelDiameter, 4.0) * nAxles;
mred = k * std::pow(wheelDiameter, 2.0) * nAxles;
}
}
void physics::Vehicle::LoadFIZ_Brake(std::string const &line)
{
extract_value(brakes.config.distributorParameters, "BrakeValve", line, "");
BrakeValveDecode(brakes.config.distributorParameters);
BrakeSubsystemDecode();
extract_value(brakes.config.blocksPerAxle, "NBpA", line, "");
extract_value(brakes.config.maxForce, "MBF", line, "");
extract_value(brakes.config.distributorSize, "Size", line, "");
extract_value(brakes.config.trackBrakeForce, "TBF", line, "");
brakes.config.trackBrakeForce *= 1000.0;
extract_value(brakes.config.maxCylinderPressure[3], "MaxBP", line, "");
if (brakes.config.maxCylinderPressure[3] > 0.0)
{
extract_value(brakes.config.cylinders.count, "BCN", line, "");
if (brakes.config.cylinders.count > 0)
{
extract_value(brakes.config.maxCylinderPressure[0], "MaxLBP", line, "");
if (brakes.config.maxCylinderPressure[0] < 0.01)
{
brakes.config.maxCylinderPressure[0] = brakes.config.maxCylinderPressure[3];
}
extract_value(brakes.config.maxCylinderPressure[1], "TareMaxBP", line, "");
extract_value(brakes.config.maxCylinderPressure[2], "MedMaxBP", line, "");
extract_value(brakes.config.maxCylinderPressure[4], "MaxASBP", line, "");
if (brakes.config.maxCylinderPressure[4] < 0.01)
{
brakes.config.maxCylinderPressure[4] = 0.0;
}
extract_value(brakes.config.cylinders.radius, "BCR", line, "");
extract_value(brakes.config.cylinders.stroke, "BCD", line, "");
extract_value(brakes.config.cylinders.springForce, "BCS", line, "");
extract_value(brakes.config.cylinders.slackAdjusterForce, "BSA", line, "");
extract_value(brakes.config.cylinders.riggingEfficiency, "BRE", line, "1");
extract_value(brakes.config.cylinders.leverRatio[0], "BCM", line, "");
extract_value(brakes.config.cylinders.leverRatio[1], "BCMlo", line, "");
extract_value(brakes.config.cylinders.leverRatio[2], "BCMHi", line, "");
brakes.config.pressureToForce = 100 * M_PI * std::pow(brakes.config.cylinders.radius, 2); // w kN/bar
if (brakes.config.cylinders.leverRatio[1] > 0.0 || brakes.config.maxCylinderPressure[1] > 0.0)
{
brakes.loadSetting = 1;
}
else
{
brakes.loadSetting = 0;
}
brakes.config.cylinderVolume = M_PI * std::pow(brakes.config.cylinders.radius, 2) * brakes.config.cylinders.stroke * brakes.config.cylinders.count;
extract_value(brakes.config.valveVolume, "BVV", line, "");
{
std::map<std::string, int, std::less<>> 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));
brakes.config.method = lookup != brakemethods.end() ? lookup->second : 0;
}
extract_value(brakes.config.rapidRatio, "RM", line, "1");
extract_value(brakes.config.rapidSpeed, "RV", line, "55");
}
}
else
{
// maxbrakepress[3] == 0 or less
brakes.config.pressureToForce = 0;
}
// Ra 2014-07: trochę niedokładności
// the draws are sequenced: the order of the operands of '-' is unspecified, and GCC and MSVC draw them the other way round
auto const firstdraw{Random(10)};
brakes.controlReservoirPressure = 5 + 0.001 * (Random(10) - firstdraw);
extract_value(brakes.controlReservoirPressure, "HiPP", line, "");
brakes.config.pipeHighPressure = brakes.controlReservoirPressure;
brakes.config.pipeLowPressure = std::min(brakes.config.pipeHighPressure, 3.5);
extract_value(brakes.config.pipeLowPressure, "LoPP", line, "");
brakes.config.pipePressureRange = brakes.config.pipeHighPressure - brakes.config.pipeLowPressure;
extract_value(air.config.mainReservoirVolume, "Vv", line, "");
/*
if( VeselVolume == 0.0 ) { VeselVolume = 0.01; }
*/
extract_value(air.compressor.config.minPressure, "MinCP", line, "");
extract_value(air.compressor.config.maxPressure, "MaxCP", line, "");
extract_value(air.compressor.config.minPressureCabB, "MinCP_B", line, "");
extract_value(air.compressor.config.maxPressureCabB, "MaxCP_B", line, "");
extract_value(air.compressor.config.tankValve, "CompressorTankValve", line, "");
extract_value(air.compressor.config.speed, "CompressorSpeed", line, "");
extract_value(brakes.emergencyValve.offPressure, "MinEVP", line, "");
extract_value(brakes.emergencyValve.onPressure, "MaxEVP", line, "");
extract_value(brakes.emergencyValve.area, "EVArea", line, "");
extract_value(brakes.config.universalButtonActions[0], "UBB1", line, "");
extract_value(brakes.config.universalButtonActions[1], "UBB2", line, "");
extract_value(brakes.config.universalButtonActions[2], "UBB3", line, "");
extract_value(brakes.pipeLock.onPressure, "LPOn", line, "-1");
extract_value(brakes.pipeLock.offPressure, "LPOff", line, "-1");
extract_value(brakes.pipeLock.unlockHandlePosition, "HandlePipeUnlockPos", line, "-3");
extract_value(brakes.config.emergencyCutsOffDriverValve, "EmergencyCutsOffHandle", line, "");
{
using enum CompressorSupply;
std::map<std::string, CompressorSupply, std::less<>> compressorpowers{
{"Main", mainCircuit},
// the default: powered by the converter, switched by hand
{"Converter", converter},
{"Engine", engine}, // equivalent of Main, TODO: separate 'main' and 'engine' in the code
{"Coupler1", frontUnitConverter}, // włączana w silnikowym EZT z przodu
{"Coupler2", rearUnitConverter} // włączana w silnikowym EZT z tyłu
};
auto lookup = compressorpowers.find(extract_value("CompressorPower", line));
air.compressor.config.supply = lookup != compressorpowers.end() ? lookup->second : converterManual;
}
extract_value(air.compressor.config.startDelay, "CompressorStartDelay", line, "");
if (true == extract_value(air.config.leakRate, "AirLeakRate", line, ""))
{
// the parameter is provided in form of a multiplier, where 1.0 means the default rate of 0.01
air.config.leakRate *= 0.01;
}
extract_value(ReleaserEnabledOnlyAtNoPowerPos, "ReleaserPowerPosLock", line, EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric ? "yes" : "no");
if (air.compressor.config.minPressureCabB > 0.0)
{
air.compressor.config.minPressureCabA = air.compressor.config.minPressure;
air.compressor.config.cabDependent = true;
}
else
{
air.compressor.config.minPressureCabB = air.compressor.config.minPressure;
}
if (air.compressor.config.maxPressureCabB > 0.0)
{
air.compressor.config.maxPressureCabA = air.compressor.config.maxPressure;
air.compressor.config.cabDependent = true;
}
else
{
air.compressor.config.maxPressureCabB = air.compressor.config.maxPressure;
}
}
void physics::Vehicle::LoadFIZ_Doors(std::string const &line)
{
std::map<std::string, control_t, std::less<>> doorcontrols{
{"Passenger", control_t::passenger}, {"AutomaticCtrl", control_t::autonomous}, {"DriverCtrl", control_t::driver}, {"Conductor", control_t::conductor}, {"Mixed", control_t::mixed}};
// opening method
{
auto lookup = doorcontrols.find(extract_value("OpenCtrl", line));
Doors.open_control = lookup != doorcontrols.end() ? lookup->second : control_t::passenger;
}
// closing method
{
auto lookup = doorcontrols.find(extract_value("CloseCtrl", line));
Doors.close_control = lookup != doorcontrols.end() ? lookup->second : control_t::passenger;
}
// automatic closing conditions
extract_value(Doors.auto_duration, "DoorStayOpen", line, "");
extract_value(Doors.auto_velocity, "DoorAutoCloseVel", line, "");
extract_value(Doors.auto_include_remote, "DoorAutoCloseRemote", line, "");
// operation permit
extract_value(Doors.permit_needed, "DoorNeedPermit", line, "");
// the door closure lamp (SOD) of the cab signals the doors of the whole consist
extract_value(Doors.closure_signal, "DoorClosureSignal", line, "");
{
auto permitpresets = Split(extract_value("DoorPermitList", line), '|');
for (auto const &permit : permitpresets)
{
Doors.permit_presets.emplace_back(std::stoi(permit));
}
if (false == Doors.permit_presets.empty())
{
// 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<int>(static_cast<int>(Doors.permit_presets.size()), Doors.permit_preset) - 1;
}
}
extract_value(Doors.open_rate, "OpenSpeed", line, "");
extract_value(Doors.open_delay, "DoorOpenDelay", line, "");
extract_value(Doors.close_rate, "CloseSpeed", line, "");
extract_value(Doors.close_delay, "DoorCloseDelay", line, "");
extract_value(Doors.range, "DoorMaxShiftL", line, "");
extract_value(Doors.range, "DoorMaxShiftR", line, "");
extract_value(Doors.range_out, "DoorMaxShiftPlug", line, "");
std::map<std::string, int, std::less<>> doortypes{
{"Shift", 1},
{"Rotate", 2},
{"Fold", 3},
{"Plug", 4},
};
// opening method
{
auto lookup = doortypes.find(extract_value("DoorOpenMethod", line));
Doors.type = lookup != doortypes.end() ? lookup->second : 2; // default type is plain, rotating door
}
extract_value(Doors.has_warning, "DoorClosureWarning", line, "");
extract_value(Doors.has_autowarning, "DoorClosureWarningAuto", line, "");
extract_value(Doors.has_lock, "DoorBlocked", line, "");
extract_value(Doors.doorLockSpeed, "DoorLockSpeed", line, "");
{
auto const remotedoorcontrol{Doors.open_control == control_t::driver || Doors.open_control == control_t::conductor || Doors.open_control == control_t::mixed};
extract_value(Doors.voltage, "DoorVoltage", line, remotedoorcontrol ? "24" : "0");
}
extract_value(Doors.step_rate, "PlatformSpeed", line, "");
extract_value(Doors.step_range, "PlatformMaxShift", line, "");
std::string platformopenmethod;
extract_value(platformopenmethod, "PlatformOpenMethod", line, "");
if (platformopenmethod == "Shift")
{
Doors.step_type = 1;
} // przesuw
extract_value(MirrorMaxShift, "MirrorMaxShift", line, "");
extract_value(MirrorVelClose, "MirrorVelClose", line, "");
extract_value(DoorsOpenWithPermitAfter, "DoorOpenWithPermit", line, "");
extract_value(doorsPermitLightBlinking, "DoorsPermitLightBlinking", line, "");
}
namespace
{
// the value of an optional key of the line, or the default without it
double optional_value(std::string const &Line, std::string const &Key, double const Default)
{
auto value{Default};
extract_value(value, Key, Line, "");
return value;
}
// the value of an optional key of the line given in kilo-units, in units; or the default (in units) without it
double optional_kilo_value(std::string const &Line, std::string const &Key, double const Default)
{
auto value{0.0};
return extract_value(value, Key, Line, "") && value > 0.0 ? value * 1000.0 : Default;
}
// the play of a coupling as made, for each kind: a screw coupling is tightened so that the buffers touch, the knuckles of
// an automatic coupler have about a centimetre between them, a chain hangs loose
double default_slack(TCouplerType const Type)
{
switch (Type)
{
case TCouplerType::Automatic:
return 0.005;
case TCouplerType::Chain:
return 0.05;
default:
return 0.0;
}
}
// the parameters of the physical model of the coupling (couplerphysics in eu07.ini, see couplerphysics.h), taken from
// those of the legacy model, and the optional keys of the .fiz for what the legacy model doesn't have:
// Slack [m] the play of the coupling of this end, negative for a screw coupling tightened to press the buffers in
// ProgB, ProgC [-] progression of the buffers and of the draw gear, 0 linear, up to 0.9
// UnloadB, UnloadC [-] force of the unloading curve of the buffers and of the draw gear to that of the loading one
// FyieldC [kN] the force past which the link stretches for good; DbreakC [m] the elongation at which it breaks
// kL [kN/m] stiffness of the steel parts past the travel of the springs; FcrushB [kN] the buffers give under it
// RestitutionSolid [-] coefficient of restitution of a hit on the springs gone solid
coupler_physics::end_parameters coupler_physics_parameters(TCoupling const &Coupler, std::string const &Line)
{
coupler_physics::end_parameters parameters;
parameters.buffers = {Coupler.SpringKB, Coupler.DmaxB, std::clamp(optional_value(Line, "ProgB", 0.5), 0.0, 0.9)};
parameters.draw_gear = {Coupler.SpringKC, Coupler.DmaxC, std::clamp(optional_value(Line, "ProgC", 0.3), 0.0, 0.9)};
// only a screw coupling can be tightened to press the buffers in, and not past their travel
auto const tightest{Coupler.CouplerType == TCouplerType::Screw ? -Coupler.DmaxB : 0.0};
parameters.slack = std::max(optional_value(Line, "Slack", default_slack(Coupler.CouplerType)), tightest);
// the legacy model sprang back at beta of the force it was loaded with
auto const unloading{Coupler.beta > 0.0 && Coupler.beta < 1.0 ? Coupler.beta : 0.5};
parameters.buffers_unloading = std::clamp(optional_value(Line, "UnloadB", unloading), 0.05, 1.0);
parameters.draw_gear_unloading = std::clamp(optional_value(Line, "UnloadC", unloading), 0.05, 1.0);
// as much as the legacy model had
parameters.damping = CouplerTune * (Coupler.FmaxC + Coupler.FmaxB) * std::max(Coupler.beta, 0.0);
// FmaxC is the rated breaking force of the coupling
auto const ultimate{std::max(Coupler.FmaxC, 1.0)};
auto const yield{std::min(optional_kilo_value(Line, "FyieldC", 0.8 * ultimate), ultimate)};
auto const elongation{std::max(optional_value(Line, "DbreakC", 0.02), 0.001)};
parameters.link = {yield, ultimate, std::max((ultimate - yield) / elongation, 1.0), Coupler.CouplerType != TCouplerType::Articulated};
// the steel parts give a few millimetres under the rated force
parameters.link_stiffness = optional_kilo_value(Line, "kL", ultimate / 0.003);
parameters.crush_force = optional_kilo_value(Line, "FcrushB", 2.5 * std::max(Coupler.FmaxB, Coupler.FmaxC));
parameters.solid_restitution = std::clamp(optional_value(Line, "RestitutionSolid", parameters.solid_restitution), 0.05, 0.95);
return parameters;
}
void scale_strength(coupler_physics::link_strength &Link, double const Factor)
{
Link.yield *= Factor;
Link.ultimate *= Factor;
}
// the optional keys of the collisions past the buffers (physics.collisions new, see collision.h), what's not given
// comes from the kind of the vehicle:
// FcrushPeak, FcrushPlateau [kN] the force the end starts to crush at, and keeps crushing at
// CrushOnset, CrushDensify, CrushLimit [m] the crush the peak drops at, it packs down past, it can't go past
// CrushHardening [1/m] the growth of the force past CrushDensify, to the plateau for each metre
// CrashZone [yes/no] built to EN 15227: energy absorbers and anticlimbers; AntiClimber [yes/no] on its own
// BufferHeight [m] of the empty vehicle above the rail
// BufferCategory [A/B/C/L/P] the buffers of EN 15551 (P those of the coaches) in place of kB and DmaxB
collision::end_definition collision_definition(std::string const &Line)
{
collision::end_definition definition;
auto const number = [&Line](std::string const &Key, double const Scale) -> std::optional<double> {
auto value{0.0};
if (extract_value(value, Key, Line, "") && value >= 0.0)
{
return value * Scale;
}
return std::nullopt;
};
auto const flag = [&Line](std::string const &Key) -> std::optional<bool> {
auto value{false};
if (extract_value(value, Key, Line, ""))
{
return value;
}
return std::nullopt;
};
definition.peak = number("FcrushPeak", 1000.0);
definition.plateau = number("FcrushPlateau", 1000.0);
definition.onset = number("CrushOnset", 1.0);
definition.densify = number("CrushDensify", 1.0);
definition.hardening = number("CrushHardening", 1.0);
definition.limit = number("CrushLimit", 1.0);
definition.crash_zone = flag("CrashZone");
definition.anticlimber = flag("AntiClimber");
definition.buffer_height = number("BufferHeight", 1.0);
return definition;
}
} // namespace
void physics::Vehicle::LoadFIZ_BuffCoupl(std::string const &line, int const Index)
{
TCoupling *thiscoupler;
if (Index == 2)
{
thiscoupler = &Couplers[1];
}
else
{
thiscoupler = &Couplers[0];
}
std::map<std::string, TCouplerType, std::less<>> couplertypes{
{"Automatic", TCouplerType::Automatic}, {"Screw", TCouplerType::Screw}, {"Chain", TCouplerType::Chain}, {"Bare", TCouplerType::Bare}, {"Articulated", TCouplerType::Articulated},
};
auto lookup = couplertypes.find(extract_value("CType", line));
thiscoupler->CouplerType = lookup != couplertypes.end() ? lookup->second : TCouplerType::NoCoupler;
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, "");
// the sets are numbers in the definition, the sums of the numbers of the kinds of coupling
auto automaticflag{thiscoupler->AutomaticCouplingFlag.Bits()};
extract_value(automaticflag, "AutomaticFlag", line, "");
thiscoupler->AutomaticCouplingFlag = CouplingSet::FromBits(automaticflag);
auto allowedflag{thiscoupler->AllowedFlag.Bits()};
extract_value(allowedflag, "AllowedFlag", line, "");
// negative: the coupling is permanent besides
thiscoupler->AllowedFlag = allowedflag < 0 ? CouplingSet::FromBits(-allowedflag) | Coupling::permanent : CouplingSet::FromBits(allowedflag);
auto powercoupling{thiscoupler->PowerCoupling.Bits()};
extract_value(powercoupling, "PowerCoupling", line, "");
thiscoupler->PowerCoupling = CouplingSet::FromBits(powercoupling);
auto powerflag{thiscoupler->PowerFlag.Bits()};
extract_value(powerflag, "PowerFlag", line, "");
thiscoupler->PowerFlag = CouplingSet::FromBits(powerflag);
extract_value(thiscoupler->control_type, "ControlType", line, "");
if (thiscoupler->CouplerType != TCouplerType::NoCoupler && thiscoupler->CouplerType != TCouplerType::Bare && thiscoupler->CouplerType != TCouplerType::Articulated)
{
thiscoupler->SpringKC *= 1000;
thiscoupler->FmaxC *= 1000;
thiscoupler->SpringKB *= 1000;
thiscoupler->FmaxB *= 1000;
}
else if (thiscoupler->CouplerType == TCouplerType::Bare)
{
thiscoupler->SpringKC = 50.0 * emptyMass + Ftmax / 0.05;
thiscoupler->DmaxC = 0.05;
thiscoupler->FmaxC = 100.0 * emptyMass + 2 * Ftmax;
thiscoupler->SpringKB = 60.0 * emptyMass + Ftmax / 0.05;
thiscoupler->DmaxB = 0.05;
thiscoupler->FmaxB = 50.0 * emptyMass + 2.0 * Ftmax;
thiscoupler->beta = 0.3;
}
else if (thiscoupler->CouplerType == TCouplerType::Articulated)
{
/*
coupler->SpringKC = 60.0 * emptyMass + 1000;
coupler->DmaxC = 0.05;
coupler->FmaxC = 20000000.0 + 2.0 * Ftmax;
coupler->SpringKB = 70.0 * emptyMass + 1000;
coupler->DmaxB = 0.05;
coupler->FmaxB = 4000000.0 + 2.0 * Ftmax;
coupler->beta = 0.55;
*/
thiscoupler->SpringKC = 4500 * 1000;
thiscoupler->FmaxC = 850 * 1000;
thiscoupler->SpringKB = 9200 * 1000;
thiscoupler->FmaxB = 320 * 1000;
thiscoupler->beta = 0.55;
// the spring force is taken up to Dmax only, past it the vehicles collide (CollisionDetect()); so the joint
// carries the full FmaxC either way before it gives. with 0.05 m it carried 225 kN, short of what a loaded
// articulated wagon in a freight train takes, which then collided at every step (eu07/maszyna#553)
thiscoupler->DmaxC = std::max(0.05, thiscoupler->FmaxC / thiscoupler->SpringKC);
thiscoupler->DmaxB = std::max(0.05, thiscoupler->FmaxC / thiscoupler->SpringKB);
}
// the buffers of a category of EN 15551 in place of the springs given
auto const categoryname{extract_value("BufferCategory", line)};
auto const category{categoryname.empty() ? std::nullopt : collision::buffer_category_of(categoryname.front())};
auto const buffered{thiscoupler->CouplerType != TCouplerType::NoCoupler && thiscoupler->CouplerType != TCouplerType::Bare && thiscoupler->CouplerType != TCouplerType::Articulated};
if (category && buffered)
{
auto const linear{collision::buffer_curve(*category, 0.0)};
thiscoupler->SpringKB = linear.stiffness;
thiscoupler->DmaxB = linear.travel;
}
thiscoupler->physics = coupler_physics_parameters(*thiscoupler, line);
if (category && buffered)
{
thiscoupler->physics.buffers = collision::buffer_curve(*category, thiscoupler->physics.buffers.progression);
}
thiscoupler->collision = collision_definition(line);
thiscoupler->collision.buffers = category;
if (Index == 0)
{
// 0 indicates single entry for both couplers
Couplers[1] = Couplers[0];
}
// each coupling as made is a little stronger than its rated force, a different one at each end
for (auto const end : VehicleEnds)
{
if (Index == 0 || end == (Index == 2 ? VehicleEnd::rear : VehicleEnd::front))
{
scale_strength(Couplers[end].physics.link, coupler_physics::strength_scatter(Name, NumberOf(end)));
}
}
}
void physics::Vehicle::LoadFIZ_TurboPos(std::string const &Input)
{
extract_value(TurboTest, "TurboPos", Input, "");
}
void physics::Vehicle::LoadFIZ_Cntrl(std::string const &line)
{
LoadFIZ_CntrlBrakes(line);
LoadFIZ_CntrlControllers(line);
LoadFIZ_CntrlStarts(line);
}
// Cntrl.: the brake system, the handles, the brake delays and the local and manual brakes
void physics::Vehicle::LoadFIZ_CntrlBrakes(std::string const &line)
{
{
using enum TBrakeSystem;
std::map<std::string, TBrakeSystem, std::less<>> brakesystems{{"Pneumatic", Pneumatic}, {"ElectroPneumatic", ElectroPneumatic}};
auto lookup = brakesystems.find(extract_value("BrakeSystem", line));
brakes.config.kind = lookup != brakesystems.end() ? lookup->second : Individual;
}
if (brakes.config.kind != TBrakeSystem::Individual)
{
LoadFIZ_CntrlTrainBrake(line);
} // brakesystem != individual
// localbrake
{
using enum TLocalBrake;
std::map<std::string, TLocalBrake, std::less<>> localbrakes{{"ManualBrake", ManualBrake}, {"PneumaticBrake", PneumaticBrake}, {"HydraulicBrake", HydraulicBrake}};
auto lookup = localbrakes.find(extract_value("LocalBrake", line));
brakes.config.localKind = lookup != localbrakes.end() ? lookup->second : NoBrake;
}
// mbrake
extract_value(brakes.config.hasHandBrake, "ManualBrake", line, "");
}
// Cntrl.: of a vehicle with a train brake, its positions, delays, modes, handles, load weighing and anti-slip brake
void physics::Vehicle::LoadFIZ_CntrlTrainBrake(std::string const &line)
{
using enum TBrakeHandle;
extract_value(brakes.config.handlePositions, "BCPN", line, "");
for (int idx = 0; idx < 4; ++idx)
{
extract_value(brakes.config.delays[idx], std::format("BDelay{}", idx + 1), line, "");
}
// brakedelays, brakedelayflag
{
std::map<std::string, int, std::less<>> brakedelays{{"GPR", bdelay_G + bdelay_P + bdelay_R},
{"PR", bdelay_P + bdelay_R},
{"GP", bdelay_G + bdelay_P},
{"R", bdelay_R},
{"P", bdelay_P},
{"G", bdelay_G},
{"GPR+Mg", bdelay_G + bdelay_P + bdelay_R + bdelay_M},
{"PR+Mg", bdelay_P + bdelay_R + bdelay_M}};
std::map<std::string, int, std::less<>> brakedelayflags{{"R", bdelay_R}, {"P", bdelay_P}, {"G", bdelay_G}};
std::string brakedelay;
extract_value(brakedelay, "BrakeDelays", line, "");
auto lookup = brakedelays.find(brakedelay);
brakes.config.availableDelays = lookup != brakedelays.end() ? lookup->second : 0;
lookup = brakedelayflags.find(brakedelay);
brakes.delaySetting = lookup != brakedelayflags.end() ? lookup->second : 0;
}
// brakeopmode
{
std::map<std::string, int, std::less<>> 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));
brakes.config.availableOperatingModes = lookup != brakeopmodes.end() ? lookup->second : 0;
}
// brakehandle
{
std::map<std::string, TBrakeHandle, std::less<>> 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));
brakes.config.driverValveType = lookup != brakehandles.end() ? lookup->second : NoHandle;
}
extract_value(brakes.config.driverValveSettings.automaticOverload, "HAO", line, "");
extract_value(brakes.config.driverValveSettings.manualOverload, "HMO", line, "");
extract_value(brakes.config.driverValveSettings.genericParameter1, "HGDP1", line, "");
extract_value(brakes.config.driverValveSettings.genericParameter2, "HGDP2", line, "");
extract_value(brakes.config.driverValveSettings.overloadMaxPressure, "OMP", line, "");
extract_value(brakes.config.driverValveSettings.overloadPressureDecrease, "OPD", line, "");
// brakelochandle
{
std::map<std::string, TBrakeHandle, std::less<>> locbrakehandles{{"FD1", FD1}, {"Knorr", Knorr}, {"Westinghouse", West}};
auto lookup = locbrakehandles.find(extract_value("LocBrakeHandle", line));
brakes.config.independentValveType = lookup != locbrakehandles.end() ? lookup->second : NoHandle;
}
// mbpm
if (true == extract_value(brakes.config.maxPressureMass, "MaxBPMass", line, ""))
{
// NOTE: only convert the value from tons to kilograms if the entry is present in the config file
brakes.config.maxPressureMass *= 1000.0;
}
// asbtype
LoadFIZ_CntrlAntiSlipBrake(ToLower(extract_value("ASB", line)));
}
// Cntrl.: the kind of the anti-slip brake, by hand or automatic only for a vehicle with a brake handle
void physics::Vehicle::LoadFIZ_CntrlAntiSlipBrake(std::string_view const asb)
{
if (asb == "yes")
{
brakes.config.antiSlipType = 128;
}
else if (brakes.config.handlePositions > 0 && asb == "manual")
{
brakes.config.antiSlipType = 1;
}
else if (brakes.config.handlePositions > 0 && asb == "automatic")
{
brakes.config.antiSlipType = 2;
}
}
// Cntrl.: the controllers, their delays, the cab and the switches of the driver's desk
void physics::Vehicle::LoadFIZ_CntrlControllers(std::string const &line)
{
// maksymalna predkosc dostepna na tarczce predkosciomierza
extract_value(maxTachoSpeed, "MaxTachoSpeed", line, "");
// horns
{
using enum horn_supply;
std::map<std::string, horn_supply, std::less<>> const hornsupplies{{"Pneumatic", air}, {"Electric", electric}};
auto lookup = hornsupplies.find(extract_value("HornType", line));
hornSupply = lookup != hornsupplies.end() ? lookup->second : air;
lookup = hornsupplies.find(extract_value("Horn3Type", line));
Horn3Supply = lookup != hornsupplies.end() ? lookup->second : hornSupply;
}
// dynamicbrake
{
std::map<std::string, int, std::less<>> dynamicbrakes{{"Passive", dbrake_passive}, {"Switch", dbrake_switch}, {"Reversal", dbrake_reversal}, {"Automatic", dbrake_automatic}};
auto lookup = dynamicbrakes.find(extract_value("DynamicBrake", line));
brakes.electrodynamic.type = lookup != dynamicbrakes.end() ? lookup->second : dbrake_none;
extract_value(brakes.electrodynamic.ammeters, "DBAM", line, "");
}
// split ED/pneumatic brake control: when true the local brake operates only on the
// pneumatic locomotive cylinder while electrodynamic braking is commanded by a
// separate "dynamicbrakectrl" lever (or the negative range of jointctrl).
extract_value(brakes.electrodynamic.splitFromPneumatic, "SplitEDPneumaticBrake", line, "");
// number of stepped positions for the dedicated ED brake controller (default 10)
brakes.electrodynamic.controllerPositions = 10;
extract_value(brakes.electrodynamic.controllerPositions, "DBPN", line, "");
if (brakes.electrodynamic.controllerPositions < 1)
{
brakes.electrodynamic.controllerPositions = 10;
}
extract_value(MainCtrlPosNo, "MCPN", line, "");
extract_value(scndCtrlPosNo, "SCPN", line, "");
extract_value(ScndInMain, "SCIM", line, "");
extract_value(mainCtrlMaxDirChangePos, "DirChangeMaxPos", line, "");
if (auto const autorelay{ToLower(extract_value("AutoRelay", line))}; autorelay == "optional")
{
autoRelayType = 2;
}
else if (autorelay == "yes")
{
autoRelayType = 1;
}
else
{
autoRelayType = 0;
}
// a key of its own rather than a new AutoRelay value: an exe that doesn't know it reads the line as before, and the value
// stays Optional, which every check of the switch looks for
extract_value(fieldShuntSwitch, "FieldShuntSwitch", line, "");
extract_value(CoupledCtrl, "CoupledCtrl", line, "");
extract_value(HasCamshaft, "Camshaft", line, "");
extract_value(EIMCtrlType, "EIMCtrlType", line, "");
EIMCtrlType = std::clamp(EIMCtrlType, 0, 3);
extract_value(brakes.config.independentTraxx, "LocalBrakeTraxx", line, "");
extract_value(EIMCtrlAdditionalZeros, "EIMCtrlAddZeros", line, "");
extract_value(eimCtrlEmergency, "EIMCtrlEmergency", line, "");
// Elf (EIMCtrlType 2): an emergency brake position below the controller's position 0, which shifts the other positions up by one
extract_value(eimCtrlMainEmergency, "EIMCtrlMainEmergency", line, "");
if (auto const elfpositions{4 + EIMCtrlEmergencyPositions()}; EIMCtrlEmergencyPositions() > 0 && MainCtrlPosNo < elfpositions)
{
// the old positions in the file: without the fix-up the controller would have no power position, and the
// reverser would stop working at neutral (DirChangeMaxPos read before, in the old positions)
mainCtrlMaxDirChangePos += EIMCtrlEmergencyPositions();
ErrorLog(std::format("Bad fiz: EIMCtrlMainEmergency needs MCPN={} in {}, DirChangeMaxPos taken as {}", elfpositions, TypeName, mainCtrlMaxDirChangePos));
MainCtrlPosNo = elfpositions;
}
extract_value(ScndS, "ScndS", line, ""); // brak pozycji rownoleglej przy niskiej nastawie PSR
extract_value(ScndCtrlResistiveLock, "ScndCtrlResistiveLock", line, ""); // bocznikowanie tylko na pozycjach bezoporowych
extract_value(initialCtrlDelay, "IniCDelay", line, "");
extract_value(CtrlDelay, "SCDelay", line, "");
CtrlDownDelay = CtrlDelay; // hunter-101012: jesli nie ma SCDDelay;
extract_value(CtrlDownDelay, "SCDDelay", line, "");
// hunter-111012: dla siodemek 303E
FastSerialCircuit = ToLower(extract_value("FSCircuit", line)) == "yes" ? 1 : 0;
extract_value(BackwardsBranchesAllowed, "BackwardsBranchesAllowed", line, "");
extract_value(AutomaticCabActivation, "AutomaticCabActivation", line, "");
extract_value(InactiveCabFlag, "InactiveCabFlag", line, "");
extract_value(brakes.holding.deceleration, "SBD", line, "");
extract_value(brakes.holding.releaseDelay, "SBDReleaseDelay", line, ""); // the holding brake waits for the power demand this long, s
extract_value(brakes.spring.releasesParking, "ReleaseParkingBySpringBrake", line, "");
extract_value(brakes.spring.releasesParkingWithDoorOpen, "ReleaseParkingBySpringBrakeWhenDoorIsOpen", line, "");
extract_value(brakes.spring.cutsOffDrive, "SpringBrakeCutsOffDrive", line, "");
extract_value(brakes.spring.driveEmergencySpeed, "SpringBrakeDriveEmergencyVel", line, "");
extract_value(HideDirStatusWhenMoving, "HideDirStatusWhenMoving", line, "");
extract_value(HideDirStatusSpeed, "HideDirStatusSpeed", line, "");
extract_value(isDoubleClickForMeasureNeeded, "DCMB", line, "");
extract_value(DistanceCounterDoublePressPeriod, "DCDPP", line, "");
extract_value(lowVoltage.config.batteryButtonImpulse, "IBTB", line, "");
extract_value(lowVoltage.config.batteryButtonHeld, "SBBBH", line, "");
extract_value(lowVoltage.config.batteryButtonHoldTime, "BBHT", line, "");
}
// Cntrl.: how the devices start (MainStart, BatteryStart, ...) and their relays
void physics::Vehicle::LoadFIZ_CntrlStarts(std::string const &line)
{
using enum start_t;
std::map<std::string, start_t, std::less<>> starts{{"Disabled", disabled}, {"Manual", manual}, {"Automatic", automatic}, {"Mixed", manualwithautofallback},
{"Battery", battery}, {"Converter", converter}, {"Direction", direction}};
// main circuit
extract_value(lineBreaker.config.initTime, "MainInitTime", line, "");
{
auto lookup = starts.find(extract_value("MainStart", line));
lineBreaker.config.start = lookup != starts.end() ? lookup->second : manual;
}
extract_value(lineBreaker.config.pantographsRequireIt, "PantRequiresMain", line, "");
// the brake pipe pressure of an emergency brake application, which opens the line breaker under power
extract_value(lineBreaker.config.emergencyOffPressure, "EmergencyBrakeMainOff", line, "");
lineBreaker.config.emergencyOffPressure = std::max(0.0, lineBreaker.config.emergencyOffPressure);
// battery
{
auto lookup = starts.find(extract_value("BatteryStart", line));
lowVoltage.config.batteryStart = lookup != starts.end() ? lookup->second : manual;
}
// converter
{
auto lookup = starts.find(extract_value("ConverterStart", line));
this->converter.config.start = lookup != starts.end() ? lookup->second : manual;
}
extract_value(this->converter.config.startDelay, "ConverterStartDelay", line, "");
extract_value(this->converter.config.overloadRelayOffWithLineBreaker, "ConverterOverloadWhenMainIsOff", line, trainType == train_type::emu ? "yes" : "no");
// compressor
{
auto lookup = starts.find(extract_value("CompressorStart", line));
air.compressor.config.start = lookup != starts.end() ? lookup->second : manual;
}
// pantograph compressor
{
auto lookup = starts.find(extract_value("PantCompressorStart", line));
pantographAir.config.compressorStart = lookup != starts.end() ? lookup->second : manual;
}
// pantograph compressor valve
pantographAir.config.autoValve = trainType == train_type::emu; // legacy code behaviour, automatic valve was initially installed in all EMUs
extract_value(pantographAir.config.autoValve, "PantAutoValve", line, "");
// pantographs valve
{
auto lookup = starts.find(extract_value("PantEPValveStart", line));
pantographAir.valve.start_type = lookup != starts.end() ? lookup->second : automatic; // legacy code behaviour, there was no pantographs valve
extract_value(pantographAir.valve.spring, "PantEPValveSpring", line, "");
}
// pantograph valve configuration
{
auto lookup = starts.find(extract_value("PantValveStart", line));
auto valvestarttype = lookup != starts.end() ? lookup->second : manual;
auto valvespring{true};
extract_value(valvespring, "PantValveSpring", line, "");
auto valvesolenoid{true};
extract_value(valvesolenoid, "PantValveSolenoid", line, "");
for (auto &pantograph : pantographs)
{
pantograph.valve.spring = valvespring;
pantograph.valve.solenoid = valvesolenoid;
pantograph.valve.start_type = valvestarttype;
}
}
// fuel pump
{
auto lookup = starts.find(extract_value("FuelStart", line));
FuelPump.start_type = lookup != starts.end() ? lookup->second : manual;
}
// oil pump
{
auto lookup = starts.find(extract_value("OilStart", line));
OilPump.start_type = lookup != starts.end() ? lookup->second : manual;
}
// genset of a dual-mode vehicle: Manual (the default) needs GensetSwitch, Automatic runs whenever the selector is on it
{
auto lookup = starts.find(extract_value("GensetStart", line));
Genset.start_type = lookup != starts.end() ? lookup->second : manual;
}
// water pump
{
auto lookup = starts.find(extract_value("WaterStart", line));
WaterPump.start_type = lookup != starts.end() ? lookup->second : manual;
}
// traction motor fans
{
auto lookup = starts.find(extract_value("MotorBlowersStart", line));
MotorBlowers[VehicleEnd::rear].start_type = lookup != starts.end() ? lookup->second : manual;
MotorBlowers[VehicleEnd::front].start_type = MotorBlowers[VehicleEnd::rear].start_type;
}
// what else the line contactors need to close
{
std::map<std::string, line_contactors_interlock, std::less<>> const interlocks{{"Converter", line_contactors_interlock::converter},
{"MotorBlowers", line_contactors_interlock::motor_blowers}};
auto lookup = interlocks.find(extract_value("LineContactorsInterlock", line));
lineContactors.config.interlock = lookup != interlocks.end() ? lookup->second : line_contactors_interlock::none;
}
extract_value(LouvresOpenPressure, "LouvresOpenPressure", line, "");
// compartment lights
{
auto lookup = starts.find(extract_value("CompartmentLightsStart", line));
CompartmentLights.start_type = lookup != starts.end() ? lookup->second : automatic; // legacy behaviour
}
// ground relay
{
auto lookup = starts.find(extract_value("GroundRelayStart", line));
auto const defaultstart{trainType == train_type::emu ? automatic : manual};
protection.config.groundStart = lookup != starts.end() ? lookup->second : defaultstart;
}
// converter overload relay
{
auto lookup = starts.find(extract_value("ConverterOverloadRelayStart", line));
// the relay of a multiple unit activates when the converter is switched off
auto const defaultstart{trainType == train_type::emu ? converter : manual};
this->converter.config.overloadRelayStart = lookup != starts.end() ? lookup->second : defaultstart;
}
}
void physics::Vehicle::LoadFIZ_Blending(std::string const &line)
{
extract_value(brakes.blending.maxSpeed, "MED_Vmax", line, std::to_string(vmax));
extract_value(brakes.blending.minSpeed, "MED_Vmin", line, "0");
extract_value(brakes.blending.referenceSpeed, "MED_Vref", line, std::to_string(vmax));
extract_value(brakes.blending.maxDeceleration, "MED_amax", line, "9.81");
extract_value(brakes.blending.epCorrection, "MED_EPVC", line, "");
extract_value(brakes.blending.loadCorrection, "MED_Ncor", line, "");
extract_value(brakes.blending.minEdDemand, "MED_MinBrakeReqED", line, "");
extract_value(brakes.blending.edForceFactor, "MED_FrEDFactor", line, "");
extract_value(brakes.blending.edFirstDelay, "MED_FirstDelayED", line, "");
extract_value(brakes.blending.edNextDelay, "MED_ScndDelayED", line, "");
}
void physics::Vehicle::LoadFIZ_DCEMUED(std::string const &line)
{
extract_value(brakes.emuDynamic.checkedCoupler, "CouplerCheck", line, "0");
extract_value(brakes.emuDynamic.epMaxSpeed, "EP_max_Vel", line, "0");
extract_value(brakes.emuDynamic.epMinCurrent, "EP_min_Im", line, "0");
extract_value(brakes.emuDynamic.epDelay, "EP_delay", line, "0");
}
void physics::Vehicle::LoadFIZ_SpringBrake(std::string const &line)
{
double vol{1.0};
extract_value(vol, "Volume", line, "1");
if (!brakes.spring.cylinder)
brakes.spring.cylinder = std::make_shared<TReservoir>();
brakes.spring.cylinder->CreateCap(vol);
extract_value(brakes.spring.maxForce, "MBF", line, "");
extract_value(brakes.spring.maxSetPressure, "MaxSP", line, "");
extract_value(brakes.spring.resetPressure, "ResetP", line, "");
extract_value(brakes.spring.minForcePressure, "MinFP", line, "");
extract_value(brakes.spring.pressureOff, "PressOff", line, "");
extract_value(brakes.spring.pressureOn, "PressOn", line, "");
extract_value(brakes.spring.valveOffArea, "ValveOnArea", line, "");
extract_value(brakes.spring.valveOnArea, "ValveOffArea", line, "");
extract_value(brakes.spring.valvePneumaticArea, "ValvePNBArea", line, "");
brakes.spring.pneumaticConnection = brakes.spring.valvePneumaticArea > 0;
extract_value(brakes.spring.controlCouplings, "MTC", line, "");
brakes.spring.shutOff = false;
brakes.spring.activate = false;
brakes.spring.isReady = true;
}
void physics::Vehicle::LoadFIZ_Light(std::string const &line)
{
LightPowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("Light", line));
LoadFIZ_PowerParamsDecode(LightPowerSource, "L", line);
AlterLightPowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("AlterLight", line));
LoadFIZ_PowerParamsDecode(AlterLightPowerSource, "AlterL", line);
extract_value(NominalVoltage, "Volt", line, "");
auto batteryvoltage{lowVoltage.BatteryVoltage()};
extract_value(batteryvoltage, "LMaxVoltage", line, "");
lowVoltage.SetBattery(batteryvoltage);
}
void physics::Vehicle::LoadFIZ_Clima(std::string const &line)
{
HeatingPowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("Heating", line));
LoadFIZ_PowerParamsDecode(HeatingPowerSource, "H", line);
AlterHeatPowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("AlterHeating", line));
LoadFIZ_PowerParamsDecode(AlterHeatPowerSource, "AlterH", line);
}
void physics::Vehicle::LoadFIZ_Power(std::string const &Line)
{
EnginePowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("EnginePower", Line));
LoadFIZ_PowerParamsDecode(EnginePowerSource, "", Line);
/*
if( ( EnginePowerSource.SourceType == TPowerSource::Generator )
&& ( EnginePowerSource.GeneratorEngine == TEngineType::WheelsDriven ) ) {
// perpetuum mobile?
ConversionError = 666;
}
*/
if (Power == 0.0)
{
// jeśli nie ma mocy, np. rozrządcze EZT
EnginePowerSource.SourceType = TPowerSource::NotDefined;
}
else
{
LoadFIZ_Genset(Line);
}
SystemPowerSource.SourceType = LoadFIZ_SourceDecode(extract_value("SystemPower", Line));
LoadFIZ_PowerParamsDecode(SystemPowerSource, "", Line);
}
// the genset of a dual-mode vehicle (eu07/maszyna#536), on the Power: line; all optional, no genset without GensetPower
void physics::Vehicle::LoadFIZ_Genset(std::string const &Line)
{
extract_value(Genset.power, "GensetPower", Line, "");
if (false == Genset.fitted())
{
return;
}
extract_value(Genset.voltage_nominal, "GensetVoltage", Line, "");
if (Genset.voltage_nominal <= 0.0)
{
Genset.voltage_nominal = EnginePowerSource.MaxVoltage > 0.0 ? 0.65 * EnginePowerSource.MaxVoltage : 3000.0;
}
extract_value(Genset.revolutions_idle, "GensetIdleRPM", Line, "600");
extract_value(Genset.revolutions_max, "GensetMaxRPM", Line, "1800");
Genset.revolutions_max = std::max(Genset.revolutions_max, 1.0) / 60.0;
Genset.revolutions_idle = std::clamp(Genset.revolutions_idle / 60.0, 1.0 / 60.0, Genset.revolutions_max);
extract_value(Genset.start_time, "GensetStartTime", Line, "8");
extract_value(Genset.spinup_time, "GensetSpinUpTime", Line, "3");
extract_value(Genset.traction_share, "GensetPmaxRatio", Line, "1");
Genset.start_time = std::max(Genset.start_time, 0.0);
Genset.spinup_time = std::max(Genset.spinup_time, 0.01);
Genset.traction_share = std::clamp(Genset.traction_share, 0.0, 1.0);
}
void physics::Vehicle::LoadFIZ_SpeedControl(std::string const &Line)
{
// speed control
extract_value(speedCtrl, "SpeedCtrl", Line, "");
if (!speedCtrl && EngineType == TEngineType::ElectricInductionMotor && scndCtrlPosNo > 0) // backward compatibility
speedCtrl = true;
extract_value(SpeedCtrlDelay, "SpeedCtrlDelay", Line, "");
speedCtrlTypeTime = extract_value("SpeedCtrlType", Line) == "Time" ? true : false;
extract_value(SpeedCtrlAutoTurnOffFlag, "SpeedCtrlATOF", Line, "");
auto speedpresets = Split(extract_value("SpeedButtons", Line), '|');
int speed_no = 0;
for (auto const &speed : speedpresets)
{
SpeedCtrlButtons[speed_no++] = std::stod(speed);
if (speed_no > 9)
break;
}
extract_value(SpeedCtrlUnit.ManualStateOverride, "OverrideManual", Line, "");
extract_value(SpeedCtrlUnit.BrakeIntervention, "BrakeIntervention", Line, "");
extract_value(SpeedCtrlUnit.InitialPower, "InitPwr", Line, "");
extract_value(SpeedCtrlUnit.FullPowerVelocity, "MaxPwrVel", Line, "");
extract_value(SpeedCtrlUnit.StartVelocity, "StartVel", Line, "");
extract_value(SpeedCtrlUnit.VelocityStep, "VelStep", Line, "");
extract_value(SpeedCtrlUnit.PowerStep, "PwrStep", Line, "");
extract_value(SpeedCtrlUnit.MinPower, "MinPwr", Line, "");
extract_value(SpeedCtrlUnit.MaxPower, "MaxPwr", Line, "");
extract_value(SpeedCtrlUnit.MinVelocity, "MinVel", Line, "");
extract_value(SpeedCtrlUnit.MaxVelocity, "MaxVel", Line, "");
extract_value(SpeedCtrlUnit.Offset, "Offset", Line, "");
extract_value(SpeedCtrlUnit.FactorPpos, "kPpos", Line, "");
extract_value(SpeedCtrlUnit.FactorPneg, "kPneg", Line, "");
extract_value(SpeedCtrlUnit.FactorIpos, "kIpos", Line, "");
extract_value(SpeedCtrlUnit.FactorIneg, "kIneg", Line, "");
extract_value(SpeedCtrlUnit.BrakeInterventionVel, "BrakeIntMaxVel", Line, "");
extract_value(SpeedCtrlUnit.PowerUpSpeed, "PowerUpSpeed", Line, "");
extract_value(SpeedCtrlUnit.PowerDownSpeed, "PowerDownSpeed", Line, "");
}
void physics::Vehicle::LoadFIZ_Engine(std::string const &Input)
{
EngineType = LoadFIZ_EngineDecode(extract_value("EngineType", Input));
extract_value(lineBreaker.config.jointStart, "JointEngineStart", Input, "");
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
if (ratios.size() != 2)
{
ErrorLog("Wrong transmition definition: " + transmission);
}
Transmision.NToothM = std::atoi(ratios[0].c_str()); // ToothM to pierwszy czyli 18
Transmision.NToothW = std::atoi(ratios[1].c_str()); // ToothW to drugi parametr czyli 79
if (Transmision.NToothM > 0)
Transmision.Ratio = static_cast<double>(Transmision.NToothW) / Transmision.NToothM;
else
Transmision.Ratio = 1.0;
extract_value(Transmision.Efficiency, "TransEff", Input, "");
}
switch (EngineType)
{
case TEngineType::ElectricSeriesMotor:
{
extract_value(NominalVoltage, "Volt", Input, "");
extract_value(windingRes, "WindingRes", Input, "");
if (windingRes == 0.0)
{
windingRes = 0.01;
}
extract_value(nmax, "nmax", Input, "");
nmax /= 60.0;
break;
}
case TEngineType::WheelsDriven:
case TEngineType::Dumb:
{
extract_value(Ftmax, "Ftmax", Input, "");
break;
}
case TEngineType::DieselEngine:
{
LoadFIZ_EngineDiesel(Input);
break;
}
case TEngineType::DieselElectric:
{ // youBy
LoadFIZ_EngineDieselElectric(Input);
break;
}
case TEngineType::ElectricInductionMotor:
{
LoadFIZ_EngineInductionMotor(Input);
break;
}
default:
{
// nothing here
}
} // engine type
// NOTE: elements shared by both diesel engine variants; crude but, eh
if (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric)
{
LoadFIZ_EngineDieselShared(Input);
}
// traction motors
extract_value(MotorBlowers[VehicleEnd::front].speed, "MotorBlowersSpeed", Input, "");
extract_value(MotorBlowers[VehicleEnd::front].sustain_time, "MotorBlowersSustainTime", Input, "");
extract_value(MotorBlowers[VehicleEnd::front].min_start_velocity, "MotorBlowersStartVelocity", Input, "");
MotorBlowers[VehicleEnd::rear] = MotorBlowers[VehicleEnd::front];
// pressure switch
extract_value(protection.config.hasPressureSwitch, "PressureSwitch", Input, trainType != train_type::emu ? "yes" : "no");
// its brake cylinder half; the brake pipe one stays
extract_value(protection.config.pressureSwitchWatchesCylinders, "PressureSwitchBrakeCylinder", Input, "");
}
// Engine: of a diesel engine, its revolutions, gears, hydraulic transmission and retarder
void physics::Vehicle::LoadFIZ_EngineDiesel(std::string const &Input)
{
extract_value(diesel.minRevolutions, "nmin", Input, "");
diesel.minRevolutions /= 60.0;
diesel.governorMinRevolutions = diesel.minRevolutions * 0.98;
extract_value(diesel.hydraulicMinRevolutions, "nmin_hdrive", Input, "");
diesel.hydraulicMinRevolutions /= 60.0;
if (diesel.hydraulicMinRevolutions == 0.0)
{
diesel.hydraulicMinRevolutions = diesel.minRevolutions;
}
extract_value(diesel.hydraulicMinRevolutionsFactor, "nmin_hdrive_factor", Input, "");
diesel.hydraulicMinRevolutionsFactor /= 60.0;
extract_value(diesel.retarderRevolutions, "nmin_retarder", Input, "");
diesel.retarderRevolutions /= 60.0;
if (diesel.retarderRevolutions == 0.0)
{
diesel.retarderRevolutions = diesel.minRevolutions;
}
// TODO: unify naming scheme and sort out which diesel engine params are used where and how
extract_value(nmax, "nmax", Input, "");
nmax /= 60.0;
extract_value(diesel.cutoffRevolutions, "nmax_cutoff", Input, "0.0");
diesel.cutoffRevolutions /= 60.0;
extract_value(diesel.governorAcceleration, "nreg_acc", Input, "");
diesel.governorAcceleration /= 60.0;
extract_value(diesel.shaftInertia, "AIM", Input, "1.0");
extract_value(diesel.revolutionsDecreaseRate, "RPMDecRate", Input, "");
extract_value(engageupspeed, "EUS", Input, "0.5");
extract_value(engagedownspeed, "EDS", Input, "0.9");
if (true == extract_value(anPos, "ShuntMode", Input, ""))
{
// dodatkowa przekładnia dla SM03 (2Ls150)
ShuntModeAllow = true;
ShuntMode = false;
if (anPos < 1.0)
{
//"rozruch wysoki" ma dawać większą siłę
anPos = 1.0 / anPos; // im większa liczba, tym wolniej jedzie
}
}
extract_value(torqueConverter.present, "IsTC", Input, "");
if (true == torqueConverter.present)
{
extract_value(torqueConverter.maxTorqueRatio, "TC_TMMax", Input, "");
extract_value(torqueConverter.couplingPoint, "TC_CP", Input, "");
extract_value(torqueConverter.lockupTorque, "TC_LT", Input, "");
extract_value(torqueConverter.lockupRate, "TC_LR", Input, "");
extract_value(torqueConverter.unlockRate, "TC_ULR", Input, "");
extract_value(torqueConverter.fillRateIncrease, "TC_FRI", Input, "");
extract_value(torqueConverter.fillRateDecrease, "TC_FRD", Input, "");
extract_value(torqueConverter.torqueInIn, "TC_TII", Input, "");
extract_value(torqueConverter.torqueInOut, "TC_TIO", Input, "");
extract_value(torqueConverter.torqueOutOut, "TC_TOO", Input, "");
extract_value(torqueConverter.lockupSpeed, "TC_LS", Input, "");
extract_value(torqueConverter.unlockSpeed, "TC_ULS", Input, "");
extract_value(diesel.converterReleaseVelocity, "MaxVelANS", Input, "");
extract_value(retarder.present, "IsRetarder", Input, "");
if (true == retarder.present)
{
extract_value(retarder.placement, "R_Place", Input, "");
extract_value(retarder.torqueInIn, "R_TII", Input, "");
extract_value(retarder.maxTorque, "R_MT", Input, "");
extract_value(retarder.maxPower, "R_MP", Input, "");
extract_value(retarder.fillRateIncrease, "R_FRI", Input, "");
extract_value(retarder.fillRateDecrease, "R_FRD", Input, "");
extract_value(retarder.minVelocity, "R_MinVel", Input, "");
extract_value(retarder.engageVelocity, "R_EngageVel", Input, "");
extract_value(retarder.hasClutch, "R_IsClutch", Input, "");
extract_value(retarder.clutchSpeed, "R_ClutchSpeed", Input, "");
extract_value(retarder.withIndividual, "R_WithIndividual", Input, "");
}
}
}
// Engine: of a diesel-electric
void physics::Vehicle::LoadFIZ_EngineDieselElectric(std::string const &Input)
{
extract_value(Ftmax, "Ftmax", Input, "");
Flat = extract_value("Flat", Input) == "1";
extract_value(Vhyp, "Vhyp", Input, "");
Vhyp /= 3.6;
extract_value(Vadd, "Vadd", Input, "");
Vadd /= 3.6;
extract_value(PowerCorRatio, "Cr", Input, "");
extract_value(RelayType, "RelayType", Input, "");
if (extract_value("ShuntMode", Input) == "1")
{
ShuntModeAllow = true;
ShuntMode = false;
anPos = 0.0;
imaxHi = 2;
imaxLo = 1;
}
extract_value(trainHeating.config.engineRpm, "HeatingRPM", Input, "");
extract_value(diesel.shaftInertia, "AIM", Input, "1.25");
extract_value(diesel.revolutionsDecreaseRate, "RPMDecRate", Input, "");
LoadFIZ_DieselElectricDynamicBrake(Input);
}
// Engine: of an induction motor drive
void physics::Vehicle::LoadFIZ_EngineInductionMotor(std::string const &Input)
{
RVentnmax = 1.0;
extract_value(NominalVoltage, "Volt", Input, "");
extract_value(inductionMotor.motor.currentPerSlip, "dfic", Input, "");
extract_value(inductionMotor.motor.maxSlipFrequency, "dfmax", Input, "");
extract_value(inductionMotor.motor.polePairs, "p", Input, "");
extract_value(inductionMotor.motor.voltsPerHertz, "cfu", Input, "");
extract_value(inductionMotor.motor.torquePerCurrent, "cim", Input, "");
extract_value(inductionMotor.motor.fieldCurrentRatio, "icif", Input, "");
extract_value(inductionMotor.converter.maxLinkVoltage, "Uzmax", Input, "");
extract_value(inductionMotor.converter.brakingLinkVoltage, "Uzh", Input, "");
extract_value(inductionMotor.converter.voltageDrop, "DU", Input, "");
extract_value(inductionMotor.converter.noLoadCurrent, "I0", Input, "");
extract_value(inductionMotor.converter.voltsPerHertz, "fcfu", Input, "");
if (false == extract_value(inductionMotor.converter.brakingVoltsPerHertz, "fcfuH", Input, ""))
{
// without its own figure the dynamic brake takes the one of the traction
inductionMotor.converter.brakingVoltsPerHertz = inductionMotor.converter.voltsPerHertz;
}
extract_value(inductionMotor.traction.startingForce, "F0", Input, "");
extract_value(inductionMotor.traction.forceDropPerSpeed, "a1", Input, "");
extract_value(inductionMotor.traction.maxPower, "Pmax", Input, "");
extract_value(inductionMotor.braking.maxForce, "Fh", Input, "");
extract_value(inductionMotor.braking.maxPower, "Ph", Input, "");
extract_value(inductionMotor.braking.offSpeed, "Vh0", Input, "");
extract_value(inductionMotor.braking.fullSpeed, "Vh1", Input, "");
extract_value(inductionMotor.traction.maxCurrent, "Imax", Input, "");
extract_value(inductionMotor.braking.cylinderPressureGain, "abed", Input, "");
extract_value(inductionMotor.braking.maxEpDeceleration, "edep", Input, "");
extract_value(inductionMotor.logForce, "eimclf", Input, "");
extract_value(inductionMotor.inverterCount, "InvNo", Input, "");
extract_value(inductionMotor.inverterControlCouplings, "InvCtrCplFlag", Input, "");
extract_value(brakes.electrodynamic.resistorPassiveMaxCurrent, "Imaxrpc", Input, "");
extract_value(brakes.electrodynamic.resistorFansSustain, "BRVto", Input, "");
extract_value(Flat, "Flat", Input, "");
if (inductionMotor.traction.maxPower > 0 && Power > 0 && inductionMotor.inverterCount == 0)
{
inductionMotor.inverterCount = 1;
}
inductionMotor.inverters.resize(inductionMotor.inverterCount);
/*for (int i = 0; i > inductionMotor.inverterCount; i++)
{
Inverter x;
inductionMotor.inverters.emplace_back(x);
}*/
}
// Engine: what both kinds of diesels have, their heat among it
void physics::Vehicle::LoadFIZ_EngineDieselShared(std::string const &Input)
{
// oil pump
extract_value(OilPump.pressure_minimum, "OilMinPressure", Input, "");
extract_value(OilPump.pressure_maximum, "OilMaxPressure", Input, "");
// the time the starter turns the engine before it fires and smokes (eu07/maszyna#523)
extract_value(diesel.smokeDelay, "SmokeDelay", Input, "0");
diesel.smokeDelay = std::max(0.0, diesel.smokeDelay);
// engine cooling factore
extract_value(diesel.heat.kw, "HeatKW", Input, "");
extract_value(diesel.heat.kv, "HeatKV", Input, "");
extract_value(diesel.heat.kfe, "HeatKFE", Input, "");
extract_value(diesel.heat.kfs, "HeatKFS", Input, "");
extract_value(diesel.heat.kfo, "HeatKFO", Input, "");
extract_value(diesel.heat.kfo2, "HeatKFO2", Input, "");
// engine cooling systems
extract_value(diesel.heat.water.config.temp_min, "WaterMinTemperature", Input, "");
extract_value(diesel.heat.water.config.temp_max, "WaterMaxTemperature", Input, "");
extract_value(diesel.heat.water.config.temp_flow, "WaterFlowTemperature", Input, "");
extract_value(diesel.heat.water.config.temp_cooling, "WaterCoolingTemperature", Input, "");
extract_value(diesel.heat.water.config.shutters, "WaterShutters", Input, "");
extract_value(diesel.heat.auxiliary_water_circuit, "WaterAuxCircuit", Input, "");
extract_value(diesel.heat.water_aux.config.temp_min, "WaterAuxMinTemperature", Input, "");
extract_value(diesel.heat.water_aux.config.temp_max, "WaterAuxMaxTemperature", Input, "");
extract_value(diesel.heat.water_aux.config.temp_cooling, "WaterAuxCoolingTemperature", Input, "");
extract_value(diesel.heat.water_aux.config.shutters, "WaterAuxShutters", Input, "");
extract_value(diesel.heat.oil.config.temp_min, "OilMinTemperature", Input, "");
extract_value(diesel.heat.oil.config.temp_max, "OilMaxTemperature", Input, "");
extract_value(diesel.heat.engine_max_temp, "EngineMaxTemperature", Input, "");
extract_value(diesel.heat.fan_speed, "WaterCoolingFanSpeed", Input, "");
// water heater
extract_value(WaterHeater.config.temp_min, "HeaterMinTemperature", Input, "");
extract_value(WaterHeater.config.temp_max, "HeaterMaxTemperature", Input, "");
float pf{1235.f};
extract_value(pf, "NominalCoolingPower", Input, "1235");
diesel.heat.powerfactor = 1235 / pf;
}
void physics::Vehicle::LoadFIZ_Switches(std::string const &Input)
{
extract_value(pantographCircuit.config.switchType, "Pantograph", Input, "");
extract_value(converter.config.switchType, "Converter", Input, "");
extract_value(lineContactors.config.switchType, "MotorConnectors", Input, "");
trainHeating.config.switchImpulse = ToLower(extract_value("TrainHeating", Input)) == "impulse";
// because people can't make up their minds whether it's "impulse" or "Impulse"...
pantographCircuit.config.switchType = ToLower(pantographCircuit.config.switchType);
converter.config.switchType = ToLower(converter.config.switchType);
lineContactors.config.switchType = ToLower(lineContactors.config.switchType);
// universal reset buttons assignments
extract_value(UniversalResetButtonFlag[0], "RelayResetButton1", Input, "");
extract_value(UniversalResetButtonFlag[1], "RelayResetButton2", Input, "");
extract_value(UniversalResetButtonFlag[2], "RelayResetButton3", Input, "");
extract_value(enableModernDimmerValue, "ModernDimmer", Input, "");
// pantograph presets
{
auto &presets{pantographCircuit.presets.first};
extract_value(presets, "PantographPresets", Input, "0|1|3|2");
std::erase(presets, '|');
}
}
void physics::Vehicle::LoadFIZ_MotorParamTable(std::string const &Input)
{
switch (EngineType)
{
case TEngineType::DieselEngine:
{
extract_value(diesel.fullEngageMinVelocity, "minVelfullengage", Input, "");
extract_value(diesel.clutchDiameter, "engageDia", Input, "");
extract_value(diesel.clutchMaxForce, "engageMaxForce", Input, "");
extract_value(diesel.clutchFriction, "engagefriction", Input, "");
break;
}
default:
{
// nothing here
}
}
}
void physics::Vehicle::LoadFIZ_Circuit(std::string const &Input)
{
extract_value(CircuitRes, "CircuitRes", Input, "");
extract_value(IminLo, "IminLo", Input, "");
extract_value(IminHi, "IminHi", Input, "");
extract_value(imaxLo, "ImaxLo", Input, "");
extract_value(imaxHi, "ImaxHi", Input, "");
imin = IminLo;
Imax = imaxLo;
extract_value(TUHEX_Sum, "TUHEX_Sum", Input, "");
extract_value(TUHEX_Diff, "TUHEX_Diff", Input, "");
extract_value(TUHEX_MaxIw, "TUHEX_MaxIw", Input, "");
extract_value(TUHEX_MinIw, "TUHEX_MinIw", Input, "");
extract_value(TUHEX_Sum1, "TUHEX_Sum1", Input, "");
extract_value(TUHEX_Sum2, "TUHEX_Sum2", Input, "");
extract_value(TUHEX_Sum3, "TUHEX_Sum3", Input, "");
extract_value(TUHEX_Stages, "TUHEX_Stages", Input, "0");
}
void physics::Vehicle::LoadFIZ_AI(std::string const &Input)
{
extract_value(aiHintPantstate, "Pantstate", Input, "");
extract_value(aiHintShuntPantstate, "ShuntPantstate", Input, "");
extract_value(AIHintPantUpIfIdle, "IdlePantUp", Input, "");
extract_value(aiHintLocalBrakeAccFactor, "LocalBrakeAccFactor", Input, "");
}
void physics::Vehicle::LoadFIZ_RList(std::string const &Input)
{
extract_value(RlistSize, "Size", Input, "");
if (auto const venttype{ToLower(extract_value("RVent", Input))}; venttype == "automatic")
{
RVentType = 2;
}
else
{
RVentType = venttype == "yes" ? 1 : 0;
}
if (RVentType > 0)
{
extract_value(RVentnmax, "RVentnmax", Input, "");
RVentnmax /= 60.0;
extract_value(RVentCutOff, "RVentCutOff", Input, "");
}
extract_value(RVentMinI, "RVentMinI", Input, "");
extract_value(RVentSpeed, "RVentSpeed", Input, "");
extract_value(brakes.electrodynamic.resistance, "DynBrakeRes", Input, "");
extract_value(brakes.electrodynamic.resistance1, "DynBrakeRes1", Input, "");
extract_value(brakes.electrodynamic.resistance2, "DynBrakeRes2", Input, "");
}
// the dynamic brake of a diesel-electric vehicle, from its Engine section: none without EDBrake
void physics::Vehicle::LoadFIZ_DieselElectricDynamicBrake(std::string const &Input)
{
using enum diesel_electric_dynamic_brake::control;
std::map<std::string, diesel_electric_dynamic_brake::control, std::less<>> const sources{{"Controller", controller}, {"Lever", lever}};
auto const lookup{sources.find(extract_value("EDBrake", Input))};
if (lookup == sources.end())
{
return;
}
auto &brake{DEDynamicBrake};
brake.source = lookup->second;
auto force{0.0}; // [kN]
auto power{0.0}; // [kW]
extract_value(force, "EDBrakeFmax", Input, "");
extract_value(power, "EDBrakePmax", Input, "");
brake.max_force = force * 1000.0;
brake.max_power = power * 1000.0;
extract_value(brake.fade_low, "EDBrakeV0", Input, "");
extract_value(brake.fade_high, "EDBrakeV1", Input, "");
extract_value(brake.rate, "EDBrakeRate", Input, "");
extract_value(brake.blending, "EDBrakeBlending", Input, "");
if (brake.source == lever)
{
// the lever of its own, which the commands of the dynamic brake controller move
brakes.electrodynamic.splitFromPneumatic = true;
}
}
void physics::Vehicle::LoadFIZ_UCList(std::string const &Input)
{
extract_value(UniCtrlListSize, "Size", Input, "");
extract_value(UniCtrlIntegratedBrakeCtrl, "IntegratedBrake", Input, "");
extract_value(uniCtrlIntegratedLocalBrakeCtrl, "IntegratedLocBrake", Input, "");
extract_value(UniCtrlIntegratedBrakePNCtrl, "IntegratedBrakePN", Input, "");
extract_value(uniCtrlValStep, "CtrlValStep", Input, "");
uniCtrlValStep = std::max(uniCtrlValStep, 0.0);
}
void physics::Vehicle::LoadFIZ_DList(std::string const &Input)
{
extract_value(diesel.maxMoment, "Mmax", Input, "");
extract_value(diesel.maxMomentRevolutions, "nMmax", Input, "");
extract_value(diesel.maxRevolutionsMoment, "Mnmax", Input, "");
extract_value(diesel.maxRevolutions, "nmax", Input, "");
extract_value(diesel.nominalFill, "nominalfill", Input, "");
extract_value(diesel.standingMoment, "Mstand", Input, "");
extract_value(diesel.nominalFuelConsumptionRate, "NomFuelConsRate", Input, "");
if (diesel.maxMomentRevolutions == diesel.maxRevolutions)
{
// HACK: guard against cases where nMmax == nmax, leading to division by 0 in momentum calculation
diesel.maxMomentRevolutions = diesel.maxRevolutions - 1.0 / 60.0;
}
// Calculation of fuel consumption coefficient for futher calculation
double dizel_max_power = diesel.maxRevolutions * (diesel.maxRevolutionsMoment - diesel.standingMoment) * M_PI * 2 * 0.001; // power in kW
double dizel_max_energy = dizel_max_power; // energy per one hour in kWh is equal to power in kW times 1 h
double fuel_density = 850; // g/l
diesel.fuelConsumption = diesel.nominalFuelConsumptionRate * dizel_max_energy / fuel_density / diesel.maxRevolutions;
}
void physics::Vehicle::LoadFIZ_FFList(std::string const &Input)
{
extract_value(FFListSize, "Size", Input, "");
}
void physics::Vehicle::LoadFIZ_FFEDList(std::string const &Input)
{
extract_value(FFEDListSize, "Size", Input, "");
}
void physics::Vehicle::LoadFIZ_WiperList(std::string const &Input)
{
extract_value(WiperListSize, "Size", Input, "");
extract_value(WiperAngle, "Angle", Input, "");
extract_value(WiperDefaultPos, "Default", Input, "");
}
void physics::Vehicle::LoadFIZ_DimmerList(std::string const &Input)
{
// extract_value(modernWpierListSize, "Size", Input, "");
extract_value(modernDimmerCanCycle, "Cycle", Input, "");
extract_value(modernDimmerDefaultPosition, "DefaultPos", Input, "");
}
void physics::Vehicle::LoadFIZ_LightsList(std::string const &Input)
{
extract_value(LightsPosNo, "Size", Input, "");
extract_value(LightsWrap, "Wrap", Input, "");
extract_value(LightsDefPos, "Default", Input, "");
}
void physics::Vehicle::LoadFIZ_CompressorList(std::string const &Input)
{
extract_value(air.compressor.config.listPositions, "Size", Input, "");
extract_value(air.compressor.config.listWraps, "Wrap", Input, "");
extract_value(air.compressor.config.listDefaultPosition, "Default", Input, "");
}
void physics::Vehicle::LoadFIZ_PowerParamsDecode(TPowerParameters &Powerparameters, std::string const &Prefix, std::string const &Line)
{
switch (Powerparameters.SourceType)
{
case TPowerSource::NotDefined:
case TPowerSource::InternalSource:
{
Powerparameters.PowerType = LoadFIZ_PowerDecode(extract_value(Prefix + "PowerType", Line));
break;
}
case TPowerSource::Transducer:
{
extract_value(Powerparameters.Transducer.InputVoltage, Prefix + "TransducerInputV", Line, "");
break;
}
case TPowerSource::Generator:
{
// prime mover for the generator
auto &generatorparameters{Powerparameters.EngineGenerator};
if (auto const enginetype{LoadFIZ_EngineDecode(extract_value(Prefix + "GeneratorEngine", Line))}; enginetype == TEngineType::Main)
{
generatorparameters.engine_revolutions = &enrot;
}
else
{
// TODO: for engine types other than Main create requested engine object and link to its revolutions
generatorparameters.engine_revolutions = nullptr;
generatorparameters.revolutions = 0;
generatorparameters.voltage = 0;
}
// config
extract_value(generatorparameters.voltage_min, Prefix + "GeneratorMinVoltage", Line, "0");
extract_value(generatorparameters.voltage_max, Prefix + "GeneratorMaxVoltage", Line, "0");
// NOTE: for consistency the fiz file specifies revolutions per minute
extract_value(generatorparameters.revolutions_min, Prefix + "GeneratorMinRPM", Line, "0");
extract_value(generatorparameters.revolutions_max, Prefix + "GeneratorMaxRPM", Line, "0");
generatorparameters.revolutions_min /= 60;
generatorparameters.revolutions_max /= 60;
break;
}
case TPowerSource::Accumulator:
{
extract_value(Powerparameters.RAccumulator.MaxCapacity, Prefix + "Cap", Line, "");
Powerparameters.RAccumulator.RechargeSource = LoadFIZ_SourceDecode(extract_value(Prefix + "RS", Line));
break;
}
case TPowerSource::CurrentCollector:
{
auto &collectorparameters = Powerparameters.CollectorParameters;
collectorparameters = TCurrentCollector{0, 0, 0, 0, 0, 0, false, 0, 0, 0, false, 0};
std::string PantType = "";
extract_value(PantType, "PantType", Line, "");
if (PantType == "AKP_4E")
collectorparameters.PantographType = TPantType::AKP_4E;
if (PantType.size() >= 3 && PantType.compare(0, 3, "DSA") == 0)
collectorparameters.PantographType = TPantType::DSAx;
if (PantType == "EC160" || PantType == "EC200")
collectorparameters.PantographType = TPantType::EC160_200;
if (PantType == "WBL85")
collectorparameters.PantographType = TPantType::WBL85;
extract_value(collectorparameters.CollectorsNo, "CollectorsNo", Line, "");
extract_value(collectorparameters.MinH, "MinH", Line, "");
extract_value(collectorparameters.MaxH, "MaxH", Line, "");
extract_value(collectorparameters.CSW, "CSW", Line, ""); // szerokość części roboczej
extract_value(collectorparameters.MaxV, "MaxVoltage", Line, "");
extract_value(collectorparameters.OVP, "OverVoltProt", Line, ""); // przekaźnik nadnapięciowy
// napięcie rozłączające WS
collectorparameters.MinV = 0.5 * collectorparameters.MaxV; // gdyby parametr nie podany
extract_value(collectorparameters.MinV, "MinV", Line, "");
// napięcie wymagane do załączenia WS
collectorparameters.InsetV = 0.6 * collectorparameters.MaxV; // gdyby parametr nie podany
extract_value(collectorparameters.InsetV, "InsetV", Line, "");
// ciśnienie rozłączające WS
extract_value(collectorparameters.MinPress, "MinPress", Line, "3.5"); // domyślnie 2 bary do załączenia WS
// maksymalne ciśnienie za reduktorem
// collectorparameters.MaxPress = 5.0 + 0.001 * ( Random( 50 ) - Random( 50 ) );
extract_value(collectorparameters.MaxPress, "MaxPress", Line, "5.0");
extract_value(collectorparameters.FakePower, "FakePower", Line, "");
if (extract_value(collectorparameters.PhysicalLayout, "PhysicalLayout", Line, "3"))
collectorparameters.CollectorsNo = std::min(collectorparameters.PhysicalLayout, 2);
break;
}
case TPowerSource::PowerCable:
{
Powerparameters.RPowerCable.PowerTrans = LoadFIZ_PowerDecode(extract_value(Prefix + "PowerTrans", Line));
if (Powerparameters.RPowerCable.PowerTrans == TPowerType::SteamPower)
{
extract_value(Powerparameters.RPowerCable.SteamPressure, Prefix + "SteamPress", Line, "");
}
break;
}
case TPowerSource::Heater:
{
// jeszcze nie skonczone!
break;
}
default:; // nothing here
}
if (Powerparameters.SourceType != TPowerSource::Heater && Powerparameters.SourceType != TPowerSource::InternalSource)
{
extract_value(Powerparameters.MaxVoltage, Prefix + "MaxVoltage", Line, "");
extract_value(Powerparameters.MaxCurrent, Prefix + "MaxCurrent", Line, "");
extract_value(Powerparameters.IntR, Prefix + "IntR", Line, "");
}
}
TPowerType physics::Vehicle::LoadFIZ_PowerDecode(std::string const &Powertype) const
{
using enum TPowerType;
std::map<std::string, TPowerType, std::less<>> powertypes{
{"BioPower", BioPower}, {"MechPower", MechPower}, {"ElectricPower", ElectricPower}, {"SteamPower", SteamPower}};
auto lookup = powertypes.find(Powertype);
return lookup != powertypes.end() ? lookup->second : NoPower;
}
TPowerSource physics::Vehicle::LoadFIZ_SourceDecode(std::string const &Source) const
{
using enum TPowerSource;
std::map<std::string, TPowerSource, std::less<>> 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 : NotDefined;
}
TEngineType physics::Vehicle::LoadFIZ_EngineDecode(std::string const &Engine) const
{
using enum TEngineType;
std::map<std::string, TEngineType, std::less<>> 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 : None;
}