How to convey multiple variables through single emit() in OMNET++?

Viewed 31

According to OMNET++ Simulation Manual the types can be carried by emit() are, "The value can be of type bool, long, double, simtime_t, const char * , or (const) cObject * . Other types can be cast into one of these types, or wrapped into an object subclassed from cObject."

So to pass multiple vairables through single emit(), cObject must be used. The Manual's solution for this is to create a class driven from cObject to hold the values and pass it to the emit().

 class cRawTableData : public cObject, noncopyable
{
public:
    unsigned int sVehicleID;
    double sPositionX;                    
    double sPositionY;                                     
    double sSpeed;                    
};

if (hasListeners(rawTableSignal)){
cRawTableData tmp;
tmp.sVehicleID=senderId;
tmp.sPositionX=senderPOx;
tmp.sPositionY=senderPOy;
tmp.sSpeed=senderSpeed;
emit(rawTableSignal, &tmp);
}

However, when I run the simulation I get this error:

omnetpp::VectorRecorder: Cannot convert cObject* to double

run-time error

What is that I am doing wrong? thank you for the help

0 Answers
Related