X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fsnippets%2Fhighlevelstatehandlers%2Fstandard%2FStandardHighLevelStateHandler.java;h=af3ad22b1999b01df7f949b976119a624cd2414b;hb=039f31334c661633b71e945aa4332cedb7055526;hp=1c3ac62c6f2da999fb1b7f5955105d1e0040a313;hpb=a00663c79d0e26b494ff79eee4b6c049f086c7e0;p=Mograsim.git diff --git a/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/StandardHighLevelStateHandler.java b/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/StandardHighLevelStateHandler.java index 1c3ac62c..af3ad22b 100644 --- a/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/StandardHighLevelStateHandler.java +++ b/net.mograsim.logic.model/src/net/mograsim/logic/model/snippets/highlevelstatehandlers/standard/StandardHighLevelStateHandler.java @@ -2,10 +2,12 @@ package net.mograsim.logic.model.snippets.highlevelstatehandlers.standard; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import java.util.function.BiFunction; import java.util.function.Function; import net.mograsim.logic.model.model.components.submodels.SubmodelComponent; +import net.mograsim.logic.model.serializing.IdentifyParams; import net.mograsim.logic.model.snippets.HighLevelStateHandler; import net.mograsim.logic.model.snippets.SnippetDefinintion; import net.mograsim.logic.model.snippets.SubmodelComponentSnippetSuppliers; @@ -139,6 +141,39 @@ public class StandardHighLevelStateHandler implements HighLevelStateHandler } } + @Override + public String getIDForSerializing(IdentifyParams idParams) + { + return "standard"; + } + + @Override + public StandardHighLevelStateHandlerParams getParamsForSerializing(IdentifyParams idParams) + { + StandardHighLevelStateHandlerParams params = new StandardHighLevelStateHandlerParams(); + params.subcomponentHighLevelStates = new HashMap<>(); + params.atomicHighLevelStates = new HashMap<>(); + for (Entry e : subcomponentHighLevelStateHandlers.entrySet()) + { + String stateID = e.getKey(); + SubcomponentHighLevelStateHandler handler = e.getValue(); + SubcomponentHighLevelStateHandlerParams handlerParams = new SubcomponentHighLevelStateHandlerParams(); + handlerParams.id = handler.getIDForSerializing(idParams); + handlerParams.params = handler.getParamsForSerializingJSON(idParams); + params.subcomponentHighLevelStates.put(stateID, handlerParams); + } + for (Entry e : atomicHighLevelStateHandlers.entrySet()) + { + String stateID = e.getKey(); + AtomicHighLevelStateHandler handler = e.getValue(); + AtomicHighLevelStateHandlerParams handlerParams = new AtomicHighLevelStateHandlerParams(); + handlerParams.id = handler.getIDForSerializing(idParams); + handlerParams.params = handler.getParamsForSerializingJSON(idParams); + params.atomicHighLevelStates.put(stateID, handlerParams); + } + return params; + } + public static class StandardHighLevelStateHandlerParams { public Map subcomponentHighLevelStates;