From ae80b1a585b36725d0440ec321bd6b5ded7c6937 Mon Sep 17 00:00:00 2001 From: fros4943 Date: Tue, 28 Oct 2008 09:57:48 +0000 Subject: [PATCH] rewriting mote interfaces for faster simulation execution. clock interface --- .../contikimote/interfaces/ContikiClock.java | 40 +++++++++---------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiClock.java b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiClock.java index 1922e7d52..23cb803c2 100644 --- a/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiClock.java +++ b/tools/cooja/java/se/sics/cooja/contikimote/interfaces/ContikiClock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Swedish Institute of Computer Science. + * Copyright (c) 2008, Swedish Institute of Computer Science. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -26,7 +26,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ContikiClock.java,v 1.3 2007/06/19 09:59:19 fros4943 Exp $ + * $Id: ContikiClock.java,v 1.4 2008/10/28 09:57:48 fros4943 Exp $ */ package se.sics.cooja.contikimote.interfaces; @@ -38,24 +38,27 @@ import org.jdom.Element; import se.sics.cooja.*; import se.sics.cooja.contikimote.ContikiMoteInterface; import se.sics.cooja.interfaces.Clock; +import se.sics.cooja.interfaces.PolledBeforeActiveTicks; /** - * The class represents a clock and controls the core time. - * - * It needs read/write access to the following core variables: + * Clock mote interface. Controls Contiki time. + * + * Contiki variables: * - * Dependency core interfaces are: + * + * Core interface: * *

- * This observable never updates. - * - * @author Fredrik Osterlind + * + * This observable never notifies. + * + * @author Fredrik Österlind */ -public class ContikiClock extends Clock implements ContikiMoteInterface { +public class ContikiClock extends Clock implements ContikiMoteInterface, PolledBeforeActiveTicks { private Mote mote = null; private SectionMoteMemory moteMem = null; @@ -63,10 +66,8 @@ public class ContikiClock extends Clock implements ContikiMoteInterface { private int timeDrift = 0; /** - * Creates a time connected to mote. - * - * @param mote - * Mote to connect this time to. + * @param mote Mote + * * @see Mote * @see se.sics.cooja.MoteInterfaceHandler */ @@ -92,15 +93,12 @@ public class ContikiClock extends Clock implements ContikiMoteInterface { } public void doActionsBeforeTick() { - // Update core time to correspond with the simulation time + /* Update time */ int moteTime = mote.getSimulation().getSimulationTime() + timeDrift; - - if (moteTime > 0) - setTime(moteTime); - } - public void doActionsAfterTick() { - // Nothing to do + if (moteTime > 0) { + setTime(moteTime); + } } public JPanel getInterfaceVisualizer() {