18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 11:47:06 +01:00
Files
maszyna/tests/unit/test_oil_pump.cpp
Hirek 160ffe2147 refactor(physics): the low voltage, the train heating and the pantographs keep their state to themselves
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.
2026-11-29 10:08:54 +01:00

56 lines
2.1 KiB
C++

#include "stdafx.h"
#include "doctest.h"
#include "vehicle.h"
using test::definition;
using test::vehicle;
// the oil pump lamp of the cab (i-oilpump) shows OilPump.is_active: the pre-lubrication pump of 401Da, which works
// before the engine start and stops once the engine runs and makes the oil pressure itself (eu07/maszyna#546)
// NOTE: the test vehicle has no diesel engine, so the pump check is called the way dizel_Update() calls it
TEST_CASE("oil pump: the pre-lubrication pump works before the engine start and stops once the engine runs") {
vehicle loco{definition::load("cab_vehicle").set("Cntrl", "OilStart", "Manual")};
REQUIRE(loco->OilPump.start_type == start_t::manual);
loco->lowVoltage.Set24vAvailableForTest(true); // battery on
loco->OilPumpCheck(0.01);
CHECK_FALSE(loco->OilPump.is_active); // not switched on yet
loco->OilPump.is_enabled = true; // pump switch on: pre-lubrication
loco->OilPumpCheck(0.01);
CHECK(loco->OilPump.is_active);
loco->lineBreaker.Close(); // engine started
loco->OilPumpCheck(0.01);
CHECK_FALSE(loco->OilPump.is_active);
}
TEST_CASE("oil pump: the pump started with the engine start procedure stops once the engine runs") {
vehicle loco{definition::load("cab_vehicle").set("Cntrl", "OilStart", "Automatic")};
REQUIRE(loco->OilPump.start_type == start_t::automatic);
loco->lowVoltage.Set24vAvailableForTest(true);
loco->diesel.startupRequested = true; // starter button pressed
loco->OilPumpCheck(0.01);
CHECK(loco->OilPump.is_active);
loco->diesel.startupRequested = false; // start procedure done, the pump keeps working until the engine runs
loco->OilPumpCheck(0.01);
CHECK(loco->OilPump.is_active);
loco->lineBreaker.Close();
loco->OilPumpCheck(0.01);
CHECK_FALSE(loco->OilPump.is_active);
}
TEST_CASE("oil pump: without power the pump and its lamp stay off") {
vehicle loco{definition::load("cab_vehicle")};
loco->lowVoltage.Set24vAvailableForTest(false);
loco->lowVoltage.Set110vAvailableForTest(false);
loco->OilPump.is_enabled = true;
loco->OilPumpCheck(0.01);
CHECK_FALSE(loco->OilPump.is_active);
}