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=90ceb285f818a2c67e13cc09597dea19b9c70621;hb=a9c80655950119176572052903dd95304ed1c141;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..90ceb285 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 @@ -10,6 +10,8 @@ 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; @@ -30,14 +32,20 @@ public class GUIComponentTestbench // 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) - inputPinNames.add(p.name); - else - outputPinNames.add(p.name); - - outputPinNames.remove("R=0"); - inputPinNames.add("R=0"); + 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); inputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY))); outputPinNames.sort(Comparator.comparing(comp::getPin, Comparator.comparing(Pin::getRelY))); @@ -45,15 +53,23 @@ public class GUIComponentTestbench comp.moveTo(100, 0); for (int i = 0; i < inputPinNames.size(); i++) { - GUIManualSwitch sw = new GUIManualSwitch(model); - sw.moveTo(0, 20 * i); - new GUIWire(model, comp.getPin(inputPinNames.get(i)), sw.getOutputPin()); + String pinName = inputPinNames.get(i); + if (comp.getPin(pinName).logicWidth == 1) + { + GUIManualSwitch sw = new GUIManualSwitch(model); + sw.moveTo(0, 20 * i); + new GUIWire(model, comp.getPin(pinName), sw.getOutputPin()); + } } for (int i = 0; i < outputPinNames.size(); i++) { - GUIBitDisplay bd = new GUIBitDisplay(model); - bd.moveTo(200, 20 * i); - new GUIWire(model, comp.getPin(outputPinNames.get(i)), bd.getInputPin()); + String pinName = outputPinNames.get(i); + if (comp.getPin(pinName).logicWidth == 1) + { + GUIBitDisplay bd = new GUIBitDisplay(model); + bd.moveTo(200, 20 * i); + new GUIWire(model, comp.getPin(pinName), bd.getInputPin()); + } } } } \ No newline at end of file