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=f2acc618f90e6317d47ab6a23bd63da0623506c6;hpb=e3d7905ec00f7515817ab9921724fd0eb51f79e7;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 f2acc618..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 @@ -5,13 +5,14 @@ import java.util.Comparator; import java.util.List; import net.mograsim.logic.model.SimpleLogicUIStandalone; -import net.mograsim.logic.model.am2900.components.am2910.GUIAm2910InstrPLA; 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.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 { @@ -23,37 +24,33 @@ public class GUIComponentTestbench @SuppressWarnings("unused") // for GUIWires being created public static void createTestbench(ViewModelModifiable model) { -// GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "GUIAm2901", "Am2901"); - GUIComponent comp = new GUIAm2910InstrPLA(model, "Am2910"); + 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<>(); for (Pin p : comp.getPins().values()) - if (p.getRelX() == 0) + if (p.usage == PinUsage.INPUT) inputPinNames.add(p.name); else outputPinNames.add(p.name); - outputPinNames.remove("R=0"); - inputPinNames.add("R=0"); - 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++) { - GUIManualSwitch sw = new GUIManualSwitch(model); + String pinName = inputPinNames.get(i); + GUIManualSwitch sw = new GUIManualSwitch(model, comp.getPin(pinName).logicWidth); sw.moveTo(0, 20 * i); - new GUIWire(model, comp.getPin(inputPinNames.get(i)), sw.getOutputPin()); + new GUIWire(model, comp.getPin(pinName), sw.getOutputPin()); } for (int i = 0; i < outputPinNames.size(); i++) { - GUIBitDisplay bd = new GUIBitDisplay(model); + String pinName = outputPinNames.get(i); + GUIBitDisplay bd = new GUIBitDisplay(model, comp.getPin(pinName).logicWidth); bd.moveTo(200, 20 * i); - new GUIWire(model, comp.getPin(outputPinNames.get(i)), bd.getInputPin()); + new GUIWire(model, comp.getPin(pinName), bd.getInputPin()); } } } \ No newline at end of file