X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=SampleERCP%2Fsrc%2Fsampleercp%2Fparts%2FLogicUIPart.java;h=481879c6a209ee9d02721bb5271ca295fddb9a05;hb=6c67a9ff8361cd9fc082f40e2676f2c8b5911fe4;hp=7ed8377e0419d822ebb57f9a93100c443a90cc8f;hpb=15c8eb1395228603c0eb9ef8c8209eea1d879701;p=Mograsim.git diff --git a/SampleERCP/src/sampleercp/parts/LogicUIPart.java b/SampleERCP/src/sampleercp/parts/LogicUIPart.java index 7ed8377e..481879c6 100644 --- a/SampleERCP/src/sampleercp/parts/LogicUIPart.java +++ b/SampleERCP/src/sampleercp/parts/LogicUIPart.java @@ -9,7 +9,7 @@ import org.eclipse.swt.widgets.Composite; import era.mi.gui.LogicUICanvas; import era.mi.gui.examples.RSLatchGUIExample; -import era.mi.logic.Simulation; +import era.mi.logic.timeline.Timeline; import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput; public class LogicUIPart @@ -20,6 +20,7 @@ public class LogicUIPart @PostConstruct public void create(Composite parent) { + Timeline timeline = new Timeline(11); LogicUICanvas ui = new LogicUICanvas(parent, SWT.NONE); RSLatchGUIExample.addComponentsAndWires(ui); ui.addTransformListener((x, y, z) -> part.setDirty(z < 1)); @@ -33,10 +34,10 @@ public class LogicUIPart while (!ui.isDisposed()) { // always execute to keep timeline from "hanging behind" for too long - Simulation.TIMELINE.executeUpTo(System.currentTimeMillis(), System.currentTimeMillis() + 10); + timeline.executeUpTo(System.currentTimeMillis(), System.currentTimeMillis() + 10); long sleepTime; - if (Simulation.TIMELINE.hasNext()) - sleepTime = Simulation.TIMELINE.nextEventTime() - System.currentTimeMillis(); + if (timeline.hasNext()) + sleepTime = timeline.nextEventTime() - System.currentTimeMillis(); else sleepTime = 10; try @@ -50,5 +51,10 @@ public class LogicUIPart } }); simulationThread.start(); + timeline.addEventAddedListener(event -> + { + if (event.getTiming() <= System.currentTimeMillis()) + simulationThread.interrupt(); + }); } } \ No newline at end of file