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%2FGUIdlatch.java;h=c9c932568075ae90bf2689dc6e5d1cdcaf268480;hb=8183e70989d1293764b045a8f8903b33fc2e8cb3;hp=7378237d0fb7c802c5c3cfcf9662f9ca17c29ada;hpb=47ea68ed5c444dd14864412639f6a6fd60ab8a0f;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/model/components/mi/nandbased/GUIdlatch.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/model/components/mi/nandbased/GUIdlatch.java index 7378237d..c9c93256 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/model/components/mi/nandbased/GUIdlatch.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/model/components/mi/nandbased/GUIdlatch.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 GUIdlatch extends SimpleRectangularSubmodelComponent { - private GUI_rsLatch _rsLatch; + private StandardHighLevelStateHandler highLevelStateHandler; public GUIdlatch(ViewModelModifiable model) { @@ -37,7 +39,7 @@ public class GUIdlatch extends SimpleRectangularSubmodelComponent GUINandGate nand1 = new GUINandGate(submodelModifiable, 1); GUINandGate nand2 = new GUINandGate(submodelModifiable, 1); - _rsLatch = new GUI_rsLatch(submodelModifiable); + GUI_rsLatch _rsLatch = new GUI_rsLatch(submodelModifiable); WireCrossPoint cp1 = new WireCrossPoint(submodelModifiable, 1); WireCrossPoint cp2 = new WireCrossPoint(submodelModifiable, 1); @@ -59,34 +61,20 @@ public class GUIdlatch extends SimpleRectangularSubmodelComponent new GUIWire(submodelModifiable, _rsLatch.getPin("Q"), Q, new Point[0]); new GUIWire(submodelModifiable, _rsLatch.getPin("_Q"), _Q); - addAtomicHighLevelStateID("q"); + highLevelStateHandler = new StandardHighLevelStateHandler(this); + highLevelStateHandler.addAtomicHighLevelState("q", DelegatingAtomicHighLevelStateHandler::new).set(_rsLatch, "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