Skip to content

Commit

Permalink
feat(intention): Hern intention codes
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyTWF committed May 19, 2022
2 parents 45a1226 + fc5d50a commit 966a445
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 171 deletions.
75 changes: 29 additions & 46 deletions src/plugin/intention/SectorExitPointLelna.cpp
@@ -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
43 changes: 20 additions & 23 deletions src/plugin/intention/SectorExitPointLelna.h
@@ -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
4 changes: 2 additions & 2 deletions src/plugin/intention/SectorExitRepositoryFactory.cpp
Expand Up @@ -139,8 +139,8 @@ namespace UKControllerPlugin {

// Hern
points["ORTAC"] = std::make_unique<SectorExitPoint>("ORTAC", "H", SectorExitPoint::outSouth);
points["LORKU"] = std::make_unique<SectorExitPoint>("LORKU", "H4", SectorExitPoint::outSouth);
points["LELNA"] = std::make_unique<SectorExitPointLelna>("LELNA", "H2", SectorExitPoint::outSouth);
points["LORKU"] = std::make_unique<SectorExitPoint>("LORKU", "H9", SectorExitPoint::outSouth);
points["LELNA"] = std::make_unique<SectorExitPointLelna>("LELNA", "H8", SectorExitPoint::outSouth);

// Paris
points["NEVIL"] = std::make_unique<SectorExitPoint>("NEVIL", "W", SectorExitPoint::outSouth);
Expand Down
144 changes: 46 additions & 98 deletions test/plugin/intention/SectorExitPointLelnaTest.cpp
@@ -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
4 changes: 2 additions & 2 deletions test/plugin/intention/SectorExitRepositoryTest.cpp
Expand Up @@ -410,12 +410,12 @@ namespace UKControllerPluginTest {

// LORKU
ASSERT_TRUE(repo->GetSectorExitPoint("LORKU").GetName().compare("LORKU") == 0);
ASSERT_TRUE(repo->GetSectorExitPoint("LORKU").GetIntentionCode(mockRoute, -1, 37000).compare("H4") == 0);
ASSERT_TRUE(repo->GetSectorExitPoint("LORKU").GetIntentionCode(mockRoute, -1, 37000).compare("H9") == 0);
ASSERT_EQ(repo->outSouth, repo->GetSectorExitPoint("LORKU").GetOutDirection());

// LELNA
ASSERT_TRUE(repo->GetSectorExitPoint("LELNA").GetName().compare("LELNA") == 0);
ASSERT_TRUE(repo->GetSectorExitPoint("LELNA").GetIntentionCode(mockRoute, -1, 37000).compare("H2") == 0);
ASSERT_TRUE(repo->GetSectorExitPoint("LELNA").GetIntentionCode(mockRoute, -1, 37000).compare("H8") == 0);
ASSERT_EQ(repo->outSouth, repo->GetSectorExitPoint("LELNA").GetOutDirection());

// Paris
Expand Down

0 comments on commit 966a445

Please sign in to comment.