From: Daniel Kirschten Date: Thu, 12 Sep 2019 19:31:40 +0000 (+0200) Subject: Made ModelMemoryWA referencable from components X-Git-Url: https://mograsim.net/gitweb/?a=commitdiff_plain;h=fef6208422d970ce5929750595a8b52f01d91be7;p=Mograsim.git Made ModelMemoryWA referencable from components --- diff --git a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/Am2900Loader.java b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/Am2900Loader.java index 51e8cecb..10cf1412 100644 --- a/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/Am2900Loader.java +++ b/net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/Am2900Loader.java @@ -7,6 +7,7 @@ import org.osgi.framework.BundleContext; import net.mograsim.logic.model.serializing.ClassLoaderBasedResourceLoader; import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; +import net.mograsim.machine.MachineLoader; public class Am2900Loader implements BundleActivator { @@ -32,6 +33,7 @@ public class Am2900Loader implements BundleActivator ClassLoaderBasedResourceLoader resourceLoader = ClassLoaderBasedResourceLoader.create(Am2900Loader.class.getClassLoader()); IndirectModelComponentCreator.registerResourceLoader(resourceLoader, "Am2900Loader"); IndirectModelComponentCreator.loadStandardComponentIDs(Am2900Loader.class.getResourceAsStream("standardComponentIDMapping.json")); + MachineLoader.setup(); // System.out.println("SETUP DONE"); // TODO: Debug } } diff --git a/net.mograsim.machine/META-INF/MANIFEST.MF b/net.mograsim.machine/META-INF/MANIFEST.MF index 69361685..d604d946 100644 --- a/net.mograsim.machine/META-INF/MANIFEST.MF +++ b/net.mograsim.machine/META-INF/MANIFEST.MF @@ -17,3 +17,5 @@ Export-Package: net.mograsim.machine, net.mograsim.machine.mi, net.mograsim.machine.mi.parameters, net.mograsim.machine.standard.memory +Bundle-Activator: net.mograsim.machine.MachineLoader +Bundle-ActivationPolicy: lazy diff --git a/net.mograsim.machine/src/net/mograsim/machine/MachineLoader.java b/net.mograsim.machine/src/net/mograsim/machine/MachineLoader.java new file mode 100644 index 00000000..9a88575b --- /dev/null +++ b/net.mograsim.machine/src/net/mograsim/machine/MachineLoader.java @@ -0,0 +1,36 @@ +package net.mograsim.machine; + +import java.util.concurrent.atomic.AtomicBoolean; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +import net.mograsim.logic.model.serializing.ClassLoaderBasedResourceLoader; +import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; + +public class MachineLoader implements BundleActivator +{ + private static AtomicBoolean activated = new AtomicBoolean(false); + + @Override + public void start(BundleContext context) throws Exception + { + setup(); + } + + @Override + public void stop(BundleContext context) throws Exception + { + // nothing + } + + public static void setup() + { + if (activated.getAndSet(true)) + return; + ClassLoaderBasedResourceLoader resourceLoader = ClassLoaderBasedResourceLoader.create(MachineLoader.class.getClassLoader()); + IndirectModelComponentCreator.registerResourceLoader(resourceLoader, "MachineLoader"); + IndirectModelComponentCreator.loadStandardComponentIDs(MachineLoader.class.getResourceAsStream("standardComponentIDMapping.json")); +// System.out.println("SETUP DONE"); // TODO: Debug + } +} diff --git a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelMemoryWA.java b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelMemoryWA.java index 9f5b1cc9..2b4f9055 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelMemoryWA.java +++ b/net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelMemoryWA.java @@ -4,7 +4,6 @@ import net.haspamelodica.swt.helper.gcs.GeneralGC; import net.haspamelodica.swt.helper.swtobjectwrappers.Rectangle; import net.mograsim.logic.model.model.LogicModelModifiable; import net.mograsim.logic.model.model.components.ModelComponent; -import net.mograsim.logic.model.model.components.atomic.ModelAndGate; import net.mograsim.logic.model.model.wires.Pin; import net.mograsim.logic.model.model.wires.PinUsage; import net.mograsim.logic.model.modeladapter.LogicCoreAdapter; @@ -12,8 +11,8 @@ import net.mograsim.logic.model.serializing.IdentifyParams; import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; import net.mograsim.logic.model.snippets.Renderer; import net.mograsim.logic.model.snippets.outlinerenderers.DefaultOutlineRenderer; -import net.mograsim.logic.model.snippets.symbolrenderers.CenteredTextSymbolRenderer; -import net.mograsim.logic.model.snippets.symbolrenderers.CenteredTextSymbolRenderer.CenteredTextParams; +import net.mograsim.logic.model.snippets.symbolrenderers.SimpleRectangularLikeSymbolRenderer; +import net.mograsim.logic.model.snippets.symbolrenderers.SimpleRectangularLikeSymbolRenderer.SimpleRectangularLikeParams; import net.mograsim.logic.model.util.JsonHandler; import net.mograsim.machine.MainMemoryDefinition; @@ -28,13 +27,16 @@ public class ModelMemoryWA extends ModelComponent public ModelMemoryWA(LogicModelModifiable model, MainMemoryDefinition definition, String name) { - super(model, name,false); + super(model, name, false); this.definition = definition; - CenteredTextParams renderer1Params = new CenteredTextParams(); - renderer1Params.text = "RAM"; - renderer1Params.fontHeight = 24; - this.symbolRenderer = new CenteredTextSymbolRenderer(this, renderer1Params); + SimpleRectangularLikeParams rendererParams = new SimpleRectangularLikeParams(); + rendererParams.centerText = "RAM"; + rendererParams.centerTextHeight = 24; + rendererParams.horizontalComponentCenter = width / 100; + rendererParams.pinLabelHeight = 17.5; + rendererParams.pinLabelMargin = 2.5; + this.symbolRenderer = new SimpleRectangularLikeSymbolRenderer(this, rendererParams); this.outlineRenderer = new DefaultOutlineRenderer(this); setSize(width, height); @@ -42,7 +44,7 @@ public class ModelMemoryWA extends ModelComponent addPin(addrPin = new Pin(model, this, "A", definition.getMemoryAddressBits(), PinUsage.INPUT, 0, 10)); addPin(dataPin = new Pin(model, this, "D", definition.getCellWidth(), PinUsage.TRISTATE, 0, 30)); addPin(rWPin = new Pin(model, this, "RW", 1, PinUsage.INPUT, 0, 50)); - + init(); } @@ -103,7 +105,7 @@ public class ModelMemoryWA extends ModelComponent static { LogicCoreAdapter.addComponentAdapter(new WordAddressableMemoryAdapter()); - IndirectModelComponentCreator.setComponentSupplier(ModelAndGate.class.getCanonicalName(), (m, p, n) -> + IndirectModelComponentCreator.setComponentSupplier(ModelMemoryWA.class.getCanonicalName(), (m, p, n) -> { ModelMemoryWAParams params = JsonHandler.fromJsonTree(p, ModelMemoryWAParams.class); return new ModelMemoryWA(m, MainMemoryDefinition.create(params.addrBits, params.cellWidth, params.minAddr, params.maxAddr), n); diff --git a/net.mograsim.machine/src/net/mograsim/machine/standardComponentIDMapping.json b/net.mograsim.machine/src/net/mograsim/machine/standardComponentIDMapping.json new file mode 100644 index 00000000..eb8c9411 --- /dev/null +++ b/net.mograsim.machine/src/net/mograsim/machine/standardComponentIDMapping.json @@ -0,0 +1,4 @@ +mograsim version: 0.1.3 +{ + "MemoryWA": "resloader:MachineLoader:class:net.mograsim.machine.standard.memory.ModelMemoryWA" +} \ No newline at end of file