1 package net.mograsim.logic.ui.examples;
3 import java.util.ArrayList;
6 import net.mograsim.logic.ui.SimpleLogicUIStandalone;
7 import net.mograsim.logic.ui.model.ViewModelModifiable;
8 import net.mograsim.logic.ui.model.components.atomic.GUIBitDisplay;
9 import net.mograsim.logic.ui.model.components.atomic.GUIManualSwitch;
10 import net.mograsim.logic.ui.model.components.submodels.SubmodelComponent;
11 import net.mograsim.logic.ui.model.wires.GUIWire;
12 import net.mograsim.logic.ui.model.wires.Pin;
13 import net.mograsim.logic.ui.serializing.SubmodelComponentDeserializer;
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 SubmodelComponent comp = SubmodelComponentDeserializer.create(model, "components/am2901/GUIAm2901.json");
27 // guess which pins are outputs and which are inputs
28 List<String> inputPinNames = new ArrayList<>();
29 List<String> outputPinNames = new ArrayList<>();
30 for (Pin p : comp.getPins().values())
32 inputPinNames.add(p.name);
34 outputPinNames.add(p.name);
37 for (int i = 0; i < inputPinNames.size(); i++)
39 GUIManualSwitch sw = new GUIManualSwitch(model);
41 new GUIWire(model, comp.getPin(inputPinNames.get(i)), sw.getOutputPin());
43 for (int i = 0; i < outputPinNames.size(); i++)
45 GUIBitDisplay bd = new GUIBitDisplay(model);
46 bd.moveTo(200, 20 * i);
47 new GUIWire(model, comp.getPin(outputPinNames.get(i)), bd.getInputPin());