Skip to content

Commit

Permalink
Better ack handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cesarBLG committed Sep 17, 2023
1 parent d8aa6f4 commit da881c1
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 20 deletions.
2 changes: 2 additions & 0 deletions DMI/window/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ void menu::setLayout()
{
if (labels[i] != nullptr) addToLayout(labels[i], new RelativeAlignment(nullptr, 334, 100+24*i, 0));
}
extern Component ackButton;
addToLayout(&ackButton, new RelativeAlignment(nullptr, 600, 348, 0));
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion DMI/window/window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#include "platform_runtime.h"
bool isInside(Component *comp, float x, float y)
{
if (componentAck != nullptr && comp != componentAck && comp != &ackButton) return false;
//if (componentAck != nullptr && comp != componentAck && comp != &ackButton) return false;
return (comp->x-comp->touch_left)<x && (comp->x + comp->sx + comp->touch_right)>x
&& (comp->y-comp->touch_up)<y && (comp->y + comp->sy+comp->touch_down)>y;
}
Expand Down
13 changes: 5 additions & 8 deletions EVC/DMI/acks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,12 @@ void update_acks()
}
if (ack_required && active_dialog != dialog_sequence::StartUp) {
if (active_dialog != dialog_sequence::None) {
if (active_dialog == dialog_sequence::NTCData) {
for (auto &kvp : installed_stms) {
auto *stm = kvp.second;
if (stm->data_entry == stm_object::data_entry_state::Driver)
stm->data_entry = stm_object::data_entry_state::Active;
}
std::string active = active_window_dmi["active"];
if (active != "menu_main" && active != "menu_override" && active != "menu_spec" &&
active != "menu_settings" && active != "menu_radio" && active != "menu_ntc") {
close_window();
last_ack_time = get_milliseconds();
}
active_dialog = dialog_sequence::None;
last_ack_time = get_milliseconds();
}
if (get_milliseconds() > last_ack_time + 1000)
ack_allowed = true;
Expand Down
1 change: 1 addition & 0 deletions EVC/DMI/acks.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
*/
#pragma once
extern bool ack_allowed;
extern bool ack_required;
void update_acks();
23 changes: 13 additions & 10 deletions EVC/DMI/windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,6 +783,11 @@ void update_dmi_windows()
}
enabled_buttons["EndDataEntry"] = active_dialog_step != "S1" && active_dialog_step != "S4";
}
if (ack_required) {
for (auto &kvp : enabled_buttons) {
kvp.second = false;
}
}
std::string active = active_window_dmi["active"];
if (active == "menu_main" && !active_window_dmi.contains("hour_glass")) {
json &enabled = active_window_dmi["enabled"];
Expand Down Expand Up @@ -826,45 +831,43 @@ void update_dmi_windows()
}
if (active_dialog != dialog_sequence::None && active_dialog != dialog_sequence::StartUp && (!som_active || som_status != S1)) {
extern bool traindata_applied;
bool close = false;
if ((active == "trn_window" && !enabled_buttons["Train Running Number"])
|| (active == "driver_window" && !enabled_buttons["Driver ID"])
|| (active == "level_window" && !enabled_buttons["Level"])
|| ((active == "train_data_validation_window" || active == "train_data_window" || active == "fixed_train_data_validation_window" || active == "fixed_train_data_window") && !enabled_buttons["Train Data"])) {
active_dialog_step = "S1";
close = true;
if ((active == "fixed_train_data_window" || active == "fixed_train_data_validation_window" || active == "train_data_window" || active == "train_data_validation_window") && V_est != 0) {
traindata_applied = true;
trigger_brake_reason(1);
}
}
if ((active == "rbc_data_window" && !enabled_buttons["Enter RBC data"])
|| (active == "radio_network_window" && !enabled_buttons["Radio Network ID"]) ) {
active_dialog_step = "S5-1";
close = true;
}
if ((active == "language_window" && !enabled_buttons["Language"])
|| (active == "volume_window" && !enabled_buttons["Volume"])
|| (active == "brightness_window" && !enabled_buttons["Brightness"]) ) {
active_dialog_step = "S1";
close = true;
}
if ((active == "adhesion_window" && !enabled_buttons["Adhesion"])
|| (active == "sr_data_window" && !enabled_buttons["SRspeed"]) ) {
active_dialog_step = "S1";
close = true;
if (active == "sr_data_window" && V_est != 0) {
traindata_applied = true;
trigger_brake_reason(1);
}
}
if ((active == "ntc_data_window" || active == "ntc_data_validation_window") && !enabled_buttons[active_window_dmi["ntc"]]) {
for (auto &kvp : installed_stms) {
auto *stm = kvp.second;
if (stm->data_entry == stm_object::data_entry_state::Driver)
stm->data_entry = stm_object::data_entry_state::Active;
}
active_dialog_step = "S2";
close = true;
if (V_est != 0) {
traindata_applied = true;
trigger_brake_reason(1);
}
}
if (close)
close_window();
}
}
void close_window()
Expand Down
3 changes: 2 additions & 1 deletion EVC/TrainSubsystems/brake.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,8 @@ void handle_brake_command()
}
}
}
if ((prevEB || prevSB) && !EB_command && !SB_command) send_command("playSinfo","");
extern bool any_button_pressed;
if ((prevEB || prevSB) && !EB_command && !SB_command && !any_button_pressed) send_command("playSinfo","");
prevEB = EB_command;
prevSB = SB_command;
}

0 comments on commit da881c1

Please sign in to comment.