Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(251)

Unified Diff: src/lr-wpan/model/lr-wpan-spectrum-value-helper.cc

Issue 194960043: Integrated 802.15.4e TSCH model
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/lr-wpan/model/lr-wpan-spectrum-value-helper.h ('k') | src/lr-wpan/model/lr-wpan-tsch-mac.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/lr-wpan/model/lr-wpan-spectrum-value-helper.cc
===================================================================
--- a/src/lr-wpan/model/lr-wpan-spectrum-value-helper.cc
+++ b/src/lr-wpan/model/lr-wpan-spectrum-value-helper.cc
@@ -16,6 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Author: Gary Pei <guangyu.pei@boeing.com>
+ * Pjotr Kourzanov <peter.kourzanov@xs4all.nl>
*/
#include "lr-wpan-spectrum-value-helper.h"
#include <ns3/log.h>
@@ -124,16 +125,49 @@
}
double
-LrWpanSpectrumValueHelper::TotalAvgPower (Ptr<const SpectrumValue> psd)
+LrWpanSpectrumValueHelper::TotalAvgPower (Ptr<const SpectrumValue> psd, uint32_t channel)
{
NS_LOG_FUNCTION (psd);
double totalAvgPower = 0.0;
+ //Only the psd relative to the current channel must be used
+ Ptr<SpectrumValue> newPsd = Create <SpectrumValue> (psd->GetSpectrumModel());
+ Ptr<SpectrumValue> oldPsd = psd->Copy();
+
+ (*newPsd)[3 + 5 * (channel - 11)] = (*oldPsd)[3 + 5 * (channel - 11)];
+ (*newPsd)[4 + 5 * (channel - 11)] = (*oldPsd)[4 + 5 * (channel - 11)];
+ (*newPsd)[5 + 5 * (channel - 11)] = (*oldPsd)[5 + 5 * (channel - 11)];
+ (*newPsd)[6 + 5 * (channel - 11)] = (*oldPsd)[6 + 5 * (channel - 11)];
+ (*newPsd)[7 + 5 * (channel - 11)] = (*oldPsd)[7 + 5 * (channel - 11)];
+
// numerically integrate to get area under psd using
// 1 MHz resolution from 2400 to 2483 MHz (center freq)
- totalAvgPower = Sum (*psd * 1.0e6);
+ totalAvgPower = Sum ((*newPsd) * 1.0e6);
+
return totalAvgPower;
}
+double
+LrWpanSpectrumValueHelper::CentralAvgPower (Ptr<const SpectrumValue> psd, uint32_t channel)
+{
+ NS_LOG_FUNCTION (psd);
+ double centralAvgPower = 0.0;
+
+ //Only the psd relative to the current channel must be used
+ Ptr<SpectrumValue> newPsd = Create <SpectrumValue> (psd->GetSpectrumModel());
+ Ptr<SpectrumValue> oldPsd = psd->Copy();
+
+ (*newPsd)[3 + 5 * (channel - 11)] = (*oldPsd)[3 + 5 * (channel - 11)];
+ (*newPsd)[4 + 5 * (channel - 11)] = (*oldPsd)[4 + 5 * (channel - 11)];
+ (*newPsd)[5 + 5 * (channel - 11)] = (*oldPsd)[5 + 5 * (channel - 11)];
+ (*newPsd)[6 + 5 * (channel - 11)] = (*oldPsd)[6 + 5 * (channel - 11)];
+ (*newPsd)[7 + 5 * (channel - 11)] = (*oldPsd)[7 + 5 * (channel - 11)];
+
+ // numerically integrate to get area under psd using
+ // 1 MHz resolution from 2400 to 2483 MHz (center freq)
+ centralAvgPower = (*newPsd)[5 + 5 * (channel - 11)]*2.0e6;
+ return centralAvgPower;
+}
+
} // namespace ns3
« no previous file with comments | « src/lr-wpan/model/lr-wpan-spectrum-value-helper.h ('k') | src/lr-wpan/model/lr-wpan-tsch-mac.h » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b