diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fb538a8..dd0b8b0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,7 +9,7 @@ on: jobs: build: name: Build - runs-on: windows-latest + runs-on: windows-2019 concurrency: group: flow-sdk-build-${{ github.ref }} cancel-in-progress: true diff --git a/README.md b/README.md index 85c8fde..23a3003 100644 --- a/README.md +++ b/README.md @@ -4,15 +4,79 @@ A Software Development Kit (SDK) for the ECFMP Flow Control API ## Integrating With The SDK -Coming soon! +### Create a HTTP Client -## Building +Rather than ship with an opinionated viewpoint as to what you should use for HTTP requests, this SDK +provides an interface `HttpClient` that the HTTP client of your choice must implement. + +### Create a logger + +You can optionally pass the SDK a logging class that implements the `Logger` interface. This will allow you to log +messages from the SDK. + +### Create an instance of the SDK + +To create an instance of the SDK, you must use the `SDKFactory` class. This class will allow you to configure the SDK, +and +then create an instance of it. + +```c++ +#include "ECFMP/SDKFactory.h" +#include "ECFMP/SDK.h" + +auto http = std::make_shared(); +auto logger = std::make_shared(); +auto ecfmp = ECFMP::Plugin::SdkFactory::Build() + .WithLogger(logger) + .WithHttpClient(std::move(http)).Instance(); +``` + +### Add the SDK to EuroScopes timer event + +The SDK needs to be called periodically to process events. To do this, you must add the call to the EuroScopes timer +event. This is necessary because EuroScope requires that calls to its internal classes are made from the plugin thread +(as opposed to something asynchronous.) + +```c++ +void MyPlugin::OnTimer(int time) +{ + ecfmp.OnEuroscopeTimerTick(); +} +``` + +### Register event handlers + +You can register event handlers with the SDK. These event handlers will be called when the SDK processes an event. +These listeners must implement the `EventListener` interface. + +```c++ +auto eventListener = std::make_shared>(); +ecfmp.EventBus().Subscribe(eventListener); +``` + +## Testing Your Integration + +You can test your integration by making use of the mocks provided by the SDK. These mocks will allow you to simulate +events that would be sent by the ECFMP SDK. + +You can find the mocks in `include/mock`. + +## Known Limitations + +At the moment, the SDK has the following limitations: + +- The SDK does not support Event Participation filters on Flow Measures. This is because EuroScope does not provide + the CID of the aircraft that is being filtered on, and thus a way around this needs to be devised. + +## Development + +### Building This project builds using CMake. You can build using a command similar to below `cmake -DCMAKE_BUILD_TYPE= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_DEPENDS_USE_COMPILER=FALSE -G Ninja -Bbuild` -## Running Tests +### Running Tests Tests can be run using the `ctest` command, from the build directory: @@ -24,8 +88,13 @@ The SDK has the following design rationale. ### Event Driven -Similar to how EuroScope is event driven, so is this SDK. Integrations can register a series of event handlers with the SDK, which will pass on events, such as new Flow Measures for processing. +Similar to how EuroScope is event driven, so is this SDK. Integrations can register a series of event handlers with the +SDK, which will pass on events, such as new Flow Measures for processing. + +The SDK itself is also event driven, and uses an internal event bus to handle events. ### Async -EuroScope is a single-threaded application when it comes to plugins, therefore, anything that may take a while (e.g. HTTP requests) will be done aysynchronously. The results of these operations will be deferred for when the EuroScope thread comes back around, as EuroScope sometimes doesn't like things interacting with it asynchronously. +EuroScope is a single-threaded application when it comes to plugins, therefore, anything that may take a while (e.g. +HTTP requests) will be done asynchronously. The results of these operations will be deferred for when the EuroScope +thread comes back around, as EuroScope sometimes doesn't like things interacting with it asynchronously. diff --git a/include/ECFMP/flowmeasure/AirportFilter.h b/include/ECFMP/flowmeasure/AirportFilter.h index 26f7b50..90bee73 100644 --- a/include/ECFMP/flowmeasure/AirportFilter.h +++ b/include/ECFMP/flowmeasure/AirportFilter.h @@ -1,4 +1,5 @@ #pragma once +#include "ChecksAircraftApplicability.h" namespace ECFMP::FlowMeasure { @@ -11,7 +12,7 @@ namespace ECFMP::FlowMeasure { /** * A filter that pertains to arrival or departure airports */ - class AirportFilter + class AirportFilter : public ChecksAircraftApplicability { public: virtual ~AirportFilter() = default; diff --git a/include/ECFMP/flowmeasure/ChecksAircraftApplicability.h b/include/ECFMP/flowmeasure/ChecksAircraftApplicability.h new file mode 100644 index 0000000..0dd06e8 --- /dev/null +++ b/include/ECFMP/flowmeasure/ChecksAircraftApplicability.h @@ -0,0 +1,19 @@ +#pragma once + +namespace ECFMP::Euroscope { + class EuroscopeAircraft; +}// namespace ECFMP::Euroscope + +namespace ECFMP::FlowMeasure { + class ChecksAircraftApplicability + { + public: + virtual ~ChecksAircraftApplicability() = default; + + /** + * Returns whether the given aircraft is applicable to this filter. + */ + [[nodiscard]] virtual auto ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept + -> bool = 0; + }; +}// namespace ECFMP::FlowMeasure diff --git a/include/ECFMP/flowmeasure/EventFilter.h b/include/ECFMP/flowmeasure/EventFilter.h index df37458..db62ffe 100644 --- a/include/ECFMP/flowmeasure/EventFilter.h +++ b/include/ECFMP/flowmeasure/EventFilter.h @@ -1,4 +1,5 @@ #pragma once +#include "ChecksAircraftApplicability.h" namespace ECFMP::Event { class Event; @@ -19,7 +20,7 @@ namespace ECFMP::FlowMeasure { /** * A filter that pertains to participation in an event. */ - class EventFilter + class EventFilter : public ChecksAircraftApplicability { public: virtual ~EventFilter() = default; diff --git a/include/ECFMP/flowmeasure/FlowMeasure.h b/include/ECFMP/flowmeasure/FlowMeasure.h index b7f041e..86e61f4 100644 --- a/include/ECFMP/flowmeasure/FlowMeasure.h +++ b/include/ECFMP/flowmeasure/FlowMeasure.h @@ -10,6 +10,11 @@ namespace ECFMP { }// namespace FlightInformationRegion }// namespace ECFMP +namespace EuroScopePlugIn { + class CFlightPlan; + class CRadarTarget; +}// namespace EuroScopePlugIn + namespace ECFMP::FlowMeasure { class FlowMeasureFilters; class Measure; @@ -115,5 +120,13 @@ namespace ECFMP::FlowMeasure { // Information about the canonical nature of the flow measure [[nodiscard]] virtual auto CanonicalInformation() const noexcept -> const CanonicalFlowMeasureInfo& = 0; + + /** + * Returns true if the flow measure is applicable to the given aircraft. It will be applicable if all + * of the filters are applicable. + */ + [[nodiscard]] virtual auto ApplicableToAircraft( + const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ) const -> bool = 0; }; }// namespace ECFMP::FlowMeasure diff --git a/include/ECFMP/flowmeasure/FlowMeasureFilters.h b/include/ECFMP/flowmeasure/FlowMeasureFilters.h index 65c8cd0..cd0088d 100644 --- a/include/ECFMP/flowmeasure/FlowMeasureFilters.h +++ b/include/ECFMP/flowmeasure/FlowMeasureFilters.h @@ -4,6 +4,11 @@ namespace ECFMP::FlightInformationRegion { class FlightInformationRegion; }// namespace ECFMP::FlightInformationRegion +namespace EuroScopePlugIn { + class CFlightPlan; + class CRadarTarget; +}// namespace EuroScopePlugIn + namespace ECFMP::FlowMeasure { class AirportFilter; @@ -27,6 +32,14 @@ namespace ECFMP::FlowMeasure { */ [[nodiscard]] virtual auto ApplicableToAirport(const std::string& airfield) const noexcept -> bool = 0; + /** + * Returns true if the flow measure is applicable to the given aircraft. It will be applicable if all + * of the filters are applicable. + */ + [[nodiscard]] virtual auto ApplicableToAircraft( + const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ) const -> bool = 0; + /** * Methods that allow for iteration of the filters. */ diff --git a/include/ECFMP/flowmeasure/LevelRangeFilter.h b/include/ECFMP/flowmeasure/LevelRangeFilter.h index aaf2b6d..c79d40a 100644 --- a/include/ECFMP/flowmeasure/LevelRangeFilter.h +++ b/include/ECFMP/flowmeasure/LevelRangeFilter.h @@ -1,4 +1,5 @@ #pragma once +#include "ChecksAircraftApplicability.h" namespace ECFMP::FlowMeasure { @@ -11,7 +12,7 @@ namespace ECFMP::FlowMeasure { /** * A filter that pertains to the cruising level of the aircraft. */ - class LevelRangeFilter + class LevelRangeFilter : public ChecksAircraftApplicability { public: virtual ~LevelRangeFilter() = default; diff --git a/include/ECFMP/flowmeasure/MultipleLevelFilter.h b/include/ECFMP/flowmeasure/MultipleLevelFilter.h index 2d3a03b..941bb57 100644 --- a/include/ECFMP/flowmeasure/MultipleLevelFilter.h +++ b/include/ECFMP/flowmeasure/MultipleLevelFilter.h @@ -1,10 +1,11 @@ #pragma once +#include "ChecksAircraftApplicability.h" namespace ECFMP::FlowMeasure { /** * A filter that pertains to the cruising level of the aircraft. */ - class MultipleLevelFilter + class MultipleLevelFilter : public ChecksAircraftApplicability { public: virtual ~MultipleLevelFilter() = default; diff --git a/include/ECFMP/flowmeasure/RangeToDestinationFilter.h b/include/ECFMP/flowmeasure/RangeToDestinationFilter.h index 6c0b1ae..a6e2fa2 100644 --- a/include/ECFMP/flowmeasure/RangeToDestinationFilter.h +++ b/include/ECFMP/flowmeasure/RangeToDestinationFilter.h @@ -1,10 +1,11 @@ #pragma once +#include "ChecksAircraftApplicability.h" namespace ECFMP::FlowMeasure { /** * A filter that pertains to arrival or departure airports */ - class RangeToDestinationFilter + class RangeToDestinationFilter : public ChecksAircraftApplicability { public: virtual ~RangeToDestinationFilter() = default; diff --git a/include/ECFMP/flowmeasure/RouteFilter.h b/include/ECFMP/flowmeasure/RouteFilter.h index e0e98a6..90741a0 100644 --- a/include/ECFMP/flowmeasure/RouteFilter.h +++ b/include/ECFMP/flowmeasure/RouteFilter.h @@ -1,10 +1,11 @@ #pragma once +#include "ChecksAircraftApplicability.h" namespace ECFMP::FlowMeasure { /** * A filter that pertains to aircraft on particular routes. */ - class RouteFilter + class RouteFilter : public ChecksAircraftApplicability { public: virtual ~RouteFilter() = default; diff --git a/include/mock/AirportFilterMock.h b/include/mock/AirportFilterMock.h index e4d1b9c..32d625c 100644 --- a/include/mock/AirportFilterMock.h +++ b/include/mock/AirportFilterMock.h @@ -10,6 +10,7 @@ namespace ECFMP::Mock::FlowMeasure { MOCK_METHOD(const std::set&, AirportStrings, (), (const, noexcept, override)); MOCK_METHOD(ECFMP::FlowMeasure::AirportFilterType, Type, (), (const, noexcept, override)); MOCK_METHOD(bool, ApplicableToAirport, (const std::string&), (const, noexcept, override)); + MOCK_METHOD(bool, ApplicableToAircraft, (const Euroscope::EuroscopeAircraft&), (const, noexcept, override)); }; }// namespace ECFMP::Mock::FlowMeasure diff --git a/include/mock/EventFilterMock.h b/include/mock/EventFilterMock.h index 943a759..ca3a158 100644 --- a/include/mock/EventFilterMock.h +++ b/include/mock/EventFilterMock.h @@ -11,6 +11,7 @@ namespace ECFMP::Mock::FlowMeasure { MOCK_METHOD(const ECFMP::Event::Event&, Event, (), (const, noexcept, override)); MOCK_METHOD(ECFMP::FlowMeasure::EventParticipation, Participation, (), (const, noexcept, override)); MOCK_METHOD(bool, IsParticipating, (), (const, noexcept, override)); + MOCK_METHOD(bool, ApplicableToAircraft, (const Euroscope::EuroscopeAircraft&), (const, noexcept, override)); }; }// namespace ECFMP::Mock::FlowMeasure diff --git a/include/mock/FlowMeasureFiltersMock.h b/include/mock/FlowMeasureFiltersMock.h index 0529369..fb2d42d 100644 --- a/include/mock/FlowMeasureFiltersMock.h +++ b/include/mock/FlowMeasureFiltersMock.h @@ -9,6 +9,10 @@ namespace ECFMP::Mock::FlowMeasure { { public: MOCK_METHOD(bool, ApplicableToAirport, (const std::string&), (const, noexcept, override)); + MOCK_METHOD( + bool, ApplicableToAircraft, (const EuroScopePlugIn::CFlightPlan&, const EuroScopePlugIn::CRadarTarget&), + (const, noexcept, override) + ); MOCK_METHOD( void, ForEachAirportFilter, (const std::function&), (const, noexcept, override) diff --git a/include/mock/FlowMeasureMock.h b/include/mock/FlowMeasureMock.h index 9a251a8..455301f 100644 --- a/include/mock/FlowMeasureMock.h +++ b/include/mock/FlowMeasureMock.h @@ -31,6 +31,10 @@ namespace ECFMP::Mock::FlowMeasure { (const ECFMP::FlightInformationRegion::FlightInformationRegion&), (const, noexcept, override) ); MOCK_METHOD(bool, IsApplicableToFlightInformationRegion, (const std::string&), (const, noexcept, override)); + MOCK_METHOD( + bool, ApplicableToAircraft, (const EuroScopePlugIn::CFlightPlan&, const EuroScopePlugIn::CRadarTarget&), + (const, override) + ); }; }// namespace ECFMP::Mock::FlowMeasure diff --git a/include/mock/LevelRangeFilterMock.h b/include/mock/LevelRangeFilterMock.h index 4e4cc97..0489a72 100644 --- a/include/mock/LevelRangeFilterMock.h +++ b/include/mock/LevelRangeFilterMock.h @@ -12,6 +12,7 @@ namespace ECFMP::Mock::FlowMeasure { MOCK_METHOD(int, Altitude, (), (const, noexcept, override)); MOCK_METHOD(bool, ApplicableToAltitude, (int), (const, noexcept, override)); MOCK_METHOD(bool, ApplicableToLevel, (int), (const, noexcept, override)); + MOCK_METHOD(bool, ApplicableToAircraft, (const Euroscope::EuroscopeAircraft&), (const, noexcept, override)); }; }// namespace ECFMP::Mock::FlowMeasure diff --git a/include/mock/MultipleLevelFilterMock.h b/include/mock/MultipleLevelFilterMock.h index 39e35b2..079660c 100644 --- a/include/mock/MultipleLevelFilterMock.h +++ b/include/mock/MultipleLevelFilterMock.h @@ -11,6 +11,7 @@ namespace ECFMP::Mock::FlowMeasure { MOCK_METHOD(std::vector, Altitudes, (), (const, noexcept, override)); MOCK_METHOD(bool, ApplicableToAltitude, (int), (const, noexcept, override)); MOCK_METHOD(bool, ApplicableToLevel, (int), (const, noexcept, override)); + MOCK_METHOD(bool, ApplicableToAircraft, (const Euroscope::EuroscopeAircraft&), (const, noexcept, override)); }; }// namespace ECFMP::Mock::FlowMeasure diff --git a/include/mock/RangeToDestinationFilterMock.h b/include/mock/RangeToDestinationFilterMock.h new file mode 100644 index 0000000..dcaa81c --- /dev/null +++ b/include/mock/RangeToDestinationFilterMock.h @@ -0,0 +1,14 @@ +#pragma once +#include "ECFMP/flowmeasure/RangeToDestinationFilter.h" +#include + +namespace ECFMP::Mock::FlowMeasure { + class RangeToDestinationFilterMock : public ECFMP::FlowMeasure::RangeToDestinationFilter + { + public: + MOCK_METHOD( + bool, ApplicableToAircraft, (const ECFMP::Euroscope::EuroscopeAircraft&), (const, noexcept, override) + ); + MOCK_METHOD(int, Range, (), (const, noexcept, override)); + }; +}// namespace ECFMP::Mock::FlowMeasure diff --git a/include/mock/RouteFilterMock.h b/include/mock/RouteFilterMock.h index 8cd47d5..a265cc8 100644 --- a/include/mock/RouteFilterMock.h +++ b/include/mock/RouteFilterMock.h @@ -8,6 +8,7 @@ namespace ECFMP::Mock::FlowMeasure { { public: MOCK_METHOD(const std::set&, RouteStrings, (), (const, noexcept, override)); + MOCK_METHOD(bool, ApplicableToAircraft, (const Euroscope::EuroscopeAircraft&), (const, noexcept, override)); }; }// namespace ECFMP::Mock::FlowMeasure diff --git a/include/mock/flow-sdk-mock.h b/include/mock/ecfmp-sdk-mock.h similarity index 86% rename from include/mock/flow-sdk-mock.h rename to include/mock/ecfmp-sdk-mock.h index 8706f8f..d05d4dd 100644 --- a/include/mock/flow-sdk-mock.h +++ b/include/mock/ecfmp-sdk-mock.h @@ -10,4 +10,5 @@ #include "LevelRangeFilterMock.h" #include "MeasureMock.h" #include "MultipleLevelFilterMock.h" +#include "RangeToDestinationFilterMock.h" #include "RouteFilterMock.h" diff --git a/lib/EuroScopePlugInDll.dll b/lib/EuroScopePlugInDll.dll new file mode 100644 index 0000000..7b01fcd Binary files /dev/null and b/lib/EuroScopePlugInDll.dll differ diff --git a/lib/EuroScopePlugInDll.lib b/lib/EuroScopePlugInDll.lib new file mode 100644 index 0000000..31b16ee Binary files /dev/null and b/lib/EuroScopePlugInDll.lib differ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2d7b6a1..ffe372a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,13 +16,15 @@ set(src_events event/ConcreteEventParticipant.cpp "event/ConcreteEventParticipant.h" event/Event.cpp eventbus/EventStream.h ../include/ECFMP/eventbus/EventListener.h ../include/ECFMP/eventbus/EventFilter.h) +set(src_euroscope euroscope/EuroscopeAircraft.h euroscope/EuroscopeAircraftFactory.h euroscope/EuroscopeAircraftFactoryImpl.cpp euroscope/EuroscopeAircraftFactoryImpl.h euroscope/EuroscopeAircraftImpl.cpp euroscope/EuroscopeAircraftImpl.h) + set(src_eventbus eventbus/EventStream.h ../include/ECFMP/eventbus/EventListener.h ../include/ECFMP/eventbus/EventFilter.h ../include/ECFMP/eventbus/EventBus.h eventbus/InternalEventBus.h eventbus/EventDispatcher.h eventbus/SynchronousEventDispatcher.h eventbus/AsynchronousEventDispatcher.h eventbus/EuroscopeEventDispatcher.h eventbus/PendingEuroscopeEvents.cpp eventbus/PendingEuroscopeEvents.h eventbus/EventDispatcherFactory.h eventbus/SubscriptionFlags.h) set(src_flowmeasures - flowmeasure/ConcreteFlowMeasure.cpp flowmeasure/ConcreteFlowMeasure.h flowmeasure/ConcreteAirportFilter.cpp flowmeasure/ConcreteAirportFilter.h flowmeasure/ConcreteEventFilter.cpp flowmeasure/ConcreteEventFilter.h flowmeasure/ConcreteLevelRangeFilter.cpp flowmeasure/ConcreteLevelRangeFilter.h flowmeasure/ConcreteRouteFilter.cpp flowmeasure/ConcreteRouteFilter.h flowmeasure/ConcreteMeasure.cpp flowmeasure/ConcreteMeasure.h flowmeasure/ConcreteMeasureFactory.cpp flowmeasure/ConcreteMeasureFactory.h flowmeasure/ConcreteFlowMeasureFilters.cpp flowmeasure/ConcreteFlowMeasureFilters.h api/FlowMeasureFilterParserInterface.h ../include/ECFMP/flowmeasure/MultipleLevelFilter.h flowmeasure/ConcreteMultipleLevelFilter.cpp flowmeasure/ConcreteMultipleLevelFilter.h ../include/mock/MultipleLevelFilterMock.h ../include/ECFMP/flowmeasure/RangeToDestinationFilter.h flowmeasure/ConcreteRangeToDestinationFilter.cpp flowmeasure/ConcreteRangeToDestinationFilter.h flowmeasure/CanonicalFlowMeasureInfo.cpp ../include/ECFMP/flowmeasure/CanonicalFlowMeasureInfo.h flowmeasure/FlowMeasureStatusUpdates.cpp flowmeasure/FlowMeasureStatusUpdates.h) + flowmeasure/ConcreteFlowMeasure.cpp flowmeasure/ConcreteFlowMeasure.h flowmeasure/ConcreteAirportFilter.cpp flowmeasure/ConcreteAirportFilter.h flowmeasure/ConcreteEventFilter.cpp flowmeasure/ConcreteEventFilter.h flowmeasure/ConcreteLevelRangeFilter.cpp flowmeasure/ConcreteLevelRangeFilter.h flowmeasure/ConcreteRouteFilter.cpp flowmeasure/ConcreteRouteFilter.h flowmeasure/ConcreteMeasure.cpp flowmeasure/ConcreteMeasure.h flowmeasure/ConcreteMeasureFactory.cpp flowmeasure/ConcreteMeasureFactory.h flowmeasure/ConcreteFlowMeasureFilters.cpp flowmeasure/ConcreteFlowMeasureFilters.h api/FlowMeasureFilterParserInterface.h ../include/ECFMP/flowmeasure/MultipleLevelFilter.h flowmeasure/ConcreteMultipleLevelFilter.cpp flowmeasure/ConcreteMultipleLevelFilter.h ../include/mock/MultipleLevelFilterMock.h ../include/ECFMP/flowmeasure/RangeToDestinationFilter.h flowmeasure/ConcreteRangeToDestinationFilter.cpp flowmeasure/ConcreteRangeToDestinationFilter.h flowmeasure/CanonicalFlowMeasureInfo.cpp ../include/ECFMP/flowmeasure/CanonicalFlowMeasureInfo.h flowmeasure/FlowMeasureStatusUpdates.cpp flowmeasure/FlowMeasureStatusUpdates.h ../include/ECFMP/flowmeasure/ChecksAircraftApplicability.h) set(src_log log/LogDecorator.cpp log/LogDecorator.h log/LogDecorator.h log/NullLogger.cpp log/NullLogger.h) @@ -40,6 +42,7 @@ set(ALL_FILES ${src_api} ${src_date} ${src_events} + ${src_euroscope} ${src_eventbus} ${src_flowmeasures} ${src_flight_information_regions} @@ -57,8 +60,30 @@ target_include_directories(${PROJECT_NAME} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR};" "${CMAKE_CURRENT_SOURCE_DIR}/../include;" "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/nlohmann;" + "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/euroscope;" + ) + +# Treat Euroscope as a system include directory to suppress warning, because they have lots +target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/euroscope;" ) target_compile_options(${PROJECT_NAME} PRIVATE + $<$: + /Od + /Zi; + > + $<$: + /O2; + > + /std:c++20; + /sdl; /EHa + ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; + /Zm200; + ${DEFAULT_CXX_EXCEPTION_HANDLING} + /W4; + /WX; + -Wno-unused-parameter; # Lots of interfaces don't use everything + -Wno-missing-field-initializers; # Windows has loads of this sadly ) diff --git a/src/api/ApiDataScheduler.cpp b/src/api/ApiDataScheduler.cpp index ccf95c9..c63fa05 100644 --- a/src/api/ApiDataScheduler.cpp +++ b/src/api/ApiDataScheduler.cpp @@ -12,7 +12,7 @@ namespace ECFMP::Api { const std::chrono::seconds runInterval = std::chrono::seconds(90); // The last time we ran - std::chrono::system_clock::time_point lastRuntime = std::chrono::system_clock::time_point::min(); + std::chrono::system_clock::time_point lastRuntime = (std::chrono::system_clock::time_point::min)(); // For publishing events std::shared_ptr eventBus; diff --git a/src/api/FlowMeasureFilterParser.cpp b/src/api/FlowMeasureFilterParser.cpp index cab31c8..355e4a1 100644 --- a/src/api/FlowMeasureFilterParser.cpp +++ b/src/api/FlowMeasureFilterParser.cpp @@ -16,9 +16,14 @@ #include "nlohmann/json.hpp" namespace ECFMP::Api { - FlowMeasureFilterParser::FlowMeasureFilterParser(const std::shared_ptr& logger) : logger(logger) + FlowMeasureFilterParser::FlowMeasureFilterParser( + const std::shared_ptr& logger, + std::shared_ptr aircraftFactory + ) + : logger(logger), aircraftFactory(std::move(aircraftFactory)) { assert(this->logger && "Logger cannot be null"); + assert(this->aircraftFactory && "Aircraft factory cannot be null"); } auto FlowMeasureFilterParser::Parse(const nlohmann::json& data, const InternalEventCollection& events) const @@ -130,7 +135,7 @@ namespace ECFMP::Api { return std::make_unique( std::move(airportFilters), std::move(eventFilters), std::move(routeFilters), - std::move(levelRangeFilters), std::move(multipleLevelFilters), std::move(rangeFilters) + std::move(levelRangeFilters), std::move(multipleLevelFilters), std::move(rangeFilters), aircraftFactory ); } diff --git a/src/api/FlowMeasureFilterParser.h b/src/api/FlowMeasureFilterParser.h index 1e935fc..cfddc75 100644 --- a/src/api/FlowMeasureFilterParser.h +++ b/src/api/FlowMeasureFilterParser.h @@ -6,6 +6,9 @@ #include "FlowMeasureFilterParserInterface.h" namespace ECFMP { + namespace Euroscope { + class EuroscopeAircraftFactory; + }// namespace Euroscope namespace FlowMeasure { class AirportFilter; class EventFilter; @@ -20,7 +23,10 @@ namespace ECFMP::Api { class FlowMeasureFilterParser : public FlowMeasureFilterParserInterface { public: - explicit FlowMeasureFilterParser(const std::shared_ptr& logger); + explicit FlowMeasureFilterParser( + const std::shared_ptr& logger, + std::shared_ptr aircraftFactory + ); [[nodiscard]] auto Parse(const nlohmann::json& data, const InternalEventCollection& events) const -> std::unique_ptr override; @@ -46,5 +52,8 @@ namespace ECFMP::Api { // Logger std::shared_ptr logger; + + // For wrapping EuroScope aircraft classes + std::shared_ptr aircraftFactory; }; }// namespace ECFMP::Api diff --git a/src/date/ParseDateStrings.cpp b/src/date/ParseDateStrings.cpp index 6ab2b4a..a2dba17 100644 --- a/src/date/ParseDateStrings.cpp +++ b/src/date/ParseDateStrings.cpp @@ -20,7 +20,7 @@ namespace ECFMP::Date { std::istringstream inputStream(date); inputStream >> std::chrono::parse(timeFormat, timePoint); - return static_cast(inputStream) ? timePoint : std::chrono::system_clock::time_point::max(); + return static_cast(inputStream) ? timePoint : (std::chrono::system_clock::time_point::max)(); } auto DateStringFromTimePoint(const std::chrono::system_clock::time_point& timePoint) -> std::string diff --git a/src/euroscope/EuroscopeAircraft.h b/src/euroscope/EuroscopeAircraft.h new file mode 100644 index 0000000..8174728 --- /dev/null +++ b/src/euroscope/EuroscopeAircraft.h @@ -0,0 +1,54 @@ +#pragma once + +namespace ECFMP::Euroscope { + + /** + * A class that represents an aircraft in Euroscope, encapsulating the + * flightplan and radar target. + */ + class EuroscopeAircraft + { + public: + virtual ~EuroscopeAircraft() = default; + + /** + * Returns the aircraft's vatsim CID. + */ + [[nodiscard]] virtual auto Cid() const -> int = 0; + + /** + * Returns the aircraft's current altitude at standard pressure. + */ + [[nodiscard]] virtual auto CurrentAltitudeStandardPressure() const -> int = 0; + + /** + * Returns the aircraft's flight planned cruise altitude. + */ + [[nodiscard]] virtual auto CruiseAltitude() const -> int = 0; + + /** + * Returns the aircrafts departure airport. + */ + [[nodiscard]] virtual auto DepartureAirport() const -> std::string = 0; + + /** + * Returns the aircrafts destination airport. + */ + [[nodiscard]] virtual auto DestinationAirport() const -> std::string = 0; + + /** + * Returns the aircraft's range to destination + */ + [[nodiscard]] virtual auto RangeToDestination() const -> double = 0; + + /** + * Returns the aircraft's route string. + */ + [[nodiscard]] virtual auto RouteString() const -> std::string = 0; + + /** + * Returns the aircraft's ground speed. + */ + [[nodiscard]] virtual auto GroundSpeed() const -> int = 0; + }; +}// namespace ECFMP::Euroscope diff --git a/src/euroscope/EuroscopeAircraftFactory.h b/src/euroscope/EuroscopeAircraftFactory.h new file mode 100644 index 0000000..7d398a6 --- /dev/null +++ b/src/euroscope/EuroscopeAircraftFactory.h @@ -0,0 +1,24 @@ +#pragma once + +namespace EuroScopePlugIn { + class CFlightPlan; + class CRadarTarget; +}// namespace EuroScopePlugIn + +namespace ECFMP::Euroscope { + + class EuroscopeAircraft; + + /** + * A factory class for EuroscopeAircraft objects. + */ + class EuroscopeAircraftFactory + { + public: + virtual ~EuroscopeAircraftFactory() = default; + + [[nodiscard]] virtual auto + Make(const EuroScopePlugIn::CFlightPlan& flightplan, + const EuroScopePlugIn::CRadarTarget& radarTarget) const noexcept -> std::shared_ptr = 0; + }; +}// namespace ECFMP::Euroscope diff --git a/src/euroscope/EuroscopeAircraftFactoryImpl.cpp b/src/euroscope/EuroscopeAircraftFactoryImpl.cpp new file mode 100644 index 0000000..e55f1bc --- /dev/null +++ b/src/euroscope/EuroscopeAircraftFactoryImpl.cpp @@ -0,0 +1,12 @@ +#include "EuroscopeAircraftFactoryImpl.h" +#include "EuroscopeAircraftImpl.h" + +namespace ECFMP::Euroscope { + + auto EuroscopeAircraftFactoryImpl::Make( + const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ) const noexcept -> std::shared_ptr + { + return std::make_shared(flightplan, radarTarget); + } +}// namespace ECFMP::Euroscope diff --git a/src/euroscope/EuroscopeAircraftFactoryImpl.h b/src/euroscope/EuroscopeAircraftFactoryImpl.h new file mode 100644 index 0000000..58d6216 --- /dev/null +++ b/src/euroscope/EuroscopeAircraftFactoryImpl.h @@ -0,0 +1,12 @@ +#pragma once +#include "EuroscopeAircraftFactory.h" + +namespace ECFMP::Euroscope { + class EuroscopeAircraftFactoryImpl : public EuroscopeAircraftFactory + { + public: + [[nodiscard]] auto + Make(const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ) const noexcept -> std::shared_ptr override; + }; +}// namespace ECFMP::Euroscope diff --git a/src/euroscope/EuroscopeAircraftImpl.cpp b/src/euroscope/EuroscopeAircraftImpl.cpp new file mode 100644 index 0000000..a26767f --- /dev/null +++ b/src/euroscope/EuroscopeAircraftImpl.cpp @@ -0,0 +1,51 @@ +#include "EuroscopeAircraftImpl.h" +#include "EuroScopePlugIn.h" + +namespace ECFMP::Euroscope { + EuroscopeAircraftImpl::EuroscopeAircraftImpl( + const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ) + : flightplan(flightplan), radarTarget(radarTarget) + {} + + auto EuroscopeAircraftImpl::CurrentAltitudeStandardPressure() const -> int + { + return flightplan.GetFPTrackPosition().GetFlightLevel(); + } + + auto EuroscopeAircraftImpl::CruiseAltitude() const -> int + { + return flightplan.GetFlightPlanData().GetFinalAltitude(); + } + + auto EuroscopeAircraftImpl::DepartureAirport() const -> std::string + { + return flightplan.GetFlightPlanData().GetOrigin(); + } + + auto EuroscopeAircraftImpl::DestinationAirport() const -> std::string + { + return flightplan.GetFlightPlanData().GetDestination(); + } + + auto EuroscopeAircraftImpl::Cid() const -> int + { + // TODO: Implement this, EuroScope doesn't have a CID property that we can use + return 0; + } + + auto EuroscopeAircraftImpl::RangeToDestination() const -> double + { + return flightplan.GetDistanceToDestination(); + } + + auto EuroscopeAircraftImpl::GroundSpeed() const -> int + { + return radarTarget.GetGS(); + } + + auto EuroscopeAircraftImpl::RouteString() const -> std::string + { + return flightplan.GetFlightPlanData().GetRoute(); + } +}// namespace ECFMP::Euroscope diff --git a/src/euroscope/EuroscopeAircraftImpl.h b/src/euroscope/EuroscopeAircraftImpl.h new file mode 100644 index 0000000..c294857 --- /dev/null +++ b/src/euroscope/EuroscopeAircraftImpl.h @@ -0,0 +1,32 @@ +#pragma once +#include "EuroscopeAircraft.h" +#include + +namespace EuroScopePlugIn { + class CFlightPlan; + class CRadarTarget; +}// namespace EuroScopePlugIn + +namespace ECFMP::Euroscope { + + class EuroscopeAircraftImpl : public EuroscopeAircraft + { + public: + EuroscopeAircraftImpl( + const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ); + [[nodiscard]] auto CurrentAltitudeStandardPressure() const -> int override; + [[nodiscard]] auto CruiseAltitude() const -> int override; + [[nodiscard]] auto DepartureAirport() const -> std::string override; + [[nodiscard]] auto DestinationAirport() const -> std::string override; + [[nodiscard]] auto Cid() const -> int override; + [[nodiscard]] auto RangeToDestination() const -> double override; + [[nodiscard]] auto GroundSpeed() const -> int override; + [[nodiscard]] auto RouteString() const -> std::string override; + + private: + // The underlying Euroscope objects, not owned by this class. + const EuroScopePlugIn::CFlightPlan& flightplan; + const EuroScopePlugIn::CRadarTarget& radarTarget; + }; +}// namespace ECFMP::Euroscope diff --git a/src/flowmeasure/ConcreteAirportFilter.cpp b/src/flowmeasure/ConcreteAirportFilter.cpp index c54858e..e2f33ee 100644 --- a/src/flowmeasure/ConcreteAirportFilter.cpp +++ b/src/flowmeasure/ConcreteAirportFilter.cpp @@ -1,4 +1,5 @@ #include "ConcreteAirportFilter.h" +#include "euroscope/EuroscopeAircraft.h" namespace ECFMP::FlowMeasure { ConcreteAirportFilter::ConcreteAirportFilter(std::set airportStrings, AirportFilterType type) noexcept @@ -31,4 +32,11 @@ namespace ECFMP::FlowMeasure { { return type; } + + bool ConcreteAirportFilter::ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept + { + return ApplicableToAirport( + type == AirportFilterType::Departure ? aircraft.DepartureAirport() : aircraft.DestinationAirport() + ); + } }// namespace ECFMP::FlowMeasure diff --git a/src/flowmeasure/ConcreteAirportFilter.h b/src/flowmeasure/ConcreteAirportFilter.h index fbee051..1e29e93 100644 --- a/src/flowmeasure/ConcreteAirportFilter.h +++ b/src/flowmeasure/ConcreteAirportFilter.h @@ -10,6 +10,7 @@ namespace ECFMP::FlowMeasure { [[nodiscard]] auto AirportStrings() const noexcept -> const std::set& override; [[nodiscard]] auto ApplicableToAirport(const std::string& airport) const noexcept -> bool override; [[nodiscard]] auto Type() const noexcept -> AirportFilterType override; + auto ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept -> bool override; private: // The strings for the airport filter, may contain wildcards (*) diff --git a/src/flowmeasure/ConcreteEventFilter.cpp b/src/flowmeasure/ConcreteEventFilter.cpp index 8e51e09..a7bf3cd 100644 --- a/src/flowmeasure/ConcreteEventFilter.cpp +++ b/src/flowmeasure/ConcreteEventFilter.cpp @@ -1,5 +1,8 @@ #include "ConcreteEventFilter.h" #include "ECFMP/event/Event.h" +#include "ECFMP/event/EventParticipant.h" +#include "euroscope/EuroscopeAircraft.h" +#include namespace ECFMP::FlowMeasure { @@ -30,4 +33,31 @@ namespace ECFMP::FlowMeasure { { return Participation() == EventParticipation::Participating; } + + bool ConcreteEventFilter::ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept + { + auto cid = aircraft.Cid(); + + /* + * Euroscope doesnt have the concept of a CID, so we can't get this info. + * This workaround means we can write tests for things, but ultimately we'll + * need to find a way to get the CID from Euroscope. + * + * TODO: Find a way to get the CID in + */ + if (cid == 0) { + return true; + } + + const auto isParticipating = + std::find_if( + event->Participants().cbegin(), event->Participants().cend(), + [&aircraft](const std::shared_ptr& participant) { + return participant->Cid() == aircraft.Cid(); + } + ) + != event->Participants().end(); + + return (IsParticipating() && isParticipating) || (!IsParticipating() && !isParticipating); + } }// namespace ECFMP::FlowMeasure diff --git a/src/flowmeasure/ConcreteEventFilter.h b/src/flowmeasure/ConcreteEventFilter.h index c17e8cf..39fdc4c 100644 --- a/src/flowmeasure/ConcreteEventFilter.h +++ b/src/flowmeasure/ConcreteEventFilter.h @@ -17,6 +17,7 @@ namespace ECFMP::FlowMeasure { [[nodiscard]] auto Event() const noexcept -> const ECFMP::Event::Event& override; [[nodiscard]] auto Participation() const noexcept -> EventParticipation override; [[nodiscard]] auto IsParticipating() const noexcept -> bool override; + auto ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept -> bool override; private: // The event in question diff --git a/src/flowmeasure/ConcreteFlowMeasure.cpp b/src/flowmeasure/ConcreteFlowMeasure.cpp index 6c03238..93ed4e7 100644 --- a/src/flowmeasure/ConcreteFlowMeasure.cpp +++ b/src/flowmeasure/ConcreteFlowMeasure.cpp @@ -11,7 +11,7 @@ namespace ECFMP::FlowMeasure { std::chrono::system_clock::time_point startTime, std::chrono::system_clock::time_point endTime, std::chrono::system_clock::time_point withdrawnTime, MeasureStatus status, const std::vector>& notifiedFirs, - std::unique_ptr measure, std::unique_ptr filters + std::unique_ptr measure, std::unique_ptr filters ) : id(id), event(std::move(event)), identifier(std::move(identifier)), canonicalInformation(std::make_unique(this->identifier)), reason(std::move(reason)), @@ -112,4 +112,11 @@ namespace ECFMP::FlowMeasure { { return *canonicalInformation; } + + bool ConcreteFlowMeasure::ApplicableToAircraft( + const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ) const + { + return filters->ApplicableToAircraft(flightplan, radarTarget); + } }// namespace ECFMP::FlowMeasure diff --git a/src/flowmeasure/ConcreteFlowMeasure.h b/src/flowmeasure/ConcreteFlowMeasure.h index e242dbf..4fc10f4 100644 --- a/src/flowmeasure/ConcreteFlowMeasure.h +++ b/src/flowmeasure/ConcreteFlowMeasure.h @@ -38,6 +38,9 @@ namespace ECFMP::FlowMeasure { ) const noexcept -> bool override; [[nodiscard]] auto IsApplicableToFlightInformationRegion(const std::string& flightInformationRegion ) const noexcept -> bool override; + auto ApplicableToAircraft( + const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ) const -> bool override; private: // Id of the measure diff --git a/src/flowmeasure/ConcreteFlowMeasureFilters.cpp b/src/flowmeasure/ConcreteFlowMeasureFilters.cpp index e5f5e4a..4fc2943 100644 --- a/src/flowmeasure/ConcreteFlowMeasureFilters.cpp +++ b/src/flowmeasure/ConcreteFlowMeasureFilters.cpp @@ -1,6 +1,13 @@ #include "ConcreteFlowMeasureFilters.h" #include "ECFMP/flightinformationregion/FlightInformationRegion.h" #include "ECFMP/flowmeasure/AirportFilter.h" +#include "ECFMP/flowmeasure/EventFilter.h" +#include "ECFMP/flowmeasure/LevelRangeFilter.h" +#include "ECFMP/flowmeasure/MultipleLevelFilter.h" +#include "ECFMP/flowmeasure/RangeToDestinationFilter.h" +#include "ECFMP/flowmeasure/RouteFilter.h" +#include "euroscope/EuroscopeAircraftFactory.h" +#include namespace ECFMP::FlowMeasure { @@ -9,13 +16,16 @@ namespace ECFMP::FlowMeasure { std::list> eventFilters, std::list> routeFilters, std::list> levelFilters, std::list> multipleLevelFilters, - std::list> rangeToDestinationFilters + std::list> rangeToDestinationFilters, + std::shared_ptr aircraftFactory ) : airportFilters(std::move(airportFilters)), eventFilters(std::move(eventFilters)), routeFilters(std::move(routeFilters)), levelFilters(std::move(levelFilters)), multipleLevelFilters(std::move(multipleLevelFilters)), - rangeToDestinationFilters(std::move(rangeToDestinationFilters)) - {} + rangeToDestinationFilters(std::move(rangeToDestinationFilters)), aircraftFactory(std::move(aircraftFactory)) + { + assert(this->aircraftFactory != nullptr && "The aircraft factory cannot be null."); + } auto ConcreteFlowMeasureFilters::ApplicableToAirport(const std::string& airport) const noexcept -> bool { @@ -167,4 +177,78 @@ namespace ECFMP::FlowMeasure { { return rangeToDestinationFilters; } + + /** + * The logic between different filters is logical AND, with values within filters being logical OR. + * @return + */ + bool ConcreteFlowMeasureFilters::ApplicableToAircraft( + const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ) const + { + const auto euroscopeAircraft = aircraftFactory->Make(flightplan, radarTarget); + + // Check if the aircraft is not applicable to any of the airport filters + const auto passesAirportFilters = + std::all_of(airportFilters.cbegin(), airportFilters.cend(), [&euroscopeAircraft](const auto& filter) { + return filter->ApplicableToAircraft(*euroscopeAircraft); + }); + + if (!passesAirportFilters) { + return false; + } + + // Check if the aircraft is not applicable to any of the event filters + const auto passesEventFilters = + std::all_of(eventFilters.cbegin(), eventFilters.cend(), [&euroscopeAircraft](const auto& filter) { + return filter->ApplicableToAircraft(*euroscopeAircraft); + }); + + if (!passesEventFilters) { + return false; + } + + // Check if the aircraft is not applicable to any of the level filters + + const auto passesLevelFilters = + std::all_of(levelFilters.cbegin(), levelFilters.cend(), [&euroscopeAircraft](const auto& filter) { + return filter->ApplicableToAircraft(*euroscopeAircraft); + }); + + if (!passesLevelFilters) { + return false; + } + + // Check if the aircraft is not applicable to any of the multiple level filters + const auto passesMultipleLevelFilters = std::all_of( + multipleLevelFilters.cbegin(), multipleLevelFilters.cend(), + [&euroscopeAircraft](const auto& filter) { + return filter->ApplicableToAircraft(*euroscopeAircraft); + } + ); + + if (!passesMultipleLevelFilters) { + return false; + } + + // Check if the aircraft is not applicable to any of the route filters + const auto passesRouteFilters = + std::all_of(routeFilters.cbegin(), routeFilters.cend(), [&euroscopeAircraft](const auto& filter) { + return filter->ApplicableToAircraft(*euroscopeAircraft); + }); + + if (!passesRouteFilters) { + return false; + } + + // Check if the aircraft is not applicable to any of the range to destination filters + const auto passesRangeToDestinationFilters = std::all_of( + rangeToDestinationFilters.cbegin(), rangeToDestinationFilters.cend(), + [&euroscopeAircraft](const auto& filter) { + return filter->ApplicableToAircraft(*euroscopeAircraft); + } + ); + + return passesRangeToDestinationFilters; + } }// namespace ECFMP::FlowMeasure diff --git a/src/flowmeasure/ConcreteFlowMeasureFilters.h b/src/flowmeasure/ConcreteFlowMeasureFilters.h index 1d7fa9f..96f31e3 100644 --- a/src/flowmeasure/ConcreteFlowMeasureFilters.h +++ b/src/flowmeasure/ConcreteFlowMeasureFilters.h @@ -1,10 +1,14 @@ #pragma once #include "ECFMP/flowmeasure/FlowMeasureFilters.h" -#include "ECFMP/flowmeasure/MultipleLevelFilter.h" -namespace ECFMP::FlightInformationRegion { - class FlightInformationRegion; -}// namespace ECFMP::FlightInformationRegion +namespace ECFMP { + namespace Euroscope { + class EuroscopeAircraftFactory; + }// namespace Euroscope + namespace FlightInformationRegion { + class FlightInformationRegion; + }// namespace FlightInformationRegion +}// namespace ECFMP namespace ECFMP::FlowMeasure { /** @@ -19,7 +23,8 @@ namespace ECFMP::FlowMeasure { std::list> routeFilters, std::list> levelFilters, std::list> multipleLevelFilters, - std::list> rangeToDestinationFilters + std::list> rangeToDestinationFilters, + std::shared_ptr aircraftFactory ); [[nodiscard]] auto AirportFilters() const noexcept -> const std::list>&; [[nodiscard]] auto EventFilters() const noexcept -> const std::list>&; @@ -30,6 +35,9 @@ namespace ECFMP::FlowMeasure { [[nodiscard]] auto RangeToDestinationFilters() const noexcept -> const std::list>&; [[nodiscard]] auto ApplicableToAirport(const std::string& airfield) const noexcept -> bool override; + auto ApplicableToAircraft( + const EuroScopePlugIn::CFlightPlan& flightplan, const EuroScopePlugIn::CRadarTarget& radarTarget + ) const -> bool override; void ForEachAirportFilter(const std::function& callback) const noexcept override; void ForEachEventFilter(const std::function& callback) const noexcept override; void ForEachLevelFilter(const std::function& callback) const noexcept override; @@ -70,5 +78,8 @@ namespace ECFMP::FlowMeasure { // All the range to destination filters std::list> rangeToDestinationFilters; + + // For wrapping euroscope classes for testing + std::shared_ptr aircraftFactory; }; }// namespace ECFMP::FlowMeasure diff --git a/src/flowmeasure/ConcreteLevelRangeFilter.cpp b/src/flowmeasure/ConcreteLevelRangeFilter.cpp index 9e37232..75fcada 100644 --- a/src/flowmeasure/ConcreteLevelRangeFilter.cpp +++ b/src/flowmeasure/ConcreteLevelRangeFilter.cpp @@ -1,4 +1,5 @@ #include "ConcreteLevelRangeFilter.h" +#include "euroscope/EuroscopeAircraft.h" namespace ECFMP::FlowMeasure { ConcreteLevelRangeFilter::ConcreteLevelRangeFilter(LevelRangeFilterType type, int filterLevel) @@ -30,4 +31,9 @@ namespace ECFMP::FlowMeasure { return type == LevelRangeFilterType::AtOrBelow ? altitude <= filterLevelAsAltitude : altitude >= filterLevelAsAltitude; } + + bool ConcreteLevelRangeFilter::ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept + { + return ApplicableToAltitude(aircraft.CruiseAltitude()); + } }// namespace ECFMP::FlowMeasure diff --git a/src/flowmeasure/ConcreteLevelRangeFilter.h b/src/flowmeasure/ConcreteLevelRangeFilter.h index d1f9128..0adeb03 100644 --- a/src/flowmeasure/ConcreteLevelRangeFilter.h +++ b/src/flowmeasure/ConcreteLevelRangeFilter.h @@ -12,6 +12,7 @@ namespace ECFMP::FlowMeasure { [[nodiscard]] auto Altitude() const noexcept -> int override; [[nodiscard]] auto ApplicableToLevel(int level) const noexcept -> bool override; [[nodiscard]] auto ApplicableToAltitude(int level) const noexcept -> bool override; + auto ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept -> bool override; private: // The type of level filter this is diff --git a/src/flowmeasure/ConcreteMeasure.cpp b/src/flowmeasure/ConcreteMeasure.cpp index 51641bb..4c8256d 100644 --- a/src/flowmeasure/ConcreteMeasure.cpp +++ b/src/flowmeasure/ConcreteMeasure.cpp @@ -14,7 +14,7 @@ namespace ECFMP::FlowMeasure { {} ConcreteMeasure::ConcreteMeasure(MeasureType type, std::set value) - : type(MeasureType::MandatoryRoute), setValue(std::move(value)), valueType(MeasureValueType::Set) + : type(MeasureType::MandatoryRoute), valueType(MeasureValueType::Set), setValue(std::move(value)) {} auto ConcreteMeasure::Type() const noexcept -> MeasureType diff --git a/src/flowmeasure/ConcreteMultipleLevelFilter.cpp b/src/flowmeasure/ConcreteMultipleLevelFilter.cpp index d9049b1..0fc754f 100644 --- a/src/flowmeasure/ConcreteMultipleLevelFilter.cpp +++ b/src/flowmeasure/ConcreteMultipleLevelFilter.cpp @@ -1,4 +1,5 @@ #include "ConcreteMultipleLevelFilter.h" +#include "euroscope/EuroscopeAircraft.h" namespace ECFMP::FlowMeasure { ConcreteMultipleLevelFilter::ConcreteMultipleLevelFilter(std::vector levels) : levels(std::move(levels)) @@ -27,4 +28,9 @@ namespace ECFMP::FlowMeasure { { return std::find(this->altitudes.begin(), this->altitudes.end(), altitude) != this->altitudes.end(); } + + bool ConcreteMultipleLevelFilter::ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept + { + return ApplicableToAltitude(aircraft.CruiseAltitude()); + } }// namespace ECFMP::FlowMeasure diff --git a/src/flowmeasure/ConcreteMultipleLevelFilter.h b/src/flowmeasure/ConcreteMultipleLevelFilter.h index 00b294c..d584159 100644 --- a/src/flowmeasure/ConcreteMultipleLevelFilter.h +++ b/src/flowmeasure/ConcreteMultipleLevelFilter.h @@ -28,6 +28,12 @@ namespace ECFMP::FlowMeasure { */ [[nodiscard]] auto ApplicableToAltitude(int level) const noexcept -> bool override; + /** + * Helper method to determine, given a particular aircraft, does this filter apply. + */ + [[nodiscard]] auto ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept + -> bool override; + private: // The levels (e.g. 350) associated with this filter std::vector levels; diff --git a/src/flowmeasure/ConcreteRangeToDestinationFilter.cpp b/src/flowmeasure/ConcreteRangeToDestinationFilter.cpp index 34c0cca..01d254e 100644 --- a/src/flowmeasure/ConcreteRangeToDestinationFilter.cpp +++ b/src/flowmeasure/ConcreteRangeToDestinationFilter.cpp @@ -1,4 +1,5 @@ #include "ConcreteRangeToDestinationFilter.h" +#include "euroscope/EuroscopeAircraft.h" namespace ECFMP::FlowMeasure { ConcreteRangeToDestinationFilter::ConcreteRangeToDestinationFilter(int range) noexcept : range(range) @@ -8,4 +9,10 @@ namespace ECFMP::FlowMeasure { { return range; } + + bool ConcreteRangeToDestinationFilter::ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft + ) const noexcept + { + return ((int) ceil(aircraft.RangeToDestination())) <= range; + } }// namespace ECFMP::FlowMeasure diff --git a/src/flowmeasure/ConcreteRangeToDestinationFilter.h b/src/flowmeasure/ConcreteRangeToDestinationFilter.h index a6dda4a..0c12331 100644 --- a/src/flowmeasure/ConcreteRangeToDestinationFilter.h +++ b/src/flowmeasure/ConcreteRangeToDestinationFilter.h @@ -8,6 +8,7 @@ namespace ECFMP::FlowMeasure { public: explicit ConcreteRangeToDestinationFilter(int range) noexcept; auto Range() const noexcept -> int override; + auto ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept -> bool override; private: // The range to destination. diff --git a/src/flowmeasure/ConcreteRouteFilter.cpp b/src/flowmeasure/ConcreteRouteFilter.cpp index f132d1b..abcc5eb 100644 --- a/src/flowmeasure/ConcreteRouteFilter.cpp +++ b/src/flowmeasure/ConcreteRouteFilter.cpp @@ -1,4 +1,5 @@ #include "ConcreteRouteFilter.h" +#include "euroscope/EuroscopeAircraft.h" namespace ECFMP::FlowMeasure { ConcreteRouteFilter::ConcreteRouteFilter(std::set routes) : routes(std::move(routes)) @@ -8,4 +9,14 @@ namespace ECFMP::FlowMeasure { { return routes; } + + bool ConcreteRouteFilter::ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept + { + return std::find_if( + routes.begin(), routes.end(), + [&aircraft](const std::string& route) { + return aircraft.RouteString().find(route) != std::string::npos; + } + ) != routes.end(); + } }// namespace ECFMP::FlowMeasure diff --git a/src/flowmeasure/ConcreteRouteFilter.h b/src/flowmeasure/ConcreteRouteFilter.h index 375b774..45e8e2d 100644 --- a/src/flowmeasure/ConcreteRouteFilter.h +++ b/src/flowmeasure/ConcreteRouteFilter.h @@ -7,6 +7,8 @@ namespace ECFMP::FlowMeasure { public: explicit ConcreteRouteFilter(std::set routes); [[nodiscard]] auto RouteStrings() const noexcept -> const std::set& override; + [[nodiscard]] auto ApplicableToAircraft(const Euroscope::EuroscopeAircraft& aircraft) const noexcept + -> bool override; private: // The route strings diff --git a/src/pch.h b/src/pch.h index a414e86..a8bc024 100644 --- a/src/pch.h +++ b/src/pch.h @@ -1,5 +1,6 @@ #pragma once -#include +#include +#include #include #include #include diff --git a/src/plugin/SdkFactory.cpp b/src/plugin/SdkFactory.cpp index 11ae257..4fe8487 100644 --- a/src/plugin/SdkFactory.cpp +++ b/src/plugin/SdkFactory.cpp @@ -14,6 +14,7 @@ #include "api/FlowMeasureDataParser.h" #include "api/FlowMeasureFilterParser.h" #include "api/FlowMeasureMeasureParser.h" +#include "euroscope/EuroscopeAircraftFactoryImpl.h" #include "eventbus/InternalEventBusFactory.h" #include "flowmeasure/FlowMeasureStatusUpdates.h" #include "log/LogDecorator.h" @@ -28,7 +29,9 @@ namespace ECFMP::Plugin { std::make_shared(GetLogger(), GetEventBus()), std::make_shared(GetLogger(), GetEventBus()), std::make_shared( - std::make_unique(GetLogger()), + std::make_unique( + GetLogger(), std::make_shared() + ), std::make_unique(GetLogger()), GetLogger(), GetEventBus() ), GetLogger() diff --git a/src/time/Clock.cpp b/src/time/Clock.cpp index 7ba53c6..60a275f 100644 --- a/src/time/Clock.cpp +++ b/src/time/Clock.cpp @@ -2,15 +2,16 @@ namespace ECFMP::Time { - std::chrono::system_clock::time_point testNow = std::chrono::system_clock::time_point::min(); + auto DefaultTime() -> std::chrono::system_clock::time_point + { + return (std::chrono::system_clock::time_point::min)(); + } + + std::chrono::system_clock::time_point testNow = DefaultTime(); auto TimeNow() -> std::chrono::system_clock::time_point { - if (testNow != std::chrono::system_clock::time_point::min()) { - return testNow; - } - - return std::chrono::system_clock::now(); + return testNow != DefaultTime() ? testNow : std::chrono::system_clock::now(); } void SetTestNow(const std::chrono::system_clock::time_point& now) @@ -20,6 +21,6 @@ namespace ECFMP::Time { void UnsetTestNow() { - testNow = std::chrono::system_clock::time_point::min(); + testNow = DefaultTime(); } }// namespace ECFMP::Time diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b705111..e80ae29 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -49,9 +49,10 @@ set(test__log ) set(test__mock + mock/MockEuroscopeAircraft.h mock/MockLogger.h mock/MockHttpClient.h - ) + mock/MockEuroscopeAircraftFactory.h) set(test__pch pch/pch.cpp @@ -100,18 +101,25 @@ target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/nlohmann;" ) +# Treat Euroscope as a system include directory to suppress warning, because they have lots +target_include_directories(${PROJECT_NAME} SYSTEM PRIVATE + "${CMAKE_CURRENT_SOURCE_DIR}/../third_party/euroscope;" + ) + #### LINKS target_link_directories( ${PROJECT_NAME} PUBLIC "${CMAKE_BINARY_DIR}/src/" + "${CMAKE_CURRENT_SOURCE_DIR}/../lib" ) target_link_libraries(${PROJECT_NAME} PRIVATE gmock flow_plugin_sdk_src + "EuroScopePlugInDll;" ) -set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "-m32" LINK_FLAGS "-m32" JSON_MultipleHeaders "ON") +set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS " -m32" LINK_FLAGS "-m32" JSON_MultipleHeaders "ON ") #### COMPILE OPTIONS target_compile_options(${PROJECT_NAME} PRIVATE @@ -130,10 +138,10 @@ target_compile_options(${PROJECT_NAME} PRIVATE /W4; /WX; ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; - ${DEFAULT_CXX_EXCEPTION_HANDLING} - -Wno-unused-parameter # Lots of interfaces don't use everything - -Wno-missing-field-initializers # Windows has loads of this sadly - /EHa + ${DEFAULT_CXX_EXCEPTION_HANDLING}; + -Wno-unused-parameter; # Lots of interfaces don't use everything + -Wno-missing-field-initializers; # Windows has loads of this sadly + /EHa; ) #### LINK OPTIONS @@ -152,3 +160,9 @@ target_link_options(${PROJECT_NAME} PRIVATE /NODEFAULTLIB:LIBCMT; /SUBSYSTEM:CONSOLE; ) + +# Post-build copy the EuroScope binary +add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/../lib/EuroScopePlugInDll.dll" "${PROJECT_BINARY_DIR}/EuroScopePlugInDll.dll" + COMMENT "Copied EuroScope shared library to ${PROJECT_BINARY_DIR}/EuroScopePlugInDll.dll" + ) diff --git a/test/MockHeaderTest.cpp b/test/MockHeaderTest.cpp index 4f7e799..fc5c601 100644 --- a/test/MockHeaderTest.cpp +++ b/test/MockHeaderTest.cpp @@ -1,4 +1,4 @@ -#include "mock/flow-sdk-mock.h" +#include "mock/ecfmp-sdk-mock.h" namespace ECFMPTest { class FlowSdkHeaderMockTest : public testing::Test @@ -18,6 +18,7 @@ namespace ECFMPTest { testing::NiceMock mutliLevelFilter; testing::NiceMock measure; testing::NiceMock routeFilter; + testing::NiceMock rangeFilter; // Dummy expectation, the purpose of this test is to make sure the header compiles properly. EXPECT_TRUE(true); diff --git a/test/api/ApiDataDownloaderTest.cpp b/test/api/ApiDataDownloaderTest.cpp index 18171f2..dcb7635 100644 --- a/test/api/ApiDataDownloaderTest.cpp +++ b/test/api/ApiDataDownloaderTest.cpp @@ -17,7 +17,7 @@ namespace ECFMPTest::Api { void OnEvent(const ECFMP::Api::ApiDataDownloadedEvent& event) override { callCount++; - ASSERT_EQ(event.data, expectedJson); + EXPECT_EQ(event.data, expectedJson); } [[nodiscard]] auto GetCallCount() const -> int diff --git a/test/api/FlowMeasureDataParserTest.cpp b/test/api/FlowMeasureDataParserTest.cpp index 4887e05..d48bce4 100644 --- a/test/api/FlowMeasureDataParserTest.cpp +++ b/test/api/FlowMeasureDataParserTest.cpp @@ -15,6 +15,7 @@ #include "flowmeasure/ConcreteAirportFilter.h" #include "flowmeasure/ConcreteFlowMeasureFilters.h" #include "flowmeasure/ConcreteMeasure.h" +#include "mock/MockEuroscopeAircraftFactory.h" #include "mock/MockLogger.h" #include "nlohmann/json.hpp" #include "plugin/InternalSdkEvents.h" @@ -167,7 +168,8 @@ namespace ECFMPTest::Api { std::list>(), std::list>(), std::list>(), - std::list>() + std::list>(), + std::make_shared() ); })); @@ -385,7 +387,8 @@ namespace ECFMPTest::Api { std::list>(), std::list>(), std::list>(), - std::list>() + std::list>(), + std::make_shared() ); })); @@ -834,7 +837,7 @@ namespace ECFMPTest::Api { TEST_F(FlowMeasureDataParserBizarreDataTest, ItReturnsNullptrIfJsonNotObject) { auto result = parser->ParseFlowMeasures(nlohmann::json::array(), events, firs); - ASSERT_EQ(nullptr, result); + EXPECT_EQ(nullptr, result); EXPECT_EQ(0, mockEventHandler->GetCallCount()); EXPECT_EQ(0, mockEventHandlerInternal->GetCallCount()); } @@ -842,7 +845,7 @@ namespace ECFMPTest::Api { TEST_F(FlowMeasureDataParserBizarreDataTest, ItReturnsNullptrIfJsonDoesntContainFlowMeasuresKey) { auto result = parser->ParseFlowMeasures(nlohmann::json{{"foo", "bar"}}, events, firs); - ASSERT_EQ(nullptr, result); + EXPECT_EQ(nullptr, result); EXPECT_EQ(0, mockEventHandler->GetCallCount()); EXPECT_EQ(0, mockEventHandlerInternal->GetCallCount()); } @@ -850,7 +853,7 @@ namespace ECFMPTest::Api { TEST_F(FlowMeasureDataParserBizarreDataTest, ItReturnsNullptrIfFlowMeasuresKeyIsNotArray) { auto result = parser->ParseFlowMeasures(nlohmann::json{{"flow_measures", "bar"}}, events, firs); - ASSERT_EQ(nullptr, result); + EXPECT_EQ(nullptr, result); EXPECT_EQ(0, mockEventHandler->GetCallCount()); EXPECT_EQ(0, mockEventHandlerInternal->GetCallCount()); } diff --git a/test/api/FlowMeasureFilterParserTest.cpp b/test/api/FlowMeasureFilterParserTest.cpp index d1b96f6..ed0ae20 100644 --- a/test/api/FlowMeasureFilterParserTest.cpp +++ b/test/api/FlowMeasureFilterParserTest.cpp @@ -7,6 +7,7 @@ #include "flowmeasure/ConcreteAirportFilter.h" #include "flowmeasure/ConcreteFlowMeasureFilters.h" #include "mock/EventMock.h" +#include "mock/MockEuroscopeAircraftFactory.h" #include "mock/MockLogger.h" #include "nlohmann/json.hpp" @@ -15,7 +16,8 @@ namespace ECFMPTest::Api { class FlowMeasureFilterParserNoDataTest : public ::testing::Test { public: - FlowMeasureFilterParserNoDataTest() : parser(std::make_shared()) + FlowMeasureFilterParserNoDataTest() + : parser(std::make_shared(), std::make_shared()) {} ECFMP::Api::InternalApiElementCollection events; @@ -30,12 +32,12 @@ namespace ECFMPTest::Api { auto castedFilters = static_cast(*filters.get()); - ASSERT_EQ(castedFilters.AirportFilters().size(), 0); - ASSERT_EQ(castedFilters.LevelFilters().size(), 0); - ASSERT_EQ(castedFilters.MultipleLevelFilters().size(), 0); - ASSERT_EQ(castedFilters.EventFilters().size(), 0); - ASSERT_EQ(castedFilters.RouteFilters().size(), 0); - ASSERT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); + EXPECT_EQ(castedFilters.AirportFilters().size(), 0); + EXPECT_EQ(castedFilters.LevelFilters().size(), 0); + EXPECT_EQ(castedFilters.MultipleLevelFilters().size(), 0); + EXPECT_EQ(castedFilters.EventFilters().size(), 0); + EXPECT_EQ(castedFilters.RouteFilters().size(), 0); + EXPECT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); } struct FlowMeasureFilterParserAirportFilterTestCase { @@ -48,7 +50,8 @@ namespace ECFMPTest::Api { : public ::testing::TestWithParam { public: - FlowMeasureFilterParserAirportFilterTest() : parser(std::make_shared()) + FlowMeasureFilterParserAirportFilterTest() + : parser(std::make_shared(), std::make_shared()) {} ECFMP::Api::InternalApiElementCollection events; @@ -64,19 +67,19 @@ namespace ECFMPTest::Api { auto castedFilters = static_cast(*filters.get()); - ASSERT_EQ(castedFilters.AirportFilters().size(), 1); - ASSERT_EQ(castedFilters.LevelFilters().size(), 0); - ASSERT_EQ(castedFilters.MultipleLevelFilters().size(), 0); - ASSERT_EQ(castedFilters.EventFilters().size(), 0); - ASSERT_EQ(castedFilters.RouteFilters().size(), 0); - ASSERT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); + EXPECT_EQ(castedFilters.AirportFilters().size(), 1); + EXPECT_EQ(castedFilters.LevelFilters().size(), 0); + EXPECT_EQ(castedFilters.MultipleLevelFilters().size(), 0); + EXPECT_EQ(castedFilters.EventFilters().size(), 0); + EXPECT_EQ(castedFilters.RouteFilters().size(), 0); + EXPECT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); auto expectedFilterType = GetParam().filterType == "ADES" ? ECFMP::FlowMeasure::AirportFilterType::Destination : ECFMP::FlowMeasure::AirportFilterType::Departure; const auto& airportFilter = castedFilters.AirportFilters().front(); - ASSERT_EQ(airportFilter->Type(), expectedFilterType); - ASSERT_EQ(airportFilter->AirportStrings().size(), GetParam().airports.size()); - ASSERT_EQ(airportFilter->AirportStrings(), GetParam().airports); + EXPECT_EQ(airportFilter->Type(), expectedFilterType); + EXPECT_EQ(airportFilter->AirportStrings().size(), GetParam().airports.size()); + EXPECT_EQ(airportFilter->AirportStrings(), GetParam().airports); } INSTANTIATE_TEST_SUITE_P( @@ -102,7 +105,8 @@ namespace ECFMPTest::Api { : public ::testing::TestWithParam { public: - FlowMeasureFilterParserLevelRangeFilterTest() : parser(std::make_shared()) + FlowMeasureFilterParserLevelRangeFilterTest() + : parser(std::make_shared(), std::make_shared()) {} ECFMP::Api::InternalApiElementCollection events; @@ -118,16 +122,16 @@ namespace ECFMPTest::Api { auto castedFilters = static_cast(*filters.get()); - ASSERT_EQ(castedFilters.AirportFilters().size(), 0); - ASSERT_EQ(castedFilters.LevelFilters().size(), 1); - ASSERT_EQ(castedFilters.MultipleLevelFilters().size(), 0); - ASSERT_EQ(castedFilters.EventFilters().size(), 0); - ASSERT_EQ(castedFilters.RouteFilters().size(), 0); - ASSERT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); + EXPECT_EQ(castedFilters.AirportFilters().size(), 0); + EXPECT_EQ(castedFilters.LevelFilters().size(), 1); + EXPECT_EQ(castedFilters.MultipleLevelFilters().size(), 0); + EXPECT_EQ(castedFilters.EventFilters().size(), 0); + EXPECT_EQ(castedFilters.RouteFilters().size(), 0); + EXPECT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); const auto& levelFilter = castedFilters.LevelFilters().front(); - ASSERT_EQ(GetParam().expectedFilterType, levelFilter->Type()); - ASSERT_EQ(GetParam().expectedLevel, levelFilter->Level()); + EXPECT_EQ(GetParam().expectedFilterType, levelFilter->Type()); + EXPECT_EQ(GetParam().expectedLevel, levelFilter->Level()); } INSTANTIATE_TEST_SUITE_P( @@ -154,7 +158,8 @@ namespace ECFMPTest::Api { : public ::testing::TestWithParam { public: - FlowMeasureFilterParserSpecificLevelFilterTest() : parser(std::make_shared()) + FlowMeasureFilterParserSpecificLevelFilterTest() + : parser(std::make_shared(), std::make_shared()) {} ECFMP::Api::InternalApiElementCollection events; @@ -170,15 +175,15 @@ namespace ECFMPTest::Api { auto castedFilters = static_cast(*filters.get()); - ASSERT_EQ(castedFilters.AirportFilters().size(), 0); - ASSERT_EQ(castedFilters.LevelFilters().size(), 0); - ASSERT_EQ(castedFilters.MultipleLevelFilters().size(), 1); - ASSERT_EQ(castedFilters.EventFilters().size(), 0); - ASSERT_EQ(castedFilters.RouteFilters().size(), 0); - ASSERT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); + EXPECT_EQ(castedFilters.AirportFilters().size(), 0); + EXPECT_EQ(castedFilters.LevelFilters().size(), 0); + EXPECT_EQ(castedFilters.MultipleLevelFilters().size(), 1); + EXPECT_EQ(castedFilters.EventFilters().size(), 0); + EXPECT_EQ(castedFilters.RouteFilters().size(), 0); + EXPECT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); const auto& levelFilter = castedFilters.MultipleLevelFilters().front(); - ASSERT_EQ(GetParam().expectedLevels, levelFilter->Levels()); + EXPECT_EQ(GetParam().expectedLevels, levelFilter->Levels()); } INSTANTIATE_TEST_SUITE_P( @@ -202,7 +207,8 @@ namespace ECFMPTest::Api { : public ::testing::TestWithParam { public: - FlowMeasureFilterParserEventParticipationFilterTest() : parser(std::make_shared()) + FlowMeasureFilterParserEventParticipationFilterTest() + : parser(std::make_shared(), std::make_shared()) { auto event1 = std::make_shared(); ON_CALL(*event1, Id).WillByDefault(testing::Return(100)); @@ -226,16 +232,16 @@ namespace ECFMPTest::Api { auto castedFilters = static_cast(*filters.get()); - ASSERT_EQ(castedFilters.AirportFilters().size(), 0); - ASSERT_EQ(castedFilters.LevelFilters().size(), 0); - ASSERT_EQ(castedFilters.MultipleLevelFilters().size(), 0); - ASSERT_EQ(castedFilters.EventFilters().size(), 1); - ASSERT_EQ(castedFilters.RouteFilters().size(), 0); - ASSERT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); + EXPECT_EQ(castedFilters.AirportFilters().size(), 0); + EXPECT_EQ(castedFilters.LevelFilters().size(), 0); + EXPECT_EQ(castedFilters.MultipleLevelFilters().size(), 0); + EXPECT_EQ(castedFilters.EventFilters().size(), 1); + EXPECT_EQ(castedFilters.RouteFilters().size(), 0); + EXPECT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); const auto& eventFilter = castedFilters.EventFilters().front(); - ASSERT_EQ(GetParam().expectedFilterType, eventFilter->Participation()); - ASSERT_EQ(GetParam().expectedEventId, eventFilter->Event().Id()); + EXPECT_EQ(GetParam().expectedFilterType, eventFilter->Participation()); + EXPECT_EQ(GetParam().expectedEventId, eventFilter->Event().Id()); } INSTANTIATE_TEST_SUITE_P( @@ -263,7 +269,8 @@ namespace ECFMPTest::Api { : public ::testing::TestWithParam { public: - FlowMeasureFilterParserRouteFilterTest() : parser(std::make_shared()) + FlowMeasureFilterParserRouteFilterTest() + : parser(std::make_shared(), std::make_shared()) {} ECFMP::Api::InternalApiElementCollection events; @@ -279,15 +286,15 @@ namespace ECFMPTest::Api { auto castedFilters = static_cast(*filters.get()); - ASSERT_EQ(castedFilters.AirportFilters().size(), 0); - ASSERT_EQ(castedFilters.LevelFilters().size(), 0); - ASSERT_EQ(castedFilters.MultipleLevelFilters().size(), 0); - ASSERT_EQ(castedFilters.EventFilters().size(), 0); - ASSERT_EQ(castedFilters.RouteFilters().size(), 1); - ASSERT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); + EXPECT_EQ(castedFilters.AirportFilters().size(), 0); + EXPECT_EQ(castedFilters.LevelFilters().size(), 0); + EXPECT_EQ(castedFilters.MultipleLevelFilters().size(), 0); + EXPECT_EQ(castedFilters.EventFilters().size(), 0); + EXPECT_EQ(castedFilters.RouteFilters().size(), 1); + EXPECT_EQ(castedFilters.RangeToDestinationFilters().size(), 0); const auto& routeFilter = castedFilters.RouteFilters().front(); - ASSERT_EQ(GetParam().expectedWaypoints, routeFilter->RouteStrings()); + EXPECT_EQ(GetParam().expectedWaypoints, routeFilter->RouteStrings()); } INSTANTIATE_TEST_SUITE_P( @@ -310,7 +317,8 @@ namespace ECFMPTest::Api { : public ::testing::TestWithParam { public: - FlowMeasureFilterParserRangeToDestinationTest() : parser(std::make_shared()) + FlowMeasureFilterParserRangeToDestinationTest() + : parser(std::make_shared(), std::make_shared()) { auto event1 = std::make_shared(); ON_CALL(*event1, Id).WillByDefault(testing::Return(100)); @@ -334,15 +342,15 @@ namespace ECFMPTest::Api { auto castedFilters = static_cast(*filters.get()); - ASSERT_EQ(castedFilters.AirportFilters().size(), 0); - ASSERT_EQ(castedFilters.LevelFilters().size(), 0); - ASSERT_EQ(castedFilters.MultipleLevelFilters().size(), 0); - ASSERT_EQ(castedFilters.EventFilters().size(), 0); - ASSERT_EQ(castedFilters.RouteFilters().size(), 0); - ASSERT_EQ(castedFilters.RangeToDestinationFilters().size(), 1); + EXPECT_EQ(castedFilters.AirportFilters().size(), 0); + EXPECT_EQ(castedFilters.LevelFilters().size(), 0); + EXPECT_EQ(castedFilters.MultipleLevelFilters().size(), 0); + EXPECT_EQ(castedFilters.EventFilters().size(), 0); + EXPECT_EQ(castedFilters.RouteFilters().size(), 0); + EXPECT_EQ(castedFilters.RangeToDestinationFilters().size(), 1); const auto& rangeFilter = castedFilters.RangeToDestinationFilters().front(); - ASSERT_EQ(GetParam().range, rangeFilter->Range()); + EXPECT_EQ(GetParam().range, rangeFilter->Range()); } INSTANTIATE_TEST_SUITE_P( @@ -362,7 +370,8 @@ namespace ECFMPTest::Api { : public ::testing::TestWithParam { public: - FlowMeasureFilterParserInvalidDataTest() : parser(std::make_shared()) + FlowMeasureFilterParserInvalidDataTest() + : parser(std::make_shared(), std::make_shared()) { auto event1 = std::make_shared(); ON_CALL(*event1, Id()).WillByDefault(testing::Return(100)); diff --git a/test/api/FlowMeasureMeasureParserTest.cpp b/test/api/FlowMeasureMeasureParserTest.cpp index 2f1fbd7..e47e3b1 100644 --- a/test/api/FlowMeasureMeasureParserTest.cpp +++ b/test/api/FlowMeasureMeasureParserTest.cpp @@ -34,9 +34,9 @@ namespace ECFMPTest::Api { json["type"] = param.jsonType; json["value"] = param.jsonValue; auto measure = parser.Parse(json); - ASSERT_NE(measure, nullptr); - ASSERT_EQ(measure->Type(), param.expectedType); - ASSERT_EQ(measure->IntegerValue(), param.expectedValue); + EXPECT_NE(measure, nullptr); + EXPECT_EQ(measure->Type(), param.expectedType); + EXPECT_EQ(measure->IntegerValue(), param.expectedValue); } INSTANTIATE_TEST_SUITE_P( @@ -80,9 +80,9 @@ namespace ECFMPTest::Api { json["type"] = param.jsonType; json["value"] = param.jsonValue; auto measure = parser.Parse(json); - ASSERT_NE(measure, nullptr); - ASSERT_EQ(measure->Type(), param.expectedType); - ASSERT_DOUBLE_EQ(measure->DoubleValue(), param.expectedValue); + EXPECT_NE(measure, nullptr); + EXPECT_EQ(measure->Type(), param.expectedType); + EXPECT_DOUBLE_EQ(measure->DoubleValue(), param.expectedValue); } INSTANTIATE_TEST_SUITE_P( @@ -119,9 +119,9 @@ namespace ECFMPTest::Api { json["type"] = param.jsonType; json["value"] = param.jsonValue; auto measure = parser.Parse(json); - ASSERT_NE(measure, nullptr); - ASSERT_EQ(measure->Type(), param.expectedType); - ASSERT_EQ(measure->SetValue(), param.expectedValue); + EXPECT_NE(measure, nullptr); + EXPECT_EQ(measure->Type(), param.expectedType); + EXPECT_EQ(measure->SetValue(), param.expectedValue); } INSTANTIATE_TEST_SUITE_P( @@ -157,8 +157,8 @@ namespace ECFMPTest::Api { json["type"] = param.jsonType; json["value"] = param.jsonValue; auto measure = parser.Parse(json); - ASSERT_NE(measure, nullptr); - ASSERT_EQ(measure->Type(), param.expectedType); + EXPECT_NE(measure, nullptr); + EXPECT_EQ(measure->Type(), param.expectedType); } INSTANTIATE_TEST_SUITE_P( @@ -195,7 +195,7 @@ namespace ECFMPTest::Api { TEST_P(FlowMeasureMeasureParserBadDataTest, ItReturnsNullptrBadData) { const auto& param = GetParam(); - ASSERT_EQ(nullptr, parser.Parse(param.json)); + EXPECT_EQ(nullptr, parser.Parse(param.json)); } INSTANTIATE_TEST_SUITE_P( diff --git a/test/flowmeasure/ConcreteAirportFilterTest.cpp b/test/flowmeasure/ConcreteAirportFilterTest.cpp index a7ad9a6..e82999a 100644 --- a/test/flowmeasure/ConcreteAirportFilterTest.cpp +++ b/test/flowmeasure/ConcreteAirportFilterTest.cpp @@ -1,4 +1,5 @@ #include "flowmeasure/ConcreteAirportFilter.h" +#include "mock/MockEuroscopeAircraft.h" namespace ECFMPTest::FlowMeasure { @@ -33,18 +34,41 @@ namespace ECFMPTest::FlowMeasure { class ConcreteAirportFilterApplicabilityTest : public testing::TestWithParam { public: - ConcreteAirportFilterApplicabilityTest() - : airportFilter( - std::set{"EGKK", "LF", "EDD", "K"}, ECFMP::FlowMeasure::AirportFilterType::Destination - ) - {} - - ECFMP::FlowMeasure::ConcreteAirportFilter airportFilter; + [[nodiscard]] static auto GetFilter(ECFMP::FlowMeasure::AirportFilterType type) + -> ECFMP::FlowMeasure::ConcreteAirportFilter + { + return ECFMP::FlowMeasure::ConcreteAirportFilter(std::set{"EGKK", "LF", "EDD", "K"}, type); + } }; TEST_P(ConcreteAirportFilterApplicabilityTest, ItChecksAirportApplicability) { - EXPECT_EQ(GetParam().expected, airportFilter.ApplicableToAirport(GetParam().airport)); + EXPECT_EQ( + GetParam().expected, + GetFilter(ECFMP::FlowMeasure::AirportFilterType::Destination).ApplicableToAirport(GetParam().airport) + ); + } + + TEST_P(ConcreteAirportFilterApplicabilityTest, ItChecksDepartureAirportApplicabilityForAircraft) + { + const auto aircraft = testing::NiceMock(); + EXPECT_CALL(aircraft, DepartureAirport).WillRepeatedly(testing::Return(GetParam().airport)); + + EXPECT_EQ( + GetParam().expected, + GetFilter(ECFMP::FlowMeasure::AirportFilterType::Departure).ApplicableToAirport(GetParam().airport) + ); + } + + TEST_P(ConcreteAirportFilterApplicabilityTest, ItChecksDestinationAirportApplicabilityForAircraft) + { + const auto aircraft = testing::NiceMock(); + EXPECT_CALL(aircraft, DepartureAirport).WillRepeatedly(testing::Return(GetParam().airport)); + + EXPECT_EQ( + GetParam().expected, + GetFilter(ECFMP::FlowMeasure::AirportFilterType::Destination).ApplicableToAirport(GetParam().airport) + ); } INSTANTIATE_TEST_SUITE_P( diff --git a/test/flowmeasure/ConcreteEventFilterTest.cpp b/test/flowmeasure/ConcreteEventFilterTest.cpp index 91468f0..4bc5e79 100644 --- a/test/flowmeasure/ConcreteEventFilterTest.cpp +++ b/test/flowmeasure/ConcreteEventFilterTest.cpp @@ -1,6 +1,8 @@ #include "flowmeasure/ConcreteEventFilter.h" #include "event/ConcreteEvent.h" +#include "event/ConcreteEventParticipant.h" #include "flightinformationregion/ConcreteFlightInformationRegion.h" +#include "mock/MockEuroscopeAircraft.h" namespace ECFMPTest::FlowMeasure { @@ -12,7 +14,8 @@ namespace ECFMPTest::FlowMeasure { ), event(std::make_shared( 1, "TEST", std::chrono::system_clock::now(), std::chrono::system_clock::now(), fir, "ABC", - std::vector>{} + std::vector>{ + std::make_shared(1, "EGGD", "EGLL")} )), eventFilter(event, ECFMP::FlowMeasure::EventParticipation::NotParticipating) {} @@ -48,4 +51,70 @@ namespace ECFMPTest::FlowMeasure { EXPECT_TRUE(eventFilter.ApplicableToEvent(*event)); EXPECT_FALSE(eventFilter.ApplicableToEvent(event2)); } + + TEST_F(ConcreteEventFilterTest, ItsApplicableToAircraftIfParticipatingFilterAndCidIsZero) + { + const auto aircraft = testing::NiceMock(); + ON_CALL(aircraft, Cid).WillByDefault(testing::Return(0)); + + ECFMP::FlowMeasure::ConcreteEventFilter eventFilter2( + event, ECFMP::FlowMeasure::EventParticipation::Participating + ); + EXPECT_TRUE(eventFilter2.ApplicableToAircraft(aircraft)); + } + + TEST_F(ConcreteEventFilterTest, ItsApplicableToAircraftIfNotParticipatingFilterAndCidIsZero) + { + const auto aircraft = testing::NiceMock(); + ON_CALL(aircraft, Cid).WillByDefault(testing::Return(0)); + + ECFMP::FlowMeasure::ConcreteEventFilter eventFilter2( + event, ECFMP::FlowMeasure::EventParticipation::NotParticipating + ); + EXPECT_TRUE(eventFilter2.ApplicableToAircraft(aircraft)); + } + + TEST_F(ConcreteEventFilterTest, ItsApplicableToAircraftIfParticipatingFilterAndAircraftParticipating) + { + const auto aircraft = testing::NiceMock(); + ON_CALL(aircraft, Cid).WillByDefault(testing::Return(1)); + + ECFMP::FlowMeasure::ConcreteEventFilter eventFilter2( + event, ECFMP::FlowMeasure::EventParticipation::Participating + ); + EXPECT_TRUE(eventFilter2.ApplicableToAircraft(aircraft)); + } + + TEST_F(ConcreteEventFilterTest, ItsApplicableToAircraftIfNotParticipatingFilterAndAircraftNotParticipating) + { + const auto aircraft = testing::NiceMock(); + ON_CALL(aircraft, Cid).WillByDefault(testing::Return(2)); + + ECFMP::FlowMeasure::ConcreteEventFilter eventFilter2( + event, ECFMP::FlowMeasure::EventParticipation::NotParticipating + ); + EXPECT_TRUE(eventFilter2.ApplicableToAircraft(aircraft)); + } + + TEST_F(ConcreteEventFilterTest, ItsNotApplicableToAircraftIfParticipatingFilterAndAircraftNotParticipating) + { + const auto aircraft = testing::NiceMock(); + ON_CALL(aircraft, Cid).WillByDefault(testing::Return(2)); + + ECFMP::FlowMeasure::ConcreteEventFilter eventFilter2( + event, ECFMP::FlowMeasure::EventParticipation::Participating + ); + EXPECT_FALSE(eventFilter2.ApplicableToAircraft(aircraft)); + } + + TEST_F(ConcreteEventFilterTest, ItsNotApplicableToAircraftIfNotParticipatingFilterAndAircraftParticipating) + { + const auto aircraft = testing::NiceMock(); + ON_CALL(aircraft, Cid).WillByDefault(testing::Return(1)); + + ECFMP::FlowMeasure::ConcreteEventFilter eventFilter2( + event, ECFMP::FlowMeasure::EventParticipation::NotParticipating + ); + EXPECT_FALSE(eventFilter2.ApplicableToAircraft(aircraft)); + } }// namespace ECFMPTest::FlowMeasure diff --git a/test/flowmeasure/ConcreteFlowMeasureFiltersTest.cpp b/test/flowmeasure/ConcreteFlowMeasureFiltersTest.cpp index 31c3d43..b1d6df1 100644 --- a/test/flowmeasure/ConcreteFlowMeasureFiltersTest.cpp +++ b/test/flowmeasure/ConcreteFlowMeasureFiltersTest.cpp @@ -1,5 +1,7 @@ #include "flowmeasure/ConcreteFlowMeasureFilters.h" +#include "EuroScopePlugIn.h" #include "event/ConcreteEvent.h" +#include "event/ConcreteEventParticipant.h" #include "flightinformationregion/ConcreteFlightInformationRegion.h" #include "flowmeasure/ConcreteAirportFilter.h" #include "flowmeasure/ConcreteEventFilter.h" @@ -7,45 +9,65 @@ #include "flowmeasure/ConcreteMultipleLevelFilter.h" #include "flowmeasure/ConcreteRangeToDestinationFilter.h" #include "flowmeasure/ConcreteRouteFilter.h" +#include "mock/MockEuroscopeAircraft.h" +#include "mock/MockEuroscopeAircraftFactory.h" namespace ECFMPTest::FlowMeasure { class ConcreteFlowMeasureFiltersTest : public testing::Test { public: ConcreteFlowMeasureFiltersTest() - : filters( - std::list>{ - std::make_shared( - std::set{"EGLL"}, ECFMP::FlowMeasure::AirportFilterType::Departure - )}, - std::list>{ - std::make_shared( - std::make_shared( - 1, "Test", std::chrono::system_clock::now(), - std::chrono::system_clock::now(), - std::make_shared< - ECFMP::FlightInformationRegion::ConcreteFlightInformationRegion>( - 1, "EGTT", "London" - ), - "ABC", std::vector>{} - ), - ECFMP::FlowMeasure::EventParticipation::Participating - ), - }, - std::list>{ - std::make_shared(std::set{"XAMAB"})}, - std::list>{ - std::make_shared( - ECFMP::FlowMeasure::LevelRangeFilterType::AtOrBelow, 150 - )}, - std::list>{ - std::make_shared(std::vector{150, 200} - )}, - std::list>{ - std::make_shared(1)} - ) - {} + : aircraftFactory(std::make_shared>()), + mockAircraft(std::make_shared>()), + filters( + std::list>{ + std::make_shared( + std::set{"EGLL"}, ECFMP::FlowMeasure::AirportFilterType::Departure + )}, + std::list>{ + std::make_shared( + std::make_shared( + 1, "Test", std::chrono::system_clock::now(), + std::chrono::system_clock::now(), + std::make_shared< + ECFMP::FlightInformationRegion::ConcreteFlightInformationRegion>( + 1, "EGTT", "London" + ), + "ABC", + std::vector>{ + std::make_shared( + 1, "EGLL", "EGKK" + )} + ), + ECFMP::FlowMeasure::EventParticipation::Participating + ), + }, + std::list>{ + std::make_shared(std::set{"XAMAB"} + )}, + std::list>{ + std::make_shared( + ECFMP::FlowMeasure::LevelRangeFilterType::AtOrBelow, 150 + )}, + std::list>{ + std::make_shared(std::vector{ + 150, 200})}, + std::list>{ + std::make_shared(100)}, + aircraftFactory + ) + { + ON_CALL(*aircraftFactory, Make(testing::_, testing::_)).WillByDefault(testing::Return(mockAircraft)); + ON_CALL(*mockAircraft, RouteString).WillByDefault(testing::Return("XAMAB")); + ON_CALL(*mockAircraft, DepartureAirport).WillByDefault(testing::Return("EGLL")); + ON_CALL(*mockAircraft, CruiseAltitude).WillByDefault(testing::Return(15000)); + ON_CALL(*mockAircraft, RangeToDestination).WillByDefault(testing::Return(99.0)); + ON_CALL(*mockAircraft, Cid).WillByDefault(testing::Return(1)); + } + + std::shared_ptr> aircraftFactory; + std::shared_ptr> mockAircraft; ECFMP::FlowMeasure::ConcreteFlowMeasureFilters filters; }; @@ -157,10 +179,10 @@ namespace ECFMPTest::FlowMeasure { TEST_F(ConcreteFlowMeasureFiltersTest, ItReturnsApplicableRangeToDestinationFilter) { EXPECT_EQ( - 1, + 100, filters.FirstRangeToDestinationFilter( [](const ECFMP::FlowMeasure::RangeToDestinationFilter& rangeToDestinationFilter) { - return rangeToDestinationFilter.Range() == 1; + return rangeToDestinationFilter.Range() == 100; } )->Range() ); @@ -239,4 +261,45 @@ namespace ECFMPTest::FlowMeasure { EXPECT_EQ(1, filterCount); } + + TEST_F(ConcreteFlowMeasureFiltersTest, ItsApplicableToAircraftIfAllFiltersPass) + { + EXPECT_TRUE(filters.ApplicableToAircraft(EuroScopePlugIn::CFlightPlan(), EuroScopePlugIn::CRadarTarget())); + } + + TEST_F(ConcreteFlowMeasureFiltersTest, ItsNotApplicableToAircraftIfAirportFiltersFail) + { + ON_CALL(*mockAircraft, DepartureAirport).WillByDefault(testing::Return("EGKK")); + EXPECT_FALSE(filters.ApplicableToAircraft(EuroScopePlugIn::CFlightPlan(), EuroScopePlugIn::CRadarTarget())); + } + + TEST_F(ConcreteFlowMeasureFiltersTest, ItsNotApplicableToAircraftIfEventFiltersFail) + { + ON_CALL(*mockAircraft, Cid).WillByDefault(testing::Return(2)); + EXPECT_FALSE(filters.ApplicableToAircraft(EuroScopePlugIn::CFlightPlan(), EuroScopePlugIn::CRadarTarget())); + } + + TEST_F(ConcreteFlowMeasureFiltersTest, ItsNotApplicableToAircraftIfLevelRangeFiltersFail) + { + ON_CALL(*mockAircraft, CruiseAltitude).WillByDefault(testing::Return(20000)); + EXPECT_FALSE(filters.ApplicableToAircraft(EuroScopePlugIn::CFlightPlan(), EuroScopePlugIn::CRadarTarget())); + } + + TEST_F(ConcreteFlowMeasureFiltersTest, ItsNotApplicableToAircraftIfMultipleLevelFiltersFail) + { + ON_CALL(*mockAircraft, CruiseAltitude).WillByDefault(testing::Return(14000)); + EXPECT_FALSE(filters.ApplicableToAircraft(EuroScopePlugIn::CFlightPlan(), EuroScopePlugIn::CRadarTarget())); + } + + TEST_F(ConcreteFlowMeasureFiltersTest, ItsNotApplicableToAircraftIfRouteFiltersFail) + { + ON_CALL(*mockAircraft, RouteString).WillByDefault(testing::Return("VEULE")); + EXPECT_FALSE(filters.ApplicableToAircraft(EuroScopePlugIn::CFlightPlan(), EuroScopePlugIn::CRadarTarget())); + } + + TEST_F(ConcreteFlowMeasureFiltersTest, ItsNotApplicableToAircraftIfRangeToDestinationFiltersFail) + { + ON_CALL(*mockAircraft, RangeToDestination).WillByDefault(testing::Return(101.0)); + EXPECT_FALSE(filters.ApplicableToAircraft(EuroScopePlugIn::CFlightPlan(), EuroScopePlugIn::CRadarTarget())); + } }// namespace ECFMPTest::FlowMeasure diff --git a/test/flowmeasure/ConcreteFlowMeasureTest.cpp b/test/flowmeasure/ConcreteFlowMeasureTest.cpp index 060be57..881b037 100644 --- a/test/flowmeasure/ConcreteFlowMeasureTest.cpp +++ b/test/flowmeasure/ConcreteFlowMeasureTest.cpp @@ -8,6 +8,7 @@ #include "flowmeasure/ConcreteAirportFilter.h" #include "flowmeasure/ConcreteFlowMeasureFilters.h" #include "flowmeasure/ConcreteMeasure.h" +#include "mock/MockEuroscopeAircraftFactory.h" namespace ECFMPTest::FlowMeasure { class ConcreteFlowMeasureTest : public testing::Test @@ -44,7 +45,8 @@ namespace ECFMPTest::FlowMeasure { std::list>{}, std::list>{}, std::list>{}, - std::list>{} + std::list>{}, + std::make_shared() ) ), measureWithNoEvent( @@ -57,7 +59,8 @@ namespace ECFMPTest::FlowMeasure { std::list>{}, std::list>{}, std::list>{}, - std::list>{} + std::list>{}, + std::make_shared() ) ), withdrawnMeasure( @@ -70,7 +73,8 @@ namespace ECFMPTest::FlowMeasure { std::list>{}, std::list>{}, std::list>{}, - std::list>{} + std::list>{}, + std::make_shared() ) ) {} @@ -121,7 +125,8 @@ namespace ECFMPTest::FlowMeasure { std::list>{}, std::list>{}, std::list>{}, - std::list>{} + std::list>{}, + std::make_shared() ) ); diff --git a/test/flowmeasure/ConcreteLevelRangeFilterTest.cpp b/test/flowmeasure/ConcreteLevelRangeFilterTest.cpp index f545ba1..6e5d145 100644 --- a/test/flowmeasure/ConcreteLevelRangeFilterTest.cpp +++ b/test/flowmeasure/ConcreteLevelRangeFilterTest.cpp @@ -1,4 +1,5 @@ #include "flowmeasure/ConcreteLevelRangeFilter.h" +#include "mock/MockEuroscopeAircraft.h" namespace ECFMPTest::FlowMeasure { @@ -53,7 +54,7 @@ namespace ECFMPTest::FlowMeasure { { }; - TEST_P(ConcreteLevelFilterApplicabilityTest, ItChecksAirportApplicability) + TEST_P(ConcreteLevelFilterApplicabilityTest, ItChecksApplicability) { ECFMP::FlowMeasure::ConcreteLevelRangeFilter filter(GetParam().filterType, GetParam().filterLevel); if (GetParam().checkType == ApplicabilityCheckType::Level) { @@ -118,4 +119,61 @@ namespace ECFMPTest::FlowMeasure { return name; } ); + + using LevelFilterAircraftApplicabilityCheck = struct LevelFilterAircraftApplicabilityCheck { + // The filter type + ECFMP::FlowMeasure::LevelRangeFilterType filterType; + + // The level for the filter + int filterLevel; + + // The level to check against + int checkLevel; + + // Expected applicability + bool expectedApplicability; + }; + + class ConcreteLevelFilterAircraftApplicabilityTest + : public testing::TestWithParam + { + }; + + TEST_P(ConcreteLevelFilterAircraftApplicabilityTest, ItChecksApplicabilityForAircraft) + { + ECFMP::FlowMeasure::ConcreteLevelRangeFilter filter(GetParam().filterType, GetParam().filterLevel); + const auto aircraft = testing::NiceMock(); + ON_CALL(aircraft, CruiseAltitude).WillByDefault(testing::Return(GetParam().checkLevel)); + EXPECT_EQ(GetParam().expectedApplicability, filter.ApplicableToAircraft(aircraft)); + } + + INSTANTIATE_TEST_SUITE_P( + ConcreteLevelFilterAircraftApplicabilityTestCases, ConcreteLevelFilterAircraftApplicabilityTest, + testing::Values( + LevelFilterAircraftApplicabilityCheck{ECFMP::FlowMeasure::AtOrBelow, 350, 35000, true}, + LevelFilterAircraftApplicabilityCheck{ECFMP::FlowMeasure::AtOrBelow, 350, 34000, true}, + LevelFilterAircraftApplicabilityCheck{ECFMP::FlowMeasure::AtOrBelow, 350, 36000, false}, + LevelFilterAircraftApplicabilityCheck{ECFMP::FlowMeasure::AtOrAbove, 350, 35000, true}, + LevelFilterAircraftApplicabilityCheck{ECFMP::FlowMeasure::AtOrAbove, 350, 36000, true}, + LevelFilterAircraftApplicabilityCheck{ECFMP::FlowMeasure::AtOrAbove, 350, 34000, false} + ), + [](const ::testing::TestParamInfo& info) { + std::string name; + switch (info.param.filterType) { + case ECFMP::FlowMeasure::AtOrBelow: { + name += "AtOrBelow_"; + break; + } + case ECFMP::FlowMeasure::AtOrAbove: { + name += "AtOrAbove_"; + break; + } + } + + name += std::to_string(info.param.filterLevel) + "_with_altitude_"; + name += std::to_string(info.param.checkLevel); + + return name; + } + ); }// namespace ECFMPTest::FlowMeasure diff --git a/test/flowmeasure/ConcreteMultipleLevelFilterTest.cpp b/test/flowmeasure/ConcreteMultipleLevelFilterTest.cpp index 9644ed1..e8f1c23 100644 --- a/test/flowmeasure/ConcreteMultipleLevelFilterTest.cpp +++ b/test/flowmeasure/ConcreteMultipleLevelFilterTest.cpp @@ -1,4 +1,5 @@ #include "flowmeasure/ConcreteMultipleLevelFilter.h" +#include "mock/MockEuroscopeAircraft.h" namespace ECFMPTest::FlowMeasure { @@ -14,42 +15,56 @@ namespace ECFMPTest::FlowMeasure { TEST_F(ConcreteMultipleFlowLevelFilterTest, ItReturnsLevels) { auto expected = std::vector{340, 360, 390}; - ASSERT_EQ(filter.Levels().size(), 3); - ASSERT_EQ(filter.Levels(), expected); + EXPECT_EQ(filter.Levels().size(), 3); + EXPECT_EQ(filter.Levels(), expected); } TEST_F(ConcreteMultipleFlowLevelFilterTest, ItReturnsAltitudes) { auto expected = std::vector{34000, 36000, 39000}; - ASSERT_EQ(filter.Altitudes().size(), 3); - ASSERT_EQ(filter.Altitudes(), expected); + EXPECT_EQ(filter.Altitudes().size(), 3); + EXPECT_EQ(filter.Altitudes(), expected); } TEST_F(ConcreteMultipleFlowLevelFilterTest, ItReturnsTrueForApplicableLevel) { - ASSERT_TRUE(filter.ApplicableToLevel(340)); - ASSERT_TRUE(filter.ApplicableToLevel(360)); - ASSERT_TRUE(filter.ApplicableToLevel(390)); + EXPECT_TRUE(filter.ApplicableToLevel(340)); + EXPECT_TRUE(filter.ApplicableToLevel(360)); + EXPECT_TRUE(filter.ApplicableToLevel(390)); } TEST_F(ConcreteMultipleFlowLevelFilterTest, ItReturnsFalseForNonApplicableLevel) { - ASSERT_FALSE(filter.ApplicableToLevel(350)); - ASSERT_FALSE(filter.ApplicableToLevel(370)); - ASSERT_FALSE(filter.ApplicableToLevel(380)); + EXPECT_FALSE(filter.ApplicableToLevel(350)); + EXPECT_FALSE(filter.ApplicableToLevel(370)); + EXPECT_FALSE(filter.ApplicableToLevel(380)); } TEST_F(ConcreteMultipleFlowLevelFilterTest, ItReturnsTrueForApplicableAltitude) { - ASSERT_TRUE(filter.ApplicableToAltitude(34000)); - ASSERT_TRUE(filter.ApplicableToAltitude(36000)); - ASSERT_TRUE(filter.ApplicableToAltitude(39000)); + EXPECT_TRUE(filter.ApplicableToAltitude(34000)); + EXPECT_TRUE(filter.ApplicableToAltitude(36000)); + EXPECT_TRUE(filter.ApplicableToAltitude(39000)); } TEST_F(ConcreteMultipleFlowLevelFilterTest, ItReturnsFalseForNonApplicableAltitude) { - ASSERT_FALSE(filter.ApplicableToAltitude(35000)); - ASSERT_FALSE(filter.ApplicableToAltitude(37000)); - ASSERT_FALSE(filter.ApplicableToAltitude(38000)); + EXPECT_FALSE(filter.ApplicableToAltitude(35000)); + EXPECT_FALSE(filter.ApplicableToAltitude(37000)); + EXPECT_FALSE(filter.ApplicableToAltitude(38000)); + } + + TEST_F(ConcreteMultipleFlowLevelFilterTest, ItReturnsTrueForApplicableAltitudeForAircraft) + { + const auto aircraft = testing::NiceMock(); + ON_CALL(aircraft, CruiseAltitude).WillByDefault(testing::Return(34000)); + EXPECT_TRUE(filter.ApplicableToAircraft(aircraft)); + } + + TEST_F(ConcreteMultipleFlowLevelFilterTest, ItReturnsFalseForNonApplicableAltitudeForAircraft) + { + const auto aircraft = testing::NiceMock(); + ON_CALL(aircraft, CruiseAltitude).WillByDefault(testing::Return(35000)); + EXPECT_FALSE(filter.ApplicableToAircraft(aircraft)); } }// namespace ECFMPTest::FlowMeasure diff --git a/test/flowmeasure/ConcreteRangeToDestinationFilterTest.cpp b/test/flowmeasure/ConcreteRangeToDestinationFilterTest.cpp index 88c787c..d85efa3 100644 --- a/test/flowmeasure/ConcreteRangeToDestinationFilterTest.cpp +++ b/test/flowmeasure/ConcreteRangeToDestinationFilterTest.cpp @@ -1,4 +1,5 @@ #include "flowmeasure/ConcreteRangeToDestinationFilter.h" +#include "mock/MockEuroscopeAircraft.h" namespace ECFMPTest::FlowMeasure { class ConcreteRangeToDestinationFilterTest : public ::testing::Test @@ -9,6 +10,27 @@ namespace ECFMPTest::FlowMeasure { TEST_F(ConcreteRangeToDestinationFilterTest, RangeReturnsRange) { - ASSERT_EQ(filter.Range(), 123); + EXPECT_EQ(filter.Range(), 123); + } + + TEST_F(ConcreteRangeToDestinationFilterTest, FilterReturnsTrueIfApplicableToAircraftEqual) + { + testing::NiceMock aircraft; + EXPECT_CALL(aircraft, RangeToDestination).WillOnce(testing::Return(123.0)); + EXPECT_TRUE(filter.ApplicableToAircraft(aircraft)); + } + + TEST_F(ConcreteRangeToDestinationFilterTest, FilterReturnsTrueIfApplicableToAircraftLessThan) + { + testing::NiceMock aircraft; + EXPECT_CALL(aircraft, RangeToDestination).WillOnce(testing::Return(121.0)); + EXPECT_TRUE(filter.ApplicableToAircraft(aircraft)); + } + + TEST_F(ConcreteRangeToDestinationFilterTest, FilterReturnsFalseIfApplicableToAircraftMoreThan) + { + testing::NiceMock aircraft; + EXPECT_CALL(aircraft, RangeToDestination).WillOnce(testing::Return(123.1)); + EXPECT_FALSE(filter.ApplicableToAircraft(aircraft)); } }// namespace ECFMPTest::FlowMeasure diff --git a/test/flowmeasure/ConcreteRouteFilterTest.cpp b/test/flowmeasure/ConcreteRouteFilterTest.cpp index b2883d9..6f08e88 100644 --- a/test/flowmeasure/ConcreteRouteFilterTest.cpp +++ b/test/flowmeasure/ConcreteRouteFilterTest.cpp @@ -1,4 +1,5 @@ #include "flowmeasure/ConcreteRouteFilter.h" +#include "mock/MockEuroscopeAircraft.h" namespace ECFMPTest::FlowMeasure { @@ -15,4 +16,18 @@ namespace ECFMPTest::FlowMeasure { { EXPECT_EQ(std::set({"ABC", "DEF", "GHI"}), routeFilter.RouteStrings()); } + + TEST_F(ConcreteRouteFilterTest, ItsApplicableToAircraftIfRouteStringIsFound) + { + testing::NiceMock aircraft; + EXPECT_CALL(aircraft, RouteString).WillOnce(testing::Return("LOL ABC LOL")); + EXPECT_TRUE(routeFilter.ApplicableToAircraft(aircraft)); + } + + TEST_F(ConcreteRouteFilterTest, ItsNotApplicableToAircraftIfRouteStringIsNotFound) + { + testing::NiceMock aircraft; + EXPECT_CALL(aircraft, RouteString).WillRepeatedly(testing::Return("LOL ADG LOL")); + EXPECT_FALSE(routeFilter.ApplicableToAircraft(aircraft)); + } }// namespace ECFMPTest::FlowMeasure diff --git a/test/mock/MockEuroscopeAircraft.h b/test/mock/MockEuroscopeAircraft.h new file mode 100644 index 0000000..5b5c7eb --- /dev/null +++ b/test/mock/MockEuroscopeAircraft.h @@ -0,0 +1,19 @@ +#pragma once +#include "euroscope/EuroscopeAircraft.h" +#include + +namespace ECFMPTest::Euroscope { + + class MockEuroscopeAircraft : public ECFMP::Euroscope::EuroscopeAircraft + { + public: + MOCK_METHOD(int, Cid, (), (const, override)); + MOCK_METHOD(int, CurrentAltitudeStandardPressure, (), (const, override)); + MOCK_METHOD(int, CruiseAltitude, (), (const, override)); + MOCK_METHOD(int, GroundSpeed, (), (const, override)); + MOCK_METHOD(std::string, DepartureAirport, (), (const, override)); + MOCK_METHOD(std::string, DestinationAirport, (), (const, override)); + MOCK_METHOD(double, RangeToDestination, (), (const, override)); + MOCK_METHOD(std::string, RouteString, (), (const, override)); + }; +}// namespace ECFMPTest::Euroscope diff --git a/test/mock/MockEuroscopeAircraftFactory.h b/test/mock/MockEuroscopeAircraftFactory.h new file mode 100644 index 0000000..220e693 --- /dev/null +++ b/test/mock/MockEuroscopeAircraftFactory.h @@ -0,0 +1,19 @@ +#pragma once +#include "euroscope/EuroscopeAircraftFactory.h" +#include + +namespace EuroScopePlugIn { + class CFlightPlan; + class CRadarTarget; +}// namespace EuroScopePlugIn + +namespace ECFMPTest::Euroscope { + class MockEuroscopeAircraftFactory : public ECFMP::Euroscope::EuroscopeAircraftFactory + { + public: + MOCK_METHOD( + std::shared_ptr, Make, + (const EuroScopePlugIn::CFlightPlan&, const EuroScopePlugIn::CRadarTarget&), (const, noexcept, override) + ); + }; +}// namespace ECFMPTest::Euroscope diff --git a/test/pch/pch.h b/test/pch/pch.h index 594ac85..2d23219 100644 --- a/test/pch/pch.h +++ b/test/pch/pch.h @@ -3,5 +3,6 @@ #include "gmock/gmock.h" #include "gtest/gtest.h" +#include #include #include diff --git a/third_party/euroscope/EuroScopePlugIn.h b/third_party/euroscope/EuroScopePlugIn.h new file mode 100644 index 0000000..e163ef3 --- /dev/null +++ b/third_party/euroscope/EuroScopePlugIn.h @@ -0,0 +1,4406 @@ +#pragma once + +#ifndef DllSpecEuroScope +#define DllSpecEuroScope __declspec(dllimport) +#define ESINDEX void* +#endif + +// external undefined classes +class CRadarView; +class CPlugInData; + +namespace EuroScopePlugIn { + const int COMPATIBILITY_CODE = 16; + + const int FLIGHT_PLAN_STATE_NOT_STARTED = 0; + const int FLIGHT_PLAN_STATE_SIMULATED = 1; + const int FLIGHT_PLAN_STATE_TERMINATED = 2; + + const int FLIGHT_PLAN_STATE_NON_CONCERNED = 0; + const int FLIGHT_PLAN_STATE_NOTIFIED = 1; + const int FLIGHT_PLAN_STATE_COORDINATED = 2; + const int FLIGHT_PLAN_STATE_TRANSFER_TO_ME_INITIATED = 3; + const int FLIGHT_PLAN_STATE_TRANSFER_FROM_ME_INITIATED = 4; + const int FLIGHT_PLAN_STATE_ASSUMED = 5; + const int FLIGHT_PLAN_STATE_REDUNDANT = 7; + + const int AIRWAY_CLASS_VALID = 0; + const int AIRWAY_CLASS_DIRECTION_ERROR = 1; + const int AIRWAY_CLASS_UNCONNECTED = 2; + const int AIRWAY_CLASS_NO_DATA_DIRECT = 3; + + const int CTR_DATA_TYPE_SQUAWK = 1; + const int CTR_DATA_TYPE_FINAL_ALTITUDE = 2; + const int CTR_DATA_TYPE_TEMPORARY_ALTITUDE = 3; + const int CTR_DATA_TYPE_COMMUNICATION_TYPE = 4; + const int CTR_DATA_TYPE_SCRATCH_PAD_STRING = 5; + const int CTR_DATA_TYPE_GROUND_STATE = 6; + const int CTR_DATA_TYPE_CLEARENCE_FLAG = 7; + const int CTR_DATA_TYPE_DEPARTURE_SEQUENCE = 8; + const int CTR_DATA_TYPE_SPEED = 9; + const int CTR_DATA_TYPE_MACH = 10; + const int CTR_DATA_TYPE_RATE = 11; + const int CTR_DATA_TYPE_HEADING = 12; + const int CTR_DATA_TYPE_DIRECT_TO = 13; + + const int REFRESH_PHASE_BACK_BITMAP = 0; + const int REFRESH_PHASE_BEFORE_TAGS = 1; + const int REFRESH_PHASE_AFTER_TAGS = 2; + const int REFRESH_PHASE_AFTER_LISTS = 3; + + const int TAG_COLOR_DEFAULT = 0; + const int TAG_COLOR_RGB_DEFINED = 1; + const int TAG_COLOR_NON_CONCERNED = 2; + const int TAG_COLOR_NOTIFIED = 3; + const int TAG_COLOR_ASSUMED = 4; + const int TAG_COLOR_TRANSFER_TO_ME_INITIATED = 5; + const int TAG_COLOR_REDUNDANT = 6; + const int TAG_COLOR_INFORMATION = 7; + const int TAG_COLOR_ONGOING_REQUEST_FROM_ME = 8; + const int TAG_COLOR_ONGOING_REQUEST_TO_ME = 9; + const int TAG_COLOR_ONGOING_REQUEST_ACCEPTED = 10; + const int TAG_COLOR_ONGOING_REQUEST_REFUSED = 11; + const int TAG_COLOR_EMERGENCY = 12; + + const int TAG_TYPE_UNTAGGED = 0; + const int TAG_TYPE_TAGGED = 1; + const int TAG_TYPE_DETAILED = 2; + const int TAG_TYPE_TSSR = 3; + + const int TAG_ITEM_TYPE_NEXT_LINE = 0; + const int TAG_ITEM_TYPE_STATIC_STRING = 1; + const int TAG_ITEM_TYPE_SQUAWK = 2; + const int TAG_ITEM_TYPE_VERTICAL_SPEED_INDICATOR = 3; + const int TAG_ITEM_TYPE_ALTITUDE = 4; + const int TAG_ITEM_TYPE_EMERGENCY_INDICATOR = 5; + const int TAG_ITEM_TYPE_RADIO_FAILURE_INDICATOR = 6; + const int TAG_ITEM_TYPE_HIJACK_INDICATOR = 7; + const int TAG_ITEM_TYPE_COLLOSION_ALERT = 8; + const int TAG_ITEM_TYPE_CALLSIGN = 9; + const int TAG_ITEM_TYPE_AIRCRAFT_CATEGORY = 10; + const int TAG_ITEM_TYPE_COMMUNICATION_TYPE = 11; + const int TAG_ITEM_TYPE_VERTICAL_SPEED = 12; + const int TAG_ITEM_TYPE_GROUND_SPEED_WITH_N = 13; + const int TAG_ITEM_TYPE_HANDOFF_TARGET = 14; + const int TAG_ITEM_TYPE_OWNER = 15; + const int TAG_ITEM_TYPE_PLANE_TYPE = 16; + const int TAG_ITEM_TYPE_DESTINATION = 17; + const int TAG_ITEM_TYPE_SQUAWK_ERROR = 18; + const int TAG_ITEM_TYPE_INFO_STRING = 19; + const int TAG_ITEM_TYPE_TEMP_ALTITUDE = 20; + const int TAG_ITEM_TYPE_INFO_INDICATOR = 21; + const int TAG_ITEM_TYPE_FINAL_ALTITUDE = 22; + const int TAG_ITEM_TYPE_ASSIGNED_SPEED = 23; + const int TAG_ITEM_TYPE_ASSIGNED_RATE = 24; + const int TAG_ITEM_TYPE_ASSIGNED_HEADING = 25; + const int TAG_ITEM_TYPE_SECTOR_INDICATOR = 26; + const int TAG_ITEM_TYPE_DUPLICATED_SQUAWK = 27; + const int TAG_ITEM_TYPE_COPN_COPX_NAME = 28; + const int TAG_ITEM_TYPE_COPN_COPX_ALTITUDE = 29; + const int TAG_ITEM_TYPE_FIR_COPX_NAME = 30; + const int TAG_ITEM_TYPE_COPX_NOT_CLEARED_ALTITUDE = 31; + const int TAG_ITEM_TYPE_COPX_AWERE_TEMP_ALTITUDE = 32; + const int TAG_ITEM_TYPE_NEXT_LINE_IF_NOT_EMPTY = 33; + const int TAG_ITEM_TYPE_DIRECT = 34; + const int TAG_ITEM_TYPE_GROUND_SPEED_OPTIONAL_WITH_N = 35; + const int TAG_ITEM_TYPE_FIR_COPX_NAME_OPTIONAL = 36; + const int TAG_ITEM_TYPE_DESTINATION_OPTIONAL = 37; + const int TAG_ITEM_TYPE_PLANE_TYPE_OPTIONAL = 38; + const int TAG_ITEM_TYPE_TSSR = 39; + const int TAG_ITEM_TYPE_GROUND_SPEED_WOUT_N = 40; + const int TAG_ITEM_TYPE_GROUND_SPEED_OPTIONAL_WOUT_N = 41; + const int TAG_ITEM_TYPE_COMPOUND_WARNING = 42; + const int TAG_ITEM_TYPE_TEMP_IFSET = 43; + const int TAG_ITEM_TYPE_ASSIGNED_SPEED_IFSET = 44; + const int TAG_ITEM_TYPE_ASSIGNED_RATE_IFSET = 45; + const int TAG_ITEM_TYPE_ASSIGNED_HEADING_IFSET = 46; + const int TAG_ITEM_TYPE_ASSIGNED_RUNWAY = 47; + const int TAG_ITEM_TYPE_COPN_NAME = 48; + const int TAG_ITEM_TYPE_COPN_ALTITUDE = 49; + const int TAG_ITEM_TYPE_COPN_TIME = 50; + const int TAG_ITEM_TYPE_COPX_NAME = 51; + const int TAG_ITEM_TYPE_COPX_ALTITUDE = 52; + const int TAG_ITEM_TYPE_COPX_TIME = 53; + const int TAG_ITEM_TYPE_ETA = 54; + const int TAG_ITEM_TYPE_ASSIGNED_STAR = 55; + const int TAG_ITEM_TYPE_ASSIGNED_SID = 56; + const int TAG_ITEM_TYPE_DEPARTURE_ORDER = 57; + const int TAG_ITEM_TYPE_CLEARENCE = 58; + const int TAG_ITEM_TYPE_GROUND_STATUS = 59; + const int TAG_ITEM_TYPE_ASSIGNED_SQUAWK = 60; + const int TAG_ITEM_TYPE_ORIGIN = 61; + const int TAG_ITEM_TYPE_RVSM_FLAG = 62; + const int TAG_ITEM_TYPE_FLIGHT_RULE = 63; + const int TAG_ITEM_TYPE_SECTOR_INDICATOR_FIX = 64; + const int TAG_ITEM_TYPE_MANUAL_COORDINATION = 65; + const int TAG_ITEM_TYPE_INFO_ALWAYS = 66; + const int TAG_ITEM_TYPE_CLAM_WARNING = 67; + const int TAG_ITEM_TYPE_RAM_WARNING = 68; + const int TAG_ITEM_TYPE_SQ_OR_CALLSIGN = 69; + const int TAG_ITEM_TYPE_TWO_LETTER_GS = 70; + const int TAG_ITEM_TYPE_TWO_LETTER_GS_OPTIONAL = 71; + const int TAG_ITEM_TYPE_TWO_LETTER_ASSIGNED_SPEED = 72; + const int TAG_ITEM_TYPE_TWO_LETTER_ASSIGNED_SPEED_IFSET = 73; + const int TAG_ITEM_TYPE_NOT_REACHED_TEMPORARY = 74; + const int TAG_ITEM_TYPE_NOT_CLEARED_COPN_COPX_ALT = 75; + const int TAG_ITEM_TYPE_AIRCRAFT_CATEGORY_WITH_SLASH = 76; + const int TAG_ITEM_TYPE_NON_RVSM_FLAG = 77; + const int TAG_ITEM_TYPE_AC_TYPE_CATEGORY = 78; + const int TAG_ITEM_TYPE_AC_TYPE_CATEGORY_OPTIONAL = 79; + const int TAG_ITEM_TYPE_COMMUNICATION_TYPE_REDUCED = 80; + const int TAG_ITEM_TYPE_AIRLINE = 81; + const int TAG_ITEM_TYPE_FP_STATUS = 82; + const int TAG_ITEM_TYPE_ESTIMATE = 83; + const int TAG_ITEM_TYPE_ESTIMATE_ALWAYS = 84; + const int TAG_ITEM_TYPE_CONFLICTING_AC_CALLSING = 85; + const int TAG_ITEM_TYPE_CONFLICT_START = 86; + const int TAG_ITEM_TYPE_CONFLICT_END = 87; + const int TAG_ITEM_TYPE_CONFLICT_TYPE = 88; + const int TAG_ITEM_TYPE_MSAW_INDICATOR = 89; + const int TAG_ITEM_TYPE_SIMULATION_INDICATOR = 90; + const int TAG_ITEM_TYPE_SIMULATION_WAYPOINT = 91; + + const int TAG_ITEM_FUNCTION_NO = 0; + const int TAG_ITEM_FUNCTION_TOGGLE_ROUTE_DRAW = 1; + const int TAG_ITEM_FUNCTION_TOGGLE_ITEM_DISPLAY = 2; + const int TAG_ITEM_FUNCTION_TOGGLE_FIR_COPX_DISPLAY = 3; + const int TAG_ITEM_FUNCTION_TOGGLE_DEST_DISPLAY = 4; + const int TAG_ITEM_FUNCTION_TOGGLE_PLANE_TYPE_DISPLAY = 5; + const int TAG_ITEM_FUNCTION_TOGGLE_SI_STYLE = 6; + const int TAG_ITEM_FUNCTION_OPEN_FP_DIALOG = 7; + const int TAG_ITEM_FUNCTION_HANDOFF_POPUP_MENU = 8; + const int TAG_ITEM_FUNCTION_TAKE_HANDOFF = 9; + const int TAG_ITEM_FUNCTION_NEXT_ROUTE_POINTS_POPUP = 10; + const int TAG_ITEM_FUNCTION_TEMP_ALTITUDE_POPUP = 11; + const int TAG_ITEM_FUNCTION_ASSIGNED_SPEED_POPUP = 12; + const int TAG_ITEM_FUNCTION_ASSIGNED_RATE_POPUP = 13; + const int TAG_ITEM_FUNCTION_ASSIGNED_HEADING_POPUP = 14; + const int TAG_ITEM_FUNCTION_ASSIGNED_MACH_POPUP = 15; + const int TAG_ITEM_FUNCTION_TOGGLE_PREDICTION_DRAW = 16; + const int TAG_ITEM_FUNCTION_ASSIGNED_SID = 17; + const int TAG_ITEM_FUNCTION_ASSIGNED_STAR = 18; + const int TAG_ITEM_FUNCTION_ASSIGNED_RUNWAY = 19; + const int TAG_ITEM_FUNCTION_ASSIGNED_NEXT_CONTROLLER = 20; + const int TAG_ITEM_FUNCTION_COPN_NAME = 21; + const int TAG_ITEM_FUNCTION_COPX_NAME = 22; + const int TAG_ITEM_FUNCTION_COPN_ALTITUDE = 23; + const int TAG_ITEM_FUNCTION_COPX_ALTITUDE = 24; + const int TAG_ITEM_FUNCTION_ACCEPT_MANUAL_COORDINATION = 25; + const int TAG_ITEM_FUNCTION_COPN_COPX_ALTITUDE = 26; + const int TAG_ITEM_FUNCTION_SET_CLEARED_FLAG = 27; + const int TAG_ITEM_FUNCTION_SET_GROUND_STATUS = 28; + const int TAG_ITEM_FUNCTION_EDIT_SCRATCH_PAD = 29; + const int TAG_ITEM_FUNCTION_RFL_POPUP = 30; + const int TAG_ITEM_FUNCTION_SQUAWK_POPUP = 31; + const int TAG_ITEM_FUNCTION_COMMUNICATION_POPUP = 32; + const int TAG_ITEM_FUNCTION_CORRELATE_POPUP = 33; + const int TAG_ITEM_FUNCTION_SET_FP_STATUS = 34; + const int TAG_ITEM_FUNCTION_SET_ESTIMATE = 35; + const int TAG_ITEM_FUNCTION_SIMUL_TO_POPUP = 37; + const int TAG_ITEM_FUNCTION_SIMUL_LAND_VACATE_POPUP = 38; + const int TAG_ITEM_FUNCTION_SIMUL_TAXI_POPUP = 39; + const int TAG_ITEM_FUNCTION_SIMUL_TAXI_BEHIND = 40; + const int TAG_ITEM_FUNCTION_SIMULATION_POPUP = 41; + const int TAG_ITEM_FUNCTION_SIMUL_NEXT_WAYPOINTS = 42; + const int TAG_ITEM_FUNCTION_SIMUL_HOLDING_POINTS = 43; + + const int TAG_DATA_UNCORRELATED_RADAR = 1; + const int TAG_DATA_FLIGHT_PLAN_TRACK = 2; + const int TAG_DATA_CORRELATED = 3; + + const int BUTTON_LEFT = 1; + const int BUTTON_MIDDLE = 2; + const int BUTTON_RIGHT = 3; + + const int POPUP_ELEMENT_UNCHECKED = 0; + const int POPUP_ELEMENT_CHECKED = 1; + const int POPUP_ELEMENT_NO_CHECKBOX = 2; + + const int CONNECTION_TYPE_NO = 0; + const int CONNECTION_TYPE_DIRECT = 1; + const int CONNECTION_TYPE_VIA_PROXY = 2; + const int CONNECTION_TYPE_SIMULATOR_SERVER = 3; + const int CONNECTION_TYPE_PLAYBACK = 4; + const int CONNECTION_TYPE_SIMULATOR_CLIENT = 5; + const int CONNECTION_TYPE_SWEATBOX = 6; + + const int COORDINATION_STATE_NONE = 1; + const int COORDINATION_STATE_REQUESTED_BY_ME = 2; + const int COORDINATION_STATE_REQUESTED_BY_OTHER = 3; + const int COORDINATION_STATE_ACCEPTED = 4; + const int COORDINATION_STATE_REFUSED = 5; + const int COORDINATION_STATE_MANUAL_ACCEPTED = 6; + + const int SECTOR_ELEMENT_INFO = 0; + const int SECTOR_ELEMENT_VOR = 1; + const int SECTOR_ELEMENT_NDB = 2; + const int SECTOR_ELEMENT_AIRPORT = 3; + const int SECTOR_ELEMENT_RUNWAY = 4; + const int SECTOR_ELEMENT_FIX = 5; + const int SECTOR_ELEMENT_STAR = 6; + const int SECTOR_ELEMENT_SID = 7; + const int SECTOR_ELEMENT_LOW_AIRWAY = 8; + const int SECTOR_ELEMENT_HIGH_AIRWAY = 9; + const int SECTOR_ELEMENT_HIGH_ARTC = 10; + const int SECTOR_ELEMENT_ARTC = 11; + const int SECTOR_ELEMENT_LOW_ARTC = 12; + const int SECTOR_ELEMENT_GEO = 13; + const int SECTOR_ELEMENT_FREE_TEXT = 14; + const int SECTOR_ELEMENT_AIRSPACE = 15; + const int SECTOR_ELEMENT_POSITION = 16; + const int SECTOR_ELEMENT_SIDS_STARS = 17; + const int SECTOR_ELEMENT_RADARS = 18; + const int SECTOR_ELEMENT_REGIONS = 19; + + const int SECTOR_ELEMENT_NUMBER = 20; + const int SECTOR_ELEMENT_ALL = -1; + + const int RADAR_POSITION_NONE = 0; + const int RADAR_POSITION_PRIMARY = 1; + const int RADAR_POSITION_SECONDARY_C = 2; + const int RADAR_POSITION_SECONDARY_S = 4; + const int RADAR_POSITION_ALL = 7; + + // forward declaration + class DllSpecEuroScope CSectorElement; + + class DllSpecEuroScope CPosition + { + public: + double m_Latitude; + double m_Longitude; + + //---CPosition----------------------------------------------------- + + inline CPosition(void) + { + m_Latitude = m_Longitude = 0.0; + }; + + //---LoadFromStrings----------------------------------------------- + + bool LoadFromStrings(const char* sLongitude, const char* sLatitude); + //----------------------------------------------------------------- + // Parameters : + // => sLongitude - longitude value + // => sLatitude - latitude value + // + // Return : + // true - if success + // false - else + // + // Description : + // It loads the position from sectrofile format coordinate strings. + //----------------------------------------------------------------- + + //---DistanceTo---------------------------------------------------- + + double DistanceTo(const CPosition OtherPosition) const; + //----------------------------------------------------------------- + // Parameters : + // => OtherPosition - another position + // + // Return : + // the distance between the positions + //----------------------------------------------------------------- + + //---DirectionTo--------------------------------------------------- + + double DirectionTo(const CPosition OtherPosition) const; + //----------------------------------------------------------------- + // Parameters : + // => OtherPosition - another position + // + // Return : + // the magnetic direction from this to the other position + // using the active sectorfile magnetic deviation value + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CFlightPlanExtractedRoute + { + private: + ESINDEX m_FpPosition;// the currently referenced AC position + + friend class CFlightPlan; + + public: + //---CFlightPlanExtractedRoute--------------------------------------- + + inline CFlightPlanExtractedRoute(void) + { + m_FpPosition = NULL; + }; + + //---GetPointsNumber----------------------------------------------- + + int GetPointsNumber(void) const; + //----------------------------------------------------------------- + // Return : + // The number of points in the extracted route array. + //----------------------------------------------------------------- + + //---GetPointsCalculatedIndex-------------------------------------- + + int GetPointsCalculatedIndex(void) const; + //----------------------------------------------------------------- + // Return : + // The index of point in the extracted route that edge is the + // closest to the actual plane position. The return value is + // between 0 and point number - 2. + // The value may be -1 indicating invalid state. + //----------------------------------------------------------------- + + //---GetPointsAssignedIndex---------------------------------------- + + int GetPointsAssignedIndex(void) const; + //----------------------------------------------------------------- + // Return : + // The index of point in the extracted route that was assigned + // by a controller as next (direct to). The return value is + // between 0 and point number - 1. + // The value may be -1 indicating no direct was given. + //----------------------------------------------------------------- + + //---GetPointName-------------------------------------------------- + + const char* GetPointName(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the requested point. It must be + // between 0 and point number - 1. + // + // Return : + // The name of the point in the extracted route array. + //----------------------------------------------------------------- + + //---GetPointPosition---------------------------------------------- + + CPosition GetPointPosition(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the requested point. It must be + // between 0 and point number - 1. + // + // Return : + // The coordinates of the point in the extracted route array. + //----------------------------------------------------------------- + + //---GetPointAirwayName-------------------------------------------- + + const char* GetPointAirwayName(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the requested point. It must be + // between 1 and point number - 1. + // For point 0 it is always empty. + // + // Return : + // The name of the airway or SID/STAR from the previous point + // (Index-1) to this one. + //----------------------------------------------------------------- + + //---GetPointAirwayClassification---------------------------------- + + int GetPointAirwayClassification(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the requested point. It must be + // between 1 and point number - 1. + // For point 0 it is always direct to. + // + // Return : + // The calssification (see AIRWAY_CLASS_...) of the airway + // from the previous point (Index-1) to this one. + //----------------------------------------------------------------- + + //---GetPointDistanceInMinutes------------------------------------- + + int GetPointDistanceInMinutes(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the requested point. It must be + // between 0 and point number - 1. + // + // Return : + // The distance of the point in minutes from plane current position. + // May return -1 if the point has been passed. + //----------------------------------------------------------------- + + //---GetPointCalculatedProfileAltitude----------------------------- + + int GetPointCalculatedProfileAltitude(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the requested point. It must be + // between 0 and point number - 1. + // + // Return : + // The altitude (no FL/altitude change here) calculated from + // the route, clib/descend profile and COPX altitude constraints. + // The index must be between 0 and point number - 1. + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CFlightPlanPositionPredictions + { + private: + ESINDEX m_FpPosition;// the currently referenced AC position + + friend class CFlightPlan; + + public: + //---CFlightPlanPositionPredictions---------------------------------- + + inline CFlightPlanPositionPredictions(void) + { + m_FpPosition = NULL; + }; + + //---GetPointsNumber----------------------------------------------- + + int GetPointsNumber(void) const; + //----------------------------------------------------------------- + // Return : + // The number of points in the prediction array. + //----------------------------------------------------------------- + + //---GetPosition--------------------------------------------------- + + CPosition GetPosition(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the requested point. It must be + // between 0 and point number - 1. The index is + // equal the minutes from now. + // + // Return : + // The predicted position of the AC expected at Index minutes from now. + //----------------------------------------------------------------- + + //---GetAltitude--------------------------------------------------- + + int GetAltitude(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the requested point. It must be + // between 0 and point number - 1. The index is + // equal the minutes from now. + // + // Return : + // The predicted altitude/level of the AC expected at Index + // minutes from now. There is no ALT/FL conversion in this + // function. + //----------------------------------------------------------------- + + //---GetControllerId----------------------------------------------- + + const char* GetControllerId(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the requested point. It must be + // between 0 and point number - 1. The index is + // equal the minutes from now. + // + // Return : + // The position ID of the predicted controller at Index + // minutes from now. + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CRadarTargetPositionData + { + private: + ESINDEX m_RtPosition;// the currently referenced RT position + ESINDEX m_PosPosition; + + friend class CRadarTarget; + friend class CFlightPlan; + + public: + //---CRadarTargetPositionData----------------------------------------- + + inline CRadarTargetPositionData(void) + { + m_RtPosition = m_PosPosition = NULL; + }; + + //---IsValid------------------------------------------------------- + + inline bool IsValid(void) const + { + return m_RtPosition != NULL; + }; + //----------------------------------------------------------------- + // Return : + // true - if the position reference is valid + // false - else + // + // Description : + // It tests if the AC and the position reference is valid. + //----------------------------------------------------------------- + + //---IsFPTrackPosition--------------------------------------------- + + inline bool IsFPTrackPosition(void) const + { + return m_PosPosition == NULL; + }; + //----------------------------------------------------------------- + // Return : + // true - if the position is a reference to the FP track + // false - else + //----------------------------------------------------------------- + + //---GetReceivedTime----------------------------------------------- + + int GetReceivedTime(void) const; + //----------------------------------------------------------------- + // Return : + // The number of seconds elapsed since the position data received. + //----------------------------------------------------------------- + + //---GetPosition--------------------------------------------------- + + CPosition GetPosition(void) const; + //----------------------------------------------------------------- + // Return : + // The lat/lon coordinates of the plane. + //----------------------------------------------------------------- + + //---GetSquawk----------------------------------------------------- + + const char* GetSquawk(void) const; + //----------------------------------------------------------------- + // Return : + // The squawk sent by the pilot + //----------------------------------------------------------------- + + //---GetTransponderC------------------------------------------------ + + bool GetTransponderC(void) const; + //----------------------------------------------------------------- + // Return : + // true - if the plane transponder is C mode + // false - else + //----------------------------------------------------------------- + + //---GetTransponderI------------------------------------------------ + + bool GetTransponderI(void) const; + //----------------------------------------------------------------- + // Return : + // true - if the plane transponder is IDENT mode + // false - else + //----------------------------------------------------------------- + + //---GetPressureAltitude------------------------------------------- + + int GetPressureAltitude(void) const; + //----------------------------------------------------------------- + // Return : + // The true altitude of the plane in feet. + //----------------------------------------------------------------- + + //---GetFlightLevel------------------------------------------------ + + int GetFlightLevel(void) const; + //----------------------------------------------------------------- + // Return : + // The altitude calculated using stadard pressure. The return + // value is in feet. + //----------------------------------------------------------------- + + //---GetReportedGS------------------------------------------------- + + int GetReportedGS(void) const; + //----------------------------------------------------------------- + // Return : + // The GS reported by the pilot client + //----------------------------------------------------------------- + + //---GetReportedHeading-------------------------------------------- + + int GetReportedHeading(void) const; + int GetReportedHeadingTrueNorth(void) const; + //----------------------------------------------------------------- + // Return : + // The heading (not tracking) reported by the pilot client. + //----------------------------------------------------------------- + + //---GetReportedPitch---------------------------------------------- + + int GetReportedPitch(void) const; + //----------------------------------------------------------------- + // Return : + // The pitch reported by the pilot client. The value is between + // -180 and +180; negative means above horizon. + //----------------------------------------------------------------- + + //---GetReportedBank----------------------------------------------- + + int GetReportedBank(void) const; + //----------------------------------------------------------------- + // Return : + // The pitch reported by the pilot client. The value is between + // -180 and +180; negative means right bank. + //----------------------------------------------------------------- + + //---GetRadarFlags------------------------------------------------- + + int GetRadarFlags(void) const; + //----------------------------------------------------------------- + // Return : + // The logical or combination of the following values: + // - RADAR_POSITION_PRIMARY - primary position received + // - RADAR_POSITION_SECONDARY_C - A+C mode transponder received + // - RADAR_POSITION_SECONDARY_S - S mode transponder received + // + // Description : + // It returns the radar response flags for the specified position. + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CFlightPlanData + { + private: + ESINDEX m_FpPosition;// the currently referenced AC position + + friend class CFlightPlan; + + public: + //---CFlightPlanData------------------------------------------- + + inline CFlightPlanData(void) + { + m_FpPosition = NULL; + }; + + //---IsReceived---------------------------------------------------- + + bool IsReceived(void) const; + //----------------------------------------------------------------- + // Return : + // true - if any kind of FP is received from the servers + // false - else + //----------------------------------------------------------------- + + //---IsAmended----------------------------------------------------- + + bool IsAmended(void) const; + //----------------------------------------------------------------- + // Return : + // true - if the FP is amended by a controller + // false - else + //----------------------------------------------------------------- + + //---AmendFlightPlan----------------------------------------------- + + bool AmendFlightPlan(void); + //----------------------------------------------------------------- + // Return : + // true - if success + // false - else + // + // Description : + // It amends the FP + //----------------------------------------------------------------- + + //---GetPlanType--------------------------------------------------- + + const char* GetPlanType(void) const; + //----------------------------------------------------------------- + // Return : + // The type of the flight plan: V or I. + //----------------------------------------------------------------- + + //---SetPlanType--------------------------------------------------- + + bool SetPlanType(const char* sPlanType); + //----------------------------------------------------------------- + // Parameters : + // => sPlanType - the type of the FP: V or I. + // + // Return : + // true - if success + // false - else + // + // Description : + // It changes the FP type. + //----------------------------------------------------------------- + + //---GetAircraftInfo----------------------------------------------- + + const char* GetAircraftInfo(void) const; + //----------------------------------------------------------------- + // Return : + // The unextracted aircraft information. + //----------------------------------------------------------------- + + //---SetAircraftInfo----------------------------------------------- + + bool SetAircraftInfo(const char* sInfo); + //----------------------------------------------------------------- + // Parameters : + // => sInfo - the complete aircraft information + // + // Return : + // true - if success + // false - else + // + // Description : + // It changes the FP AC info. + //----------------------------------------------------------------- + + //---GetAircraftWtc------------------------------------------------ + + char GetAircraftWtc(void) const; + //----------------------------------------------------------------- + // Return : + // The weight category of the aircraft. + // Possible values are: + // ? - unknown + // L - light + // M - medium + // H - heavy + // J - super heavy + //----------------------------------------------------------------- + + //---GetAircraftType----------------------------------------------- + + char GetAircraftType(void) const; + //----------------------------------------------------------------- + // Return : + // The type of the aircraft. + // Possible values are: + // ? - unknown + // L - landplane + // S - seaplane + // A - amphibian + // H - helicopter + // G - gyrocopter + // T - tilt-wing AC + //----------------------------------------------------------------- + + //---GetEngineNumber----------------------------------------------- + + int GetEngineNumber(void) const; + //----------------------------------------------------------------- + // Return : + // The number of engines. + //----------------------------------------------------------------- + + //---GetEngineType------------------------------------------------- + + char GetEngineType(void) const; + //----------------------------------------------------------------- + // Return : + // The type of the engines of the aircraft. + // Possible values are: + // ? - unknown + // P - piston + // T - turboprop/turboshaft + // J - jet + // E - electric + //----------------------------------------------------------------- + + //---GetCapibilities----------------------------------------------- + + char GetCapibilities(void) const; + //----------------------------------------------------------------- + // Return : + // The navigation capibilities of the aircraft. + // Possible values are: + // ? - unknown + // T - no DME, Transponder without mode A+C + // X - no DME, No Transponder + // U - no DME, Transponder with mode A+C + // D - DME, No Transponder + // B - DME, Transponder without mode A+C + // A - DME, Transponder with mode A+C + // M - TACAN only, No Transponder + // N - TACAN only, Transponder without mode A+C + // P - TACAN only, Transponder with mode A+C + // Y - simple RNAV, No Transponder + // C - simple RNAV, Transponder without mode A+C + // I - simple RNAV, Transponder with mode A+C + // E - advanced RNAV with Dual FMS + // F - advanced RNAV with Single FMS + // G - advanced RNAV with GPS or GNSS + // R - advanced RNAV with RNP capability + // W - advanced RNAV with RVSM capability + // Q - advanced RNAV with RNP and RVSM + //----------------------------------------------------------------- + + //---IsRvsm-------------------------------------------------------- + + bool IsRvsm(void) const; + //----------------------------------------------------------------- + // Return : + // true - if the aircraft if RVSM capable + // false - else + //----------------------------------------------------------------- + + //---GetManufacturerType------------------------------------------- + + const char* GetManufacturerType(void) const; + //----------------------------------------------------------------- + // Return : + // The type description of the aircraft by the manufacturer. + //----------------------------------------------------------------- + + //---GetAircraftFPType--------------------------------------------- + + const char* GetAircraftFPType(void) const; + //----------------------------------------------------------------- + // Return : + // The unencoded AC type as written to the FP. + //----------------------------------------------------------------- + + //---GetTrueAirspeed----------------------------------------------- + + int GetTrueAirspeed(void) const; + //----------------------------------------------------------------- + // Return : + // The true airspeed filed. + //----------------------------------------------------------------- + + //---SetTrueAirspeed----------------------------------------------- + + bool SetTrueAirspeed(int TrueAirspeed); + //----------------------------------------------------------------- + // Parameters : + // => TrueAirspeed - the true airspeed value + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the true airspeed value. + //----------------------------------------------------------------- + + //---GetOrigin----------------------------------------------------- + + const char* GetOrigin(void) const; + //----------------------------------------------------------------- + // Return : + // The origin airport. + //----------------------------------------------------------------- + + //---SetOrigin----------------------------------------------------- + + bool SetOrigin(const char* sOrigin); + //----------------------------------------------------------------- + // Parameters : + // => sOrigin - the origina airport + // + // Return : + // true - if success + // false - else + // + // Description : + // It changes the origin airport. + //----------------------------------------------------------------- + + //---GetFinalAltitude---------------------------------------------- + + int GetFinalAltitude(void) const; + //----------------------------------------------------------------- + // Return : + // The final requested altitude. + //----------------------------------------------------------------- + + //---SetFinalAltitude---------------------------------------------- + + bool SetFinalAltitude(int FinalAltitude); + //----------------------------------------------------------------- + // Parameters : + // => FinalAltitude - the final altitude + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the final altitude. + //----------------------------------------------------------------- + + //---GetDestination------------------------------------------------ + + const char* GetDestination(void) const; + //----------------------------------------------------------------- + // Return : + // The destination airport. + //----------------------------------------------------------------- + + //---SetDestination------------------------------------------------ + + bool SetDestination(const char* sDestination); + //----------------------------------------------------------------- + // Parameters : + // => sDestination - the destination airport + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the destination airport. + //----------------------------------------------------------------- + + //---GetAlternate-------------------------------------------------- + + const char* GetAlternate(void) const; + //----------------------------------------------------------------- + // Return : + // The alternate airport. + //----------------------------------------------------------------- + + //---SetAlternate-------------------------------------------------- + + bool SetAlternate(const char* sAlternate); + //----------------------------------------------------------------- + // Parameters : + // sAlternate - the alternate airport + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the alternate airport. + //----------------------------------------------------------------- + + //---GetRemarks---------------------------------------------------- + + const char* GetRemarks(void) const; + //----------------------------------------------------------------- + // Return : + // The remarks field. + //----------------------------------------------------------------- + + //---SetRemarks---------------------------------------------------- + + bool SetRemarks(const char* sRemarks); + //----------------------------------------------------------------- + // Parameters : + // => sRemarks - the remarks field + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the remarks fileds. + //----------------------------------------------------------------- + + //---GetCommunicationType------------------------------------------ + + char GetCommunicationType(void) const; + //----------------------------------------------------------------- + // Return : + // The communications type. + // Possible values are: + // ? - unknown + // V - voice + // R - receive voice only + // T - text only + //----------------------------------------------------------------- + + //---GetRoute------------------------------------------------------ + + const char* GetRoute(void) const; + //----------------------------------------------------------------- + // Return : + // The route field. + //----------------------------------------------------------------- + + //---SetRoute------------------------------------------------------ + + bool SetRoute(const char* sRoute); + //----------------------------------------------------------------- + // Parameters : + // => sRoute - the route field + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the route field. + //----------------------------------------------------------------- + + //---GetSidName---------------------------------------------------- + + const char* GetSidName(void) const; + //----------------------------------------------------------------- + // Return : + // The extracted or assigned SID name. + //----------------------------------------------------------------- + + //---GetStarName--------------------------------------------------- + + const char* GetStarName(void) const; + //----------------------------------------------------------------- + // Return : + // The extracted or assigned STAR name. + //----------------------------------------------------------------- + + //---GetDepartureRwy----------------------------------------------- + + const char* GetDepartureRwy(void) const; + //----------------------------------------------------------------- + // Return : + // The extracted or assigned departure RWY name. + //----------------------------------------------------------------- + + //---GetArrivalRwy------------------------------------------------- + + const char* GetArrivalRwy(void) const; + //----------------------------------------------------------------- + // Return : + // The extracted or assigned arrival RWY name. + //----------------------------------------------------------------- + + //---GetEstimatedDepartureTime------------------------------------- + + const char* GetEstimatedDepartureTime(void) const; + //----------------------------------------------------------------- + // Return : + // The pilot sent estimated departure time (uncompiled original + // content as string value). + //----------------------------------------------------------------- + + //---SetEstimatedDepartureTime------------------------------------- + + bool SetEstimatedDepartureTime(const char* sDepTime); + //----------------------------------------------------------------- + // Parameters : + // => sDepTime - The estimated departure time (uncompiled + // original content as string value) + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the estimated departure time. + //----------------------------------------------------------------- + + //---GetActualDepartureTime---------------------------------------- + + const char* GetActualDepartureTime(void) const; + //----------------------------------------------------------------- + // Return : + // The pilot sent actual departure time (uncompiled original + // content as string value). + //----------------------------------------------------------------- + + //---SetActualDepartureTime---------------------------------------- + + bool SetActualDepartureTime(const char* sDepTime); + //----------------------------------------------------------------- + // Parameters : + // => sDepTime - The actual departure time (uncompiled + // original content as string value) + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the actual departure time. + //----------------------------------------------------------------- + + //---GetEnrouteHours----------------------------------------------- + + const char* GetEnrouteHours(void) const; + //----------------------------------------------------------------- + // Return : + // The pilot sent hours for enroute (uncompiled original + // content as string value). + //----------------------------------------------------------------- + + //---SetEnrouteHours----------------------------------------------- + + bool SetEnrouteHours(const char* sEnrouteHours); + //----------------------------------------------------------------- + // Parameters : + // => sEnrouteHours - The hours for enroute (uncompiled + // original content as string value) + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the enroute hours field. + //----------------------------------------------------------------- + + //---GetEnrouteMinutes--------------------------------------------- + + const char* GetEnrouteMinutes(void) const; + //----------------------------------------------------------------- + // Return : + // The pilot sent minutes for enroute (uncompiled original + // content as string value). + //----------------------------------------------------------------- + + //---SetEnrouteMinutes--------------------------------------------- + + bool SetEnrouteMinutes(const char* sEnrouteMinutes); + //----------------------------------------------------------------- + // Parameters : + // => sEnrouteMinutes - The minutes for enroute (uncompiled + // original content as string value) + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the enroute minutes field. + //----------------------------------------------------------------- + + //---GetFuelHours-------------------------------------------------- + + const char* GetFuelHours(void) const; + //----------------------------------------------------------------- + // Return : + // The pilot sent hours available fuel (uncompiled original + // content as string value). + //----------------------------------------------------------------- + + //---SetFuelHours-------------------------------------------------- + + bool SetFuelHours(const char* sFuelHours); + //----------------------------------------------------------------- + // Parameters : + // => sFuelHours - The hours of available fuel (uncompiled + // original content as string value) + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the available fuel hours field. + //----------------------------------------------------------------- + + //---GetFuelMinutes------------------------------------------------ + + const char* GetFuelMinutes(void) const; + //----------------------------------------------------------------- + // Return : + // The pilot sent minutes available fuel (uncompiled original + // content as string value). + //----------------------------------------------------------------- + + //---SetFuelMinutes------------------------------------------------ + + bool SetFuelMinutes(const char* sFuelMinutes); + //----------------------------------------------------------------- + // Parameters : + // => sFuelMinutes - The minutes of available fuel (uncompiled + // original content as string value) + // + // Return : + // true - if success + // false - else + // + // Description : + // It sets the available fuel minutes field. + //----------------------------------------------------------------- + + //---PerformanceGetIas--------------------------------------------- + + int PerformanceGetIas(int Altitude, int VerticalSpeed); + //----------------------------------------------------------------- + // Parameters : + // => Altitude - the actual altitude (or FL) + // => VerticalSpeed - VS indicator (-1 for descend, + // 0 for level, + // +1 for climb ) + // + // Return : + // The IAS of the AC at the given level and vertical direction + //----------------------------------------------------------------- + + //---PerformanceGetMach-------------------------------------------- + + int PerformanceGetMach(int Altitude, int VerticalSpeed); + //----------------------------------------------------------------- + // Parameters : + // => Altitude - the actual altitude (or FL) + // => VerticalSpeed - VS indicator (-1 for descend, + // 0 for level, + // +1 for climb ) + // + // Return : + // The Mach number (multiplied by 100) of the AC at the given + // level and vertical direction + //----------------------------------------------------------------- + + //---PerformanceGetClimbRate--------------------------------------- + + int PerformanceGetClimbRate(int Altitude); + //----------------------------------------------------------------- + // Parameters : + // => Altitude - the actual altitude (FL) + // + // Return : + // The climb rate. + //----------------------------------------------------------------- + + //---PerformanceGetDescentRate------------------------------------- + + int PerformanceGetDescentRate(int Altitude); + //----------------------------------------------------------------- + // Parameters : + // => Altitude - the actual altitude (FL) + // + // Return : + // The descent rate. + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CFlightPlanControllerAssignedData + { + private: + ESINDEX m_FpPosition;// the currently referenced AC position + + friend class CFlightPlan; + + public: + //---CFlightPlanControllerAssignedData----------------------------- + + inline CFlightPlanControllerAssignedData(void) + { + m_FpPosition = NULL; + }; + + //---GetSquawk----------------------------------------------------- + + const char* GetSquawk(void) const; + //----------------------------------------------------------------- + // Return : + // The assigned squawk (may be empty). + //----------------------------------------------------------------- + + //---SetSquawk----------------------------------------------------- + + bool SetSquawk(const char* sSquawk); + //----------------------------------------------------------------- + // Parameters : + // => sSquawk - the newly assigned squawk + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetFinalAltitude---------------------------------------------- + + int GetFinalAltitude(void) const; + //----------------------------------------------------------------- + // Return : + // The controller ovveriden final altitude. No ALT/FL change here. + //----------------------------------------------------------------- + + //---SetFinalAltitude---------------------------------------------- + + bool SetFinalAltitude(int FinalAltitude); + //----------------------------------------------------------------- + // Parameters : + // => FinalAltitude - final altitude + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetClearedAltitude-------------------------------------------- + + int GetClearedAltitude(void) const; + //----------------------------------------------------------------- + // Return : + // The cleared altitude; no ALT/FL change here. There are + // spacial values: + // 0 - no cleared level (use the final instead of) + // 1 - cleared for ILS approach + // 2 - cleared for visual approach + //----------------------------------------------------------------- + + //---SetClearedAltitude-------------------------------------------- + + bool SetClearedAltitude(int ClearedAltitude); + //----------------------------------------------------------------- + // Parameters : + // => ClearedAltitude - the new cleared altitude (see the + // special values above) + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetCommunicationType------------------------------------------ + + char GetCommunicationType(void) const; + //----------------------------------------------------------------- + // Return : + // The communications type. + // Possible values are: + // 0 - unassigned + // V - voice + // R - receive voice only + // T - text only + //----------------------------------------------------------------- + + //---SetCommunicationType------------------------------------------ + + bool SetCommunicationType(char CommunicationType); + //----------------------------------------------------------------- + // Parameters : + // => CommunicationType - the new type (see the values above) + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetScratchPadString------------------------------------------- + + const char* GetScratchPadString(void) const; + //----------------------------------------------------------------- + // Return : + // The scratch pad string value. Only the real valus, directs, + // assigned speed, heading etc are not stored here. + //----------------------------------------------------------------- + + //---SetScratchPadString------------------------------------------- + + bool SetScratchPadString(const char* sString); + //----------------------------------------------------------------- + // Parameters : + // => sString - the new scratch string value + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetAssignedSpeed---------------------------------------------- + + int GetAssignedSpeed(void) const; + //----------------------------------------------------------------- + // Return : + // The controller assigned speed. Value 0 indicates no assignment. + //----------------------------------------------------------------- + + //---SetAssignedSpeed---------------------------------------------- + + bool SetAssignedSpeed(int AssignedSpeed); + //----------------------------------------------------------------- + // Parameters : + // => AssignedSpeed - the new assigned speed + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetAssignedMach----------------------------------------------- + + int GetAssignedMach(void) const; + //----------------------------------------------------------------- + // Return : + // The controller assigned mach number multiplied by 100. + // 750 indicates 0.75 Mach. Value 0 indicates no assignment. + //----------------------------------------------------------------- + + //---SetAssignedMach----------------------------------------------- + + bool SetAssignedMach(int AssignedMach); + //----------------------------------------------------------------- + // Parameters : + // => AssignedMach - the assigned Mach number (multiplied + // by 100) + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetAssignedRate----------------------------------------------- + + int GetAssignedRate(void) const; + //----------------------------------------------------------------- + // Return : + // The controller assigned climb/descend rate. There is no + // indication if climb or descend rate is assigned. Value 0 + // indicates no assignment. + //----------------------------------------------------------------- + + //---SetAssignedRate----------------------------------------------- + + bool SetAssignedRate(int AssignedRate); + //----------------------------------------------------------------- + // Parameters : + // => AssignedRate - the assigned rate + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetAssignedHeading-------------------------------------------- + + int GetAssignedHeading(void) const; + //----------------------------------------------------------------- + // Return : + // The controller assigned heading. Value 0 indicates no assignment. + //----------------------------------------------------------------- + + //---SetAssignedHeading-------------------------------------------- + + bool SetAssignedHeading(int AssignedHeading); + //----------------------------------------------------------------- + // Parameters : + // => AssignedHeading - assigned heading + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetDirectToPointName------------------------------------------ + + const char* GetDirectToPointName(void) const; + //----------------------------------------------------------------- + // Return : + // The assigned direct to point name. + //----------------------------------------------------------------- + + //---SetDirectToPointName------------------------------------------ + + bool SetDirectToPointName(const char* sPointName); + //----------------------------------------------------------------- + // Parameters : + // => sPointName - the name of the point + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + + //---GetFlightStripAnnotation-------------------------------------- + + const char* GetFlightStripAnnotation(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the annotation (0-8). + // + // Return : + // The selected fligt strip annotation. + //----------------------------------------------------------------- + + //---SetFlightStripAnnotation-------------------------------------- + + bool SetFlightStripAnnotation(int Index, const char* sAnnotation); + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the annotation (0-8). + // => sAnnotation - the text itself + // + // Return : + // true - if success + // false - else + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CFlightPlan + { + private: + ESINDEX m_FpPosition;// the currently referenced AC position + + friend class CPlugInData; + friend class CPlugIn; + friend class CFlightPlanList; + friend class CRadarTarget; + + public: + //---CFlightPlan--------------------------------------------------- + + inline CFlightPlan(void) + { + m_FpPosition = NULL; + }; + + //---IsValid------------------------------------------------------- + + inline bool IsValid(void) const + { + return m_FpPosition != NULL; + }; + //----------------------------------------------------------------- + // Return : + // true - if the AC reference is valid + // false - else + // + // Description : + // It tests if the AC reference is valid. + //----------------------------------------------------------------- + + //---GetCallsign--------------------------------------------------- + + const char* GetCallsign(void) const; + //----------------------------------------------------------------- + // Return : + // The callsign of the AC. + //----------------------------------------------------------------- + + //---GetPilotName-------------------------------------------------- + + const char* GetPilotName(void) const; + //----------------------------------------------------------------- + // Return : + // The name of the pilot extracted from statistics data. + // Empty string if no selected AC or no statistics data + //----------------------------------------------------------------- + + //---GetState------------------------------------------------------ + + int GetState(void) const; + //----------------------------------------------------------------- + // Return : + // The state of the AC (see FLIGHT_PLAN_STATE_ ...). + // 0 if no selected AC + //----------------------------------------------------------------- + + //---GetFPState---------------------------------------------------- + + int GetFPState(void) const; + //----------------------------------------------------------------- + // Return : + // The state of the AC (FLIGHT_PLAN_STATE_NOT_STARTED, + // FLIGHT_PLAN_STATE_SIMULATED, + // FLIGHT_PLAN_STATE_TERMINATED) + // 0 if no selected AC + //----------------------------------------------------------------- + + //---GetSimulated-------------------------------------------------- + + bool GetSimulated(void) const; + //----------------------------------------------------------------- + // Return : + // true - if the AC is out of range and ES simulates its movements + // false - else + //----------------------------------------------------------------- + + //---GetTrackingControllerCallsign--------------------------------- + + const char* GetTrackingControllerCallsign(void) const; + //----------------------------------------------------------------- + // Return : + // The callsign of the controller currently tracking. + // Empty if noone is tracking it + //----------------------------------------------------------------- + + //---GetTrackingControllerId--------------------------------------- + + const char* GetTrackingControllerId(void) const; + //----------------------------------------------------------------- + // Return : + // The position ID of the controller currently tracking. + // Empty if noone is tracking it + //----------------------------------------------------------------- + + //---GetTrackingControllerIsMe------------------------------------- + + bool GetTrackingControllerIsMe(void) const; + //----------------------------------------------------------------- + // Return : + // true - if the plane is tracked by me + // false - else + //----------------------------------------------------------------- + + //---GetHandoffTargetControllerCallsign---------------------------- + + const char* GetHandoffTargetControllerCallsign(void) const; + //----------------------------------------------------------------- + // Return : + // The callsign of the controller who is the target of the + // actual handoff. + // Empty if no actual handoff. + //----------------------------------------------------------------- + + //---GetHandoffTargetControllerId---------------------------------- + + const char* GetHandoffTargetControllerId(void) const; + //----------------------------------------------------------------- + // Return : + // The position ID of the controller who is the target of the + // actual handoff. + // Empty if no actual handoff. + //----------------------------------------------------------------- + + //---GetDistanceToDestination-------------------------------------- + + double GetDistanceToDestination(void) const; + //----------------------------------------------------------------- + // Return : + // The full calculated distance to the destination airport. + //----------------------------------------------------------------- + + //---GetDistanceFromOrigin----------------------------------------- + + double GetDistanceFromOrigin(void) const; + //----------------------------------------------------------------- + // Return : + // The full calculated distance from the origin airport. + //----------------------------------------------------------------- + + //---GetNextCopxPointName------------------------------------------ + + const char* GetNextCopxPointName(void) const; + //----------------------------------------------------------------- + // Return : + // The next active COPX point name along the extracted route. + // May be empty. + //----------------------------------------------------------------- + + //---GetNextFirCopxPointName--------------------------------------- + + const char* GetNextFirCopxPointName(void) const; + //----------------------------------------------------------------- + // Return : + // The next active FIR COPX point name along the extracted route. + // May be empty. + //----------------------------------------------------------------- + + //---GetSectorEntryMinutes----------------------------------------- + + int GetSectorEntryMinutes(void) const; + //----------------------------------------------------------------- + // Return : + // The time in minutes this plane will enter to my sectors. + // If already inside then 0 will be returned. + // If it will never enter then -1 will be returned. + //----------------------------------------------------------------- + + //---GetSectorExitMinutes------------------------------------------ + + int GetSectorExitMinutes(void) const; + //----------------------------------------------------------------- + // Return : + // The time in minutes this plane will leave to my sectors. + // If the plane will never enter to my sectors it will ne -1. + //----------------------------------------------------------------- + + //---GetRAMFlag---------------------------------------------------- + + bool GetRAMFlag(void) const; + //----------------------------------------------------------------- + // Return : + // The RAM flag when RAM warning is to be displayed. + //----------------------------------------------------------------- + + //---GetCLAMFlag--------------------------------------------------- + + bool GetCLAMFlag(void) const; + //----------------------------------------------------------------- + // Return : + // The CLAM flag when CLAM warning is to be displayed. + //----------------------------------------------------------------- + + //---GetGroundState------------------------------------------------ + + const char* GetGroundState(void) const; + //----------------------------------------------------------------- + // Return : + // The ground state of the AC (PUSH, TAXI, DEPA or empty). + //----------------------------------------------------------------- + + //---GetClearenceFlag---------------------------------------------- + + bool GetClearenceFlag(void) const; + //----------------------------------------------------------------- + // Return : + // The state if the clearence is received or not. + //----------------------------------------------------------------- + + //---IsTextCommunication------------------------------------------- + + bool IsTextCommunication(void) const; + //----------------------------------------------------------------- + // Return : + // A flag indicating if the pilot or a controller indicated + // text communication. + //----------------------------------------------------------------- + + //---GetFinalAltitude---------------------------------------------- + + int GetFinalAltitude(void) const; + //----------------------------------------------------------------- + // Return : + // The final altitude from the FP or from controller override. + // There is no ALT/FL change here. + //----------------------------------------------------------------- + + //---GetClearedAltitude-------------------------------------------- + + int GetClearedAltitude(void) const; + //----------------------------------------------------------------- + // Return : + // The cleared altitude. If missing then the final one. + // There is no ALT/FL change here. + //----------------------------------------------------------------- + + //---GetEntryCoordinationPointState-------------------------------- + + int GetEntryCoordinationPointState(void) const; + //----------------------------------------------------------------- + // Return : + // The state of the entry point coordination. One of the + // COORDINATION_STATE_... + //----------------------------------------------------------------- + + //---GetEntryCoordinationPointName--------------------------------- + + const char* GetEntryCoordinationPointName(void) const; + //----------------------------------------------------------------- + // Return : + // The cordination point name for entry point. + //----------------------------------------------------------------- + + //---GetEntryCoordinationAltitudeState----------------------------- + + int GetEntryCoordinationAltitudeState(void) const; + //----------------------------------------------------------------- + // Return : + // The state of the entry point altitude coordination. One of the + // COORDINATION_STATE_... + //----------------------------------------------------------------- + + //---GetEntryCoordinationAltitude---------------------------------- + + int GetEntryCoordinationAltitude(void) const; + //----------------------------------------------------------------- + // Return : + // The cordination point altitude for entry point. + //----------------------------------------------------------------- + + //---GetExitCoordinationNameState---------------------------------- + + int GetExitCoordinationNameState(void) const; + //----------------------------------------------------------------- + // Return : + // The state of the exit point name coordination. One of the + // COORDINATION_STATE_... + //----------------------------------------------------------------- + + //---GetExitCoordinationPointName---------------------------------- + + const char* GetExitCoordinationPointName(void) const; + //----------------------------------------------------------------- + // Return : + // The cordination point name for exit point. + //----------------------------------------------------------------- + + //---GetExitCoordinationAltitudeState------------------------------ + + int GetExitCoordinationAltitudeState(void) const; + //----------------------------------------------------------------- + // Return : + // The state of the exit point altitude coordination. One of the + // COORDINATION_STATE_... + //----------------------------------------------------------------- + + //---GetExitCoordinationAltitude----------------------------------- + + int GetExitCoordinationAltitude(void) const; + //----------------------------------------------------------------- + // Return : + // The cordination point altitude for entry point. + //----------------------------------------------------------------- + + //---GetCoordinatedNextController---------------------------------- + + const char* GetCoordinatedNextController(void) const; + //----------------------------------------------------------------- + // Return : + // - the callsign of the next controller if there is a + // coordinated one + // - empty else + //----------------------------------------------------------------- + + //---GetCoordinatedNextControllerState----------------------------- + + int GetCoordinatedNextControllerState(void) const; + //----------------------------------------------------------------- + // Return : + // The state of the next controller coordination. One of the + // COORDINATION_STATE_... + //----------------------------------------------------------------- + + //---GetCorrelatedRadarTarget-------------------------------------- + + CRadarTarget GetCorrelatedRadarTarget(void) const; + //----------------------------------------------------------------- + // Return : + // The correlated radar target. If no correlated target then + // the returned element is invalid. + //----------------------------------------------------------------- + + //---CorrelateWithRadarTarget-------------------------------------- + + bool CorrelateWithRadarTarget(CRadarTarget RadarTarget); + //----------------------------------------------------------------- + // Parameters : + // => RadarTarget - the radar target to get correlated wit + // + // Retrun : + // true - if success + // false - if failed + // + // Description : + // Call this function to correlate an flight plan with a radar + // target. Afetr calling it you DO NOT need to call the + // CorrelateWithFlightPlan on the radar target. + //----------------------------------------------------------------- + + //---Uncorrelate--------------------------------------------------- + + void Uncorrelate(void); + //----------------------------------------------------------------- + // Description : + // It uncorrelates the flight plan from its current target. + // After uncorrelate you DO NOT need to call the Uncorrelate + // on the radar target position. After uncorrelating the FP + // will not be correlated automatically by the system + //----------------------------------------------------------------- + + //---StartTracking------------------------------------------------- + + bool StartTracking(void); + //----------------------------------------------------------------- + // Return : + // true - if success + // false - else + // + // Description : + // It starts tracking the AC if it was untracked before. + //----------------------------------------------------------------- + + //---EndTracking--------------------------------------------------- + + bool EndTracking(void); + //----------------------------------------------------------------- + // Return : + // true - if success + // false - else + // + // Description : + // It releases (drops) the target. + //----------------------------------------------------------------- + + //---InitiateHandoff----------------------------------------------- + + bool InitiateHandoff(const char* sTargetController); + //----------------------------------------------------------------- + // Parameters : + // => sTargetController - the controller to initiate the + // handoff to + // + // Return : + // true - if success + // false - else + // + // Description : + // It initiates a handoff to the specified target controller. + //----------------------------------------------------------------- + + //---AcceptHandoff------------------------------------------------- + + void AcceptHandoff(void); + //----------------------------------------------------------------- + // Description : + // It accepts a handoff initiated to me. + //----------------------------------------------------------------- + + //---RefuseHandoff------------------------------------------------- + + void RefuseHandoff(void); + //----------------------------------------------------------------- + // Description : + // It refuses a handoff initiated to me. + //----------------------------------------------------------------- + + //---InitiateCoordination------------------------------------------ + + bool InitiateCoordination(const char* sTargetController, const char* sPointName, int Altitude); + //----------------------------------------------------------------- + // Parameters : + // => sTargetController - the controller to initiate the + // handoff to + // => sPointName - the requested point name (it + // can not be empty) + // => Altitude - the requested altitude (pass 0 + // if only the point is requested) + // + // Return : + // true - if success + // false - else + // + // Description : + // It initiates a COPN/COPX request. + //----------------------------------------------------------------- + + //---AcceptCoordination-------------------------------------------- + + void AcceptCoordination(void); + //----------------------------------------------------------------- + // Description : + // It accepts a coordination initiated to me. + //----------------------------------------------------------------- + + //---RefuseCoordination-------------------------------------------- + + void RefuseCoordination(void); + //----------------------------------------------------------------- + // Description : + // It refuses a handoff initiated to me. + //----------------------------------------------------------------- + + //---PushFlightStrip----------------------------------------------- + + void PushFlightStrip(const char* sTargetController); + //----------------------------------------------------------------- + // Parameters : + // => sTargetController - the controller to send the flight + // strip to + //----------------------------------------------------------------- + + //---SetEstimation------------------------------------------------- + + void SetEstimation(const char* sPointName, const char* sTime); + //----------------------------------------------------------------- + // Parameters : + // => sPointName - the name along the route + // => sTime - the estimated arrival time in HHMM format + // in zulu time. + //----------------------------------------------------------------- + + //---ClearEstimation----------------------------------------------- + + void ClearEstimation(void); + void ClearEstimation(const char* sPointName); + //----------------------------------------------------------------- + // Parameters : + // => sPointName - the name along the route + // + // Description : + // It clears the estimated arrival time from the given point. + // The first release clears all estimations. + //----------------------------------------------------------------- + + //---GetExtractedRoute--------------------------------------------- + + CFlightPlanExtractedRoute GetExtractedRoute(void) const; + //----------------------------------------------------------------- + // Return : + // An extracted route object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + //----------------------------------------------------------------- + + //---GetPositionPredictions---------------------------------------- + + CFlightPlanPositionPredictions GetPositionPredictions(void) const; + //----------------------------------------------------------------- + // Return : + // A position prediction array object instance. + // The position prediction array contains the position used + // by ES to determinate where the AC will be at a given time. + // Every element in the array contains data for the position + // flown by the next minute. Therefore the size of the array is + // always the remaining flight time in minutes. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + //----------------------------------------------------------------- + + //---GetFPTrackPosition-------------------------------------------- + + CRadarTargetPositionData GetFPTrackPosition(void) const; + //----------------------------------------------------------------- + // Return : + // A flight plan track position. This position data points to the + // FP track position and can not be used for subsequent + // GetPreviousPosition calls. + // The FP position is the same as the last radar target position + // if the FP is correlated. Otherwise the system calculated position. + //----------------------------------------------------------------- + + //---GetFlightPlanData--------------------------------------------- + + CFlightPlanData GetFlightPlanData(void) const; + //----------------------------------------------------------------- + // Return : + // A flight plan data object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + //----------------------------------------------------------------- + + //---GetControllerAssignedData------------------------------------- + + CFlightPlanControllerAssignedData GetControllerAssignedData(void) const; + //----------------------------------------------------------------- + // Return : + // An instance that holds controller assigned data. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CRadarTarget + { + private: + ESINDEX m_RtPosition;// the currently referenced AC position + + friend class CPlugInData; + friend class CPlugIn; + friend class CFlightPlan; + + public: + //---CRadarTarget-------------------------------------------------- + + inline CRadarTarget(void) + { + m_RtPosition = NULL; + }; + + //---IsValid------------------------------------------------------- + + inline bool IsValid(void) const + { + return m_RtPosition != NULL; + }; + //----------------------------------------------------------------- + // Return : + // true - if the AC reference is valid + // false - else + // + // Description : + // It tests if the AC reference is valid. + //----------------------------------------------------------------- + + //---GetCallsign--------------------------------------------------- + + const char* GetCallsign(void) const; + //----------------------------------------------------------------- + // Return : + // The callsign of the AC. + //----------------------------------------------------------------- + + //---GetSystemID--------------------------------------------------- + + const char* GetSystemID(void) const; + //----------------------------------------------------------------- + // Return : + // The system assigned ID to the radar target. It is surely the + // same on all instances - as the code itself is generated from + // the callsign. + //----------------------------------------------------------------- + + //---GetVerticalSpeed---------------------------------------------- + + int GetVerticalSpeed(void) const; + //----------------------------------------------------------------- + // Return : + // The calculated vertical speed of the selected AC in feet/minute. + // Be careful, it might be extremely inaccurate due the + // protocol. Use only for climb/descend/level test + // 0 - else + //----------------------------------------------------------------- + + //---GetTrackHeading----------------------------------------------- + + double GetTrackHeading(void) const; + //----------------------------------------------------------------- + // Return : + // The calculated track direction in degree + //----------------------------------------------------------------- + + //---GetGS--------------------------------------------------------- + + int GetGS(void) const; + //----------------------------------------------------------------- + // Return : + // The ground speed. First it uses the plane reported GS. If + // that is 0 then uses the calculated one. + //----------------------------------------------------------------- + + //---GetCorrelatedFlightPlan--------------------------------------- + + CFlightPlan GetCorrelatedFlightPlan(void) const; + //----------------------------------------------------------------- + // Return : + // The currently correlated flight plan. If the radar target + // is uncorrelated then the returned flight plan is invalid. + //----------------------------------------------------------------- + + //---CorrelateWithFlightPlan--------------------------------------- + + bool CorrelateWithFlightPlan(CFlightPlan FlightPlan); + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the flight plan to be correlated with + // + // Retrun : + // true - if success + // false - if failed + // + // Description : + // Call this function to correlate an radar target with a + // flight plan. After this function you DO NOT need to call the + // CorrelateWithradarTarget on the flight plan. + //----------------------------------------------------------------- + + //---Uncorrelate--------------------------------------------------- + + void Uncorrelate(void); + //----------------------------------------------------------------- + // Description : + // It uncorrelates the radar target from the flight plan. + // After it you DO NOT need to call the Uncorrelate on the + // flight plan. After uncorrelating the system will never + // correlate it automatically. + //----------------------------------------------------------------- + + //---GetPosition--------------------------------------------------- + + CRadarTargetPositionData GetPosition(void) const; + //----------------------------------------------------------------- + // Return : + // A plane position array instance. After calling this function + // the returned variable points to the last position of the radar target. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + //----------------------------------------------------------------- + + //---GetPreviousPosition------------------------------------------- + + CRadarTargetPositionData GetPreviousPosition(const CRadarTargetPositionData CurrentPosition) const; + //----------------------------------------------------------------- + // Parameters : + // => CurrentPosition - the current position object + // + // Return : + // A plane position object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CController + { + private: + ESINDEX m_CtrPosition;// the currently referenced AC position + bool m_Myself; // indicates myself is selected + + friend class CPlugInData; + friend class CPlugIn; + + public: + //---CController--------------------------------------------------- + + inline CController(void) + { + m_CtrPosition = NULL; + m_Myself = false; + }; + + //---IsValid------------------------------------------------------- + + inline bool IsValid(void) const + { + return m_CtrPosition != NULL || m_Myself; + }; + //----------------------------------------------------------------- + // Return : + // true - if the CTR reference is valid + // false - else + // + // Description : + // It tests if the CTR reference is valid. + //----------------------------------------------------------------- + + //---GetCallsign--------------------------------------------------- + + const char* GetCallsign(void) const; + //----------------------------------------------------------------- + // Return : + // The callsign of the controller. + //----------------------------------------------------------------- + + //---GetPositionId------------------------------------------------- + + const char* GetPositionId(void) const; + //----------------------------------------------------------------- + // Return : + // The position ID of the selected controller. + //----------------------------------------------------------------- + + //---GetPositionIdentified----------------------------------------- + + bool GetPositionIdentified(void) const; + //----------------------------------------------------------------- + // Return : + // true - if the controller is identified in the position file + // false - else + //----------------------------------------------------------------- + + //---GetPrimaryFrequency------------------------------------------- + + double GetPrimaryFrequency(void) const; + //----------------------------------------------------------------- + // Return : + // the primary frequency of the controller + // 199.980 if no primary frequency is selected + //----------------------------------------------------------------- + + //---GetFullName--------------------------------------------------- + + const char* GetFullName(void) const; + //----------------------------------------------------------------- + // Return : + // The position ID of the selected controller. + //----------------------------------------------------------------- + + //---GetRating----------------------------------------------------- + + int GetRating(void) const; + //----------------------------------------------------------------- + // Return : + // the rating of the controller: + // 1 - observer, OBS + // 2 - old STU or student 1, now Tower (TWR) + // 3 - old student 2 - never used + // 4 - old STU+ or student 3, now Approach (APP) + // 5 - old CTR or controller 1, now Centre (CTR) + // 6 - old controller 2 - never used + // 7 - old CTR+ or controller 3, now Senior Controller (CTR+) + // 8 - instructor 1, INS + // 9 - instructor 2 - never used + // 10 - instructor 3, INS+ + // 11 - supervisor, SUP + // 12 - administrator, ADM + //----------------------------------------------------------------- + + //---GetFacility--------------------------------------------------- + + int GetFacility(void) const; + //----------------------------------------------------------------- + // Return : + // the facility of the controller: + // 1 - FSS - flight service station + // 2 - DEL - delivery + // 3 - GND - ground + // 4 - TWR - tower + // 5 - APP, DEP - approach, departure + // 6 - CTR - controller + //----------------------------------------------------------------- + + //---GetSectorFileName--------------------------------------------- + + const char* GetSectorFileName(void) const; + //----------------------------------------------------------------- + // Return : + // The name of the sectorfile used by the controller. + //----------------------------------------------------------------- + + //---IsController-------------------------------------------------- + + bool IsController(void) const; + //----------------------------------------------------------------- + // Return : + // true - if the controller is accepted as controller by the + // servers (it has right to track AC, change FP, etc). + // false - else + //----------------------------------------------------------------- + + //---GetPosition--------------------------------------------------- + + CPosition GetPosition(void) const; + //----------------------------------------------------------------- + // Return : + // The center position of the controller. It returns only the + // main center but never the additional visibility points. + //----------------------------------------------------------------- + + //---GetRange------------------------------------------------------ + + int GetRange(void) const; + //----------------------------------------------------------------- + // Return : + // The visibility range of the controller. + //----------------------------------------------------------------- + + //---IsBreaking---------------------------------------------------- + + bool IsBreaking(void) const; + //----------------------------------------------------------------- + // Return : + // The breaking state of the controller. + //----------------------------------------------------------------- + + //---IsOngoingAble------------------------------------------------- + + bool IsOngoingAble(void) const; + //----------------------------------------------------------------- + // Return : + // Indicates if ready for ongoing coordination (indicates + // EuroScope on the other side). + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CRadarScreen + { + private: + CRadarView* m_pRadarView;// pointer to the structure behind + CPlugIn* m_pPlugIn; + // pointer back to the plugin for easy access + + friend CPlugInData; + + public: + //---CRadarScreen-------------------------------------------------- + + CRadarScreen(void); + //----------------------------------------------------------------- + // Description : + // The default constructor. + //----------------------------------------------------------------- + + //---GetPlugIn----------------------------------------------------- + + inline CPlugIn* GetPlugIn(void) + { + return m_pPlugIn; + }; + + //---GetRadarView-------------------------------------------------- + + inline CRadarView* GetRadarView(void) + { + return m_pRadarView; + }; + + //---GetToolbarArea------------------------------------------------ + + RECT GetToolbarArea(void); + //----------------------------------------------------------------- + // Return : + // The rectangle that is cobered by the toolbar in pixels. + // This are is not used for radar display. + //----------------------------------------------------------------- + + //---GetRadarArea-------------------------------------------------- + + RECT GetRadarArea(void); + //----------------------------------------------------------------- + // Return : + // The rectangle that is covered by the radar screen. + //----------------------------------------------------------------- + + //---GetChatArea--------------------------------------------------- + + RECT GetChatArea(void); + //----------------------------------------------------------------- + // Return : + // The rectangle that is covered by the chat lines. + //----------------------------------------------------------------- + + //---ConvertCoordFromPixelToPosition------------------------------- + + CPosition ConvertCoordFromPixelToPosition(POINT Pt); + //----------------------------------------------------------------- + // Parameters : + // => Pt - a pixel coordinates + // + // Return : + // The value converted to Lat, Lon position. + //----------------------------------------------------------------- + + //---ConvertCoordFromPositionToPixel------------------------------- + + POINT ConvertCoordFromPositionToPixel(CPosition Pos); + //----------------------------------------------------------------- + // Parameters : + // => Pos - a lat, lon position + // + // Return : + // The value converted to pixels. + //----------------------------------------------------------------- + + //---SaveDataToAsr------------------------------------------------- + + void SaveDataToAsr(const char* sVariableName, const char* sVariableDescription, const char* sValue); + //----------------------------------------------------------------- + // Parameters : + // => sVariableName - the name under your value will be saved + // => sVariableDescription- a user readable name of the variable; + // this value will be shown in the + // save modified settings dialog; if + // empty (never pass NULL), then it + // will not be shown + // => sValue - the value itself to be stored; it + // may contain only printable chars and + // never LF or CR or ':'. + // + // Description : + // It saves the value for the plug in the ASR file. + //----------------------------------------------------------------- + + //---GetDataFromAsr------------------------------------------------ + + const char* GetDataFromAsr(const char* sVariableName); + //----------------------------------------------------------------- + // Parameters : + // => sVariableName - the name under your value was saved + // + // Return : + // the value found in the ASR or + // NULL if not found + // + // Description : + // It loads the value for the plug from the ASR file. + //----------------------------------------------------------------- + + //---AddScreenObject----------------------------------------------- + + void AddScreenObject(int ObjectType, const char* sObjectId, RECT Area, bool Moveable, const char* sMessage); + //----------------------------------------------------------------- + // Parameters : + // => ObjectType - the type of the object (depends on the plugin) + // => sObjectId - the object identifier (most commin is to set + // the callisgn or similar) + // => Area - the area covered by the screen object + // => Moveable - indicates if the user can move it + // => sMessage - a message to be diplayed in the message + // area of the main screen when the obejct + // is clicked + // + // Description : + // This is a really short living object. Define all clickable + // areas on the radar screen when drawing your graphics + // elements. Call this function from the OnRefresh function + // only. The object list is cleared before the next refresh. + //----------------------------------------------------------------- + + //---RequestRefresh------------------------------------------------ + + void RequestRefresh(void); + //----------------------------------------------------------------- + // Description : + // Call this function when you need an update on the screen. + // It just posts a request and the screen will be painted + // only once when the thread finished all other tasks. Do + // call when the content is changed and it is absolutely + // necessary to refresj the screen before the standard 1 sec + // refresh. + //----------------------------------------------------------------- + + //---ShowSectorFileElement----------------------------------------- + + void ShowSectorFileElement(CSectorElement Element, const char* sComponentName, bool Show); + //----------------------------------------------------------------- + // Parameters : + // => Element - the element to be shown/hidden + // => sComponentName - the displayable component name (call + // the GetComponentName to retreive + // the available component names) + // => Show - true to show, false to hide + // + // Description : + // This function shows or hides individual sector file elements + // on the screen. This function just saves the flag, but does + // not refresh the background map as it takes long time. When + // you finished all switching call the RefreshMapContent to + // really refresh the elements. + //----------------------------------------------------------------- + + //---RefreshMapContent--------------------------------------------- + + void RefreshMapContent(void); + //----------------------------------------------------------------- + // Description : + // This function refreshes the background map content of the view. + // Call this function after setting all the necessary elements + // on and off. + //----------------------------------------------------------------- + + //---StartTagFunction---------------------------------------------- + + void StartTagFunction( + const char* sCallsign, const char* sItemPlugInName, int ItemCode, const char* sItemString, + const char* sFunctionPlugInName, int FunctionId, POINT Pt, RECT Area + ); + //------------------------------------------------------------------ + // Parameters : + // => sCallsign - the AC which TAG is clicked + // => sItemPlugInName - the item provider plug-in (for base + // EuroScope TAG functions pass NULL) + // => ItemCode - the item code + // => sItemString - the string of the selected item (as + // these are TAG item functions they may + // require the actual item string) + // => sFunctionPlugInName - the function provider plugin (for base + // EuroScope TAG functions pass NULL) + // => FunctionId - the ID of the function + // => Pt - the mouse position + // => Area - the area covered by the TAG item + // + // Description : + // Call this function to execute the inner logic of EuroScope + // after clicking on a TAG item. Be sure to ASEL the appropriate + // AC before initiating the TAG function as most of them + // operates on the ASEL one. + //----------------------------------------------------------------- + + //---GetDisplayArea------------------------------------------------ + + void GetDisplayArea(CPosition* pLeftDown, CPosition* pRightUp); + //----------------------------------------------------------------- + // Parameters : + // <= pLeftDown - the left down corner of the screen + // <= pRightUp - the right up corner of the screen + // + // Description : + // It returns the position of the left-down and right-up corners. + //----------------------------------------------------------------- + + //---SetDisplayArea------------------------------------------------ + + void SetDisplayArea(CPosition LeftDown, CPosition RightUp); + //----------------------------------------------------------------- + // Parameters : + // => LeftDown - the desired left down corner of the screen + // => RightUp - the desired right up corner of the screen + // + // Description : + // It update the display area of the screen to fully cover + // the defined rectangle. The are might bi bigger if the + // aspect ratio of the screen is different. + //----------------------------------------------------------------- + + //---OnAsrContentLoaded-------------------------------------------- + + inline virtual void OnAsrContentLoaded(bool Loaded){}; + //------------------------------------------------------------------ + // Parameters : + // => Loaded - indicates if the content was really loaded + // from a file (true) or the ASR file is ready + // just after NEW command. + // + // Description : + // This function is called after the initialization of the + // ASR file is complete. It may be after loading it from the + // file or just after executing a NEW command. + //------------------------------------------------------------------ + + //---OnAsrContentToBeSaved------------------------------------------ + + virtual void OnAsrContentToBeSaved(void){}; + //------------------------------------------------------------------ + // Description : + // This function is called just before the content change dialog. + // is saved. It is the latest time you can register any change + // to the ASR file to be prompted to save or not. + //------------------------------------------------------------------ + + //---OnRefresh------------------------------------------------------ + + inline virtual void OnRefresh(HDC hDC, int Phase){}; + //------------------------------------------------------------------ + // Parameters : + // => hDC - handle to the device context + // => Phase - the refresh phase + // + // Description : + // This function is called several times during the refresh. The + // Phase indicates the actual state: + // REFRESH_PHASE_BACK_BITMAP - used to draw the content of + // background bitmap, it is updated + // only on zooming/panning + // REFRESH_PHASE_BEFORE_TAGS - before TAGs are displayed + // REFRESH_PHASE_AFTER_TAGS - after TAGs, before lists + // REFRESH_PHASE_AFTER_LISTS - after all (before chat, + // toolbar and popup menus). + // The hDC points to an internal bitmap. Therefore your drawings + // will not be displayed immediately. Only when all drawings are + // ready the bitmap is copied to the screen. + // Normally this function is called once a second. Be fast and + // efficient to draw all your drawings in a resonable short time. + // When something is dragged on the screen this function will be + // called far more often. + // In the current version there is no way to refresh only part + // of the radar screen. It is painted as whole all the times. + // Therefore a fast drawing is really necessary. + //------------------------------------------------------------------ + + //---OnAsrContentToBeClosed------------------------------------------ + + virtual void OnAsrContentToBeClosed(void) = NULL; + //------------------------------------------------------------------ + // Description : + // This function is called just before close of the ASR file. + // Actually you can not save data here, but you may clean up + // things. + // IMPORTANT: You MUST free the instance as the last action + // of this callback. Call: delete this. + //------------------------------------------------------------------ + + //---OnControllerPositionUpdate------------------------------------ + + inline virtual void OnControllerPositionUpdate(CController Controller){}; + //----------------------------------------------------------------- + // Parameters : + // => Controller - the controller reference whose position + // is updated + // + // Description : + // All plugins must implement this function to handle the + // events when a controller position is updated. + //----------------------------------------------------------------- + + //---OnControllerDisconnect---------------------------------------- + + inline virtual void OnControllerDisconnect(CController Controller){}; + //----------------------------------------------------------------- + // Parameters : + // => Controller - the controller reference + // + // Description : + // All plugins must implement this function to handle the + // events when a controller is logged off or its position + // update is timed out. + //----------------------------------------------------------------- + + //---OnRadarTargetPositionUpdate-------------------------------------- + + inline virtual void OnRadarTargetPositionUpdate(CRadarTarget RadarTarget){}; + //----------------------------------------------------------------- + // Parameters : + // => RadarTarget - the radara reference whose position + // is updated + // + // Description : + // All plugins must implement this function to handle the + // events when a radar target position is updated. + //----------------------------------------------------------------- + + //---OnFlightPlanDisconnect---------------------------------------- + + inline virtual void OnFlightPlanDisconnect(CFlightPlan FlightPlan){}; + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the flight plan reference + // + // Description : + // All plugins must implement this function to handle the + // events when a flight plan is logged off or its position + // update is timed out. + //----------------------------------------------------------------- + + //---OnFlightPlanFlightPlanDataUpdate------------------------------ + + inline virtual void OnFlightPlanFlightPlanDataUpdate(CFlightPlan FlightPlan){}; + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the flight plan reference whose flight plan + // data is updated + // + // Description : + // All plugins must implement this function to handle the + // events when a flight plan flight plan data is updated. + //----------------------------------------------------------------- + + //---OnFlightPlanControllerAssignedDataUpdate---------------------- + + inline virtual void OnFlightPlanControllerAssignedDataUpdate(CFlightPlan FlightPlan, int DataType){}; + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the flight plan reference whose controller + // assigned data is updated + // => DataType - the type of the data updated (CTR_DATA_TYPE ...) + // + // Description : + // All plugins must implement this function to handle the + // events when a flight plan controller assigned data is updated. + //----------------------------------------------------------------- + + //---OnFlightPlanFlightStripPushed--------------------------------- + + inline virtual void OnFlightPlanFlightStripPushed( + CFlightPlan FlightPlan, const char* sSenderController, const char* sTargetController + ){}; + //------------------------------------------------------------------ + // Parameters : + // => FlightPlan - the flight plan reference whose flight + // stirp is pushed from one controller + // to another + // => sSenderController - the one who sent the strip + // => sTargetController - the one who received the strip + // + // Description : + // This function is called when a strip is pushed to you or + // by you. One of SenderController or TargetController is always + // you. + //------------------------------------------------------------------ + + //---OnCompileCommand----------------------------------------------- + + inline virtual bool OnCompileCommand(const char* sCommandLine) + { + return false; + }; + //------------------------------------------------------------------ + // Parameters : + // => sCommandLine - the full command line + // + // Return : + // true - if the command is compiled + // false - else + // + // Description : + // When a command is not interpreted by EuroScope it calls the + // plugins. Firt this functions are called from the radar + // screen handlers. If all refuses then the plug-in level + // functions are called too. If one function return true, no + // more functions are called. + //------------------------------------------------------------------ + + //---OnOverScreenObject--------------------------------------------- + + inline virtual void OnOverScreenObject(int ObjectType, const char* sObjectId, POINT Pt, RECT Area){}; + //------------------------------------------------------------------ + // Parameters : + // => ObjectType - the type of the screen object + // => sObjectId - the ID of the screen object + // => Pt - the mouse position + // => Area - the area originally registered for the + // screen object + // + // Description : + // This function is called whenever the mouse is over a view + // object that was registered by the plugin. + //------------------------------------------------------------------ + + //---OnButtonDownScreenObject--------------------------------------- + + inline virtual void + OnButtonDownScreenObject(int ObjectType, const char* sObjectId, POINT Pt, RECT Area, int Button){}; + //------------------------------------------------------------------ + // Parameters : + // => ObjectType - the type of the screen object + // => sObjectId - the ID of the screen object + // => Pt - the mouse position + // => Area - the area originally registered for the + // screen object + // => Button - BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT + // + // Description : + // This function is called whenever the mouse button is pressed + // an object that was registered by the plugin. + //------------------------------------------------------------------ + + //---OnButtonUpScreenObject----------------------------------------- + + inline virtual void + OnButtonUpScreenObject(int ObjectType, const char* sObjectId, POINT Pt, RECT Area, int Button){}; + //------------------------------------------------------------------ + // Parameters : + // => ObjectType - the type of the screen object + // => sObjectId - the ID of the screen object + // => Pt - the mouse position + // => Area - the area originally registered for the + // screen object + // => Button - BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT + // + // Description : + // This function is called whenever the mouse button is released + // an object that was registered by the plugin. + //------------------------------------------------------------------ + + //---OnClickScreenObject-------------------------------------------- + + inline virtual void + OnClickScreenObject(int ObjectType, const char* sObjectId, POINT Pt, RECT Area, int Button){}; + //------------------------------------------------------------------ + // Parameters : + // => ObjectType - the type of the screen object + // => sObjectId - the ID of the screen object + // => Pt - the mouse position + // => Area - the area originally registered for the + // screen object + // => Button - BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT + // + // Description : + // This function is called whenever the user clicks on an object + // that was registered by the plugin. + //------------------------------------------------------------------ + + //---OnDoubleClickScreenObject-------------------------------------- + + inline virtual void + OnDoubleClickScreenObject(int ObjectType, const char* sObjectId, POINT Pt, RECT Area, int Button){}; + //------------------------------------------------------------------ + // Parameters : + // => ObjectType - the type of the screen object + // => sObjectId - the ID of the screen object + // => Pt - the mouse position + // => Area - the area originally registered for the + // screen object + // => Button - BUTTON_LEFT, BUTTON_MIDDLE, BUTTON_RIGHT + // + // Description : + // This function is called whenever the user doubleclicks on an + // object that was registered by the plugin. + //------------------------------------------------------------------ + + //---OnMoveScreenObject--------------------------------------------- + + inline virtual void + OnMoveScreenObject(int ObjectType, const char* sObjectId, POINT Pt, RECT Area, bool Released){}; + //------------------------------------------------------------------ + // Parameters : + // => ObjectType - the type of the screen object + // => sObjectId - the ID of the screen object + // => Pt - the mouse position + // => Area - the area originally registered for the + // screen object + // => Released - indicates that this is the last call of the + // move as the user has just released the + // object + // + // Description : + // This function is called whenever the user moves the view object. + // While it is being dragged this function is called several times + // with Released == false. At the end when the object is released + // the Released == true, and no more call for the object. + //------------------------------------------------------------------ + + //---OnFunctionCall------------------------------------------------- + + inline virtual void OnFunctionCall(int FunctionId, const char* sItemString, POINT Pt, RECT Area){}; + //------------------------------------------------------------------ + // Parameters : + // => FunctionId - the ID of the function that is selected + // => sItemString - the string of the item initiated the + // function call (on popup edit calls it + // holds the updated string) + // => Pt - the mouse position + // => Area - the area originally registered for the + // screen object that initiated the function + // + // Description : + // This function is called when a function is initiated. The + // function itself can be a TAG item function and the user + // clicked on a TAG or on an AC list. This function is also + // clalled after popup edit and menu items. + //------------------------------------------------------------------ + }; + + class DllSpecEuroScope CFlightPlanList + { + private: + ESINDEX m_Position;// the currently referenced AC list position + + friend class CPlugInData; + friend class CPlugIn; + + public: + //---CFlightPlanList----------------------------------------------- + + inline CFlightPlanList(void) + { + m_Position = NULL; + }; + + //---IsValid------------------------------------------------------- + + inline bool IsValid(void) const + { + return m_Position != NULL; + }; + + //---GetColumnNumber----------------------------------------------- + + int GetColumnNumber(void); + //----------------------------------------------------------------- + // Return : + // The number of the columns defined so far. It is a good idea + // to test with this function if the AC list is filled from + // the settings before adding new columns. + //----------------------------------------------------------------- + + //---DeleteAllColumns---------------------------------------------- + + void DeleteAllColumns(void); + //----------------------------------------------------------------- + // Description : + // It deletes all previous column definitions. + //----------------------------------------------------------------- + + //---AddColumnDefinition------------------------------------------- + + void AddColumnDefinition( + const char* sColumnTitle, int Width, bool Centered, const char* sItemProvifer, int ItemCode, + const char* sLeftButtonFunctionProvifer, int LeftButtonFunction, + const char* sRightButtonFunctionProvifer, int RightButtonFunction + ); + //----------------------------------------------------------------- + // Parameters : + // => sColumnTitle - the title string of the column + // => Width - width of the column (in chars) + // => Centered - indicates centered alignment + // => sItemProvifer - TAG item provider for the column; pass + // NULL or "" for ES built in items + // => ItemCode - the TAG item codes )see above the + // built in codes) + // => sLeftButtonFunctionProvifer + // - the provider of the left button function + // (pass NULL, not yet implemented) + // => LeftButtonFunction - the left button function (see above + // the built in functions) + // => sRightButtonFunctionProvifer, + // - the provider of the right button function + // (pass NULL, not yet implemented) + // => RightButtonFunction - the right button function (see above + // the built in functions) + // + // Description : + // It adds one column definition to the AC list. Call this + // function after registering the AC list immediately. All + // column definitions later will be ignored. Also if there are + // data about the content of the list in the settings file then + // all calls are ignored. + //----------------------------------------------------------------- + + //---AddFpToTheList------------------------------------------------ + + void AddFpToTheList(CFlightPlan FlightPlan); + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the FP to be added to the list + // + // Description : + // It adds a new FP to the FP list. + //----------------------------------------------------------------- + + //---RemoveFpFromTheList------------------------------------------- + + void RemoveFpFromTheList(CFlightPlan FlightPlan); + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the FP to be removed from the list + // + // Description : + // It removes a FP to the FP list. + //----------------------------------------------------------------- + + //---ShowFpList---------------------------------------------------- + + void ShowFpList(bool Show); + //----------------------------------------------------------------- + // Parameters : + // => Show - show/hide + // + // Description : + // It shows or hides the FP list. + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CSectorElement + { + private: + int m_Position; // the currently referenced element position + int m_ElementType;// the type of the element + + friend class CPlugInData; + friend class CPlugIn; + friend class CRadarScreen; + + public: + //---CSectorElement------------------------------------------------ + + inline CSectorElement(void) + { + m_Position = -1; + m_ElementType = 0; + }; + + //---IsValid------------------------------------------------------- + + inline bool IsValid(void) const + { + return m_Position != -1; + }; + //----------------------------------------------------------------- + // Return : + // true - if the CTR reference is valid + // false - else + // + // Description : + // It tests if the CTR reference is valid. + //----------------------------------------------------------------- + + //---GetElementType------------------------------------------------ + + inline int GetElementType(void) const + { + return m_ElementType; + }; + + //---GetName------------------------------------------------------- + + const char* GetName(void) const; + //----------------------------------------------------------------- + // Return : + // the name of the element + //----------------------------------------------------------------- + + //---GetPosition--------------------------------------------------- + + bool GetPosition(CPosition* pPosition, int Index); + //----------------------------------------------------------------- + // Parameters : + // <= pPosition - the position of the element + // => Index - the index of the required position (star + // from zero always) + // + // Return : + // true - if the Index if valid within the element and the + // position is optained + // false - esle + // + // Remarks : + // Not all element have coordinates. This function may return + // false for Index zero. + //----------------------------------------------------------------- + + //---GetComponentName---------------------------------------------- + + const char* GetComponentName(int Index); + //----------------------------------------------------------------- + // Parameters : + // => Index - the index of the required component (star + // from zero always) + // + // Return : + // the name of the component or + // empty string if the index is invalid + // + // Description : + // It returns the name of the individual components that can be + // switched on or off in the drawings. + //----------------------------------------------------------------- + + //---GetFrequency-------------------------------------------------- + + double GetFrequency(void) const; + //----------------------------------------------------------------- + // Return : + // the frequency of the VOR, NDB, AIRPORT elements + // 0.0 for all the rest + //----------------------------------------------------------------- + + //---GetRunwayName------------------------------------------------- + + const char* GetRunwayName(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - 0 or 1 + // + // Return : + // the name of the runway + // empty string if the index is invalid + // + // Description : + // It returns the name of the runway. Index 0 and 1 is valid + // for runway elements while sid/star elements always return + // its runway. + //----------------------------------------------------------------- + + //---GetRunwayHeading---------------------------------------------- + + int GetRunwayHeading(int Index) const; + //----------------------------------------------------------------- + // Parameters : + // => Index - 0 or 1 + // + // Return : + // the heading of the runway + // -1 if the index is invalid + // + // Description : + // It returns the heding name of the runway. + //----------------------------------------------------------------- + + //---GetAirportName------------------------------------------------ + + const char* GetAirportName(void) const; + //----------------------------------------------------------------- + // Return : + // the name of the airport this element belongs to + // empty string if the type is invalid + // + // Description : + // It returns the name of the runway for runway and sid/star + // elements. + //----------------------------------------------------------------- + + //--IsElementActive------------------------------------------------ + + bool IsElementActive(bool Departure, int Index = 0); + //----------------------------------------------------------------- + // Parameters : + // => Departure - indicates if the elements shoudl be tested + // if active for arrival (false) or + // departure (true) + // => Index - 0 or 1 + // + // Return : + // true - if the element is active + // false - else + // + // Description : + // It returns if the element (that can be airport or runway) is + // active for arrival or departure. The Index is used for + // runways only. + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CGrountToAirChannel + { + private: + int m_Index;// the currently referenced element index + + friend class CPlugIn; + friend class CPlugInData; + + public: + inline CGrountToAirChannel(void) + { + m_Index = -1; + } + + //---IsValid------------------------------------------------------- + + inline bool IsValid(void) const + { + return m_Index != -1; + }; + //----------------------------------------------------------------- + // Return : + // true - if the CTR reference is valid + // false - else + // + // Description : + // It tests if the CTR reference is valid. + //----------------------------------------------------------------- + + //---GetName------------------------------------------------------- + + const char* GetName(void); + //----------------------------------------------------------------- + // Return : + // The name of the communication channel. + //----------------------------------------------------------------- + + //---GetFrequency-------------------------------------------------- + + double GetFrequency(void); + //----------------------------------------------------------------- + // Return : + // The frequency of the communication channel. + //----------------------------------------------------------------- + + //---GetVoiceServer------------------------------------------------ + + const char* GetVoiceServer(void); + //----------------------------------------------------------------- + // Return : + // The voice server name of the communication channel. + //----------------------------------------------------------------- + + //---GetVoiceChannel----------------------------------------------- + + const char* GetVoiceChannel(void); + //----------------------------------------------------------------- + // Return : + // The voice server channel name of the communication channel. + //----------------------------------------------------------------- + + //---GetIsPrimary-------------------------------------------------- + + bool GetIsPrimary(void); + //----------------------------------------------------------------- + // Return : + // A flag indicating if the channel is the primary channel. + //----------------------------------------------------------------- + + //---GetIsAtis----------------------------------------------------- + + bool GetIsAtis(void); + //----------------------------------------------------------------- + // Return : + // A flag indicating if the channel is the ATIS channel. + //----------------------------------------------------------------- + + //---GetIsTextReceiveOn-------------------------------------------- + + bool GetIsTextReceiveOn(void); + //----------------------------------------------------------------- + // Return : + // A flag indicating if the channel is receiving text messages. + //----------------------------------------------------------------- + + //---GetIsTextTransmitOn------------------------------------------- + + bool GetIsTextTransmitOn(void); + //----------------------------------------------------------------- + // Return : + // A flag indicating if the channel is transmitting text messages. + //----------------------------------------------------------------- + + //---GetIsVoiceReceiveOn------------------------------------------- + + bool GetIsVoiceReceiveOn(void); + //----------------------------------------------------------------- + // Return : + // A flag indicating if the channel is receiving voice. This + // flag is set when the check box is set. It alone does not + // mean the server connection is on. + //----------------------------------------------------------------- + + //---GetIsVoiceTransmitOn------------------------------------------ + + bool GetIsVoiceTransmitOn(void); + //----------------------------------------------------------------- + // Return : + // A flag indicating if the channel is transmitting voice. + //----------------------------------------------------------------- + + //---GetIsVoiceConnected------------------------------------------- + + bool GetIsVoiceConnected(void); + //----------------------------------------------------------------- + // Return : + // A flag indicating if the channel is successfully connected + // to the voice server. + //----------------------------------------------------------------- + + //---TogglePrimary------------------------------------------------- + + void TogglePrimary(void); + //----------------------------------------------------------------- + // Description : + // It changes the primary setting of the channel (like clicking + // on the check box). + //----------------------------------------------------------------- + + //---ToggleAtis---------------------------------------------------- + + void ToggleAtis(void); + //----------------------------------------------------------------- + // Description : + // It changes the ATIS setting of the channel (like clicking + // on the check box). + //----------------------------------------------------------------- + + //---ToggleTextReceive--------------------------------------------- + + void ToggleTextReceive(void); + //----------------------------------------------------------------- + // Description : + // It changes the text receive setting of the channel (like clicking + // on the check box). + //----------------------------------------------------------------- + + //---ToggleTextTransmit-------------------------------------------- + + void ToggleTextTransmit(void); + //----------------------------------------------------------------- + // Description : + // It changes the text transmit setting of the channel (like clicking + // on the check box). + //----------------------------------------------------------------- + + //---ToggleVoiceReceive-------------------------------------------- + + void ToggleVoiceReceive(void); + //----------------------------------------------------------------- + // Description : + // It changes the voice receive setting of the channel (like clicking + // on the check box). + //----------------------------------------------------------------- + + //---ToggleVoiceTransmit------------------------------------------- + + void ToggleVoiceTransmit(void); + //----------------------------------------------------------------- + // Description : + // It changes the voice transmit setting of the channel (like clicking + // on the check box). + //----------------------------------------------------------------- + }; + + class DllSpecEuroScope CPlugIn + { + private: + CPlugInData* m_pPluginData; + // pointer to the internal data structure + + public: + //---CPlugIn------------------------------------------------------- + + CPlugIn(int CompatibilityCode, const char* sPlugInName, const char* sVersionNumber, const char* sAuthorName, + const char* sCopyrigthMessage); + //----------------------------------------------------------------- + // Parameters : + // => CompatibilityCode - for compatiblity check + // => sPlugInName - the user readable name of the plugin + // => sVersionNumber - actual version number + // => sAuthorName - the name of the author + // => sCopyrightMessage - the name of the author + // + // Description : + // The default constructor. + //----------------------------------------------------------------- + + //---~CPlugIn------------------------------------------------------ + + virtual ~CPlugIn(void); + //----------------------------------------------------------------- + // Description : + // The descriptoz. Keep it virtual. + //----------------------------------------------------------------- + + //---OnControllerPositionUpdate------------------------------------ + + inline virtual void OnControllerPositionUpdate(CController Controller){}; + //----------------------------------------------------------------- + // Parameters : + // => Controller - the controller reference whose position + // is updated + // + // Description : + // All plugins must implement this function to handle the + // events when a controller position is updated. + //----------------------------------------------------------------- + + //---OnControllerDisconnect---------------------------------------- + + inline virtual void OnControllerDisconnect(CController Controller){}; + //----------------------------------------------------------------- + // Parameters : + // => Controller - the controller reference + // + // Description : + // All plugins must implement this function to handle the + // events when a controller is logged off or its position + // update is timed out. + //----------------------------------------------------------------- + + //---OnRadarTergetPositionUpdate-------------------------------------- + + inline virtual void OnRadarTargetPositionUpdate(CRadarTarget RadarTarget){}; + //----------------------------------------------------------------- + // Parameters : + // => radarTarget - the radar target reference whose position + // is updated + // + // Description : + // All plugins must implement this function to handle the + // events when a radara target position is updated. + //----------------------------------------------------------------- + + //---OnFlightPlanDisconnect---------------------------------------- + + inline virtual void OnFlightPlanDisconnect(CFlightPlan FlightPlan){}; + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the flight plan reference + // + // Description : + // All plugins must implement this function to handle the + // events when a fight plan is logged off or its position + // update is timed out. + //----------------------------------------------------------------- + + //---OnFlightPlanFlightPlanDataUpdate------------------------------ + + inline virtual void OnFlightPlanFlightPlanDataUpdate(CFlightPlan FlightPlan){}; + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the flight plan reference whose flight plan + // data is updated + // + // Description : + // All plugins must implement this function to handle the + // events when a flight plan flight plan data is updated. + //----------------------------------------------------------------- + + //---OnPlaneInformationUpdate-------------------------------------- + + inline virtual void + OnPlaneInformationUpdate(const char* sCallsign, const char* sLivery, const char* sPlaneType){}; + //----------------------------------------------------------------- + // Parameters : + // => sCallsign - the callsign of the plane + // => sLivery - the livery set in the pilot client + // => sPlaneType - the manufacturer and type set in the pilot client + // + // Description : + // This function is called when a SqwakBox plane information + // update message is received. + //----------------------------------------------------------------- + + //---OnFlightPlanControllerAssignedDataUpdate---------------------- + + inline virtual void OnFlightPlanControllerAssignedDataUpdate(CFlightPlan FlightPlan, int DataType){}; + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the flight plan reference whose controller + // assigned data is updated + // => DataType - the type of the data updated (CTR_DATA_TYPE ...) + // + // Description : + // All plugins must implement this function to handle the + // events when a plane controller assigned data is updated. + //----------------------------------------------------------------- + + //---OnFlightPlanFlightStripPushed--------------------------------- + + inline virtual void OnFlightPlanFlightStripPushed( + CFlightPlan FlightPlan, const char* sSenderController, const char* sTargetController + ){}; + //------------------------------------------------------------------ + // Parameters : + // => FlightPlan - the FP reference whose flight + // stirp is pushed from one controller + // to another + // => sSenderController - the one who sent the strip + // => sTargetController - the one who received the strip + // + // Description : + // This function is called when a strip is pushed to you or + // by you. One of SenderController or TargetController is always + // you. + //------------------------------------------------------------------ + + //---OnRadarScreenCreated------------------------------------------ + + inline virtual CRadarScreen* OnRadarScreenCreated( + const char* sDisplayName, bool NeedRadarContent, bool GeoReferenced, bool CanBeSaved, bool CanBeCreated + ) + { + return NULL; + }; + //----------------------------------------------------------------- + // Parameters : + // => sDisplayName - the name of the display that is just + // created; if the name is + // "Standard ES radar screen" + // it is a standard ES radar screen + // => NeedRadarContent, + // => GeoReferenced, + // => CanBeSaved, + // => CanBeCreated - other radar screen attributes + // see them at RegisterDisplayType + // + // Return : + // an instance to your own radar scren class member or + // NULL if this type is not handled by your plug-in + // + // Description : + // When a new radar display is opened your plug-in is called + // to create an screen object instance. You may create your own + // radar handling class that is derived from CRadarScreen. + // Allocate a new instance and return the pointer to handle + // all the events from there. + //----------------------------------------------------------------- + + //---OnCompileCommand----------------------------------------------- + + inline virtual bool OnCompileCommand(const char* sCommandLine) + { + return false; + }; + //------------------------------------------------------------------ + // Parameters : + // => sCommandLine - the full command line + // + // Return : + // true - if the command is compiled + // false - else + // + // Description : + // When a command is not interpreted by EuroScope it calls the + // plugins. Firt the radar screens are called. If all refuses + // then the plug-in level functions are called too. If one + // function return true, no more functions are called. + //------------------------------------------------------------------ + + //---OnCompileFrequencyChat----------------------------------------- + + inline virtual void + OnCompileFrequencyChat(const char* sSenderCallsign, double Frequency, const char* sChatMessage){}; + //------------------------------------------------------------------ + // Parameters : + // => sSenderCallsign - the sender + // => Frequency - the frequency where you received the + // message + // => sChatMessage - the full message string + // + // Description : + // When a frequency message is received you have the possibility + // to process, display its content. This function may be called + // for several times with the same message if it is sent to + // several frequencies. + //------------------------------------------------------------------ + + //---OnCompilePrivateChat------------------------------------------- + + inline virtual void + OnCompilePrivateChat(const char* sSenderCallsign, const char* sReceiverCallsign, const char* sChatMessage){}; + //------------------------------------------------------------------ + // Parameters : + // => sSenderCallsign - the sender + // => sReceiverCallsign - the receivers callsign + // server - for messages from the SERVER + // ATC - ATC messages + // Broadcast- broadcast messages + // SUP - supervisor requests + // => sChatMessage - the full message string + // + // Description : + // When a private message is received you have the possibility + // to process, display its content. + //------------------------------------------------------------------ + + //---OnGetTagItem--------------------------------------------------- + + inline virtual void OnGetTagItem( + CFlightPlan FlightPlan, CRadarTarget RadarTarget, int ItemCode, int TagData, char sItemString[16], + int* pColorCode, COLORREF* pRGB, double* pFontSize + ){}; + //----------------------------------------------------------------- + // Parameters : + // => FlightPlan - the FP reference whose TAG item is + // to be created - it may be invalid + // => RadarTraget - the RT reference whose TAG item is + // to be created - it may be invalid + // => ItemCode - the code of the item + // => TagData - the data available for the TAG; values are + // - TAG_DATA_UNCORRELATED_RADAR + // - TAG_DATA_FLIGHT_PLAN_TRACK + // - TAG_DATA_CORRELATED + // <= sItemString - the generated string; it is strictly limited + // to 15 chars (plust terminator \0) + // <= pColorCode - the color code of the item; return one of + // the TAG_COLOR_ ... value + // TAG_COLOR_DEFAULT - indicates the default for AC state + // TAG_COLOR_RGB_DEFINED - do not use and + // predefined color, but the return value + // in pRGB + // <= pRGB - the requested color of the TAG item; it is + // used only in case if pColorCode is + // TAG_COLOR_RGB_DEFINED + // <=> pFontSize - the requested size of the font + // + // Description : + // All plugins must implement this function to handle the + // events when a plane position is updated. + //----------------------------------------------------------------- + + //---OnRefreshFpListContent---------------------------------------- + + inline virtual void OnRefreshFpListContent(CFlightPlanList AcList){}; + //----------------------------------------------------------------- + // Parameters : + // => AcList - the AC list to be refreshed + // + // Description : + // This function is called once in a second just after all plane + // data is refreshed in ES memory. You may add/remove planes + // to/from the list, or clear the content and add the planes + // again. + //----------------------------------------------------------------- + + //---OnNewMetarReceived-------------------------------------------- + + inline virtual void OnNewMetarReceived(const char* sStation, const char* sFullMetar){}; + //----------------------------------------------------------------- + // Parameters : + // => sStation - the airport + // => sFullMetar - the original comlete metar string + // + // Description : + // This function is called whenever a new metar data is received + // from the server. + //----------------------------------------------------------------- + + //---OnFunctionCall------------------------------------------------- + + inline virtual void OnFunctionCall(int FunctionId, const char* sItemString, POINT Pt, RECT Area){}; + //------------------------------------------------------------------ + // Parameters : + // => FunctionId - the ID of the function that is selected + // => sItemString - the string of the item initiated the + // function call (on popup edit calls it + // holds the updated string) + // => Pt - the mouse position + // => Area - the area originally registered for the + // screen object that initiated the function + // + // Description : + // This function is called when a function is initiated. The + // function itself can be a TAG item function and the user + // clicked on a TAG or on an AC list. This function is also + // clalled after popup edit and menu items. + //------------------------------------------------------------------ + + //---OnAirportRunwayActivityChanged--------------------------------- + + inline virtual void OnAirportRunwayActivityChanged(void){}; + //----------------------------------------------------------------- + // Description : + // This function is called whenever the user closes the + // runway activity dialog with OK. + //----------------------------------------------------------------- + + //---OnAirportRunwayActivityChanged--------------------------------- + + inline virtual void OnTimer(int Counter){}; + //----------------------------------------------------------------- + // Parameters : + // => Counter - It counts the secods from the application start + // + // Description : + // This function is called once in a second. Timer is a limited + // resource and you can use the one that refreshes the sceens + // once in a second. + //----------------------------------------------------------------- + + //---GetPlugInName------------------------------------------------- + + const char* GetPlugInName(void); + //----------------------------------------------------------------- + // Return : + // the plugin name. + //----------------------------------------------------------------- + + //---RegisterDisplayType------------------------------------------- + + void RegisterDisplayType( + const char* sDisplayName, bool NeedRadarContent, bool GeoReferenced, bool CanBeSaved, bool CanBeCreated + ); + //----------------------------------------------------------------- + // Parameters : + // => sDisplayType - the name of the display type + // => NeedRadarContent- indicates that the default radar content + // should be displayed in this type + // => GeoReferenced - indicates that lat/lon coordnates + // can be used in the type, and therefore + // zooming in/out a panning is allowed + // => CanBeSaved - indicates that ASR file content can + // be saved on exit + // => CanBeCreated - indicates that it should be listed in + // new ASR types + // + // Description : + // Call this function to register your own display type within + // EuroScope. You need this only in case you would like to + // create a complete new outllok of the view. In your own type + // you are free to display anything to the screen. + //----------------------------------------------------------------- + + //---RegisterTagItemType------------------------------------------- + + void RegisterTagItemType(const char* sDisplayName, int Code); + //----------------------------------------------------------------- + // Parameters : + // => sDisplayName - the user readable name of the TAG item + // => Code - the item code (must be bigger than 0) + // + // Description : + // It registers a new TAG item type. + //----------------------------------------------------------------- + + //---RegisterTagItemFunction--------------------------------------- + + void RegisterTagItemFunction(const char* sDisplayName, int Code); + //----------------------------------------------------------------- + // Parameters : + // => sDisplayName - the user readable name of the TAG item + // => Code - the item code (must be bigger than 0) + // + // Description : + // It registers a new TAG item function. + //----------------------------------------------------------------- + + //---RegisterFpList------------------------------------------------ + + CFlightPlanList RegisterFpList(const char* sListName); + //----------------------------------------------------------------- + // Parameters : + // => sListName - the name of the list box + // + // Return : + // The new AC list instance. The returned instance may be saved + // into your memory area and can be used in further processing. + // + // Description : + // It registers a new AC list. + //----------------------------------------------------------------- + + //---RegisterToolbarItem------------------------------------------- + + void RegisterToolbarItem(int ItemId, const char* sItemName); + //----------------------------------------------------------------- + // Parameters : + // => ItemId - the ID of the toolbar item + // => sItemName - the name of the toolbar item + // + // Decsription : + // It registers a toolbar item for the plugin. To display it + // implement the OnToolbarItem... functions. + //----------------------------------------------------------------- + + //---RefreshToolbar------------------------------------------------ + + void RefreshToolbar(bool ResizeToo); + //----------------------------------------------------------------- + // Parameters : + // => ResizeToo - indicates that the plugin would liek to + // change the size of the toolbar item + // + // Description : + // Call this function to indicate that the toolbar content is + // invalid. + //----------------------------------------------------------------- + + //---SaveDataToSettings-------------------------------------------- + + void SaveDataToSettings(const char* sVariableName, const char* sVariableDescription, const char* sValue); + //----------------------------------------------------------------- + // Parameters : + // => sVariableName - the name under your value will be saved + // => sVariableDescription- a user readable name of the variable; + // this value will be shown in the + // save modified settings dialog; if + // empty (never pass NULL), then it + // will not be shown + // => sValue - the value itself to be stored; it + // may contain only printable chars and + // never LF or CR or ':'. + // + // Description : + // It saves the value for the plug in the settings file. + //----------------------------------------------------------------- + + //---GetDataFromSettings------------------------------------------- + + const char* GetDataFromSettings(const char* sVariableName); + //----------------------------------------------------------------- + // Parameters : + // => sVariableName - the name under your value was saved + // + // Return : + // the value found in the ASR or + // NULL if not found + // + // Description : + // It loads the value for the plug in from the settings file. + //----------------------------------------------------------------- + + //---OpenPopupEdit------------------------------------------------- + + void OpenPopupEdit(RECT Area, int FunctionId, const char* sInitialValue); + //----------------------------------------------------------------- + // Parameters : + // => Area - the rectangle where the edit box + // appears (it is a good idea to pass the + // rectangle coming from the OnFunctionCall) + // => FunctionId - the ID of the editing mode; this value + // will be passed to the OnFunctionCall + // => sInitialValue - the initial content of the edit box + // + // Description : + // It opens up a popup edit box in the Area rectangle with the + // sInitialContent. After editing it by the user the + // OnFunctionCall is called with the ID and with the new + // string value. + //----------------------------------------------------------------- + + //---OpenPopupList------------------------------------------------- + + void OpenPopupList(RECT Area, const char* sTitle, int ColumnNumber); + //----------------------------------------------------------------- + // Parameters : + // => Area - the requested position of the center + // (selected element) in the list + // => sTitle - the popup list title + // => ColumnNumber- the number of the columns in the list + // (currently it is limited to 1 and 2) + // + // Description : + // It starts opening a popup list. You must call the + // AddPopupListElement to fill the list with content. Without + // that it will not be displayed. The popup list is a global + // resource of EuroScope and there is only one list available. + //----------------------------------------------------------------- + + //---AddPopupListElement------------------------------------------- + + void AddPopupListElement( + const char* sString1, const char* sString2, int FunctionId, bool Selected = false, + int Checked = POPUP_ELEMENT_NO_CHECKBOX, bool Disabled = false, bool Fixed = false + ); + //----------------------------------------------------------------- + // Parameters : + // => sString1, + // sString2 - the strings to be displayed in the first + // and in the second column (in case of two + // columns); sString1 will be passed as + // string parameter to OnFunctionCall if the + // item is selected + // => FunctionId - the function ID to be passed to + // OnFunctionCall if the element is selected + // => Selected - indicates if the element is the actual + // value (pass true only once in a definition) + // => Checked - indicates if the item needs a check box in + // from or not; and if it has check box then + // checked or unchecked + // => Disabled - indicates if the element can not be selected + // => Fixed - fixed elements are the last ones; they + // appear in the bottom and are not scrolled + // with the rest; never add more than 3-4 fixed + // items + // + // Description : + // It adds a new popup element to the popup list. + //----------------------------------------------------------------- + + //---GetConnectionType--------------------------------------------- + + int GetConnectionType(void) const; + //----------------------------------------------------------------- + // Return : + // the actual connection type - on of CONNECTION_TYPE_... + //----------------------------------------------------------------- + + //---SelectActiveSectorfile---------------------------------------- + + void SelectActiveSectorfile(void); + //----------------------------------------------------------------- + // Description : + // It selects the active sectorfile as the source for the + // subsequent SectorElementFirst and SectorElementNext calls. + //----------------------------------------------------------------- + + //---SelectScreenSectorfile---------------------------------------- + + void SelectScreenSectorfile(CRadarScreen* pRadarScreen); + //----------------------------------------------------------------- + // Parameters : + // => pRadarScreen - the screen reference + // + // Description : + // It selects the active sectorfile as the source for the + // subsequent SectorElementFirst and SectorElementNext calls. + //----------------------------------------------------------------- + + //---SetASELAircraft----------------------------------------------- + + void SetASELAircraft(const CFlightPlan FlightPlan); + void SetASELAircraft(const CRadarTarget RadarTarget); + //----------------------------------------------------------------- + // Parameter : + // => FlightPlan - the FP to be selected as ASEL + // => RadarTarget - the RT to be selected as ASEL + // + // Description : + // It sets the given FP/RT as ASEL. + //----------------------------------------------------------------- + + //---FlightPlanSelect---------------------------------------------- + + CFlightPlan FlightPlanSelect(const char* sCallsign) const; + //----------------------------------------------------------------- + // Parameters : + // => sCallsign - the callsign of the FP to be selected + // + // Return : + // A flight plan object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the FP with the given callsign. + //----------------------------------------------------------------- + + //---RadarTargetSelect--------------------------------------------- + + CRadarTarget RadarTargetSelect(const char* sCallsign) const; + //----------------------------------------------------------------- + // Parameters : + // => sCallsign - the callsign of the RT to be selected + // you can also enter system ID as callsign + // + // Return : + // A radar target object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the RT with the given callsign/system ID. + //----------------------------------------------------------------- + + //---FlightPlanSelectFirst----------------------------------------- + + CFlightPlan FlightPlanSelectFirst(void) const; + //----------------------------------------------------------------- + // Return : + // An flight plan object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the first FP in the list. + //----------------------------------------------------------------- + + //---RadarTargetSelectFirst---------------------------------------- + + CRadarTarget RadarTargetSelectFirst(void) const; + //----------------------------------------------------------------- + // Return : + // An radar target object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the first RT in the list. + //----------------------------------------------------------------- + + //---FlightPlanSelectNext------------------------------------------ + + CFlightPlan FlightPlanSelectNext(CFlightPlan CurrentFlightPlan) const; + //----------------------------------------------------------------- + // Parameters : + // => CurrentFlightPlan - the actually selected FP element + // + // Return : + // A flight plan object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the next FP in the list. + //----------------------------------------------------------------- + + //---RadarTargetSelectNext----------------------------------------- + + CRadarTarget RadarTargetSelectNext(CRadarTarget CurrentRadartarget) const; + //----------------------------------------------------------------- + // Parameters : + // => CurrentRadartarget - the actually selected RT element + // + // Return : + // A radar target object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the next RT in the list. + //----------------------------------------------------------------- + + //---FlightPlanSelectASEL------------------------------------------ + + CFlightPlan FlightPlanSelectASEL(void) const; + //----------------------------------------------------------------- + // Return : + // A flight plan object instance. May be invalid. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the currently ASEL flight plan. + //----------------------------------------------------------------- + + //---RadarTargetSelectASEL----------------------------------------- + + CRadarTarget RadarTargetSelectASEL(void) const; + //----------------------------------------------------------------- + // Return : + // A radar target object instance. May be invalid. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the currently ASEL radar target. + //----------------------------------------------------------------- + + //---ControllerSelect---------------------------------------------- + + CController ControllerSelect(const char* sCallsign) const; + //----------------------------------------------------------------- + // Parameters : + // => sCallsign - the callsign of the controller to be selected + // + // Return : + // A controller object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the controller with the given callsign. + //----------------------------------------------------------------- + + //---ControllerSelectByPositionId---------------------------------- + + CController ControllerSelectByPositionId(const char* sPositionId) const; + //----------------------------------------------------------------- + // Parameters : + // => sPositionId - the position ID of the controller to be selected + // + // Return : + // A controller object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the controller with the given position ID. + //----------------------------------------------------------------- + + //---ControllerMyself---------------------------------------------- + + CController ControllerMyself(void) const; + //----------------------------------------------------------------- + // Return : + // A controller object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the controller that was logged in in this session. + //----------------------------------------------------------------- + + //---ControllerSelectFirst----------------------------------------- + + CController ControllerSelectFirst(void) const; + //----------------------------------------------------------------- + // Return : + // A controller object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the first controller in the list. + //----------------------------------------------------------------- + + //---ControllerSelectNext------------------------------------------ + + CController ControllerSelectNext(CController CurrentController) const; + //----------------------------------------------------------------- + // Parameters : + // => CurrentController - the actually selected controller element + // + // Return : + // A controller object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the next controller in the list. + //----------------------------------------------------------------- + + //---SectorFileElementSelectFirst---------------------------------- + + CSectorElement SectorFileElementSelectFirst(int ElementType) const; + //----------------------------------------------------------------- + // Parameters : + // => ElementType - the type of the elements to be searched + // for; pass SECTOR_ELEMENT_ALL to search + // for all element type + // + // Return : + // A sector file element object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the first element (of the given type) from the + // previously selected sectorfile. + //----------------------------------------------------------------- + + //---SectorFileElementSelectNext----------------------------------- + + CSectorElement SectorFileElementSelectNext(CSectorElement CurrentElement, int ElementType) const; + //----------------------------------------------------------------- + // Parameters : + // => CurrentElement - the actually selected sectorfile element + // => ElementType - the type of the elements to be searched + // for; pass SECTOR_ELEMENT_ALL to search + // for all element type + // + // Return : + // A sectrofile element object instance. + // + // Remark: + // This instance is only valid inside the block you are querying. + // Do not save it to a static place or into a member variables. + // Subsequent use of an invalid extracted route reference may + // cause ES to crash. + // + // Description : + // It selects the next element (of the given type) from the + // previously selected sectorfile. + //----------------------------------------------------------------- + + //---DisplayUserMessage-------------------------------------------- + + void DisplayUserMessage( + const char* sHandlerName, const char* sSenderName, const char* sMessage, bool ShowHandler, + bool ShowUnread, bool ShowUnreadEvenIfBusy, bool StartFlashing, bool NeedConfirmation + ); + //----------------------------------------------------------------- + // Parameters : + // => sHandlerName - the message handler name; this name + // above the chat area (the callsign in + // case of private chat, ATC, Broadcast, + // etc.); use your plug-in name here + // => sSenderName - the name of the sender; if empty the + // message will be displayed if the user + // were sending it + // => sMessage - the message itself + // => ShowHandler - should the handler be displayed (if hidden) + // => ShowUnread - should the handler be colored with + // unread message color if not selected + // => ShowUnreadEvenIfBusy - as above even if busy flag is set + // => StartFlashing - should the handler be flashing + // => NeedConfirmation- does this message need a confirmation + // + // Description : + // This function writes a message to the user to the standard + // chat area. + //----------------------------------------------------------------- + + //---GroundToArChannelSelectFirst---------------------------------- + + CGrountToAirChannel GroundToArChannelSelectFirst(void); + //----------------------------------------------------------------- + // Return : + // The first channel defined in the Voice Communication Setup + // (not necessarily the first in the dialog). The return value + // is temporary. Do not save it for further use. + //----------------------------------------------------------------- + + //---GroundToArChannelSelectNext----------------------------------- + + CGrountToAirChannel GroundToArChannelSelectNext(CGrountToAirChannel CurrentChannel); + //----------------------------------------------------------------- + // Parameters : + // => CurrentChannel - the current channel + // + // Return : + // The next channel defined in the Voice Communication Setup + // (not necessarily the next in the dialog). The return value + // is temporary. Do not save it for further use. + //----------------------------------------------------------------- + + //---AddAlias------------------------------------------------------ + + void AddAlias(const char* sAliasName, const char* sAliasValue); + //----------------------------------------------------------------- + // Parameters : + // => sAliasName - the alias name (must begin with .) + // => sAliasValue - the value to be used + // + // Description : + // It adds a new alias to the alias interpreter. + //----------------------------------------------------------------- + + //---OnVoiceTransmitStarted---------------------------------------- + + inline virtual void OnVoiceTransmitStarted(bool OnPrimary){}; + //----------------------------------------------------------------- + // Parameters : + // => OnPrimary - indicates if the transmit started on the + // primary voice channel + // + // Description : + // This function is called on a voice transmit start. + // Warning: This function is called from a seperated thread, + // write a thread-safe handler. + //----------------------------------------------------------------- + + //---OnVoiceTransmitEnded------------------------------------------ + + inline virtual void OnVoiceTransmitEnded(bool OnPrimary){}; + //----------------------------------------------------------------- + // => OnPrimary - indicates if the transmit ended on the + // primary voice channel + // + // Description : + // This function is called on a voice transmit end. + // Warning: This function is called from a seperated thread, + // write a thread-safe handler. + //----------------------------------------------------------------- + + //---OnVoiceReceiveStarted----------------------------------------- + + inline virtual void OnVoiceReceiveStarted(CGrountToAirChannel Channel){}; + //----------------------------------------------------------------- + // Parameters : + // => Channel - the channel that receives some voice + // + // Description : + // This function is called on a voice receive start. + //----------------------------------------------------------------- + + //---OnVoiceReceiveEnded------------------------------------------- + + inline virtual void OnVoiceReceiveEnded(CGrountToAirChannel Channel){}; + //----------------------------------------------------------------- + // Parameters : + // => Channel - the channel that received some voice + // + // Description : + // This function is called on a voice receive start. + //----------------------------------------------------------------- + + //---GetTransitionAltitude----------------------------------------- + + int GetTransitionAltitude(void); + //----------------------------------------------------------------- + // Return : + // The transition altitude of the system. + //----------------------------------------------------------------- + }; + +}// namespace EuroScopePlugIn + +//---EuroScopePlugInInit----------------------------------------------- + +void __declspec(dllexport) EuroScopePlugInInit(EuroScopePlugIn ::CPlugIn** ppPlugInInstance); +//--------------------------------------------------------------------- +// Parameters : +// <= ppPlugInInstance- a pointer to the plug-in instance +// +// Description : +// Every plugin have to implement this function. When EuroScope +// loads the DLL, it searches for this function and calls it. Do +// all initialization code (including the plugin class instance +// creation) in this function. Only one plug-in instance is +// supported by in one DLL +// Before returning you MUST call the SetPlugInName function. +// If this call is missing or any parameter is empty your DLL will +// be unloaded immediately. +//--------------------------------------------------------------------- + +//---EuroScopePlugInExit----------------------------------------------- + +void __declspec(dllexport) EuroScopePlugInExit(void); +//--------------------------------------------------------------------- +// Description : +// Every plugin have to implement this function. When EuroScope +// unloads the DLL (for user request or due exiting) it will call +// this function. Be sure to clean up all members, especialy +// delete all plugin class instances. +//---------------------------------------------------------------------