mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 05:57:08 +01:00
22ebc41d70
The line breaker, the line contactors, the protective relays and the converter
(physics/components/maincircuit.h) become classes: what the .fiz defines is in
their public `config`, their state is private, read through queries
(IsClosed(), UndervoltageHolds(), IsRunning()) and changed through operations
(Close(), ResetGround(), Switch()). The logic that concerns only them moves in:
the initialisation of the main circuit, the ground relay, the pressure switch,
the resets of the relays, and the whole step of the converter, which gets what
it needs from the vehicle as plain values (ConverterSupply).
The vehicle still decides when they act (the interlocks, the controller
positions, the voltages); the parts don't take a physics::Vehicle.
No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
75 lines
3.0 KiB
C++
75 lines
3.0 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
#include "vehicle.h"
|
|
|
|
// stopping the engine of a diesel shunter like the SM03 (eu07/maszyna#427): its fuel pump starts on its own with the
|
|
// engine and the engine runs the converter which feeds the low voltage circuit, so neither the fuel pump switch nor the
|
|
// battery switch stop it. the cab has only the starter button, and the command opening the main circuit has to stop it
|
|
|
|
namespace {
|
|
|
|
// the shunter with its engine started from the cab and idling
|
|
test::vehicle running_shunter() {
|
|
test::vehicle shunter{test::definition::load("diesel_shunter")};
|
|
shunter->CabOccupied = 1;
|
|
shunter->CabActivisation();
|
|
shunter->BatterySwitch(true);
|
|
shunter->OilPumpSwitch(true);
|
|
shunter.run(20.0); // the oil pressure builds up
|
|
shunter->MainSwitch(true);
|
|
shunter.run(15.0);
|
|
return shunter;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
TEST_CASE("engine shutdown: the shunter starts with the starter button") {
|
|
auto shunter{running_shunter()};
|
|
REQUIRE(shunter->EngineType == TEngineType::DieselEngine);
|
|
REQUIRE(shunter->FuelPump.start_type == start_t::automatic);
|
|
CHECK(shunter->lineBreaker.IsClosed());
|
|
CHECK(shunter->FuelPump.is_active);
|
|
CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions);
|
|
}
|
|
|
|
TEST_CASE("engine shutdown: neither the fuel pump switch nor the battery switch stop the engine") {
|
|
auto shunter{running_shunter()};
|
|
shunter->FuelPumpSwitchOff(true, range_t::local); // the pump started automatically ignores its switch
|
|
shunter.run(10.0);
|
|
CHECK(shunter->lineBreaker.IsClosed());
|
|
shunter->BatterySwitch(false);
|
|
shunter.run(10.0);
|
|
CHECK(shunter->lowVoltage.power110vAvailable); // the converter run by the engine keeps feeding the fuel pump
|
|
CHECK(shunter->lineBreaker.IsClosed());
|
|
CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions);
|
|
}
|
|
|
|
TEST_CASE("engine shutdown: the command opening the main circuit stops the engine and it stays stopped") {
|
|
auto shunter{running_shunter()};
|
|
REQUIRE(shunter->MainCircuitOpensWithStarterOnly()); // the cab passes the command on with only the starter button
|
|
CHECK(shunter->MainSwitch(false));
|
|
shunter.run(20.0);
|
|
CHECK_FALSE(shunter->lineBreaker.IsClosed());
|
|
CHECK_FALSE(shunter->FuelPump.is_active);
|
|
CHECK(shunter->enrot == 0.0);
|
|
}
|
|
|
|
TEST_CASE("engine shutdown: the engine starts again after it was stopped") {
|
|
auto shunter{running_shunter()};
|
|
shunter->MainSwitch(false);
|
|
shunter.run(20.0);
|
|
REQUIRE(shunter->enrot == 0.0);
|
|
shunter->MainSwitch(true);
|
|
shunter.run(15.0);
|
|
CHECK(shunter->lineBreaker.IsClosed());
|
|
CHECK(shunter->enrot > 0.9 * shunter->diesel.minRevolutions);
|
|
}
|
|
|
|
TEST_CASE("engine shutdown: vehicles without a diesel keep ignoring the command with only the button closing the circuit") {
|
|
test::vehicle wagon{test::definition::load("wagon")};
|
|
CHECK_FALSE(wagon->MainCircuitOpensWithStarterOnly());
|
|
test::vehicle electric{test::definition::load("wagon").set("Engine", "EngineType", "ElectricSeriesMotor")};
|
|
REQUIRE(electric->EngineType == TEngineType::ElectricSeriesMotor);
|
|
CHECK_FALSE(electric->MainCircuitOpensWithStarterOnly());
|
|
}
|