From: Daniel Kirschten Date: Mon, 3 Jun 2019 21:52:51 +0000 (+0200) Subject: Implemented GUI_rsLatch X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=3400148c81a0f9713ecb09d9a2c4554a4c4c7d8d;hp=e670d6ab4c81bfb65640333a3116ecb1357ad3fa;p=Mograsim.git Implemented GUI_rsLatch --- diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/ModularAm2901Example.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/ModularAm2901Example.java new file mode 100644 index 00000000..3c731170 --- /dev/null +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/examples/ModularAm2901Example.java @@ -0,0 +1,42 @@ +package net.mograsim.logic.ui.examples; + +import net.mograsim.logic.ui.SimpleLogicUIStandalone; +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.SubmodelComponent; +import net.mograsim.logic.ui.model.components.mi.nandbased.GUI_rsLatch; +import net.mograsim.logic.ui.model.wires.GUIWire; +import net.mograsim.logic.ui.modeladapter.LogicModelParameters; + +public class ModularAm2901Example +{ + public static void main(String[] args) + { + LogicModelParameters params = new LogicModelParameters(); + params.gateProcessTime = 1; + params.wireTravelTime = 1; + SimpleLogicUIStandalone.executeVisualisation(ModularAm2901Example::createAm2901Example, params); + } + + @SuppressWarnings("unused") // for GUIWires being created + public static void createAm2901Example(ViewModelModifiable model) + { + SubmodelComponent comp = new GUI_rsLatch(model); + int inputCount = 2; + + comp.moveTo(100, 0); + for (int i = 0; i < inputCount; i++) + { + GUIManualSwitch sw = new GUIManualSwitch(model); + sw.moveTo(0, 20 * i); + new GUIWire(model, comp.getPins().get(i), sw.getOutputPin()); + } + for (int i = inputCount; i < comp.getPins().size(); i++) + { + GUIBitDisplay bd = new GUIBitDisplay(model); + bd.moveTo(200, 20 * (i - inputCount)); + new GUIWire(model, comp.getPins().get(i), bd.getInputPin()); + } + } +} \ No newline at end of file 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 new file mode 100644 index 00000000..510becfa --- /dev/null +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/components/mi/nandbased/GUI_rsLatch.java @@ -0,0 +1,50 @@ +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.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 GUI_rsLatch(ViewModelModifiable model) + { + super(model, "_rsLatch"); + setSize(35, 25); + setSubmodelScale(.2); + initSubmodelComponents(); + } + + @SuppressWarnings("unused") + private void initSubmodelComponents() + { + Pin _S = addSubmodelInterface(1, 0, 5); + Pin _R = addSubmodelInterface(1, 0, 20); + Pin Q = addSubmodelInterface(1, 35, 5); + Pin _Q = addSubmodelInterface(1, 35, 20); + + GUINandGate nand1 = new GUINandGate(submodelModifiable, 1); + nand1.moveTo(80, 20); + GUINandGate nand2 = new GUINandGate(submodelModifiable, 1); + nand2.moveTo(80, 85); + + WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1); + cp1.moveTo(120, 30); + WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1); + 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.getPin()); + new GUIWire(submodelModifiable, nand2.getOutputPin(), cp2.getPin()); + new GUIWire(submodelModifiable, cp1.getPin(), nand2.getInputPins().get(0), new Point(120, 50), new Point(60, 75), + new Point(60, 90)); + new GUIWire(submodelModifiable, cp2.getPin(), nand1.getInputPins().get(1), new Point(120, 75), new Point(60, 50), + new Point(60, 35)); + new GUIWire(submodelModifiable, cp1.getPin(), Q, new Point(150, 30), new Point(150, 25)); + new GUIWire(submodelModifiable, cp2.getPin(), _Q, new Point(150, 95), new Point(150, 100)); + } +} \ No newline at end of file