From 95177b52dc8e5d3364853a91388d46606bacc120 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Wed, 5 Jun 2019 18:52:29 +0200 Subject: [PATCH] Updated GUIdff to SimpleRectangularSubmodelComponent --- .../examples/SubmodelComponentTestbench.java | 4 +- .../model/components/mi/nandbased/GUIdff.java | 93 +++++++------------ 2 files changed, 33 insertions(+), 64 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 7563d443..3ca16c1c 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.GUInand3; +import net.mograsim.logic.ui.model.components.mi.nandbased.GUIdff; 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 GUInand3(model); + SimpleRectangularSubmodelComponent comp = new GUIdff(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/GUIdff.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdff.java index 484f61e9..ce4f4416 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdff.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIdff.java @@ -3,40 +3,30 @@ 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 GUIdff extends SubmodelComponent +public class GUIdff extends SimpleRectangularSubmodelComponent { - private final Pin pinC; - private final Pin pinD; - private final Pin pinQ; - private final Pin pin_Q; - public GUIdff(ViewModelModifiable model) { - super(model, "GUIdff"); - setSize(35, 25); + super(model, 1, "GUIdff"); setSubmodelScale(.2); - - Pin C = addSubmodelInterface(1, 0, 5); - Pin D = addSubmodelInterface(1, 0, 20); - Pin Q = addSubmodelInterface(1, 35, 5); - Pin _Q = addSubmodelInterface(1, 35, 20); - - this.pinC = getSupermodelPin(C); - this.pinD = getSupermodelPin(D); - this.pinQ = getSupermodelPin(Q); - this.pin_Q = getSupermodelPin(_Q); - - initSubmodelComponents(C, D, Q, _Q); + setInputCount(2); + setOutputCount(2); + initSubmodelComponents(); } @SuppressWarnings("unused") // for GUIWires being created - private void initSubmodelComponents(Pin C, Pin D, Pin Q, Pin _Q) + private void initSubmodelComponents() { + Pin C = getInputSubmodelPins().get(0); + Pin D = getInputSubmodelPins().get(1); + Pin Q = getOutputSubmodelPins().get(0); + Pin _Q = getOutputSubmodelPins().get(1); + GUI_rsLatch _rsLatch1 = new GUI_rsLatch(submodelModifiable); GUInand3 nand3 = new GUInand3(submodelModifiable); GUINandGate nand2 = new GUINandGate(submodelModifiable, 1); @@ -47,50 +37,29 @@ public class GUIdff extends SubmodelComponent WireCrossPoint cp3 = new WireCrossPoint(submodelModifiable, 1); WireCrossPoint cp4 = new WireCrossPoint(submodelModifiable, 1); - _rsLatch1.moveTo(40, 5); + _rsLatch1.moveTo(40, 10); nand3.moveTo(40, 40); - nand2.moveTo(40, 85); - _rsLatch2.moveTo(120, 35); + nand2.moveTo(120, 60); + _rsLatch2.moveTo(120, 30); cp1.moveTo(10, 25); cp2.moveTo(20, 65); cp3.moveTo(100, 35); - cp4.moveTo(100, 55); + cp4.moveTo(100, 45); - new GUIWire(submodelModifiable, C, cp1); - new GUIWire(submodelModifiable, cp1, _rsLatch1.getPin_R()); - new GUIWire(submodelModifiable, cp1, nand3.getPinB(), new Point(10, 55)); - new GUIWire(submodelModifiable, D, nand2.getInputPins().get(1)); - new GUIWire(submodelModifiable, nand2.getOutputPin(), cp2, new Point(65, 95), new Point(65, 75), new Point(20, 75)); - new GUIWire(submodelModifiable, cp2, _rsLatch1.getPin_S(), new Point(20, 10)); - new GUIWire(submodelModifiable, cp2, nand3.getPinC()); - new GUIWire(submodelModifiable, _rsLatch1.getPin_Q(), cp3, new Point(100, 25)); - new GUIWire(submodelModifiable, cp3, nand3.getPinA(), new Point(30, 35), new Point(30, 45)); - new GUIWire(submodelModifiable, cp3, _rsLatch2.getPin_S(), new Point(100, 40)); - new GUIWire(submodelModifiable, nand3.getPinY(), cp4); - new GUIWire(submodelModifiable, cp4, _rsLatch2.getPin_R()); - new GUIWire(submodelModifiable, cp4, nand2.getInputPins().get(0), new Point(100, 80), new Point(30, 80), - new Point(30, 90)); - new GUIWire(submodelModifiable, _rsLatch2.getPinQ(), Q, new Point(165, 40), new Point(165, 25)); - new GUIWire(submodelModifiable, _rsLatch2.getPin_Q(), _Q, new Point(165, 55), new Point(165, 100)); - } - - public Pin getPinC() - { - return pinC; - } - - public Pin getPinD() - { - return pinD; - } - - public Pin getPinQ() - { - return pinQ; - } - - public Pin getPin_Q() - { - return pin_Q; + new GUIWire(submodelModifiable, C, cp1, new Point[0]); + new GUIWire(submodelModifiable, cp1, _rsLatch1.getInputPins().get(1), new Point[0]); + new GUIWire(submodelModifiable, cp1, nand3.getInputPins().get(1), new Point(10, 55)); + new GUIWire(submodelModifiable, D, nand2.getInputPins().get(1), new Point[0]); + new GUIWire(submodelModifiable, nand2.getOutputPin(), cp2, new Point(145, 70), new Point(145, 85), new Point(20, 85)); + new GUIWire(submodelModifiable, cp2, _rsLatch1.getInputPins().get(0), new Point(20, 15)); + new GUIWire(submodelModifiable, cp2, nand3.getInputPins().get(2), new Point[0]); + new GUIWire(submodelModifiable, _rsLatch1.getOutputPins().get(1), cp3, new Point(100, 25)); + new GUIWire(submodelModifiable, cp3, nand3.getInputPins().get(0), new Point(30, 35), new Point(30, 45)); + new GUIWire(submodelModifiable, cp3, _rsLatch2.getInputPins().get(0), new Point[0]); + new GUIWire(submodelModifiable, nand3.getOutputPins().get(0), cp4, new Point[0]); + new GUIWire(submodelModifiable, cp4, _rsLatch2.getInputPins().get(1), new Point[0]); + new GUIWire(submodelModifiable, cp4, nand2.getInputPins().get(0), new Point(100, 65)); + new GUIWire(submodelModifiable, _rsLatch2.getOutputPins().get(0), Q); + new GUIWire(submodelModifiable, _rsLatch2.getOutputPins().get(1), _Q); } } \ No newline at end of file -- 2.17.1