Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sid): Allow duplicate SID identifiers when doing initial altitudes #402

Merged
merged 8 commits into from
Jan 21, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/plugin/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,13 @@ set(src__releases
releases/EnrouteRelease.cpp releases/EnrouteReleaseType.cpp releases/RejectDepartureReleaseDialog.cpp releases/RejectDepartureReleaseDialog.h releases/ReleaseApprovalRemarksUserMessage.cpp releases/ReleaseApprovalRemarksUserMessage.h releases/ReleaseRejectionRemarksUserMessage.cpp releases/ReleaseRejectionRemarksUserMessage.h)
source_group("src\\releases" FILES ${src__releases})

set(src__runway
runway/Runway.cpp runway/Runway.h
runway/RunwayCollection.cpp runway/RunwayCollection.h
runway/RunwayCollectionFactory.cpp runway/RunwayCollectionFactory.h
runway/RunwayModule.cpp runway/RunwayModule.h)
source_group("src\\runway" FILES ${src__runway})

set(src__sectorfile
"sectorfile/Runway.cpp"
"sectorfile/Runway.h"
Expand Down Expand Up @@ -769,7 +776,8 @@ set(src__sid
"sid/SidModule.h"
"sid/StandardInstrumentDeparture.cpp"
"sid/StandardInstrumentDeparture.h"
)
sid/FlightplanSidMapper.cpp sid/FlightplanSidMapper.h
sid/SidMapperInterface.h)
source_group("src\\sid" FILES ${src__sid})

set(src__squawk
Expand Down Expand Up @@ -900,6 +908,7 @@ set(ALL_FILES
${src__radarscreen}
${src__regional}
${src__releases}
${src__runway}
${src__sectorfile}
${src__selcal}
${src__sid}
Expand Down
2 changes: 2 additions & 0 deletions src/plugin/bootstrap/InitialisePlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "push/PushEventBootstrap.h"
#include "regional/RegionalPressureModule.h"
#include "releases/ReleaseModule.h"
#include "runway/RunwayModule.h"
#include "sectorfile/SectorFileBootstrap.h"
#include "selcal/SelcalModule.h"
#include "sid/SidModule.h"
Expand Down Expand Up @@ -187,6 +188,7 @@ namespace UKControllerPlugin {
// Boostrap all the modules at a plugin level
Controller::BootstrapPlugin(*this->container, loader);
Airfield::BootstrapPlugin(*this->container, loader);
Runway::BootstrapPlugin(*this->container, loader);
CollectionBootstrap::BootstrapPlugin(*this->container, loader);
FlightplanStorageBootstrap::BootstrapPlugin(*this->container);
FlightRules::BootstrapPlugin(*this->container, loader);
Expand Down
2 changes: 2 additions & 0 deletions src/plugin/bootstrap/PersistenceContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,11 @@
#include "radarscreen/RadarScreenFactory.h"
#include "radarscreen/ScreenControls.h"
#include "regional/RegionalPressureManager.h"
#include "runway/RunwayCollection.h"
#include "sectorfile/RunwayCollection.h"
#include "setting/SettingRepository.h"
#include "sid/SidCollection.h"
#include "sid/SidMapperInterface.h"
#include "squawk/SquawkAssignment.h"
#include "squawk/SquawkEventHandler.h"
#include "squawk/SquawkGenerator.h"
Expand Down
6 changes: 6 additions & 0 deletions src/plugin/bootstrap/PersistenceContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ namespace UKControllerPlugin {
namespace Releases {
class DepartureReleaseEventHandler;
} // namespace Releases
namespace Runway {
class RunwayCollection;
} // namespace Runway
namespace SectorFile {
class RunwayCollection;
} // namespace SectorFile
Expand All @@ -109,6 +112,7 @@ namespace UKControllerPlugin {
} // namespace Setting
namespace Sid {
class SidCollection;
class SidMapperInterface;
} // namespace Sid
namespace Squawk {
class SquawkAssignment;
Expand Down Expand Up @@ -206,6 +210,7 @@ namespace UKControllerPlugin::Bootstrap {

// Large collections that we don't want to go onto the stack
std::unique_ptr<Sid::SidCollection> sids;
std::unique_ptr<Sid::SidMapperInterface> sidMapper;
std::unique_ptr<const UKControllerPlugin::Airfield::AirfieldCollection> airfields;
std::shared_ptr<UKControllerPlugin::Ownership::AirfieldServiceProviderCollection> airfieldOwnership;
std::unique_ptr<UKControllerPlugin::Controller::ControllerPositionCollection> controllerPositions;
Expand All @@ -217,6 +222,7 @@ namespace UKControllerPlugin::Bootstrap {
std::shared_ptr<UKControllerPlugin::Navaids::NavaidCollection> navaids;
std::shared_ptr<UKControllerPlugin::Hold::PublishedHoldCollection> publishedHolds;
std::unique_ptr<UKControllerPlugin::FlightRules::FlightRuleCollection> flightRules;
std::unique_ptr<UKControllerPlugin::Runway::RunwayCollection> runwayCollection;

// Push events
std::shared_ptr<Push::PushEventProcessorCollection> pushEventProcessors;
Expand Down
1 change: 1 addition & 0 deletions src/plugin/euroscope/EuroScopeCFlightPlanInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ namespace UKControllerPlugin::Euroscope {
[[nodiscard]] virtual bool IsVfr() const = 0;
[[nodiscard]] virtual EuroScopePlugIn::CFlightPlan GetEuroScopeObject() const = 0;
[[nodiscard]] virtual auto GetRemarks() const -> std::string = 0;
[[nodiscard]] virtual auto GetDepartureRunway() const -> std::string = 0;
};
} // namespace UKControllerPlugin::Euroscope
5 changes: 5 additions & 0 deletions src/plugin/euroscope/EuroScopeCFlightPlanWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,9 @@ namespace UKControllerPlugin::Euroscope {
{
return this->originalData.GetFlightPlanData().GetRemarks();
}

std::string EuroScopeCFlightPlanWrapper::GetDepartureRunway() const
{
return this->originalData.GetFlightPlanData().GetDepartureRwy();
}
} // namespace UKControllerPlugin::Euroscope
1 change: 1 addition & 0 deletions src/plugin/euroscope/EuroScopeCFlightPlanWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ namespace UKControllerPlugin::Euroscope {
std::string GetOrigin() const override;
std::string GetRawRouteString() const override;
std::string GetSidName() const override;
std::string GetDepartureRunway() const override;
bool HasAssignedSquawk() const override;
bool HasControllerClearedAltitude() const override;
bool HasControllerAssignedHeading() const override;
Expand Down
9 changes: 4 additions & 5 deletions src/plugin/handoff/FlightplanSidHandoffMapper.cpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
#include "FlightplanSidHandoffMapper.h"
#include "HandoffCollection.h"
#include "sid/SidCollection.h"
#include "sid/SidMapperInterface.h"
#include "sid/StandardInstrumentDeparture.h"

namespace UKControllerPlugin::Handoff {

FlightplanSidHandoffMapper::FlightplanSidHandoffMapper(
const HandoffCollection& handoffs, const Sid::SidCollection& sids)
: handoffs(handoffs), sids(sids)
const HandoffCollection& handoffs, const Sid::SidMapperInterface& sidMapper)
: handoffs(handoffs), sidMapper(sidMapper)
{
}

auto FlightplanSidHandoffMapper::MapForFlightplan(const Euroscope::EuroScopeCFlightPlanInterface& flightplan) const
-> std::shared_ptr<HandoffOrder>
{
const auto sid = this->sids.GetForFlightplan(flightplan);

const auto sid = this->sidMapper.MapFlightplanToSid(flightplan);
if (!sid || !sid->HasHandoff()) {
return nullptr;
}
Expand Down
6 changes: 3 additions & 3 deletions src/plugin/handoff/FlightplanSidHandoffMapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace UKControllerPlugin {
class EuroScopeCFlightPlanInterface;
} // namespace Euroscope
namespace Sid {
class SidCollection;
class SidMapperInterface;
} // namespace Sid
} // namespace UKControllerPlugin

Expand All @@ -20,7 +20,7 @@ namespace UKControllerPlugin::Handoff {
class FlightplanSidHandoffMapper
{
public:
FlightplanSidHandoffMapper(const HandoffCollection& handoffs, const Sid::SidCollection& sids);
FlightplanSidHandoffMapper(const HandoffCollection& handoffs, const Sid::SidMapperInterface& sidMapper);

[[nodiscard]] auto MapForFlightplan(const Euroscope::EuroScopeCFlightPlanInterface& flightplan) const
-> std::shared_ptr<HandoffOrder>;
Expand All @@ -30,6 +30,6 @@ namespace UKControllerPlugin::Handoff {
const HandoffCollection& handoffs;

// All the sids
const Sid::SidCollection& sids;
const Sid::SidMapperInterface& sidMapper;
};
} // namespace UKControllerPlugin::Handoff
2 changes: 1 addition & 1 deletion src/plugin/handoff/HandoffModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ namespace UKControllerPlugin::Handoff {
*container.controllerHierarchyFactory,
dependency.LoadDependency(GetHandoffDependencyKey(), nlohmann::json::array()));
airfieldMapper = std::make_shared<FlightplanAirfieldHandoffMapper>(*handoffs, *container.airfields);
sidMapper = std::make_shared<FlightplanSidHandoffMapper>(*handoffs, *container.sids);
sidMapper = std::make_shared<FlightplanSidHandoffMapper>(*handoffs, *container.sidMapper);

std::shared_ptr<HandoffEventHandler> handler = std::make_shared<HandoffEventHandler>(
std::make_shared<DepartureHandoffResolver>(*sidMapper, *airfieldMapper, *container.activeCallsigns),
Expand Down
17 changes: 5 additions & 12 deletions src/plugin/initialaltitude/InitialAltitudeEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "euroscope/UserSetting.h"
#include "login/Login.h"
#include "ownership/AirfieldServiceProviderCollection.h"
#include "sid/SidCollection.h"
#include "sid/SidMapperInterface.h"
#include "sid/StandardInstrumentDeparture.h"

using UKControllerPlugin::Controller::ActiveCallsign;
Expand All @@ -18,18 +18,17 @@ using UKControllerPlugin::Euroscope::EuroScopeCRadarTargetInterface;
using UKControllerPlugin::Euroscope::EuroscopePluginLoopbackInterface;
using UKControllerPlugin::Euroscope::GeneralSettingsEntries;
using UKControllerPlugin::Ownership::AirfieldServiceProviderCollection;
using UKControllerPlugin::Sid::SidCollection;
using UKControllerPlugin::Sid::StandardInstrumentDeparture;

namespace UKControllerPlugin::InitialAltitude {

InitialAltitudeEventHandler::InitialAltitudeEventHandler(
const SidCollection& sids,
const Sid::SidMapperInterface& sidMapper,
const ActiveCallsignCollection& activeCallsigns,
const AirfieldServiceProviderCollection& airfieldOwnership,
const Login& login,
EuroscopePluginLoopbackInterface& plugin)
: sids(sids), activeCallsigns(activeCallsigns), airfieldOwnership(airfieldOwnership), login(login),
: sidMapper(sidMapper), activeCallsigns(activeCallsigns), airfieldOwnership(airfieldOwnership), login(login),
plugin(plugin)
{
}
Expand Down Expand Up @@ -65,7 +64,7 @@ namespace UKControllerPlugin::InitialAltitude {
}

// Make sure the SID exists.
std::shared_ptr<StandardInstrumentDeparture> matchedSid = this->GetSidForFlight(flightPlan);
std::shared_ptr<StandardInstrumentDeparture> matchedSid = sidMapper.MapFlightplanToSid(flightPlan);

if (!matchedSid) {
return;
Expand Down Expand Up @@ -115,7 +114,7 @@ namespace UKControllerPlugin::InitialAltitude {
}

// Make sure the SID exists.
std::shared_ptr<StandardInstrumentDeparture> matchedSid = this->GetSidForFlight(flightplan);
std::shared_ptr<StandardInstrumentDeparture> matchedSid = sidMapper.MapFlightplanToSid(flightplan);

if (!matchedSid) {
return;
Expand Down Expand Up @@ -176,12 +175,6 @@ namespace UKControllerPlugin::InitialAltitude {
return !flightplan.IsTracked() || flightplan.IsTrackedByUser();
}

auto InitialAltitudeEventHandler::GetSidForFlight(EuroScopeCFlightPlanInterface& flightplan)
-> std::shared_ptr<StandardInstrumentDeparture>
{
return this->sids.GetByAirfieldAndIdentifier(flightplan.GetOrigin(), flightplan.GetSidName());
}

/*
If its the user, do some updates
*/
Expand Down
10 changes: 3 additions & 7 deletions src/plugin/initialaltitude/InitialAltitudeEventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ namespace UKControllerPlugin {
class Login;
} // namespace Controller
namespace Sid {
class SidCollection;
class StandardInstrumentDeparture;
class SidMapperInterface;
} // namespace Sid
namespace Euroscope {
class EuroscopePluginLoopbackInterface;
Expand All @@ -39,7 +38,7 @@ namespace UKControllerPlugin::InitialAltitude {
{
public:
InitialAltitudeEventHandler(
const Sid::SidCollection& sids,
const Sid::SidMapperInterface& sidMapper,
const Controller::ActiveCallsignCollection& activeCallsigns,
const Ownership::AirfieldServiceProviderCollection& airfieldOwnership,
const Controller::Login& login,
Expand Down Expand Up @@ -72,11 +71,8 @@ namespace UKControllerPlugin::InitialAltitude {
Euroscope::EuroScopeCFlightPlanInterface& flightplan,
Euroscope::EuroScopeCRadarTargetInterface& radarTarget) -> bool;

auto GetSidForFlight(Euroscope::EuroScopeCFlightPlanInterface& flightplan)
-> std::shared_ptr<Sid::StandardInstrumentDeparture>;

// Used to generate initial altitudes.
const Sid::SidCollection& sids;
const Sid::SidMapperInterface& sidMapper;

// Used to find out the users callsign.
const Controller::ActiveCallsignCollection& activeCallsigns;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/initialaltitude/InitialAltitudeModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace UKControllerPlugin::InitialAltitude {
void InitialAltitudeModule::BootstrapPlugin(PersistenceContainer& persistence)
{
std::shared_ptr<InitialAltitudeEventHandler> initialAltitudeEventHandler(new InitialAltitudeEventHandler(
*persistence.sids,
*persistence.sidMapper,
*persistence.activeCallsigns,
*persistence.airfieldOwnership,
*persistence.login,
Expand Down
18 changes: 6 additions & 12 deletions src/plugin/initialheading/InitialHeadingEventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "euroscope/UserSetting.h"
#include "login/Login.h"
#include "ownership/AirfieldServiceProviderCollection.h"
#include "sid/SidCollection.h"
#include "sid/SidMapperInterface.h"
#include "sid/StandardInstrumentDeparture.h"

using UKControllerPlugin::Controller::ActiveCallsign;
Expand All @@ -18,18 +18,18 @@ using UKControllerPlugin::Euroscope::EuroScopeCRadarTargetInterface;
using UKControllerPlugin::Euroscope::EuroscopePluginLoopbackInterface;
using UKControllerPlugin::Euroscope::GeneralSettingsEntries;
using UKControllerPlugin::Ownership::AirfieldServiceProviderCollection;
using UKControllerPlugin::Sid::SidCollection;
using UKControllerPlugin::Sid::SidMapperInterface;
using UKControllerPlugin::Sid::StandardInstrumentDeparture;

namespace UKControllerPlugin::InitialHeading {

InitialHeadingEventHandler::InitialHeadingEventHandler(
const SidCollection& sids,
const SidMapperInterface& sidMapper,
const ActiveCallsignCollection& activeCallsigns,
const AirfieldServiceProviderCollection& airfieldOwnership,
const Login& login,
EuroscopePluginLoopbackInterface& plugin)
: sids(sids), activeCallsigns(activeCallsigns), airfieldOwnership(airfieldOwnership), login(login),
: sidMapper(sidMapper), activeCallsigns(activeCallsigns), airfieldOwnership(airfieldOwnership), login(login),
plugin(plugin)
{
}
Expand Down Expand Up @@ -65,7 +65,7 @@ namespace UKControllerPlugin::InitialHeading {
}

// Make sure the SID exists.
std::shared_ptr<StandardInstrumentDeparture> matchedSid = this->GetSidForFlight(flightPlan);
auto matchedSid = sidMapper.MapFlightplanToSid(flightPlan);

if (!matchedSid || matchedSid->InitialHeading() == 0) {
return;
Expand Down Expand Up @@ -110,7 +110,7 @@ namespace UKControllerPlugin::InitialHeading {
}

// Make sure the SID exists.
std::shared_ptr<StandardInstrumentDeparture> matchedSid = this->GetSidForFlight(flightplan);
auto matchedSid = sidMapper.MapFlightplanToSid(flightplan);

if (!matchedSid || matchedSid->InitialHeading() == 0) {
return;
Expand Down Expand Up @@ -178,12 +178,6 @@ namespace UKControllerPlugin::InitialHeading {
return !flightplan.IsTracked() || flightplan.IsTrackedByUser();
}

auto InitialHeadingEventHandler::GetSidForFlight(EuroScopeCFlightPlanInterface& flightplan)
-> std::shared_ptr<StandardInstrumentDeparture>
{
return this->sids.GetByAirfieldAndIdentifier(flightplan.GetOrigin(), flightplan.GetSidName());
}

/*
If its the user, do some updates
*/
Expand Down
10 changes: 3 additions & 7 deletions src/plugin/initialheading/InitialHeadingEventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ namespace UKControllerPlugin {
class Login;
} // namespace Controller
namespace Sid {
class SidCollection;
class StandardInstrumentDeparture;
class SidMapperInterface;
} // namespace Sid
namespace Euroscope {
class EuroscopePluginLoopbackInterface;
Expand All @@ -39,7 +38,7 @@ namespace UKControllerPlugin::InitialHeading {
{
public:
InitialHeadingEventHandler(
const Sid::SidCollection& sids,
const Sid::SidMapperInterface& sidMapper,
const Controller::ActiveCallsignCollection& activeCallsigns,
const Ownership::AirfieldServiceProviderCollection& airfieldOwnership,
const Controller::Login& login,
Expand Down Expand Up @@ -72,11 +71,8 @@ namespace UKControllerPlugin::InitialHeading {
Euroscope::EuroScopeCFlightPlanInterface& flightplan,
Euroscope::EuroScopeCRadarTargetInterface& radarTarget) -> bool;

auto GetSidForFlight(Euroscope::EuroScopeCFlightPlanInterface& flightplan)
-> std::shared_ptr<Sid::StandardInstrumentDeparture>;

// Used to generate initial headings.
const Sid::SidCollection& sids;
const Sid::SidMapperInterface& sidMapper;

// Used to find out the users callsign.
const Controller::ActiveCallsignCollection& activeCallsigns;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/initialheading/InitialHeadingModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace UKControllerPlugin::InitialHeading {
void BootstrapPlugin(PersistenceContainer& persistence)
{
std::shared_ptr<InitialHeadingEventHandler> handler(new InitialHeadingEventHandler(
*persistence.sids,
*persistence.sidMapper,
*persistence.activeCallsigns,
*persistence.airfieldOwnership,
*persistence.login,
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/prenote/PrenoteModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace UKControllerPlugin::Prenote {
*persistence.controllerHierarchyFactory);

mapper = std::make_unique<PublishedPrenoteMapper>(
*prenotes, *persistence.airfields, *persistence.sids, *persistence.flightRules);
*prenotes, *persistence.airfields, *persistence.sidMapper, *persistence.flightRules);

ControllerPositionHierarchyFactory hierarchyFactory(*persistence.controllerPositions);

Expand Down