Made ModelMemoryWA referencable from components
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 12 Sep 2019 19:31:40 +0000 (21:31 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Thu, 12 Sep 2019 19:31:40 +0000 (21:31 +0200)
net.mograsim.logic.model.am2900/src/net/mograsim/logic/model/am2900/Am2900Loader.java
net.mograsim.machine/META-INF/MANIFEST.MF
net.mograsim.machine/src/net/mograsim/machine/MachineLoader.java [new file with mode: 0644]
net.mograsim.machine/src/net/mograsim/machine/standard/memory/ModelMemoryWA.java
net.mograsim.machine/src/net/mograsim/machine/standardComponentIDMapping.json [new file with mode: 0644]

index 51e8cec..10cf141 100644 (file)
@@ -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
        }
 }
index 6936168..d604d94 100644 (file)
@@ -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 (file)
index 0000000..9a88575
--- /dev/null
@@ -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
+       }
+}
index 9f5b1cc..2b4f905 100644 (file)
@@ -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 (file)
index 0000000..eb8c941
--- /dev/null
@@ -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