From c7862e7a0ddeff91c5b9b51ff7aee0eef2870365 Mon Sep 17 00:00:00 2001 From: Leon Kleinschmidt <101114069+LeoKle@users.noreply.github.com> Date: Sat, 20 Apr 2024 14:38:13 +0200 Subject: [PATCH] v1.3.2 (#45) * fix access violation error in DataManager * extract compile commands from vACDM.cpp * fully extract TagItems to TagItems.h * fully extract TagFunctions into TagFunctions.h declaring the plugin functions RegisterTagItemTypes, OnCompileCommand, OnFunctionCall and OnGetTagItem as class functions in TagItems.h / TagFunctions.h / CompileCommands.h removes use of pointers and function forwarding in vACDM.cpp * DataManager: amend async Euroscope updates to use Pilot type * bump version to 1.3.2 --- CMakeLists.txt | 2 +- src/core/CompileCommands.h | 96 ++++++++++++++++++++++++++++++++++++++ src/core/DataManager.cpp | 29 ++++++------ src/core/DataManager.h | 2 +- src/core/TagFunctions.h | 87 +++++++++++++++++----------------- src/core/TagItems.h | 40 +++++++++------- src/vACDM.cpp | 91 ++---------------------------------- src/vACDM.h | 3 ++ 8 files changed, 186 insertions(+), 164 deletions(-) create mode 100644 src/core/CompileCommands.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c02c265..fb77e75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.14) -PROJECT(vACDM VERSION "1.3.1") +PROJECT(vACDM VERSION "1.3.2") SET_PROPERTY(GLOBAL PROPERTY USE_FOLDERS ON) SET(CMAKE_CXX_STANDARD 20) SET(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/src/core/CompileCommands.h b/src/core/CompileCommands.h new file mode 100644 index 0000000..83dcda7 --- /dev/null +++ b/src/core/CompileCommands.h @@ -0,0 +1,96 @@ +#include +#include + +#pragma warning(push, 0) +#include "EuroScopePlugIn.h" +#pragma warning(pop) + +#include "core/DataManager.h" +#include "core/Server.h" +#include "log/Logger.h" +#include "utils/Number.h" +#include "utils/String.h" +#include "vACDM.h" + +using namespace vacdm; +using namespace vacdm::logging; +using namespace vacdm::core; +using namespace vacdm::utils; + +namespace vacdm { +bool vACDM::OnCompileCommand(const char *sCommandLine) { + std::string command(sCommandLine); + +#pragma warning(push) +#pragma warning(disable : 4244) + std::transform(command.begin(), command.end(), command.begin(), ::toupper); +#pragma warning(pop) + + // only handle commands containing ".vacdm" + if (0 != command.find(".VACDM")) return false; + + // master command + if (std::string::npos != command.find("MASTER")) { + bool userIsConnected = this->GetConnectionType() != EuroScopePlugIn::CONNECTION_TYPE_NO; + bool userIsInSweatbox = this->GetConnectionType() == EuroScopePlugIn::CONNECTION_TYPE_SWEATBOX; + bool userIsObserver = std::string_view(this->ControllerMyself().GetCallsign()).ends_with("_OBS") == true || + this->ControllerMyself().GetFacility() == 0; + bool serverAllowsObsAsMaster = com::Server::instance().getServerConfig().allowMasterAsObserver; + bool serverAllowsSweatboxAsMaster = com::Server::instance().getServerConfig().allowMasterInSweatbox; + + std::string userIsNotEligibleMessage; + + if (!userIsConnected) { + userIsNotEligibleMessage = "You are not logged in to the VATSIM network"; + } else if (userIsObserver && !serverAllowsObsAsMaster) { + userIsNotEligibleMessage = "You are logged in as Observer and Server does not allow Observers to be Master"; + } else if (userIsInSweatbox && !serverAllowsSweatboxAsMaster) { + userIsNotEligibleMessage = + "You are logged in on a Sweatbox Server and Server does not allow Sweatbox connections"; + } else { + DisplayMessage("Executing vACDM as the MASTER"); + Logger::instance().log(Logger::LogSender::vACDM, "Switched to MASTER", Logger::LogLevel::Info); + com::Server::instance().setMaster(true); + + return true; + } + + DisplayMessage("Cannot upgrade to Master"); + DisplayMessage(userIsNotEligibleMessage); + return true; + } else if (std::string::npos != command.find("SLAVE")) { + DisplayMessage("Executing vACDM as the SLAVE"); + Logger::instance().log(Logger::LogSender::vACDM, "Switched to SLAVE", Logger::LogLevel::Info); + com::Server::instance().setMaster(false); + return true; + } else if (std::string::npos != command.find("RELOAD")) { + this->reloadConfiguration(); + return true; + } else if (std::string::npos != command.find("LOG")) { + if (std::string::npos != command.find("LOGLEVEL")) { + DisplayMessage(Logger::instance().handleLogLevelCommand(command)); + } else { + DisplayMessage(Logger::instance().handleLogCommand(command)); + } + return true; + } else if (std::string::npos != command.find("UPDATERATE")) { + const auto elements = vacdm::utils::String::splitString(command, " "); + if (elements.size() != 3) { + DisplayMessage("Usage: .vacdm UPDATERATE value"); + return true; + } + if (false == isNumber(elements[2]) || + std::stoi(elements[2]) < minUpdateCycleSeconds && std::stoi(elements[2]) > maxUpdateCycleSeconds) { + DisplayMessage("Usage: .vacdm UPDATERATE value"); + DisplayMessage("Value must be number between " + std::to_string(minUpdateCycleSeconds) + " and " + + std::to_string(maxUpdateCycleSeconds)); + return true; + } + + DisplayMessage(DataManager::instance().setUpdateCycleSeconds(std::stoi(elements[2]))); + + return true; + } + return false; +} +} // namespace vacdm \ No newline at end of file diff --git a/src/core/DataManager.cpp b/src/core/DataManager.cpp index 674e7b3..46d1b5f 100644 --- a/src/core/DataManager.cpp +++ b/src/core/DataManager.cpp @@ -347,9 +347,14 @@ void DataManager::setActiveAirports(const std::list activeAirports) } void DataManager::queueFlightplanUpdate(EuroScopePlugIn::CFlightPlan flightplan) { - if (false == flightplan.IsValid()) return; + if (false == flightplan.IsValid() || nullptr == flightplan.GetFlightPlanData().GetPlanType() || + nullptr == flightplan.GetFlightPlanData().GetOrigin()) + return; + + auto pilot = this->CFlightPlanToPilot(flightplan); + std::lock_guard guard(this->m_euroscopeUpdatesLock); - this->m_euroscopeFlightplanUpdates.push_back({std::chrono::utc_clock::now(), flightplan}); + this->m_euroscopeFlightplanUpdates.push_back({std::chrono::utc_clock::now(), pilot}); } void DataManager::consolidateWithBackend(std::map>& pilots) { @@ -436,7 +441,7 @@ void DataManager::processEuroScopeUpdates(std::map resultList; for (const auto& currentUpdate : inputList) { - auto& flightplan = currentUpdate.data; + auto pilot = currentUpdate.data; + // only handle updates for active airports { std::lock_guard guard(this->m_airportLock); - bool flightDepartsFromActiveAirport = - std::find(m_activeAirports.begin(), m_activeAirports.end(), - std::string(flightplan.GetFlightPlanData().GetOrigin())) != m_activeAirports.end(); + bool flightDepartsFromActiveAirport = std::find(m_activeAirports.begin(), m_activeAirports.end(), + std::string(pilot.origin)) != m_activeAirports.end(); if (false == flightDepartsFromActiveAirport) continue; } // Check if the flight plan already exists in the result list auto it = std::find_if(resultList.begin(), resultList.end(), [¤tUpdate](const EuroscopeFlightplanUpdate& existingUpdate) { - return existingUpdate.data.GetCallsign() == currentUpdate.data.GetCallsign(); + return existingUpdate.data.callsign == currentUpdate.data.callsign; }); if (it != resultList.end()) { @@ -484,20 +489,18 @@ void DataManager::consolidateFlightplanUpdates(std::listRegisterTagItemFunction("Modify EXOT", EXOT_MODIFY); - plugin->RegisterTagItemFunction("TOBT now", TOBT_NOW); - plugin->RegisterTagItemFunction("Set TOBT", TOBT_MANUAL); - plugin->RegisterTagItemFunction("TOBT confirm", TOBT_CONFIRM); - plugin->RegisterTagItemFunction("Tobt menu", TOBT_MENU); - plugin->RegisterTagItemFunction("ASAT now", ASAT_NOW); - plugin->RegisterTagItemFunction("ASAT now and startup state", ASAT_NOW_AND_STARTUP); - plugin->RegisterTagItemFunction("Startup Request", STARTUP_REQUEST); - plugin->RegisterTagItemFunction("Request Offblock", OFFBLOCK_REQUEST); - plugin->RegisterTagItemFunction("Set AOBT and Groundstate", AOBT_NOW_AND_STATE); +void vACDM::RegisterTagItemFuntions() { + RegisterTagItemFunction("Modify EXOT", EXOT_MODIFY); + RegisterTagItemFunction("TOBT now", TOBT_NOW); + RegisterTagItemFunction("Set TOBT", TOBT_MANUAL); + RegisterTagItemFunction("TOBT confirm", TOBT_CONFIRM); + RegisterTagItemFunction("Tobt menu", TOBT_MENU); + RegisterTagItemFunction("ASAT now", ASAT_NOW); + RegisterTagItemFunction("ASAT now and startup state", ASAT_NOW_AND_STARTUP); + RegisterTagItemFunction("Startup Request", STARTUP_REQUEST); + RegisterTagItemFunction("Request Offblock", OFFBLOCK_REQUEST); + RegisterTagItemFunction("Set AOBT and Groundstate", AOBT_NOW_AND_STATE); // Reset Functions - plugin->RegisterTagItemFunction("Reset TOBT", RESET_TOBT); - plugin->RegisterTagItemFunction("Reset ASAT", RESET_ASAT); - plugin->RegisterTagItemFunction("Reset confirmed TOBT", RESET_TOBT_CONFIRM); - plugin->RegisterTagItemFunction("Reset Offblock Request", RESET_AORT); - plugin->RegisterTagItemFunction("Reset AOBT", RESET_AOBT_AND_STATE); - plugin->RegisterTagItemFunction("Reset Menu", RESET_MENU); - plugin->RegisterTagItemFunction("Reset pilot", RESET_PILOT); + RegisterTagItemFunction("Reset TOBT", RESET_TOBT); + RegisterTagItemFunction("Reset ASAT", RESET_ASAT); + RegisterTagItemFunction("Reset confirmed TOBT", RESET_TOBT_CONFIRM); + RegisterTagItemFunction("Reset Offblock Request", RESET_AORT); + RegisterTagItemFunction("Reset AOBT", RESET_AOBT_AND_STATE); + RegisterTagItemFunction("Reset Menu", RESET_MENU); + RegisterTagItemFunction("Reset pilot", RESET_PILOT); } -void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, POINT pt, RECT area) { +void vACDM::OnFunctionCall(int functionId, const char *itemString, POINT pt, RECT area) { std::ignore = pt; // do not handle functions if client is not master if (false == Server::instance().getMaster()) return; - auto flightplan = plugin->FlightPlanSelectASEL(); + auto flightplan = FlightPlanSelectASEL(); std::string callsign(flightplan.GetCallsign()); if (false == DataManager::instance().checkPilotExists(callsign)) return; @@ -75,7 +76,7 @@ void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, PO switch (static_cast(functionId)) { case EXOT_MODIFY: - plugin->OpenPopupEdit(area, static_cast(itemFunction::EXOT_NEW_VALUE), itemString); + OpenPopupEdit(area, static_cast(itemFunction::EXOT_NEW_VALUE), itemString); break; case EXOT_NEW_VALUE: if (true == isNumber(itemString)) { @@ -90,7 +91,7 @@ void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, PO std::chrono::utc_clock::now()); break; case TOBT_MANUAL: - plugin->OpenPopupEdit(area, TOBT_MANUAL_EDIT, ""); + OpenPopupEdit(area, TOBT_MANUAL_EDIT, ""); break; case TOBT_MANUAL_EDIT: { std::string clock(itemString); @@ -102,9 +103,9 @@ void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, PO pilot.callsign, utils::Date::convertStringToTimePoint(clock)); else - plugin->DisplayMessage("Invalid time format. Expected: HHMM (24 hours)"); + DisplayMessage("Invalid time format. Expected: HHMM (24 hours)"); } else if (clock.length() != 0) { - plugin->DisplayMessage("Invalid time format. Expected: HHMM (24 hours)"); + DisplayMessage("Invalid time format. Expected: HHMM (24 hours)"); } break; } @@ -128,7 +129,7 @@ void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, PO std::chrono::utc_clock::now()); } - plugin->SetGroundState(flightplan, "ST-UP"); + SetGroundState(flightplan, "ST-UP"); break; } @@ -148,9 +149,9 @@ void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, PO // set status depending on if the aircraft is positioned at a taxi-out position if (pilot.taxizoneIsTaxiout) { - plugin->SetGroundState(flightplan, "TAXI"); + SetGroundState(flightplan, "TAXI"); } else { - plugin->SetGroundState(flightplan, "PUSH"); + SetGroundState(flightplan, "PUSH"); } break; } @@ -165,10 +166,10 @@ void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, PO break; } case TOBT_MENU: { - plugin->OpenPopupList(area, "TOBT menu", 1); - plugin->AddPopupListElement("TOBT now", NULL, TOBT_NOW, false, 2, false, false); - plugin->AddPopupListElement("TOBT edit", NULL, TOBT_MANUAL, false, 2, false, false); - plugin->AddPopupListElement("TOBT confirm", NULL, TOBT_CONFIRM, false, 2, false, false); + OpenPopupList(area, "TOBT menu", 1); + AddPopupListElement("TOBT now", NULL, TOBT_NOW, false, 2, false, false); + AddPopupListElement("TOBT edit", NULL, TOBT_MANUAL, false, 2, false, false); + AddPopupListElement("TOBT confirm", NULL, TOBT_CONFIRM, false, 2, false, false); break; } case RESET_TOBT: @@ -178,7 +179,7 @@ void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, PO case RESET_ASAT: DataManager::instance().handleTagFunction(DataManager::MessageType::ResetASAT, pilot.callsign, types::defaultTime); - plugin->SetGroundState(flightplan, "NSTS"); + SetGroundState(flightplan, "NSTS"); break; case RESET_ASRT: DataManager::instance().handleTagFunction(DataManager::MessageType::ResetASRT, pilot.callsign, @@ -195,17 +196,17 @@ void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, PO case RESET_AOBT_AND_STATE: DataManager::instance().handleTagFunction(DataManager::MessageType::ResetAOBT, pilot.callsign, types::defaultTime); - plugin->SetGroundState(flightplan, "NSTS"); + SetGroundState(flightplan, "NSTS"); break; case RESET_MENU: - plugin->OpenPopupList(area, "RESET menu", 1); - plugin->AddPopupListElement("Reset TOBT", NULL, RESET_TOBT, false, 2, false, false); - plugin->AddPopupListElement("Reset ASAT", NULL, RESET_ASAT, false, 2, false, false); - plugin->AddPopupListElement("Reset ASRT", NULL, RESET_ASRT, false, 2, false, false); - plugin->AddPopupListElement("Reset confirmed TOBT", NULL, RESET_TOBT_CONFIRM, false, 2, false, false); - plugin->AddPopupListElement("Reset AORT", NULL, RESET_AORT, false, 2, false, false); - plugin->AddPopupListElement("Reset AOBT", NULL, RESET_AOBT_AND_STATE, false, 2, false, false); - plugin->AddPopupListElement("Reset Pilot", NULL, RESET_PILOT, false, 2, false, false); + OpenPopupList(area, "RESET menu", 1); + AddPopupListElement("Reset TOBT", NULL, RESET_TOBT, false, 2, false, false); + AddPopupListElement("Reset ASAT", NULL, RESET_ASAT, false, 2, false, false); + AddPopupListElement("Reset ASRT", NULL, RESET_ASRT, false, 2, false, false); + AddPopupListElement("Reset confirmed TOBT", NULL, RESET_TOBT_CONFIRM, false, 2, false, false); + AddPopupListElement("Reset AORT", NULL, RESET_AORT, false, 2, false, false); + AddPopupListElement("Reset AOBT", NULL, RESET_AOBT_AND_STATE, false, 2, false, false); + AddPopupListElement("Reset Pilot", NULL, RESET_PILOT, false, 2, false, false); break; case RESET_PILOT: DataManager::instance().handleTagFunction(DataManager::MessageType::ResetPilot, pilot.callsign, @@ -215,4 +216,4 @@ void handleTagFunction(vACDM *plugin, int functionId, const char *itemString, PO break; } } -} // namespace vacdm::tagfunctions \ No newline at end of file +} // namespace vacdm \ No newline at end of file diff --git a/src/core/TagItems.h b/src/core/TagItems.h index 5ce67c6..11b49ce 100644 --- a/src/core/TagItems.h +++ b/src/core/TagItems.h @@ -8,8 +8,11 @@ #include "TagItemsColor.h" #include "types/Pilot.h" +#include "vACDM.h" -namespace vacdm::tagitems { +using namespace vacdm::tagitems; + +namespace vacdm { enum itemType { EOBT, TOBT, @@ -26,20 +29,20 @@ enum itemType { EVENT_BOOKING, }; -void RegisterTagItemTypes(vACDM *plugin) { - plugin->RegisterTagItemType("EOBT", itemType::EOBT); - plugin->RegisterTagItemType("TOBT", itemType::TOBT); - plugin->RegisterTagItemType("TSAT", itemType::TSAT); - plugin->RegisterTagItemType("TTOT", itemType::TTOT); - plugin->RegisterTagItemType("EXOT", itemType::EXOT); - plugin->RegisterTagItemType("ASAT", itemType::ASAT); - plugin->RegisterTagItemType("AOBT", itemType::AOBT); - plugin->RegisterTagItemType("ATOT", itemType::ATOT); - plugin->RegisterTagItemType("ASRT", itemType::ASRT); - plugin->RegisterTagItemType("AORT", itemType::AORT); - plugin->RegisterTagItemType("CTOT", itemType::CTOT); - plugin->RegisterTagItemType("Event Booking", itemType::EVENT_BOOKING); - plugin->RegisterTagItemType("ECFMP Measures", itemType::ECFMP_MEASURES); +void vACDM::RegisterTagItemTypes() { + RegisterTagItemType("EOBT", itemType::EOBT); + RegisterTagItemType("TOBT", itemType::TOBT); + RegisterTagItemType("TSAT", itemType::TSAT); + RegisterTagItemType("TTOT", itemType::TTOT); + RegisterTagItemType("EXOT", itemType::EXOT); + RegisterTagItemType("ASAT", itemType::ASAT); + RegisterTagItemType("AOBT", itemType::AOBT); + RegisterTagItemType("ATOT", itemType::ATOT); + RegisterTagItemType("ASRT", itemType::ASRT); + RegisterTagItemType("AORT", itemType::AORT); + RegisterTagItemType("CTOT", itemType::CTOT); + RegisterTagItemType("Event Booking", itemType::EVENT_BOOKING); + RegisterTagItemType("ECFMP Measures", itemType::ECFMP_MEASURES); } std::string formatTime(const std::chrono::utc_clock::time_point timepoint) { @@ -49,8 +52,9 @@ std::string formatTime(const std::chrono::utc_clock::time_point timepoint) { return ""; } -void displayTagItem(EuroScopePlugIn::CFlightPlan FlightPlan, EuroScopePlugIn::CRadarTarget RadarTarget, int ItemCode, - int TagData, char sItemString[16], int *pColorCode, COLORREF *pRGB, double *pFontSize) { +void vACDM::OnGetTagItem(EuroScopePlugIn::CFlightPlan FlightPlan, EuroScopePlugIn::CRadarTarget RadarTarget, + int ItemCode, int TagData, char sItemString[16], int *pColorCode, COLORREF *pRGB, + double *pFontSize) { std::ignore = RadarTarget; std::ignore = TagData; std::ignore = pRGB; @@ -138,4 +142,4 @@ void displayTagItem(EuroScopePlugIn::CFlightPlan FlightPlan, EuroScopePlugIn::CR std::strcpy(sItemString, outputText.str().c_str()); } -} // namespace vacdm::tagitems \ No newline at end of file +} // namespace vacdm \ No newline at end of file diff --git a/src/vACDM.cpp b/src/vACDM.cpp index a89fee4..af56bcf 100644 --- a/src/vACDM.cpp +++ b/src/vACDM.cpp @@ -7,6 +7,7 @@ #include "Version.h" #include "config/ConfigParser.h" +#include "core/CompileCommands.h" #include "core/DataManager.h" #include "core/Server.h" #include "core/TagFunctions.h" @@ -21,7 +22,6 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase; using namespace vacdm; using namespace vacdm::com; using namespace vacdm::core; -using namespace vacdm::tagitems; using namespace vacdm::logging; using namespace vacdm::utils; @@ -40,8 +40,8 @@ vACDM::vACDM() PathRemoveFileSpecA(path); this->m_dllPath = std::string(path); - tagitems::RegisterTagItemTypes(this); - tagfunctions::RegisterTagItemFuntions(this); + this->RegisterTagItemTypes(); + this->RegisterTagItemFuntions(); this->reloadConfiguration(true); } @@ -174,90 +174,5 @@ void vACDM::OnAirportRunwayActivityChanged() { } DataManager::instance().setActiveAirports(activeAirports); } -void vACDM::OnFunctionCall(int functionId, const char *itemString, POINT pt, RECT area) { - tagfunctions::handleTagFunction(this, functionId, itemString, pt, area); -} - -void vACDM::OnGetTagItem(EuroScopePlugIn::CFlightPlan FlightPlan, EuroScopePlugIn::CRadarTarget RadarTarget, - int ItemCode, int TagData, char sItemString[16], int *pColorCode, COLORREF *pRGB, - double *pFontSize) { - tagitems::displayTagItem(FlightPlan, RadarTarget, ItemCode, TagData, sItemString, pColorCode, pRGB, pFontSize); -} - -bool vACDM::OnCompileCommand(const char *sCommandLine) { - std::string command(sCommandLine); - -#pragma warning(push) -#pragma warning(disable : 4244) - std::transform(command.begin(), command.end(), command.begin(), ::toupper); -#pragma warning(pop) - - // only handle commands containing ".vacdm" - if (0 != command.find(".VACDM")) return false; - - // master command - if (std::string::npos != command.find("MASTER")) { - bool userIsConnected = this->GetConnectionType() != EuroScopePlugIn::CONNECTION_TYPE_NO; - bool userIsInSweatbox = this->GetConnectionType() == EuroScopePlugIn::CONNECTION_TYPE_SWEATBOX; - bool userIsObserver = std::string_view(this->ControllerMyself().GetCallsign()).ends_with("_OBS") == true || - this->ControllerMyself().GetFacility() == 0; - bool serverAllowsObsAsMaster = com::Server::instance().getServerConfig().allowMasterAsObserver; - bool serverAllowsSweatboxAsMaster = com::Server::instance().getServerConfig().allowMasterInSweatbox; - - std::string userIsNotEligibleMessage; - - if (!userIsConnected) { - userIsNotEligibleMessage = "You are not logged in to the VATSIM network"; - } else if (userIsObserver && !serverAllowsObsAsMaster) { - userIsNotEligibleMessage = "You are logged in as Observer and Server does not allow Observers to be Master"; - } else if (userIsInSweatbox && !serverAllowsSweatboxAsMaster) { - userIsNotEligibleMessage = - "You are logged in on a Sweatbox Server and Server does not allow Sweatbox connections"; - } else { - DisplayMessage("Executing vACDM as the MASTER"); - Logger::instance().log(Logger::LogSender::vACDM, "Switched to MASTER", Logger::LogLevel::Info); - com::Server::instance().setMaster(true); - - return true; - } - - DisplayMessage("Cannot upgrade to Master"); - DisplayMessage(userIsNotEligibleMessage); - return true; - } else if (std::string::npos != command.find("SLAVE")) { - DisplayMessage("Executing vACDM as the SLAVE"); - Logger::instance().log(Logger::LogSender::vACDM, "Switched to SLAVE", Logger::LogLevel::Info); - com::Server::instance().setMaster(false); - return true; - } else if (std::string::npos != command.find("RELOAD")) { - this->reloadConfiguration(); - return true; - } else if (std::string::npos != command.find("LOG")) { - if (std::string::npos != command.find("LOGLEVEL")) { - DisplayMessage(Logger::instance().handleLogLevelCommand(command)); - } else { - DisplayMessage(Logger::instance().handleLogCommand(command)); - } - return true; - } else if (std::string::npos != command.find("UPDATERATE")) { - const auto elements = vacdm::utils::String::splitString(command, " "); - if (elements.size() != 3) { - DisplayMessage("Usage: .vacdm UPDATERATE value"); - return true; - } - if (false == isNumber(elements[2]) || - std::stoi(elements[2]) < minUpdateCycleSeconds && std::stoi(elements[2]) > maxUpdateCycleSeconds) { - DisplayMessage("Usage: .vacdm UPDATERATE value"); - DisplayMessage("Value must be number between " + std::to_string(minUpdateCycleSeconds) + " and " + - std::to_string(maxUpdateCycleSeconds)); - return true; - } - - DisplayMessage(DataManager::instance().setUpdateCycleSeconds(std::stoi(elements[2]))); - - return true; - } - return false; -} } // namespace vacdm \ No newline at end of file diff --git a/src/vACDM.h b/src/vACDM.h index b83f92e..f5b6e50 100644 --- a/src/vACDM.h +++ b/src/vACDM.h @@ -37,6 +37,9 @@ class vACDM : public EuroScopePlugIn::CPlugIn { void runEuroscopeUpdate(); void checkServerConfiguration(); void reloadConfiguration(bool initialLoading = false); + + void RegisterTagItemTypes(); + void RegisterTagItemFuntions(); }; } // namespace vacdm