Merge branch 'development' of
authorFabian Stemmler <stemmler@in.tum.de>
Wed, 29 May 2019 10:42:50 +0000 (12:42 +0200)
committerFabian Stemmler <stemmler@in.tum.de>
Wed, 29 May 2019 10:42:50 +0000 (12:42 +0200)
https://gitlab.lrz.de/lrr-tum/students/eragp-misim-2019 into development

# Conflicts:
# LogicUI/oldsrc/RSLatchGUIExample.java
# LogicUI/src/era/mi/gui/LogicUIStandalone.java
# LogicUI/src/era/mi/gui/components/GUIManualSwitch.java
# SampleERCP/src/sampleercp/parts/LogicUIPart.java

1  2 
LogicUI/oldsrc/RSLatchGUIExample.java
LogicUI/src/era/mi/gui/LogicUIStandalone.java
LogicUI/src/era/mi/gui/components/GUIManualSwitch.java

index 0000000,0fb1886..413525b
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,61 +1,62 @@@
 -package era.mi.gui.examples;
 -
 -import era.mi.gui.LogicUICanvas;
 -import era.mi.gui.LogicUIStandalone;
 -import era.mi.gui.components.GUIManualSwitch;
 -import era.mi.gui.components.GUINotGate;
 -import era.mi.gui.components.GUIOrGateOld;
 -import era.mi.gui.wires.WireConnectionPoint;
 -import era.mi.logic.timeline.Timeline;
 -import era.mi.logic.wires.Wire;
 -import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
 -
 -public class RSLatchGUIExample
 -{
 -      private static final int WIRE_DELAY = 10;
 -      private static final int OR_DELAY = 50;
 -      private static final int NOT_DELAY = 50;
 -
 -      public static void main(String[] args)
 -      {
 -              Timeline t = new Timeline(11);
 -              LogicUIStandalone ui = new LogicUIStandalone(t);
 -              addComponentsAndWires(ui.getLogicUICanvas(), t);
 -              ui.run();
 -      }
 -
 -      public static void addComponentsAndWires(LogicUICanvas ui, Timeline t)
 -      {
 -              Wire r = new Wire(t, 1, WIRE_DELAY);
 -              Wire s = new Wire(t, 1, WIRE_DELAY);
 -              Wire t2 = new Wire(t, 1, WIRE_DELAY);
 -              Wire t1 = new Wire(t, 1, WIRE_DELAY);
 -              Wire q = new Wire(t, 1, WIRE_DELAY);
 -              Wire nq = new Wire(t, 1, WIRE_DELAY);
 -
 -              GUIManualSwitch rIn = ui.addComponent(new GUIManualSwitch(t, r.createReadWriteEnd()), 100, 100);
 -              GUIManualSwitch sIn = ui.addComponent(new GUIManualSwitch(t, s.createReadWriteEnd()), 100, 200);
 -              GUIOrGateOld or1 = ui.addComponent(new GUIOrGateOld(t, OR_DELAY, t1.createReadWriteEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd()),
 -                              160, 102.5);
 -              GUIOrGateOld or2 = ui.addComponent(new GUIOrGateOld(t, OR_DELAY, t2.createReadWriteEnd(), q.createReadOnlyEnd(), s.createReadOnlyEnd()),
 -                              160, 192.5);
 -              GUINotGate not1 = ui.addComponent(new GUINotGate(t, NOT_DELAY, t1.createReadOnlyEnd(), q.createReadWriteEnd()), 200, 107.5);
 -              GUINotGate not2 = ui.addComponent(new GUINotGate(t, NOT_DELAY, t2.createReadOnlyEnd(), nq.createReadWriteEnd()), 200, 197.5);
 -
 -              WireConnectionPoint p1 = ui.addComponent(new WireConnectionPoint(q, 3), 250, 112.5);
 -              WireConnectionPoint p2 = ui.addComponent(new WireConnectionPoint(nq, 3), 250, 202.5);
 -              WireConnectionPoint o1 = ui.addComponent(new WireConnectionPoint(q, 1), 270, 112.5);
 -              WireConnectionPoint o2 = ui.addComponent(new WireConnectionPoint(nq, 1), 270, 202.5);
 -
 -              ui.addWire(rIn, 0, or1, 0);
 -              ui.addWire(sIn, 0, or2, 1);
 -              ui.addWire(or1, 2, not1, 0);
 -              ui.addWire(or2, 2, not2, 0);
 -              ui.addWire(not1, 1, p1, 0);
 -              ui.addWire(not2, 1, p2, 0);
 -              ui.addWire(p1, 1, or2, 0, new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
 -              ui.addWire(p2, 1, or1, 1, new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
 -              ui.addWire(p1, 2, o1, 0);
 -              ui.addWire(p2, 2, o2, 0);
 -      }
++package era.mi.gui.examples;\r
++\r
++import era.mi.gui.LogicUICanvas;\r
++import era.mi.gui.LogicUIStandalone;\r
++import era.mi.gui.components.GUIManualSwitch;\r
++import era.mi.gui.components.GUINotGate;\r
++import era.mi.gui.components.GUIOrGateOld;\r
++import era.mi.gui.wires.WireConnectionPoint;\r
++import era.mi.logic.timeline.Timeline;\r
++import era.mi.logic.wires.Wire;\r
++import net.haspamelodica.swt.helper.swtobjectwrappers.Point;\r
++\r
++public class RSLatchGUIExample\r
++{\r
++      private static final int WIRE_DELAY = 10;\r
++      private static final int OR_DELAY = 50;\r
++      private static final int NOT_DELAY = 50;\r
++\r
++      public static void main(String[] args)\r
++      {\r
++              Timeline t = new Timeline(11);\r
++              t.setTimeFunction(() -> System.currentTimeMillis()); // real time simulation\r
++              LogicUIStandalone ui = new LogicUIStandalone(t);\r
++              addComponentsAndWires(ui.getLogicUICanvas(), t);\r
++              ui.run();\r
++      }\r
++\r
++      public static void addComponentsAndWires(LogicUICanvas ui, Timeline t)\r
++      {\r
++              Wire r = new Wire(t, 1, WIRE_DELAY);\r
++              Wire s = new Wire(t, 1, WIRE_DELAY);\r
++              Wire t2 = new Wire(t, 1, WIRE_DELAY);\r
++              Wire t1 = new Wire(t, 1, WIRE_DELAY);\r
++              Wire q = new Wire(t, 1, WIRE_DELAY);\r
++              Wire nq = new Wire(t, 1, WIRE_DELAY);\r
++\r
++              GUIManualSwitch rIn = ui.addComponent(new GUIManualSwitch(t, r.createReadWriteEnd()), 100, 100);\r
++              GUIManualSwitch sIn = ui.addComponent(new GUIManualSwitch(t, s.createReadWriteEnd()), 100, 200);\r
++              GUIOrGateOld or1 = ui.addComponent(new GUIOrGateOld(t, OR_DELAY, t1.createReadWriteEnd(), r.createReadOnlyEnd(), nq.createReadOnlyEnd()),\r
++                              160, 102.5);\r
++              GUIOrGateOld or2 = ui.addComponent(new GUIOrGateOld(t, OR_DELAY, t2.createReadWriteEnd(), q.createReadOnlyEnd(), s.createReadOnlyEnd()),\r
++                              160, 192.5);\r
++              GUINotGate not1 = ui.addComponent(new GUINotGate(t, NOT_DELAY, t1.createReadOnlyEnd(), q.createReadWriteEnd()), 200, 107.5);\r
++              GUINotGate not2 = ui.addComponent(new GUINotGate(t, NOT_DELAY, t2.createReadOnlyEnd(), nq.createReadWriteEnd()), 200, 197.5);\r
++\r
++              WireConnectionPoint p1 = ui.addComponent(new WireConnectionPoint(q, 3), 250, 112.5);\r
++              WireConnectionPoint p2 = ui.addComponent(new WireConnectionPoint(nq, 3), 250, 202.5);\r
++              WireConnectionPoint o1 = ui.addComponent(new WireConnectionPoint(q, 1), 270, 112.5);\r
++              WireConnectionPoint o2 = ui.addComponent(new WireConnectionPoint(nq, 1), 270, 202.5);\r
++\r
++              ui.addWire(rIn, 0, or1, 0);\r
++              ui.addWire(sIn, 0, or2, 1);\r
++              ui.addWire(or1, 2, not1, 0);\r
++              ui.addWire(or2, 2, not2, 0);\r
++              ui.addWire(not1, 1, p1, 0);\r
++              ui.addWire(not2, 1, p2, 0);\r
++              ui.addWire(p1, 1, or2, 0, new Point(250, 130), new Point(140, 185), new Point(140, 197.5));\r
++              ui.addWire(p2, 1, or1, 1, new Point(250, 185), new Point(140, 130), new Point(140, 117.5));\r
++              ui.addWire(p1, 2, o1, 0);\r
++              ui.addWire(p2, 2, o2, 0);\r
++      }\r
+ }
@@@ -49,33 -50,33 +50,34 @@@ public class LogicUIStandalon
        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
-                               timeline.executeUntil(timeline.laterThan(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
+ //            Thread simulationThread = new Thread(() ->\r
+ //            {\r
+ //                    while (running.get())\r
+ //                    {\r
+ //                            // always execute to keep timeline from "hanging behind" for too long\r
++//                            timeline.executeUntil(timeline.laterThan(System.currentTimeMillis()), System.currentTimeMillis() + 10);         \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
  \r
                shell.open();\r
                while (!shell.isDisposed())\r
index ff674c5,0000000..7bec909
mode 100644,000000..100644
--- /dev/null
@@@ -1,96 -1,0 +1,6 @@@
- import java.util.ArrayList;\r
- import java.util.Collections;\r
- import java.util.HashMap;\r
- import java.util.List;\r
- import java.util.Map;\r
\r
- import era.mi.logic.components.ManualSwitch;\r
- import era.mi.logic.timeline.Timeline;\r
- import era.mi.logic.types.Bit;\r
- import era.mi.logic.wires.Wire.ReadEnd;\r
- import era.mi.logic.wires.Wire.ReadWriteEnd;\r
- import net.haspamelodica.swt.helper.gcs.GeneralGC;\r
- import net.haspamelodica.swt.helper.swtobjectwrappers.Font;\r
- import net.haspamelodica.swt.helper.swtobjectwrappers.Point;\r
- import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;\r
\r
- public class GUIManualSwitch extends ManualSwitch implements BasicGUIComponent\r
 +package era.mi.gui.components;\r
 +\r
-       private static final Map<Bit, String> bitNames;\r
-       static\r
-       {\r
-               Map<Bit, String> bitNamesModifiable = new HashMap<>();\r
-               bitNamesModifiable.put(Bit.ONE, "1");\r
-               bitNamesModifiable.put(Bit.ZERO, "0");\r
-               bitNamesModifiable.put(Bit.Z, "Z");\r
-               bitNamesModifiable.put(Bit.U, "U");\r
-               bitNamesModifiable.put(Bit.X, "X");\r
-               bitNames = Collections.unmodifiableMap(bitNamesModifiable);\r
-       }\r
\r
-       private final ReadEnd we;\r
-       private final List<ReadEnd> connectedWireEnds;\r
-       private final List<Point> wireEndConnectionPoints;\r
\r
-       public GUIManualSwitch(Timeline timeline, ReadWriteEnd output)\r
-       {\r
-               super(timeline, output);\r
\r
-               this.we = output;\r
\r
-               List<ReadEnd> connectedWireEndsModifiable = new ArrayList<>();\r
-               List<Point> wireEndConnectionPointsModifiable = new ArrayList<>();\r
\r
-               connectedWireEndsModifiable.add(output);\r
-               wireEndConnectionPointsModifiable.add(new Point(20, 7.5));\r
\r
-               this.connectedWireEnds = Collections.unmodifiableList(connectedWireEndsModifiable);\r
-               this.wireEndConnectionPoints = Collections.unmodifiableList(wireEndConnectionPointsModifiable);\r
-       }\r
\r
-       @Override\r
-       public Rectangle getBounds()\r
-       {\r
-               return new Rectangle(0, 0, 20, 15);\r
-       }\r
\r
-       @Override\r
-       public void render(GeneralGC gc)\r
-       {\r
-               gc.drawRectangle(0, 0, 20, 15);\r
-               String label = bitNames.get(we.getValue());\r
-               Font oldFont = gc.getFont();\r
-               Font labelFont = new Font(oldFont.getName(), 6, oldFont.getStyle());\r
-               gc.setFont(labelFont);\r
-               Point textExtent = gc.textExtent(label);\r
-               gc.drawText(label, 10 - textExtent.x / 2, 7.5 - textExtent.y / 2, true);\r
-               gc.setFont(oldFont);\r
-       }\r
\r
-       @Override\r
-       public boolean clicked(double x, double y)\r
-       {\r
-               timeline.addEvent((e) -> toggle(), (int) (System.currentTimeMillis() - timeline.getSimulationTime()));\r
-               return true;\r
-       }\r
\r
-       @Override\r
-       public int getConnectedWireEndsCount()\r
-       {\r
-               return connectedWireEnds.size();\r
-       }\r
\r
-       @Override\r
-       public ReadEnd getConnectedWireEnd(int connectionIndex)\r
-       {\r
-               return connectedWireEnds.get(connectionIndex);\r
-       }\r
++public class GUIManualSwitch\r
 +{\r
-       @Override\r
-       public Point getWireEndConnectionPoint(int connectionI)\r
-       {\r
-               return wireEndConnectionPoints.get(connectionI);\r
-       }\r
- }
 +\r
++}\r