18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-21 20:14:59 +01:00

Merge pull request #272 from MaSzyna-EU07/feat/mains-before-pantographs

Line breaker before the pantographs (`Cntrl.PantRequiresMain`)
This commit is contained in:
maj00r
2026-11-11 22:41:28 +01:00
committed by GitHub
6 changed files with 447 additions and 27 deletions

View File

@@ -2165,6 +2165,11 @@ class TMoverParameters
// config, Engine:JointEngineStart. whether the cab's line breaker / engine start switch works the vehicles in multiple
// too; when it doesn't, the cab has separate switches for them (mainb_*, mainc_*)
bool JointEngineStart{true};
// config, .fiz Cntrl.PantRequiresMain: the line breaker closes without traction voltage and holds without it, and the
// pantographs rise and stay up only while it's closed (EU05, EP05, ČD 181 family); off, the pantographs come first and the line
// breaker needs their voltage. what the main circuit feeds still needs the voltage (MainCircuitPowered()), and without
// it the undervoltage relay opens the line contactors (NoVoltRelay)
bool PantographsRequireMains{false};
bool LineBreakerClosesOnlyAtNoPowerPos{false};
bool ControlPressureSwitch{false}; // activates if the main pipe and/or brake cylinder pressure aren't within operational levels
bool HasControlPressureSwitch{true};
@@ -2230,7 +2235,9 @@ class TMoverParameters
double PantPress = 0.0; /*Cisnienie w zbiornikach pantografow*/
bool PantPressSwitchActive{false}; // state of the pantograph pressure switch. gets primed at defined pressure level in pantograph air system
bool PantPressLockActive{false}; // pwr system state flag. fires when pressure switch activates by pantograph pressure dropping below defined level
bool NoVoltRelay{true}; // switches off if the power level drops below threshold
// switches off if the power level drops below threshold, which opens the line breaker; with PantographsRequireMains
// it opens the line contactors instead, and switches back on only with the master controller at zero or the first position
bool NoVoltRelay{true};
bool OvervoltageRelay{true}; // switches off if the power level goes above threshold
bool s_CAtestebrake = false; // hunter-091012: zmienna dla testu ca
std::array<std::pair<double, double>, 4> PowerCircuits; // 24v, 110v, 3x400v and 3000v power circuits, voltage from local sources and current draw pairs
@@ -2659,6 +2666,11 @@ class TMoverParameters
bool HeatingSwitch(bool const State, range_t const Notify = range_t::consist);
void HeatingSwitch_(bool const State);
double EnginePowerSourceVoltage() const; // returns voltage of defined main engine power source
// whether the main circuit feeds what runs on it (the converter, a compressor, the heating, the motor and resistor
// blowers, the traction motors): the line breaker closed, and where it closes ahead of the pantographs and holds
// without traction voltage (PantographsRequireMains) also the voltage there, at least the one the undervoltage
// trip takes. everywhere else it's the same as Mains
bool MainCircuitPowered() const;
/*-funkcje typowe dla lokomotywy elektrycznej*/
void LowVoltagePowerCheck(double const Deltatime);

View File

@@ -438,7 +438,7 @@ double TMoverParameters::Current(double n, double U)
// writepaslog("Delta ", FloatToStr(Delta));
// writepaslog("DeltaQ ", FloatToStr(DeltaQ));
// writepaslog("U ", FloatToStr(U));
if (Mains)
if (MainCircuitPowered())
{
if (U > 0)
MotorCurrent = (U1 - Isf * Rz - Mn * motor_param(SP).fi * n + std::sqrt(Delta)) / (2.0 * Rz);
@@ -1874,7 +1874,8 @@ void TMoverParameters::MainsCheck(double const Deltatime)
break;
}
}
auto const maincircuitpowersupply{std::abs(localvoltage) > 0.1 || GetTrainsetHighVoltage() > 0.1};
// a line breaker closed ahead of the pantographs gets ready on the low voltage circuits
auto const maincircuitpowersupply{std::abs(localvoltage) > 0.1 || GetTrainsetHighVoltage() > 0.1 || (PantographsRequireMains && (Power24vIsAvailable || Power110vIsAvailable))};
if (true == maincircuitpowersupply)
{
@@ -1953,7 +1954,7 @@ void TMoverParameters::PowerCouplersCheck(double const /*Deltatime*/, coupling c
case TPowerSource::Main:
{
// HACK: main circuit can be fed through couplers, so we explicitly check pantograph supply here
localvoltage = true == Mains ? PantographVoltage : 0.0;
localvoltage = MainCircuitPowered() ? PantographVoltage : 0.0;
break;
}
default:
@@ -2210,7 +2211,7 @@ void TMoverParameters::ConverterCheck(double const Timestep)
if (ConverterAllow && ConverterAllowLocal && false == ConvOvldFlag &&
false == PantPressLockActive
// HACK: allow carriages to operate converter without (missing) fuse prerequisite
&& (Power > 1.0 ? Mains : GetTrainsetHighVoltage() > 0.0))
&& (Power > 1.0 ? MainCircuitPowered() : GetTrainsetHighVoltage() > 0.0))
{
// delay timer can be optionally configured, and is set anew whenever converter goes off
if (ConverterStartDelayTimer <= 0.0)
@@ -2296,7 +2297,7 @@ void TMoverParameters::HeatingCheck(double const /*Timestep*/)
}
case TPowerSource::Main:
{
voltage = true == Mains ? std::max(GetTrainsetHighVoltage(), PantographVoltage) : 0.0;
voltage = MainCircuitPowered() ? std::max(GetTrainsetHighVoltage(), PantographVoltage) : 0.0;
break;
}
default:
@@ -2407,7 +2408,7 @@ void TMoverParameters::MotorBlowersCheck(double const Timestep)
// TODO: bind properly power source when ld is in place
(blower.start_type == start_t::battery ? Power24vIsAvailable :
blower.start_type == start_t::converter ? Power110vIsAvailable :
Mains) // power source
MainCircuitPowered()) // power source
// breaker condition disabled until it's implemented in the class data
// && ( true == blower.breaker )
&& false == disable &&
@@ -2466,7 +2467,8 @@ void TMoverParameters::PantographsCheck(double const /*Timestep*/)
valve.is_active = (valve.spring ? lowvoltagepower : true) // spring actuator needs power to maintain non-default state
&& (manualcontrol && lowvoltagepower ? false == valve.is_disabled : true) // needs power to change state, without it just pass through
&& (manualcontrol && lowvoltagepower ? false == PantAllDown : true) &&
(valve.is_active || (manualcontrol && lowvoltagepower && valve.is_enabled) || (autostart && lowvoltagepower)); // shouldn't ever get this far but, eh
(Mains || false == PantographsRequireMains) // fed through the closed line breaker, where it comes first
&& (valve.is_active || (manualcontrol && lowvoltagepower && valve.is_enabled) || (autostart && lowvoltagepower)); // shouldn't ever get this far but, eh
auto const pantographexists{EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.PhysicalLayout & 1 << pant_id};
@@ -3863,7 +3865,8 @@ bool TMoverParameters::MainSwitchCheck() const
case ElectricInductionMotor:
{
// TODO: check whether we can simplify this check and skip the outer EngineType switch
powerisavailable = EnginePowerSourceVoltage() > 0.5 * EnginePowerSource.MaxVoltage;
// closed ahead of the pantographs, the line breaker runs on the low voltage circuits
powerisavailable = PantographsRequireMains ? Power24vIsAvailable || Power110vIsAvailable : EnginePowerSourceVoltage() > 0.5 * EnginePowerSource.MaxVoltage;
break;
}
default:
@@ -3873,7 +3876,8 @@ bool TMoverParameters::MainSwitchCheck() const
}
return powerisavailable && (ScndCtrlPos == 0 || EngineType == ElectricInductionMotor) && MainsInitTimeCountdown <= 0.0 &&
(ConvOvldFlag == false || ConverterOverloadRelayOffWhenMainIsOff) && true == GroundRelay && true == NoVoltRelay && true == OvervoltageRelay && LastSwitchingTime > CtrlDelay &&
(ConvOvldFlag == false || ConverterOverloadRelayOffWhenMainIsOff) && true == GroundRelay && (true == NoVoltRelay || PantographsRequireMains) && true == OvervoltageRelay &&
LastSwitchingTime > CtrlDelay &&
(HasCamshaft ? IsMainCtrlActualNoPowerPos() :
LineBreakerClosesOnlyAtNoPowerPos ? IsMainCtrlNoPowerPos() :
true) &&
@@ -3978,6 +3982,25 @@ double TMoverParameters::EnginePowerSourceVoltage() const
0.0;
}
// whether the main circuit feeds what runs on it: the converter, a compressor, the heating, the motor and resistor
// blowers, the traction motors
bool TMoverParameters::MainCircuitPowered() const
{
if (false == Mains)
{
return false;
}
if (false == PantographsRequireMains || EnginePowerSource.SourceType != TPowerSource::CurrentCollector)
{
// the closed line breaker says it all: the undervoltage trip opens it without traction voltage, and an engine
// which runs is its own supply
return true;
}
// closed ahead of the pantographs the line breaker holds without the voltage, which the undervoltage trip isn't
// there to vouch for
return EnginePowerSourceVoltage() >= EnginePowerSource.CollectorParameters.MinV;
}
// *************************************************************************************************
// Q: 20160711
// zwiększenie nastawy hamulca
@@ -4571,7 +4594,7 @@ void TMoverParameters::CompressorCheck(double dt)
}
// the main circuit, also for a compressor driven by the engine, otherwise the low voltage
auto const compressorpower{CompressorPower == 0 || CompressorPower == 3 ? Mains : Power110vIsAvailable};
auto const compressorpower{CompressorPower == 0 || CompressorPower == 3 ? MainCircuitPowered() : Power110vIsAvailable};
CompressorPowerTime = compressorpower ? CompressorPowerTime + dt : 0.0;
auto const compressorready{compressorpower && CompressorPowerTime >= CompressorStartDelay};
// TBD: split CompressorAllow into separate enable/disable flags, inherit compressor from basic_device
@@ -5908,7 +5931,7 @@ double TMoverParameters::TractionForce(double dt)
case TEngineType::ElectricSeriesMotor:
{
if (true == Mains)
if (MainCircuitPowered())
{
switch (RVentType)
{
@@ -6040,11 +6063,18 @@ double TMoverParameters::TractionForce(double dt)
{
// update the state of voltage relays
auto const voltage{std::max(GetTrainsetHighVoltage(), PantographVoltage)};
NoVoltRelay = EnginePowerSource.SourceType != TPowerSource::CurrentCollector || voltage >= EnginePowerSource.CollectorParameters.MinV;
// where the line breaker holds without voltage (closed ahead of the pantographs) the undervoltage relay opens the
// line contactors instead, see MotorConnectorsCheck(). it picks up again only with the master controller back
// where a start begins, as the line breaker it stands in for wouldn't close on a running position either: at
// zero, or at the first position, which is the first resistance step, where the line contactors close on any
// start, and where the AI waits for them rather than going back to zero
auto const novoltrelaypicksup{false == PantographsRequireMains || NoVoltRelay || MainCtrlPowerPos() <= 1};
NoVoltRelay = EnginePowerSource.SourceType != TPowerSource::CurrentCollector || (voltage >= EnginePowerSource.CollectorParameters.MinV && novoltrelaypicksup);
OvervoltageRelay =
EnginePowerSource.SourceType != TPowerSource::CurrentCollector || voltage <= EnginePowerSource.CollectorParameters.MaxV || false == EnginePowerSource.CollectorParameters.OVP;
// wywalanie szybkiego z powodu niewłaściwego napięcia
EventFlag |= true == Mains && (false == NoVoltRelay || false == OvervoltageRelay) &&
// (a line breaker closed ahead of the pantographs holds without voltage)
EventFlag |= true == Mains && ((false == NoVoltRelay && false == PantographsRequireMains) || false == OvervoltageRelay) &&
MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide
break;
}
@@ -6053,7 +6083,8 @@ double TMoverParameters::TractionForce(double dt)
{
// TODO: check if we can use instead the code for electricseriesmotor
// nie wchodzić w funkcję bez potrzeby
if (Mains && (std::max(GetTrainsetHighVoltage(), PantographVoltage) < EnginePowerSource.CollectorParameters.MinV ||
// (a line breaker closed ahead of the pantographs holds without voltage)
if (Mains && ((std::max(GetTrainsetHighVoltage(), PantographVoltage) < EnginePowerSource.CollectorParameters.MinV && false == PantographsRequireMains) ||
std::max(GetTrainsetHighVoltage(), PantographVoltage) > EnginePowerSource.CollectorParameters.MaxV + 200))
{
MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide
@@ -6574,7 +6605,7 @@ double TMoverParameters::TractionForce(double dt)
case TEngineType::ElectricInductionMotor:
{
if (true == Mains && !SecuritySystem.is_engine_blocked())
if (MainCircuitPowered() && !SecuritySystem.is_engine_blocked())
{
double ActiveInverters = 0.0;
for (auto const &inv : Inverters)
@@ -7492,7 +7523,11 @@ bool TMoverParameters::MotorConnectorsCheck()
return false;
}
auto const connectorsoff{false == Mains || true == FuseFlag || true == StLinSwitchOff || DirActive == 0};
// 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 connectorsoff{false == Mains || undervoltage || true == FuseFlag || true == StLinSwitchOff || DirActive == 0};
return false == connectorsoff;
}
@@ -7867,7 +7902,7 @@ void TMoverParameters::CheckEIMIC(double dt)
eimic = 0;
}
auto const eimicpowerenabled{(true == Mains || Power == 0.0) && (!SpringBrake.IsActive || !SpringBrakeCutsOffDrive) && !LockPipe && DirAbsolute != 0};
auto const eimicpowerenabled{(MainCircuitPowered() || Power == 0.0) && (!SpringBrake.IsActive || !SpringBrakeCutsOffDrive) && !LockPipe && DirAbsolute != 0};
auto const eimicdoorenabled{(SpringBrake.IsActive && ReleaseParkingBySpringBrakeWhenDoorIsOpen)};
double eimic_max = 0.0;
if (Doors.instances[side::left].open_permit == false && Doors.instances[side::right].open_permit == false)
@@ -11572,6 +11607,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
auto lookup = starts.find(extract_value("MainStart", line));
MainsStart = lookup != starts.end() ? lookup->second : start_t::manual;
}
extract_value(PantographsRequireMains, "PantRequiresMain", line, "");
// battery
{
auto lookup = starts.find(extract_value("BatteryStart", line));