1 package net.mograsim.logic.ui.model.components.mi.nandbased;
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.ui.model.ViewModelModifiable;
5 import net.mograsim.logic.ui.model.components.GUINandGate;
6 import net.mograsim.logic.ui.model.components.SubmodelComponent;
7 import net.mograsim.logic.ui.model.wires.GUIWire;
8 import net.mograsim.logic.ui.model.wires.Pin;
9 import net.mograsim.logic.ui.model.wires.WireCrossPoint;
11 public class GUIdlatch extends SubmodelComponent
13 private final Pin pinD;
14 private final Pin pinE;
15 private final Pin pinQ;
16 private final Pin pin_Q;
18 public GUIdlatch(ViewModelModifiable model)
20 super(model, "GUIdlatch");
24 Pin D = addSubmodelInterface(1, 0, 5);
25 Pin E = addSubmodelInterface(1, 0, 20);
26 Pin Q = addSubmodelInterface(1, 35, 5);
27 Pin _Q = addSubmodelInterface(1, 35, 20);
29 this.pinD = getSupermodelPin(D);
30 this.pinE = getSupermodelPin(E);
31 this.pinQ = getSupermodelPin(Q);
32 this.pin_Q = getSupermodelPin(_Q);
34 initSubmodelComponents(D, E, Q, _Q);
37 @SuppressWarnings("unused") // for GUIWires being created
38 private void initSubmodelComponents(Pin D, Pin E, Pin Q, Pin _Q)
40 GUINandGate nand1 = new GUINandGate(submodelModifiable, 1);
41 GUINandGate nand2 = new GUINandGate(submodelModifiable, 1);
42 GUI_rsLatch _rsLatch = new GUI_rsLatch(submodelModifiable);
44 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
45 WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1);
47 nand1.moveTo(10, 7.5);
49 _rsLatch.moveTo(45, 7.5);
53 new GUIWire(submodelModifiable, D, nand1.getInputPins().get(0));
54 new GUIWire(submodelModifiable, E, cp1);
55 new GUIWire(submodelModifiable, cp1, nand1.getInputPins().get(1), new Point(5, 22.5));
56 new GUIWire(submodelModifiable, cp1, nand2.getInputPins().get(1));
57 new GUIWire(submodelModifiable, nand1.getOutputPin(), cp2);
58 new GUIWire(submodelModifiable, cp2, nand2.getInputPins().get(0), new Point(35, 30), new Point(10, 30), new Point(10, 40));
59 new GUIWire(submodelModifiable, cp2, _rsLatch.getPin_S(), new Point(35, 12.5));
60 new GUIWire(submodelModifiable, nand2.getOutputPin(), _rsLatch.getPin_R(), new Point(40, 45), new Point(40, 27.5));
61 new GUIWire(submodelModifiable, _rsLatch.getPinQ(), Q);
62 new GUIWire(submodelModifiable, _rsLatch.getPin_Q(), _Q, new Point(82.5, 27.5), new Point(82.5, 50));