1 package net.mograsim.logic.model.examples;
3 import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
4 import net.mograsim.logic.model.SimpleLogicUIStandalone;
5 import net.mograsim.logic.model.model.LogicModelModifiable;
6 import net.mograsim.logic.model.model.components.atomic.ModelManualSwitch;
7 import net.mograsim.logic.model.model.components.atomic.ModelNotGate;
8 import net.mograsim.logic.model.model.components.atomic.ModelOrGate;
9 import net.mograsim.logic.model.model.wires.ModelWire;
10 import net.mograsim.logic.model.model.wires.ModelWireCrossPoint;
12 public class RSLatchExample
14 public static void main(String[] args)
16 SimpleLogicUIStandalone.executeVisualisation(RSLatchExample::createRSLatchExample);
19 @SuppressWarnings("unused") // for Wires being created
20 public static void createRSLatchExample(LogicModelModifiable model)
22 ModelManualSwitch rIn = new ModelManualSwitch(model, 1);
24 ModelManualSwitch sIn = new ModelManualSwitch(model, 1);
27 ModelOrGate or1 = new ModelOrGate(model, 1);
28 or1.moveTo(160, 102.5);
29 new ModelWire(model, rIn.getOutputPin(), or1.getPin("A"));
31 ModelOrGate or2 = new ModelOrGate(model, 1);
32 or2.moveTo(160, 192.5);
33 new ModelWire(model, sIn.getOutputPin(), or2.getPin("B"));
35 ModelNotGate not1 = new ModelNotGate(model, 1);
36 not1.moveTo(200, 107.5);
37 new ModelWire(model, or1.getPin("Y"), not1.getPin("A"));
39 ModelNotGate not2 = new ModelNotGate(model, 1);
40 not2.moveTo(200, 197.5);
41 new ModelWire(model, or2.getPin("Y"), not2.getPin("A"));
43 ModelWireCrossPoint p1 = new ModelWireCrossPoint(model, 1);
44 p1.moveCenterTo(250, 112.5);
45 new ModelWire(model, not1.getPin("Y"), p1);
46 new ModelWire(model, p1, or2.getPin("A"), new Point(250, 130), new Point(140, 185), new Point(140, 197.5));
48 ModelWireCrossPoint p2 = new ModelWireCrossPoint(model, 1);
49 p2.moveCenterTo(250, 202.5);
50 new ModelWire(model, not2.getPin("Y"), p2);
51 new ModelWire(model, p2, or1.getPin("B"), new Point(250, 185), new Point(140, 130), new Point(140, 117.5));
53 ModelWireCrossPoint o1 = new ModelWireCrossPoint(model, 1);
54 o1.moveCenterTo(270, 112.5);
55 new ModelWire(model, p1, o1);
57 ModelWireCrossPoint o2 = new ModelWireCrossPoint(model, 1);
58 o2.moveCenterTo(270, 202.5);
59 new ModelWire(model, p2, o2);