X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fexamples%2FGUIComponentTestbench.java;h=6803a500f78b00ca2a5315360e4a22e31247e088;hb=d07d97764c8f41ff26f76e59d4d2f1789c2bcc9e;hp=45f538cc5dbc44607dffd4ca85f34cbcbfb3927b;hpb=422779cc67647f9495b06f5fb84e9b27de95e0c2;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java index 45f538cc..6803a500 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/GUIComponentTestbench.java @@ -9,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 @@ -25,27 +24,15 @@ public class GUIComponentTestbench @SuppressWarnings("unused") // for GUIWires being created public static void createTestbench(ViewModelModifiable model) { - GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, - "class:net.mograsim.logic.model.am2900.components.am2904.GUIAm2904RegCTInstrDecode"); + GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "file:components/am2904/GUIAm2904.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 inputPinNames = new ArrayList<>(); List 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)));