mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 22:07:55 +01:00
refactor(physics): the line breaker, the line contactors, the relays and the converter as components
The main circuit of physics::Vehicle becomes components, with English names
(physics/components/maincircuit.h):
lineBreaker (LineBreaker) Mains closed, MainsInitTime(Countdown)
initTime / initCountdown, MainsStart start,
JointEngineStart jointStart,
PantographsRequireMains pantographsRequireIt,
LineBreakerClosesOnlyAtNoPowerPos
closesOnlyAtNoPower,
EmergencyBrakeMainOffPressure emergencyOffPressure
lineContactors (LineContactors) StLinFlag closed, StLinSwitchOff forcedOpen,
StLinSwitchType switchType,
LineContactorsInterlock interlock,
LastRelayTime lastSwitchTime
protection (ProtectionRelays) NoVoltRelay noVoltage, OvervoltageRelay
overvoltage, GroundRelay(Start) ground(Start),
ControlPressureSwitch pressureSwitch,
HasControlPressureSwitch hasPressureSwitch,
PressureSwitchBrakeCylinder
pressureSwitchWatchesCylinders
converter (PowerConverter) the Converter* fields: start, startDelay(Timer),
allow(Local), running, overloadRelayStart,
overloadRelayOffWithLineBreaker; ConvOvldFlag
overloaded, ConvSwitchType switchType
The long comments of the fields went with them into the header. Where the
loading of the .fiz has using enum start_t, the member is this->converter:
the enumerator start_t::converter would hide it there.
No string literal changed (checked over all the changed files).
No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
This commit is contained in:
@@ -97,11 +97,11 @@ bool physics::Vehicle::IncMainCtrl(int CtrlSpeed)
|
||||
{
|
||||
if (DelayCtrlFlag)
|
||||
{
|
||||
if (LastRelayTime >= InitialCtrlDelay && MainCtrlPos == 1)
|
||||
LastRelayTime = 0;
|
||||
if (lineContactors.lastSwitchTime >= InitialCtrlDelay && MainCtrlPos == 1)
|
||||
lineContactors.lastSwitchTime = 0;
|
||||
}
|
||||
else if (LastRelayTime > CtrlDelay)
|
||||
LastRelayTime = 0;
|
||||
else if (lineContactors.lastSwitchTime > CtrlDelay)
|
||||
lineContactors.lastSwitchTime = 0;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
@@ -226,11 +226,11 @@ bool physics::Vehicle::DecMainCtrl(int CtrlSpeed)
|
||||
{
|
||||
if (DelayCtrlFlag)
|
||||
{
|
||||
if (LastRelayTime >= InitialCtrlDelay)
|
||||
LastRelayTime = 0;
|
||||
if (lineContactors.lastSwitchTime >= InitialCtrlDelay)
|
||||
lineContactors.lastSwitchTime = 0;
|
||||
}
|
||||
else if (LastRelayTime > CtrlDownDelay)
|
||||
LastRelayTime = 0;
|
||||
else if (lineContactors.lastSwitchTime > CtrlDownDelay)
|
||||
lineContactors.lastSwitchTime = 0;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
@@ -363,7 +363,7 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed)
|
||||
// TBD, TODO: refactor this validation as part of relay check routine (currently in tractionforce()
|
||||
// TBD, TODO: diesel electric engine utilize scndctrlactualpos like the other types?
|
||||
if (EngineType == TEngineType::DieselElectric &&
|
||||
(IsMainCtrlNoPowerPos() || fieldshunting::diesel_electric(AutoRelayType, FieldShuntSwitch, AutoRelayFlag) != fieldshunting::control::manual || ShuntMode || false == Mains))
|
||||
(IsMainCtrlNoPowerPos() || fieldshunting::diesel_electric(AutoRelayType, FieldShuntSwitch, AutoRelayFlag) != fieldshunting::control::manual || ShuntMode || false == lineBreaker.closed))
|
||||
{
|
||||
OK = false;
|
||||
}
|
||||
@@ -392,8 +392,8 @@ bool physics::Vehicle::IncScndCtrl(int CtrlSpeed)
|
||||
OK = false;
|
||||
// if OK then LastRelayTime:=0;
|
||||
// hunter-101012: poprawka
|
||||
if (OK && LastRelayTime > CtrlDelay)
|
||||
LastRelayTime = 0;
|
||||
if (OK && lineContactors.lastSwitchTime > CtrlDelay)
|
||||
lineContactors.lastSwitchTime = 0;
|
||||
|
||||
if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1 && MainCtrlPos > 0)
|
||||
{
|
||||
@@ -454,8 +454,8 @@ bool physics::Vehicle::DecScndCtrl(int CtrlSpeed)
|
||||
OK = false;
|
||||
// if OK then LastRelayTime:=0;
|
||||
// hunter-101012: poprawka
|
||||
if (OK && LastRelayTime > CtrlDownDelay)
|
||||
LastRelayTime = 0;
|
||||
if (OK && lineContactors.lastSwitchTime > CtrlDownDelay)
|
||||
lineContactors.lastSwitchTime = 0;
|
||||
|
||||
if (OK && EngineType == TEngineType::ElectricInductionMotor && ScndCtrlPosNo == 1)
|
||||
{
|
||||
@@ -549,7 +549,7 @@ bool physics::Vehicle::AutoRelayCheck(void)
|
||||
// yBARC - rozlaczenie stycznikow liniowych
|
||||
if (motorconnectorsoff || (HasCamshaft ? IsMainCtrlActualNoPowerPos() : IsMainCtrlNoPowerPos()))
|
||||
{
|
||||
StLinFlag = false;
|
||||
lineContactors.closed = false;
|
||||
if (false == DynamicBrakeFlag)
|
||||
{
|
||||
Im = 0;
|
||||
@@ -569,7 +569,7 @@ bool physics::Vehicle::AutoRelayCheck(void)
|
||||
// przejście dalej przez danie nastawnika na dalszą pozycję - tak to do
|
||||
// tej pory działało i na tym się opiera fizyka ET22-2k
|
||||
{
|
||||
if (StLinFlag)
|
||||
if (lineContactors.closed)
|
||||
{
|
||||
if (RList[MainCtrlActualPos].R == 0 && (ScndCtrlActualPos > 0 || ScndCtrlPos > 0) && (!CoupledCtrl || RList[MainCtrlActualPos].Relay == MainCtrlPos))
|
||||
{ // zmieniaj scndctrlactualpos
|
||||
@@ -585,7 +585,7 @@ bool physics::Vehicle::AutoRelayCheck(void)
|
||||
OK = AutoRelayLineContactorsStep(motorconnectorsoff);
|
||||
}
|
||||
if (OK)
|
||||
LastRelayTime = 0;
|
||||
lineContactors.lastSwitchTime = 0;
|
||||
|
||||
return OK;
|
||||
}
|
||||
@@ -598,7 +598,7 @@ bool physics::Vehicle::AutoRelayShuntStep(bool const ARFASI2)
|
||||
// scnd bez samoczynnego rozruchu
|
||||
if (ScndCtrlActualPos < ScndCtrlPos)
|
||||
{
|
||||
if (LastRelayTime > CtrlDelay && ARFASI2)
|
||||
if (lineContactors.lastSwitchTime > CtrlDelay && ARFASI2)
|
||||
{
|
||||
++ScndCtrlActualPos;
|
||||
SetFlag(SoundFlag, sound::shuntfield);
|
||||
@@ -607,7 +607,7 @@ bool physics::Vehicle::AutoRelayShuntStep(bool const ARFASI2)
|
||||
}
|
||||
else if (ScndCtrlActualPos > ScndCtrlPos)
|
||||
{
|
||||
if (LastRelayTime > CtrlDownDelay && TrainType != train_type::emu)
|
||||
if (lineContactors.lastSwitchTime > CtrlDownDelay && TrainType != train_type::emu)
|
||||
{
|
||||
--ScndCtrlActualPos;
|
||||
SetFlag(SoundFlag, sound::shuntfield);
|
||||
@@ -640,7 +640,7 @@ bool physics::Vehicle::AutoRelayMainStep(bool const ARFASI)
|
||||
}
|
||||
else if (RList[MainCtrlActualPos].R > 0 && ScndCtrlActualPos > 0)
|
||||
{
|
||||
if (LastRelayTime > CtrlDownDelay)
|
||||
if (lineContactors.lastSwitchTime > CtrlDownDelay)
|
||||
{
|
||||
--ScndCtrlActualPos; // boczniki nie dzialaja na poz. oporowych
|
||||
SetFlag(SoundFlag, sound::shuntfield);
|
||||
@@ -681,7 +681,7 @@ bool physics::Vehicle::AutoRelayMainUp(bool const ARFASI)
|
||||
OK = true;
|
||||
}
|
||||
}
|
||||
else if (LastRelayTime > CtrlDelay && ARFASI)
|
||||
else if (lineContactors.lastSwitchTime > CtrlDelay && ARFASI)
|
||||
{
|
||||
OK = AutoRelayMainNotchUp();
|
||||
}
|
||||
@@ -704,7 +704,7 @@ bool physics::Vehicle::AutoRelayMainNotchUp()
|
||||
DelayCtrlFlag = true; // tryb przejscia
|
||||
OK = true;
|
||||
}
|
||||
else if (LastRelayTime > 4 * CtrlDelay) // przejscie
|
||||
else if (lineContactors.lastSwitchTime > 4 * CtrlDelay) // przejscie
|
||||
{
|
||||
|
||||
DelayCtrlFlag = false;
|
||||
@@ -753,7 +753,7 @@ bool physics::Vehicle::AutoRelayMainDown()
|
||||
SetFlag(SoundFlag, sound::parallel);
|
||||
}
|
||||
}
|
||||
else if (LastRelayTime > CtrlDownDelay)
|
||||
else if (lineContactors.lastSwitchTime > CtrlDownDelay)
|
||||
{
|
||||
if (TrainType != train_type::emu) // tutaj powinien być tryb sterowania wałem
|
||||
{
|
||||
@@ -779,9 +779,9 @@ bool physics::Vehicle::AutoRelayLineContactorsStep(bool const motorconnectorsoff
|
||||
{
|
||||
|
||||
DelayCtrlFlag = true;
|
||||
if (LastRelayTime >= InitialCtrlDelay)
|
||||
if (lineContactors.lastSwitchTime >= InitialCtrlDelay)
|
||||
{
|
||||
StLinFlag = true;
|
||||
lineContactors.closed = true;
|
||||
MainCtrlActualPos = 1;
|
||||
DelayCtrlFlag = false;
|
||||
SetFlag(SoundFlag, sound::relay | sound::loud);
|
||||
@@ -793,7 +793,7 @@ bool physics::Vehicle::AutoRelayLineContactorsStep(bool const motorconnectorsoff
|
||||
DelayCtrlFlag = false;
|
||||
}
|
||||
|
||||
if (false == StLinFlag && (MainCtrlActualPos > 0 || ScndCtrlActualPos > 0))
|
||||
if (false == lineContactors.closed && (MainCtrlActualPos > 0 || ScndCtrlActualPos > 0))
|
||||
{
|
||||
OK |= CamshaftRunDown();
|
||||
}
|
||||
@@ -813,7 +813,7 @@ bool physics::Vehicle::CamshaftRunDown()
|
||||
{
|
||||
OK = CamshaftRunDownEMU();
|
||||
}
|
||||
else if (LastRelayTime > CtrlDownDelay) // wal kulakowy dwukierunkowy
|
||||
else if (lineContactors.lastSwitchTime > CtrlDownDelay) // wal kulakowy dwukierunkowy
|
||||
{
|
||||
if (ScndCtrlActualPos > 0)
|
||||
{
|
||||
@@ -830,7 +830,7 @@ bool physics::Vehicle::CamshaftRunDown()
|
||||
else if (HasCamshaft)
|
||||
{
|
||||
// wal kulakowy dwukierunkowy
|
||||
if (LastRelayTime > CtrlDownDelay)
|
||||
if (lineContactors.lastSwitchTime > CtrlDownDelay)
|
||||
{
|
||||
if (MainCtrlActualPos > 0)
|
||||
{
|
||||
@@ -863,7 +863,7 @@ bool physics::Vehicle::CamshaftRunDownEMU()
|
||||
else
|
||||
{
|
||||
|
||||
if (LastRelayTime > CtrlDownDelay)
|
||||
if (lineContactors.lastSwitchTime > CtrlDownDelay)
|
||||
{
|
||||
|
||||
if (MainCtrlActualPos < RlistSize)
|
||||
@@ -894,29 +894,29 @@ bool physics::Vehicle::MotorConnectorsCheck()
|
||||
|
||||
// hunter-111211: wylacznik cisnieniowy
|
||||
// (on some vehicles it watches the brake pipe alone)
|
||||
ControlPressureSwitch = HasControlPressureSwitch && ((PressureSwitchBrakeCylinder && brakes.cylinderPressure > 2.0) || brakePipe.pressure < 3.6);
|
||||
protection.pressureSwitch = protection.hasPressureSwitch && ((protection.pressureSwitchWatchesCylinders && brakes.cylinderPressure > 2.0) || brakePipe.pressure < 3.6);
|
||||
|
||||
if (true == ControlPressureSwitch)
|
||||
if (true == protection.pressureSwitch)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// a line breaker closed ahead of the pantographs holds without voltage; what cuts the motors off there is its
|
||||
// undervoltage relay, which elsewhere opens the line breaker
|
||||
auto const undervoltage{PantographsRequireMains && false == NoVoltRelay};
|
||||
auto const undervoltage{lineBreaker.pantographsRequireIt && false == protection.noVoltage};
|
||||
|
||||
auto const connectorsoff{false == Mains || undervoltage || true == FuseFlag || true == StLinSwitchOff || DirActive == 0};
|
||||
auto const connectorsoff{false == lineBreaker.closed || undervoltage || true == FuseFlag || true == lineContactors.forcedOpen || DirActive == 0};
|
||||
|
||||
return false == connectorsoff && LineContactorsInterlockReleased();
|
||||
}
|
||||
|
||||
bool physics::Vehicle::LineContactorsInterlockReleased() const
|
||||
{
|
||||
switch (LineContactorsInterlock)
|
||||
switch (lineContactors.interlock)
|
||||
{
|
||||
case line_contactors_interlock::converter:
|
||||
// the converter of this very vehicle, not the 110 V of the trainset: a section with its fans off doesn't start
|
||||
return ConverterFlag;
|
||||
return converter.running;
|
||||
case line_contactors_interlock::motor_blowers:
|
||||
return std::ranges::all_of(MotorBlowers, [this](auto const &Blower) {
|
||||
if (Blower.min_start_velocity < 0)
|
||||
@@ -1092,7 +1092,7 @@ void physics::Vehicle::EIMICFromFourPositions(double dt)
|
||||
// hamowanie nagle: pelne hamowanie od razu, przewod glowny oproznia UpdatePipePressure()
|
||||
eimic = -1.0;
|
||||
}
|
||||
else if (MainCtrlActualPos != MainCtrlPos || LastRelayTime > InitialCtrlDelay)
|
||||
else if (MainCtrlActualPos != MainCtrlPos || lineContactors.lastSwitchTime > InitialCtrlDelay)
|
||||
{
|
||||
double delta = MainCtrlActualPos == MainCtrlPos ? dt * CtrlDelay : 0.01;
|
||||
// the positions below are those of the controller without the emergency brake position
|
||||
@@ -1120,10 +1120,10 @@ void physics::Vehicle::EIMICFromFourPositions(double dt)
|
||||
}
|
||||
}
|
||||
if (MainCtrlActualPos == MainCtrlPos)
|
||||
LastRelayTime += dt;
|
||||
lineContactors.lastSwitchTime += dt;
|
||||
else
|
||||
{
|
||||
LastRelayTime = 0;
|
||||
lineContactors.lastSwitchTime = 0;
|
||||
MainCtrlActualPos = MainCtrlPos;
|
||||
}
|
||||
}
|
||||
@@ -1136,7 +1136,7 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak
|
||||
UniversalControllerTrainBrake();
|
||||
}
|
||||
|
||||
if (MainCtrlActualPos != MainCtrlPos || LastRelayTime > InitialCtrlDelay)
|
||||
if (MainCtrlActualPos != MainCtrlPos || lineContactors.lastSwitchTime > InitialCtrlDelay)
|
||||
{
|
||||
auto const &position{UniCtrlList[MainCtrlPos]};
|
||||
double ramped{eimic};
|
||||
@@ -1148,10 +1148,10 @@ void physics::Vehicle::EIMICFromUniversalController(double dt, double const brak
|
||||
eimic = UniCtrlValStep > 0.0 ? stepped_uc_value(eimic, ramped, position, UniCtrlValStep, MainCtrlActualPos != MainCtrlPos, eimic_step_progress) : ramped;
|
||||
}
|
||||
if (MainCtrlActualPos == MainCtrlPos)
|
||||
LastRelayTime += dt;
|
||||
lineContactors.lastSwitchTime += dt;
|
||||
else
|
||||
{
|
||||
LastRelayTime = 0;
|
||||
lineContactors.lastSwitchTime = 0;
|
||||
MainCtrlActualPos = MainCtrlPos;
|
||||
}
|
||||
if (brakes.distributor->GetEDBCP() > 0.3 && eimic < 0 && !UniCtrlIntegratedLocalBrakeCtrl) // when braking with pneumatic brake
|
||||
|
||||
Reference in New Issue
Block a user