45 localAntennaPlacement_{},
46 dLocalAntennaAzimuthDegrees_{},
47 dLocalAntennaElevationDegrees_{},
48 bHasLocalAntennaProfile_{
false}{}
52 for(
const auto & antennaProfile : antennaProfiles)
60 if(nemId_ == antennaProfile.getNEMId())
62 pLocalPattern_ = std::get<0>(ret.first);
63 pLocalBlockage_ = std::get<1>(ret.first);
64 localAntennaPlacement_ = std::get<2>(ret.first);
65 dLocalAntennaAzimuthDegrees_ = antennaProfile.getAntennaAzimuthDegrees();
66 dLocalAntennaElevationDegrees_ = antennaProfile.getAntennaElevationDegrees();
67 bHasLocalAntennaProfile_ =
true;
71 antennaProfileStore_[antennaProfile.getNEMId()] = antennaProfile;
76 throw makeException<AntennaProfileException>(
"NEM %hu: unknown antenna profile %hu",
84 std::pair<double,EMANE::GainManager::GainStatus>
87 const std::pair<double, bool> & optionalRxFixedGaindBi,
88 const std::pair<double, bool> & optionalTxFixedGaindBi)
const 90 double dRxAntennaGaindBi{optionalRxFixedGaindBi.first};
91 double dTxAntennaGaindBi{optionalTxFixedGaindBi.first};
92 double dRxAntennaBlockagedBi{};
93 double dTxAntennaBlockagedBi{};
95 double dDistanceMeters{};
101 "PHYI %03hu GainManager::%s src: %hu rx fixed gain %lf (%s) tx fixed gain %lf (%s)",
106 optionalRxFixedGaindBi.second ?
"yes" :
"no",
108 optionalTxFixedGaindBi.second ?
"yes" :
"no");
110 if(!optionalTxFixedGaindBi.second)
112 AntennaProfileStore::const_iterator remoteAntennaProfileIter;
114 if(!locationPairInfo)
119 if((remoteAntennaProfileIter = antennaProfileStore_.find(transmitterId)) == antennaProfileStore_.end())
134 antennaPlacement = std::get<2>(ret.first);
141 localAntennaPlacement_);
143 dDistanceMeters = std::get<2>(direction);
148 remoteAntennaProfileIter->second.getAntennaAzimuthDegrees(),
149 std::get<1>(direction),
150 remoteAntennaProfileIter->second.getAntennaElevationDegrees());
153 dTxAntennaGaindBi = pRemotePattern->getGain(std::round(lookupAngles.first),
154 std::round(lookupAngles.second));
160 dTxAntennaBlockagedBi = pRemoteBlockage->getGain(std::round(std::get<0>(direction)),
161 std::round(std::get<1>(direction)));
166 [
this,&antennaPlacement]()
170 strings.push_back(
"remote antenna");
173 strings.push_back(
"local antenna");
178 "PHYI %03hu GainManager::%s remote calc tx antenna gain: %lf tx antenna" 179 " blockage: %lf direction az: %lf el: %lf dist: %lf remote antenna az: %lf el: %lf" 180 " lookup bearing: %lf lookup el: %lf",
184 dTxAntennaBlockagedBi,
185 std::get<0>(direction),
186 std::get<1>(direction),
187 std::get<2>(direction),
188 remoteAntennaProfileIter->second.getAntennaAzimuthDegrees(),
189 remoteAntennaProfileIter->second.getAntennaElevationDegrees(),
191 lookupAngles.second);
200 if(!optionalRxFixedGaindBi.second)
202 if(!locationPairInfo)
207 if(!bHasLocalAntennaProfile_)
215 localAntennaPlacement_,
222 dLocalAntennaAzimuthDegrees_,
223 std::get<1>(direction),
224 dLocalAntennaElevationDegrees_);
228 pLocalPattern_->
getGain(std::round(lookupAngles.first),
229 std::round(lookupAngles.second));
235 dRxAntennaBlockagedBi =
236 pLocalBlockage_->
getGain(std::round(std::get<0>(direction)),
237 std::round(std::get<1>(direction)));
242 [
this,&antennaPlacement]()
246 strings.push_back(
"local antenna");
249 strings.push_back(
"remote antenna");
254 "PHYI %03hu GainManager::%s local calc rx antenna gain: %lf rx antenna" 255 " blockage: %lf direction az: %lf el: %lf dist: %lf local antenna az: %lf el: %lf" 256 " lookup bearing: %lf lookup el: %lf",
260 dRxAntennaBlockagedBi,
261 std::get<0>(direction),
262 std::get<1>(direction),
263 std::get<2>(direction),
264 dLocalAntennaAzimuthDegrees_,
265 dLocalAntennaElevationDegrees_,
267 lookupAngles.second);
276 if(!locationPairInfo ==
false &&
277 dDistanceMeters > 10 &&
280 remotePosition.getAltitudeMeters() +
281 antennaPlacement.getUpMeters(),
282 dDistanceMeters) ==
false)
288 double dCombinedGaindBi{dRxAntennaGaindBi + dRxAntennaBlockagedBi + dTxAntennaGaindBi + dTxAntennaBlockagedBi};
292 "PHYI %03hu GainManager::%s combined gain: %lf",
std::tuple< double, double, double > calculateDirection(const PositionOrientationVelocity &localLocationInfo, const PositionNEU &localAntennaPositionNEU, const PositionOrientationVelocity &remoteLocationInfo, const PositionNEU &remoteAntennaPositionNEU)
std::pair< double, GainStatus > determineGain(NEMId transmitterId, const LocationInfo &locationPairInfo, const std::pair< double, bool > &optionalRxFixedGaindBi, const std::pair< double, bool > &optionalTxFixedGaindBi) const
#define LOGGER_VERBOSE_LOGGING(logger, level, fmt, args...)
std::pair< double, double > calculateLookupAngles(double dAzReference, double dAzPointing, double dElReference, double dElPointing)
#define LOGGER_VERBOSE_LOGGING_FN_VARGS(logger, level, fn, fmt, args...)
double getGain(std::int16_t iBearing, std::int16_t iElevation) const
const Position & getPosition() const
std::list< std::string > Strings
const PositionOrientationVelocity & getRemotePOV() const
const PositionOrientationVelocity & getLocalPOV() const
double getUpMeters() const
void update(const Events::AntennaProfiles &antennaProfiles)
bool checkHorizon(const double dHeightMeters1, const double dHeightMeters2, const double dDistanceMeters)
static AntennaProfileManifest * instance()
std::list< AntennaProfile > AntennaProfiles
std::pair< std::tuple< AntennaPattern *, AntennaPattern *, PositionNEU >, bool > getProfileInfo(AntennaProfileId antennaProfileId) const