25 #include "ns3/double.h"
31 NS_LOG_COMPONENT_DEFINE(
"SatAntennaGainPattern");
38 NS_OBJECT_ENSURE_REGISTERED(SatAntennaGainPattern);
44 TypeId(
"ns3::SatAntennaGainPattern")
46 .AddConstructor<SatAntennaGainPattern>()
48 "MinAcceptableAntennaGainDb",
49 "Minimum acceptable antenna gain in dBs",
52 MakeDoubleChecker<double>());
65 m_minAcceptableAntennaGainInDb(40.0),
66 m_uniformRandomVariable(),
75 m_latDefaultSatellite(0.0),
76 m_lonDefaultSatellite(0.0),
84 : m_nanStrings(m_nanStringArray,
85 m_nanStringArray + (sizeof m_nanStringArray / sizeof m_nanStringArray[0]))
90 ObjectBase::ConstructSelf(AttributeConstructionList());
102 NS_LOG_FUNCTION(
this << filePathName);
105 std::ifstream* ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
111 filePathName =
"../../" + filePathName;
112 ifs =
new std::ifstream(filePathName.c_str(), std::ifstream::in);
116 NS_FATAL_ERROR(
"The file " << filePathName <<
" is not found.");
121 std::vector<double> rowVector;
124 double lat, lon, gainDouble;
125 std::string gainString;
126 bool firstRowDone(
false);
129 *ifs >> lat >> lon >> gainString;
134 if (lat < -90.0 || lat > 90.0 || lon < -180.0 || lon > 180.0)
136 NS_FATAL_ERROR(
"SatAntennaGainPattern::ReadAntennaPatternFromFile - unvalid latitude: "
137 << lat <<
" or longitude. " << lon);
149 gainDouble = atof(gainString.c_str());
189 if (rowVector.empty())
193 rowVector.push_back(gainDouble);
198 rowVector.push_back(gainDouble);
208 rowVector.push_back(gainDouble);
216 *ifs >> lat >> lon >> gainString;
233 Ptr<SatMobilityModel> mobility)
const
235 NS_LOG_FUNCTION(
this);
239 NS_FATAL_ERROR(
"SatAntennaGainPattern::GetSatelliteOffset - Called without initializing "
240 "satellite position first");
248 NS_LOG_DEBUG(
this <<
" Satellite offset (moved from the beginning of the simulation): "
249 << latOffset <<
" / " << lonOffset);
255 NS_LOG_FUNCTION(
this << mobility);
257 double satLatOffset, satLonOffset;
262 std::pair<double, double> lowerLeftCoord;
273 std::pair<double, double> testPos;
277 testPos.second = lowerLeftCoord.second;
293 testPos.first = lowerLeftCoord.first;
308 double latitude = lowerLeftCoord.first + latOffset - satLatOffset;
309 double longitude = lowerLeftCoord.second + lonOffset - satLonOffset;
318 TracedCallback<double> cb,
319 Ptr<SatMobilityModel> mobility)
const
333 double satLatOffset, satLonOffset;
337 double latitude = coord.
GetLatitude() + satLatOffset;
343 NS_LOG_WARN(
"Given latitude and longitude out of range!");
344 return std::numeric_limits<double>::quiet_NaN();
360 NS_LOG_WARN(
this <<
", some value(s) of the interpolated grid point(s) is/are NAN!");
361 return std::numeric_limits<double>::quiet_NaN();
382 double valLatLower = upperLonShare * G11 + lowerLonShare * G12;
385 double valLatUpper = upperLonShare * G21 + lowerLonShare * G22;
GeoCoordinate class is used to store and operate with geodetic coordinates.
double GetLatitude() const
Gets latitude value of coordinate.
double GetLongitude() const
Gets longitude value of coordinate.
void GetSatelliteOffset(double &latOffset, double &lonOffset, Ptr< SatMobilityModel > mobility) const
virtual TypeId GetInstanceTypeId(void) const
Get the type ID of instance.
SatAntennaGainPattern()
Default constructor.
double GetAntennaGain_lin(GeoCoordinate coord, Ptr< SatMobilityModel > mobility) const
Calculate the antenna gain value for a certain {latitude, longitude} point.
Ptr< UniformRandomVariable > m_uniformRandomVariable
Uniform random variable used for beam selection.
GeoCoordinate GetValidRandomPosition(Ptr< SatMobilityModel > mobility) const
Get a valid random position under this spot-beam coverage.
double m_lonInterval
Interval between longitudes, must be constant.
static const std::string m_nanStringArray[4]
Valid Not-a-Number (NaN) strings.
double m_minLon
Minimum longitude value of the antenna gain pattern.
std::vector< double > m_latitudes
All valid latitudes from the file.
double m_maxLat
Maximum latitude value of the antenna gain pattern.
double m_lonDefaultSatellite
Longitude of default satellite for antenna gain pattern.
bool IsValidPosition(GeoCoordinate coord, TracedCallback< double > cb, Ptr< SatMobilityModel > mobility) const
Check if a given position is under this spot-beam coverage.
double m_minAcceptableAntennaGainInDb
Minimum acceptable antenna gain for a serving spot-beam.
std::vector< std::string > m_nanStrings
double m_latDefaultSatellite
Latitude of default satellite for antenna gain pattern.
double m_maxLon
Minimum longitude value of the antenna gain pattern.
double m_minLat
Minimum latitude value of the antenna gain pattern.
void ReadAntennaPatternFromFile(std::string filePathName)
Read the antenna gain pattern from a file.
std::vector< std::pair< double, double > > m_validPositions
Container for valid positions.
std::vector< double > m_longitudes
All valid latitudes from the file.
std::vector< std::vector< double > > m_antennaPattern
Container for the antenna pattern from one spot-beam.
static TypeId GetTypeId(void)
Get the type ID.
double m_latInterval
Interval between latitudes, must be constant.
static T DbToLinear(T db)
Converts decibels to linear.
static T LinearToDb(T linear)
Converts linear to decibels.
SatArqSequenceNumber is handling the sequence numbers for the ARQ process.