X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fexamples%2FAm2904Testbench.java;fp=net.mograsim.logic.model.am2900%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Fexamples%2FAm2904Testbench.java;h=a4c4290ae43b780fc639bb3a619ac95430c6546d;hb=9165b392dfb013db0b15213cea57e5f6976859ab;hp=0000000000000000000000000000000000000000;hpb=18ee8ea8e2c7979aab2bd96f1651c8f3f33d7f63;p=Mograsim.git diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/Am2904Testbench.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/Am2904Testbench.java new file mode 100644 index 00000000..a4c4290a --- /dev/null +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/examples/Am2904Testbench.java @@ -0,0 +1,58 @@ +package net.mograsim.logic.model.examples; + +import net.haspamelodica.swt.helper.gcs.GeneralGC; +import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; +import net.mograsim.logic.core.types.Bit; +import net.mograsim.logic.core.types.BitVector; +import net.mograsim.logic.model.SimpleLogicUIStandalone; +import net.mograsim.logic.model.SimpleLogicUIStandalone.VisualisationObjects; +import net.mograsim.logic.model.model.ViewModelModifiable; +import net.mograsim.logic.model.model.components.atomic.GUIManualSwitch; +import net.mograsim.logic.model.model.components.submodels.SubmodelComponent; +import net.mograsim.logic.model.serializing.DeserializedSubmodelComponent; +import net.mograsim.logic.model.serializing.IdentifierGetter; +import net.mograsim.logic.model.serializing.IndirectGUIComponentCreator; +import net.mograsim.logic.model.snippets.Renderer; + +public class Am2904Testbench +{ + public static void main(String[] args) + { + SimpleLogicUIStandalone.executeVisualisation(Am2904Testbench::create, Am2904Testbench::beforeRun); + } + + public static void create(ViewModelModifiable model) + { + // TODO use _SE in GUIAm2904.json + // TODO replace with proper ViewModel deserialization + DeserializedSubmodelComponent testbench = (DeserializedSubmodelComponent) IndirectGUIComponentCreator.createComponent(model, + "file:GUIAm2904Testbench.json", "testbench"); + testbench.setSize(1000, 1000); + testbench.setOutlineRenderer(new Renderer() + { + @Override + public Object getParamsForSerializing(IdentifierGetter idGetter) + { + return null; + } + + @Override + public void render(GeneralGC gc, Rectangle visibleRegion) + { + // do nothing + } + }); + } + + public static void beforeRun(VisualisationObjects vis) + { + ((SubmodelComponent) vis.model.getComponentsByName().get("testbench")).submodel.getComponentsByName().values().forEach(c -> + { + if (c instanceof GUIManualSwitch) + { + GUIManualSwitch cCasted = (GUIManualSwitch) c; + cCasted.setHighLevelState("out", BitVector.of(Bit.ZERO, cCasted.logicWidth)); + } + }); + } +} \ No newline at end of file