From: Daniel Kirschten Date: Wed, 5 Jun 2019 17:17:14 +0000 (+0200) Subject: Updated GUIfulladder to SimpleRectangularSubmodelComponent X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;ds=sidebyside;h=5306a9be5a7d08a765aafdfbd466d302d560009b;p=Mograsim.git Updated GUIfulladder to SimpleRectangularSubmodelComponent --- 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 8b8cef62..95177b7b 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.GUIdlatch4; +import net.mograsim.logic.ui.model.components.mi.nandbased.GUIfulladder; 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 GUIdlatch4(model); + SimpleRectangularSubmodelComponent comp = new GUIfulladder(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/GUIfulladder.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIfulladder.java index 0e3a8fd9..111b644d 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIfulladder.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUIfulladder.java @@ -1,83 +1,49 @@ 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; -public class GUIfulladder extends SubmodelComponent +public class GUIfulladder extends SimpleRectangularSubmodelComponent { - private final Pin pinA; - private final Pin pinB; - private final Pin pinC; - private final Pin pinY; - private final Pin pinZ; - public GUIfulladder(ViewModelModifiable model) { - super(model, "GUIfulladder"); + super(model, 1, "GUIfulladder"); setSize(50, 40); setSubmodelScale(.4); - - Pin A = addSubmodelInterface(1, 0, 5); - Pin B = addSubmodelInterface(1, 0, 20); - Pin C = addSubmodelInterface(1, 0, 35); - Pin Y = addSubmodelInterface(1, 50, 5); - Pin Z = addSubmodelInterface(1, 50, 20); - - this.pinA = getSupermodelPin(A); - this.pinB = getSupermodelPin(B); - this.pinC = getSupermodelPin(C); - this.pinY = getSupermodelPin(Y); - this.pinZ = getSupermodelPin(Z); - - initSubmodelComponents(A, B, C, Y, Z); + setInputCount(3); + setOutputCount(2); + initSubmodelComponents(); } @SuppressWarnings("unused") // for GUIWires being created - private void initSubmodelComponents(Pin A, Pin B, Pin C, Pin Y, Pin Z) + private void initSubmodelComponents() { + Pin A = getInputSubmodelPins().get(0); + Pin B = getInputSubmodelPins().get(1); + Pin C = getInputSubmodelPins().get(2); + Pin Y = getOutputSubmodelPins().get(0); + Pin Z = getOutputSubmodelPins().get(1); + GUIhalfadder halfBC = new GUIhalfadder(submodelModifiable); GUIhalfadder halfAY = new GUIhalfadder(submodelModifiable); GUINandGate nandZ = new GUINandGate(submodelModifiable, 1); - halfAY.moveTo(55, 7.5); - halfBC.moveTo(10, 40); - nandZ.moveTo(100, 25); - - new GUIWire(submodelModifiable, A, halfAY.getPinA()); - new GUIWire(submodelModifiable, B, halfBC.getPinA());// , new Point(5, 50), new Point(5, 45)); - new GUIWire(submodelModifiable, C, halfBC.getPinB());// , new Point(5, 87.5), new Point(5, 60)); - new GUIWire(submodelModifiable, halfBC.getPinY(), halfAY.getPinB());// , new Point(50, 45), new Point(50, 27.5)); - new GUIWire(submodelModifiable, halfBC.getPin_Z(), nandZ.getInputPins().get(1)); - new GUIWire(submodelModifiable, halfAY.getPinY(), Y); - new GUIWire(submodelModifiable, halfAY.getPin_Z(), nandZ.getInputPins().get(0)); + halfAY.moveTo(45, 7.5); + halfBC.moveTo(5, 40); + nandZ.moveTo(57.5, 40); + + new GUIWire(submodelModifiable, A, halfAY.getInputPins().get(0), new Point[0]); + new GUIWire(submodelModifiable, B, halfBC.getInputPins().get(0)); + new GUIWire(submodelModifiable, C, halfBC.getInputPins().get(1)); + new GUIWire(submodelModifiable, halfBC.getOutputPins().get(0), halfAY.getInputPins().get(1)); + new GUIWire(submodelModifiable, halfBC.getOutputPins().get(1), nandZ.getInputPins().get(1), new Point[0]); + new GUIWire(submodelModifiable, halfAY.getOutputPins().get(0), Y, new Point[0]); + new GUIWire(submodelModifiable, halfAY.getOutputPins().get(1), nandZ.getInputPins().get(0), new Point(82.5, 22.5), + new Point(82.5, 35), new Point(52.5, 35), new Point(52.5, 45)); new GUIWire(submodelModifiable, nandZ.getOutputPin(), Z); } - - public Pin getPinA() - { - return pinA; - } - - public Pin getPinB() - { - return pinB; - } - - public Pin getPinC() - { - return pinC; - } - - public Pin getPinY() - { - return pinY; - } - - public Pin getPinZ() - { - return pinZ; - } } \ No newline at end of file