Skip to content

Commit

Permalink
Implement Line 4 tag elements (#24)
Browse files Browse the repository at this point in the history
* Approach/Departure: Arrival Runway and Approach or SID
* Aerodrome: Arrival Runway and Approach
* Terminal/Area: Arrival Runway, Route Abbreviation, Gate ETA and AMAN delay
  • Loading branch information
arthuwu authored Jul 12, 2024
1 parent 6294234 commit 7c8de6b
Show file tree
Hide file tree
Showing 53 changed files with 25,241 additions and 26 deletions.
569 changes: 550 additions & 19 deletions AT3/AT3Tags.cpp

Large diffs are not rendered by default.

40 changes: 37 additions & 3 deletions AT3/AT3Tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,17 @@
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <fstream>
#include <nlohmann/json.hpp>
#include "MAESTROapi.h"
#include <chrono>
#include <ctime>

using namespace std;
using namespace EuroScopePlugIn;
using json = nlohmann::json;

class AT3Tags :
public EuroScopePlugIn::CPlugIn
Expand All @@ -30,6 +37,21 @@ class AT3Tags :
POINT Pt,
RECT Area);

virtual void OnFlightPlanControllerAssignedDataUpdate(CFlightPlan FlightPlan,
int DataType);

virtual void OnTimer(int Counter);

void SetApp(int index, CFlightPlan FlightPlan, vector<string> appsVec);

void SetRte(int index, CFlightPlan FlightPlan, vector<string> rteVec, string dest, string destRunway);

string GetActiveArrRwy(string airport);

vector<string> GetAvailableApps(string airport, string runway);

vector<string> GetAvailableRtes(string airport, string runway);

string GetFormattedAltitude(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

string GetFormattedAltitudedAssigned(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);
Expand All @@ -42,19 +64,31 @@ class AT3Tags :

string GetFormattedSpeedAssigned(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

string GetRouteCode(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);
void GetRouteCode(CFlightPlan& FlightPlan);

string GetRouteCodeLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

void GetAssignedAPP(CFlightPlan& FlightPlan);

string GetAPPDEPLine4(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

string GetAMCLine4 (CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

string GetFormattedSlot(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);
string GetFormattedETA(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget, int minutes);

string GetAMANDelay(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

string GetCallsign(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

string GetATYPWTC(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

string GetVSIndicator(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

string GetArrivalRwy(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);
string GetFormattedArrivalRwy(CFlightPlan& FlightPlan, CRadarTarget& RadarTarget);

protected:
int minu;
json appsJson;
json rteJson;
set<string> arptSet;
};
17 changes: 15 additions & 2 deletions Constant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@ const int TAG_ITEM_AT3_SPEED_ASSIGNED = 15;
const int TAG_ITEM_AT3_ROUTE_CODE = 16;
const int TAG_ITEM_AT3_APPDEP_LINE4 = 17;
const int TAG_ITEM_AT3_AMC_LINE4 = 18;
const int TAG_ITEM_AT3_SLOT = 19;
const int TAG_ITEM_AT3_ETA = 19;
const int TAG_ITEM_AT3_CALLSIGN = 20;
const int TAG_ITEM_AT3_ATYPWTC = 21;
const int TAG_ITEM_AT3_ATYPWTC = 21;
const int TAG_ITEM_AT3_VS_INDICATOR = 22;
const int TAG_ITEM_AT3_ARRIVAL_RWY = 23;
const int TAG_ITEM_AT3_DELAY = 24;

const int TAG_FUNC_APP_SEL_MENU = 200;
const int TAG_FUNC_APP_SEL_ITEM_1 = 201;
Expand All @@ -38,6 +39,18 @@ const int TAG_FUNC_APP_SEL_ITEM_5 = 205;
const int TAG_FUNC_APP_SEL_ITEM_6 = 206;
const int TAG_FUNC_APP_SEL_ITEM_7 = 207;
const int TAG_FUNC_APP_SEL_ITEM_8 = 208;
const int TAG_FUNC_APP_SEL_DUMMY = 209;

const int TAG_FUNC_RTE_SEL_MENU = 300;
const int TAG_FUNC_RTE_SEL_ITEM_1 = 301;
const int TAG_FUNC_RTE_SEL_ITEM_2 = 302;
const int TAG_FUNC_RTE_SEL_ITEM_3 = 303;
const int TAG_FUNC_RTE_SEL_ITEM_4 = 304;
const int TAG_FUNC_RTE_SEL_ITEM_5 = 305;
const int TAG_FUNC_RTE_SEL_ITEM_6 = 306;
const int TAG_FUNC_RTE_SEL_ITEM_7 = 307;
const int TAG_FUNC_RTE_SEL_ITEM_8 = 308;
const int TAG_FUNC_RTE_SEL_DUMMY = 309;

const int TAG_FUNC_CHECKFP_MENU = 100;
const int TAG_FUNC_CHECKFP_CHECK = 101;
Expand Down
6 changes: 6 additions & 0 deletions HKCP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,22 @@ CRadarScreen* HKCPPlugin::OnRadarScreenCreated(const char* sDisplayName, bool Ne

void HKCPPlugin::OnFunctionCall(int FunctionId, const char* ItemString, POINT Pt, RECT Area) {
VFPC->OnFunctionCall(FunctionId, ItemString, Pt, Area);
tags->OnFunctionCall(FunctionId, ItemString, Pt, Area);
}

void HKCPPlugin::OnGetTagItem(CFlightPlan FlightPlan, CRadarTarget RadarTarget, int ItemCode, int TagData, char sItemString[16], int* pColorCode, COLORREF* pRGB, double* pFontSize) {
VFPC->OnGetTagItem(FlightPlan, RadarTarget, ItemCode, TagData, sItemString, pColorCode, pRGB, pFontSize);
tags->OnGetTagItem(FlightPlan, RadarTarget, ItemCode, TagData, sItemString, pColorCode, pRGB, pFontSize);
}

void HKCPPlugin::OnFlightPlanControllerAssignedDataUpdate(CFlightPlan FlightPlan, int DataType) {
tags->OnFlightPlanControllerAssignedDataUpdate(FlightPlan, DataType);
}

void HKCPPlugin::OnTimer(int Count) {
VFPC->OnTimer(Count);
Atis->OnTimer(Count);
tags->OnTimer(Count);
}

void HKCPPlugin::OnFlightPlanDisconnect(CFlightPlan FlightPlan) {
Expand Down
2 changes: 2 additions & 0 deletions HKCP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class HKCPPlugin :
COLORREF* pRGB,
double* pFontSize);

virtual void OnFlightPlanControllerAssignedDataUpdate(CFlightPlan FlightPlan, int DataType);

virtual void OnFlightPlanDisconnect(CFlightPlan FlightPlan);

virtual bool OnCompileCommand(const char* sCommandLine);
Expand Down
4 changes: 2 additions & 2 deletions HKCP.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
<PreprocessorDefinitions>WIN32;NDEBUG;EDFFCHECKFP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions); CURL_STATICLIB</PreprocessorDefinitions>
<PreprocessorDefinitions>WIN32;NDEBUG;EDFFCHECKFP_EXPORTS;_WINDOWS;_USRDLL;%(PreprocessorDefinitions);CURL_STATICLIB;_CRT_SECURE_NO_WARNINGS</PreprocessorDefinitions>
<ConformanceMode>true</ConformanceMode>
<PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>
<AdditionalIncludeDirectories>$(ProjectDir)Libs;$(ProjectDir)Libs\include;$(ProjectDir)</AdditionalIncludeDirectories>
Expand All @@ -177,7 +177,7 @@
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableUAC>false</EnableUAC>
<AdditionalDependencies>$(ProjectDir)Libs\EuroScopePlugInDll.lib; winmm.lib; $(ProjectDir)Libs\libcurl_a.lib; Ws2_32.lib;Crypt32.lib; Wldap32.lib; Normaliz.lib </AdditionalDependencies>
<AdditionalDependencies>$(ProjectDir)Libs\EuroScopePlugInDll.lib;$(ProjectDir)Libs\MAESTRO.lib;winmm.lib;$(ProjectDir)Libs\libcurl_a.lib;Ws2_32.lib;Crypt32.lib;Wldap32.lib;Normaliz.lib</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
Expand Down
Binary file added Libs/MAESTRO.lib
Binary file not shown.
17 changes: 17 additions & 0 deletions Libs/MAESTROapi.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#pragma once

#ifndef MAESTROapi
#define MAESTROapi __declspec ( dllimport )
#endif

extern "C" MAESTROapi bool IsInSequence( const char * callsign ) ;
// return value: true if the callsign (case sensitive!) is found in the sequence
// false otherwise

extern "C" MAESTROapi double GetCurrentDelay( const char * callsign ) ;
// return value: current (remaining) delay in minutes if the callsign (case sensitive!) is found in the sequence
// 0 otherwise

extern "C" MAESTROapi double GetTotalDelay( const char * callsign ) ;
// return value: total delay in minutes if the callsign (case sensitive!) is found in the sequence
// 0 otherwise
55 changes: 55 additions & 0 deletions Libs/include/nlohmann/adl_serializer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT

#pragma once

#include <utility>

#include <nlohmann/detail/abi_macros.hpp>
#include <nlohmann/detail/conversions/from_json.hpp>
#include <nlohmann/detail/conversions/to_json.hpp>
#include <nlohmann/detail/meta/identity_tag.hpp>

NLOHMANN_JSON_NAMESPACE_BEGIN

/// @sa https://json.nlohmann.me/api/adl_serializer/
template<typename ValueType, typename>
struct adl_serializer
{
/// @brief convert a JSON value to any value type
/// @sa https://json.nlohmann.me/api/adl_serializer/from_json/
template<typename BasicJsonType, typename TargetType = ValueType>
static auto from_json(BasicJsonType && j, TargetType& val) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), val)))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), val), void())
{
::nlohmann::from_json(std::forward<BasicJsonType>(j), val);
}

/// @brief convert a JSON value to any value type
/// @sa https://json.nlohmann.me/api/adl_serializer/from_json/
template<typename BasicJsonType, typename TargetType = ValueType>
static auto from_json(BasicJsonType && j) noexcept(
noexcept(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {})))
-> decltype(::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {}))
{
return ::nlohmann::from_json(std::forward<BasicJsonType>(j), detail::identity_tag<TargetType> {});
}

/// @brief convert any value type to a JSON value
/// @sa https://json.nlohmann.me/api/adl_serializer/to_json/
template<typename BasicJsonType, typename TargetType = ValueType>
static auto to_json(BasicJsonType& j, TargetType && val) noexcept(
noexcept(::nlohmann::to_json(j, std::forward<TargetType>(val))))
-> decltype(::nlohmann::to_json(j, std::forward<TargetType>(val)), void())
{
::nlohmann::to_json(j, std::forward<TargetType>(val));
}
};

NLOHMANN_JSON_NAMESPACE_END
103 changes: 103 additions & 0 deletions Libs/include/nlohmann/byte_container_with_subtype.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
// __ _____ _____ _____
// __| | __| | | | JSON for Modern C++
// | | |__ | | | | | | version 3.11.3
// |_____|_____|_____|_|___| https://github.com/nlohmann/json
//
// SPDX-FileCopyrightText: 2013-2023 Niels Lohmann <https://nlohmann.me>
// SPDX-License-Identifier: MIT

#pragma once

#include <cstdint> // uint8_t, uint64_t
#include <tuple> // tie
#include <utility> // move

#include <nlohmann/detail/abi_macros.hpp>

NLOHMANN_JSON_NAMESPACE_BEGIN

/// @brief an internal type for a backed binary type
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/
template<typename BinaryType>
class byte_container_with_subtype : public BinaryType
{
public:
using container_type = BinaryType;
using subtype_type = std::uint64_t;

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype() noexcept(noexcept(container_type()))
: container_type()
{}

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype(const container_type& b) noexcept(noexcept(container_type(b)))
: container_type(b)
{}

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype(container_type&& b) noexcept(noexcept(container_type(std::move(b))))
: container_type(std::move(b))
{}

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype(const container_type& b, subtype_type subtype_) noexcept(noexcept(container_type(b)))
: container_type(b)
, m_subtype(subtype_)
, m_has_subtype(true)
{}

/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/byte_container_with_subtype/
byte_container_with_subtype(container_type&& b, subtype_type subtype_) noexcept(noexcept(container_type(std::move(b))))
: container_type(std::move(b))
, m_subtype(subtype_)
, m_has_subtype(true)
{}

bool operator==(const byte_container_with_subtype& rhs) const
{
return std::tie(static_cast<const BinaryType&>(*this), m_subtype, m_has_subtype) ==
std::tie(static_cast<const BinaryType&>(rhs), rhs.m_subtype, rhs.m_has_subtype);
}

bool operator!=(const byte_container_with_subtype& rhs) const
{
return !(rhs == *this);
}

/// @brief sets the binary subtype
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/set_subtype/
void set_subtype(subtype_type subtype_) noexcept
{
m_subtype = subtype_;
m_has_subtype = true;
}

/// @brief return the binary subtype
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/subtype/
constexpr subtype_type subtype() const noexcept
{
return m_has_subtype ? m_subtype : static_cast<subtype_type>(-1);
}

/// @brief return whether the value has a subtype
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/has_subtype/
constexpr bool has_subtype() const noexcept
{
return m_has_subtype;
}

/// @brief clears the binary subtype
/// @sa https://json.nlohmann.me/api/byte_container_with_subtype/clear_subtype/
void clear_subtype() noexcept
{
m_subtype = 0;
m_has_subtype = false;
}

private:
subtype_type m_subtype = 0;
bool m_has_subtype = false;
};

NLOHMANN_JSON_NAMESPACE_END
Loading

0 comments on commit 7c8de6b

Please sign in to comment.