00001 // 00002 // This program is free software: you can redistribute it and/or modify 00003 // it under the terms of the GNU Lesser General Public License as published by 00004 // the Free Software Foundation, either version 3 of the License, or 00005 // (at your option) any later version. 00006 // 00007 // This program is distributed in the hope that it will be useful, 00008 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00009 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00010 // GNU Lesser General Public License for more details. 00011 // 00012 // You should have received a copy of the GNU Lesser General Public License 00013 // along with this program. If not, see http://www.gnu.org/licenses/. 00014 // 00015 00016 #include "LogNormalShadowing.h" 00017 00018 DimensionSet LogNormalShadowing::dimensions(Dimension::time_static()); 00019 00020 LogNormalShadowing::LogNormalShadowing(double mean, double stdDev, simtime_t interval): 00021 mean(mean), stdDev(stdDev), interval(interval) 00022 { } 00023 00024 LogNormalShadowing::~LogNormalShadowing() {} 00025 00026 double LogNormalShadowing::randomLogNormalGain() const { 00027 return FWMath::dBm2mW(-1.0 * normal(mean, stdDev)); 00028 } 00029 00030 void LogNormalShadowing::filterSignal(Signal& s) { 00031 simtime_t start = s.getSignalStart(); 00032 simtime_t end = start + s.getSignalLength(); 00033 00034 Mapping* att = MappingUtils::createMapping(dimensions, Mapping::LINEAR); 00035 00036 Argument pos; 00037 00038 for(simtime_t t = start; t <= end; t += interval) 00039 { 00040 pos.setTime(t); 00041 att->appendValue(pos, randomLogNormalGain()); 00042 } 00043 00044 s.addAttenuation(att); 00045 }