diff --git a/README.md b/README.md index 221a8f3..ee2fc8f 100644 --- a/README.md +++ b/README.md @@ -1,92 +1 @@ -# cdm-plugin - - - -## Getting started - -To make it easy for you to get started with GitLab, here's a list of recommended next steps. - -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! - -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://git.vatsim-germany.org/nav/tools/vacdm/cdm-plugin.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://git.vatsim-germany.org/nav/tools/vacdm/cdm-plugin/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. +# vACDM-Plugin diff --git a/com/Server.cpp b/com/Server.cpp index 3c3a7a0..d17dbc1 100644 --- a/com/Server.cpp +++ b/com/Server.cpp @@ -50,7 +50,7 @@ Server::Server() : m_deleteRequest(), m_firstCall(true), m_validWebApi(false), - m_baseUrl("https://vacdm.vatsim-germany.org/api/v1"), + m_baseUrl("https://vacdm.vatsim-germany.org"), m_master(false), m_errorCode() { /* configure the get request */ @@ -135,7 +135,7 @@ bool Server::checkWepApi() { if (nullptr != m_getRequest.socket && true == m_firstCall) { __receivedGetData.clear(); - std::string url = m_baseUrl + "/version"; + std::string url = m_baseUrl + "/api/v1/version"; curl_easy_setopt(m_getRequest.socket, CURLOPT_URL, url.c_str()); /* send the command */ @@ -179,7 +179,7 @@ Server::ServerConfiguration_t Server::serverConfiguration() { if (nullptr != m_getRequest.socket) { __receivedGetData.clear(); - std::string url = m_baseUrl + "/config"; + std::string url = m_baseUrl + "/api/v1/config"; curl_easy_setopt(m_getRequest.socket, CURLOPT_URL, url.c_str()); /* send the command */ @@ -226,7 +226,7 @@ std::list Server::allFlights(const std::string& airport) { if (nullptr != m_getRequest.socket) { __receivedGetData.clear(); - std::string url = m_baseUrl + "/pilots"; + std::string url = m_baseUrl + "/api/v1/pilots"; if (airport.length() != 0) url += "?adep=" + airport; curl_easy_setopt(m_getRequest.socket, CURLOPT_URL, url.c_str()); @@ -322,7 +322,7 @@ void Server::postFlight(const Json::Value& root) { std::lock_guard guard(this->m_postRequest.lock); if (nullptr != m_postRequest.socket) { - std::string url = m_baseUrl + "/pilots"; + std::string url = m_baseUrl + "/api/v1/pilots"; curl_easy_setopt(m_postRequest.socket, CURLOPT_URL, url.c_str()); curl_easy_setopt(m_postRequest.socket, CURLOPT_POSTFIELDS, message.c_str()); @@ -341,7 +341,7 @@ void Server::patchFlight(const std::string& callsign, const Json::Value& root) { std::lock_guard guard(this->m_patchRequest.lock); if (nullptr != m_patchRequest.socket) { - std::string url = m_baseUrl + "/pilots/" + callsign; + std::string url = m_baseUrl + "/api/v1/pilots/" + callsign; curl_easy_setopt(m_patchRequest.socket, CURLOPT_URL, url.c_str()); curl_easy_setopt(m_patchRequest.socket, CURLOPT_POSTFIELDS, message.c_str()); @@ -360,7 +360,7 @@ void Server::deleteFlight(const std::string& callsign) { std::lock_guard guard(this->m_deleteRequest.lock); if (m_deleteRequest.socket != nullptr) { - std::string url = m_baseUrl + "/pilots/" + callsign; + std::string url = m_baseUrl + "/api/v1/pilots/" + callsign; curl_easy_setopt(m_deleteRequest.socket, CURLOPT_URL, url.c_str()); diff --git a/types/SystemConfig.h b/types/SystemConfig.h index 98cf3f6..a364668 100644 --- a/types/SystemConfig.h +++ b/types/SystemConfig.h @@ -9,7 +9,7 @@ namespace vacdm { struct SystemConfig { bool valid = true; - std::string serverUrl = "https://vacdm.dotfionn.de/api/v1"; + std::string serverUrl = "https://vacdm.vatsim-germany.org"; COLORREF lightgreen = RGB(127, 252, 73); COLORREF lightblue = RGB(53, 218, 235); COLORREF green = RGB(0, 181, 27); diff --git a/vACDM.cpp b/vACDM.cpp index 409c819..ee04255 100644 --- a/vACDM.cpp +++ b/vACDM.cpp @@ -169,21 +169,27 @@ void vACDM::OnFlightPlanControllerAssignedDataUpdate(EuroScopePlugIn::CFlightPla if (EuroScopePlugIn::CTR_DATA_TYPE_TEMPORARY_ALTITUDE != dataType && EuroScopePlugIn::CTR_DATA_TYPE_SQUAWK != dataType) return; - this->updateFlight(flightplan.GetCorrelatedRadarTarget()); + this->updateFlight(flightplan); } void vACDM::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget RadarTarget) { + + std::string callsign = RadarTarget.GetCallsign(); + if (callsign != RadarTarget.GetCorrelatedFlightPlan().GetCallsign() || callsign == "" || callsign.length() == 0) { + return; + } + std::string_view origin(RadarTarget.GetCorrelatedFlightPlan().GetFlightPlanData().GetOrigin()); { std::lock_guard guard(this->m_airportLock); for (auto& airport : this->m_airports) { if (airport->airport() == origin) { - if (false == airport->flightExists(RadarTarget.GetCallsign())) { + if (false == airport->flightExists(callsign)) { break; } - const auto& flightData = airport->flight(RadarTarget.GetCallsign()); + const auto& flightData = airport->flight(callsign); // check for AOBT and ATOT if (flightData.asat.time_since_epoch().count() > 0) { @@ -191,15 +197,16 @@ void vACDM::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget RadarTarge float distanceMeters = 0.0f; GeographicLib::Geodesic::WGS84().Inverse(static_cast(RadarTarget.GetPosition().GetPosition().m_Latitude), static_cast(RadarTarget.GetPosition().GetPosition().m_Longitude), - static_cast(flightData.latitude), static_cast(flightData.longitude), distanceMeters); + static_cast(flightData.latitude), static_cast(flightData.longitude), distanceMeters); if (distanceMeters >= 5.0f) { - airport->updateAobt(RadarTarget.GetCallsign(), std::chrono::utc_clock::now()); + airport->updateAobt(callsign, std::chrono::utc_clock::now()); } } else if (flightData.atot.time_since_epoch().count() <= 0) { - if (RadarTarget.GetGS() > 50) - airport->updateAtot(RadarTarget.GetCallsign(), std::chrono::utc_clock::now()); + if (RadarTarget.GetGS() > 50) { + airport->updateAtot(callsign, std::chrono::utc_clock::now()); + } } } break; @@ -207,7 +214,7 @@ void vACDM::OnRadarTargetPositionUpdate(EuroScopePlugIn::CRadarTarget RadarTarge } } - this->updateFlight(RadarTarget); + this->updateFlight(RadarTarget.GetCorrelatedFlightPlan()); } void vACDM::OnFlightPlanDisconnect(EuroScopePlugIn::CFlightPlan FlightPlan) { @@ -248,8 +255,8 @@ void vACDM::OnGetTagItem(EuroScopePlugIn::CFlightPlan FlightPlan, EuroScopePlugI std::lock_guard guard(this->m_airportLock); for (auto& airport : this->m_airports) { if (airport->airport() == origin) { - if (true == airport->flightExists(RadarTarget.GetCallsign())) { - const auto& data = airport->flight(RadarTarget.GetCallsign()); + if (true == airport->flightExists(FlightPlan.GetCallsign())) { + const auto& data = airport->flight(FlightPlan.GetCallsign()); std::stringstream stream; switch (static_cast(ItemCode)) { @@ -515,9 +522,7 @@ std::chrono::utc_clock::time_point vACDM::convertToTobt(const std::string& calls return tobt; } -void vACDM::updateFlight(const EuroScopePlugIn::CRadarTarget& rt) { - const auto& fp = rt.GetCorrelatedFlightPlan(); - +void vACDM::updateFlight(const EuroScopePlugIn::CFlightPlan& fp) { // ignore irrelevant and non-IFR flights if (nullptr == fp.GetFlightPlanData().GetPlanType() || 0 == std::strlen(fp.GetFlightPlanData().GetPlanType())) return; @@ -534,10 +539,10 @@ void vACDM::updateFlight(const EuroScopePlugIn::CRadarTarget& rt) { return; types::Flight_t flight; - flight.callsign = rt.GetCallsign(); + flight.callsign = fp.GetCallsign(); flight.inactive = false; - flight.latitude = rt.GetPosition().GetPosition().m_Latitude; - flight.longitude = rt.GetPosition().GetPosition().m_Longitude; + flight.latitude = fp.GetFPTrackPosition().GetPosition().m_Latitude; + flight.longitude = fp.GetFPTrackPosition().GetPosition().m_Longitude; flight.origin = fp.GetFlightPlanData().GetOrigin(); flight.destination = fp.GetFlightPlanData().GetDestination(); flight.rule = "I"; @@ -546,11 +551,11 @@ void vACDM::updateFlight(const EuroScopePlugIn::CRadarTarget& rt) { flight.runway = fp.GetFlightPlanData().GetDepartureRwy(); flight.sid = fp.GetFlightPlanData().GetSidName(); flight.assignedSquawk = fp.GetControllerAssignedData().GetSquawk(); - flight.currentSquawk = rt.GetPosition().GetSquawk(); + flight.currentSquawk = fp.GetFPTrackPosition().GetSquawk(); flight.initialClimb = std::to_string(fp.GetControllerAssignedData().GetClearedAltitude()); - if (rt.GetGS() > 50) { - logging::Logger::instance().log("vACDM", logging::Logger::Level::Debug, flight.callsign + " departed. GS: " + std::to_string(rt.GetGS())); + if (fp.GetCorrelatedRadarTarget().GetGS() > 50) { + logging::Logger::instance().log("vACDM", logging::Logger::Level::Debug, flight.callsign + " departed. GS: " + std::to_string(fp.GetFPTrackPosition().GetReportedGS())); flight.departed = true; } @@ -566,8 +571,8 @@ void vACDM::updateFlight(const EuroScopePlugIn::CRadarTarget& rt) { } void vACDM::GetAircraftDetails() { - for (auto rt = RadarTargetSelectFirst(); rt.IsValid(); rt = RadarTargetSelectNext(rt)) - this->updateFlight(rt); + for (auto fp = FlightPlanSelectFirst(); fp.IsValid(); fp = FlightPlanSelectNext(fp)) + this->updateFlight(fp); } static __inline bool isNumber(const std::string& s) { @@ -577,14 +582,14 @@ static __inline bool isNumber(const std::string& s) { void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, RECT area) { std::ignore = pt; - auto radarTarget = this->RadarTargetSelectASEL(); - std::string callsign(radarTarget.GetCallsign()); + auto flightplan = this->FlightPlanSelectASEL(); + std::string callsign(flightplan.GetCallsign()); - if ("I" != std::string_view(radarTarget.GetCorrelatedFlightPlan().GetFlightPlanData().GetPlanType())) + if ("I" != std::string_view(flightplan.GetFlightPlanData().GetPlanType())) return; std::shared_ptr currentAirport; - std::string_view origin(radarTarget.GetCorrelatedFlightPlan().GetFlightPlanData().GetOrigin()); + std::string_view origin(flightplan.GetFlightPlanData().GetOrigin()); this->m_airportLock.lock(); for (const auto& airport : std::as_const(this->m_airports)) { if (airport->airport() == origin) { @@ -651,7 +656,7 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC currentAirport->updateAsrt(callsign, std::chrono::utc_clock::now()); } - SetGroundState(radarTarget, "ST-UP"); + SetGroundState(flightplan, "ST-UP"); break; } @@ -670,10 +675,10 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC // set status depending on if the aircraft is positioned at a taxi-out position if (data.taxizoneIsTaxiout) { - SetGroundState(radarTarget, "TAXI"); + SetGroundState(flightplan, "TAXI"); } else { - SetGroundState(radarTarget, "PUSH"); + SetGroundState(flightplan, "PUSH"); } break; } @@ -703,7 +708,7 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC case RESET_ASAT: { currentAirport->updateAsat(callsign, types::defaultTime); - SetGroundState(radarTarget, "NSTS"); + SetGroundState(flightplan, "NSTS"); break; } case RESET_ASRT: @@ -723,7 +728,7 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC } case RESET_AOBT_AND_STATE: { - SetGroundState(radarTarget, "NSTS"); + SetGroundState(flightplan, "NSTS"); currentAirport->updateAobt(callsign, types::defaultTime); break; } @@ -749,7 +754,7 @@ void vACDM::OnFunctionCall(int functionId, const char* itemString, POINT pt, REC } } -void vACDM::SetGroundState(const EuroScopePlugIn::CRadarTarget radarTarget, const std::string groundstate) { +void vACDM::SetGroundState(const EuroScopePlugIn::CFlightPlan flightplan, const std::string groundstate) { // using GRP and default Euroscope ground states // STATE ABBREVIATION GRP STATE // - No state(departure) NSTS @@ -763,9 +768,9 @@ void vACDM::SetGroundState(const EuroScopePlugIn::CRadarTarget radarTarget, cons // - No state(arrival) NOSTATE Y // - Parked PARK - std::string scratchBackup(radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().GetScratchPadString()); - radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().SetScratchPadString(groundstate.c_str()); - radarTarget.GetCorrelatedFlightPlan().GetControllerAssignedData().SetScratchPadString(scratchBackup.c_str()); + std::string scratchBackup(flightplan.GetControllerAssignedData().GetScratchPadString()); + flightplan.GetControllerAssignedData().SetScratchPadString(groundstate.c_str()); + flightplan.GetControllerAssignedData().SetScratchPadString(scratchBackup.c_str()); } void vACDM::RegisterTagItemFuntions() { diff --git a/vACDM.h b/vACDM.h index 95e4bd5..a0bf95e 100644 --- a/vACDM.h +++ b/vACDM.h @@ -73,7 +73,7 @@ class vACDM : public EuroScopePlugIn::CPlugIn { void reloadConfiguration(); void changeServerUrl(const std::string& url); - void updateFlight(const EuroScopePlugIn::CRadarTarget& rt); + void updateFlight(const EuroScopePlugIn::CFlightPlan& rt); static std::chrono::utc_clock::time_point convertToTobt(const std::string& callsign, const std::string& eobt); void checkServerConfiguration(); @@ -91,7 +91,7 @@ class vACDM : public EuroScopePlugIn::CPlugIn { void DisplayDebugMessage(const std::string &message); void GetAircraftDetails(); - void SetGroundState(const EuroScopePlugIn::CRadarTarget radarTarget, const std::string groundstate); + void SetGroundState(const EuroScopePlugIn::CFlightPlan flightplan, const std::string groundstate); void RegisterTagItemFuntions(); void RegisterTagItemTypes(); };