Omnet Syntax - ThomasRueckert/sensorSim GitHub Wiki

get modules fields

cClassDescriptor* thisDescr = cClassDescriptor::getDescriptorFor(this);
int count = thisDescr->getFieldCount(this);

for ( int i = 0; i < count; i++) {
    std::stringstream s;
    //i = 17: displaystring
    s << i <<" " << thisDescr->getFieldName(this, i) << " " << thisDescr->getFieldAsString(this, i, 0);
    s << i << " " << thisDescr->getFieldName(this, i);
    cMessage *mseg = new cMessage(s.str().c_str());
    send(mseg, "worldDataGate$o");
}

simtime

get the sim time
simtime_t time = simTime();
schedule an event at a given time
scheduleAt(simTime()+delay, event);

get an instance of a global method (like any ComponentType)

Allgemein
#include <FindModule.h>

[Classname]* testtype = FindModule<[Classname]*>::findSubModule(this);
get the position of a node that uses mobility
Coord* back;
//getPosition();
BasePhyLayer* phy = FindModule<BasePhyLayer*>::findSubModule(this);
ChannelMobilityPtrType pMobType = phy->getMobilityModule();
if(pMobType != NULL){
    back = new Coord(pMobType->getCurrentPosition());
}
get the nodetype which subclass componenttype
NodeType* testtype = FindModule<NodeType*>::findSubModule(this);
this->setComponentType(testtype);

using the object list of cmessage

adding object
    cMessage *newmsg = new cMessage("any name");
    SimpleCoord *coord = new SimpleCoord("pos", position);
    newmsg->getParList().add(coord);
    send(newmsg, "toWorld$o");
getting (and removing) objects
    SimpleCoord *array = (SimpleCoord*) msg->getParList().remove("pos");
    //double x = par->x;
    //double y = par->y;
    string name = msg->getName();
    delete msg;
    delete array;
⚠️ **GitHub.com Fallback** ⚠️