X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fmodel%2Fcomponents%2Fatomic%2FModelClock.java;h=d84e2027a41d8d31db743c3c6bff2c2023858820;hb=0c97f70d199e1ffcd2bc13817f7bb12867ba033e;hp=38963536d0d8163deded311a08155614e9f01edf;hpb=7d05144c25daa53e60fc9ed9fd503546a86567f8;p=Mograsim.git diff --git a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelClock.java b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelClock.java index 38963536..d84e2027 100644 --- a/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelClock.java +++ b/plugins/net.mograsim.logic.model/src/net/mograsim/logic/model/model/components/atomic/ModelClock.java @@ -20,6 +20,7 @@ import net.mograsim.logic.model.modeladapter.LogicCoreAdapter; import net.mograsim.logic.model.modeladapter.componentadapters.ClockAdapter; import net.mograsim.logic.model.serializing.IdentifyParams; import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; +import net.mograsim.logic.model.snippets.HighLevelStateHandler; import net.mograsim.logic.model.util.JsonHandler; import net.mograsim.preferences.Preferences; @@ -53,6 +54,47 @@ public class ModelClock extends ModelComponent this.outputPin = new Pin(model, this, "", 1, PinUsage.OUTPUT, oc.newX(width, height / 2), oc.newY(width, height / 2)); addPin(outputPin); + setHighLevelStateHandler(new HighLevelStateHandler() + { + @Override + public Object getHighLevelState(String stateID) + { + switch (stateID) + { + case "out": + if (clock != null) + return clock.getOut().getInputValues(); + return null; + default: + throw new IllegalArgumentException("No high level state with ID " + stateID); + } + } + + @Override + public void setHighLevelState(String stateID, Object newState) + { + switch (stateID) + { + case "out": + throw new UnsupportedOperationException("cannot set state of clock"); + default: + throw new IllegalArgumentException("No high level state with ID " + stateID); + } + } + + @Override + public String getIDForSerializing(IdentifyParams idParams) + { + return null; + } + + @Override + public Object getParamsForSerializing(IdentifyParams idParams) + { + return null; + } + }); + init(); } @@ -89,32 +131,6 @@ public class ModelClock extends ModelComponent return clock != null; } - @Override - public Object getHighLevelState(String stateID) - { - switch (stateID) - { - case "out": - if (clock != null) - return clock.getOut().getInputValues(); - return null; - default: - return super.getHighLevelState(stateID); - } - } - - @Override - public void setHighLevelState(String stateID, Object newState) - { - switch (stateID) - { - case "out": - throw new UnsupportedOperationException("cannot set state of clock"); - default: - super.setHighLevelState(stateID, newState); - } - } - public CoreClock getClock() { return clock;