18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 09:36:48 +01:00

refactor(physics): six more of what the rest only reads are private, under names of their own

The mass of the empty vehicle, the braking force, the outcome of a derailment,
the departure signal, the traction mode of a dual-mode vehicle and the moment
of the motors are private to physics::Vehicle like the 53 before them, read
through Mass(), Fb(), Derailed(), DepartureSignal(), TractionMode() and Mm().
Inside the class they are emptyMass, brakingForce, derailOutcome,
departureSignalOn, tractionModeSetting and motorMoment, as the plain camelCase
names were taken by locals there.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 13:23:53 +01:00
parent 5879c228dc
commit ef8a1fdbfd
41 changed files with 167 additions and 160 deletions
+4 -4
View File
@@ -25,8 +25,8 @@ TEST_CASE("fiz: every real vehicle loads and keeps its parameters") {
test::trace trace{"fiz/" + path, test::channels::parameters(), 1};
trace.sample(0.0, real.physics());
// what every vehicle has, the rest of its parameters are in the golden trace
CHECK(real->Mass > 0.0);
CHECK(real->TotalMass() >= real->Mass);
CHECK(real->Mass() > 0.0);
CHECK(real->TotalMass() >= real->Mass());
CHECK(real->Vmax() > 0.0);
CHECK(real->NAxles() > 0);
CHECK(real->WheelDiameter() > 0.0);
@@ -37,8 +37,8 @@ TEST_CASE("fiz: every real vehicle loads and keeps its parameters") {
TEST_CASE("fiz: changes made by a test reach the vehicle") {
auto const eu07{definition::fiz("4e_v1/4e")};
CHECK(vehicle{eu07}->Mass == doctest::Approx(80000.0));
CHECK(vehicle{definition{eu07}.set("Param", "M", 90000)}->Mass == doctest::Approx(90000.0));
CHECK(vehicle{eu07}->Mass() == doctest::Approx(80000.0));
CHECK(vehicle{definition{eu07}.set("Param", "M", 90000)}->Mass() == doctest::Approx(90000.0));
// a key the file doesn't have is added to its section
CHECK(vehicle{definition{eu07}.set("Brake", "MaxBP", 3.5)}->brakes.config.maxCylinderPressure[3] == doctest::Approx(3.5));
// removing a key brings its default back