mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
removed unused currentSimTime + fixed bug when nodes are added during simulations
This commit is contained in:
parent
11a084f8df
commit
6011abbb79
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* $Id: MspMote.java,v 1.12 2008/09/22 16:18:48 joxe Exp $
|
* $Id: MspMote.java,v 1.13 2008/10/07 16:49:21 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.mspmote;
|
package se.sics.cooja.mspmote;
|
||||||
@ -261,25 +261,23 @@ public abstract class MspMote implements Mote {
|
|||||||
*/
|
*/
|
||||||
protected abstract boolean initEmulator(File ELFFile);
|
protected abstract boolean initEmulator(File ELFFile);
|
||||||
|
|
||||||
private int currentSimTime = -1;
|
|
||||||
|
|
||||||
/* return false when done - e.g. true means more work to do before finished with this tick */
|
/* return false when done - e.g. true means more work to do before finished with this tick */
|
||||||
|
private boolean firstTick = true;
|
||||||
public boolean tick(int simTime) {
|
public boolean tick(int simTime) {
|
||||||
if (stopNextInstruction) {
|
if (stopNextInstruction) {
|
||||||
stopNextInstruction = false;
|
stopNextInstruction = false;
|
||||||
throw new RuntimeException("Request simulation stop");
|
throw new RuntimeException("Request simulation stop");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSimTime < 0) {
|
/* Nodes may be added in an ongoing simulation:
|
||||||
currentSimTime = simTime;
|
* Update cycle drift to current simulation time */
|
||||||
|
if (firstTick) {
|
||||||
|
firstTick = false;
|
||||||
|
cycleDrift += (-NR_CYCLES_PER_MSEC*simTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentSimTime != simTime) {
|
long maxSimTimeCycles = NR_CYCLES_PER_MSEC*(simTime+1) + cycleDrift;
|
||||||
currentSimTime = simTime;
|
if (maxSimTimeCycles <= cycleCounter) {
|
||||||
}
|
|
||||||
|
|
||||||
long maxSimTimeCycles = NR_CYCLES_PER_MSEC*(simTime+1);
|
|
||||||
if (maxSimTimeCycles <= cycleCounter - cycleDrift) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user