Added getter for submodel interface pins in GUIand and GUI_rsLatch
[Mograsim.git] / net.mograsim.logic.ui / src / net / mograsim / logic / ui / model / components / mi / nandbased / GUI_rsLatch.java
1 package net.mograsim.logic.ui.model.components.mi.nandbased;
2
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;
10
11 public class GUI_rsLatch extends SubmodelComponent
12 {
13         private final Pin pin_S;
14         private final Pin pin_R;
15         private final Pin pinQ;
16         private final Pin pin_Q;
17
18         public GUI_rsLatch(ViewModelModifiable model)
19         {
20                 super(model, "_rsLatch");
21                 setSize(35, 25);
22                 setSubmodelScale(.2);
23
24                 Pin _S = addSubmodelInterface(1, 0, 5);
25                 Pin _R = addSubmodelInterface(1, 0, 20);
26                 Pin Q = addSubmodelInterface(1, 35, 5);
27                 Pin _Q = addSubmodelInterface(1, 35, 20);
28
29                 this.pin_S = getSupermodelPin(_S);
30                 this.pin_R = getSupermodelPin(_R);
31                 this.pinQ = getSupermodelPin(Q);
32                 this.pin_Q = getSupermodelPin(_Q);
33
34                 initSubmodelComponents(_S, _R, Q, _Q);
35         }
36
37         @SuppressWarnings("unused") // for GUIWires being created
38         private void initSubmodelComponents(Pin _S, Pin _R, Pin Q, Pin _Q)
39         {
40
41                 GUINandGate nand1 = new GUINandGate(submodelModifiable, 1);
42                 nand1.moveTo(80, 20);
43                 GUINandGate nand2 = new GUINandGate(submodelModifiable, 1);
44                 nand2.moveTo(80, 85);
45
46                 WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1);
47                 cp1.moveTo(120, 30);
48                 WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1);
49                 cp2.moveTo(120, 95);
50
51                 new GUIWire(submodelModifiable, _S, nand1.getInputPins().get(0));
52                 new GUIWire(submodelModifiable, _R, nand2.getInputPins().get(1));
53                 new GUIWire(submodelModifiable, nand1.getOutputPin(), cp1.getPin());
54                 new GUIWire(submodelModifiable, nand2.getOutputPin(), cp2.getPin());
55                 new GUIWire(submodelModifiable, cp1.getPin(), nand2.getInputPins().get(0), new Point(120, 50), new Point(60, 75),
56                                 new Point(60, 90));
57                 new GUIWire(submodelModifiable, cp2.getPin(), nand1.getInputPins().get(1), new Point(120, 75), new Point(60, 50),
58                                 new Point(60, 35));
59                 new GUIWire(submodelModifiable, cp1.getPin(), Q, new Point(150, 30), new Point(150, 25));
60                 new GUIWire(submodelModifiable, cp2.getPin(), _Q, new Point(150, 95), new Point(150, 100));
61         }
62
63         public Pin getPin_S()
64         {
65                 return pin_S;
66         }
67
68         public Pin getPin_R()
69         {
70                 return pin_R;
71         }
72
73         public Pin getPinQ()
74         {
75                 return pinQ;
76         }
77
78         public Pin getPin_Q()
79         {
80                 return pin_Q;
81         }
82 }