mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 02:56:01 +01:00
feat: bistable hold coil lever of the line breaker (eu07/maszyna#364)
main_off_bt declared with "type: toggle" in the cab's .mmd is now the line breaker's hold coil lever of the ET22 and EP09: it stays where it is put. Off, it opens the line breaker and keeps it from closing (also cancelling a closing armed by a held main_on_bt); back on, it only feeds the coil again. The single keyboard key puts the lever back on before closing, and a line breaker closed by the AI or through the control cable puts the lever back on to match. TGauge now remembers whether type: was given, since every control defaults to toggle. Without type: on main_off_bt (all vehicles today) nothing changes. Data (SVN, not part of this commit): add "type: toggle" to main_off_bt: in dynamic/pkp/et22_v3/*.mmd and dynamic/pkp/ep09_v1, ep09_v2/*.mmd. Older exes ignore it.
This commit is contained in:
30
tests/unit/test_hold_coil_lever.cpp
Normal file
30
tests/unit/test_hold_coil_lever.cpp
Normal 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));
|
||||
}
|
||||
Reference in New Issue
Block a user