sending data structure as a message between simple modules

231 views
Skip to first unread message

Zoya

unread,
Jan 9, 2015, 4:52:13 AM1/9/15
to omn...@googlegroups.com
Hello,

I have to send data structure as a message between simple Modules.

My data structure is described as follow :

    struct message {
      Entity sender;
      Entity receiver;
      list<Fact> facts;
      string goal;
    };

Im a begginer on omnet++ and i used a simple string as a message to circulate it between simple modules :

        cMessage *msg = new cMessage("bidon");
        cModule *targetModule = getParentModule()-> getSubmodule("phone");
        sendDirect(msg, targetModule, "in");

How to adapt this code to send a data structure and not a string ? or we must use another class ("cMessage) to send data structure ?

Thank you in advance for your help,

Zoya

unread,
Jan 9, 2015, 10:52:44 AM1/9/15
to omn...@googlegroups.com
Should we use the fonction controlInfo of cMessage class ??
How to send a complex message like a vector of data, list of data, structure data,... ?

Alfonso Ariza Quintana

unread,
Jan 9, 2015, 12:14:31 PM1/9/15
to omn...@googlegroups.com

You can find this information in the manual, how to define fields and complex structures fields in a packet

--
You received this message because you are subscribed to the Google Groups "omnetpp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Zoya

unread,
Jan 12, 2015, 5:58:46 AM1/12/15
to omn...@googlegroups.com, aari...@hotmail.com
Thank you very mauch Alfonso :)

I created the message file "message.msg" as follow and it's work :

cplusplus {{
    #include <list>
    #include "Fact.h"
    #include "Entity.h"
    #include <string>
    typedef std::list<Fact> FactsList;   
}};

class noncobject Fact;
class noncobject Entity;
class noncobject FactsList;

packet message {
  Entity sender;
  Entity receiver;
  FactsList facts;
  string goal;
Reply all
Reply to author
Forward
0 new messages