inet icon indicating copy to clipboard operation
inet copied to clipboard

Schedule event in the past while reading trace file using Ns2MotionMobility module

Open Ahsan01 opened this issue 9 years ago • 0 comments

Please refer to the following snippet of the code in file Ns2MotionMobility.cc. The variable

nextChange = The next simulation time when the mobility module needs to update its internal state

In the case when the variable now >= time && vec[3] == 0 then the execution will come in the else-if block of the code snippet. Inside block (Line 186 of Ns2MotionMobility.cc), we set nextChange = time

This is wrong as: time =< now and we are setting nextChange to past.

Solution: change it to: nextChange = now

 const Ns2MotionFile::Line& vec = ns2File->lines[vecpos];
    double time = vec[0];
    simtime_t now = simTime();
    // TODO: this code is dubious at best
    if (now < time) {
        nextChange = time;
        targetPosition = lastPosition;
    }
    else if (vec[3] == 0) {    // the node is stopped
        const Ns2MotionFile::Line& vec = ns2File->lines[vecpos + 1];
        double time = vec[0];
        nextChange = time; 
        EV << "COMING HERE AFTER and next change is:" << nextChange << endl;
        targetPosition = lastPosition;
        vecpos++;
    }

Ahsan01 avatar Mar 30 '16 13:03 Ahsan01