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
@SuppressWarnings("unused") // for GUIWires being created
public static void createTestbench(ViewModelModifiable model)
{
- GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "GUIAm2901", "Am2901");
+ GUIComponent comp = IndirectGUIComponentCreator.createComponent(model,
+ "resource:net.mograsim.logic.model.am2900.Am2900Loader:/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<>();
for (Pin p : comp.getPins().values())
- if (p.getRelX() == 0)
+ if (p.usage == PinUsage.INPUT)
inputPinNames.add(p.name);
else
outputPinNames.add(p.name);
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