Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Changelog.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
[Changelog v0.15.0]
[!WARNING]
SID evaluation slightly changed due to the bug fixing of restrictions overruling pilot filed SIDs. If you encounter odd or unexpected evaluation results please feel free to report back.
>[!WARNING]
>SID evaluation slightly changed due to the bug fixing of restrictions overruling pilot filed SIDs. If you encounter odd or unexpected evaluation results please feel free to report back.

:new: **New Features**
* GEN - add crash handling
* a .txt file is generated with a small stacktrace showing the line or offset, depending if the pdb file was present at the time of the crash
* a .dmp file is generated (default is a minidump - a fulldump can be generated by adding a file "create_fulldump" without file ending next to the dll)
* the pdb file is generated during the build process
* GEN - new logger added
* logs are now stored in a "logs" folder next to the dll
* logs are rotated on ES start or when reaching 10 MB per file (maximum 5 logs are stored)
* new command ".vsid log dev" to enable logging of development messages (disabled by default)
* new main config setting "logDevOnly" as boolean value
* FPLN - add "handover" flag for airports where the TWR controller sends pilots over to radar
* flag is shown immediately after takeoff / airborne
* airport config values:
Expand Down
13 changes: 6 additions & 7 deletions area.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
#include "area.h"
#include "messageHandler.h"
#include "utils.h"
#include "logger.h"

#include <algorithm>
#include <stdexcept>
#include <format>

vsid::Area::Area(std::vector<std::pair<std::string, std::string>> &coords, bool isActive, bool arrAsDep)
{
for (std::pair<std::string, std::string>& coord : coords)
{
if(coord.first.empty() || coord.second.empty())
{
messageHandler->writeMessage("WARNING", "Empty coordinate string found (first: \"" + coord.first +
"\" / second: \"" + coord.second + "\"! Skipping coordinate.");
vsid::Logger::log(vsid::LogLevel::Warning, std::format("Empty coordinate string found (first: [{}] / second: [{}]! Skipping coordinate.",
coord.first, coord.second));
continue;
}
this->points.push_back(toPoint(coord));
Expand Down Expand Up @@ -43,16 +45,13 @@ void vsid::Area::showline()
{
for (auto& line : this->lines)
{
messageHandler->writeMessage("DEBUG", "line: " + std::to_string(line.first.lon) + ":" + std::to_string(line.first.lat) + " - " +
std::to_string(line.second.lon) + "." + std::to_string(line.second.lat));
vsid::Logger::log(vsid::LogLevel::Debug, std::format("area line: {}:{} - {}:{}",
line.first.lon, line.first.lat, line.second.lon, line.second.lat), vsid::DebugLevel::Area);
}
}

vsid::Area::Point vsid::Area::toPoint(std::pair<std::string, std::string> &pos)
{
/*double lat = toDeg(pos.first);
double lon = toDeg(pos.second);*/

double lat = vsid::utils::toDeg(pos.first);
double lon = vsid::utils::toDeg(pos.second);

Expand Down
135 changes: 72 additions & 63 deletions configparser.cpp

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions configparser.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ namespace vsid
bool preferTopsky;
int notifyUpdate;
int hovWarningAlt;
bool logDevOnly;

private:
std::set<std::filesystem::path> configPaths;
Expand Down
4 changes: 4 additions & 0 deletions crashhandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <fstream>
#include <string>

#include "logger.h"

#include "include/es/EuroScopePlugIn.h"

// expose plug-in entry point for crash handler to identify vsid module
Expand Down Expand Up @@ -46,6 +48,8 @@ namespace vsid
//************************************
inline LONG WINAPI vSIDCrashHandler(EXCEPTION_POINTERS* exceptionInfo)
{
vsid::Logger::panicFlush(); // flush logs to file in case of crash

PVOID crashAdress = exceptionInfo->ExceptionRecord->ExceptionAddress;

// get the crashed module
Expand Down
72 changes: 33 additions & 39 deletions display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@
#include "constants.h"
#include "messageHandler.h"
#include "utils.h"
#include "logger.h"

#include <utility>
#include <format>

vsid::Display::Display(int id, std::shared_ptr<vsid::VSIDPlugin> plugin, const std::string name) : EuroScopePlugIn::CRadarScreen()
{
this->id = id;
this->plugin = plugin;
this->name = name;
}
vsid::Display::~Display() { messageHandler->writeMessage("DEBUG", "Removed display with id: " + std::to_string(this->id), vsid::MessageHandler::DebugArea::Menu); }
vsid::Display::~Display() {
vsid::Logger::log(vsid::LogLevel::Debug, std::format("Removed display with id: {}", this->id), vsid::DebugLevel::Menu);
}

void vsid::Display::OnAsrContentLoaded(bool loaded)
{
Expand All @@ -28,11 +32,11 @@ void vsid::Display::OnAsrContentToBeClosed()

if (std::shared_ptr sharedPlugin = this->plugin.lock())
{
messageHandler->writeMessage("DEBUG", "Removing display with id: " + std::to_string(this->id) + " from saved displays.", vsid::MessageHandler::DebugArea::Menu);
vsid::Logger::log(vsid::LogLevel::Debug, std::format("Removing display with id [{}] from saved displays.", this->id), vsid::DebugLevel::Menu);
sharedPlugin->deleteScreen(this->id);
}
else messageHandler->writeMessage("ERROR", "Could not remove display id: " + std::to_string(this->id) +
" from vSID as vSID is already destroyed. Code: " + ERROR_DSP_REMOVE);
else vsid::Logger::log(vsid::LogLevel::Error, std::format("Could not remove display id [{}] from vSID as vSID is already destroyed. Code: {}",
this->id, ERROR_DSP_REMOVE));

//delete this;
}
Expand Down Expand Up @@ -78,8 +82,8 @@ void vsid::Display::OnRefresh(HDC hDC, int Phase)
{
if (!messageHandler->genErrorsContains(ERROR_CONF_DISPLAY))
{
messageHandler->writeMessage("ERROR", "[Range] Missing config section during display refresh: " +
std::string(e.what()) + ". Code: " + ERROR_CONF_DISPLAY);
vsid::Logger::log(vsid::LogLevel::Error, std::format("[Range] Missing config section during display refresh: {}. Code: {}",
std::string(e.what()), ERROR_CONF_DISPLAY));
messageHandler->addGenError(ERROR_CONF_DISPLAY);
}
}
Expand Down Expand Up @@ -359,8 +363,9 @@ void vsid::Display::OnRefresh(HDC hDC, int Phase)
{
if (!messageHandler->genErrorsContains(ERROR_DSP_COUNTICAO + mMenu.getTitle()))
{
messageHandler->writeMessage("ERROR", "Failed to get ICAO from menu title " +
mMenu.getTitle() + " while counting startups. Code: " + ERROR_DSP_COUNTICAO);
vsid::Logger::log(vsid::LogLevel::Error, std::format("Failed to get ICAO from menu title [{}] while counting startups. Code: {}",
mMenu.getTitle(), ERROR_DSP_COUNTICAO));

messageHandler->addGenError(ERROR_DSP_COUNTICAO + mMenu.getTitle());
}
}
Expand Down Expand Up @@ -396,8 +401,9 @@ void vsid::Display::OnRefresh(HDC hDC, int Phase)
{
if (!messageHandler->genErrorsContains(ERROR_DSP_COUNTRMICAO + mMenu.getTitle()))
{
messageHandler->writeMessage("ERROR", "Failed to retrieve icao from menu " + mMenu.getTitle() +
" during departure count check. Code: " + ERROR_DSP_COUNTRMICAO);
vsid::Logger::log(vsid::LogLevel::Error, std::format("Failed to retrieve icao from menu [{}] during departure count check. Code: {}",
mMenu.getTitle(), ERROR_DSP_COUNTRMICAO));

messageHandler->addGenError(ERROR_DSP_COUNTRMICAO + mMenu.getTitle());
}
}
Expand Down Expand Up @@ -511,10 +517,10 @@ void vsid::Display::OnClickScreenObject(int ObjectType, const char* sObjectId, P
}
else
{
messageHandler->writeMessage("DEBUG", "menus doesn't contain " + std::string(sObjectId) + " elems are:", vsid::MessageHandler::DebugArea::Menu);
vsid::Logger::log(vsid::LogLevel::Debug, std::format("Menus doesn't contain [{}]. Elements are:", std::string(sObjectId)));
for (auto &[title, _] : this->menues)
{
messageHandler->writeMessage("DEBUG", "menu title: " + title, vsid::MessageHandler::DebugArea::Menu);
vsid::Logger::log(vsid::LogLevel::Debug, std::format("menu title [{}]", title), vsid::DebugLevel::Menu);
}
}

Expand Down Expand Up @@ -543,8 +549,8 @@ void vsid::Display::OnClickScreenObject(int ObjectType, const char* sObjectId, P
}
else
{
messageHandler->writeMessage("ERROR", "Couldn't close menu, because menu title couldn't be extracted from button " +
std::string(sObjectId) + ". Code: " + ERROR_DSP_BTNEXTTITLE);
vsid::Logger::log(vsid::LogLevel::Error, std::format("Couldn't close menu, because menu title couldn't be extracted from button [{}]. Code: {}",
std::string(sObjectId), ERROR_DSP_BTNEXTTITLE));
}
}
}
Expand All @@ -567,7 +573,7 @@ bool vsid::Display::OnCompileCommand(const char* sCommandLine)
{
if (!sharedPlugin->getActiveApts().contains(params[2]))
{
messageHandler->writeMessage("INFO", "[" + params[2] + "] is not an active airport. Cannot open menu.");
vsid::Logger::log(vsid::LogLevel::Info, std::format("[{}] is not an active airport. Cannot open menu.", params[2]));
return true;
}

Expand All @@ -581,21 +587,21 @@ bool vsid::Display::OnCompileCommand(const char* sCommandLine)

if (std::string(sCommandLine) == ".vsid display config")
{
messageHandler->writeMessage("INFO", "Zoom-Level: " + std::to_string(this->getZoomLevel()));
vsid::Logger::log(vsid::LogLevel::Info, std::format("Zoom-Level [{}]", this->getZoomLevel()));
return true;
}
return false;
}

void vsid::Display::OnAirportRunwayActivityChanged()
{
messageHandler->writeMessage("DEBUG", "[MENU] Activity Changed()", vsid::MessageHandler::DebugArea::Menu);
vsid::Logger::log(vsid::LogLevel::Debug, "[MENU] Runway Activity Changed()", vsid::DebugLevel::Menu);

if (this->menues.empty()) return;

if (std::shared_ptr sharedPlugin = this->plugin.lock())
{
messageHandler->writeMessage("DEBUG", "[MENU] Shared Ptr valid.", vsid::MessageHandler::DebugArea::Menu);
vsid::Logger::log(vsid::LogLevel::Debug, "[MENU] Shared Ptr valid.", vsid::DebugLevel::Menu, true);

// re-create mainmenu

Expand All @@ -605,7 +611,7 @@ void vsid::Display::OnAirportRunwayActivityChanged()

for (const auto&[title,menu] : this->menues)
{
messageHandler->writeMessage("DEBUG", "[" + title + "] is checked on runway change", vsid::MessageHandler::DebugArea::Menu);
vsid::Logger::log(vsid::LogLevel::Debug, std::format("[{}] is checked on runway change", title), vsid::DebugLevel::Menu);
if (title == std::string("mainmenu"))
{
CPoint topLeft = this->menues["mainmenu"].topLeft();
Expand All @@ -615,19 +621,11 @@ void vsid::Display::OnAirportRunwayActivityChanged()
}
else if (title.find("startupmenu_") != std::string::npos)
{
messageHandler->writeMessage("DEBUG", "[" + title + "] storing startup menu", vsid::MessageHandler::DebugArea::Menu);
vsid::Logger::log(vsid::LogLevel::Debug, std::format("[{}] storing startup menu", title), vsid::DebugLevel::Menu);
this->reopenStartup.insert({title, { menu.topLeft(), menu.getParent(), menu.getRender() }});
}
}

/*if (this->menues.contains("mainmenu"))
{
CPoint topLeft = this->menues["mainmenu"].topLeft();
top = topLeft.y;
left = topLeft.x;
render = this->menues["mainmenu"].getRender();
}*/

this->removeMenu("mainmenu");

this->openMainMenu(top, left, render);
Expand All @@ -638,7 +636,7 @@ void vsid::Display::OnAirportRunwayActivityChanged()
{
try
{
messageHandler->writeMessage("DEBUG", "[" + title + "] reopening startup menu", vsid::MessageHandler::DebugArea::Menu);
vsid::Logger::log(vsid::LogLevel::Debug, std::format("[{}] reopening startup menu", title), vsid::DebugLevel::Menu);
std::string apt = vsid::utils::split(title, '_').at(1);

if (!sharedPlugin->getActiveApts().contains(apt)) continue;
Expand All @@ -647,16 +645,15 @@ void vsid::Display::OnAirportRunwayActivityChanged()
}
catch (std::out_of_range)
{
messageHandler->writeMessage("ERROR", "Failed to get apt ICAO while re-opening startup menu \"" + title +
"\". Code: " + ERROR_DSP_REOPENICAO);
vsid::Logger::log(vsid::LogLevel::Error, std::format("Failed to get apt ICAO while re-opening startup menu [{}]. Code: {}", title, ERROR_DSP_REOPENICAO));
}

}

this->reopenStartup.clear();
}
}
else messageHandler->writeMessage("ERROR", "Couldn't update active airports for screen as plugin couldn't be accessed. Code: " + ERROR_DSP_PLUGACCESS);
else vsid::Logger::log(vsid::LogLevel::Error, "Couldn't update active airports for screen as plugin couldn't be accessed. Code: {}" + ERROR_DSP_PLUGACCESS, vsid::DebugLevel::Menu);
}

void vsid::Display::openMainMenu(int top, int left, bool render)
Expand Down Expand Up @@ -690,7 +687,7 @@ void vsid::Display::openMainMenu(int top, int left, bool render)

for (auto& [title, apt] : this->plugin.lock()->getActiveApts())
{
messageHandler->writeMessage("DEBUG", "Button add for apt: " + title);
vsid::Logger::log(vsid::LogLevel::Debug, std::format("Add airport button for [{}]", title), vsid::DebugLevel::Menu, true);
newMenu.addButton(MENU_BUTTON, "apt_" + title, newMenu.getArea(), title, 20, 20, 400, { 5, 5, 5, 5 });
}

Expand Down Expand Up @@ -738,8 +735,7 @@ void vsid::Display::openStartupMenu(const std::string apt, const std::string par

this->menues.insert({ title, std::move(newMenu) });
}
else messageHandler->writeMessage("ERROR", "Tried to create startup menu for [" + apt +
"] but plugin couldn't be accessed. Code: " + ERROR_DSP_MENUSUCREATE);
vsid::Logger::log(vsid::LogLevel::Error, std::format("Tried to create startup menu for [{}] but plugin couldn't be accessed. Code: {}", apt, ERROR_DSP_MENUSUCREATE));
}

void vsid::Display::removeMenu(const std::string &title)
Expand All @@ -752,15 +748,13 @@ void vsid::Display::removeMenu(const std::string &title)
}
this->menues.erase(title);
}
else messageHandler->writeMessage("ERROR", "Called to remove menu [" + title +
"] but it wasn't found in the menues list. Code: " + ERROR_DSP_RMMENU);
vsid::Logger::log(vsid::LogLevel::Error, std::format("Called to remove menu [{}] but it wasn't found in the menues list. Code: {}", title, ERROR_DSP_RMMENU));
}

void vsid::Display::closeMenu(const std::string &title)
{
if (this->menues.contains(title)) this->menues[title].toggleRender();
else messageHandler->writeMessage("ERROR", "Couldn't close menu " + title +
" because it is not in the menu list. Code: " + ERROR_DSP_RMMENU);
vsid::Logger::log(vsid::LogLevel::Error, std::format("Couldn't close menu [{}] because it is not in the menu list. Code: {}", title, ERROR_DSP_RMMENU));
}

EuroScopePlugIn::CPosition vsid::Display::calculateIndicatorMeterOffset(double lat, double lon, double offset, double deg)
Expand Down
Loading
Loading