Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit bcc95da
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Mon Oct 9 09:16:18 2023 +0200

    Do not terminate session if phone number changes

commit 82f9a05
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Thu Oct 5 16:31:49 2023 +0200

    Fix LX in rear bug

commit 7079c33
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Mon Oct 2 21:44:25 2023 +0200

    Baseline 3 and 4 variables

commit 343cf18
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Mon Oct 2 21:43:39 2023 +0200

    Fix confidence interval for odometer distances. Second try

commit f6b2a5a
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Sun Oct 1 23:10:29 2023 +0200

    Fix confidence interval calculation

commit 77118a8
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Sun Oct 1 21:38:59 2023 +0200

    Fix menu items

commit 548e102
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Sun Oct 1 21:09:46 2023 +0200

    Fix shift not included

commit 761c4a0
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Fri Sep 29 09:50:22 2023 +0200

    Debug messages

commit de49376
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Sun Sep 24 22:14:53 2023 +0200

    Fix distance bugs

commit 74b3837
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Sun Sep 24 20:45:44 2023 +0200

    Update odometer relocation for baseline 4

commit 8c4f51a
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Tue Sep 19 19:10:12 2023 +0200

    Initial Baseline 4 implementation for DMI

commit bdb2961
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Fri Sep 22 08:14:14 2023 +0200

    Ack with menu active

commit d0a42f3
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Tue Sep 19 16:39:25 2023 +0200

    Speed/distance toggle

commit 6ea8e3a
Merge: 02d8e3d 69a91be
Author: Bartłomiej Skwara <bartek@skwara.me>
Date:   Tue Sep 19 07:16:47 2023 +0200

    Merge branch 'cesarBLG:master' into master

commit 69a91be
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Mon Sep 18 21:14:07 2023 +0200

    Do not establish session to report mode change to SB

commit 02d8e3d
Author: Bartłomiej Skwara <bartek@skwara.me>
Date:   Mon Sep 18 16:57:05 2023 +0200

    Lets try this way....

commit a6f98cf
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Mon Sep 18 15:14:41 2023 +0200

    Fix missing cast

commit df337b1
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Mon Sep 18 14:48:00 2023 +0200

    Fix session terminating ordered by trackside

commit f6a2b6e
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Mon Sep 18 11:32:25 2023 +0200

    Refactor DMI windows

commit e451947
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Mon Sep 18 09:20:03 2023 +0200

    Further ack fix

commit b258b53
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Sun Sep 17 22:22:58 2023 +0200

    Fill RBC ID

commit da881c1
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Sun Sep 17 11:38:53 2023 +0200

    Better ack handling

commit d8aa6f4
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Sat Sep 16 08:52:43 2023 +0200

    Fixes STM

commit 152dd71
Merge: 5ff951a 27faf1c
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Fri Sep 15 13:41:36 2023 +0200

    Merge branch 'master' of github.com:cesarBLG/ETCS

commit 5ff951a
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Fri Sep 15 13:41:22 2023 +0200

    Data entry abortion

commit 27faf1c
Merge: 756e67d ab54bbb
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Fri Sep 15 13:40:22 2023 +0200

    Merge pull request #17 from cesarBLG/Alberto

    Update Traindata & Spanish language

commit ecf5cbf
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Thu Sep 14 21:24:02 2023 +0200

    Fix moved ETCS areas STM

commit 756e67d
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Thu Sep 14 13:01:22 2023 +0200

    Fix STM window construction

commit e2e8c8c
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Thu Sep 14 12:09:49 2023 +0200

    Ack button light

commit c7a8a7d
Author: César Benito Lamata <cesarbema2009@hotmail.com>
Date:   Wed Sep 13 21:09:41 2023 +0200

    Remove text messages after EVC disconnection
  • Loading branch information
albertosaurio65 committed Oct 9, 2023
1 parent 820823c commit 721e425
Show file tree
Hide file tree
Showing 96 changed files with 2,693 additions and 1,420 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ endif()
if (WIN32)
add_definitions(-D_WIN32_WINNT=0x602)
endif()
add_definitions(-DBASELINE=3)
add_subdirectory(EVC)
add_subdirectory(DMI)
107 changes: 61 additions & 46 deletions DMI/STM/stm_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../monitor.h"
#include "../graphics/display.h"
#include "../graphics/text_button.h"
#include "../graphics/icon_button.h"
#include "../messages/messages.h"
#include "../time_etcs.h"
#include "../../EVC/Packets/STM/15.h"
Expand Down Expand Up @@ -111,22 +112,36 @@ void ntc_window::display_indicator(int id, int position, int icon, std::string t
else
{
std::string area;
if (position < 4)
area = "B"+std::to_string(position+2);
else if (position == 4)
area = "H1";
else if (position < 10)
area = "C"+std::to_string(position-3);
else if (position < 20)
area = "G"+std::to_string(position-9);
/*{
if (position < 3)
area = "F"+std::to_string(position+7);
else if (position < 8)
area = "C"+std::to_string(position-1);
else if (position < 18)
area = "G"+std::to_string(position-7);
}*/
if (isButton)
{
if (softkeys)
{
if (position < 4)
area = "F"+std::to_string(position+7);
else if (position < 7)
area = "H"+std::to_string(position-2);
}
else
{
if (position < 3)
area = "F"+std::to_string(position+7);
else if (position < 8)
area = "C"+std::to_string(position-1);
else if (position < 18)
area = "G"+std::to_string(position-7);
}
}
else
{
if (position < 4)
area = "B"+std::to_string(position+2);
else if (position == 4)
area = "H1";
else if (position < 10)
area = "C"+std::to_string(position-3);
else if (position < 20)
area = "G"+std::to_string(position-9);
}
if (areas.find(area) == areas.end())
return;
pos = areas[area];
Expand Down Expand Up @@ -190,12 +205,8 @@ void ntc_window::display_text(int id, bool ack, std::string text, int properties
void initialize_stm_windows()
{
setup_areas();

/*std::string val = "00101011""0000001100100""01""0100000000""0010000""0000000000""0100000010""000001000000000"
"000""010""11""011""10""000""00""101""00""11";
parse_stm_message(val);*/
}
void parse_stm_message(const stm_message &message)
void parse_stm_message(stm_message &message)
{
if (!message.valid) return;
int nid_stm = message.NID_STM.rawdata;
Expand Down Expand Up @@ -256,10 +267,6 @@ void parse_stm_message(const stm_message &message)
}
window->display_indicator(button.NID_BUTTON, button.NID_BUTPOS, button.NID_ICON, text, button.M_BUT_ATTRIB, true);
}
/*for (auto &var : r.log_entries)
{
std::cout<<var.first<<"\t"<<var.second<<"\n";
}*/
}
else if (pack->NID_PACKET == 35)
{
Expand All @@ -282,10 +289,6 @@ void parse_stm_message(const stm_message &message)
}
window->display_indicator(icon.NID_INDICATOR, icon.NID_INDPOS, icon.NID_ICON, text, icon.M_IND_ATTRIB, false);
}
/*for (auto &var : r.log_entries)
{
std::cout<<var.first<<"\t"<<var.second<<"\n";
}*/
}
else if (pack->NID_PACKET == 38)
{
Expand Down Expand Up @@ -382,12 +385,18 @@ void update_stm_windows()
prev_default_window = nullptr;
active_ntc_window = nullptr;
}
active_windows.erase(it->second);
for (auto it2 = active_windows.begin(); it2 != active_windows.end();)
{
if (*it2 == it->second)
it2 = active_windows.erase(it2);
else
++it2;
}
delete it->second;
it = ntc_windows.erase(it);
continue;
}
if (it->second->state == stm_state::DA)
if (it->second->state == stm_state::DA && (active_ntc_window == nullptr || it->second == prev_default_window))
default_window = active_ntc_window = it->second;
++it;
}
Expand All @@ -396,8 +405,13 @@ void update_stm_windows()
{
if (prev_default_window != nullptr)
{
prev_default_window->active = false;
active_windows.erase(prev_default_window);
for (auto it = active_windows.begin(); it != active_windows.end();)
{
if (*it == prev_default_window)
it = active_windows.erase(it);
else
++it;
}
if (prev_default_window != &etcs_default_window)
{
auto *ntc = (ntc_window*)prev_default_window;
Expand All @@ -407,36 +421,38 @@ void update_stm_windows()
}
}
}
default_window->construct();
default_window->updateLayout();
if (active_ntc_window != nullptr && active_ntc_window->customized != nullptr)
{
//extern TextButton main_button;
//extern TextButton override_button;
//extern TextButton dataview_button;
//extern TextButton special_button;
//extern TextButton settings_button;
extern TextButton main_button;
extern TextButton override_button;
extern TextButton dataview_button;
extern TextButton special_button;
extern IconButton config_button;
extern Component a4;
extern Component modeRegion;
extern Component levelRegion;
extern Component c1;
extern Component c7;
extern Component c9;
extern Component e1;
extern Component time_hour;
for (auto &kvp : active_ntc_window->customized->moved_areas)
{
Component *moved = nullptr;
if (kvp.first == "A4") moved = &a4;
//else if (kvp.first == "F1") moved = &main_button;
//else if (kvp.first == "F2") moved = &override_button;
//else if (kvp.first == "F3") moved = &dataview_button;
//else if (kvp.first == "F4") moved = &special_button;
//else if (kvp.first == "F5") moved = &settings_button;
else if (kvp.first == "F1") moved = &main_button;
else if (kvp.first == "F2") moved = &override_button;
else if (kvp.first == "F3") moved = &dataview_button;
else if (kvp.first == "F4") moved = &special_button;
else if (kvp.first == "F5") moved = &config_button;
else if (kvp.first == "B7") moved = &modeRegion;
else if (kvp.first == "C8") moved = &levelRegion;
else if (kvp.first == "C1") moved = &c1;
else if (kvp.first == "C7") moved = &c7;
else if (kvp.first == "C9") moved = &c9;
else if (kvp.first == "E1") moved = &e1;
else if (kvp.first == "G13") moved = &time_hour;
if (moved != nullptr)
{
active_ntc_window->remove(moved);
Expand All @@ -461,8 +477,7 @@ void update_stm_windows()
maxSpeed = active_ntc_window->customized->etcs_dial_range;
else
maxSpeed = etcsDialMaxSpeed;
default_window->active = true;
active_windows.insert(default_window);
active_windows.push_front(default_window);
if (active_ntc_window != nullptr)
{
for (auto &kvp : active_ntc_window->messages)
Expand Down
15 changes: 11 additions & 4 deletions DMI/STM/stm_objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "../graphics/color.h"
#include "../graphics/button.h"
#include "../graphics/component.h"
#include "../graphics/drawing.h"
#include "../messages/messages.h"
#include "../window/window.h"
#include "../../EVC/Packets/STM/43.h"
Expand Down Expand Up @@ -87,6 +88,7 @@ struct customized_dmi
int flash_style;
std::map<int, std::unique_ptr<StmSound>> sounds;
std::map<std::string,moved_area> moved_areas;
std::map<std::string, std::pair<int,int>> softkeys_coordinates;
customized_dmi(json &j)
{
nid_stm = j["nid_stm"].get<int>();
Expand All @@ -98,13 +100,16 @@ struct customized_dmi
{
buttons[inds["id"].get<int>()] = indicator(inds);
}
for (auto &pos : j["positions"])
for (auto &pos : j[softkeys ? "positions_softkeys" : "positions"])
{
positions[pos["id"].get<int>()] = {pos["x"].get<int>(),pos["y"].get<int>(),pos["width"].get<int>(),pos["height"].get<int>()};
}
for (auto &pos : j["button_positions"])
for (auto &pos : j[softkeys ? "button_positions_softkeys" : "button_positions"])
{
button_positions[pos["id"].get<int>()] = {pos["x"].get<int>(),pos["y"].get<int>(),pos["width"].get<int>(),pos["height"].get<int>()};
std::vector<int> coords = {pos["x"].get<int>(),pos["y"].get<int>(),pos["width"].get<int>(),pos["height"].get<int>()};
button_positions[pos["id"].get<int>()] = coords;
if (pos.contains("softkey"))
softkeys_coordinates[pos["softkey"]] = {coords[0]+1,coords[1]+1};
}
for (auto &ics : j["icons"])
{
Expand All @@ -130,6 +135,8 @@ struct customized_dmi
a.x = area["x"];
a.y = area["y"];
moved_areas[area["area"]] = a;
if (area.contains("softkey"))
softkeys_coordinates[area["softkey"]] = {a.x + 1, a.y + 1};
}
}
}
Expand Down Expand Up @@ -189,4 +196,4 @@ class ntc_window : public window
extern ntc_window *active_ntc_window;
void initialize_ntc_windows();
void update_ntc_windows();
void parse_stm_message(const stm_message &message);
void parse_stm_message(stm_message &message);
39 changes: 21 additions & 18 deletions DMI/control/control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../graphics/display.h"
#include "../graphics/drawing.h"
#include "../monitor.h"
#include "../planning/planning.h"
#include "../window/window.h"
#include "../window/data_view.h"
#include "../window/train_data.h"
Expand Down Expand Up @@ -39,18 +40,11 @@ void startWindows()

active_windows.clear();
etcs_default_window.construct();
navigation_bar.construct();
planning_area.construct();
taf_window.construct();
default_window = &etcs_default_window;
extern int maxSpeed;
extern int etcsDialMaxSpeed;
maxSpeed = etcsDialMaxSpeed;
active_windows.insert(default_window);
active_windows.insert(&navigation_bar);
active_windows.insert(&planning_area);
active_windows.insert(&taf_window);
taf_window.active = false;
active_windows.push_front(default_window);
active_name = "default";
}
void setWindow(json &data)
Expand All @@ -66,12 +60,14 @@ void setWindow(json &data)
json j = data["ActiveWindow"];
subwindow *w = nullptr;
std::string name = j["active"].get<std::string>();
if (name == "default") {
if (name == "default")
{
extern bool showSpeeds;
navigation_bar.active = default_window->active = true;
planning_area.active = !display_taf && (mode == Mode::FS || (mode == Mode::OS && showSpeeds));
taf_window.active = display_taf;
} else {
setPlanning(!display_taf && (mode == Mode::FS || (mode == Mode::OS && showSpeeds)));
setTAF(display_taf);
}
else
{
bool same = name == active_name;
if (name == "menu_main") {
menu_main *m;
Expand Down Expand Up @@ -199,17 +195,24 @@ void setWindow(json &data)
{
w->exit_button.enabled = !j.contains("enabled") || !j["enabled"].contains("Exit") || j["enabled"]["Exit"].get<bool>();
}
navigation_bar.active = planning_area.active = false;
default_window->active = w == nullptr || !w->fullscreen;
setPlanning(false);
setTAF(false);
}
active_name = name;
if (active != w) {
if (active != nullptr) {
old_windows.insert(active);
active_windows.erase(active);
for (auto it = active_windows.begin(); it != active_windows.end(); )
{
if (*it == active)
{
delete *it;
it = active_windows.erase(it);
}
else ++it;
}
}
active = w;
if (active != nullptr)
active_windows.insert(w);
active_windows.push_back(w);
}
}
2 changes: 1 addition & 1 deletion DMI/graphics/component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void Component::drawLine(float x1, float y1, float x2, float y2, Color c)
}
void Component::paint()
{
bool show = true;;
bool show = true;
if (flash_style != 0)
{
bool fast = flash_style & 1;
Expand Down
1 change: 1 addition & 0 deletions DMI/graphics/component.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class Component
float y;
float sx;
float sy;
bool visible = true;

protected:
inline float getX(float val)
Expand Down
15 changes: 5 additions & 10 deletions DMI/graphics/display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,18 @@
#include "../monitor.h"
#include "../control/control.h"
#include "../state/acks.h"
using namespace std;
unordered_set<window*> active_windows;
unordered_set<window*> old_windows;
std::list<window*> active_windows;
extern Mode mode;
extern uint32_t evc_peer;
void displayETCS()
{
updateAcks();
if (!evc_peer) return;
for(auto it=active_windows.begin(); it!=active_windows.end(); ++it)
std::vector<std::vector<int>> alreadyDrawn;
for(auto it=active_windows.rbegin(); it!=active_windows.rend(); ++it)
{
window *w = *it;
if(w->active) w->display();
w->display(alreadyDrawn);
alreadyDrawn.insert(alreadyDrawn.end(), w->bounds.begin(), w->bounds.end());
}
for(auto it=old_windows.begin(); it!=old_windows.end(); ++it)
{
delete *it;
}
old_windows.clear();
}
8 changes: 2 additions & 6 deletions DMI/graphics/display.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,10 @@
*/
#ifndef _DISPLAY_H
#define _DISPLAY_H
#include <unordered_set>
#include <list>
#include "../window/window.h"
extern window etcs_default_window;
extern window* default_window;
extern window navigation_bar;
//extern window menu_main;
extern window planning_area;;
extern std::unordered_set<window*> active_windows;
extern std::unordered_set<window*> old_windows;
extern std::list<window*> active_windows;
void displayETCS();
#endif
Loading

0 comments on commit 721e425

Please sign in to comment.