From 57fdc5b6f1585b27a2e82ff8b7cf34c5baa07003 Mon Sep 17 00:00:00 2001 From: Anthony Romaniello <66272872+aromanielloNTIA@users.noreply.github.com> Date: Thu, 21 Nov 2024 18:52:53 -0500 Subject: [PATCH] Adjust for single library header --- app/include/Structs.h | 2 +- include/ITS.ITU.PSeries.P2108/Enums.h | 40 ------ include/ITS.ITU.PSeries.P2108/P2108.h | 79 ---------- include/ITS.ITU.PSeries.P2108/ReturnCodes.h | 43 ------ include/P2108.h | 136 ++++++++++++++++++ include/PropLibTemplate.h | 57 -------- src/AeronauticalStatisticalModel.cpp | 2 +- src/HeightGainTerminalCorrectionModel.cpp | 2 +- ...rseComplementaryCumulativeDistribution.cpp | 2 +- src/TerrestrialStatisticalModel.cpp | 2 +- tests/TestUtils.h | 2 +- 11 files changed, 142 insertions(+), 225 deletions(-) delete mode 100644 include/ITS.ITU.PSeries.P2108/Enums.h delete mode 100644 include/ITS.ITU.PSeries.P2108/P2108.h delete mode 100644 include/ITS.ITU.PSeries.P2108/ReturnCodes.h create mode 100644 include/P2108.h delete mode 100644 include/PropLibTemplate.h diff --git a/app/include/Structs.h b/app/include/Structs.h index 448863e..bd6dd35 100644 --- a/app/include/Structs.h +++ b/app/include/Structs.h @@ -3,7 +3,7 @@ */ #pragma once -#include "ITS.ITU.PSeries.P2108/Enums.h" // For ClutterType +#include "P2108.h" // For ClutterType enum #include // for std::string diff --git a/include/ITS.ITU.PSeries.P2108/Enums.h b/include/ITS.ITU.PSeries.P2108/Enums.h deleted file mode 100644 index 769af60..0000000 --- a/include/ITS.ITU.PSeries.P2108/Enums.h +++ /dev/null @@ -1,40 +0,0 @@ -/** @file Enums.h - * Enumerated types used by this software - */ -#pragma once - -namespace ITS { -namespace ITU { -namespace PSeries { -namespace P2108 { - -/** Clutter type enum, based on Table 3 in Section 3.1 */ -enum ClutterType { - WATER_SEA = 1, /**< Water/sea clutter type */ - OPEN_RURAL = 2, /**< Open/rural clutter type */ - SUBURBAN = 3, /**< Suburban clutter type */ - URBAN = 4, /**< Urban clutter type */ - TREES_FOREST = 5, /**< Trees/forest clutter type */ - DENSE_URBAN = 6, /**< Dense urban clutter type */ -}; - -/** - * Default values of the representative clutter height @f$ R @f$, - * in meters, by clutter type. - * - * These should be used as inputs to the height gain terminal - * correction model when local information is not available. - */ -enum RepresentativeClutterHeight { - R__WATER_SEA = 10, /**< @f$ R @f$ for the trees/forest clutter type */ - R__OPEN_RURAL = 10, /**< @f$ R @f$ for the open/rural clutter type */ - R__SUBURBAN = 10, /**< @f$ R @f$ for the suburban clutter type */ - R__URBAN = 15, /**< @f$ R @f$ for the urban clutter type */ - R__TREES_FOREST = 15, /**< @f$ R @f$ for the trees/forest clutter type */ - R__DENSE_URBAN = 20, /**< @f$ R @f$ for the dense urban clutter type */ -}; - -} // namespace P2108 -} // namespace PSeries -} // namespace ITU -} // namespace ITS diff --git a/include/ITS.ITU.PSeries.P2108/P2108.h b/include/ITS.ITU.PSeries.P2108/P2108.h deleted file mode 100644 index 01cb195..0000000 --- a/include/ITS.ITU.PSeries.P2108/P2108.h +++ /dev/null @@ -1,79 +0,0 @@ -/** @file P2108.h - * Interface header for this library - */ -#pragma once - -#include "Enums.h" -#include "ReturnCodes.h" - -namespace ITS { -namespace ITU { -namespace PSeries { -namespace P2108 { - -// Define cross-platform EXPORTED -#ifndef DOXYGEN_SHOULD_SKIP - #ifdef _WIN32 - #define EXPORTED extern "C" __declspec(dllexport) - #else - #define EXPORTED extern "C" - #endif -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Constants -/** Approximate value of @f$ \pi @f$ */ -constexpr double PI = 3.14159265358979323846; - -//////////////////////////////////////////////////////////////////////////////// -// Public Functions -EXPORTED ReturnCode AeronauticalStatisticalModel( - const double f__ghz, - const double theta__deg, - const double p, - double &L_ces__db -); -EXPORTED ReturnCode TerrestrialStatisticalModel( - const double f__ghz, const double d__km, const double p, double &L_ctt__db -); -EXPORTED ReturnCode HeightGainTerminalCorrectionModel( - const double f__ghz, - const double h__meter, - const double w_s__meter, - const double R__meter, - const ClutterType clutter_type, - double &A_h__db -); -EXPORTED char *GetReturnStatusCharArray(const int code); -EXPORTED void FreeReturnStatusCharArray(char *c_msg); - -//////////////////////////////////////////////////////////////////////////////// -// Private Functions -std::string GetReturnStatus(const int code); -double cot(const double x); -double InverseComplementaryCumulativeDistribution(const double q); -double Equation_2a(const double nu); -double Equation_2b( - const double K_h2, const double h__meter, const double R__meter -); -ReturnCode Section3p1_InputValidation( - const double f__ghz, - const double h__meter, - const double w_s__meter, - const double R__meter -); -ReturnCode Section3p2_InputValidation( - const double f__ghz, const double d__km, const double p -); -ReturnCode Section3p3_InputValidation( - const double f__ghz, const double theta__deg, const double p -); -double TerrestrialStatisticalModelHelper( - const double f__ghz, const double d__km, const double p -); - - -} // namespace P2108 -} // namespace PSeries -} // namespace ITU -} // namespace ITS diff --git a/include/ITS.ITU.PSeries.P2108/ReturnCodes.h b/include/ITS.ITU.PSeries.P2108/ReturnCodes.h deleted file mode 100644 index 1bf32c1..0000000 --- a/include/ITS.ITU.PSeries.P2108/ReturnCodes.h +++ /dev/null @@ -1,43 +0,0 @@ -/** @file ReturnCodes.h - * Contains return codes used by this software - */ -#pragma once - -#include // for std::string -#include // for std::unordered_map - -namespace ITS { -namespace ITU { -namespace PSeries { -namespace P2108 { - -/******************************************************************************* - * Return Codes defined by this software (0-127) - ******************************************************************************/ -// clang-format off -enum ReturnCode { - SUCCESS = 0, /**< Successful execution */ - - // Section 3.1 Error Codes - ERROR31__FREQUENCY = 32, /**< Frequency must be between 0.3 and 3 GHz */ - ERROR31__ANTENNA_HEIGHT, /**< Antenna height must be @f$ \geq @f$ 0 meters */ - ERROR31__STREET_WIDTH, /**< Street width must be @f$ > @f$ 0 meters */ - ERROR31__CLUTTER_HEIGHT, /**< Representative clutter height must be @f$ > @f$ 0 meters */ - ERROR31__CLUTTER_TYPE, /**< Invalid value for clutter type */ - - // Section 3.2 Error Codes - ERROR32__FREQUENCY = 48, /**< Frequency must be between 2 and 67 GHz */ - ERROR32__DISTANCE, /**< Path distance must be @f$ \geq @f$ 0.25 km */ - ERROR32__PERCENTAGE, /**< Percentage must be between 0 and 100 */ - - // Section 3.3 Error Codes - ERROR33__FREQUENCY = 64, /**< Frequency must be between 10 and 100 GHz */ - ERROR33__THETA, /**< Elevation angle must be between 0 and 100 GHz */ - ERROR33__PERCENTAGE, /**< Percentage must be between 0 and 100 */ -}; -// clang-format on - -} // namespace P2108 -} // namespace PSeries -} // namespace ITU -} // namespace ITS diff --git a/include/P2108.h b/include/P2108.h new file mode 100644 index 0000000..76ccf16 --- /dev/null +++ b/include/P2108.h @@ -0,0 +1,136 @@ +/** @file P2108.h + * Interface header for this library + */ +#pragma once + +#include // for std::string +#include // for std::unordered_map + +namespace ITS { +namespace ITU { +namespace PSeries { +namespace P2108 { + +// Define cross-platform PROPLIB_API to export functions +#ifndef DOXYGEN_SHOULD_SKIP + #ifndef PROPLIB_API + #ifdef _WIN32 + #define PROPLIB_API extern "C" __declspec(dllexport) + #else + #define PROPLIB_API extern "C" + #endif + #endif +#endif + +//////////////////////////////////////////////////////////////////////////////// +// Enums + +/** Clutter type enum, based on Table 3 in Section 3.1 */ +enum ClutterType { + WATER_SEA = 1, /**< Water/sea clutter type */ + OPEN_RURAL = 2, /**< Open/rural clutter type */ + SUBURBAN = 3, /**< Suburban clutter type */ + URBAN = 4, /**< Urban clutter type */ + TREES_FOREST = 5, /**< Trees/forest clutter type */ + DENSE_URBAN = 6, /**< Dense urban clutter type */ +}; + +/******************************************************************************* + * Default values of the representative clutter height @f$ R @f$, + * in meters, by clutter type. + * + * These should be used as inputs to the height gain terminal + * correction model when local information is not available. + ******************************************************************************/ +enum RepresentativeClutterHeight { + R__WATER_SEA = 10, /**< @f$ R @f$ for the trees/forest clutter type */ + R__OPEN_RURAL = 10, /**< @f$ R @f$ for the open/rural clutter type */ + R__SUBURBAN = 10, /**< @f$ R @f$ for the suburban clutter type */ + R__URBAN = 15, /**< @f$ R @f$ for the urban clutter type */ + R__TREES_FOREST = 15, /**< @f$ R @f$ for the trees/forest clutter type */ + R__DENSE_URBAN = 20, /**< @f$ R @f$ for the dense urban clutter type */ +}; + +/******************************************************************************* + * Return Codes defined by this software (0-127) + ******************************************************************************/ +// clang-format off +enum ReturnCode { + SUCCESS = 0, /**< Successful execution */ + + // Section 3.1 Error Codes + ERROR31__FREQUENCY = 32, /**< Frequency must be between 0.3 and 3 GHz */ + ERROR31__ANTENNA_HEIGHT, /**< Antenna height must be @f$ \geq @f$ 0 meters */ + ERROR31__STREET_WIDTH, /**< Street width must be @f$ > @f$ 0 meters */ + ERROR31__CLUTTER_HEIGHT, /**< Representative clutter height must be @f$ > @f$ 0 meters */ + ERROR31__CLUTTER_TYPE, /**< Invalid value for clutter type */ + + // Section 3.2 Error Codes + ERROR32__FREQUENCY = 48, /**< Frequency must be between 2 and 67 GHz */ + ERROR32__DISTANCE, /**< Path distance must be @f$ \geq @f$ 0.25 km */ + ERROR32__PERCENTAGE, /**< Percentage must be between 0 and 100 */ + + // Section 3.3 Error Codes + ERROR33__FREQUENCY = 64, /**< Frequency must be between 10 and 100 GHz */ + ERROR33__THETA, /**< Elevation angle must be between 0 and 100 GHz */ + ERROR33__PERCENTAGE, /**< Percentage must be between 0 and 100 */ +}; +// clang-format on + +//////////////////////////////////////////////////////////////////////////////// +// Constants +/** Approximate value of @f$ \pi @f$ */ +constexpr double PI = 3.14159265358979323846; + +//////////////////////////////////////////////////////////////////////////////// +// Public Functions +PROPLIB_API ReturnCode AeronauticalStatisticalModel( + const double f__ghz, + const double theta__deg, + const double p, + double &L_ces__db +); +PROPLIB_API ReturnCode TerrestrialStatisticalModel( + const double f__ghz, const double d__km, const double p, double &L_ctt__db +); +PROPLIB_API ReturnCode HeightGainTerminalCorrectionModel( + const double f__ghz, + const double h__meter, + const double w_s__meter, + const double R__meter, + const ClutterType clutter_type, + double &A_h__db +); +PROPLIB_API char *GetReturnStatusCharArray(const int code); +PROPLIB_API void FreeReturnStatusCharArray(char *c_msg); + +//////////////////////////////////////////////////////////////////////////////// +// Private Functions +std::string GetReturnStatus(const int code); +double cot(const double x); +double InverseComplementaryCumulativeDistribution(const double q); +double Equation_2a(const double nu); +double Equation_2b( + const double K_h2, const double h__meter, const double R__meter +); +ReturnCode Section3p1_InputValidation( + const double f__ghz, + const double h__meter, + const double w_s__meter, + const double R__meter +); +ReturnCode Section3p2_InputValidation( + const double f__ghz, const double d__km, const double p +); +ReturnCode Section3p3_InputValidation( + const double f__ghz, const double theta__deg, const double p +); +double TerrestrialStatisticalModelHelper( + const double f__ghz, const double d__km, const double p +); + + +} // namespace P2108 +} // namespace PSeries +} // namespace ITU +} // namespace ITS diff --git a/include/PropLibTemplate.h b/include/PropLibTemplate.h deleted file mode 100644 index 4a0dbaf..0000000 --- a/include/PropLibTemplate.h +++ /dev/null @@ -1,57 +0,0 @@ -/** @file PropLibTemplate.h - * Interface header for this library - * // TODO-TEMPLATE: Rename this file to your ${LIB_NAME} - */ -#pragma once - -#include // for std::string -#include // for std::unordered_map - -// TODO-TEMPLATE: This header should provide EVERYTHING needed to interface -// with the shared library, without needing to include other headers. - -namespace ITS { -// TODO-TEMPLATE: Use your library's namespace - -// Define cross-platform PROPLIB_API to export functions -#ifndef DOXYGEN_SHOULD_SKIP - #ifndef PROPLIB_API - #ifdef _WIN32 - #define PROPLIB_API extern "C" __declspec(dllexport) - #else - #define PROPLIB_API extern "C" - #endif - #endif -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Enums - -/******************************************************************************* - * Return Codes defined by this software (0-127) - ******************************************************************************/ -// clang-format off -enum ReturnCode { - SUCCESS = 0, /**< Successful execution */ - - // TODO-TEMPLATE add return codes for this software - // TODO-TEMPLATE: Add corresponding status messages in src/ReturnCodes.cpp -}; -// clang-format on - -//////////////////////////////////////////////////////////////////////////////// -// Constants -// TODO-TEMPLATE define any global constants here (use constexpr!) - -//////////////////////////////////////////////////////////////////////////////// -// Public Functions -// TODO-TEMPLATE: Add functions which should be exported in the DLL -PROPLIB_API char *GetReturnStatusCharArray(const int code); -PROPLIB_API void FreeReturnStatusCharArray(char *c_msg); - -//////////////////////////////////////////////////////////////////////////////// -// Private Functions -// TODO-TEMPLATE: Add other/internal functions here (no need for "PROPLIB_API") -std::string GetReturnStatus(const int code); - -} // namespace ITS diff --git a/src/AeronauticalStatisticalModel.cpp b/src/AeronauticalStatisticalModel.cpp index 8a93522..930d8a0 100644 --- a/src/AeronauticalStatisticalModel.cpp +++ b/src/AeronauticalStatisticalModel.cpp @@ -1,7 +1,7 @@ /** @file AeronauticalStatisticalModel.cpp * Implements the model from ITU-R P.2108 Section 3.3. */ -#include "ITS.ITU.PSeries.P2108/P2108.h" +#include "P2108.h" #include // for std::pow, std::log, std::tan diff --git a/src/HeightGainTerminalCorrectionModel.cpp b/src/HeightGainTerminalCorrectionModel.cpp index 9e60179..09d6678 100644 --- a/src/HeightGainTerminalCorrectionModel.cpp +++ b/src/HeightGainTerminalCorrectionModel.cpp @@ -1,7 +1,7 @@ /** @file HeightGainTerminalCorrectionModel.cpp * Implements the model from ITU-R P.2108 Section 3.1. */ -#include "ITS.ITU.PSeries.P2108/P2108.h" +#include "P2108.h" #include // for std::atan, std::log10, std::pow, std::sqrt diff --git a/src/InverseComplementaryCumulativeDistribution.cpp b/src/InverseComplementaryCumulativeDistribution.cpp index 127534b..139d465 100644 --- a/src/InverseComplementaryCumulativeDistribution.cpp +++ b/src/InverseComplementaryCumulativeDistribution.cpp @@ -1,7 +1,7 @@ /** @internal @file InverseComplementaryCumulativeDistribution.cpp * @brief Implements a function to calculate the inverse CCDF. */ -#include "ITS.ITU.PSeries.P2108/P2108.h" +#include "P2108.h" #include // for std::log, std::sqrt #include // for std::out_of_range diff --git a/src/TerrestrialStatisticalModel.cpp b/src/TerrestrialStatisticalModel.cpp index e8c9d59..faa232a 100644 --- a/src/TerrestrialStatisticalModel.cpp +++ b/src/TerrestrialStatisticalModel.cpp @@ -1,7 +1,7 @@ /** @file TerrestrialStatisticalModel.cpp * Implements the model from ITU-R P.2108 Section 3.2. */ -#include "ITS.ITU.PSeries.P2108/P2108.h" +#include "P2108.h" #include // for std::fmin, std::log10, std::pow, std::sqrt diff --git a/tests/TestUtils.h b/tests/TestUtils.h index 6d973c7..21b3f4f 100644 --- a/tests/TestUtils.h +++ b/tests/TestUtils.h @@ -1,6 +1,6 @@ #pragma once -#include "ITS.ITU.PSeries.P2108/P2108.h" +#include "P2108.h" #include // for std::string #include // for std::vector