Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(intention): Hern intention codes
- Loading branch information
Showing
5 changed files
with
99 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,39 @@ | ||
#include "pch/pch.h" | ||
#include "intention/SectorExitPointLelna.h" | ||
#include "SectorExitPointLelna.h" | ||
#include "euroscope/EuroscopeExtractedRouteInterface.h" | ||
#include "intention/IntentionCodeGenerator.h" | ||
|
||
using UKControllerPlugin::IntentionCode::IntentionCodeGenerator; | ||
using UKControllerPlugin::Euroscope::EuroscopeExtractedRouteInterface; | ||
|
||
namespace UKControllerPlugin { | ||
namespace IntentionCode { | ||
|
||
/* | ||
Look at the rest of the route to see where the aircraft goes in order to determine | ||
the intention code. | ||
*/ | ||
std::string SectorExitPointLelna::GetIntentionCode( | ||
EuroscopeExtractedRouteInterface & route, | ||
int foundPointIndex, | ||
int cruiseLevel | ||
) const { | ||
const int numberOfPointsInRoute = route.GetPointsNumber(); | ||
|
||
// The arrival airport is always the last point on the route | ||
if (numberOfPointsInRoute >= 2) | ||
{ | ||
std::string arrivalAirport = route.GetPointName(numberOfPointsInRoute - 1); | ||
if (arrivalAirport.substr(0, 3) == "LFR" && arrivalAirport != "LFRC") | ||
{ | ||
return "H5"; | ||
} | ||
|
||
if (arrivalAirport == "LFRC") | ||
{ | ||
return "JC"; | ||
} | ||
namespace UKControllerPlugin::IntentionCode { | ||
|
||
/* | ||
Look at the rest of the route to see where the aircraft goes in order to determine | ||
the intention code. | ||
*/ | ||
std::string SectorExitPointLelna::GetIntentionCode( | ||
EuroscopeExtractedRouteInterface& route, int foundPointIndex, int cruiseLevel) const | ||
{ | ||
const int numberOfPointsInRoute = route.GetPointsNumber(); | ||
|
||
// The arrival airport is always the last point on the route | ||
if (numberOfPointsInRoute >= 2) { | ||
std::string arrivalAirport = route.GetPointName(numberOfPointsInRoute - 1); | ||
if (arrivalAirport.substr(0, 3) == "LFR" && arrivalAirport != "LFRC") { | ||
return "H7"; | ||
} | ||
|
||
while (foundPointIndex < numberOfPointsInRoute) { | ||
if (strcmp(route.GetPointName(foundPointIndex), "DIN") == 0) { | ||
return "H2"; | ||
} | ||
|
||
// Not ARE, but the airway continues to there. | ||
if (strcmp(route.GetPointName(foundPointIndex), "DOMOK") == 0 || | ||
strcmp(route.GetPointName(foundPointIndex), "ARE") == 0 | ||
) { | ||
return "H3"; | ||
} | ||
if (arrivalAirport == "LFRC") { | ||
return "JC"; | ||
} | ||
} | ||
|
||
foundPointIndex++; | ||
while (foundPointIndex < numberOfPointsInRoute) { | ||
if (strcmp(route.GetPointName(foundPointIndex), "DOMOK") == 0) { | ||
return "H6"; | ||
} | ||
|
||
return SectorExitPoint::GetIntentionCode(route, foundPointIndex, cruiseLevel); | ||
foundPointIndex++; | ||
} | ||
} // namespace IntentionCode | ||
} // namespace UKControllerPlugin | ||
|
||
return SectorExitPoint::GetIntentionCode(route, foundPointIndex, cruiseLevel); | ||
} | ||
} // namespace UKControllerPlugin::IntentionCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,25 @@ | ||
#pragma once | ||
#include "intention/SectorExitPoint.h" | ||
#include "SectorExitPoint.h" | ||
|
||
namespace UKControllerPlugin { | ||
namespace Euroscope { | ||
class EuroscopeExtractedRouteInterface; | ||
} // namespace Euroscope | ||
} // namespace UKControllerPlugin | ||
namespace UKControllerPlugin::Euroscope { | ||
class EuroscopeExtractedRouteInterface; | ||
} // namespace UKControllerPlugin::Euroscope | ||
|
||
namespace UKControllerPlugin { | ||
namespace IntentionCode { | ||
namespace UKControllerPlugin::IntentionCode { | ||
|
||
/* | ||
Special class to handle the LELNA SectorExitPoint. | ||
*/ | ||
class SectorExitPointLelna : public SectorExitPoint | ||
/* | ||
Special class to handle the LELNA SectorExitPoint. | ||
*/ | ||
class SectorExitPointLelna : public SectorExitPoint | ||
{ | ||
public: | ||
SectorExitPointLelna(std::string name, std::string intentionCode, unsigned int outDirection) | ||
: SectorExitPoint(name, intentionCode, outDirection) | ||
{ | ||
public: | ||
SectorExitPointLelna(std::string name, std::string intentionCode, unsigned int outDirection) | ||
: SectorExitPoint(name, intentionCode, outDirection) {} // namespace IntentionCode | ||
std::string GetIntentionCode( | ||
UKControllerPlugin::Euroscope::EuroscopeExtractedRouteInterface & route, | ||
int foundPointIndex, | ||
int cruiseLevel | ||
) const override; | ||
}; | ||
} // namespace IntentionCode | ||
} // namespace UKControllerPlugin | ||
} // namespace IntentionCode | ||
std::string GetIntentionCode( | ||
UKControllerPlugin::Euroscope::EuroscopeExtractedRouteInterface& route, | ||
int foundPointIndex, | ||
int cruiseLevel) const override; | ||
}; | ||
} // namespace UKControllerPlugin::IntentionCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,56 @@ | ||
#include "intention/SectorExitPointLelna.h" | ||
#include "intention/IntentionCodeGenerator.h" | ||
|
||
using ::testing::NiceMock; | ||
using ::testing::Return; | ||
using ::testing::StrictMock; | ||
using UKControllerPlugin::IntentionCode::IntentionCodeGenerator; | ||
using UKControllerPlugin::IntentionCode::SectorExitPointLelna; | ||
using UKControllerPluginTest::Euroscope::MockEuroscopeExtractedRouteInterface; | ||
|
||
namespace UKControllerPluginTest { | ||
namespace IntentionCode { | ||
namespace UKControllerPluginTest::IntentionCode { | ||
|
||
TEST(SectorExitPointLelna, ItAppliesToAllControllers) | ||
class SectorExitPointLelnaTest : public testing::Test | ||
{ | ||
public: | ||
SectorExitPointLelnaTest() : exitPoint("LELNA", "H8", SectorExitPointLelna::outSouth) | ||
{ | ||
StrictMock<MockEuroscopeExtractedRouteInterface> routeMock; | ||
SectorExitPointLelna exitPoint("LELNA", "H2", SectorExitPointLelna::outSouth); | ||
|
||
EXPECT_TRUE(exitPoint.AppliesToController("BLA")); | ||
} | ||
|
||
TEST(SectorExitPointLelna, GetIntentionCodeReturnsCorrectDefaultCodeLelna) | ||
{ | ||
StrictMock<MockEuroscopeExtractedRouteInterface> routeMock; | ||
SectorExitPointLelna exitPoint("LELNA", "H2", SectorExitPointLelna::outSouth); | ||
|
||
EXPECT_CALL(routeMock, GetPointsNumber()).Times(1).WillRepeatedly(Return(2)); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(0)).Times(3).WillRepeatedly(Return("LELNA")); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(1)).Times(4).WillRepeatedly(Return("LFMN")); | ||
|
||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 37000).compare("H2")); | ||
} | ||
|
||
TEST(SectorExitPointLelna, GetIntentionCodeReturnsCorrectSecondaryCodeDinard) | ||
{ | ||
StrictMock<MockEuroscopeExtractedRouteInterface> routeMock; | ||
SectorExitPointLelna exitPoint("LELNA", "H2", SectorExitPointLelna::outSouth); | ||
|
||
EXPECT_CALL(routeMock, GetPointsNumber()).Times(1).WillRepeatedly(Return(3)); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(0)).Times(3).WillRepeatedly(Return("LELNA")); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(1)).Times(1).WillRepeatedly(Return("DIN")); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(2)).Times(1).WillRepeatedly(Return("LEMD")); | ||
|
||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 37000).compare("H2")); | ||
} | ||
|
||
TEST(SectorExitPointLelna, GetIntentionCodeReturnsCorrectSecondaryCodeArree) | ||
{ | ||
StrictMock<MockEuroscopeExtractedRouteInterface> routeMock; | ||
SectorExitPointLelna exitPoint("LELNA", "H2", SectorExitPointLelna::outSouth); | ||
|
||
EXPECT_CALL(routeMock, GetPointsNumber()).Times(1).WillRepeatedly(Return(3)); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(0)).Times(3).WillRepeatedly(Return("LELNA")); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(1)).Times(3).WillRepeatedly(Return("ARE")); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(2)).Times(1).WillRepeatedly(Return("LEMD")); | ||
|
||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 37000).compare("H3")); | ||
} | ||
|
||
TEST(SectorExitPointLelna, GetIntentionCodeReturnsCorrectSecondaryCodeDomok) | ||
{ | ||
StrictMock<MockEuroscopeExtractedRouteInterface> routeMock; | ||
SectorExitPointLelna exitPoint("LELNA", "H2", SectorExitPointLelna::outSouth); | ||
|
||
EXPECT_CALL(routeMock, GetPointsNumber()).Times(1).WillRepeatedly(Return(3)); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(0)).Times(3).WillRepeatedly(Return("LELNA")); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(1)).Times(2).WillRepeatedly(Return("DOMOK")); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(2)).Times(1).WillRepeatedly(Return("LEMD")); | ||
|
||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 37000).compare("H3")); | ||
} | ||
|
||
TEST(SectorExitPointLelna, GetIntentionCodeReturnsCorrectIntentionCodeForBrestFirArrivals) | ||
{ | ||
StrictMock<MockEuroscopeExtractedRouteInterface> routeMock; | ||
SectorExitPointLelna exitPoint("LELNA", "H2", SectorExitPointLelna::outSouth); | ||
|
||
EXPECT_CALL(routeMock, GetPointsNumber()).Times(1).WillRepeatedly(Return(3)); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(2)).Times(1).WillRepeatedly(Return("LFRO")); | ||
|
||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 37000).compare("H5")); | ||
} | ||
|
||
TEST(SectorExitPointLelna, GetIntentionCodeReturnsCorrectIntentionCodeForCherbourgArrivals) | ||
{ | ||
StrictMock<MockEuroscopeExtractedRouteInterface> routeMock; | ||
SectorExitPointLelna exitPoint("LELNA", "H5", SectorExitPointLelna::outSouth); | ||
|
||
EXPECT_CALL(routeMock, GetPointsNumber()).Times(1).WillRepeatedly(Return(3)); | ||
|
||
EXPECT_CALL(routeMock, GetPointName(2)).Times(1).WillRepeatedly(Return("LFRC")); | ||
|
||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 25000).compare("JC")); | ||
} | ||
|
||
} // namespace IntentionCode | ||
} // namespace UKControllerPluginTest | ||
NiceMock<MockEuroscopeExtractedRouteInterface> routeMock; | ||
SectorExitPointLelna exitPoint; | ||
}; | ||
|
||
TEST_F(SectorExitPointLelnaTest, ItAppliesToAllControllers) | ||
{ | ||
EXPECT_TRUE(exitPoint.AppliesToController("BLA")); | ||
} | ||
|
||
TEST_F(SectorExitPointLelnaTest, GetIntentionCodeReturnsCorrectDefaultCodeLelna) | ||
{ | ||
ON_CALL(routeMock, GetPointsNumber()).WillByDefault(Return(2)); | ||
ON_CALL(routeMock, GetPointName(0)).WillByDefault(Return("LELNA")); | ||
ON_CALL(routeMock, GetPointName(1)).WillByDefault(Return("LFMN")); | ||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 37000).compare("H8")); | ||
} | ||
|
||
TEST_F(SectorExitPointLelnaTest, GetIntentionCodeReturnsCorrectSecondaryCodeDomok) | ||
{ | ||
ON_CALL(routeMock, GetPointsNumber()).WillByDefault(Return(3)); | ||
ON_CALL(routeMock, GetPointName(0)).WillByDefault(Return("LELNA")); | ||
ON_CALL(routeMock, GetPointName(1)).WillByDefault(Return("DOMOK")); | ||
ON_CALL(routeMock, GetPointName(2)).WillByDefault(Return("LEMD")); | ||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 37000).compare("H6")); | ||
} | ||
|
||
TEST_F(SectorExitPointLelnaTest, GetIntentionCodeReturnsCorrectIntentionCodeForBrestFirArrivals) | ||
{ | ||
ON_CALL(routeMock, GetPointsNumber()).WillByDefault(Return(3)); | ||
ON_CALL(routeMock, GetPointName(2)).WillByDefault(Return("LFRO")); | ||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 37000).compare("H7")); | ||
} | ||
|
||
TEST_F(SectorExitPointLelnaTest, GetIntentionCodeReturnsCorrectIntentionCodeForCherbourgArrivals) | ||
{ | ||
ON_CALL(routeMock, GetPointsNumber()).WillByDefault(Return(3)); | ||
ON_CALL(routeMock, GetPointName(2)).WillByDefault(Return("LFRC")); | ||
EXPECT_EQ(0, exitPoint.GetIntentionCode(routeMock, 0, 25000).compare("JC")); | ||
} | ||
} // namespace UKControllerPluginTest::IntentionCode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters