introduced execute method with duration argument

This commit is contained in:
fros4943 2010-02-03 19:08:40 +00:00
parent b3e0a2506f
commit 3786f2f5fb

View file

@ -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.40 2010/02/03 16:04:44 fros4943 Exp $ * $Id: MspMote.java,v 1.41 2010/02/03 19:08:40 fros4943 Exp $
*/ */
package se.sics.cooja.mspmote; package se.sics.cooja.mspmote;
@ -310,7 +310,10 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
private long lastExecute = -1; /* Last time mote executed */ private long lastExecute = -1; /* Last time mote executed */
private long nextExecute; private long nextExecute;
public void execute(long t) { public void execute(long time) {
execute(time, EXECUTE_DURATION_US);
}
public void execute(long t, int duration) {
/* Wait until mote boots */ /* Wait until mote boots */
if (myMoteInterfaceHandler.getClock().getTime() < 0) { if (myMoteInterfaceHandler.getClock().getTime() < 0) {
scheduleNextWakeup(t - myMoteInterfaceHandler.getClock().getTime()); scheduleNextWakeup(t - myMoteInterfaceHandler.getClock().getTime());
@ -336,8 +339,8 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
/* TODO Try-catch overhead */ /* TODO Try-catch overhead */
try { try {
nextExecute = nextExecute =
t + EXECUTE_DURATION_US + t + duration +
myCpu.stepMicros(t - lastExecute, EXECUTE_DURATION_US); myCpu.stepMicros(t - lastExecute, duration);
lastExecute = t; lastExecute = t;
} catch (EmulationException e) { } catch (EmulationException e) {
if (e.getMessage().startsWith("Bad operation")) { if (e.getMessage().startsWith("Bad operation")) {
@ -350,7 +353,7 @@ public abstract class MspMote extends AbstractEmulatedMote implements Mote, Watc
} }
/* Schedule wakeup */ /* Schedule wakeup */
if (nextExecute <= t) { if (nextExecute < t) {
throw new RuntimeException(t + ": MSPSim requested early wakeup: " + nextExecute); throw new RuntimeException(t + ": MSPSim requested early wakeup: " + nextExecute);
} }
/*logger.debug(t + ": Schedule next wakeup at " + nextExecute);*/ /*logger.debug(t + ": Schedule next wakeup at " + nextExecute);*/