X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2FLogicExecuter.java;h=52adeba0b44968fced83828086fcb2681171de1a;hb=6579fc1c18c0f008f259c3c48c47e604adac2a4c;hp=c1061219bca069d1ef912fb7042bb94c605c1fe5;hpb=fac8a9fce341bc42173af3cde70ef6aef00d7ee7;p=Mograsim.git diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicExecuter.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicExecuter.java index c1061219..52adeba0 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicExecuter.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/LogicExecuter.java @@ -5,6 +5,7 @@ import java.util.concurrent.atomic.AtomicLong; import net.mograsim.logic.core.timeline.PauseableTimeFunction; import net.mograsim.logic.core.timeline.Timeline; +import net.mograsim.logic.core.timeline.Timeline.ExecutionResult; //TODO maybe move to logic core? public class LogicExecuter @@ -41,8 +42,12 @@ public class LogicExecuter { while (shouldBeRunningLive.get()) { - long current = tf.getAsLong(); - timeline.executeUntil(timeline.laterThan(current), System.currentTimeMillis() + 10); + long current = tf.getTime(); + // The tf.isPaused() condition is justified, because timeline.getSimulationTime() returns the timestamp of the last + // processed event during executeUntil() + if (timeline.executeUntil(() -> timeline.laterThan(current).getAsBoolean() || tf.isPaused(), + System.currentTimeMillis() + 10) == ExecutionResult.EXEC_OUT_OF_TIME) + timeline.synchTime(); // TODO: should this also be called if tf.isPaused() condition is met? long nextEventTime = timeline.nextEventTime(); long sleepTime; if (timeline.hasNext()) @@ -132,6 +137,11 @@ public class LogicExecuter return isPaused.get(); } + public double getSpeedFactor() + { + return tf.getSpeedFactor(); + } + public void setSpeedFactor(double factor) { tf.setSpeedFactor(factor);