diff --git a/examples/veins/omnetpp.ini b/examples/veins/omnetpp.ini index 59b581520e..968b248bc0 100644 --- a/examples/veins/omnetpp.ini +++ b/examples/veins/omnetpp.ini @@ -5,7 +5,6 @@ cmdenv-status-frequency = 10000000s #tkenv-default-config = debug #tkenv-default-run = 1 - ned-path = . network = RSUExampleScenario diff --git a/src/veins/base/connectionManager/BaseConnectionManager.cc b/src/veins/base/connectionManager/BaseConnectionManager.cc index e8ddb33801..8695277cae 100644 --- a/src/veins/base/connectionManager/BaseConnectionManager.cc +++ b/src/veins/base/connectionManager/BaseConnectionManager.cc @@ -8,7 +8,7 @@ #include "veins/base/utils/FindModule.h" #ifndef ccEV -#define ccEV (getEnvir()->isDisabled()||!coreDebug) ? EV : EV << getName() << ": " +#define ccEV EV << getName() << ": " #endif namespace { diff --git a/src/veins/base/connectionManager/ConnectionManager.cc b/src/veins/base/connectionManager/ConnectionManager.cc index b62a2d69c2..0629525a20 100644 --- a/src/veins/base/connectionManager/ConnectionManager.cc +++ b/src/veins/base/connectionManager/ConnectionManager.cc @@ -5,7 +5,7 @@ #include "veins/base/modules/BaseWorldUtility.h" #ifndef ccEV -#define ccEV (getEnvir()->isDisabled()||!coreDebug) ? EV : EV << getName() << ": " +#define ccEV EV << getName() << ": " #endif Define_Module( ConnectionManager ); diff --git a/src/veins/base/connectionManager/NicEntryDebug.cc b/src/veins/base/connectionManager/NicEntryDebug.cc index 8429d9546d..84efd5fa25 100644 --- a/src/veins/base/connectionManager/NicEntryDebug.cc +++ b/src/veins/base/connectionManager/NicEntryDebug.cc @@ -27,7 +27,7 @@ #include "veins/base/utils/FindModule.h" #ifndef nicEV -#define nicEV (getEnvir()->isDisabled()||!coreDebug) ? EV : EV << "NicEntry: " +#define nicEV EV << "NicEntry: " #endif using std::endl; @@ -80,7 +80,7 @@ int NicEntryDebug::collectGates(const char* pattern, GateStack& gates) { cGate* hostGate = host->gate(gateName); if(hostGate->isConnectedOutside()) { - throw cException("Gate %s is still connected but not registered with this " + throw cRuntimeError("Gate %s is still connected but not registered with this " "NicEntry. Either the last NicEntry for this NIC did not " "clean up correctly or another gate creation module is " "interfering with this one!", gateName); diff --git a/src/veins/base/connectionManager/NicEntryDirect.cc b/src/veins/base/connectionManager/NicEntryDirect.cc index d0f94bfc3c..ca79cc6cca 100644 --- a/src/veins/base/connectionManager/NicEntryDirect.cc +++ b/src/veins/base/connectionManager/NicEntryDirect.cc @@ -24,7 +24,7 @@ #include "veins/base/connectionManager/ChannelAccess.h" #ifndef nicEV -#define nicEV (getEnvir()->isDisabled()||!coreDebug) ? EV : EV << "NicEntry: " +#define nicEV EV << "NicEntry: " #endif using std::endl; diff --git a/src/veins/base/modules/BaseApplLayer.h b/src/veins/base/modules/BaseApplLayer.h index cc3033149c..c969dde55b 100644 --- a/src/veins/base/modules/BaseApplLayer.h +++ b/src/veins/base/modules/BaseApplLayer.h @@ -127,14 +127,14 @@ class MIXIM_API BaseApplLayer : public BaseLayer */ virtual void handleUpperMsg(cMessage *msg) { assert(false); - throw cException("Application has no upper layers!"); + throw cRuntimeError("Application has no upper layers!"); delete msg; } /** @brief Handle control messages from upper layer */ virtual void handleUpperControl(cMessage *msg) { assert(false); - throw cException("Application has no upper layers!"); + throw cRuntimeError("Application has no upper layers!"); delete msg; } diff --git a/src/veins/base/modules/BaseLayer.cc b/src/veins/base/modules/BaseLayer.cc index 6347d1d948..e7ac128c71 100644 --- a/src/veins/base/modules/BaseLayer.cc +++ b/src/veins/base/modules/BaseLayer.cc @@ -96,14 +96,14 @@ void BaseLayer::handleMessage(cMessage* msg) * it would be wrong to forward the message to one of these gates, * as they actually don't exist, so raise an error instead. */ - throw cException("No self message and no gateID?? Check configuration."); + throw cRuntimeError("No self message and no gateID?? Check configuration."); } else { /* msg->getArrivalGateId() should be valid, but it isn't recognized * here. This could signal the case that this class is extended * with extra gates, but handleMessage() isn't overridden to * check for the new gate(s). */ - throw cException("Unknown gateID?? Check configuration or override handleMessage()."); + throw cRuntimeError("Unknown gateID?? Check configuration or override handleMessage()."); } } diff --git a/src/veins/base/modules/BaseMobility.cc b/src/veins/base/modules/BaseMobility.cc index 1d02341773..e18958e678 100644 --- a/src/veins/base/modules/BaseMobility.cc +++ b/src/veins/base/modules/BaseMobility.cc @@ -283,7 +283,7 @@ void BaseMobility::updatePosition() { //publish the the new move emit(mobilityStateChangedSignal, this); - if(getEnvir()->isGUI()) + if(hasGUI()) { std::ostringstream osDisplayTag; #ifdef __APPLE__ diff --git a/src/veins/base/modules/BaseMobility.ned b/src/veins/base/modules/BaseMobility.ned index 63fbb6ae54..a322c4bc7a 100644 --- a/src/veins/base/modules/BaseMobility.ned +++ b/src/veins/base/modules/BaseMobility.ned @@ -14,7 +14,7 @@ simple BaseMobility like IMobility double x; // x coordinate of the nodes' position (-1 = random) double y; // y coordinate of the nodes' position (-1 = random) double z; // z coordinate of the nodes' position (-1 = random) - @signal[veinsmobilityStateChanged](type="BaseMobility"); + @signal[veinsmobilityStateChanged](type="BaseMobility"); @display("i=block/cogwheel"); } diff --git a/src/veins/base/modules/BaseModule.cc b/src/veins/base/modules/BaseModule.cc index bb7cb20d94..4dfff21ea1 100644 --- a/src/veins/base/modules/BaseModule.cc +++ b/src/veins/base/modules/BaseModule.cc @@ -59,7 +59,7 @@ void BaseModule::receiveSignal(cComponent *source, simsignal_t signalID, cObject handleHostState(*pHostState); } else { - throw cException("Got catHostStateSignal but obj was not a HostState pointer?"); + throw cRuntimeError("Got catHostStateSignal but obj was not a HostState pointer?"); } } } diff --git a/src/veins/base/modules/BaseModule.h b/src/veins/base/modules/BaseModule.h index 3a41727f1a..1f4d72b3fc 100644 --- a/src/veins/base/modules/BaseModule.h +++ b/src/veins/base/modules/BaseModule.h @@ -29,13 +29,13 @@ #include "veins/base/utils/HostState.h" #ifndef debugEV -#define debugEV_clear (getEnvir()->isDisabled()||!debug) ? EV : EV -#define debugEV (getEnvir()->isDisabled()||!debug) ? EV : EV << logName() << "::" << getClassName() << ": " +#define debugEV_clear EV +#define debugEV EV << logName() << "::" << getClassName() << ": " #endif #ifndef coreEV -#define coreEV_clear (getEnvir()->isDisabled()||!coreDebug) ? EV : EV -#define coreEV (getEnvir()->isDisabled()||!coreDebug) ? EV : EV << logName() << "::" << getClassName() <<": " +#define coreEV_clear EV +#define coreEV EV << logName() << "::" << getClassName() << ": " #endif /** diff --git a/src/veins/base/modules/BaseWorldUtility.cc b/src/veins/base/modules/BaseWorldUtility.cc index 073c92be55..1de059efbd 100644 --- a/src/veins/base/modules/BaseWorldUtility.cc +++ b/src/veins/base/modules/BaseWorldUtility.cc @@ -37,7 +37,7 @@ void BaseWorldUtility::initialize(int stage) { //check if necessary modules are there //Connection Manager if(!FindModule::findGlobalModule()) { - throw cException("Could not find a connection manager module in the network!"); + throw cRuntimeError("Could not find a connection manager module in the network!"); } } } @@ -53,15 +53,15 @@ void BaseWorldUtility::initializeIfNecessary() use2DFlag ? 0. : par("playgroundSizeZ").doubleValue()); if(playgroundSize.x < 0) { - throw cException("Playground size in X direction is invalid: "\ + throw cRuntimeError("Playground size in X direction is invalid: "\ "(%f). Should be greater than or equal to zero.", playgroundSize.x); } if(playgroundSize.y < 0) { - throw cException("Playground size in Y direction is invalid: "\ + throw cRuntimeError("Playground size in Y direction is invalid: "\ "(%f). Should be greater than or equal to zero.", playgroundSize.y); } if(!use2DFlag && playgroundSize.z < 0) { - throw cException("Playground size in Z direction is invalid: "\ + throw cRuntimeError("Playground size in Z direction is invalid: "\ "(%f). Should be greater than or equal to zero.", playgroundSize.z); } diff --git a/src/veins/base/modules/BatteryAccess.cc b/src/veins/base/modules/BatteryAccess.cc index 23b9075cda..e635fea639 100644 --- a/src/veins/base/modules/BatteryAccess.cc +++ b/src/veins/base/modules/BatteryAccess.cc @@ -25,7 +25,7 @@ void BatteryAccess::registerWithBattery(const std::string& name, int numAccounts battery = FindModule::findSubModule(findHost()); if(!battery) { - throw cException("No battery module defined!"); + throw cRuntimeError("No battery module defined!"); } else { deviceID = battery->registerDevice(name, numAccounts); } diff --git a/src/veins/base/phyLayer/BaseDecider.cc b/src/veins/base/phyLayer/BaseDecider.cc index 0d637474c6..6a53ac9e7d 100644 --- a/src/veins/base/phyLayer/BaseDecider.cc +++ b/src/veins/base/phyLayer/BaseDecider.cc @@ -76,7 +76,7 @@ simtime_t BaseDecider::processSignalEnd(AirFrame* frame) { } simtime_t BaseDecider::processUnknownSignal(AirFrame* frame) { - throw cException("Unknown state for the AirFrame with ID %d", frame->getId()); + throw cRuntimeError("Unknown state for the AirFrame with ID %d", frame->getId()); return notAgain; } @@ -100,7 +100,7 @@ simtime_t BaseDecider::handleChannelSenseRequest(ChannelSenseRequest* request) { } if (currentChannelSenseRequest.first != request) { - throw cException("Got a new ChannelSenseRequest while already handling another one!"); + throw cRuntimeError("Got a new ChannelSenseRequest while already handling another one!"); return notAgain; } diff --git a/src/veins/base/phyLayer/BaseDecider.h b/src/veins/base/phyLayer/BaseDecider.h index af9d4e5c53..8fe2c465d1 100644 --- a/src/veins/base/phyLayer/BaseDecider.h +++ b/src/veins/base/phyLayer/BaseDecider.h @@ -15,7 +15,7 @@ class Mapping; using Veins::AirFrame; -#define deciderEV (getEnvir()->isDisabled()||!debug) ? EV : EV << "[Host " << myIndex << "] - PhyLayer(Decider): " +#define deciderEV EV << "[Host " << myIndex << "] - PhyLayer(Decider): " /** * @brief Provides some base functionality for most common deciders. @@ -185,7 +185,7 @@ class MIXIM_API BaseDecider: public Decider { * Default implementation does not handle signal headers. */ virtual simtime_t processSignalHeader(AirFrame* frame) { - throw cException("BaseDecider does not handle Signal headers!"); + throw cRuntimeError("BaseDecider does not handle Signal headers!"); return notAgain; } diff --git a/src/veins/base/phyLayer/BasePhyLayer.cc b/src/veins/base/phyLayer/BasePhyLayer.cc index 16fcc26a62..d04b5e66a6 100644 --- a/src/veins/base/phyLayer/BasePhyLayer.cc +++ b/src/veins/base/phyLayer/BasePhyLayer.cc @@ -1,7 +1,5 @@ #include "veins/base/phyLayer/BasePhyLayer.h" -#include - #include "veins/base/phyLayer/MacToPhyControlInfo.h" #include "veins/base/phyLayer/PhyToMacControlInfo.h" #include "veins/base/utils/FindModule.h" @@ -81,12 +79,12 @@ void BasePhyLayer::initialize(int stage) { // get pointer to the world module world = FindModule::findGlobalModule(); if (world == NULL) { - throw cException("Could not find BaseWorldUtility module"); + throw cRuntimeError("Could not find BaseWorldUtility module"); } if(cc->hasPar("sat") && (sensitivity - FWMath::dBm2mW(cc->par("sat").doubleValue())) < -0.000001) { - throw cException("Sensitivity can't be smaller than the " + throw cRuntimeError("Sensitivity can't be smaller than the " "signal attenuation threshold (sat) in ConnectionManager. " "Please adjust your omnetpp.ini file accordingly."); } @@ -146,10 +144,8 @@ void BasePhyLayer::getParametersFromXML(cXMLElement* xmlData, ParameterMap& outp const char* name = (*it)->getAttribute("name"); const char* type = (*it)->getAttribute("type"); const char* value = (*it)->getAttribute("value"); - if(name == 0 || type == 0 || value == 0) { - EV << "Invalid parameter, could not find name, type or value." << endl; - continue; - } + if(name == 0 || type == 0 || value == 0) + throw cRuntimeError("Invalid parameter, could not find name, type or value"); std::string sType = type; //needed for easier comparision std::string sValue = value; //needed for easier comparision @@ -170,8 +166,7 @@ void BasePhyLayer::getParametersFromXML(cXMLElement* xmlData, ParameterMap& outp param.setLongValue(strtol(value, 0, 0)); } else { - EV << "Unknown parameter type: \"" << sType << "\"" << endl; - continue; + throw cRuntimeError("Unknown parameter type: '%s'", sType.c_str()); } //add parameter to output map @@ -192,20 +187,17 @@ void BasePhyLayer::initializeDecider(cXMLElement* xmlConfig) { decider = 0; if(xmlConfig == 0) { - throw cException("No decider configuration file specified."); - return; + throw cRuntimeError("No decider configuration file specified."); } cXMLElementList deciderList = xmlConfig->getElementsByTagName("Decider"); if(deciderList.empty()) { - throw cException("No decider configuration found in configuration file."); - return; + throw cRuntimeError("No decider configuration found in configuration file."); } if(deciderList.size() > 1) { - throw cException("More than one decider configuration found in configuration file."); - return; + throw cRuntimeError("More than one decider configuration found in configuration file."); } cXMLElement* deciderData = deciderList.front(); @@ -213,8 +205,7 @@ void BasePhyLayer::initializeDecider(cXMLElement* xmlConfig) { const char* name = deciderData->getAttribute("type"); if(name == 0) { - throw cException("Could not read type of decider from configuration file."); - return; + throw cRuntimeError("Could not read type of decider from configuration file."); } ParameterMap params; @@ -223,8 +214,7 @@ void BasePhyLayer::initializeDecider(cXMLElement* xmlConfig) { decider = getDeciderFromName(name, params); if(decider == 0) { - throw cException("Could not find a decider with the name \"%s\".", name); - return; + throw cRuntimeError("Could not find a decider with the name \"%s\".", name); } coreEV << "Decider \"" << name << "\" loaded." << endl; @@ -252,7 +242,7 @@ void BasePhyLayer::initializeAnalogueModels(cXMLElement* xmlConfig) { if(newAnalogueModel == 0) { - throw cException("Could not find an analogue model with the name \"%s\".", s.c_str()); + throw cRuntimeError("Could not find an analogue model with the name \"%s\".", s.c_str()); } else { @@ -261,15 +251,13 @@ void BasePhyLayer::initializeAnalogueModels(cXMLElement* xmlConfig) { if(xmlConfig == 0) { - throw cException("No analogue models configuration file specified."); - return; + throw cRuntimeError("No analogue models configuration file specified."); } cXMLElementList analogueModelList = xmlConfig->getElementsByTagName("AnalogueModel"); if(analogueModelList.empty()) { - throw cException("No analogue models configuration found in configuration file."); - return; + throw cRuntimeError("No analogue models configuration found in configuration file."); } // iterate over all AnalogueModel-entries, get a new AnalogueModel instance and add @@ -283,8 +271,7 @@ void BasePhyLayer::initializeAnalogueModels(cXMLElement* xmlConfig) { const char* name = analogueModelData->getAttribute("type"); if(name == 0) { - throw cException("Could not read name of analogue model."); - continue; + throw cRuntimeError("Could not read name of analogue model."); } ParameterMap params; @@ -293,8 +280,7 @@ void BasePhyLayer::initializeAnalogueModels(cXMLElement* xmlConfig) { AnalogueModel* newAnalogueModel = getAnalogueModelFromName(name, params); if(newAnalogueModel == 0) { - throw cException("Could not find an analogue model with the name \"%s\".", name); - continue; + throw cRuntimeError("Could not find an analogue model with the name \"%s\".", name); } // attach the new AnalogueModel to the AnalogueModelList @@ -365,8 +351,7 @@ void BasePhyLayer::handleAirFrame(AirFrame* frame) { break; default: - throw cException( "Unknown AirFrame state: %s", frame->getState()); - break; + throw cRuntimeError( "Unknown AirFrame state: %s", frame->getState()); } } @@ -429,7 +414,7 @@ void BasePhyLayer::handleAirFrameReceiving(AirFrame* frame) { //invalid point in time } else if(nextHandleTime < simTime() || nextHandleTime > signalEndTime) { - throw cException("Invalid next handle time returned by Decider. Expected a value between current simulation time (%.2f) and end of signal (%.2f) but got %.2f", + throw cRuntimeError("Invalid next handle time returned by Decider. Expected a value between current simulation time (%.2f) and end of signal (%.2f) but got %.2f", SIMTIME_DBL(simTime()), SIMTIME_DBL(signalEndTime), SIMTIME_DBL(nextHandleTime)); } @@ -463,7 +448,7 @@ void BasePhyLayer::handleUpperMessage(cMessage* msg){ { delete msg; msg = 0; - throw cException("Error: message for sending received, but radio not in state TX"); + throw cRuntimeError("Error: message for sending received, but radio not in state TX"); } // check if not already sending @@ -471,7 +456,7 @@ void BasePhyLayer::handleUpperMessage(cMessage* msg){ { delete msg; msg = 0; - throw cException("Error: message for sending received, but radio already sending"); + throw cRuntimeError("Error: message for sending received, but radio already sending"); } // build the AirFrame to send @@ -551,7 +536,7 @@ void BasePhyLayer::handleChannelSenseRequest(cMessage* msg) { channelInfo.startRecording(simTime()); } } else if(nextHandleTime >= 0.0){ - throw cException("Next handle time of ChannelSenseRequest returned by the Decider is smaller then current simulation time: %.2f", + throw cRuntimeError("Next handle time of ChannelSenseRequest returned by the Decider is smaller then current simulation time: %.2f", SIMTIME_DBL(nextHandleTime)); } @@ -566,8 +551,7 @@ void BasePhyLayer::handleUpperControlMessage(cMessage* msg){ handleChannelSenseRequest(msg); break; default: - EV << "Received unknown control message from upper layer!" << endl; - break; + throw cRuntimeError("Received unknown control message from upper layer!"); } } @@ -729,7 +713,7 @@ simtime_t BasePhyLayer::setRadioState(int rs) { assert(radio); if(txOverTimer && txOverTimer->isScheduled()) { - throw cException("Switched radio while sending an AirFrame. The effects this would have on the transmission are not simulated by the BasePhyLayer!"); + EV_WARN << "Switched radio while sending an AirFrame. The effects this would have on the transmission are not simulated by the BasePhyLayer!"; } simtime_t switchTime = radio->switchTo(rs, simTime()); @@ -767,7 +751,7 @@ int BasePhyLayer::getPhyHeaderLength() { void BasePhyLayer::setCurrentRadioChannel(int newRadioChannel) { if(txOverTimer && txOverTimer->isScheduled()) { - throw cException("Switched channel while sending an AirFrame. The effects this would have on the transmission are not simulated by the BasePhyLayer!"); + EV_WARN << "Switched channel while sending an AirFrame. The effects this would have on the transmission are not simulated by the BasePhyLayer!"; } radio->setCurrentChannel(newRadioChannel); diff --git a/src/veins/base/phyLayer/BasePhyLayer.h b/src/veins/base/phyLayer/BasePhyLayer.h index d57b3aeb8f..5de13c7fea 100644 --- a/src/veins/base/phyLayer/BasePhyLayer.h +++ b/src/veins/base/phyLayer/BasePhyLayer.h @@ -15,6 +15,7 @@ class AnalogueModel; class Decider; class BaseWorldUtility; +//class omnetpp::cXMLElement; using Veins::AirFrame; using Veins::ChannelAccess; diff --git a/src/veins/base/utils/FindModule.h b/src/veins/base/utils/FindModule.h index 78722eef33..92c564a744 100644 --- a/src/veins/base/utils/FindModule.h +++ b/src/veins/base/utils/FindModule.h @@ -1,8 +1,7 @@ #ifndef FIND_MODULE_H #define FIND_MODULE_H -#include -using namespace omnetpp; +#include "veins/base/utils/MiXiMDefs.h" /** * @brief Provides method templates to find omnet modules. @@ -23,7 +22,7 @@ class FindModule static T findSubModule(const cModule *const top) { for (cModule::SubmoduleIterator i(top); !i.end(); i++) { - cModule *const sub = *i; + cModule *const sub = i(); // this allows also a return type of read only pointer: const cModule *const T dCastRet = dynamic_cast(sub); if (dCastRet != NULL) diff --git a/src/veins/base/utils/MiXiMDefs.h b/src/veins/base/utils/MiXiMDefs.h index f8fd937bc2..38a65268e4 100644 --- a/src/veins/base/utils/MiXiMDefs.h +++ b/src/veins/base/utils/MiXiMDefs.h @@ -19,8 +19,55 @@ #define __MIXIM_MIXIMDEFS_H #include + +namespace omnetpp { } +using namespace omnetpp; + #include "veins/base/utils/miximkerneldefs.h" +// OMNeT 5 compatibility +// Around OMNeT++ 5.0 beta 2, the "ev" and "simulation" macros were eliminated, and replaced +// by the functions/methods getEnvir() and getSimulation(), the INET codebase updated. +// The following lines let the code compile with earlier OMNeT++ versions as well. +#ifdef ev +inline cEnvir *getEnvir() {return cSimulation::getActiveEnvir();} +inline cSimulation *getSimulation() {return cSimulation::getActiveSimulation();} +inline bool hasGUI() {return cSimulation::getActiveEnvir()->isGUI();} +#endif //ev + +// new OMNeT++ 5 logging macros +#if OMNETPP_VERSION < 0x500 +# define EV_FATAL EV << "FATAL: " +# define EV_ERROR EV << "ERROR: " +# define EV_WARN EV << "WARN: " +# define EV_INFO EV +# define EV_DETAIL EV << "DETAIL: " +# define EV_DEBUG EV << "DEBUG: " +# define EV_TRACE EV << "TRACE: " +# define EV_FATAL_C(category) EV << "[" << category << "] FATAL: " +# define EV_ERROR_C(category) EV << "[" << category << "] ERROR: " +# define EV_WARN_C(category) EV << "[" << category << "] WARN: " +# define EV_INFO_C(category) EV << "[" << category << "] " +# define EV_DETAIL_C(category) EV << "[" << category << "] DETAIL: " +# define EV_DEBUG_C(category) EV << "[" << category << "] DEBUG: " +# define EV_TRACE_C(category) EV << "[" << category << "] TRACE: " +# define EV_STATICCONTEXT /* Empty */ +#endif // OMNETPP_VERSION < 0x500 + +// Around OMNeT++ 5.0 beta 2, random variate generation functions like exponential() became +// members of cComponent. By prefixing calls with the following macro you can make the code +// compile with earlier OMNeT++ versions as well. +#if OMNETPP_BUILDNUM >= 1002 +#define RNGCONTEXT (cSimulation::getActiveSimulation()->getContext())-> +#else +#define RNGCONTEXT +#endif + +// Around OMNeT++ 5.0 beta 3, MAXTIME was renamed to SIMTIME_MAX +#if OMNETPP_BUILDNUM < 1005 +#define SIMTIME_MAX MAXTIME +#endif + #if defined(MIXIM_EXPORT) # define MIXIM_API OPP_DLLEXPORT #elif defined(MIXIM_IMPORT) @@ -29,8 +76,6 @@ # define MIXIM_API #endif -using namespace omnetpp; - /** * @brief Helper function to initialize signal change identifier on use and * not on initializing static sections. @@ -59,8 +104,7 @@ class MIXIM_API simsignalwrap_t { ASSERT(sSignalName); sRunId = getRunId(); ssChangeSignal = cComponent::registerSignal(sSignalName); - - // opp_warning("%d = cComponent::registerSignal(\"%s\")", ssChangeSignal, sSignalName); + // throw cRuntimeError("%d = cComponent::registerSignal(\"%s\")", ssChangeSignal, sSignalName); } return ssChangeSignal; } diff --git a/src/veins/base/utils/PassedMessage.h b/src/veins/base/utils/PassedMessage.h index 45ddeff592..c40ac6e2fb 100644 --- a/src/veins/base/utils/PassedMessage.h +++ b/src/veins/base/utils/PassedMessage.h @@ -30,7 +30,7 @@ class MIXIM_API PassedMessage : public cObject { case LOWER_DATA: s = "LOWER_DATA"; break; case LOWER_CONTROL: s = "LOWER_CONTROL"; break; default: - throw cException("PassedMessage::gateToString: got invalid value"); + throw cRuntimeError("PassedMessage::gateToString: got invalid value"); s = 0; break; } diff --git a/src/veins/modules/analogueModel/BreakpointPathlossModel.cc b/src/veins/modules/analogueModel/BreakpointPathlossModel.cc index d72618daa0..546112b3d4 100644 --- a/src/veins/modules/analogueModel/BreakpointPathlossModel.cc +++ b/src/veins/modules/analogueModel/BreakpointPathlossModel.cc @@ -4,7 +4,7 @@ using Veins::AirFrame; -#define debugEV (getEnvir()->isDisabled()||!debug) ? EV : EV << "PhyLayer(BreakpointPathlossModel): " +#define debugEV EV << "PhyLayer(BreakpointPathlossModel): " void BreakpointPathlossModel::filterSignal(AirFrame *frame, const Coord& sendersPos, const Coord& receiverPos) { diff --git a/src/veins/modules/analogueModel/JakesFading.cc b/src/veins/modules/analogueModel/JakesFading.cc index 67eaa7bd00..8d0c4e7784 100644 --- a/src/veins/modules/analogueModel/JakesFading.cc +++ b/src/veins/modules/analogueModel/JakesFading.cc @@ -75,8 +75,8 @@ JakesFading::JakesFading(int fadingPaths, simtime_t_cref delayRMS, delay = new simtime_t[fadingPaths]; for (int i = 0; i < fadingPaths; i++) { - angleOfArrival[i] = cos(uniform(getEnvir()->getRNG(0), 0, M_PI)); - delay[i] = exponential(getEnvir()->getRNG(0), delayRMS.dbl()); + angleOfArrival[i] = cos(RNGCONTEXT uniform(0, M_PI)); + delay[i] = (RNGCONTEXT exponential(delayRMS)); } } diff --git a/src/veins/modules/analogueModel/LogNormalShadowing.cc b/src/veins/modules/analogueModel/LogNormalShadowing.cc index aa203df201..a8158235d9 100644 --- a/src/veins/modules/analogueModel/LogNormalShadowing.cc +++ b/src/veins/modules/analogueModel/LogNormalShadowing.cc @@ -27,7 +27,7 @@ LogNormalShadowing::LogNormalShadowing(double mean, double stdDev, simtime_t_cre LogNormalShadowing::~LogNormalShadowing() {} double LogNormalShadowing::randomLogNormalGain() const { - return FWMath::dBm2mW(-1.0 * normal(getEnvir()->getRNG(0), mean, stdDev)); + return FWMath::dBm2mW(-1.0 * (RNGCONTEXT normal(mean, stdDev))); } void LogNormalShadowing::filterSignal(AirFrame *frame, const Coord& sendersPos, const Coord& receiverPos) { diff --git a/src/veins/modules/analogueModel/PERModel.cc b/src/veins/modules/analogueModel/PERModel.cc index 3df4f1275e..a0026ef8f4 100644 --- a/src/veins/modules/analogueModel/PERModel.cc +++ b/src/veins/modules/analogueModel/PERModel.cc @@ -10,7 +10,7 @@ void PERModel::filterSignal(AirFrame *frame, const Coord& sendersPos, const Coor //simtime_t end = signal.getReceptionEnd(); double attenuationFactor = 1; // no attenuation - if(packetErrorRate > 0 && uniform(getEnvir()->getRNG(0), 0, 1) < packetErrorRate) { + if(packetErrorRate > 0 && RNGCONTEXT uniform(0, 1) < packetErrorRate) { attenuationFactor = 0; // absorb all energy so that the receveir cannot receive anything } diff --git a/src/veins/modules/analogueModel/SimpleObstacleShadowing.cc b/src/veins/modules/analogueModel/SimpleObstacleShadowing.cc index 2fa61b95db..aa2d6d61e1 100644 --- a/src/veins/modules/analogueModel/SimpleObstacleShadowing.cc +++ b/src/veins/modules/analogueModel/SimpleObstacleShadowing.cc @@ -2,7 +2,7 @@ using Veins::AirFrame; -#define debugEV (getEnvir()->isDisabled()||!debug) ? EV : EV << "PhyLayer(SimpleObstacleShadowing): " +#define debugEV EV << "PhyLayer(SimpleObstacleShadowing): " #if 0 SimplePathlossConstMapping::SimplePathlossConstMapping(const DimensionSet& dimensions, @@ -35,7 +35,7 @@ SimpleObstacleShadowing::SimpleObstacleShadowing(ObstacleControl& obstacleContro playgroundSize(playgroundSize), debug(debug) { - if (useTorus) throw cException("SimpleObstacleShadowing does not work on torus-shaped playgrounds"); + if (useTorus) throw cRuntimeError("SimpleObstacleShadowing does not work on torus-shaped playgrounds"); } diff --git a/src/veins/modules/analogueModel/SimplePathlossModel.cc b/src/veins/modules/analogueModel/SimplePathlossModel.cc index 37a5d51249..30ba5511b5 100644 --- a/src/veins/modules/analogueModel/SimplePathlossModel.cc +++ b/src/veins/modules/analogueModel/SimplePathlossModel.cc @@ -4,7 +4,7 @@ using Veins::AirFrame; -#define splmEV (getEnvir()->isDisabled()||!debug) ? EV : EV << "PhyLayer(SimplePathlossModel): " +#define splmEV EV << "PhyLayer(SimplePathlossModel): " SimplePathlossConstMapping::SimplePathlossConstMapping(const DimensionSet& dimensions, SimplePathlossModel* model, diff --git a/src/veins/modules/analogueModel/TwoRayInterferenceModel.cc b/src/veins/modules/analogueModel/TwoRayInterferenceModel.cc index 60f20f6ffb..cbb76c7667 100644 --- a/src/veins/modules/analogueModel/TwoRayInterferenceModel.cc +++ b/src/veins/modules/analogueModel/TwoRayInterferenceModel.cc @@ -23,7 +23,7 @@ using Veins::AirFrame; -#define debugEV (getEnvir()->isDisabled()||!debug) ? EV : EV << "PhyLayer(TwoRayInterferenceModel): " +#define debugEV EV << "PhyLayer(TwoRayInterferenceModel): " void TwoRayInterferenceModel::filterSignal(AirFrame *frame, const Coord& senderPos, const Coord& receiverPos) { Signal& s = frame->getSignal(); diff --git a/src/veins/modules/mac/ieee80211p/Mac1609_4.cc b/src/veins/modules/mac/ieee80211p/Mac1609_4.cc index f18a849bd9..480b64f2e6 100755 --- a/src/veins/modules/mac/ieee80211p/Mac1609_4.cc +++ b/src/veins/modules/mac/ieee80211p/Mac1609_4.cc @@ -25,6 +25,12 @@ #include "veins/base/phyLayer/PhyToMacControlInfo.h" #include "veins/modules/messages/PhyControlMessage_m.h" +#if OMNETPP_VERSION >= 0x500 +#define OWNER owner-> +#else +#define OWNER +#endif + #define DBG_MAC EV //#define DBG_MAC std::cerr << "[" << simTime().raw() << "] " << myId << " " @@ -63,7 +69,7 @@ void Mac1609_4::initialize(int stage) { //create two edca systems - myEDCA[type_CCH] = new EDCA(type_CCH,this,par("queueSize").longValue()); + myEDCA[type_CCH] = new EDCA(this, type_CCH,par("queueSize").longValue()); myEDCA[type_CCH]->myId = myId; myEDCA[type_CCH]->myId.append(" CCH"); @@ -72,7 +78,7 @@ void Mac1609_4::initialize(int stage) { myEDCA[type_CCH]->createQueue(6,CWMIN_11P,CWMAX_11P,AC_BE); myEDCA[type_CCH]->createQueue(9,CWMIN_11P,CWMAX_11P,AC_BK); - myEDCA[type_SCH] = new EDCA(type_SCH,this,par("queueSize").longValue()); + myEDCA[type_SCH] = new EDCA(this, type_SCH,par("queueSize").longValue()); myEDCA[type_SCH]->myId = myId; myEDCA[type_SCH]->myId.append(" SCH"); myEDCA[type_SCH]->createQueue(2,(((CWMIN_11P+1)/4)-1),(((CWMIN_11P +1)/2)-1),AC_VO); @@ -88,7 +94,7 @@ void Mac1609_4::initialize(int stage) { case 2: mySCH = Channels::SCH2; break; case 3: mySCH = Channels::SCH3; break; case 4: mySCH = Channels::SCH4; break; - default: throw new cException("Service Channel must be between 1 and 4"); break; + default: throw cRuntimeError("Service Channel must be between 1 and 4"); break; } } @@ -328,7 +334,7 @@ void Mac1609_4::handleLowerControl(cMessage* msg) { //don't set the chan to idle. the PHY layer decides, not us. if (guardActive()) { - throw new cException("We shouldnt have sent a packet in guard!"); + throw cRuntimeError("We shouldnt have sent a packet in guard!"); } } else if (msg->getKind() == Mac80211pToPhy11pInterface::CHANNEL_BUSY) { @@ -469,7 +475,7 @@ simtime_t Mac1609_4::timeLeftInSlot() const { void Mac1609_4::changeServiceChannel(int cN) { ASSERT(useSCH); if (cN != Channels::SCH1 && cN != Channels::SCH2 && cN != Channels::SCH3 && cN != Channels::SCH4) { - throw new cException("This Service Channel doesnt exit: %d",cN); + throw cRuntimeError("This Service Channel doesnt exit: %d",cN); } mySCH = cN; @@ -542,7 +548,7 @@ int Mac1609_4::EDCA::queuePacket(t_access_category ac,WaveShortMessage* msg) { int Mac1609_4::EDCA::createQueue(int aifsn, int cwMin, int cwMax,t_access_category ac) { if (myQueues.find(ac) != myQueues.end()) { - throw new cException("You can only add one queue per Access Category per EDCA subsystem"); + throw cRuntimeError("You can only add one queue per Access Category per EDCA subsystem"); } EDCAQueue newQueue(aifsn,cwMin,cwMax,ac); @@ -558,13 +564,12 @@ Mac1609_4::t_access_category Mac1609_4::mapPriority(int prio) { case 1: return AC_BE; case 2: return AC_VI; case 3: return AC_VO; - default: throw new cException("MacLayer received a packet with unknown priority"); break; + default: throw cRuntimeError("MacLayer received a packet with unknown priority"); break; } return AC_VO; } WaveShortMessage* Mac1609_4::EDCA::initiateTransmit(simtime_t lastIdle) { - EV_STATICCONTEXT //iterate through the queues to return the packet we want to send WaveShortMessage* pktToSend = NULL; @@ -589,7 +594,7 @@ WaveShortMessage* Mac1609_4::EDCA::initiateTransmit(simtime_t lastIdle) { statsNumInternalContention++; iter->second.cwCur = std::min(iter->second.cwMax,iter->second.cwCur*2); - iter->second.currentBackoff = myMac->intuniform(0,iter->second.cwCur); + iter->second.currentBackoff = OWNER intuniform(0,iter->second.cwCur); DBG_MAC << "Internal contention for queue " << iter->first << " : "<< iter->second.currentBackoff << ". Increase cwCur to " << iter->second.cwCur << std::endl; } } @@ -597,13 +602,12 @@ WaveShortMessage* Mac1609_4::EDCA::initiateTransmit(simtime_t lastIdle) { } if (pktToSend == NULL) { - throw new cException("No packet was ready"); + throw cRuntimeError("No packet was ready"); } return pktToSend; } simtime_t Mac1609_4::EDCA::startContent(simtime_t idleSince,bool guardActive) { - EV_STATICCONTEXT DBG_MAC << "Restarting contention." << std::endl; @@ -624,7 +628,7 @@ simtime_t Mac1609_4::EDCA::startContent(simtime_t idleSince,bool guardActive) { if (guardActive == true && iter->second.currentBackoff == 0) { //cw is not increased - iter->second.currentBackoff = myMac->intuniform(0,iter->second.cwCur); + iter->second.currentBackoff = OWNER intuniform(0,iter->second.cwCur); statsNumBackoff++; } @@ -654,7 +658,6 @@ simtime_t Mac1609_4::EDCA::startContent(simtime_t idleSince,bool guardActive) { } void Mac1609_4::EDCA::stopContent(bool allowBackoff, bool generateTxOp) { - EV_STATICCONTEXT //update all Queues DBG_MAC << "Stopping Contention at " << simTime().raw() << std::endl; @@ -709,20 +712,18 @@ void Mac1609_4::EDCA::stopContent(bool allowBackoff, bool generateTxOp) { } } void Mac1609_4::EDCA::backoff(t_access_category ac) { - EV_STATICCONTEXT - myQueues[ac].currentBackoff = myMac->intuniform(0,myQueues[ac].cwCur); + myQueues[ac].currentBackoff = OWNER intuniform(0,myQueues[ac].cwCur); statsSlotsBackoff += myQueues[ac].currentBackoff; statsNumBackoff++; DBG_MAC << "Going into Backoff because channel was busy when new packet arrived from upperLayer" << std::endl; } void Mac1609_4::EDCA::postTransmit(t_access_category ac) { - EV_STATICCONTEXT delete myQueues[ac].queue.front(); myQueues[ac].queue.pop(); myQueues[ac].cwCur = myQueues[ac].cwMin; //post transmit backoff - myQueues[ac].currentBackoff = myMac->intuniform(0,myQueues[ac].cwCur); + myQueues[ac].currentBackoff = OWNER intuniform(0,myQueues[ac].cwCur); statsSlotsBackoff += myQueues[ac].currentBackoff; statsNumBackoff++; DBG_MAC << "Queue " << ac << " will go into post-transmit backoff for " << myQueues[ac].currentBackoff << " slots" << std::endl; @@ -799,7 +800,7 @@ void Mac1609_4::channelIdle(bool afterSwitch) { //this rare case can happen when another node's time has such a big offset that the node sent a packet although we already changed the channel //the workaround is not trivial and requires a lot of changes to the phy and decider return; - //throw new cException("channel turned idle but contention timer was scheduled!"); + //throw cRuntimeError("channel turned idle but contention timer was scheduled!"); } idleChannel = true; @@ -846,7 +847,7 @@ void Mac1609_4::setParametersForBitrate(uint64_t bitrate) { return; } } - throw new cException("Chosen Bitrate is not valid for 802.11p: Valid rates are: 3Mbps, 4.5Mbps, 6Mbps, 9Mbps, 12Mbps, 18Mbps, 24Mbps and 27Mbps. Please adjust your omnetpp.ini file accordingly."); + throw cRuntimeError("Chosen Bitrate is not valid for 802.11p: Valid rates are: 3Mbps, 4.5Mbps, 6Mbps, 9Mbps, 12Mbps, 18Mbps, 24Mbps and 27Mbps. Please adjust your omnetpp.ini file accordingly."); } @@ -863,4 +864,3 @@ simtime_t Mac1609_4::getFrameDuration(int payloadLengthBits, enum PHY_MCS mcs) c return duration; } - diff --git a/src/veins/modules/mac/ieee80211p/Mac1609_4.h b/src/veins/modules/mac/ieee80211p/Mac1609_4.h index 6ed4a8baac..2eafc91809 100755 --- a/src/veins/modules/mac/ieee80211p/Mac1609_4.h +++ b/src/veins/modules/mac/ieee80211p/Mac1609_4.h @@ -37,8 +37,6 @@ #include "veins/modules/utility/ConstsPhy.h" -class Mac1609_4; - /** * @brief * Manages timeslots for CCH and SCH listening and sending. @@ -86,11 +84,13 @@ class Mac1609_4 : public BaseMacLayer, }; }; - EDCA(t_channel channelType,Mac1609_4* my_mac,int maxQueueLength = 0): numQueues(0),maxQueueSize(maxQueueLength),channelType(channelType),myMac(my_mac) { + EDCA(cModule *owner, t_channel channelType,int maxQueueLength = 0):owner(owner),numQueues(0),maxQueueSize(maxQueueLength),channelType(channelType) { statsNumInternalContention = 0; statsNumBackoff = 0; statsSlotsBackoff = 0; }; + const cObject *getThisPtr() const {return NULL;} + const char *getClassName() const {return "Mac1609_4::EDCA"; } /* * Currently you have to call createQueue in the right order. First Call is priority 0, second 1 and so on... */ @@ -108,6 +108,7 @@ class Mac1609_4 : public BaseMacLayer, WaveShortMessage* initiateTransmit(simtime_t idleSince); public: + cModule *owner; std::map myQueues; int numQueues; uint32_t maxQueueSize; @@ -121,7 +122,6 @@ class Mac1609_4 : public BaseMacLayer, /** @brief Id for debug messages */ std::string myId; - Mac1609_4* myMac; }; public: diff --git a/src/veins/modules/mobility/traci/TraCIBuffer.h b/src/veins/modules/mobility/traci/TraCIBuffer.h index f3aa825bfe..e8c836e05d 100644 --- a/src/veins/modules/mobility/traci/TraCIBuffer.h +++ b/src/veins/modules/mobility/traci/TraCIBuffer.h @@ -4,7 +4,7 @@ #include #include -#include +#include "veins/base/utils/MiXiMDefs.h" namespace Veins { @@ -26,12 +26,12 @@ class TraCIBuffer { if (isBigEndian()) { for (size_t i=0; i +#include "veins/base/utils/MiXiMDefs.h" namespace Veins { diff --git a/src/veins/modules/mobility/traci/TraCIConnection.cc b/src/veins/modules/mobility/traci/TraCIConnection.cc index 7e3395e281..95524bf6b9 100644 --- a/src/veins/modules/mobility/traci/TraCIConnection.cc +++ b/src/veins/modules/mobility/traci/TraCIConnection.cc @@ -8,8 +8,6 @@ #include #endif -#include -#include #include #include @@ -50,7 +48,7 @@ TraCIConnection::~TraCIConnection() { TraCIConnection* TraCIConnection::connect(const char* host, int port) { MYDEBUG << "TraCIScenarioManager connecting to TraCI server" << endl; - if (initsocketlibonce() != 0) throw cException("Could not init socketlib"); + if (initsocketlibonce() != 0) throw cRuntimeError("Could not init socketlib"); in_addr addr; struct hostent* host_ent; @@ -62,7 +60,7 @@ TraCIConnection* TraCIConnection::connect(const char* host, int port) { } else if ((host_ent = gethostbyname(host))) { addr = *((struct in_addr*) host_ent->h_addr_list[0]); } else { - throw cException("Invalid TraCI server address: %s", host); + throw cRuntimeError("Invalid TraCI server address: %s", host); return 0; } @@ -74,10 +72,10 @@ TraCIConnection* TraCIConnection::connect(const char* host, int port) { SOCKET* socketPtr = new SOCKET(); *socketPtr = ::socket(AF_INET, SOCK_STREAM, 0); - if (*socketPtr < 0) throw cException("Could not create socket to connect to TraCI server"); + if (*socketPtr < 0) throw cRuntimeError("Could not create socket to connect to TraCI server"); if (::connect(*socketPtr, (sockaddr const*) &address, sizeof(address)) < 0) { - throw cException("Could not connect to TraCI server. Make sure it is running and not behind a firewall. Error message: %d: %s", sock_errno(), strerror(sock_errno())); + throw cRuntimeError("Could not connect to TraCI server. Make sure it is running and not behind a firewall. Error message: %d: %s", sock_errno(), strerror(sock_errno())); } { @@ -97,8 +95,8 @@ TraCIBuffer TraCIConnection::query(uint8_t commandId, const TraCIBuffer& buf) { ASSERT(commandResp == commandId); uint8_t result; obuf >> result; std::string description; obuf >> description; - if (result == RTYPE_NOTIMPLEMENTED) throw cException("TraCI server reported command 0x%2x not implemented (\"%s\"). Might need newer version.", commandId, description.c_str()); - if (result == RTYPE_ERR) throw cException("TraCI server reported error executing command 0x%2x (\"%s\").", commandId, description.c_str()); + if (result == RTYPE_NOTIMPLEMENTED) throw cRuntimeError("TraCI server reported command 0x%2x not implemented (\"%s\"). Might need newer version.", commandId, description.c_str()); + if (result == RTYPE_ERR) throw cRuntimeError("TraCI server reported error executing command 0x%2x (\"%s\").", commandId, description.c_str()); ASSERT(result == RTYPE_OK); return obuf; } @@ -118,7 +116,7 @@ TraCIBuffer TraCIConnection::queryOptional(uint8_t commandId, const TraCIBuffer& } std::string TraCIConnection::receiveMessage() { - if (!socketPtr) throw cException("Not connected to TraCI server"); + if (!socketPtr) throw cRuntimeError("Not connected to TraCI server"); uint32_t msgLength; { @@ -129,11 +127,11 @@ std::string TraCIConnection::receiveMessage() { if (receivedBytes > 0) { bytesRead += receivedBytes; } else if (receivedBytes == 0) { - throw cException("Connection to TraCI server closed unexpectedly. Check your server's log"); + throw cRuntimeError("Connection to TraCI server closed unexpectedly. Check your server's log"); } else { if (sock_errno() == EINTR) continue; if (sock_errno() == EAGAIN) continue; - throw cException("Connection to TraCI server lost. Check your server's log. Error message: %d: %s", sock_errno(), strerror(sock_errno())); + throw cRuntimeError("Connection to TraCI server lost. Check your server's log. Error message: %d: %s", sock_errno(), strerror(sock_errno())); } } TraCIBuffer(std::string(buf2, sizeof(uint32_t))) >> msgLength; @@ -149,11 +147,11 @@ std::string TraCIConnection::receiveMessage() { if (receivedBytes > 0) { bytesRead += receivedBytes; } else if (receivedBytes == 0) { - throw cException("Connection to TraCI server closed unexpectedly. Check your server's log"); + throw cRuntimeError("Connection to TraCI server closed unexpectedly. Check your server's log"); } else { if (sock_errno() == EINTR) continue; if (sock_errno() == EAGAIN) continue; - throw cException("Connection to TraCI server lost. Check your server's log. Error message: %d: %s", sock_errno(), strerror(sock_errno())); + throw cRuntimeError("Connection to TraCI server lost. Check your server's log. Error message: %d: %s", sock_errno(), strerror(sock_errno())); } } } @@ -161,7 +159,7 @@ std::string TraCIConnection::receiveMessage() { } void TraCIConnection::sendMessage(std::string buf) { - if (!socketPtr) throw cException("Not connected to TraCI server"); + if (!socketPtr) throw cRuntimeError("Not connected to TraCI server"); { uint32_t msgLength = sizeof(uint32_t) + buf.length(); @@ -175,7 +173,7 @@ void TraCIConnection::sendMessage(std::string buf) { } else { if (sock_errno() == EINTR) continue; if (sock_errno() == EAGAIN) continue; - throw cException("Connection to TraCI server lost. Check your server's log. Error message: %d: %s", sock_errno(), strerror(sock_errno())); + throw cRuntimeError("Connection to TraCI server lost. Check your server's log. Error message: %d: %s", sock_errno(), strerror(sock_errno())); } } } @@ -190,7 +188,7 @@ void TraCIConnection::sendMessage(std::string buf) { } else { if (sock_errno() == EINTR) continue; if (sock_errno() == EAGAIN) continue; - throw cException("Connection to TraCI server lost. Check your server's log. Error message: %d: %s", sock_errno(), strerror(sock_errno())); + throw cRuntimeError("Connection to TraCI server lost. Check your server's log. Error message: %d: %s", sock_errno(), strerror(sock_errno())); } } } diff --git a/src/veins/modules/mobility/traci/TraCIMobility.cc b/src/veins/modules/mobility/traci/TraCIMobility.cc index d0146af420..ee918f1558 100644 --- a/src/veins/modules/mobility/traci/TraCIMobility.cc +++ b/src/veins/modules/mobility/traci/TraCIMobility.cc @@ -227,7 +227,7 @@ void TraCIMobility::changePosition() move.setStart(Coord(nextPos.x, nextPos.y, move.getCurrentPosition().z)); // keep z position move.setDirectionByVector(Coord(cos(angle), -sin(angle))); move.setSpeed(speed); - if (getEnvir()->isGUI()) updateDisplayString(); + if (hasGUI()) updateDisplayString(); fixIfHostGetsOutside(); updatePosition(); } diff --git a/src/veins/modules/mobility/traci/TraCIScenarioManager.cc b/src/veins/modules/mobility/traci/TraCIScenarioManager.cc index e6f230827e..3197069cea 100644 --- a/src/veins/modules/mobility/traci/TraCIScenarioManager.cc +++ b/src/veins/modules/mobility/traci/TraCIScenarioManager.cc @@ -432,7 +432,7 @@ void TraCIScenarioManager::addModule(std::string nodeId, std::string type, std:: // pre-initialize TraCIMobility for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) { - cModule* submod = *iter; + cModule* submod = iter(); ifInetTraCIMobilityCallPreInitialize(submod, nodeId, position, road_id, speed, angle); TraCIMobility* mm = dynamic_cast(submod); if (!mm) continue; @@ -444,7 +444,7 @@ void TraCIScenarioManager::addModule(std::string nodeId, std::string type, std:: // post-initialize TraCIMobility for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) { - cModule* submod = *iter; + cModule* submod = iter(); TraCIMobility* mm = dynamic_cast(submod); if (!mm) continue; mm->changePosition(); @@ -686,7 +686,7 @@ void TraCIScenarioManager::processSimSubscription(std::string objectId, TraCIBuf cModule* mod = getManagedModule(idstring); for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) { - cModule* submod = *iter; + cModule* submod = iter(); TraCIMobility* mm = dynamic_cast(submod); if (!mm) continue; mm->changeParkingState(true); @@ -706,7 +706,7 @@ void TraCIScenarioManager::processSimSubscription(std::string objectId, TraCIBuf cModule* mod = getManagedModule(idstring); for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) { - cModule* submod = *iter; + cModule* submod = iter(); TraCIMobility* mm = dynamic_cast(submod); if (!mm) continue; mm->changeParkingState(false); @@ -883,7 +883,7 @@ void TraCIScenarioManager::processVehicleSubscription(std::string objectId, TraC } else { // module existed - update position for (cModule::SubmoduleIterator iter(mod); !iter.end(); iter++) { - cModule* submod = *iter; + cModule* submod = iter(); ifInetTraCIMobilityCallNextPosition(submod, p, edge, speed, angle); TraCIMobility* mm = dynamic_cast(submod); if (!mm) continue; diff --git a/src/veins/modules/mobility/traci/TraCIScreenRecorder.h b/src/veins/modules/mobility/traci/TraCIScreenRecorder.h index 665638777f..5c7ad248c3 100644 --- a/src/veins/modules/mobility/traci/TraCIScreenRecorder.h +++ b/src/veins/modules/mobility/traci/TraCIScreenRecorder.h @@ -21,8 +21,7 @@ #ifndef WORLD_TRACI_TRACISCREENRECORDER_H #define WORLD_TRACI_TRACISCREENRECORDER_H -#include -using namespace omnetpp; +#include "veins/base/utils/MiXiMDefs.h" /** * @brief diff --git a/src/veins/modules/phy/Decider80211p.cc b/src/veins/modules/phy/Decider80211p.cc index 9a791149f5..bd51071313 100755 --- a/src/veins/modules/phy/Decider80211p.cc +++ b/src/veins/modules/phy/Decider80211p.cc @@ -294,7 +294,7 @@ enum Decider80211p::PACKET_OK_RESULT Decider80211p::packetOk(double snirMin, dou //probability of no bit error in the PLCP header - double rand = dblrand(getEnvir()->getRNG(0)); + double rand = RNGCONTEXT dblrand(); if (!collectCollisionStats) { if (rand > headerNoError) @@ -320,7 +320,7 @@ enum Decider80211p::PACKET_OK_RESULT Decider80211p::packetOk(double snirMin, dou //probability of no bit error in the rest of the packet - rand = dblrand(getEnvir()->getRNG(0)); + rand = RNGCONTEXT dblrand(); if (!collectCollisionStats) { if (rand > packetOkSinr) { @@ -540,7 +540,7 @@ void Decider80211p::switchToTx() { currentSignal.first = 0; } else { - throw cException("Decider80211p: mac layer requested phy to transmit a frame while currently receiving another"); + throw cRuntimeError("Decider80211p: mac layer requested phy to transmit a frame while currently receiving another"); } } } diff --git a/src/veins/modules/phy/PhyLayer80211p.cc b/src/veins/modules/phy/PhyLayer80211p.cc index 50de29d365..92f3f762f3 100755 --- a/src/veins/modules/phy/PhyLayer80211p.cc +++ b/src/veins/modules/phy/PhyLayer80211p.cc @@ -54,7 +54,7 @@ void PhyLayer80211p::initialize(int stage) { BasePhyLayer::initialize(stage); if (stage == 0) { if (par("headerLength").longValue() != PHY_HDR_TOTAL_LENGTH) { - throw cException("The header length of the 802.11p standard is 46bit, please change your omnetpp.ini accordingly by either setting it to 46bit or removing the entry"); + throw cRuntimeError("The header length of the 802.11p standard is 46bit, please change your omnetpp.ini accordingly by either setting it to 46bit or removing the entry"); } //erase the RadioStateAnalogueModel analogueModels.erase(analogueModels.begin()); @@ -141,7 +141,7 @@ AnalogueModel* PhyLayer80211p::initializeBreakpointPathlossModel(ParameterMap& p if(cc->hasPar("alpha") && alpha1 < cc->par("alpha").doubleValue()) { // throw error - throw cException("TestPhyLayer::createPathLossModel(): alpha can't be smaller than specified in \ + throw cRuntimeError("TestPhyLayer::createPathLossModel(): alpha can't be smaller than specified in \ ConnectionManager. Please adjust your config.xml file accordingly"); } } @@ -164,7 +164,7 @@ AnalogueModel* PhyLayer80211p::initializeBreakpointPathlossModel(ParameterMap& p if(cc->hasPar("alpha") && alpha2 < cc->par("alpha").doubleValue()) { // throw error - throw cException("TestPhyLayer::createPathLossModel(): alpha can't be smaller than specified in \ + throw cRuntimeError("TestPhyLayer::createPathLossModel(): alpha can't be smaller than specified in \ ConnectionManager. Please adjust your config.xml file accordingly"); } } @@ -189,7 +189,7 @@ AnalogueModel* PhyLayer80211p::initializeBreakpointPathlossModel(ParameterMap& p if(cc->hasPar("carrierFrequency") && carrierFrequency < cc->par("carrierFrequency").doubleValue()) { // throw error - throw cException("TestPhyLayer::createPathLossModel(): carrierFrequency can't be smaller than specified in \ + throw cRuntimeError("TestPhyLayer::createPathLossModel(): carrierFrequency can't be smaller than specified in \ ConnectionManager. Please adjust your config.xml file accordingly"); } } @@ -209,7 +209,7 @@ AnalogueModel* PhyLayer80211p::initializeBreakpointPathlossModel(ParameterMap& p } if(alpha1 ==-1 || alpha2==-1 || breakpointDistance==-1 || L01==-1 || L02==-1) { - throw cException("Undefined parameters for breakpointPathlossModel. Please check your configuration."); + throw cRuntimeError("Undefined parameters for breakpointPathlossModel. Please check your configuration."); } return new BreakpointPathlossModel(L01, L02, alpha1, alpha2, breakpointDistance, carrierFrequency, useTorus, playgroundSize, coreDebug); @@ -254,7 +254,7 @@ AnalogueModel* PhyLayer80211p::initializeSimplePathlossModel(ParameterMap& param if(cc->hasPar("alpha") && alpha < cc->par("alpha").doubleValue()) { // throw error - throw cException("TestPhyLayer::createPathLossModel(): alpha can't be smaller than specified in \ + throw cRuntimeError("TestPhyLayer::createPathLossModel(): alpha can't be smaller than specified in \ ConnectionManager. Please adjust your config.xml file accordingly"); } } @@ -286,7 +286,7 @@ AnalogueModel* PhyLayer80211p::initializeSimplePathlossModel(ParameterMap& param if(cc->hasPar("carrierFrequency") && carrierFrequency < cc->par("carrierFrequency").doubleValue()) { // throw error - throw cException("TestPhyLayer::createPathLossModel(): carrierFrequency can't be smaller than specified in \ + throw cRuntimeError("TestPhyLayer::createPathLossModel(): carrierFrequency can't be smaller than specified in \ ConnectionManager. Please adjust your config.xml file accordingly"); } } @@ -344,7 +344,7 @@ AnalogueModel* PhyLayer80211p::initializeSimpleObstacleShadowing(ParameterMap& p if(cc->hasPar("carrierFrequency") && carrierFrequency < cc->par("carrierFrequency").doubleValue()) { // throw error - throw cException("initializeSimpleObstacleShadowing(): carrierFrequency can't be smaller than specified in ConnectionManager. Please adjust your config.xml file accordingly"); + throw cRuntimeError("initializeSimpleObstacleShadowing(): carrierFrequency can't be smaller than specified in ConnectionManager. Please adjust your config.xml file accordingly"); } } else // carrierFrequency has not been specified in config.xml @@ -363,7 +363,7 @@ AnalogueModel* PhyLayer80211p::initializeSimpleObstacleShadowing(ParameterMap& p } ObstacleControl* obstacleControlP = ObstacleControlAccess().getIfExists(); - if (!obstacleControlP) throw cException("initializeSimpleObstacleShadowing(): cannot find ObstacleControl module"); + if (!obstacleControlP) throw cRuntimeError("initializeSimpleObstacleShadowing(): cannot find ObstacleControl module"); return new SimpleObstacleShadowing(*obstacleControlP, carrierFrequency, useTorus, playgroundSize, coreDebug); } diff --git a/src/veins/modules/phy/SNRThresholdDecider.cc b/src/veins/modules/phy/SNRThresholdDecider.cc index 986fa912d5..36f55e5343 100644 --- a/src/veins/modules/phy/SNRThresholdDecider.cc +++ b/src/veins/modules/phy/SNRThresholdDecider.cc @@ -125,7 +125,7 @@ simtime_t SNRThresholdDecider::canAnswerCSR(const CSRInfo& requestInfo) { assert(request); if(request->getSenseMode() == UNTIL_TIMEOUT) { - throw cException("SNRThresholdDecider received an UNTIL_TIMEOUT ChannelSenseRequest.\n" + throw cRuntimeError("SNRThresholdDecider received an UNTIL_TIMEOUT ChannelSenseRequest.\n" "SNRThresholdDecider can only handle UNTIL_IDLE or UNTIL_BUSY requests because it " "implements only instantaneous sensing where UNTIL_TIMEOUT requests " "don't make sense. Please refer to ChannelSenseRequests documentation " diff --git a/src/veins/modules/world/annotations/AnnotationDummy.h b/src/veins/modules/world/annotations/AnnotationDummy.h index 3e6356e1e3..73801e5549 100644 --- a/src/veins/modules/world/annotations/AnnotationDummy.h +++ b/src/veins/modules/world/annotations/AnnotationDummy.h @@ -20,8 +20,8 @@ #ifndef WORLD_ANNOTATION_ANNOTATIONDUMMY_H #define WORLD_ANNOTATION_ANNOTATIONDUMMY_H -#include -using namespace omnetpp; +#include "veins/base/utils/MiXiMDefs.h" + /** * AnnotationDummy is just a workaround to visualize annotations * diff --git a/src/veins/modules/world/annotations/AnnotationManager.cc b/src/veins/modules/world/annotations/AnnotationManager.cc index 34627ed250..7dbc0f1cb2 100644 --- a/src/veins/modules/world/annotations/AnnotationManager.cc +++ b/src/veins/modules/world/annotations/AnnotationManager.cc @@ -327,7 +327,7 @@ void AnnotationManager::show(const Annotation* annotation) { if (const Point* o = dynamic_cast(annotation)) { - if (getEnvir()->isGUI()) { + if (hasGUI()) { // no corresponding TkEnv representation } @@ -340,7 +340,7 @@ void AnnotationManager::show(const Annotation* annotation) { } else if (const Line* l = dynamic_cast(annotation)) { - if (getEnvir()->isGUI()) { + if (hasGUI()) { #if OMNETPP_CANVAS_VERSION == 0x20140709 cLineFigure* figure = new cLineFigure(); figure->setStart(cFigure::Point(l->p1.x, l->p1.y)); @@ -366,7 +366,7 @@ void AnnotationManager::show(const Annotation* annotation) { ASSERT(p->coords.size() >= 2); - if (getEnvir()->isGUI()) { + if (hasGUI()) { #if OMNETPP_CANVAS_VERSION == 0x20140709 cPolygonFigure* figure = new cPolygonFigure(); std::vector points; diff --git a/tests/traci/omnetpp.ini b/tests/traci/omnetpp.ini index 0477d5f788..47f7d0a125 100644 --- a/tests/traci/omnetpp.ini +++ b/tests/traci/omnetpp.ini @@ -5,7 +5,6 @@ cmdenv-status-frequency = 10000000s #tkenv-default-config = accident #tkenv-default-run = 1 -tkenv-image-path = bitmaps ned-path = . network = scenario