diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 45e3305c0..a1a102075 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -1455,6 +1455,7 @@ class TMoverParameters float auto_velocity{-1.f}; // automatic door closure velocity threshold bool auto_include_remote{false}; // automatic door closure applies also to remote control bool permit_needed{false}; + bool closure_signal{false}; // the door closure lamp (SOD) of the cab signals the doors of the whole consist in three states std::vector permit_presets; // permit presets selectable with preset switch float voltage{0.f}; // power type required for door movement // ld inputs @@ -2610,6 +2611,9 @@ class TMoverParameters bool signal_departure(bool const State, range_t const Notify = range_t::consist); // toggles departure warning void update_doors(double const Deltatime); // door controller update door_closure_t door_closure() const; // state of the door closure signalling of this vehicle + // whether the door closure lamp in the cab of this vehicle is lit: with DoorClosureSignal, for the given state of the + // consist; without it, for the lock of the vehicle's own doors, as the lamp always worked + bool door_closure_lamp_lit(door_closure_t const Consist, bool const BlinkLit) const; /* funkcje dla samochodow*/ bool ChangeOffsetH(double DeltaOffset); diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 03fa3e6db..ce3c08458 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -8723,6 +8723,11 @@ door_closure_t TMoverParameters::door_closure() const return door_closure_t::released; } +bool TMoverParameters::door_closure_lamp_lit(door_closure_t const Consist, bool const BlinkLit) const +{ + return Doors.closure_signal ? door_closure_lamp(Consist, BlinkLit) : Doors.is_locked; +} + bool door_closure_lamp(door_closure_t const State, bool const BlinkLit) { switch (State) @@ -10613,6 +10618,8 @@ void TMoverParameters::LoadFIZ_Doors(std::string const &line) extract_value(Doors.auto_include_remote, "DoorAutoCloseRemote", line, ""); // operation permit extract_value(Doors.permit_needed, "DoorNeedPermit", line, ""); + // the door closure lamp (SOD) of the cab signals the doors of the whole consist + extract_value(Doors.closure_signal, "DoorClosureSignal", line, ""); { auto permitpresets = Split(extract_value("DoorPermitList", line), '|'); for (auto const &permit : permitpresets) diff --git a/tests/unit/test_door_closure.cpp b/tests/unit/test_door_closure.cpp index abfa5a7e1..c92d8fef8 100644 --- a/tests/unit/test_door_closure.cpp +++ b/tests/unit/test_door_closure.cpp @@ -1,11 +1,14 @@ #include "stdafx.h" #include "doctest.h" #include "scenario.h" +#include "vehicle.h" // the door closure signalling (SOD, the i-door_blocked lamp of a cab): the state of each vehicle's doors and of the // whole train, the most severe of its vehicles, as the driver gathers it for the lamp (eu07/maszyna#288) using test::scenario; +using test::definition; +using test::vehicle; using namespace test::channels; namespace { @@ -108,3 +111,48 @@ TEST_CASE("door closure: a locomotive has no doors to signal, its coach does") { CHECK(scenario.vehicle(1).door_closure() == door_closure_t::open); CHECK(consist_closure(scenario) == door_closure_t::open); } + +TEST_CASE("door closure: the signalling is switched on by DoorClosureSignal in the Doors section, off without it") { + SUBCASE("without the key") { + vehicle wagon{definition::load("wagon")}; + CHECK_FALSE(wagon->Doors.closure_signal); + } + SUBCASE("with the key") { + vehicle wagon{definition::load("wagon").set("Doors", "DoorClosureSignal", "Yes")}; + CHECK(wagon->Doors.closure_signal); + } +} + +TEST_CASE("door closure: without DoorClosureSignal the lamp shows the lock of the vehicle's own doors, as before") { + vehicle wagon{definition::load("wagon")}; + REQUIRE_FALSE(wagon->Doors.closure_signal); + for (auto const locked : {true, false}) { + wagon->Doors.is_locked = locked; + for (auto const consist : {door_closure_t::none, door_closure_t::locked, door_closure_t::released, door_closure_t::open}) { + for (auto const lit : {true, false}) { + CAPTURE(locked); + CAPTURE(static_cast(consist)); + CAPTURE(lit); + // no blinking at a standstill with the doors closed, whatever the consist does + CHECK(wagon->door_closure_lamp_lit(consist, lit) == locked); + } + } + } +} + +TEST_CASE("door closure: with DoorClosureSignal the lamp shows the consist in three states") { + vehicle wagon{definition::load("wagon").set("Doors", "DoorClosureSignal", "Yes")}; + REQUIRE(wagon->Doors.closure_signal); + for (auto const locked : {true, false}) { + // the vehicle's own lock doesn't matter, the consist does + wagon->Doors.is_locked = locked; + for (auto const lit : {true, false}) { + CAPTURE(locked); + CAPTURE(lit); + CHECK(wagon->door_closure_lamp_lit(door_closure_t::locked, lit)); + CHECK(wagon->door_closure_lamp_lit(door_closure_t::released, lit) == lit); + CHECK_FALSE(wagon->door_closure_lamp_lit(door_closure_t::open, lit)); + CHECK_FALSE(wagon->door_closure_lamp_lit(door_closure_t::none, lit)); + } + } +} diff --git a/utilities/Globals.cpp b/utilities/Globals.cpp index a8aadec22..b4f2e14be 100644 --- a/utilities/Globals.cpp +++ b/utilities/Globals.cpp @@ -506,12 +506,6 @@ bool global_settings::ConfigParseSimulation(cParser& Parser, const std::string& return true; } - if (token == "doorclosuresignal") - { - ParseOne(Parser, DoorClosureSignal); - return true; - } - if (token == "movelight") { ParseOne(Parser, fMoveLight, 1, false); @@ -1579,7 +1573,6 @@ global_settings::export_as_text( std::ostream &Output ) const { export_as_text( Output, "skyenabled", asSky ); export_as_text( Output, "defaultext", szDefaultExt ); export_as_text( Output, "newaircouplers", bnewAirCouplers ); - export_as_text( Output, "doorclosuresignal", DoorClosureSignal ); export_as_text( Output, "anisotropicfiltering", AnisotropicFiltering ); export_as_text( Output, "usevbo", bUseVBO ); export_as_text( Output, "feedbackmode", iFeedbackMode ); diff --git a/utilities/Globals.h b/utilities/Globals.h index 971f8495a..ad216cd96 100644 --- a/utilities/Globals.h +++ b/utilities/Globals.h @@ -115,8 +115,6 @@ struct global_settings { std::string Period{}; // time of the day, based on sun position bool FullPhysics{ true }; // full calculations performed for each simulation step bool bnewAirCouplers{ true }; - bool DoorClosureSignal{ true }; // door closure signalling lamp (i-door_blocked) shows the doors of the whole consist in three states - float fMoveLight{ 0.f }; // numer dnia w roku albo -1 bool FakeLight{ false }; // toggle between fixed and dynamic daylight double fTimeSpeed{ 1.0 }; // przyspieszenie czasu, zmienna do testów diff --git a/vehicle/Train.cpp b/vehicle/Train.cpp index 3a4c42db1..bbcdd1778 100644 --- a/vehicle/Train.cpp +++ b/vehicle/Train.cpp @@ -9108,11 +9108,12 @@ bool TTrain::Update(double const Deltatime) btLampkaDoorLeft.Turn(DynamicObject->Mechanik->IsAnyDoorOpen[cab_to_end() == end::front ? side::left : side::right]); btLampkaDoorRight.Turn(DynamicObject->Mechanik->IsAnyDoorOpen[cab_to_end() == end::front ? side::right : side::left]); } - if (Global.DoorClosureSignal && DynamicObject->Mechanik != nullptr) + if (DynamicObject->Mechanik != nullptr) { - // door closure signalling (SOD) of the whole consist: lit with all doors closed and locked, blinking with - // them closed but released, dark with a door open - btLampkaBlokadaDrzwi.Turn(door_closure_lamp(DynamicObject->Mechanik->DoorClosure, simulation::Time.data().wSecond % 2 < 1)); + // with DoorClosureSignal in the definition of the cab's vehicle, the door closure signalling (SOD) of the whole + // consist: lit with all doors closed and locked, blinking with them closed but released, dark with a door open. + // without it, the lock of the vehicle's own doors, as before + btLampkaBlokadaDrzwi.Turn(mvOccupied->door_closure_lamp_lit(DynamicObject->Mechanik->DoorClosure, simulation::Time.data().wSecond % 2 < 1)); } else {