import org.eclipse.swt.widgets.Shell;\r
\r
import era.mi.gui.model.ViewModel;\r
+import era.mi.gui.modeladapter.LogicModelParameters;\r
+import era.mi.gui.modeladapter.ViewLogicModelAdapter;\r
+import era.mi.logic.timeline.Timeline;\r
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasOverlay;\r
import net.haspamelodica.swt.helper.zoomablecanvas.helper.ZoomableCanvasUserInput;\r
\r
public class LogicUIStandalone\r
{\r
private ViewModel model;\r
+ private Timeline timeline;\r
\r
private final Display display;\r
private final Shell shell;\r
userInput.buttonZoom = 2;\r
userInput.enableUserInput();\r
new ZoomableCanvasOverlay(ui, null).enableScale();\r
+\r
+ // TODO don't do this here\r
+ LogicModelParameters params = new LogicModelParameters();\r
+ params.gateProcessTime = 50;\r
+ params.wireTravelTime = 10;\r
+ timeline = ViewLogicModelAdapter.convert(model, params);\r
}\r
\r
public LogicUICanvas getLogicUICanvas()\r
public void run()\r
{\r
AtomicBoolean running = new AtomicBoolean(true);\r
-// Thread simulationThread = new Thread(() ->\r
-// {\r
-// while (running.get())\r
-// {\r
-// // always execute to keep timeline from "hanging behind" for too long\r
-// model.timeline.executeUpTo(System.currentTimeMillis(), System.currentTimeMillis() + 10);\r
-// long sleepTime;\r
-// if (model.timeline.hasNext())\r
-// sleepTime = model.timeline.nextEventTime() - System.currentTimeMillis();\r
-// else\r
-// sleepTime = 10;\r
-// try\r
-// {\r
-// if (sleepTime > 0)\r
-// Thread.sleep(sleepTime);\r
-// }\r
-// catch (InterruptedException e)\r
-// {\r
-// } // it is normal execution flow to be interrupted\r
-// }\r
-// });\r
-// simulationThread.start();\r
-// model.timeline.addEventAddedListener(event ->\r
-// {\r
-// if (event.getTiming() <= System.currentTimeMillis())\r
-// simulationThread.interrupt();\r
-// });\r
+ Thread simulationThread = new Thread(() ->\r
+ {\r
+ while (running.get())\r
+ {\r
+ // always execute to keep timeline from "hanging behind" for too long\r
+ timeline.executeUpTo(System.currentTimeMillis(), System.currentTimeMillis() + 10);\r
+ long sleepTime;\r
+ if (timeline.hasNext())\r
+ sleepTime = timeline.nextEventTime() - System.currentTimeMillis();\r
+ else\r
+ sleepTime = 10;\r
+ try\r
+ {\r
+ if (sleepTime > 0)\r
+ Thread.sleep(sleepTime);\r
+ }\r
+ catch (InterruptedException e)\r
+ {\r
+ } // it is normal execution flow to be interrupted\r
+ }\r
+ });\r
+ simulationThread.start();\r
+ timeline.addEventAddedListener(event ->\r
+ {\r
+ if (event.getTiming() <= System.currentTimeMillis())\r
+ simulationThread.interrupt();\r
+ });\r
\r
shell.open();\r
while (!shell.isDisposed())\r