Skip to content

Commit

Permalink
Merge branch 'main' into release/1.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoKle committed Dec 28, 2023
2 parents b6b3be8 + a9a05e8 commit 558b495
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 136 deletions.
93 changes: 1 addition & 92 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
14 changes: 7 additions & 7 deletions com/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -226,7 +226,7 @@ std::list<types::Flight_t> 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());
Expand Down Expand Up @@ -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());

Expand All @@ -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());

Expand All @@ -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());

Expand Down
2 changes: 1 addition & 1 deletion types/SystemConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
73 changes: 39 additions & 34 deletions vACDM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,45 +169,52 @@ 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) {
if (flightData.aobt.time_since_epoch().count() <= 0) {
float distanceMeters = 0.0f;

GeographicLib::Geodesic::WGS84().Inverse(static_cast<float>(RadarTarget.GetPosition().GetPosition().m_Latitude), static_cast<float>(RadarTarget.GetPosition().GetPosition().m_Longitude),
static_cast<float>(flightData.latitude), static_cast<float>(flightData.longitude), distanceMeters);
static_cast<float>(flightData.latitude), static_cast<float>(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;
}
}
}

this->updateFlight(RadarTarget);
this->updateFlight(RadarTarget.GetCorrelatedFlightPlan());
}

void vACDM::OnFlightPlanDisconnect(EuroScopePlugIn::CFlightPlan FlightPlan) {
Expand Down Expand Up @@ -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<itemType>(ItemCode)) {
Expand Down Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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;
}

Expand All @@ -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) {
Expand All @@ -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<com::Airport> 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) {
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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:
Expand All @@ -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;
}
Expand All @@ -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
Expand All @@ -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() {
Expand Down
Loading

0 comments on commit 558b495

Please sign in to comment.