mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-24 02:39:14 +01:00
feat: SM42 vigilance device switched off in the shunt mode (eu07/maszyna#457)
The shunt mode of the diesel-electrics (ShuntMode=1: SM42, SP42, SU42) now suspends their vigilance device (CA): no alerter while running, no alarm for the button held too long, and an alarm already on goes out. The cab signalling (SHP) stays as it was. Back in the line mode the CA works as before.
This commit is contained in:
@@ -1131,6 +1131,7 @@ class TSecuritySystem
|
||||
bool is_sifa = false; // Sifa-like pedal device, with inverted input for convenient keyboard usage
|
||||
bool separate_acknowledge = false; // cabsignal reset button is separate from vigilance
|
||||
bool cabsignal_lock = false;
|
||||
bool vigilance_suspended = false; // the vigilance device switched off by the vehicle, as by the SM42's shunt mode
|
||||
|
||||
double vigilance_timer = 0.0;
|
||||
double alert_timer = 0.0;
|
||||
@@ -1155,6 +1156,7 @@ class TSecuritySystem
|
||||
void update(double dt, double Vel, bool pwr, int cab);
|
||||
void set_cabsignal();
|
||||
void set_cabsignal_lock(bool);
|
||||
void set_vigilance_suspended(bool Suspended);
|
||||
bool is_blinking() const;
|
||||
bool is_vigilance_blinking() const;
|
||||
bool is_cabsignal_blinking() const;
|
||||
|
||||
@@ -152,11 +152,22 @@ void TSecuritySystem::update(double dt, double vel, bool pwr, int cab)
|
||||
velocity = vel;
|
||||
cabactive = cab;
|
||||
|
||||
if (vigilance_enabled && velocity > AwareMinSpeed)
|
||||
vigilance_timer += dt;
|
||||
if (vigilance_suspended)
|
||||
{
|
||||
// the vigilance device is switched off: neither the alerter nor the button held too long, its alarm gone with it
|
||||
vigilance_timer = 0.0;
|
||||
press_timer = 0.0;
|
||||
if (!cabsignal_active)
|
||||
alert_timer = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (vigilance_enabled && velocity > AwareMinSpeed)
|
||||
vigilance_timer += dt;
|
||||
|
||||
if (pressed && (!is_sifa || velocity > AwareMinSpeed))
|
||||
press_timer += dt;
|
||||
if (pressed && (!is_sifa || velocity > AwareMinSpeed))
|
||||
press_timer += dt;
|
||||
}
|
||||
|
||||
if (vigilance_timer > AwareDelay || press_timer > MaxHoldTime || cabsignal_active)
|
||||
alert_timer += dt;
|
||||
@@ -231,6 +242,11 @@ void TSecuritySystem::set_cabsignal_lock(bool v)
|
||||
cabsignal_lock = v;
|
||||
}
|
||||
|
||||
void TSecuritySystem::set_vigilance_suspended(bool const Suspended)
|
||||
{
|
||||
vigilance_suspended = Suspended;
|
||||
}
|
||||
|
||||
bool TSecuritySystem::is_engine_blocked() const
|
||||
{
|
||||
if (!is_sifa)
|
||||
@@ -3142,6 +3158,8 @@ void TMoverParameters::SecuritySystemReset(void) // zbijanie czuwaka/SHP
|
||||
void TMoverParameters::SecuritySystemCheck(double dt)
|
||||
{
|
||||
bool isPower = Power24vIsAvailable || Power110vIsAvailable;
|
||||
// the shunt mode of the SM42/SP42 switches their vigilance device (CA) off (eu07/maszyna#457)
|
||||
SecuritySystem.set_vigilance_suspended(EngineType == TEngineType::DieselElectric && ShuntMode);
|
||||
SecuritySystem.update(dt, Vel, isPower, CabActive);
|
||||
|
||||
if (!Battery || !Radio)
|
||||
|
||||
@@ -227,3 +227,38 @@ TEST_CASE("cab: the lamps and the buzzer of the security system left unattended"
|
||||
CHECK(security.radiostop_available());
|
||||
scenario.check();
|
||||
}
|
||||
|
||||
TEST_CASE("cab: the SM42's vigilance device switched off in the shunt mode") {
|
||||
// eu07/maszyna#457: the shunt mode of the SM42 switches its vigilance device (CA) off, it alerts again
|
||||
// once the shunt mode is off
|
||||
scenario scenario{"cab/sm42 vigilance in shunt mode", motion() + brakes(), test::track{}};
|
||||
scenario.add("sm42_v1/6d1", 1);
|
||||
REQUIRE(scenario.start_up());
|
||||
auto &sm42{scenario.cab()};
|
||||
auto const &security{sm42.SecuritySystem};
|
||||
REQUIRE(sm42.CurrentSwitch(true));
|
||||
REQUIRE(sm42.ShuntMode);
|
||||
scenario.get_going();
|
||||
sm42.AnPos = 0.3;
|
||||
sm42.IncMainCtrl(1);
|
||||
scenario.act("unattended in shunt mode");
|
||||
bool blinked{false};
|
||||
for (int i = 0; i < 120; ++i) {
|
||||
scenario.train().run(1.0, scenario.line());
|
||||
blinked |= security.is_blinking();
|
||||
}
|
||||
CHECK(sm42.Vel > 1.0);
|
||||
CHECK_FALSE(blinked);
|
||||
CHECK(sm42.PipePress > 3.5);
|
||||
scenario.act("shunt mode off");
|
||||
scenario.notch_back(0);
|
||||
REQUIRE(sm42.CurrentSwitch(false));
|
||||
sm42.IncMainCtrl(1);
|
||||
scenario.act("unattended");
|
||||
for (int i = 0; i < 120; ++i) {
|
||||
scenario.train().run(1.0, scenario.line());
|
||||
blinked |= security.is_vigilance_blinking();
|
||||
}
|
||||
CHECK(blinked);
|
||||
scenario.check();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user