From 20652829b12ad12329410b1698ff11008fc88d95 Mon Sep 17 00:00:00 2001 From: milek7 Date: Sat, 16 Mar 2019 17:50:17 +0100 Subject: [PATCH] separate cabsignal acknowledge --- McZapkie/MOVER.h | 2 ++ McZapkie/Mover.cpp | 16 +++++++++++++--- Train.cpp | 8 ++++++++ Train.h | 1 + command.cpp | 1 + command.h | 1 + 6 files changed, 26 insertions(+), 3 deletions(-) diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 4ce7e394..667f9ff5 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -572,6 +572,7 @@ class TSecuritySystem bool pressed = false; bool enabled = false; 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 double vigilance_timer = 0.0; double alert_timer = 0.0; @@ -589,6 +590,7 @@ public: void set_enabled(bool e); void acknowledge_press(); void acknowledge_release(); + void cabsignal_reset(); void update(double dt, double Vel); void set_cabsignal(); bool is_blinking() const; diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index a48a86b5..978fbe97 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -82,7 +82,7 @@ int DirF(int CouplerN) void TSecuritySystem::set_enabled(bool e) { if (vigilance_enabled || cabsignal_enabled) enabled = e; - if (enabled && cabsignal_enabled && !is_sifa) { + if (enabled && cabsignal_enabled) { cabsignal_active = true; alert_timer = SoundSignalDelay; } @@ -91,14 +91,15 @@ void TSecuritySystem::set_enabled(bool e) { void TSecuritySystem::acknowledge_press() { pressed = true; - if (cabsignal_active) { + if (!separate_acknowledge && cabsignal_active) { cabsignal_active = false; alert_timer = 0.0; return; } + if (vigilance_timer > AwareDelay) + alert_timer = 0.0; vigilance_timer = 0.0; - alert_timer = 0.0; } void TSecuritySystem::acknowledge_release() { @@ -108,6 +109,13 @@ void TSecuritySystem::acknowledge_release() { alert_timer = 0.0; } +void TSecuritySystem::cabsignal_reset() { + if (cabsignal_active) { + cabsignal_active = false; + alert_timer = 0.0; + } +} + void TSecuritySystem::update(double dt, double vel) { if (!enabled) { cabsignal_active = false; @@ -176,6 +184,8 @@ void TSecuritySystem::load(std::string const &line, double Vmax) { cabsignal_enabled = true; if( awaresystem.find( "Sifa" ) != std::string::npos ) is_sifa = true; + if( awaresystem.find( "SeparateAcknowledge" ) != std::string::npos ) + separate_acknowledge = true; extract_value( AwareDelay, "AwareDelay", line, "" ); AwareMinSpeed = 0.1 * Vmax; //domyślnie 10% Vmax diff --git a/Train.cpp b/Train.cpp index 5f2431af..a9ddd216 100644 --- a/Train.cpp +++ b/Train.cpp @@ -215,6 +215,7 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = { { user_command::reverserneutral, &TTrain::OnCommand_reverserneutral }, { user_command::reverserbackward, &TTrain::OnCommand_reverserbackward }, { user_command::alerteracknowledge, &TTrain::OnCommand_alerteracknowledge }, + { user_command::cabsignalacknowledge, &TTrain::OnCommand_cabsignalacknowledge }, { user_command::batterytoggle, &TTrain::OnCommand_batterytoggle }, { user_command::batteryenable, &TTrain::OnCommand_batteryenable }, { user_command::batterydisable, &TTrain::OnCommand_batterydisable }, @@ -1730,6 +1731,13 @@ void TTrain::OnCommand_alerteracknowledge( TTrain *Train, command_data const &Co } } +void TTrain::OnCommand_cabsignalacknowledge( TTrain *Train, command_data const &Command ) { + // TODO: visual feedback + if( Command.action == GLFW_PRESS ) { + Train->mvOccupied->SecuritySystem.cabsignal_reset(); + } +} + void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command ) { if( Command.action == GLFW_PRESS ) { diff --git a/Train.h b/Train.h index f66a006b..be898179 100644 --- a/Train.h +++ b/Train.h @@ -219,6 +219,7 @@ class TTrain static void OnCommand_reverserneutral( TTrain *Train, command_data const &Command ); static void OnCommand_reverserbackward( TTrain *Train, command_data const &Command ); static void OnCommand_alerteracknowledge( TTrain *Train, command_data const &Command ); + static void OnCommand_cabsignalacknowledge( TTrain *Train, command_data const &Command ); static void OnCommand_batterytoggle( TTrain *Train, command_data const &Command ); static void OnCommand_batteryenable( TTrain *Train, command_data const &Command ); static void OnCommand_batterydisable( TTrain *Train, command_data const &Command ); diff --git a/command.cpp b/command.cpp index 8611d378..4e9e3018 100644 --- a/command.cpp +++ b/command.cpp @@ -116,6 +116,7 @@ commanddescription_sequence Commands_descriptions = { { "brakeloadcompensationdecrease", command_target::vehicle, command_mode::oneoff }, { "mubrakingindicatortoggle", command_target::vehicle, command_mode::oneoff }, { "alerteracknowledge", command_target::vehicle, command_mode::oneoff }, + { "cabsignalacknowledge", command_target::vehicle, command_mode::oneoff }, { "hornlowactivate", command_target::vehicle, command_mode::oneoff }, { "hornhighactivate", command_target::vehicle, command_mode::oneoff }, { "whistleactivate", command_target::vehicle, command_mode::oneoff }, diff --git a/command.h b/command.h index 5978764d..377e534e 100644 --- a/command.h +++ b/command.h @@ -110,6 +110,7 @@ enum class user_command { brakeloadcompensationdecrease, mubrakingindicatortoggle, alerteracknowledge, + cabsignalacknowledge, hornlowactivate, hornhighactivate, whistleactivate,