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.atomic.GUIBitDisplay;
9 import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch;
10 import net.mograsim.logic.model.model.components.submodels.SubmodelComponent;
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.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 // TODO this code exists three times... but it seems too "hacky" to put it in a helper class
29 List<String> inputPinNames = new ArrayList<>();
30 List<String> outputPinNames = new ArrayList<>();
31 for (Pin p : comp.getPins().values())
33 inputPinNames.add(p.name);
35 outputPinNames.add(p.name);
38 for (int i = 0; i < inputPinNames.size(); i++)
40 GUIManualSwitch sw = new GUIManualSwitch(model);
42 new GUIWire(model, comp.getPin(inputPinNames.get(i)), sw.getOutputPin());
44 for (int i = 0; i < outputPinNames.size(); i++)
46 GUIBitDisplay bd = new GUIBitDisplay(model);
47 bd.moveTo(200, 20 * i);
48 new GUIWire(model, comp.getPin(outputPinNames.get(i)), bd.getInputPin());