From 7be9f348debceb341aef9042abf726cd57479785 Mon Sep 17 00:00:00 2001 From: Max Schettler Date: Wed, 19 Dec 2018 13:42:12 +0100 Subject: [PATCH] Pass additional information to the Signal Add information about emission/reception orientation/antenna to the signal. This might be relevant for some analogue models. --- src/veins/base/phyLayer/BasePhyLayer.cc | 4 +-- src/veins/base/toolbox/Signal.cc | 24 ++++++++-------- src/veins/base/toolbox/Signal.h | 28 +++++++++---------- .../analogueModel/BreakpointPathlossModel.cc | 4 +-- .../modules/analogueModel/NakagamiFading.cc | 4 +-- src/veins/modules/analogueModel/PERModel.cc | 4 +-- .../analogueModel/SimpleObstacleShadowing.cc | 4 +-- .../analogueModel/SimplePathlossModel.cc | 4 +-- .../analogueModel/TwoRayInterferenceModel.cc | 4 +-- .../analogueModel/VehicleObstacleShadowing.cc | 6 ++-- .../src/TwoRayInterferenceModel.cc | 13 ++++----- 11 files changed, 49 insertions(+), 50 deletions(-) diff --git a/src/veins/base/phyLayer/BasePhyLayer.cc b/src/veins/base/phyLayer/BasePhyLayer.cc index 919379ea1e..293a53c482 100644 --- a/src/veins/base/phyLayer/BasePhyLayer.cc +++ b/src/veins/base/phyLayer/BasePhyLayer.cc @@ -631,8 +631,8 @@ void BasePhyLayer::filterSignal(AirFrame* frame) const Coord senderOrientation = senderPOA.orientation; // add position information to signal - signal.setSenderPos(senderPosition); - signal.setReceiverPos(receiverPosition); + signal.setSenderPoa(senderPOA); + signal.setReceiverPoa({receiverPosition, receiverOrientation, antenna}); // compute gains at sender and receiver antenna double receiverGain = antenna->getGain(receiverPosition.getPositionAt(), receiverOrientation, senderPosition.getPositionAt()); diff --git a/src/veins/base/toolbox/Signal.cc b/src/veins/base/toolbox/Signal.cc index 00222366cd..22fd343124 100644 --- a/src/veins/base/toolbox/Signal.cc +++ b/src/veins/base/toolbox/Signal.cc @@ -38,8 +38,8 @@ Signal::Signal(const Signal& other) , propagationDelay(other.propagationDelay) , analogueModelList(other.analogueModelList) , numAnalogueModelsApplied(other.numAnalogueModelsApplied) - , senderPos(other.senderPos) - , receiverPos(other.receiverPos) + , senderPoa(other.senderPoa) + , receiverPoa(other.receiverPoa) { } @@ -242,24 +242,24 @@ void Signal::applyAllAnalogueModels() } } -AntennaPosition Signal::getSenderPos() const +POA Signal::getSenderPoa() const { - return senderPos; + return senderPoa; } -AntennaPosition Signal::getReceiverPos() const +POA Signal::getReceiverPoa() const { - return receiverPos; + return receiverPoa; } -void Signal::setSenderPos(AntennaPosition pos) +void Signal::setSenderPoa(const POA& poa) { - senderPos = pos; + senderPoa = poa; } -void Signal::setReceiverPos(AntennaPosition pos) +void Signal::setReceiverPoa(const POA& poa) { - receiverPos = pos; + receiverPoa = poa; } simtime_t_cref Signal::getSendingStart() const @@ -331,8 +331,8 @@ Signal& Signal::operator=(const Signal& other) analogueModelList = other.getAnalogueModelList(); numAnalogueModelsApplied = other.getNumAnalogueModelsApplied(); - senderPos = other.getSenderPos(); - receiverPos = other.getReceiverPos(); + senderPoa = other.getSenderPoa(); + receiverPoa = other.getReceiverPoa(); timingUsed = other.hasTiming(); sendingStart = other.getSendingStart(); diff --git a/src/veins/base/toolbox/Signal.h b/src/veins/base/toolbox/Signal.h index 71f4babfc0..b8b595e5ff 100644 --- a/src/veins/base/toolbox/Signal.h +++ b/src/veins/base/toolbox/Signal.h @@ -22,7 +22,7 @@ #include "veins/veins.h" -#include "veins/base/utils/AntennaPosition.h" +#include "veins/base/utils/POA.h" #include "veins/base/utils/Coord.h" #include "veins/base/toolbox/Spectrum.h" #include "veins/base/phyLayer/AnalogueModel.h" @@ -287,32 +287,32 @@ class Signal { ///@} /** - * @name Sender and receiver positions + * @name Sender and receiver POAs */ ///@{ /** - * Get this signal's sender postition. + * Get this signal's sender POA. */ - AntennaPosition getSenderPos() const; + POA getSenderPoa() const; /** - * Get this signal's receiver postition. + * Get this signal's receiver POA. */ - AntennaPosition getReceiverPos() const; + POA getReceiverPoa() const; /** - * Set this signal's sender postition. + * Set this signal's sender POA. * - * @param pos the new sender position + * @param poa the new sender POA */ - void setSenderPos(AntennaPosition pos); + void setSenderPoa(const POA& poa); /** - * Set this signal's receiver postition. + * Set this signal's receiver POA. * - * @param pos the new receiver position + * @param poa the new receiver POA */ - void setReceiverPos(AntennaPosition pos); + void setReceiverPoa(const POA& poa); ///@} /** @@ -511,8 +511,8 @@ class Signal { AnalogueModelList* analogueModelList = nullptr; uint16_t numAnalogueModelsApplied = 0; - AntennaPosition senderPos; - AntennaPosition receiverPos; + POA senderPoa; + POA receiverPoa; }; /** diff --git a/src/veins/modules/analogueModel/BreakpointPathlossModel.cc b/src/veins/modules/analogueModel/BreakpointPathlossModel.cc index 5392db4736..0237766bf9 100644 --- a/src/veins/modules/analogueModel/BreakpointPathlossModel.cc +++ b/src/veins/modules/analogueModel/BreakpointPathlossModel.cc @@ -7,8 +7,8 @@ using Veins::AirFrame; void BreakpointPathlossModel::filterSignal(Signal* signal) { - auto senderPos = signal->getSenderPos().getPositionAt(); - auto receiverPos = signal->getReceiverPos().getPositionAt(); + auto senderPos = signal->getSenderPoa().pos.getPositionAt(); + auto receiverPos = signal->getReceiverPoa().pos.getPositionAt(); /** Calculate the distance factor */ double distance = useTorus ? receiverPos.sqrTorusDist(senderPos, playgroundSize) : receiverPos.sqrdist(senderPos); diff --git a/src/veins/modules/analogueModel/NakagamiFading.cc b/src/veins/modules/analogueModel/NakagamiFading.cc index 5270782205..c5ddcd1b8e 100644 --- a/src/veins/modules/analogueModel/NakagamiFading.cc +++ b/src/veins/modules/analogueModel/NakagamiFading.cc @@ -28,8 +28,8 @@ using namespace Veins; */ void NakagamiFading::filterSignal(Signal* signal) { - auto senderPos = signal->getSenderPos().getPositionAt(); - auto receiverPos = signal->getReceiverPos().getPositionAt(); + auto senderPos = signal->getSenderPoa().pos.getPositionAt(); + auto receiverPos = signal->getReceiverPoa().pos.getPositionAt(); const double M_CLOSE = 1.5; const double M_FAR = 0.75; diff --git a/src/veins/modules/analogueModel/PERModel.cc b/src/veins/modules/analogueModel/PERModel.cc index 4529bec7a5..5f88d90218 100644 --- a/src/veins/modules/analogueModel/PERModel.cc +++ b/src/veins/modules/analogueModel/PERModel.cc @@ -7,8 +7,8 @@ using Veins::AirFrame; void PERModel::filterSignal(Signal* signal) { - auto senderPos = signal->getSenderPos().getPositionAt(); - auto receiverPos = signal->getReceiverPos().getPositionAt(); + auto senderPos = signal->getSenderPoa().pos.getPositionAt(); + auto receiverPos = signal->getReceiverPoa().pos.getPositionAt(); double attenuationFactor = 1; // no attenuation if (packetErrorRate > 0 && RNGCONTEXT uniform(0, 1) < packetErrorRate) { diff --git a/src/veins/modules/analogueModel/SimpleObstacleShadowing.cc b/src/veins/modules/analogueModel/SimpleObstacleShadowing.cc index fce10e07d8..c512fa7e88 100644 --- a/src/veins/modules/analogueModel/SimpleObstacleShadowing.cc +++ b/src/veins/modules/analogueModel/SimpleObstacleShadowing.cc @@ -35,8 +35,8 @@ SimpleObstacleShadowing::SimpleObstacleShadowing(cComponent* owner, ObstacleCont void SimpleObstacleShadowing::filterSignal(Signal* signal) { - auto senderPos = signal->getSenderPos().getPositionAt(); - auto receiverPos = signal->getReceiverPos().getPositionAt(); + auto senderPos = signal->getSenderPoa().pos.getPositionAt(); + auto receiverPos = signal->getReceiverPoa().pos.getPositionAt(); double factor = obstacleControl.calculateAttenuation(senderPos, receiverPos); diff --git a/src/veins/modules/analogueModel/SimplePathlossModel.cc b/src/veins/modules/analogueModel/SimplePathlossModel.cc index cff6b919b9..b92d32cead 100644 --- a/src/veins/modules/analogueModel/SimplePathlossModel.cc +++ b/src/veins/modules/analogueModel/SimplePathlossModel.cc @@ -8,8 +8,8 @@ using Veins::AirFrame; void SimplePathlossModel::filterSignal(Signal* signal) { - auto senderPos = signal->getSenderPos().getPositionAt(); - auto receiverPos = signal->getReceiverPos().getPositionAt(); + auto senderPos = signal->getSenderPoa().pos.getPositionAt(); + auto receiverPos = signal->getReceiverPoa().pos.getPositionAt(); /** Calculate the distance factor */ double sqrDistance = useTorus ? receiverPos.sqrTorusDist(senderPos, playgroundSize) : receiverPos.sqrdist(senderPos); diff --git a/src/veins/modules/analogueModel/TwoRayInterferenceModel.cc b/src/veins/modules/analogueModel/TwoRayInterferenceModel.cc index a2dff11531..c47bd46488 100644 --- a/src/veins/modules/analogueModel/TwoRayInterferenceModel.cc +++ b/src/veins/modules/analogueModel/TwoRayInterferenceModel.cc @@ -25,8 +25,8 @@ using namespace Veins; void TwoRayInterferenceModel::filterSignal(Signal* signal) { - auto senderPos = signal->getSenderPos().getPositionAt(); - auto receiverPos = signal->getReceiverPos().getPositionAt(); + auto senderPos = signal->getSenderPoa().pos.getPositionAt(); + auto receiverPos = signal->getReceiverPoa().pos.getPositionAt(); const Coord senderPos2D(senderPos.x, senderPos.y); const Coord receiverPos2D(receiverPos.x, receiverPos.y); diff --git a/src/veins/modules/analogueModel/VehicleObstacleShadowing.cc b/src/veins/modules/analogueModel/VehicleObstacleShadowing.cc index 74f6d24111..49908a7a83 100644 --- a/src/veins/modules/analogueModel/VehicleObstacleShadowing.cc +++ b/src/veins/modules/analogueModel/VehicleObstacleShadowing.cc @@ -33,10 +33,10 @@ VehicleObstacleShadowing::VehicleObstacleShadowing(cComponent* owner, VehicleObs void VehicleObstacleShadowing::filterSignal(Signal* signal) { - auto senderPos = signal->getSenderPos().getPositionAt(); - auto receiverPos = signal->getReceiverPos().getPositionAt(); + auto senderPos = signal->getSenderPoa().pos.getPositionAt(); + auto receiverPos = signal->getReceiverPoa().pos.getPositionAt(); - auto potentialObstacles = vehicleObstacleControl.getPotentialObstacles(signal->getSenderPos(), signal->getReceiverPos(), *signal); + auto potentialObstacles = vehicleObstacleControl.getPotentialObstacles(signal->getSenderPoa().pos, signal->getReceiverPoa().pos, *signal); if (potentialObstacles.size() < 1) return; diff --git a/subprojects/veins_catch/src/TwoRayInterferenceModel.cc b/subprojects/veins_catch/src/TwoRayInterferenceModel.cc index e8ec1701e9..296fa55f3b 100644 --- a/subprojects/veins_catch/src/TwoRayInterferenceModel.cc +++ b/subprojects/veins_catch/src/TwoRayInterferenceModel.cc @@ -18,30 +18,29 @@ SCENARIO("TwoRayInterferenceModel", "[analogueModel]") { AirFrame frame = createAirframe(2.4e9, 10e6, 0, .001, 1); - Signal& s = frame.getSignal(); TwoRayInterferenceModel tri(&dc, 1.02); int dummyId = -1; - - AntennaPosition senderPos(dummyId, Coord(0, 0, 2), Coord(0, 0, 0), simTime()); + Signal& s = frame.getSignal(); + s.setSenderPoa({{dummyId, Coord(0, 0, 2), Coord(0, 0, 0), simTime()}, {}, nullptr}); WHEN("the receiver is at (10,0)") { - AntennaPosition receiverPos(dummyId, Coord(10, 0, 2), Coord(0, 0, 0), simTime()); + s.setReceiverPoa({{dummyId, Coord(10, 0, 2), Coord(0, 0, 0), simTime()}, {}, nullptr}); THEN("TwoRayInterferenceModel drops power from 1 to 959.5e-9") { - tri.filterSignal(&s, senderPos, receiverPos); + tri.filterSignal(&s); REQUIRE(s.atFrequency(2.4e9) == Approx(9.5587819943e-07).epsilon(1e-9)); } } WHEN("the receiver is at (100,0)") { - AntennaPosition receiverPos(dummyId, Coord(100, 0, 2), Coord(0, 0, 0), simTime()); + s.setReceiverPoa({{dummyId, Coord(100, 0, 2), Coord(0, 0, 0), simTime()}, {}, nullptr}); THEN("TwoRayInterferenceModel drops power from 1 to 20.3e-9") { - tri.filterSignal(&s, senderPos, receiverPos); + tri.filterSignal(&s); REQUIRE(s.atFrequency(2.4e9) == Approx(2.0317806459e-08).epsilon(1e-9)); } }