X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=SampleERCP%2Fsrc%2Fsampleercp%2Fparts%2FLogicUIPart.java;h=ee1d7759227016b4074fcfc710e4e3646ea86c68;hb=0ce7f7122a702c3d6a4b864172b8c93620c8b03b;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..ee1d7759 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,8 +20,9 @@ public class LogicUIPart @PostConstruct public void create(Composite parent) { + Timeline timeline = new Timeline(11); LogicUICanvas ui = new LogicUICanvas(parent, SWT.NONE); - RSLatchGUIExample.addComponentsAndWires(ui); + RSLatchGUIExample.addComponentsAndWires(ui, timeline); ui.addTransformListener((x, y, z) -> part.setDirty(z < 1)); ZoomableCanvasUserInput userInput = new ZoomableCanvasUserInput(ui); userInput.buttonDrag = 3; @@ -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.executeUntil(timeline.laterThan(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