X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=era.mi%2Fsrc%2Fera%2Fmi%2Flogic%2Ftests%2FGUITest.java;h=0581812b68e16dfebffff3860822b61360996e99;hb=80bfbd8ebf0ad8a7ad98584544a0c73f43e6f3b6;hp=2599b542c1dc562ca44e2e1f2afc8fc48501f69c;hpb=c1d0ddc342c482051fa6c455bb286617135bd3c3;p=Mograsim.git diff --git a/era.mi/src/era/mi/logic/tests/GUITest.java b/era.mi/src/era/mi/logic/tests/GUITest.java index 2599b542..0581812b 100644 --- a/era.mi/src/era/mi/logic/tests/GUITest.java +++ b/era.mi/src/era/mi/logic/tests/GUITest.java @@ -15,10 +15,10 @@ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.WindowConstants; -import era.mi.logic.Simulation; import era.mi.logic.components.ManualSwitch; import era.mi.logic.components.gates.NotGate; import era.mi.logic.components.gates.OrGate; +import era.mi.logic.timeline.Timeline; import era.mi.logic.timeline.Timeline.ExecutionResult; import era.mi.logic.wires.Wire; @@ -31,20 +31,22 @@ public class GUITest extends JPanel private static final int OR_DELAY = 100; private static final int NOT_DELAY = 100; - Wire r = new Wire(1, WIRE_DELAY); - Wire s = new Wire(1, WIRE_DELAY); - Wire t1 = new Wire(1, WIRE_DELAY); - Wire t2 = new Wire(1, WIRE_DELAY); - Wire q = new Wire(1, WIRE_DELAY); - Wire nq = new Wire(1, WIRE_DELAY); + private Timeline t = new Timeline(11); - ManualSwitch rIn = new ManualSwitch(r.createEnd()); - ManualSwitch sIn = new ManualSwitch(s.createEnd()); + Wire r = new Wire(t, 1, WIRE_DELAY); + Wire s = new Wire(t, 1, WIRE_DELAY); + Wire t1 = new Wire(t, 1, WIRE_DELAY); + Wire t2 = new Wire(t, 1, WIRE_DELAY); + Wire q = new Wire(t, 1, WIRE_DELAY); + Wire nq = new Wire(t, 1, WIRE_DELAY); - OrGate or1 = new OrGate(OR_DELAY, t2.createEnd(), r.createEnd(), nq.createEnd()); - OrGate or2 = new OrGate(OR_DELAY, t1.createEnd(), s.createEnd(), q.createEnd()); - NotGate not1 = new NotGate(NOT_DELAY, t2.createEnd(), q.createEnd()); - NotGate not2 = new NotGate(NOT_DELAY, t1.createEnd(), nq.createEnd()); + ManualSwitch rIn = new ManualSwitch(t, r.createReadWriteEnd()); + ManualSwitch sIn = new ManualSwitch(t, s.createReadWriteEnd()); + + OrGate or1 = new OrGate(t, OR_DELAY, t2.createReadWriteEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd()); + OrGate or2 = new OrGate(t, OR_DELAY, t1.createReadWriteEnd(), s.createReadOnlyEnd(), q.createReadOnlyEnd()); + NotGate not1 = new NotGate(t, NOT_DELAY, t2.createReadOnlyEnd(), q.createReadWriteEnd()); + NotGate not2 = new NotGate(t, NOT_DELAY, t1.createReadOnlyEnd(), nq.createReadWriteEnd()); Map switchMap = new HashMap<>(); @@ -109,6 +111,11 @@ public class GUITest extends JPanel }); } + public Timeline getTimeline() + { + return t; + }; + @Override public void paint(Graphics some_g) { @@ -241,7 +248,7 @@ public class GUITest extends JPanel g.setColor(Color.BLACK); break; case U: - g.setColor(Color.BLUE); + g.setColor(Color.MAGENTA); break; default: throw new IllegalArgumentException(); @@ -275,14 +282,14 @@ public class GUITest extends JPanel while (f.isVisible()) { - ExecutionResult er = Simulation.TIMELINE.executeUpTo((lastFrame - begin) * 3, lastFrame + 14); -// if (Simulation.TIMELINE.hasNext()) -// Simulation.TIMELINE.executeNext(); + ExecutionResult er = gt.getTimeline().executeUntil(gt.getTimeline().laterThan((lastFrame - begin) * 3), lastFrame + 14); +// if (t.hasNext()) +// t.executeNext(); if (er != ExecutionResult.NOTHING_DONE) gt.repaint(12); try { - Thread.sleep(Math.max(16 - System.currentTimeMillis() + lastFrame, 0)); + Thread.sleep(Math.max(updateT - System.currentTimeMillis() + lastFrame, 0)); } catch (Exception e) {