18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-19 09:56:01 +01:00

Merge pull request #268 from MaSzyna-EU07/fix/ws-hold-coil-lever-bistable

Bistable hold coil lever of the line breaker (eu07/maszyna#364)
This commit is contained in:
2026-11-09 12:57:49 +00:00
committed by GitHub
5 changed files with 112 additions and 2 deletions

View File

@@ -0,0 +1,30 @@
#include "stdafx.h"
#include "doctest.h"
#include "vehicle/holdcoillever.h"
// the lever of the line breaker's hold coil on the ET22 and the EP09 stays where it's put (eu07/maszyna#364), when the
// cab declares its main_off_bt control with "type: toggle"; otherwise main_off_bt is the push button it always was
TEST_CASE("hold coil lever: only a main_off_bt declared as a toggle switch is the bistable lever (eu07/maszyna#364)") {
CHECK(hold_coil_lever::is_bistable(true, true));
// declared as a push button
CHECK_FALSE(hold_coil_lever::is_bistable(true, false));
// no type given: a control defaults to the toggle type, which existing cabs relied on for the push button
CHECK_FALSE(hold_coil_lever::is_bistable(false, true));
}
TEST_CASE("hold coil lever: operated, it goes over to the other position and stays there") {
// on: the hold coil fed, the line breaker can close
CHECK_FALSE(hold_coil_lever::cuts_off(0.f));
auto const off{hold_coil_lever::operated(0.f)};
CHECK(off == doctest::Approx(1.f));
CHECK(hold_coil_lever::cuts_off(off));
// operated again it goes back on
auto const on{hold_coil_lever::operated(off)};
CHECK(on == doctest::Approx(0.f));
CHECK_FALSE(hold_coil_lever::cuts_off(on));
// caught on the way between the positions it goes to the far one
CHECK(hold_coil_lever::operated(0.3f) == doctest::Approx(1.f));
CHECK(hold_coil_lever::operated(0.7f) == doctest::Approx(0.f));
}