45 const auto & noiseData = std::get<0>(window);
46 const TimePoint & windowStartTime = std::get<1>(window);
48 const double & dRxSensitivityMilliWatt = std::get<3>(window);
49 const bool & bSignalInNoise{std::get<4>(window)};
53 std::size_t startIndex{};
54 std::size_t endIndex{noiseData.size()-1};
56 if(startTime < windowStartTime)
58 throw makeException<SpectrumServiceException>(
"max bin start time < window start time");
65 if(endTime != TimePoint::min())
67 if(endTime < startTime)
69 throw makeException<SpectrumServiceException>(
"max bin end time < max bin start time");
77 return maxBinNoiseFloor(noiseData,dRxSensitivityMilliWatt,dRxPowerdBm,bSignalInNoise,startIndex,endIndex);
84 const auto & noiseData = std::get<0>(window);
85 const TimePoint & windowStartTime = std::get<1>(window);
87 const double & dRxSensitivityMilliWatt = std::get<3>(window);
88 const bool & bSignalInNoise{std::get<4>(window)};
92 std::size_t startIndex{};
93 std::size_t endIndex{noiseData.size()-1};
95 if(startTime != TimePoint::min())
97 if(startTime < windowStartTime)
99 throw makeException<SpectrumServiceException>(
"max bin start time %13.6f < window start time %13.6f",
100 std::chrono::duration_cast<
DoubleSeconds>(startTime.time_since_epoch()).count(),
101 std::chrono::duration_cast<
DoubleSeconds>(windowStartTime.time_since_epoch()).count());
109 return maxBinNoiseFloor(noiseData,dRxSensitivityMilliWatt,dRxPowerdBm,bSignalInNoise,startIndex,endIndex);
113 double dRxSensitivityMilliWatt,
116 std::size_t startBin,
119 if(endBin < startBin)
121 throw makeException<SpectrumServiceException>(
"max bin end index %zu < max bin start index %zu," 127 else if(endBin >= noiseData.size() || startBin >= noiseData.size())
129 throw makeException<SpectrumServiceException>(
"bin index out of range, start index %zu," 130 " end index %zu, num bins %zu",
136 double dNoiseFloorMilliWatt{*std::max_element(&noiseData[startBin],&noiseData[endBin+1])};
143 if(dNoiseFloorMilliWatt < dRxSensitivityMilliWatt)
145 dNoiseFloorMilliWatt = dRxSensitivityMilliWatt;
156 std::chrono::duration_cast<
Microseconds>(tp.time_since_epoch()).count();
160 return count == 0 ? 0 : count / binSize.count() - (bAdjust && (count % binSize.count() == 0));
172 for(
const auto & entry : window)
174 if(fPrevious != entry || (ret.empty() && entry != 0))
176 ret.push_back(std::make_pair(i,entry));
SpectrumCompressedRepresentation spectrumCompress(const std::vector< double > &window)
double MILLIWATT_TO_DB(double dMillWatt)
std::tuple< std::vector< double >, TimePoint, Microseconds, double, bool > SpectrumWindow
std::pair< double, bool > maxBinNoiseFloorRange(const SpectrumWindow &window, double dRxPowerdBm, const TimePoint &startTime, const TimePoint &endTime=TimePoint::min())
Microseconds::rep timepointToAbsoluteBin(const TimePoint &timePoint, const Microseconds &binSize, bool bAdjust)
std::vector< std::pair< std::size_t, float > > SpectrumCompressedRepresentation
std::chrono::microseconds Microseconds
std::chrono::duration< double > DoubleSeconds
std::pair< double, bool > maxBinNoiseFloor(const SpectrumWindow &window, double dRxPowerdBm, const TimePoint &startTime=TimePoint::min())
double DB_TO_MILLIWATT(double ddB)
Clock::time_point TimePoint