X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.ui%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fui%2Fmodel%2Fwires%2FGUIWire.java;h=99adc4c3749ef9283c24bb7f20e00ef585b21f75;hb=74bced7a3a38f65c65f3395cc422eb98e34da0b8;hp=6398817d1cb1cf917185dc9b1c7c8996a28f0f52;hpb=a84700145147c263ad6692c99117a7cf37832378;p=Mograsim.git diff --git a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java index 6398817d..99adc4c3 100644 --- a/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java +++ b/net.mograsim.logic.ui/src/net/mograsim/logic/ui/model/wires/GUIWire.java @@ -10,7 +10,9 @@ import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Point; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.core.LogicObserver; +import net.mograsim.logic.core.types.BitVector; import net.mograsim.logic.core.types.BitVectorFormatter; +import net.mograsim.logic.core.wires.Wire; import net.mograsim.logic.core.wires.Wire.ReadEnd; import net.mograsim.logic.ui.ColorHelper; import net.mograsim.logic.ui.model.ViewModelModifiable; @@ -308,6 +310,32 @@ public class GUIWire end.registerObserver(logicObs); } + /** + * Returns whether this {@link GUIWire} has a logic model binding or not. + */ + public boolean hasLogicModelBinding() + { + return end != null; + } + + /** + * If this {@link GUIWire} has a logic model binding, delegates to {@link Wire#forceValues(BitVector)} for the {@link Wire} + * corresponding to this {@link GUIWire}. + */ + public void forceWireValues(BitVector values) + { + end.getWire().forceValues(values); + } + + /** + * If this {@link GUIWire} has a logic model binding, delegates to {@link ReadEnd#getValues()} for the {@link ReadEnd} corresponding to + * this {@link GUIWire}. + */ + public BitVector getWireValues() + { + return end.getValues(); + } + // listeners // @formatter:off @@ -318,4 +346,9 @@ public class GUIWire private void callRedrawListeners() {redrawListeners.forEach(l -> l.run());} // @formatter:on + @Override + public String toString() + { + return "GUIWire [" + pin1 + "---" + pin2 + ", value=" + (end == null ? "null" : end.getValues()) + "]"; + } } \ No newline at end of file