mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-01 05:57:08 +01:00
160ffe2147
As the parts of the main circuit: the battery and the low voltage circuits,
the train heating, the circuit of the pantographs and their air become classes
with the definition in `config` and the state behind queries and operations.
The step of the air of the pantographs (the small compressor, the three-way
cock, the leaks, the pressure switch) moves into PantographAir::Update(), which
gets what it needs as plain values (PantographAirSupply) and reports a trip of
the pressure switch, so the vehicle opens its line breaker or switches the
converter of a unit off as before. The drain of the battery and its limits move
into LowVoltageSupply. The latch of the held battery button of the cab moves
from the physics to TTrain, where the button is.
The gauges of the cab bind to the values they show through const pointers
(TGauge::Assign*() take them), so the queries they bind to return const
references and the cab reads the state live without being able to change it.
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.Is110vAvailable()); // 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());
|
|
}
|