1 package net.mograsim.logic.model.examples;
3 import java.util.ArrayList;
6 import net.mograsim.logic.model.SimpleLogicUIStandalone;
7 import net.mograsim.logic.model.model.ViewModelModifiable;
8 import net.mograsim.logic.model.model.components.GUIComponent;
9 import net.mograsim.logic.model.model.components.atomic.GUIBitDisplay;
10 import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch;
11 import net.mograsim.logic.model.model.wires.GUIWire;
12 import net.mograsim.logic.model.model.wires.Pin;
13 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
15 public class SubmodelComponentTestbench
17 public static void main(String[] args)
19 SimpleLogicUIStandalone.executeVisualisation(SubmodelComponentTestbench::createTestbench);
22 @SuppressWarnings("unused") // for GUIWires being created
23 public static void createTestbench(ViewModelModifiable model)
25 GUIComponent comp = IndirectGUIComponentCreator.createComponent(model, "GUIAm2901", "Am2901");
27 // guess which pins are outputs and which are inputs
28 // TODO this code exists three times... but it seems too "hacky" to put it in a helper class
29 // TODO sort pins correctly - use Y coordinate
30 List<String> inputPinNames = new ArrayList<>();
31 List<String> outputPinNames = new ArrayList<>();
32 for (Pin p : comp.getPins().values())
34 inputPinNames.add(p.name);
36 outputPinNames.add(p.name);
39 for (int i = 0; i < inputPinNames.size(); i++)
41 GUIManualSwitch sw = new GUIManualSwitch(model);
43 new GUIWire(model, comp.getPin(inputPinNames.get(i)), sw.getOutputPin());
45 for (int i = 0; i < outputPinNames.size(); i++)
47 GUIBitDisplay bd = new GUIBitDisplay(model);
48 bd.moveTo(200, 20 * i);
49 new GUIWire(model, comp.getPin(outputPinNames.get(i)), bd.getInputPin());