mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-18 03:19:19 +02:00
- a cab with only the combined horn lever (horn_bt:) and no separate tone buttons could sound the low and high tones at once, which the lever can't do; the tones are now exclusive there, and releasing the other tone's key keeps the lever in place (eu07/maszyna#392), - a skid ends when the wheel speed crosses the vehicle speed, which never happens with wheels locked by the brakes once the vehicle has stopped; it stayed flagged as slipping, its braking force capped by the sliding adhesion, so a few such wagons could push a braked consist around (eu07/maszyna#479). Like the Vel > 0.1 trap of the skid start, a (nearly) stopped vehicle with wheels turning at its speed is no longer slipping, - lit electronic destination signs kept showing the relation after the timetable had ended, until the battery was switched off (eu07/maszyna#446); they are blanked when the timetable runs out, physical signs stay up until changed. What the horn keys do to WarningSignal moves out of the TTrain command handlers into vehicle/horn, which the unit tests call; the handlers keep the gauges. Tests: tests/unit/test_horn.cpp, both kinds of cabs, and tests/unit/test_wheelslip.cpp, a wagon which stopped in a skid on slippery rail holds on a slope like one which stopped on dry rail (without the fix it runs away, ~70 km/h after 30 s).
40 lines
1.3 KiB
C++
40 lines
1.3 KiB
C++
#include "stdafx.h"
|
|
#include "doctest.h"
|
|
|
|
#include "vehicle/horn.h"
|
|
|
|
// the horn keys of the cab: low tone (A) and high tone (shift+A), held to sound
|
|
|
|
TEST_CASE("horn: a single lever for both tones sounds one tone at a time (eu07/maszyna#392)") {
|
|
auto signal{0};
|
|
signal = horn::pressed(signal, horn::low, true);
|
|
REQUIRE(signal == horn::low);
|
|
|
|
// the lever moved over to the high tone while the low tone key is still held
|
|
signal = horn::pressed(signal, horn::high, true);
|
|
CHECK(signal == horn::high);
|
|
|
|
// letting go of the low tone key leaves the high tone sounding
|
|
signal = horn::released(signal, horn::low);
|
|
CHECK(signal == horn::high);
|
|
|
|
signal = horn::released(signal, horn::high);
|
|
CHECK(signal == 0);
|
|
}
|
|
|
|
TEST_CASE("horn: separate buttons for the tones can sound both at once") {
|
|
auto signal{0};
|
|
signal = horn::pressed(signal, horn::low, false);
|
|
signal = horn::pressed(signal, horn::high, false);
|
|
CHECK(signal == (horn::low | horn::high));
|
|
|
|
signal = horn::released(signal, horn::low);
|
|
CHECK(signal == horn::high);
|
|
}
|
|
|
|
TEST_CASE("horn: releasing a tone leaves the other bits of the signal alone") {
|
|
auto const third{4}; // the third horn, operated separately
|
|
CHECK(horn::released(horn::low | third, horn::low) == third);
|
|
CHECK(horn::pressed(third, horn::high, true) == (horn::high | third));
|
|
}
|