X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Ftest%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fam2900%2Futil%2FSwitchWithDisplay.java;fp=net.mograsim.logic.model.am2900%2Ftest%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fam2900%2Futil%2FSwitchWithDisplay.java;h=2591e3a5eab70e1982ef4e9282d6e430a6a3408b;hb=6d28e5c93c9347784950ca66fb6d1b3a14461ece;hp=0000000000000000000000000000000000000000;hpb=9b34381259d5e6cb46bd3834712311cd60317506;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/util/SwitchWithDisplay.java b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/util/SwitchWithDisplay.java new file mode 100644 index 00000000..2591e3a5 --- /dev/null +++ b/net.mograsim.logic.model.am2900/test/net/mograsim/logic/model/am2900/util/SwitchWithDisplay.java @@ -0,0 +1,65 @@ +package net.mograsim.logic.model.am2900.util; + +import net.mograsim.logic.core.components.BitDisplay; +import net.mograsim.logic.core.components.ManualSwitch; +import net.mograsim.logic.core.types.BitVector; +import net.mograsim.logic.model.model.ViewModelModifiable; +import net.mograsim.logic.model.model.components.atomic.GUIBitDisplay; +import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch; +import net.mograsim.logic.model.model.wires.Pin; +import net.mograsim.logic.model.model.wires.WireCrossPoint; +import net.mograsim.logic.model.util.ModellingTool; + +public class SwitchWithDisplay +{ + private final Pin pin; + private final GUIBitDisplay guiBitDisplay; + private final GUIManualSwitch guiManualSwitch; + + public SwitchWithDisplay(ViewModelModifiable model, Pin target) + { + pin = target; + guiBitDisplay = new GUIBitDisplay(model, pin.logicWidth); + guiManualSwitch = new GUIManualSwitch(model, pin.logicWidth); + + ModellingTool tool = ModellingTool.createFor(model); + WireCrossPoint crossPoint = new WireCrossPoint(model, pin.logicWidth); + tool.connect(guiBitDisplay.getInputPin(), crossPoint); + tool.connect(guiManualSwitch.getOutputPin(), crossPoint); + } + + public final BitVector getDisplayedValue() + { + return guiBitDisplay.getBitDisplay().getDisplayedValue(); + } + + public final void setState(BitVector bits) + { + guiManualSwitch.getManualSwitch().setState(bits); + } + + public final Pin getPin() + { + return pin; + } + + public final BitDisplay getBitDisplay() + { + return guiBitDisplay.getBitDisplay(); + } + + public final ManualSwitch getManualSwitch() + { + return guiManualSwitch.getManualSwitch(); + } + + final GUIBitDisplay getGuiBitDisplay() + { + return guiBitDisplay; + } + + final GUIManualSwitch getGuiManualSwitch() + { + return guiManualSwitch; + } +}