Skip to content

Commit

Permalink
Prenote messages tag items (#332)
Browse files Browse the repository at this point in the history
* Request Builder Functions

* Style

* Tidy Up The Api Helper

* Add To ApiHelper

* Formatting

* Fix missing constructor for ApiInterface

* Fix Method

* Status indicator tag item

* Start cancellation menu

* Cancelling Prenote Menu

* Allow controller positions to have prenote permissions

* Only allow deletion of prenotes by responsible controllers

* Sending prenote messages

* Formatting
  • Loading branch information
AndyTWF committed Sep 4, 2021
1 parent 0c54df3 commit a611d90
Show file tree
Hide file tree
Showing 27 changed files with 2,113 additions and 817 deletions.
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,8 @@ CheckOptions:
value: '0'
- key: readability-else-after-return.WarnOnUnfixable
value: '1'
- key: readability-function-cognitive-complexity.IgnoreMacros
value: '1'
- key: readability-function-size.BranchThreshold
value: '4294967295'
- key: readability-function-size.LineThreshold
Expand Down
2 changes: 2 additions & 0 deletions docs/TAG_FUNCTIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
9013 - Open Departure Release Decision Menu
9014 - Open Departure Release Request Status View
9015 - Open Departure Release Cancellation Menu
9016 - Open Prenote Message Cancellation Menu
9017 - Open Prenote Message Sending Menu
3 changes: 2 additions & 1 deletion docs/TAG_ITEMS.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,5 @@
123 - Nattrak Oceanic Clearance Entry Estimate
124 - Departure Release Status Indicator
125 - Departure Release Countdown
126 - Departure Release Requesting Controller
126 - Departure Release Requesting Controller
127 - Prenote Messages Status Indicator
5 changes: 4 additions & 1 deletion src/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,10 @@ set(src__prenote
prenote/PrenoteAcknowledgedPushEventHandler.cpp prenote/PrenoteAcknowledgedPushEventHandler.h
prenote/PrenoteDeletedPushEventHandler.cpp prenote/PrenoteDeletedPushEventHandler.h
prenote/NewPrenotePushEventHandler.cpp prenote/NewPrenotePushEventHandler.h
prenote/PrenoteMessageTimeout.cpp prenote/PrenoteMessageTimeout.h)
prenote/PrenoteMessageTimeout.cpp prenote/PrenoteMessageTimeout.h
prenote/PrenoteStatusIndicatorTagItem.cpp prenote/PrenoteStatusIndicatorTagItem.h
prenote/CancelPrenoteMessageMenu.cpp prenote/CancelPrenoteMessageMenu.h
prenote/SendPrenoteMenu.cpp prenote/SendPrenoteMenu.h)
source_group("src\\prenote" FILES ${src__prenote})

set(src__push
Expand Down
133 changes: 70 additions & 63 deletions src/plugin/controller/ControllerPosition.cpp
Original file line number Diff line number Diff line change
@@ -1,74 +1,81 @@
#include "pch/pch.h"
#include "controller/ControllerPosition.h"
#include "ControllerPosition.h"

namespace UKControllerPlugin {
namespace Controller {
ControllerPosition::ControllerPosition(
int id,
std::string callsign,
double frequency,
std::vector<std::string> topdown,
bool requestsDepartureReleases,
bool receivesDepartureReleases
): id(id), requestsDepartureReleases(requestsDepartureReleases),
receivesDepartureReleases(receivesDepartureReleases), callsign(callsign),
frequency(frequency), topdown(std::move(topdown))
{ }
namespace UKControllerPlugin::Controller {
ControllerPosition::ControllerPosition(
int id,
std::string callsign,
double frequency,
std::vector<std::string> topdown,
bool requestsDepartureReleases,
bool receivesDepartureReleases,
bool sendsPrenoteMessages,
bool receivesPrenoteMessages)
: id(id), requestsDepartureReleases(requestsDepartureReleases),
receivesDepartureReleases(receivesDepartureReleases), callsign(std::move(callsign)), frequency(frequency),
topdown(std::move(topdown)), sendsPrenoteMessages(sendsPrenoteMessages),
receivesPrenoteMessages(receivesPrenoteMessages)
{
}

int ControllerPosition::GetId() const
{
return this->id;
}
auto ControllerPosition::GetId() const -> int
{
return this->id;
}

std::string ControllerPosition::GetUnit() const
{
return this->callsign.substr(0, this->callsign.find('_'));
}
auto ControllerPosition::GetUnit() const -> std::string
{
return this->callsign.substr(0, this->callsign.find('_'));
}

std::string ControllerPosition::GetCallsign() const
{
return this->callsign;
}
auto ControllerPosition::GetCallsign() const -> std::string
{
return this->callsign;
}

double ControllerPosition::GetFrequency() const
{
return this->frequency;
}
auto ControllerPosition::GetFrequency() const -> double
{
return this->frequency;
}

std::string ControllerPosition::GetType() const
{
return callsign.substr(this->callsign.size() - 3, this->callsign.size());
}
auto ControllerPosition::GetType() const -> std::string
{
return callsign.substr(this->callsign.size() - 3, this->callsign.size());
}

bool ControllerPosition::HasTopdownAirfield(std::string icao) const
{
return std::find(
this->topdown.cbegin(),
this->topdown.cend(),
icao
) != this->topdown.cend();
}
auto ControllerPosition::HasTopdownAirfield(const std::string& icao) const -> bool
{
return std::find(this->topdown.cbegin(), this->topdown.cend(), icao) != this->topdown.cend();
}

bool ControllerPosition::RequestsDepartureReleases() const
{
return this->requestsDepartureReleases;
}
auto ControllerPosition::RequestsDepartureReleases() const -> bool
{
return this->requestsDepartureReleases;
}

bool ControllerPosition::ReceivesDepartureReleases() const
{
return this->receivesDepartureReleases;
}
auto ControllerPosition::ReceivesDepartureReleases() const -> bool
{
return this->receivesDepartureReleases;
}

std::vector<std::string> ControllerPosition::GetTopdown() const
{
return this->topdown;
}
auto ControllerPosition::GetTopdown() const -> std::vector<std::string>
{
return this->topdown;
}

bool ControllerPosition::operator==(const ControllerPosition& position) const
{
return this->GetId() == position.GetId() &&
fabs(this->frequency - position.GetFrequency()) < 0.001 &&
this->callsign.compare(position.GetCallsign()) == 0;
}
} // namespace Controller
} // namespace UKControllerPlugin
auto ControllerPosition::operator==(const ControllerPosition& position) const -> bool
{
return this->GetId() == position.GetId() &&
fabs(this->frequency - position.GetFrequency()) < frequencyMatchDelta &&
this->callsign == position.GetCallsign();
}

auto ControllerPosition::SendsPrenoteMessages() const -> bool
{
return this->sendsPrenoteMessages;
}

auto ControllerPosition::ReceivesPrenoteMessages() const -> bool
{
return this->receivesPrenoteMessages;
}
} // namespace UKControllerPlugin::Controller
110 changes: 59 additions & 51 deletions src/plugin/controller/ControllerPosition.h
Original file line number Diff line number Diff line change
@@ -1,53 +1,61 @@
#pragma once

namespace UKControllerPlugin {
namespace Controller {

/*
Class that represents a potential UK Controller position.
*/
class ControllerPosition
{
public:
ControllerPosition(
int id,
std::string callsign,
double frequency,
std::vector<std::string> topdown,
bool requestsDepartureReleases,
bool receivesDepartureReleases
);

int GetId() const;
std::string GetUnit() const;
std::string GetCallsign() const;
double GetFrequency() const;
std::vector<std::string> GetTopdown() const;
std::string GetType() const;
bool HasTopdownAirfield(std::string icao) const;
bool RequestsDepartureReleases() const;
bool ReceivesDepartureReleases() const;
bool operator==(const ControllerPosition & position) const;

private:

// The id of the controller in the API
const int id;

// The default controller callsign
const std::string callsign;

// The controller frequency
const double frequency;

// The airfields for which this controller has some level of top-down responsibility.
const std::vector<std::string> topdown;

// Can the controller request a departure release
const bool requestsDepartureReleases;

// Can the controller receive a departure release
const bool receivesDepartureReleases;
};
} // namespace Controller
} // namespace UKControllerPlugin
namespace UKControllerPlugin::Controller {

/*
Class that represents a potential UK Controller position.
*/
class ControllerPosition
{
public:
ControllerPosition(
int id,
std::string callsign,
double frequency,
std::vector<std::string> topdown,
bool requestsDepartureReleases,
bool receivesDepartureReleases,
bool sendsPrenoteMessages = false,
bool receivesPrenoteMessages = false);

[[nodiscard]] auto GetId() const -> int;
[[nodiscard]] auto GetUnit() const -> std::string;
[[nodiscard]] auto GetCallsign() const -> std::string;
[[nodiscard]] auto GetFrequency() const -> double;
[[nodiscard]] auto GetTopdown() const -> std::vector<std::string>;
[[nodiscard]] auto GetType() const -> std::string;
[[nodiscard]] auto HasTopdownAirfield(const std::string& icao) const -> bool;
[[nodiscard]] auto RequestsDepartureReleases() const -> bool;
[[nodiscard]] auto ReceivesDepartureReleases() const -> bool;
[[nodiscard]] auto SendsPrenoteMessages() const -> bool;
[[nodiscard]] auto ReceivesPrenoteMessages() const -> bool;
auto operator==(const ControllerPosition& position) const -> bool;

private:
// The id of the controller in the API
const int id;

// The default controller callsign
const std::string callsign;

// The controller frequency
const double frequency;

// The airfields for which this controller has some level of top-down responsibility.
const std::vector<std::string> topdown;

// Can the controller request a departure release
const bool requestsDepartureReleases;

// Can the controller receive a departure release
const bool receivesDepartureReleases;

// Can this controller send a prenote
const bool sendsPrenoteMessages;

// Can this controller cancel a prenote
const bool receivesPrenoteMessages;

const double frequencyMatchDelta = 0.001;
};
} // namespace UKControllerPlugin::Controller

0 comments on commit a611d90

Please sign in to comment.