1 package net.mograsim.logic.model.model.components.mi.nandbased;
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.model.model.ViewModelModifiable;
5 import net.mograsim.logic.model.model.components.atomic.GUINandGate;
6 import net.mograsim.logic.model.model.components.submodels.SimpleRectangularSubmodelComponent;
7 import net.mograsim.logic.model.model.wires.GUIWire;
8 import net.mograsim.logic.model.model.wires.Pin;
9 import net.mograsim.logic.model.model.wires.WireCrossPoint;
10 import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator;
11 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandler;
12 import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic.DelegatingAtomicHighLevelStateHandler;
14 public class GUIdlatch extends SimpleRectangularSubmodelComponent
16 public GUIdlatch(ViewModelModifiable model)
21 public GUIdlatch(ViewModelModifiable model, String name)
23 super(model, 1, "GUIdlatch", name);
25 setInputPins("D", "E");
26 setOutputPins("Q", "_Q");
27 initSubmodelComponents();
30 @SuppressWarnings("unused") // for GUIWires being created
31 private void initSubmodelComponents()
33 Pin D = getSubmodelPin("D");
34 Pin E = getSubmodelPin("E");
35 Pin Q = getSubmodelPin("Q");
36 Pin _Q = getSubmodelPin("_Q");
38 GUINandGate nand1 = new GUINandGate(submodelModifiable, 1);
39 GUINandGate nand2 = new GUINandGate(submodelModifiable, 1);
40 GUI_rsLatch _rsLatch = new GUI_rsLatch(submodelModifiable);
42 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
43 WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1);
45 nand1.moveTo(10, 2.5);
46 nand2.moveTo(15, 27.5);
47 _rsLatch.moveTo(45, 7.5);
48 cp1.moveCenterTo(5, 37.5);
49 cp2.moveCenterTo(35, 12.5);
51 new GUIWire(submodelModifiable, D, nand1.getPin("A"));
52 new GUIWire(submodelModifiable, E, cp1, new Point[0]);
53 new GUIWire(submodelModifiable, cp1, nand1.getPin("B"), new Point(5, 17.5));
54 new GUIWire(submodelModifiable, cp1, nand2.getPin("B"), new Point(5, 42.5));
55 new GUIWire(submodelModifiable, nand1.getPin("Y"), cp2, new Point[0]);
56 new GUIWire(submodelModifiable, cp2, nand2.getPin("A"), new Point(35, 25), new Point(10, 25), new Point(10, 32.5));
57 new GUIWire(submodelModifiable, cp2, _rsLatch.getPin("_S"), new Point[0]);
58 new GUIWire(submodelModifiable, nand2.getPin("Y"), _rsLatch.getPin("_R"), new Point(40, 37.5), new Point(40, 22.5));
59 new GUIWire(submodelModifiable, _rsLatch.getPin("Q"), Q, new Point[0]);
60 new GUIWire(submodelModifiable, _rsLatch.getPin("_Q"), _Q);
62 StandardHighLevelStateHandler highLevelStateHandler = new StandardHighLevelStateHandler(this);
63 highLevelStateHandler.addAtomicHighLevelState("q", DelegatingAtomicHighLevelStateHandler::new).set(_rsLatch, "q");
64 setHighLevelStateHandler(highLevelStateHandler);
69 IndirectGUIComponentCreator.setComponentSupplier(GUIdlatch.class.getCanonicalName(), (m, p, n) -> new GUIdlatch(m, n));