From 09197853bc44edb4fab75dccc8b870fd377e7df9 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Wed, 5 Jun 2019 17:38:36 +0200 Subject: [PATCH] Updated GUI_rsLatch to SimpleRectangularSubmodelComponent --- .../examples/SubmodelComponentTestbench.java | 4 +- .../components/mi/nandbased/GUI_rsLatch.java | 84 ++++++------------- 2 files changed, 28 insertions(+), 60 deletions(-) diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/SubmodelComponentTestbench.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/SubmodelComponentTestbench.java index 5de6912a..19416b7e 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/SubmodelComponentTestbench.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/SubmodelComponentTestbench.java @@ -5,7 +5,7 @@ import net.mograsim.logic.ui.model.ViewModelModifiable; import net.mograsim.logic.ui.model.components.GUIBitDisplay; import net.mograsim.logic.ui.model.components.GUIManualSwitch; import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent; -import net.mograsim.logic.ui.model.components.mi.nandbased.GUIhalfadder; +import net.mograsim.logic.ui.model.components.mi.nandbased.GUI_rsLatch; import net.mograsim.logic.ui.model.wires.GUIWire; public class SubmodelComponentTestbench @@ -18,7 +18,7 @@ public class SubmodelComponentTestbench @SuppressWarnings("unused") // for GUIWires being created public static void createTestbench(ViewModelModifiable model) { - SimpleRectangularSubmodelComponent comp = new GUIhalfadder(model); + SimpleRectangularSubmodelComponent comp = new GUI_rsLatch(model); comp.moveTo(100, 0); for (int i = 0; i < comp.getInputPins().size(); i++) diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java index 5e16c099..79315c90 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java @@ -3,80 +3,48 @@ package net.mograsim.logic.ui.model.components.mi.nandbased; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.mograsim.logic.ui.model.ViewModelModifiable; import net.mograsim.logic.ui.model.components.GUINandGate; -import net.mograsim.logic.ui.model.components.SubmodelComponent; +import net.mograsim.logic.ui.model.components.SimpleRectangularSubmodelComponent; import net.mograsim.logic.ui.model.wires.GUIWire; import net.mograsim.logic.ui.model.wires.Pin; import net.mograsim.logic.ui.model.wires.WireCrossPoint; -public class GUI_rsLatch extends SubmodelComponent +public class GUI_rsLatch extends SimpleRectangularSubmodelComponent { - private final Pin pin_S; - private final Pin pin_R; - private final Pin pinQ; - private final Pin pin_Q; - public GUI_rsLatch(ViewModelModifiable model) { - super(model, "_rsLatch"); - setSize(35, 25); - setSubmodelScale(.2); - - Pin _S = addSubmodelInterface(1, 0, 5); - Pin _R = addSubmodelInterface(1, 0, 20); - Pin Q = addSubmodelInterface(1, 35, 5); - Pin _Q = addSubmodelInterface(1, 35, 20); - - this.pin_S = getSupermodelPin(_S); - this.pin_R = getSupermodelPin(_R); - this.pinQ = getSupermodelPin(Q); - this.pin_Q = getSupermodelPin(_Q); - - initSubmodelComponents(_S, _R, Q, _Q); + super(model, 1, "_rsLatch"); + setSubmodelScale(.4); + setInputCount(2); + setOutputCount(2); + initSubmodelComponents(); } @SuppressWarnings("unused") // for GUIWires being created - private void initSubmodelComponents(Pin _S, Pin _R, Pin Q, Pin _Q) + private void initSubmodelComponents() { + Pin _S = getInputSubmodelPins().get(0); + Pin _R = getInputSubmodelPins().get(1); + Pin Q = getOutputSubmodelPins().get(0); + Pin _Q = getOutputSubmodelPins().get(1); + GUINandGate nand1 = new GUINandGate(submodelModifiable, 1); GUINandGate nand2 = new GUINandGate(submodelModifiable, 1); WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1); WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1); - nand1.moveTo(80, 20); - nand2.moveTo(80, 85); - cp1.moveTo(120, 30); - cp2.moveTo(120, 95); - - new GUIWire(submodelModifiable, _S, nand1.getInputPins().get(0)); - new GUIWire(submodelModifiable, _R, nand2.getInputPins().get(1)); - new GUIWire(submodelModifiable, nand1.getOutputPin(), cp1); - new GUIWire(submodelModifiable, nand2.getOutputPin(), cp2); - new GUIWire(submodelModifiable, cp1, nand2.getInputPins().get(0), new Point(120, 50), new Point(60, 75), - new Point(60, 90)); - new GUIWire(submodelModifiable, cp2, nand1.getInputPins().get(1), new Point(120, 75), new Point(60, 50), - new Point(60, 35)); - new GUIWire(submodelModifiable, cp1, Q, new Point(150, 30), new Point(150, 25)); - new GUIWire(submodelModifiable, cp2, _Q, new Point(150, 95), new Point(150, 100)); - } - - public Pin getPin_S() - { - return pin_S; - } - - public Pin getPin_R() - { - return pin_R; - } - - public Pin getPinQ() - { - return pinQ; - } - - public Pin getPin_Q() - { - return pin_Q; + nand1.moveTo(10, 7.5); + nand2.moveTo(40, 12.5); + cp1.moveTo(35, 17.5); + cp2.moveTo(65, 37.5); + + new GUIWire(submodelModifiable, _S, nand1.getInputPins().get(0), new Point[0]); + new GUIWire(submodelModifiable, _R, nand2.getInputPins().get(1), new Point(35, 37.5), new Point(35, 27.5)); + new GUIWire(submodelModifiable, nand1.getOutputPin(), cp1, new Point[0]); + new GUIWire(submodelModifiable, nand2.getOutputPin(), cp2, new Point(65, 22.5)); + new GUIWire(submodelModifiable, cp1, nand2.getInputPins().get(0), new Point[0]); + new GUIWire(submodelModifiable, cp2, nand1.getInputPins().get(1), new Point(65, 42.5), new Point(5, 42.5), new Point(5, 22.5)); + new GUIWire(submodelModifiable, cp1, Q, new Point(35, 17.5), new Point(35, 7.5), new Point(65, 7.5), new Point(65, 12.5)); + new GUIWire(submodelModifiable, cp2, _Q, new Point[0]); } } \ No newline at end of file -- 2.17.1