From 901790cdb47f554ab1724cb35b34c4c6f443be0f Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Tue, 22 Aug 2023 12:00:15 +0100 Subject: [PATCH 1/7] feat: annotate `Meta` --- src/main/java/org/lemsml/jlems/core/type/Meta.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/org/lemsml/jlems/core/type/Meta.java b/src/main/java/org/lemsml/jlems/core/type/Meta.java index 6bb25e6c..ab0e2670 100644 --- a/src/main/java/org/lemsml/jlems/core/type/Meta.java +++ b/src/main/java/org/lemsml/jlems/core/type/Meta.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.HashMap; +import org.lemsml.jlems.core.annotation.ModelElement; import org.lemsml.jlems.core.sim.ContentError; import org.lemsml.jlems.core.xml.XMLAttribute; import org.lemsml.jlems.core.xml.XMLElement; @@ -11,6 +12,7 @@ // RawValued indicates that XML found inside Meta elements should be treated // processed into an element tree, but not interpreted as lems elements. // other tools can do their own thing with the content +@ModelElement(info="Meta element to provide arbitrary metadata to LEMS simulations. Note that this is not processed by the LEMS interpreter.") public class Meta { public String context; From a40a8a81c7bc09aa41d0a3c282dd456b247ba98a Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Tue, 22 Aug 2023 12:00:30 +0100 Subject: [PATCH 2/7] chore: remove extra white space --- .../java/org/lemsml/jlems/core/type/Meta.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/lemsml/jlems/core/type/Meta.java b/src/main/java/org/lemsml/jlems/core/type/Meta.java index ab0e2670..c0e2ec3b 100644 --- a/src/main/java/org/lemsml/jlems/core/type/Meta.java +++ b/src/main/java/org/lemsml/jlems/core/type/Meta.java @@ -7,32 +7,32 @@ import org.lemsml.jlems.core.sim.ContentError; import org.lemsml.jlems.core.xml.XMLAttribute; import org.lemsml.jlems.core.xml.XMLElement; - -// RawValued indicates that XML found inside Meta elements should be treated + +// RawValued indicates that XML found inside Meta elements should be treated // processed into an element tree, but not interpreted as lems elements. // other tools can do their own thing with the content @ModelElement(info="Meta element to provide arbitrary metadata to LEMS simulations. Note that this is not processed by the LEMS interpreter.") public class Meta { public String context; - + public XMLElement valueWrapper = new XMLElement("wrapper"); - + private XMLElement p_sourceXML; - + public ArrayList items = new ArrayList(); - - + + public Meta() { - + } - + public void setSource(XMLElement xe) { p_sourceXML = xe; } - + public void addXMLElement(XMLElement xe) { valueWrapper.add(xe); // E.info("Set VW " + xe.toXMLString("")); @@ -47,7 +47,7 @@ public HashMap getAttributes() { } return ret; } - + public void add(Object obj) throws ContentError { if (obj instanceof MetaItem) { @@ -55,7 +55,7 @@ public void add(Object obj) throws ContentError { } else { throw new ContentError("cant add " + obj); } - } + } public MetaItem newItem(String nm) { MetaItem ret = new MetaItem(nm); From 4d3216a74e6325e529855d50520c5e814c34c78a Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Wed, 23 Aug 2023 16:03:36 +0100 Subject: [PATCH 3/7] feat(factory-generator): add additional import ... otherwise it errors saying that `Record` is ambiguous. --- .../java/org/lemsml/jlems/io/reader/LemsFactoryGenerator.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/lemsml/jlems/io/reader/LemsFactoryGenerator.java b/src/main/java/org/lemsml/jlems/io/reader/LemsFactoryGenerator.java index fcf0350d..d951f964 100644 --- a/src/main/java/org/lemsml/jlems/io/reader/LemsFactoryGenerator.java +++ b/src/main/java/org/lemsml/jlems/io/reader/LemsFactoryGenerator.java @@ -25,6 +25,7 @@ private String generateJava() { sb.append("import org.lemsml.jlems.core.type.*;\n"); sb.append("import org.lemsml.jlems.core.type.dynamics.*;\n"); sb.append("import org.lemsml.jlems.core.type.structure.*;\n"); + sb.append("import org.lemsml.jlems.core.type.simulation.Record;\n\n"); // Record is ambiguous sb.append("import org.lemsml.jlems.core.type.simulation.*;\n\n"); sb.append("import org.lemsml.jlems.core.type.procedure.*;\n\n"); sb.append("import org.lemsml.jlems.core.type.geometry.*;\n\n"); From b60302babb876d287a3310d1354b76969f0596cf Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Wed, 23 Aug 2023 16:04:30 +0100 Subject: [PATCH 4/7] feat(lems-factory): regenerated Command to regenerate: ``` $ mvn clean install # if changes made to generator $ java -classpath target/jlems-0.10.7.jar org.lemsml.jlems.io.reader.LemsFactoryGenerator.main ``` --- .../java/org/lemsml/jlems/core/reader/LemsFactory.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/lemsml/jlems/core/reader/LemsFactory.java b/src/main/java/org/lemsml/jlems/core/reader/LemsFactory.java index eb03c0f8..ff150dd3 100644 --- a/src/main/java/org/lemsml/jlems/core/reader/LemsFactory.java +++ b/src/main/java/org/lemsml/jlems/core/reader/LemsFactory.java @@ -4,6 +4,7 @@ import org.lemsml.jlems.core.type.dynamics.*; import org.lemsml.jlems.core.type.structure.*; import org.lemsml.jlems.core.type.simulation.Record; + import org.lemsml.jlems.core.type.simulation.*; import org.lemsml.jlems.core.type.procedure.*; @@ -764,10 +765,10 @@ private Child buildChild(XMLElement xel) { ret.name = parseString(xv); } else if (xn.equals("type")) { ret.type = parseString(xv); - } else if (xn.equals("description")) { - ret.description = parseString(xv); } else if (xn.equals("substitute")) { ret.substitute = parseString(xv); + } else if (xn.equals("description")) { + ret.description = parseString(xv); } else { E.warning("Unrecognized attribute " + xa + " " + xv); } @@ -810,6 +811,8 @@ private Link buildLink(XMLElement xel) { ret.name = parseString(xv); } else if (xn.equals("type")) { ret.type = parseString(xv); + } else if (xn.equals("description")) { + ret.description = parseString(xv); } else if (xn.equals("root")) { ret.root = parseString(xv); } else if (xn.equals("isAny")) { @@ -2423,6 +2426,8 @@ private Simulation buildSimulation(XMLElement xel) { ret.dataWriters.add((DataWriter)obj); } else if (obj instanceof EventWriter) { ret.eventWriters.add((EventWriter)obj); + } else if (obj instanceof Meta) { + ret.metas.add((Meta)obj); } else { E.warning("Unrecognized element ("+xn+"): " + cel); } From de661bc91d42b3ff3734ffb657ff57b1f7a9bc99 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Wed, 23 Aug 2023 16:06:09 +0100 Subject: [PATCH 5/7] feat(simulation): add meta as children element --- .../java/org/lemsml/jlems/core/type/simulation/Simulation.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main/java/org/lemsml/jlems/core/type/simulation/Simulation.java b/src/main/java/org/lemsml/jlems/core/type/simulation/Simulation.java index 0f16b4ad..761ae8a8 100644 --- a/src/main/java/org/lemsml/jlems/core/type/simulation/Simulation.java +++ b/src/main/java/org/lemsml/jlems/core/type/simulation/Simulation.java @@ -11,6 +11,7 @@ import org.lemsml.jlems.core.type.ComponentType; import org.lemsml.jlems.core.type.Lems; import org.lemsml.jlems.core.type.LemsCollection; +import org.lemsml.jlems.core.type.Meta; @@ -29,6 +30,8 @@ public class Simulation { public transient LemsCollection eventWriters = new LemsCollection(); + public transient LemsCollection metas = new LemsCollection(); + public static int idCounter = 0; From 8079267df46e732e4e62b0862f69594723ac3322 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Wed, 23 Aug 2023 16:06:39 +0100 Subject: [PATCH 6/7] feat(lems-classes): remove abstract class ... since it cannot be instantiated (java throws error). --- src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java b/src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java index 4d4ce269..b4a84de0 100644 --- a/src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java +++ b/src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java @@ -174,7 +174,7 @@ private ArrayList getStructureClasses() { ArrayList ret = new ArrayList(); String section = "structure"; ret.add(new LemsClass(Structure.class, section)); - ret.add(new LemsClass(BuildElement.class, section)); + // ret.add(new LemsClass(BuildElement.class, section)); -> abstract ret.add(new LemsClass(MultiInstantiate.class, section)); ret.add(new LemsClass(CoInstantiate.class, section)); ret.add(new LemsClass(Assign.class, section)); From e23299003bb09e91b1e34ffd9b51dc8480e7cf77 Mon Sep 17 00:00:00 2001 From: "Ankur Sinha (Ankur Sinha Gmail)" Date: Wed, 23 Aug 2023 16:07:04 +0100 Subject: [PATCH 7/7] feat(lems-classes): add `Component` to list --- src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java b/src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java index b4a84de0..b36cd572 100644 --- a/src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java +++ b/src/main/java/org/lemsml/jlems/io/reader/LemsClasses.java @@ -199,6 +199,7 @@ private ArrayList getComponentTypeClasses() { ArrayList ret = new ArrayList(); String section = "componenttypes"; + ret.add(new LemsClass(Component.class, section)); ret.add(new LemsClass(ComponentType.class, section)); ret.add(new LemsClass(Parameter.class, section)); ret.add(new LemsClass(PathParameter.class, section));