import net.haspamelodica.swt.helper.swtobjectwrappers.Font;
import net.haspamelodica.swt.helper.swtobjectwrappers.Point;
import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle;
-import net.mograsim.logic.core.LogicObservable;
import net.mograsim.logic.core.LogicObserver;
import net.mograsim.logic.core.components.BitDisplay;
import net.mograsim.logic.core.types.BitVectorFormatter;
public void setLogicModelBinding(BitDisplay bitDisplay)
{
- deregisterLogicObs(this.bitDisplay);
+ if (this.bitDisplay != null)
+ this.bitDisplay.deregisterObserver(logicObs);
this.bitDisplay = bitDisplay;
- registerLogicObs(bitDisplay);
+ if (bitDisplay != null)
+ bitDisplay.registerObserver(logicObs);
}
- private void registerLogicObs(LogicObservable observable)
+ public boolean hasLogicModelBinding()
{
- if (observable != null)
- observable.registerObserver(logicObs);
- }
-
- private void deregisterLogicObs(LogicObservable observable)
- {
- if (observable != null)
- observable.deregisterObserver(logicObs);
+ return bitDisplay != null;
}
public BitDisplay getBitDisplay()
return pin;
}
+ // high-level access
+
+ @SuppressWarnings({ "static-method", "unused" }) // this method is intended to be overridden
+ public void setHighLevelState(String stateID, Object newState)
+ {
+ throw new IllegalArgumentException("No high level state with ID " + stateID);
+ }
+
// "graphical" operations
/**
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;
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);
+ }
+
// listeners
// @formatter:off