mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-18 19:39:20 +02:00
- automatic couplers don't catch above the safe collision speed (#86): with crash damage on they couple at a closing speed of 15 km/h at most, a faster hit locks the coupling until the vehicles part and the collision runs its course. On the way: CollisionVelocity() read a head-on 10 + 10 km/h as 14.1 km/h (quaternions turn by half the angle), it's now taken from the touching ends; CollisionDetect() took the other vehicle's speed the wrong way round for vehicles facing each other. Head-on hits now derail sooner, at the intended limit, - a single horn lever can't sound both tones at once (eu07/maszyna#392), - a skid ends once the vehicle stops on locked wheels (eu07/maszyna#479), - electronic destination signs are blanked at the end of the timetable (eu07/maszyna#446), - horns need the air or the voltage to sound (eu07/maszyna#290, #76): HornType=[Pneumatic]|Electric and Horn3Type in Cntrl.; a pneumatic horn needs 0.2 MPa in the main reservoir (or the main pipe without one), an electric one the low voltage; the lever stays where it was put, - compressor start delay (#67): CompressorStartDelay [s] in Brake., counted from the compressor getting its power, after the engine starts say; none by default, - the channel and volume buttons of a radio without power do nothing (eu07/maszyna#429); the power check of the radio is TMoverParameters::RadioPowered(), - a lever moved smoothly sounds the positions it passes (#83). Sonar findings in the functions changed: nesting, nested conditionals, commented-out code, std::format, references to const. Unit tests: test::pair for two vehicles running into each other, test_couplers, test_horn, test_wheelslip, test_compressor, test_radio, test_gauge_positions.
63 lines
2.3 KiB
C++
63 lines
2.3 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
#include "vehicle.h"
|
|
|
|
using test::definition;
|
|
using test::track;
|
|
using test::vehicle;
|
|
|
|
namespace {
|
|
|
|
struct braking_result {
|
|
bool skidded{false}; // the wheels locked while braking
|
|
bool stopped{false}; // came (almost) to a stop on the braking rail
|
|
};
|
|
|
|
// brakes the wagon from 40 km/h on the Braking rail until it's (nearly) stopped, then has it stand on the
|
|
// Standing one for 30 seconds
|
|
braking_result brake_to_stop_then_stand(vehicle &Coach, track const &Braking, track const &Standing) {
|
|
braking_result result;
|
|
Coach.hold_brake_pipe(5.0);
|
|
Coach.run(5.0, Braking);
|
|
Coach.hold_brake_pipe(3.5); // service braking
|
|
// a skidding wagon brakes on the sliding adhesion only, give it time
|
|
for (auto step = 0; step < 60000; ++step) { // 600 s in 0.01 s steps
|
|
result.skidded |= Coach->SlippingWheels;
|
|
if (auto const speed{std::abs(Coach.speed())}; speed > 0.0 && speed < 0.1) {
|
|
// almost stopped; a skidding wagon is still skidding at this point
|
|
result.stopped = true;
|
|
break;
|
|
}
|
|
Coach.step(Braking);
|
|
}
|
|
Coach.run(30.0, Standing);
|
|
return result;
|
|
}
|
|
|
|
} // namespace
|
|
|
|
// the engine doesn't let a stopped, braked vehicle slip (the Vel > 0.1 trap in TMoverParameters::ComputeTotalForce),
|
|
// so a wagon which stopped in a skid should be no different from one which stopped without it. it used to stay
|
|
// skidding instead, with its brakes capped by the sliding adhesion, and slid or crept away (eu07/maszyna#479)
|
|
TEST_CASE("wheelslip: a wagon which stopped in a skid holds like one which stopped without it") {
|
|
track const dry{0.15, 0.0};
|
|
track const slippery{0.02, 0.0};
|
|
// held only by the brakes: the sliding adhesion on this rail is too low for the slope
|
|
track const slipperyslope{0.02, 0.08};
|
|
|
|
vehicle normal{definition::load("wagon"), 40.0};
|
|
auto const normalbraking{brake_to_stop_then_stand(normal, dry, slipperyslope)};
|
|
vehicle skidding{definition::load("wagon"), 40.0};
|
|
auto const skiddingbraking{brake_to_stop_then_stand(skidding, slippery, slipperyslope)};
|
|
|
|
// the test means something only when the braking went as planned
|
|
REQUIRE(normalbraking.stopped);
|
|
REQUIRE_FALSE(normalbraking.skidded);
|
|
REQUIRE(skiddingbraking.stopped);
|
|
REQUIRE(skiddingbraking.skidded);
|
|
|
|
CHECK(std::abs(normal.speed()) < 0.1);
|
|
CHECK(std::abs(skidding.speed()) < 0.1);
|
|
CHECK_FALSE(skidding->SlippingWheels);
|
|
}
|