X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodel%2Fcomponents%2Fmi%2Fnandbased%2FGUIdff.java;h=1d67977f80d8f6f60c80c3523799f87afeccea5c;hb=0c8d57e463139a858ae07c4779a06cf3c234e8ff;hp=b8a5c8a3730f18fb15cc681c83f65e05088a6a9d;hpb=74f82a58865d948fa700efbc185a8d057e4a0175;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/model/components/mi/nandbased/GUIdff.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/model/components/mi/nandbased/GUIdff.java index b8a5c8a3..1d67977f 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/model/components/mi/nandbased/GUIdff.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/model/components/mi/nandbased/GUIdff.java @@ -8,10 +8,12 @@ import net.mograsim.logic.model.model.wires.GUIWire; import net.mograsim.logic.model.model.wires.Pin; import net.mograsim.logic.model.model.wires.WireCrossPoint; import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; +import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.StandardHighLevelStateHandler; +import net.mograsim.logic.model.snippets.highlevelstatehandlers.standard.atomic.DelegatingAtomicHighLevelStateHandler; public class GUIdff extends SimpleRectangularSubmodelComponent { - private GUI_rsLatch _rsLatch; + private StandardHighLevelStateHandler highLevelStateHandler; public GUIdff(ViewModelModifiable model) { @@ -38,7 +40,7 @@ public class GUIdff extends SimpleRectangularSubmodelComponent GUI_rsLatch _rsLatch1 = new GUI_rsLatch(submodelModifiable); GUInand3 nand3 = new GUInand3(submodelModifiable); GUINandGate nand2 = new GUINandGate(submodelModifiable, 1); - GUI_rsLatch _rsLatch2 = this._rsLatch = new GUI_rsLatch(submodelModifiable); + GUI_rsLatch _rsLatch2 = new GUI_rsLatch(submodelModifiable); WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1); WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1); @@ -70,34 +72,20 @@ public class GUIdff extends SimpleRectangularSubmodelComponent new GUIWire(submodelModifiable, _rsLatch2.getPin("Q"), Q); new GUIWire(submodelModifiable, _rsLatch2.getPin("_Q"), _Q); - addAtomicHighLevelStateID("q"); + this.highLevelStateHandler = new StandardHighLevelStateHandler(this); + highLevelStateHandler.addAtomicHighLevelState("q", DelegatingAtomicHighLevelStateHandler::new).set(_rsLatch2, "q"); } @Override - public void setAtomicHighLevelState(String stateID, Object newState) + public Object getHighLevelState(String stateID) { - switch (stateID) - { - case "q": - _rsLatch.setHighLevelState("q", newState); - break; - default: - // should not happen because we tell SubmodelComponent to only allow these state IDs. - throw new IllegalStateException("Illegal atomic state ID: " + stateID); - } + return highLevelStateHandler.getHighLevelState(stateID); } @Override - public Object getAtomicHighLevelState(String stateID) + public void setHighLevelState(String stateID, Object newState) { - switch (stateID) - { - case "q": - return _rsLatch.getHighLevelState("q"); - default: - // should not happen because we tell SubmodelComponent to only allow these state IDs. - throw new IllegalStateException("Illegal atomic state ID: " + stateID); - } + highLevelStateHandler.setHighLevelState(stateID, newState); } static