X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fexamples%2FSubmodelComponentTestbench.java;h=27e3d166c503e5a5e464ef9e3207ac12c155efb6;hb=ca786d4adb85001128a2440154d028632a22e3b8;hp=6a42d704a3d60602687c549cde2844af450ca32a;hpb=c5c0d07286a29994a11ba8b01eaffb21964b6c1b;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/SubmodelComponentTestbench.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/SubmodelComponentTestbench.java index 6a42d704..27e3d166 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/SubmodelComponentTestbench.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/SubmodelComponentTestbench.java @@ -1,18 +1,17 @@ package net.mograsim.logic.model.examples; -import java.io.IOException; -import java.io.UncheckedIOException; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import net.mograsim.logic.model.SimpleLogicUIStandalone; 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.submodels.SubmodelComponent; import net.mograsim.logic.model.model.wires.GUIWire; import net.mograsim.logic.model.model.wires.Pin; -import net.mograsim.logic.model.serializing.SubmodelComponentSerializer; +import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; public class SubmodelComponentTestbench { @@ -24,18 +23,10 @@ public class SubmodelComponentTestbench @SuppressWarnings("unused") // for GUIWires being created public static void createTestbench(ViewModelModifiable model) { - SubmodelComponent comp; - try - { - comp = SubmodelComponentSerializer.deserialize(model, "components/am2901/GUIAm2901.json"); - } - catch (IOException e) - { - throw new UncheckedIOException(e); - } + GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "GUIAm2901", "Am2901"); // guess which pins are outputs and which are inputs - // TODO this code exists three times... but it seems too "hacky" to put it in a helper class + // 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<>(); for (Pin p : comp.getPins().values()) @@ -44,6 +35,9 @@ public class SubmodelComponentTestbench 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))); + comp.moveTo(100, 0); for (int i = 0; i < inputPinNames.size(); i++) {