Make Tests compatible again
[Mograsim.git] / net.mograsim.logic.model.am2900 / src / net / mograsim / logic / model / examples / GUIComponentTestbench.java
index 1c17ac3..2fe568e 100644 (file)
@@ -1,7 +1,6 @@
 package net.mograsim.logic.model.examples;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Comparator;
 import java.util.List;
 
@@ -10,10 +9,9 @@ import net.mograsim.logic.model.model.ViewModelModifiable;
 import net.mograsim.logic.model.model.components.GUIComponent;
 import net.mograsim.logic.model.model.components.atomic.GUIBitDisplay;
 import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch;
-import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent;
-import net.mograsim.logic.model.model.components.atomic.SimpleRectangularHardcodedGUIComponent.Usage;
 import net.mograsim.logic.model.model.wires.GUIWire;
 import net.mograsim.logic.model.model.wires.Pin;
+import net.mograsim.logic.model.model.wires.PinUsage;
 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
 
 public class GUIComponentTestbench
@@ -26,34 +24,20 @@ public class GUIComponentTestbench
        @SuppressWarnings("unused") // for GUIWires being created
        public static void createTestbench(ViewModelModifiable model)
        {
-               GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "file:components/am2910/GUIAm2910.json", "Am2910");
-//             GUIComponent comp = new GUImux4_12(model, "c");
+               GUIComponent comp = IndirectGUIComponentCreator.createComponent(model,
+                               "resource:net.mograsim.logic.model.am2900.Am2900Activator:/components/GUIAm2900.json");
 
-               // guess which pins are outputs and which are inputs
-               // TODO this code exists four times... but it seems too "hacky" to put it in a helper class
                List<String> inputPinNames = new ArrayList<>();
                List<String> outputPinNames = new ArrayList<>();
-               if (comp instanceof SimpleRectangularHardcodedGUIComponent)
-               {
-                       SimpleRectangularHardcodedGUIComponent compCasted = (SimpleRectangularHardcodedGUIComponent) comp;
-                       for (Pin p : comp.getPins().values())
-                               if (compCasted.getPinUsage(p) == Usage.INPUT)
-                                       inputPinNames.add(p.name);
-                               else
-                                       outputPinNames.add(p.name);
-               } else
-                       for (Pin p : comp.getPins().values())
-                               if (p.getRelX() == 0)
-                                       inputPinNames.add(p.name);
-                               else
-                                       outputPinNames.add(p.name);
+               for (Pin p : comp.getPins().values())
+                       if (p.usage == PinUsage.INPUT)
+                               inputPinNames.add(p.name);
+                       else
+                               outputPinNames.add(p.name);
 
                inputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY)));
                outputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY)));
 
-               inputPinNames = Arrays.asList("C", "D", "_RLD", "_CC", "_CCEN", "I", "CI");
-               outputPinNames = Arrays.asList("_FULL", "_PL", "_MAP", "_VECT", "Y");
-
                comp.moveTo(100, 0);
                for (int i = 0; i < inputPinNames.size(); i++)
                {