18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 18:47:06 +01:00
Files
maszyna/tests/unit/test_switches.cpp
T
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

17 lines
638 B
C++

#include "stdafx.h"
#include "doctest.h"
#include "vehicle.h"
// the kinds of the cab switches, given in the Switches: section of the vehicle definition
TEST_CASE("switches: the train heating switch can spring back (MaSzyna-EU07/maszyna#85)") {
SUBCASE("impulse") {
test::vehicle vehicle{test::definition::load("cab_vehicle").set("Switches", "TrainHeating", "Impulse")};
CHECK(vehicle->trainHeating.config.switchImpulse); // whichever the case it's written in
}
SUBCASE("a plain switch by default") {
test::vehicle vehicle{test::definition::load("cab_vehicle")};
CHECK_FALSE(vehicle->trainHeating.config.switchImpulse);
}
}