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

feat: line breaker before the pantographs, Cntrl.PantRequiresMain (#68)

New optional .fiz key Cntrl.PantRequiresMain (default No, every existing
vehicle unchanged). With Yes, as on Czech-built locomotives:
- the line breaker closes on the low voltage circuits, without traction
  voltage, and the undervoltage trip doesn't open it (overvoltage and the
  other trips still do);
- a pantograph valve opens and stays open only while the vehicle's line
  breaker is closed, so opening it drops the pantographs.

The AI (TController::PrepareEngine) closes the line breaker before raising
the pantographs for such a vehicle; the line breaker steps moved into
TController::close_line_breaker(). test::start_up() follows the same order.

Game data: to use it, PantRequiresMain=Yes goes on the Cntrl. line of
dynamic/pkp/ep05_v2/ep05.fiz, ep05v1.fiz and dynamic/cd/181_v2/181_cz1.fiz,
18x_pl.fiz (left for later, not part of this change). (#68)
This commit is contained in:
jerrrrycho
2026-11-07 19:18:37 +01:00
parent 939e42b611
commit 5a20f86fd0
6 changed files with 164 additions and 15 deletions

View File

@@ -2093,6 +2093,10 @@ class TMoverParameters
double MainsInitTime{0.0}; // config, initialization time (in seconds) of the main circuit after it receives power, before it can be closed double MainsInitTime{0.0}; // config, initialization time (in seconds) of the main circuit after it receives power, before it can be closed
double MainsInitTimeCountdown{0.0}; // current state of main circuit initialization, remaining time (in seconds) until it's ready double MainsInitTimeCountdown{0.0}; // current state of main circuit initialization, remaining time (in seconds) until it's ready
start_t MainsStart{start_t::manual}; start_t MainsStart{start_t::manual};
// 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 (Czech locomotives); off, the pantographs come first and the line
// breaker needs their voltage
bool PantographsRequireMains{false};
bool LineBreakerClosesOnlyAtNoPowerPos{false}; bool LineBreakerClosesOnlyAtNoPowerPos{false};
bool ControlPressureSwitch{false}; // activates if the main pipe and/or brake cylinder pressure aren't within operational levels bool ControlPressureSwitch{false}; // activates if the main pipe and/or brake cylinder pressure aren't within operational levels
bool HasControlPressureSwitch{true}; bool HasControlPressureSwitch{true};

View File

@@ -1735,7 +1735,8 @@ void TMoverParameters::MainsCheck(double const Deltatime)
break; 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) if (true == maincircuitpowersupply)
{ {
@@ -2327,7 +2328,8 @@ void TMoverParameters::PantographsCheck(double const /*Timestep*/)
valve.is_active = (valve.spring ? lowvoltagepower : true) // spring actuator needs power to maintain non-default state 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 == valve.is_disabled : true) // needs power to change state, without it just pass through
&& (manualcontrol && lowvoltagepower ? false == PantAllDown : true) && && (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}; auto const pantographexists{EnginePowerSource.SourceType == TPowerSource::CurrentCollector && EnginePowerSource.CollectorParameters.PhysicalLayout & 1 << pant_id};
@@ -3683,7 +3685,8 @@ bool TMoverParameters::MainSwitchCheck() const
case ElectricInductionMotor: case ElectricInductionMotor:
{ {
// TODO: check whether we can simplify this check and skip the outer EngineType switch // 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; break;
} }
default: default:
@@ -3693,7 +3696,8 @@ bool TMoverParameters::MainSwitchCheck() const
} }
return powerisavailable && (ScndCtrlPos == 0 || EngineType == ElectricInductionMotor) && MainsInitTimeCountdown <= 0.0 && 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() : (HasCamshaft ? IsMainCtrlActualNoPowerPos() :
LineBreakerClosesOnlyAtNoPowerPos ? IsMainCtrlNoPowerPos() : LineBreakerClosesOnlyAtNoPowerPos ? IsMainCtrlNoPowerPos() :
true) && true) &&
@@ -5698,7 +5702,8 @@ double TMoverParameters::TractionForce(double dt)
OvervoltageRelay = OvervoltageRelay =
EnginePowerSource.SourceType != TPowerSource::CurrentCollector || voltage <= EnginePowerSource.CollectorParameters.MaxV || false == EnginePowerSource.CollectorParameters.OVP; EnginePowerSource.SourceType != TPowerSource::CurrentCollector || voltage <= EnginePowerSource.CollectorParameters.MaxV || false == EnginePowerSource.CollectorParameters.OVP;
// wywalanie szybkiego z powodu niewłaściwego napięcia // 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 MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide
break; break;
} }
@@ -5707,7 +5712,8 @@ double TMoverParameters::TractionForce(double dt)
{ {
// TODO: check if we can use instead the code for electricseriesmotor // TODO: check if we can use instead the code for electricseriesmotor
// nie wchodzić w funkcję bez potrzeby // 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)) std::max(GetTrainsetHighVoltage(), PantographVoltage) > EnginePowerSource.CollectorParameters.MaxV + 200))
{ {
MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide MainSwitch(false, TrainType == dt_EZT ? range_t::unit : range_t::local); // TODO: check whether we need to send this EMU-wide
@@ -10934,6 +10940,7 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
auto lookup = starts.find(extract_value("MainStart", line)); auto lookup = starts.find(extract_value("MainStart", line));
MainsStart = lookup != starts.end() ? lookup->second : start_t::manual; MainsStart = lookup != starts.end() ? lookup->second : start_t::manual;
} }
extract_value(PantographsRequireMains, "PantRequiresMain", line, "");
// battery // battery
{ {
auto lookup = starts.find(extract_value("BatteryStart", line)); auto lookup = starts.find(extract_value("BatteryStart", line));

View File

@@ -169,6 +169,13 @@ bool start_up(driven Driven, track const &Track, double Seconds, trace *Trace) {
if (diesel) { if (diesel) {
prepare_diesel(Driven); prepare_diesel(Driven);
} }
if (controlling.PantographsRequireMains && false == controlling.Mains) {
// the pantographs rise only through the closed line breaker, which closes without their voltage
for (int i = 0; i < 3 && cab.DirActive <= 0; ++i) {
cab.DirectionForward();
}
close_line_breaker(Driven);
}
if (collector) { if (collector) {
raise_pantographs(Driven); raise_pantographs(Driven);
} }

View File

@@ -0,0 +1,117 @@
#include "stdafx.h"
#include "doctest.h"
#include "drive.h"
// the order of the line breaker and the pantographs (eu07/maszyna#68): on Polish locomotives the pantographs
// come first and the line breaker closes on their voltage; on Czech ones (Cntrl.PantRequiresMain) the line
// breaker closes first, without voltage, and the pantographs rise and stay up only while it's closed
namespace {
constexpr test::track line{0.15, 0.0, test::catenary_3kv};
test::definition ep05(bool const Mainsfirst) {
auto definition{test::definition::fiz("ep05_v2/ep05")};
if (Mainsfirst) {
definition.set("Cntrl", "PantRequiresMain", "Yes");
}
return definition;
}
// battery and cab on, direction set and the relays reset, the pantographs on the main reservoir's air
void prepare(test::vehicle &Loco) {
Loco.hold_main_reservoir(6.0);
Loco->bPantKurek3 = true;
Loco->BatterySwitch(true);
Loco->CabActivisation();
for (int i = 0; i < 3 && Loco->DirActive <= 0; ++i) {
Loco->DirectionForward();
}
Loco.run(2.0, line);
Loco->RelayReset(relay_t::maincircuitground | relay_t::tractionnmotoroverload | relay_t::primaryconverteroverload);
Loco.run(2.0, line);
}
void raise_pantograph(test::vehicle &Loco) {
Loco->OperatePantographsValve(operation_t::enable);
Loco->OperatePantographValve(end::rear, operation_t::enable);
Loco.run(5.0, line);
}
void close_line_breaker(test::vehicle &Loco) {
Loco->MainSwitch(true);
Loco.run(2.0, line);
}
} // namespace
TEST_CASE("mains before pantographs: without the flag the line breaker needs the pantographs' voltage, as before") {
test::vehicle loco{ep05(false), 0.0, "test", 1};
REQUIRE_FALSE(loco->PantographsRequireMains);
prepare(loco);
close_line_breaker(loco);
CHECK_FALSE(loco->Mains);
raise_pantograph(loco);
CHECK(loco->Pantographs[end::rear].is_active);
CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv));
close_line_breaker(loco);
CHECK(loco->Mains);
// the pantographs stay up with the line breaker open, and the line breaker opens without voltage
loco->MainSwitch(false);
loco.run(2.0, line);
CHECK(loco->Pantographs[end::rear].is_active);
close_line_breaker(loco);
REQUIRE(loco->Mains);
loco->OperatePantographValve(end::rear, operation_t::disable);
loco.run(2.0, line);
CHECK_FALSE(loco->Mains);
}
TEST_CASE("mains before pantographs: with the flag the pantographs rise only through the closed line breaker") {
test::vehicle loco{ep05(true), 0.0, "test", 1};
REQUIRE(loco->PantographsRequireMains);
prepare(loco);
// the pantographs stay down while the line breaker is open
raise_pantograph(loco);
CHECK_FALSE(loco->Pantographs[end::rear].is_active);
CHECK(loco->PantographVoltage == 0.0);
// the line breaker closes without voltage, and the pantograph rises through it
close_line_breaker(loco);
CHECK(loco->Mains);
raise_pantograph(loco);
CHECK(loco->Pantographs[end::rear].is_active);
CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv));
CHECK(loco->Mains);
// opening the line breaker drops the pantograph, which stays down until the line breaker closes again
loco->MainSwitch(false);
loco.run(2.0, line);
CHECK_FALSE(loco->Mains);
CHECK_FALSE(loco->Pantographs[end::rear].is_active);
CHECK(loco->PantographVoltage == 0.0);
// a pantograph lowered under the closed line breaker leaves it closed
close_line_breaker(loco);
raise_pantograph(loco);
REQUIRE(loco->Pantographs[end::rear].is_active);
loco->OperatePantographValve(end::rear, operation_t::disable);
loco.run(5.0, line);
CHECK_FALSE(loco->Pantographs[end::rear].is_active);
CHECK(loco->Mains);
}
TEST_CASE("mains before pantographs: with the flag the line breaker still needs the battery") {
test::vehicle loco{ep05(true), 0.0, "test", 1};
loco.hold_main_reservoir(6.0);
loco.run(2.0, line);
close_line_breaker(loco);
CHECK_FALSE(loco->Mains);
}
TEST_CASE("mains before pantographs: with the flag the driver's start-up gets the locomotive ready") {
// test::start_up() takes the AI's steps of TController::PrepareEngine(), the line breaker first here
test::vehicle loco{ep05(true), 0.0, "test", 1};
auto driven{test::driving(loco)};
REQUIRE(test::start_up(driven, line));
CHECK(loco->Mains);
CHECK(loco->PantographVoltage == doctest::Approx(test::catenary_3kv));
CHECK(test::is_ready(driven));
}

View File

@@ -2679,6 +2679,20 @@ void TController::SetDriverPsyche() {
} }
} }
// closes the line breaker, or starts the engine, the relays reset first
void TController::close_line_breaker()
{
cue_action( driver_hint::mastercontrollersetzerospeed );
// consist-wide ground relay reset
cue_action( driver_hint::maincircuitgroundreset );
cue_action( driver_hint::tractionnmotoroverloadreset );
if( mvOccupied->EngineType == TEngineType::DieselEngine ) {
// specjalnie dla SN61 żeby nie zgasł
cue_action( driver_hint::mastercontrollersetidle );
}
cue_action( driver_hint::linebreakerclose );
}
bool TController::PrepareEngine() bool TController::PrepareEngine()
{ // odpalanie silnika { // odpalanie silnika
// HACK: don't immediately activate inert vehicle in case the simulation is about to replace us with human driver // HACK: don't immediately activate inert vehicle in case the simulation is about to replace us with human driver
@@ -2702,6 +2716,13 @@ bool TController::PrepareEngine()
} }
} }
if( mvControlling->PantographsRequireMains
&& IsAnyLineBreakerOpen ) {
// the pantographs rise only through the closed line breaker, which closes without their voltage
PrepareDirection();
close_line_breaker();
}
if( mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector if( mvPantographUnit->EnginePowerSource.SourceType == TPowerSource::CurrentCollector
&& mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) { && mvPantographUnit->EnginePowerSource.CollectorParameters.CollectorsNo > 0 ) {
// if our pantograph unit isn't a pantograph-devoid fallback // if our pantograph unit isn't a pantograph-devoid fallback
@@ -2756,15 +2777,7 @@ bool TController::PrepareEngine()
} }
if( IsAnyLineBreakerOpen ) { if( IsAnyLineBreakerOpen ) {
// activate main circuit or engine // activate main circuit or engine
cue_action( driver_hint::mastercontrollersetzerospeed ); close_line_breaker();
// consist-wide ground relay reset
cue_action( driver_hint::maincircuitgroundreset );
cue_action( driver_hint::tractionnmotoroverloadreset );
if( mvOccupied->EngineType == TEngineType::DieselEngine ) {
// specjalnie dla SN61 żeby nie zgasł
cue_action( driver_hint::mastercontrollersetidle );
}
cue_action( driver_hint::linebreakerclose );
} }
else { else {
// main circuit or engine is on, set up vehicle devices and controls // main circuit or engine is on, set up vehicle devices and controls

View File

@@ -592,6 +592,7 @@ public:
bool CheckVehicles( TOrders user = Wait_for_orders ); bool CheckVehicles( TOrders user = Wait_for_orders );
private: private:
bool PrepareEngine(); bool PrepareEngine();
void close_line_breaker();
bool ReleaseEngine(); bool ReleaseEngine();
void Doors( bool const Open, int const Side = 0 ); void Doors( bool const Open, int const Side = 0 );
// returns true if any vehicle in the consist has an open door // returns true if any vehicle in the consist has an open door