From 4468df190078a73ffb92874556959a017f0dd440 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Fri, 15 Aug 2014 08:05:29 -0700 Subject: [PATCH 01/21] remove externalbuilder --- .project | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.project b/.project index 9be2e08b..f7a5bad8 100644 --- a/.project +++ b/.project @@ -15,16 +15,6 @@ - - org.eclipse.ui.externaltools.ExternalToolBuilder - full,incremental, - - - LaunchConfigHandle - <project>/.externalToolBuilders/org.eclipse.m2e.core.maven2Builder (7).launch - - - org.eclipse.m2e.core.maven2Builder From bc839f1f6a3382ea6c059a7205bae0900ee68bd0 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Wed, 20 Aug 2014 09:47:56 -0700 Subject: [PATCH 02/21] Moves id to ANode level --- .../geppetto/core/model/runtime/ANode.java | 10 ++- .../core/model/runtime/AVisualObjectNode.java | 9 --- .../core/model/runtime/AspectNode.java | 9 --- .../core/model/runtime/EntityNode.java | 10 --- .../state/visitors/SerializeTreeVisitor.java | 69 +++++++++++++++---- 5 files changed, 65 insertions(+), 42 deletions(-) diff --git a/src/main/java/org/geppetto/core/model/runtime/ANode.java b/src/main/java/org/geppetto/core/model/runtime/ANode.java index 8f6bb0da..8ecc349c 100644 --- a/src/main/java/org/geppetto/core/model/runtime/ANode.java +++ b/src/main/java/org/geppetto/core/model/runtime/ANode.java @@ -44,7 +44,7 @@ public abstract class ANode implements IVisitable { protected ANode _parent; protected String _name; - //protected String _metatype; + private String _id; public String getMetaType(){ return this.getClass().getSimpleName(); @@ -70,6 +70,14 @@ public String getName() return _name; } + public void setId(String id){ + this._id = id; + } + + public String getId() { + return this._id; + } + /** * @return the next sibling of this node */ diff --git a/src/main/java/org/geppetto/core/model/runtime/AVisualObjectNode.java b/src/main/java/org/geppetto/core/model/runtime/AVisualObjectNode.java index d9474a07..88016f37 100644 --- a/src/main/java/org/geppetto/core/model/runtime/AVisualObjectNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/AVisualObjectNode.java @@ -43,7 +43,6 @@ public abstract class AVisualObjectNode extends ANode{ private Point _position; - private String _id; public AVisualObjectNode(String name) { super(name); @@ -52,14 +51,6 @@ public AVisualObjectNode(String name) { public AVisualObjectNode(){ } - public void setId(String id) { - this._id = id; - } - - public String getId(){ - return this._id; - } - public void setPosition(Point position){ this._position = position; } diff --git a/src/main/java/org/geppetto/core/model/runtime/AspectNode.java b/src/main/java/org/geppetto/core/model/runtime/AspectNode.java index c00b1adc..7e1901b0 100644 --- a/src/main/java/org/geppetto/core/model/runtime/AspectNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/AspectNode.java @@ -46,7 +46,6 @@ */ public class AspectNode extends ACompositeNode{ - private String _id; private VariableNode _time; private IModelInterpreter _modelInterpreter; private ISimulator _simulator; @@ -81,14 +80,6 @@ public ISimulator getSimulator() { public void setSimulator(ISimulator simulator) { this._simulator = simulator; } - - public void setId(String id){ - this._id = id; - } - - public String getId() { - return this._id; - } public ANode getParentEntity() { return this.getParent(); diff --git a/src/main/java/org/geppetto/core/model/runtime/EntityNode.java b/src/main/java/org/geppetto/core/model/runtime/EntityNode.java index ba3c8870..9a0ef4c0 100644 --- a/src/main/java/org/geppetto/core/model/runtime/EntityNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/EntityNode.java @@ -47,7 +47,6 @@ public class EntityNode extends ACompositeNode{ protected List _aspects =new ArrayList();; - private String _id; private List _connections; private AMetadataNode _metadata; private Point _position; @@ -74,15 +73,6 @@ public void setConnections(List connections) { public List getAspects() { return _aspects; } - - public void setId(String id){ - this._id = id; - } - - public String getId() { - return this._id; - } - public AMetadataNode getMetadata() { return this._metadata; diff --git a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java index 6e06f0e2..9d1d3133 100644 --- a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java +++ b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java @@ -28,8 +28,6 @@ import org.geppetto.core.model.values.AValue; import org.geppetto.core.visualisation.model.Point; -import com.google.gson.Gson; -import com.google.gson.JsonArray; import com.google.gson.JsonObject; public class SerializeTreeVisitor extends DefaultStateVisitor @@ -161,9 +159,14 @@ public boolean inCompositeNode(CompositeNode node) @Override public boolean outCompositeNode(CompositeNode node) { + String id = ""; + if(node.getId() != null){ + id = "\"id\":" + "\"" + node.getId() + "\","; + } + String instancePath = this.formatInstancePath(node); - _serialized.append(instancePath); + _serialized.append(id + instancePath); this.generalACompositeStateNodeOut(node); return super.outCompositeNode(node); @@ -254,9 +257,14 @@ public boolean outAspectSubTreeNode(AspectSubTreeNode node) type = "\"type\":" + "\"" + node.getType() + "\","; } + String id = ""; + if(node.getId() != null){ + id = "\"id\":" + "\"" + node.getId() + "\","; + } + String instancePath = this.formatInstancePath(node); - _serialized.append(type+instancePath); + _serialized.append(type+id+instancePath); this.generalACompositeStateNodeOut(node); return super.outAspectSubTreeNode(node); @@ -284,6 +292,11 @@ public boolean visitVariableNode(VariableNode node) metaType = "\"_metaType\":" + "\"" + node.getMetaType() + "\""; } + String id = ""; + if(node.getId() != null){ + id = "\"id\":" + "\"" + node.getId() + "\","; + } + String instancePath = this.formatInstancePath(node); PhysicalQuantity quantity = node.consumeFirstValue(); @@ -299,10 +312,10 @@ public boolean visitVariableNode(VariableNode node) scale = "\"" + quantity.getScalingFactor() + "\""; } _serialized.append("\"" + node.getName() + "\":{\"value\":" + value + ",\"unit\":" - + unit + ",\"scale\":" + scale +","+ instancePath + metaType+ "},"); + + unit + ",\"scale\":" + scale +","+ id + instancePath + metaType+ "},"); } else{ - _serialized.append("\"" + node.getName() +"\":{"+instancePath+metaType+"},"); + _serialized.append("\"" + node.getName() +"\":{"+ id + instancePath+metaType+"},"); } return super.visitVariableNode(node); @@ -316,6 +329,11 @@ public boolean visitParameterNode(ParameterNode node) metaType = "\"_metaType\":" + "\"" + node.getMetaType() + "\""; } + String id = ""; + if(node.getId() != null){ + id = "\"id\":" + "\"" + node.getId() + "\","; + } + String instancePath = this.formatInstancePath(node); String properties =""; @@ -337,7 +355,7 @@ public boolean visitParameterNode(ParameterNode node) properties = properties.concat("},"); } - _serialized.append("\"" + node.getName() + "\":{"+instancePath+metaType+properties+"},"); + _serialized.append("\"" + node.getName() + "\":{"+id +instancePath+metaType+properties+"},"); return super.visitParameterNode(node); } @@ -349,6 +367,11 @@ public boolean visitDynamicsSpecificationNode(DynamicsSpecificationNode node) metaType = "\"_metaType\":" + "\"" + node.getMetaType() + "\""; } + String id = ""; + if(node.getId() != null){ + id = "\"id\":" + "\"" + node.getId() + "\","; + } + String instancePath = this.formatInstancePath(node); PhysicalQuantity quantity = node.getInitialConditions(); @@ -391,7 +414,7 @@ public boolean visitDynamicsSpecificationNode(DynamicsSpecificationNode node) function = "\"_function\":{" + "\"expression\":" + "\"" + functionNode.getExpression() +"\""+ properties + "},"; } - _serialized.append("\"" + node.getName() +"\":{"+specs + function + instancePath + metaType+"},"); + _serialized.append("\"" + node.getName() +"\":{"+specs + function + id + instancePath + metaType+"},"); return super.visitDynamicsSpecificationNode(node); @@ -404,6 +427,11 @@ public boolean visitParameterSpecificationNode(ParameterSpecificationNode node) metaType = "\"_metaType\":" + "\"" + node.getMetaType() + "\""; } + String id = ""; + if(node.getId() != null){ + id = "\"id\":" + "\"" + node.getId() + "\","; + } + String instancePath = this.formatInstancePath(node); PhysicalQuantity quantity = node.getValue(); @@ -419,10 +447,10 @@ public boolean visitParameterSpecificationNode(ParameterSpecificationNode node) scale = "\"" + quantity.getScalingFactor() + "\""; } _serialized.append("\"" + node.getName() + "\":{\"value\":" + "\""+ value + "\",\"unit\":" + unit + - ",\"scale\":" + scale +","+ instancePath + metaType+ "},"); + ",\"scale\":" + scale +","+ id + instancePath + metaType+ "},"); } else{ - _serialized.append("\"" + node.getName() +"\":{"+instancePath+metaType+"},"); + _serialized.append("\"" + node.getName() +"\":{"+id+instancePath+metaType+"},"); } return super.visitParameterSpecificationNode(node); @@ -435,6 +463,11 @@ public boolean visitFunctionNode(FunctionNode node) metaType = "\"_metaType\":" + "\"" + node.getMetaType() + "\""; } + String id = ""; + if(node.getId() != null){ + id = "\"id\":" + "\"" + node.getId() + "\","; + } + String instancePath = this.formatInstancePath(node); String properties =""; @@ -455,7 +488,7 @@ public boolean visitFunctionNode(FunctionNode node) } _serialized.append("\"" + node.getName() + "\":{"+ - "\"expression\":" + "\"" + node.getExpression() + "\","+properties+ instancePath + metaType+"},"); + "\"expression\":" + "\"" + node.getExpression() + "\","+properties+ id + instancePath + metaType+"},"); return super.visitFunctionNode(node); } @@ -619,7 +652,12 @@ public boolean visitColladaNode(ColladaNode node) model = "\"model\":" + obj.toString() + ","; } - _serialized.append("\"" + name + "\":{\"position\":{" + positionString + "}," + model +metaType + "},"); + String id = ""; + if(node.getId() != null){ + id = "\"id\":" + "\"" + node.getId() + "\","; + } + + _serialized.append("\"" + name + "\":{\"position\":{" + positionString + "}," + model + id+metaType + "},"); return super.visitColladaNode(node); } @@ -632,6 +670,11 @@ public boolean visitObjNode(OBJNode node) metaType = "\"_metaType\":" + "\"" + node.getMetaType() + "\""; } + String id = ""; + if(node.getId() != null){ + id = "\"id\":" + "\"" + node.getId() + "\","; + } + Point position = node.getPosition(); String name = node.getName(); String positionString = ""; @@ -648,7 +691,7 @@ public boolean visitObjNode(OBJNode node) model = "\"model\":" + obj.toString() + ","; } - _serialized.append("\"" + name + "\":{\"position\":{" + positionString + "}," + model +metaType + "},"); + _serialized.append("\"" + name + "\":{\"position\":{" + positionString + "}," + model + id + metaType + "},"); return super.visitObjNode(node); } From 98fbc09247e209f6527a5716a79e7501a3b54ec1 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Fri, 22 Aug 2014 13:53:22 -0700 Subject: [PATCH 03/21] adding modified flag to subtree --- .../geppetto/core/model/runtime/AspectSubTreeNode.java | 10 +++++++++- .../model/state/visitors/SerializeTreeVisitor.java | 4 +++- .../java/org/geppetto/core/TestTreeSerialization.java | 4 ++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java b/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java index cd3252ce..272442d5 100644 --- a/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java @@ -70,7 +70,7 @@ public String toString() { } private AspectTreeType type; - + private boolean _modified = false; /** * @param modelTree.toString() @@ -99,6 +99,14 @@ public String getType(){ return this.type.toString(); } + public boolean isModified(){ + return this._modified; + } + + public void setModified(boolean mode){ + this._modified = mode; + } + /** * @param tree */ diff --git a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java index 9d1d3133..110ac66a 100644 --- a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java +++ b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java @@ -262,9 +262,11 @@ public boolean outAspectSubTreeNode(AspectSubTreeNode node) id = "\"id\":" + "\"" + node.getId() + "\","; } + String modified ="\"modified\":" + String.valueOf(node.isModified()) + ","; + String instancePath = this.formatInstancePath(node); - _serialized.append(type+id+instancePath); + _serialized.append(type+id+modified+instancePath); this.generalACompositeStateNodeOut(node); return super.outAspectSubTreeNode(node); diff --git a/src/test/java/org/geppetto/core/TestTreeSerialization.java b/src/test/java/org/geppetto/core/TestTreeSerialization.java index cd7e2551..3999261d 100644 --- a/src/test/java/org/geppetto/core/TestTreeSerialization.java +++ b/src/test/java/org/geppetto/core/TestTreeSerialization.java @@ -255,7 +255,7 @@ public void testSkeletonTree() { System.out.println(prettyJsonString); - Assert.assertEquals("{\"root\":{\"Entity_A\":{\"Aspect_A\":{\"ModelTree\":{\"type\":\"ModelTree\",\"instancePath\":\"Entity_A.Aspect_A.ModelTree\",\"_metaType\":\"AspectSubTreeNode\"},\"VisualizationTree\":{\"type\":\"VisualizationTree\",\"instancePath\":\"Entity_A.Aspect_A.VisualizationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"SimulationTree\":{\"type\":\"SimulationTree\",\"instancePath\":\"Entity_A.Aspect_A.SimulationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"instancePath\":\"Entity_A.Aspect_A\",\"_metaType\":\"AspectNode\"},\"instancePath\":\"Entity_A\",\"_metaType\":\"EntityNode\"},\"_metaType\":\"RuntimeTreeRoot\"}}", serialized); + Assert.assertEquals("{\"root\":{\"Entity_A\":{\"Aspect_A\":{\"ModelTree\":{\"type\":\"ModelTree\",\"modified\":false,\"instancePath\":\"Entity_A.Aspect_A.ModelTree\",\"_metaType\":\"AspectSubTreeNode\"},\"VisualizationTree\":{\"type\":\"VisualizationTree\",\"modified\":false,\"instancePath\":\"Entity_A.Aspect_A.VisualizationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"SimulationTree\":{\"type\":\"SimulationTree\",\"modified\":false,\"instancePath\":\"Entity_A.Aspect_A.SimulationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"instancePath\":\"Entity_A.Aspect_A\",\"_metaType\":\"AspectNode\"},\"instancePath\":\"Entity_A\",\"_metaType\":\"EntityNode\"},\"_metaType\":\"RuntimeTreeRoot\"}}", serialized); } /** @@ -440,6 +440,6 @@ public void testRefactorSampleTree() { System.out.println(prettyJsonString); - Assert.assertEquals("{\"RuntimeTree\":{\"Entity1\":{\"AspectA\":{\"ModelTree\":{\"Parameter\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"instancePath\":\"Entity1.AspectA.ModelTree.Parameter\",\"_metaType\":\"ParameterSpecificationNode\"},\"Dynamics\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"_function\":{\"expression\":\"y=x+2\",\"arguments\":{\"0\":\"1\",\"1\":\"2\"}},\"instancePath\":\"Entity1.AspectA.ModelTree.Dynamics\",\"_metaType\":\"DynamicsSpecificationNode\"},\"FunctionNode\":{\"expression\":\"y=x^2\",\"arguments\":{\"0\":\"1\"},\"instancePath\":\"Entity1.AspectA.ModelTree.FunctionNode\",\"_metaType\":\"FunctionNode\"},\"type\":\"ModelTree\",\"instancePath\":\"Entity1.AspectA.ModelTree\",\"_metaType\":\"AspectSubTreeNode\"},\"VisualizationTree\":{\"vg\":{\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg\",\"_metaType\":\"CompositeNode\"},\"vg2\":{\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg2\",\"_metaType\":\"CompositeNode\"},\"type\":\"VisualizationTree\",\"instancePath\":\"Entity1.AspectA.VisualizationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"SimulationTree\":{\"hhpop\":[{\"v\":{\"value\":20.0,\"unit\":null,\"scale\":null,\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].v\",\"_metaType\":\"VariableNode\"},\"a\":{\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].a\",\"_metaType\":\"ParameterNode\"},\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0]\",\"_metaType\":\"CompositeNode\"}],\"type\":\"SimulationTree\",\"instancePath\":\"Entity1.AspectA.SimulationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"id\":\"12\",\"simulator\":\"test\",\"modelInterpreter\":\"Test Model interpreter\",\"instancePath\":\"Entity1.AspectA\",\"_metaType\":\"AspectNode\"},\"instancePath\":\"Entity1\",\"_metaType\":\"EntityNode\"},\"_metaType\":\"RuntimeTreeRoot\"}}", serialized); + Assert.assertEquals("{\"RuntimeTree\":{\"Entity1\":{\"AspectA\":{\"ModelTree\":{\"Parameter\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"instancePath\":\"Entity1.AspectA.ModelTree.Parameter\",\"_metaType\":\"ParameterSpecificationNode\"},\"Dynamics\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"_function\":{\"expression\":\"y=x+2\",\"arguments\":{\"0\":\"1\",\"1\":\"2\"}},\"instancePath\":\"Entity1.AspectA.ModelTree.Dynamics\",\"_metaType\":\"DynamicsSpecificationNode\"},\"FunctionNode\":{\"expression\":\"y=x^2\",\"arguments\":{\"0\":\"1\"},\"instancePath\":\"Entity1.AspectA.ModelTree.FunctionNode\",\"_metaType\":\"FunctionNode\"},\"type\":\"ModelTree\",\"modified\":false,\"instancePath\":\"Entity1.AspectA.ModelTree\",\"_metaType\":\"AspectSubTreeNode\"},\"VisualizationTree\":{\"vg\":{\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg\",\"_metaType\":\"CompositeNode\"},\"vg2\":{\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg2\",\"_metaType\":\"CompositeNode\"},\"type\":\"VisualizationTree\",\"modified\":false,\"instancePath\":\"Entity1.AspectA.VisualizationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"SimulationTree\":{\"hhpop\":[{\"v\":{\"value\":20.0,\"unit\":null,\"scale\":null,\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].v\",\"_metaType\":\"VariableNode\"},\"a\":{\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].a\",\"_metaType\":\"ParameterNode\"},\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0]\",\"_metaType\":\"CompositeNode\"}],\"type\":\"SimulationTree\",\"modified\":false,\"instancePath\":\"Entity1.AspectA.SimulationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"id\":\"12\",\"simulator\":\"test\",\"modelInterpreter\":\"Test Model interpreter\",\"instancePath\":\"Entity1.AspectA\",\"_metaType\":\"AspectNode\"},\"instancePath\":\"Entity1\",\"_metaType\":\"EntityNode\"},\"_metaType\":\"RuntimeTreeRoot\"}}", serialized); } } \ No newline at end of file From bf46d40baaa03df4ef3354196dcaef2718300edb Mon Sep 17 00:00:00 2001 From: jrmartin Date: Thu, 28 Aug 2014 20:37:15 -0700 Subject: [PATCH 04/21] setting id of aspectsubtree --- .../java/org/geppetto/core/model/runtime/AspectSubTreeNode.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java b/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java index 272442d5..f4970ef5 100644 --- a/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java @@ -130,6 +130,7 @@ public void flushSubTree(AspectTreeType tree) private AspectSubTreeNode addSubTree(AspectTreeType treeType) { AspectSubTreeNode subTree = new AspectSubTreeNode(treeType.toString()); + subTree.setId(treeType.toString()); addChild(subTree); return subTree; } From ecccbec54b6457c34a6fecc53d47f0b25d3c0d8c Mon Sep 17 00:00:00 2001 From: jrmartin Date: Fri, 29 Aug 2014 13:28:05 -0700 Subject: [PATCH 05/21] visitor changes to only visit subtree if it has been modified --- .../state/visitors/SerializeTreeVisitor.java | 34 +++++++++++++------ .../geppetto/core/TestTreeSerialization.java | 7 ++-- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java index 110ac66a..9373a770 100644 --- a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java +++ b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java @@ -77,20 +77,20 @@ public void generalACompositeStateNodeIn(ACompositeNode node){ _serialized.append(namePath); - if(node.getChildren().size() > 1){ + //add bracket if node hsa more children + if(node.getChildren().size() >= 1){ + //add brakcet if not instance of compositenode if(!(node.getChildren().get(0) instanceof ACompositeNode)){ _serialized.append("{"); } - } - - // puts bracket around leaf simplestatenode - else if(node.getChildren().size() == 1){ - if(!(node.getChildren().get(0) instanceof ACompositeNode)){ - _serialized.append("{"); + //add bracket to subtree if it wasn't modified + else if(node instanceof AspectSubTreeNode){ + if(!((AspectSubTreeNode) node).isModified()){ + _serialized.append("{"); + } } } else if(node.getChildren().size() == 0){ - _serialized.append("{"); } @@ -246,7 +246,14 @@ public boolean outEntityNode(EntityNode node) public boolean inAspectSubTreeNode(AspectSubTreeNode node) { this.generalACompositeStateNodeIn(node); - return super.inAspectSubTreeNode(node); + + //only traverse inside of subtree if modified flag is set to true + if(node.isModified()){ + return super.inAspectSubTreeNode(node); + } + else{ + return false; + } } @Override @@ -269,7 +276,14 @@ public boolean outAspectSubTreeNode(AspectSubTreeNode node) _serialized.append(type+id+modified+instancePath); this.generalACompositeStateNodeOut(node); - return super.outAspectSubTreeNode(node); + + //only traverse through subtree nodes if modified flag is set to true + if(node.isModified()){ + return super.outAspectSubTreeNode(node); + } + else{ + return false; + } } @Override diff --git a/src/test/java/org/geppetto/core/TestTreeSerialization.java b/src/test/java/org/geppetto/core/TestTreeSerialization.java index 3999261d..d588574f 100644 --- a/src/test/java/org/geppetto/core/TestTreeSerialization.java +++ b/src/test/java/org/geppetto/core/TestTreeSerialization.java @@ -298,6 +298,8 @@ public void testRefactorSampleTree() { aspectA.setModelInterpreter(modelInt); AspectSubTreeNode model = new AspectSubTreeNode(AspectTreeType.MODEL_TREE); + model.setModified(true); + DynamicsSpecificationNode dynamics = new DynamicsSpecificationNode("Dynamics"); PhysicalQuantity value = new PhysicalQuantity(); @@ -332,6 +334,7 @@ public void testRefactorSampleTree() { AspectSubTreeNode visualization = new AspectSubTreeNode(AspectTreeType.VISUALIZATION_TREE); + visualization.setModified(true); SphereNode sphere = new SphereNode("sphere"); Point p = new Point(); @@ -396,7 +399,7 @@ public void testRefactorSampleTree() { vg2.addChild(sphere); AspectSubTreeNode simulation = new AspectSubTreeNode(AspectTreeType.WATCH_TREE); - + simulation.setModified(true); CompositeNode hhpop = new CompositeNode("hhpop[0]"); @@ -440,6 +443,6 @@ public void testRefactorSampleTree() { System.out.println(prettyJsonString); - Assert.assertEquals("{\"RuntimeTree\":{\"Entity1\":{\"AspectA\":{\"ModelTree\":{\"Parameter\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"instancePath\":\"Entity1.AspectA.ModelTree.Parameter\",\"_metaType\":\"ParameterSpecificationNode\"},\"Dynamics\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"_function\":{\"expression\":\"y=x+2\",\"arguments\":{\"0\":\"1\",\"1\":\"2\"}},\"instancePath\":\"Entity1.AspectA.ModelTree.Dynamics\",\"_metaType\":\"DynamicsSpecificationNode\"},\"FunctionNode\":{\"expression\":\"y=x^2\",\"arguments\":{\"0\":\"1\"},\"instancePath\":\"Entity1.AspectA.ModelTree.FunctionNode\",\"_metaType\":\"FunctionNode\"},\"type\":\"ModelTree\",\"modified\":false,\"instancePath\":\"Entity1.AspectA.ModelTree\",\"_metaType\":\"AspectSubTreeNode\"},\"VisualizationTree\":{\"vg\":{\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg\",\"_metaType\":\"CompositeNode\"},\"vg2\":{\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg2\",\"_metaType\":\"CompositeNode\"},\"type\":\"VisualizationTree\",\"modified\":false,\"instancePath\":\"Entity1.AspectA.VisualizationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"SimulationTree\":{\"hhpop\":[{\"v\":{\"value\":20.0,\"unit\":null,\"scale\":null,\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].v\",\"_metaType\":\"VariableNode\"},\"a\":{\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].a\",\"_metaType\":\"ParameterNode\"},\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0]\",\"_metaType\":\"CompositeNode\"}],\"type\":\"SimulationTree\",\"modified\":false,\"instancePath\":\"Entity1.AspectA.SimulationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"id\":\"12\",\"simulator\":\"test\",\"modelInterpreter\":\"Test Model interpreter\",\"instancePath\":\"Entity1.AspectA\",\"_metaType\":\"AspectNode\"},\"instancePath\":\"Entity1\",\"_metaType\":\"EntityNode\"},\"_metaType\":\"RuntimeTreeRoot\"}}", serialized); + Assert.assertEquals("{\"RuntimeTree\":{\"Entity1\":{\"AspectA\":{\"ModelTree\":{\"Parameter\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"instancePath\":\"Entity1.AspectA.ModelTree.Parameter\",\"_metaType\":\"ParameterSpecificationNode\"},\"Dynamics\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"_function\":{\"expression\":\"y=x+2\",\"arguments\":{\"0\":\"1\",\"1\":\"2\"}},\"instancePath\":\"Entity1.AspectA.ModelTree.Dynamics\",\"_metaType\":\"DynamicsSpecificationNode\"},\"FunctionNode\":{\"expression\":\"y=x^2\",\"arguments\":{\"0\":\"1\"},\"instancePath\":\"Entity1.AspectA.ModelTree.FunctionNode\",\"_metaType\":\"FunctionNode\"},\"type\":\"ModelTree\",\"modified\":true,\"instancePath\":\"Entity1.AspectA.ModelTree\",\"_metaType\":\"AspectSubTreeNode\"},\"VisualizationTree\":{\"vg\":{\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg\",\"_metaType\":\"CompositeNode\"},\"vg2\":{\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg2\",\"_metaType\":\"CompositeNode\"},\"type\":\"VisualizationTree\",\"modified\":true,\"instancePath\":\"Entity1.AspectA.VisualizationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"SimulationTree\":{\"hhpop\":[{\"v\":{\"value\":20.0,\"unit\":null,\"scale\":null,\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].v\",\"_metaType\":\"VariableNode\"},\"a\":{\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].a\",\"_metaType\":\"ParameterNode\"},\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0]\",\"_metaType\":\"CompositeNode\"}],\"type\":\"SimulationTree\",\"modified\":true,\"instancePath\":\"Entity1.AspectA.SimulationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"id\":\"12\",\"simulator\":\"test\",\"modelInterpreter\":\"Test Model interpreter\",\"instancePath\":\"Entity1.AspectA\",\"_metaType\":\"AspectNode\"},\"instancePath\":\"Entity1\",\"_metaType\":\"EntityNode\"},\"_metaType\":\"RuntimeTreeRoot\"}}", serialized); } } \ No newline at end of file From ef8142ae730dbff00df598d6e732afca118aecd7 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Fri, 29 Aug 2014 17:59:51 -0700 Subject: [PATCH 06/21] remove facetime, not needed --- ...rg.eclipse.wst.common.project.facet.core.xml | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index 0bd47b18..8a3719c4 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,9 +1,8 @@ - - - - - - - - - + + + + + + + + From 1f257bda0f670a9b51c426678b4f69f7fb4db7e4 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Sat, 30 Aug 2014 20:58:38 -0700 Subject: [PATCH 07/21] adding requestIDs to some methods --- .../java/org/geppetto/core/simulation/ISimulation.java | 7 ++++--- .../core/simulation/ISimulationCallbackListener.java | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/geppetto/core/simulation/ISimulation.java b/src/main/java/org/geppetto/core/simulation/ISimulation.java index 6b9edc17..21eb184f 100644 --- a/src/main/java/org/geppetto/core/simulation/ISimulation.java +++ b/src/main/java/org/geppetto/core/simulation/ISimulation.java @@ -54,7 +54,7 @@ public interface ISimulation { * @param simConfigURL * @param simulationListener */ - void init(URL simConfigURL, ISimulationCallbackListener simulationListener) throws GeppettoInitializationException; + void init(URL simConfigURL, String requestID, ISimulationCallbackListener simulationListener) throws GeppettoInitializationException; /** * Initialize the simulation from a string containing the simulation configuration @@ -63,12 +63,13 @@ public interface ISimulation { * @param simulationListener * @throws GeppettoInitializationException */ - void init(String simulationConfig, ISimulationCallbackListener simulationListener) throws GeppettoInitializationException; + void init(String simulationConfig, String requestID, ISimulationCallbackListener simulationListener) throws GeppettoInitializationException; /** + * @param requestID * */ - void start() throws GeppettoExecutionException; + void start(String requestID) throws GeppettoExecutionException; /** * diff --git a/src/main/java/org/geppetto/core/simulation/ISimulationCallbackListener.java b/src/main/java/org/geppetto/core/simulation/ISimulationCallbackListener.java index f23820f7..f98d7a52 100644 --- a/src/main/java/org/geppetto/core/simulation/ISimulationCallbackListener.java +++ b/src/main/java/org/geppetto/core/simulation/ISimulationCallbackListener.java @@ -40,10 +40,10 @@ public interface ISimulationCallbackListener public enum SimulationEvents { LOAD_MODEL, SCENE_UPDATE, - SIMULATION_OVER + SIMULATION_OVER, START_SIMULATION } - void updateReady(SimulationEvents event, String sceneUpdate); + void updateReady(SimulationEvents event, String requestID, String sceneUpdate); void error(GeppettoErrorCodes error, String classSource, String errorMessage, Exception e); } From 2a50f49029cdd119cb3929e14ecead6b180623f8 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Wed, 10 Sep 2014 15:29:15 -0700 Subject: [PATCH 08/21] fix collada and obj, was missing setmodified(true) after populating visual tree --- .../core/simulator/services/ColladaSimulatorService.java | 2 ++ .../geppetto/core/simulator/services/OBJSimulatorService.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/org/geppetto/core/simulator/services/ColladaSimulatorService.java b/src/main/java/org/geppetto/core/simulator/services/ColladaSimulatorService.java index fe283963..b881d393 100644 --- a/src/main/java/org/geppetto/core/simulator/services/ColladaSimulatorService.java +++ b/src/main/java/org/geppetto/core/simulator/services/ColladaSimulatorService.java @@ -41,6 +41,7 @@ import org.geppetto.core.model.ModelInterpreterException; import org.geppetto.core.model.ModelWrapper; import org.geppetto.core.model.runtime.AspectNode; +import org.geppetto.core.model.runtime.AspectSubTreeNode; import org.geppetto.core.model.runtime.ColladaNode; import org.geppetto.core.model.runtime.AspectSubTreeNode.AspectTreeType; import org.geppetto.core.simulation.IRunConfiguration; @@ -118,6 +119,7 @@ public boolean populateVisualTree(AspectNode aspectNode) collada.setModel((String) ((ModelWrapper) aspectNode.getModel()).getModel("COLLADA")); aspectNode.getSubTree(AspectTreeType.VISUALIZATION_TREE).addChild(collada); + ((AspectSubTreeNode) aspectNode.getSubTree(AspectTreeType.VISUALIZATION_TREE)).setModified(true); return false; } diff --git a/src/main/java/org/geppetto/core/simulator/services/OBJSimulatorService.java b/src/main/java/org/geppetto/core/simulator/services/OBJSimulatorService.java index 8b121d34..5ef34e24 100644 --- a/src/main/java/org/geppetto/core/simulator/services/OBJSimulatorService.java +++ b/src/main/java/org/geppetto/core/simulator/services/OBJSimulatorService.java @@ -41,6 +41,7 @@ import org.geppetto.core.model.ModelInterpreterException; import org.geppetto.core.model.ModelWrapper; import org.geppetto.core.model.runtime.AspectNode; +import org.geppetto.core.model.runtime.AspectSubTreeNode; import org.geppetto.core.model.runtime.AspectSubTreeNode.AspectTreeType; import org.geppetto.core.model.runtime.OBJNode; import org.geppetto.core.simulation.IRunConfiguration; @@ -118,6 +119,7 @@ public boolean populateVisualTree(AspectNode aspectNode) obj.setModel((String) ((ModelWrapper) aspectNode.getModel()).getModel("OBJ")); aspectNode.getSubTree(AspectTreeType.VISUALIZATION_TREE).addChild(obj); + ((AspectSubTreeNode) aspectNode.getSubTree(AspectTreeType.VISUALIZATION_TREE)).setModified(true); return false; } From 14b68dd646d74b4f06aecd20f9a12265f5911f79 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Fri, 12 Sep 2014 14:10:35 -0700 Subject: [PATCH 09/21] add setInitialize method to ISimulator to allow setting flag to false --- src/main/java/org/geppetto/core/simulator/ASimulator.java | 6 ++++++ src/main/java/org/geppetto/core/simulator/ISimulator.java | 2 ++ src/test/java/org/geppetto/core/TestSimulator.java | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/src/main/java/org/geppetto/core/simulator/ASimulator.java b/src/main/java/org/geppetto/core/simulator/ASimulator.java index 8af7cb52..91621012 100644 --- a/src/main/java/org/geppetto/core/simulator/ASimulator.java +++ b/src/main/java/org/geppetto/core/simulator/ASimulator.java @@ -155,6 +155,12 @@ public boolean isInitialized() { return _initialized; } + + @Override + public void setInitialized(boolean initialized) + { + _initialized = initialized; + } /** * @param _listener diff --git a/src/main/java/org/geppetto/core/simulator/ISimulator.java b/src/main/java/org/geppetto/core/simulator/ISimulator.java index 41cf74c7..cffd421d 100644 --- a/src/main/java/org/geppetto/core/simulator/ISimulator.java +++ b/src/main/java/org/geppetto/core/simulator/ISimulator.java @@ -84,4 +84,6 @@ public interface ISimulator { void clearWatchVariables(); boolean populateVisualTree(AspectNode aspectNode) throws ModelInterpreterException, GeppettoExecutionException; + + void setInitialized(boolean initialized); } diff --git a/src/test/java/org/geppetto/core/TestSimulator.java b/src/test/java/org/geppetto/core/TestSimulator.java index 654f3ba5..bf7b3e16 100644 --- a/src/test/java/org/geppetto/core/TestSimulator.java +++ b/src/test/java/org/geppetto/core/TestSimulator.java @@ -137,4 +137,10 @@ public String getId() return null; } + @Override + public void setInitialized(boolean initialized) { + // TODO Auto-generated method stub + + } + } From 5b2aadb5976b464f88ad1e992bd20d59a04d8d84 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Sat, 13 Sep 2014 09:01:52 -0700 Subject: [PATCH 10/21] setting id for collada and obj simulators. Sends notifyTreeUpdate() from simulate() method, dummy updates. --- .../core/simulator/services/ColladaSimulatorService.java | 4 ++-- .../geppetto/core/simulator/services/OBJSimulatorService.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/geppetto/core/simulator/services/ColladaSimulatorService.java b/src/main/java/org/geppetto/core/simulator/services/ColladaSimulatorService.java index b881d393..c380b1c0 100644 --- a/src/main/java/org/geppetto/core/simulator/services/ColladaSimulatorService.java +++ b/src/main/java/org/geppetto/core/simulator/services/ColladaSimulatorService.java @@ -56,6 +56,7 @@ public class ColladaSimulatorService extends ASimulator{ public void simulate(IRunConfiguration runConfiguration, AspectNode aspect) throws GeppettoExecutionException { advanceTimeStep(0); + notifyStateTreeUpdated(); } @Override @@ -85,7 +86,7 @@ public String getName() { @Override public String getId() { // TODO Auto-generated method stub - return null; + return "colladaSimulator"; } @Override @@ -123,5 +124,4 @@ public boolean populateVisualTree(AspectNode aspectNode) return false; } - } diff --git a/src/main/java/org/geppetto/core/simulator/services/OBJSimulatorService.java b/src/main/java/org/geppetto/core/simulator/services/OBJSimulatorService.java index 5ef34e24..b6b42b34 100644 --- a/src/main/java/org/geppetto/core/simulator/services/OBJSimulatorService.java +++ b/src/main/java/org/geppetto/core/simulator/services/OBJSimulatorService.java @@ -56,6 +56,7 @@ public class OBJSimulatorService extends ASimulator{ public void simulate(IRunConfiguration runConfiguration, AspectNode aspect) throws GeppettoExecutionException { advanceTimeStep(0); + notifyStateTreeUpdated(); } @Override @@ -85,7 +86,7 @@ public String getName() { @Override public String getId() { // TODO Auto-generated method stub - return null; + return "objSimulator"; } @Override @@ -123,5 +124,4 @@ public boolean populateVisualTree(AspectNode aspectNode) return false; } - } From 3a936b374f57599927da3dafbe356f882df7bbb7 Mon Sep 17 00:00:00 2001 From: Matteo Cantarelli Date: Tue, 16 Sep 2014 17:32:03 -0700 Subject: [PATCH 11/21] Adding throws clause in the interface and string constructor for ModelInterpreterException --- .../java/org/geppetto/core/model/IModelInterpreter.java | 7 +------ .../org/geppetto/core/model/ModelInterpreterException.java | 5 +++++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/geppetto/core/model/IModelInterpreter.java b/src/main/java/org/geppetto/core/model/IModelInterpreter.java index 4cf26c84..01817dbe 100644 --- a/src/main/java/org/geppetto/core/model/IModelInterpreter.java +++ b/src/main/java/org/geppetto/core/model/IModelInterpreter.java @@ -36,12 +36,7 @@ import java.net.URL; import java.util.List; -import org.geppetto.core.model.runtime.ACompositeNode; import org.geppetto.core.model.runtime.AspectNode; -import org.geppetto.core.model.runtime.AspectSubTreeNode; -import org.geppetto.core.model.runtime.EntityNode; -import org.geppetto.core.model.runtime.RuntimeTreeRoot; -import org.geppetto.core.model.simulation.Aspect; public interface IModelInterpreter { @@ -49,7 +44,7 @@ public interface IModelInterpreter { boolean populateModelTree(AspectNode aspectNode) throws ModelInterpreterException; - boolean populateRuntimeTree(AspectNode aspectNode); + boolean populateRuntimeTree(AspectNode aspectNode) throws ModelInterpreterException;; String getName(); } diff --git a/src/main/java/org/geppetto/core/model/ModelInterpreterException.java b/src/main/java/org/geppetto/core/model/ModelInterpreterException.java index a68116ab..5709b890 100644 --- a/src/main/java/org/geppetto/core/model/ModelInterpreterException.java +++ b/src/main/java/org/geppetto/core/model/ModelInterpreterException.java @@ -41,6 +41,11 @@ public class ModelInterpreterException extends Exception { + public ModelInterpreterException(String message) + { + super(message); + } + public ModelInterpreterException(Throwable e) { super(e); From 32c9120cee8c67bd76246c413a23aadcd86d24fd Mon Sep 17 00:00:00 2001 From: Adrian Quintana Date: Wed, 17 Sep 2014 20:39:37 +0100 Subject: [PATCH 12/21] Added some constructors in order to ease model tree population --- .../org/geppetto/core/model/runtime/AMetadataNode.java | 5 +++++ .../org/geppetto/core/model/runtime/CompositeNode.java | 5 +++++ .../core/model/runtime/ParameterSpecificationNode.java | 5 +++++ .../geppetto/core/model/runtime/TextMetadataNode.java | 10 ++++++++++ 4 files changed, 25 insertions(+) diff --git a/src/main/java/org/geppetto/core/model/runtime/AMetadataNode.java b/src/main/java/org/geppetto/core/model/runtime/AMetadataNode.java index 18ed4234..3da2ef03 100644 --- a/src/main/java/org/geppetto/core/model/runtime/AMetadataNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/AMetadataNode.java @@ -47,6 +47,11 @@ public AMetadataNode(String name) { super(name); } + public AMetadataNode(String name, AValue value) { + super(name); + setValue(value); + } + public AValue getValue() { return value; } diff --git a/src/main/java/org/geppetto/core/model/runtime/CompositeNode.java b/src/main/java/org/geppetto/core/model/runtime/CompositeNode.java index 2a31582f..51c45ec4 100644 --- a/src/main/java/org/geppetto/core/model/runtime/CompositeNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/CompositeNode.java @@ -46,6 +46,11 @@ public CompositeNode(String name) { super(name); } + public CompositeNode(String name, String id) { + super(name); + setId(id); + } + public CompositeNode() { super(); } diff --git a/src/main/java/org/geppetto/core/model/runtime/ParameterSpecificationNode.java b/src/main/java/org/geppetto/core/model/runtime/ParameterSpecificationNode.java index d34585b9..2c462d19 100644 --- a/src/main/java/org/geppetto/core/model/runtime/ParameterSpecificationNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/ParameterSpecificationNode.java @@ -50,6 +50,11 @@ public ParameterSpecificationNode(String name){ super(name); } + public ParameterSpecificationNode(String name, String id){ + super(name); + setId(id); + } + public void setValue(PhysicalQuantity value){ this._value = value; } diff --git a/src/main/java/org/geppetto/core/model/runtime/TextMetadataNode.java b/src/main/java/org/geppetto/core/model/runtime/TextMetadataNode.java index d699142f..3411e48a 100644 --- a/src/main/java/org/geppetto/core/model/runtime/TextMetadataNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/TextMetadataNode.java @@ -36,6 +36,7 @@ import java.util.Map; import org.geppetto.core.model.state.visitors.IStateVisitor; +import org.geppetto.core.model.values.AValue; /** * Node use for storing text metadata properties and serialization @@ -51,6 +52,15 @@ public TextMetadataNode(String name){ super(name); } + public TextMetadataNode(String name, AValue value){ + super(name, value); + } + + public TextMetadataNode(String name, String id, AValue value){ + super(name, value); + setId(id); + } + public TextMetadataNode(){ super("TextMetadataNode"); } From abdb6c6d602a259aecf248671547f41d8a865584 Mon Sep 17 00:00:00 2001 From: Matteo Cantarelli Date: Wed, 17 Sep 2014 22:53:07 -0700 Subject: [PATCH 13/21] Entities should also visit the aspects --- .../java/org/geppetto/core/model/runtime/EntityNode.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/geppetto/core/model/runtime/EntityNode.java b/src/main/java/org/geppetto/core/model/runtime/EntityNode.java index 9a0ef4c0..eaa919d1 100644 --- a/src/main/java/org/geppetto/core/model/runtime/EntityNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/EntityNode.java @@ -103,6 +103,14 @@ public synchronized boolean apply(IStateVisitor visitor) break; } } + for(AspectNode stateNode:this.getAspects()) + { + stateNode.apply(visitor); + if(visitor.stopVisiting()) + { + break; + } + } } return visitor.outEntityNode( this ); } From a5004ac7e46e61081605cba8031457105ae3d014 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Thu, 18 Sep 2014 09:50:56 -0700 Subject: [PATCH 14/21] fix serialization issues, adds test for deeper network --- .../state/visitors/SerializeTreeVisitor.java | 51 ++++- .../geppetto/core/TestTreeSerialization.java | 187 +++++++++++++++++- 2 files changed, 228 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java index 9373a770..44bbc037 100644 --- a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java +++ b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java @@ -40,7 +40,7 @@ public SerializeTreeVisitor(){ public void generalACompositeStateNodeIn(ACompositeNode node){ String name = node.getBaseName(); - if(node.isArray() && node.getParent() != null){ + if(node.isArray()){ int index = node.getIndex(); Map indexMap = _arraysLastIndexMap.get(node.getParent()); @@ -61,18 +61,18 @@ public void generalACompositeStateNodeIn(ACompositeNode node){ } indexMap.put(name, index); } - else{ + else{ String namePath = "{\"" + name + "\":"; + ANode parent = node.getParent(); if(parent != null){ - if(((ACompositeNode) parent).getChildren().contains(node)){ - if(((ACompositeNode) parent).getChildren().indexOf(node) > 0){ + ACompositeNode castParent = ((ACompositeNode) parent); + if(castParent.getChildren().indexOf(node) > 0 ){ if(_serialized.length() != 0){ namePath = namePath.replace("{", ""); } } - } } _serialized.append(namePath); @@ -175,7 +175,18 @@ public boolean outCompositeNode(CompositeNode node) @Override public boolean inAspectNode(AspectNode node) { - this.generalACompositeStateNodeIn(node); + String namePath = ""; + + if(_serialized.charAt(_serialized.length() - 1) == '{' || + _serialized.charAt(_serialized.length() - 1) == ',') + { + namePath = "\"" + node.getName() + "\":"; + } + else{ + namePath = "{\"" + node.getName() + "\":"; + } + + _serialized.append(namePath); return super.inAspectNode(node); } @@ -183,7 +194,13 @@ public boolean inAspectNode(AspectNode node) @Override public boolean outAspectNode(AspectNode node) { - + + //add bracket if node hsa more children + if(node.getChildren().size() == 0){ + //add brakcet if not instance of compositenode + _serialized.append("{"); + } + String id = ""; if(node.getId() != null){ id = "\"id\":" + "\"" + node.getId() + "\","; @@ -214,7 +231,25 @@ public boolean outAspectNode(AspectNode node) @Override public boolean inEntityNode(EntityNode node) { - this.generalACompositeStateNodeIn(node); + String namePath = "{\"" + node.getName() + "\":"; + + if(_serialized.charAt(_serialized.length() - 1) == '{' || + _serialized.charAt(_serialized.length() - 1) == ',') + { + namePath = "\"" + node.getName() + "\":"; + } + else{ + namePath = "{\"" + node.getName() + "\":"; + } + + _serialized.append(namePath); + + //add bracket if node hsa more children + if(node.getChildren().size() == 0){ + //add brakcet if not instance of compositenode + _serialized.append("{"); + } + return super.inEntityNode(node); } diff --git a/src/test/java/org/geppetto/core/TestTreeSerialization.java b/src/test/java/org/geppetto/core/TestTreeSerialization.java index d588574f..f993ec22 100644 --- a/src/test/java/org/geppetto/core/TestTreeSerialization.java +++ b/src/test/java/org/geppetto/core/TestTreeSerialization.java @@ -238,7 +238,8 @@ public void testSkeletonTree() { AspectSubTreeNode simulation = new AspectSubTreeNode(AspectTreeType.WATCH_TREE); runtime.addChild(entity_A); - entity_A.addChild(aspect_A); + entity_A.getAspects().add(aspect_A); + aspect_A.setParent(entity_A); aspect_A.addChild(model); aspect_A.addChild(visualization); aspect_A.addChild(simulation); @@ -416,7 +417,8 @@ public void testRefactorSampleTree() { ParameterNode a1 = new ParameterNode("a"); runtimeTree.addChild(entity1); - entity1.addChild(aspectA); + entity1.getAspects().add(aspectA); + aspectA.setParent(entity1); aspectA.addChild(model); model.addChild(parameter); model.addChild(dynamics); @@ -445,4 +447,185 @@ public void testRefactorSampleTree() { Assert.assertEquals("{\"RuntimeTree\":{\"Entity1\":{\"AspectA\":{\"ModelTree\":{\"Parameter\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"instancePath\":\"Entity1.AspectA.ModelTree.Parameter\",\"_metaType\":\"ParameterSpecificationNode\"},\"Dynamics\":{\"value\":\"10.0\",\"unit\":\"ms\",\"scale\":\"10\",\"_function\":{\"expression\":\"y=x+2\",\"arguments\":{\"0\":\"1\",\"1\":\"2\"}},\"instancePath\":\"Entity1.AspectA.ModelTree.Dynamics\",\"_metaType\":\"DynamicsSpecificationNode\"},\"FunctionNode\":{\"expression\":\"y=x^2\",\"arguments\":{\"0\":\"1\"},\"instancePath\":\"Entity1.AspectA.ModelTree.FunctionNode\",\"_metaType\":\"FunctionNode\"},\"type\":\"ModelTree\",\"modified\":true,\"instancePath\":\"Entity1.AspectA.ModelTree\",\"_metaType\":\"AspectSubTreeNode\"},\"VisualizationTree\":{\"vg\":{\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg\",\"_metaType\":\"CompositeNode\"},\"vg2\":{\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"cylinder\":{\"position\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"distal\":{\"x\":6.3,\"y\":8.0,\"z\":-3.999},\"radiusBottom\":\"34.55\",\"radiusTop\":\"34.55\",\"_metaType\":\"CylinderNode\"},\"sphere\":{\"position\":{\"x\":3.3,\"y\":4.0,\"z\":-1.444},\"radius\":\"33.0\",\"_metaType\":\"SphereNode\"},\"instancePath\":\"Entity1.AspectA.VisualizationTree.vg2\",\"_metaType\":\"CompositeNode\"},\"type\":\"VisualizationTree\",\"modified\":true,\"instancePath\":\"Entity1.AspectA.VisualizationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"SimulationTree\":{\"hhpop\":[{\"v\":{\"value\":20.0,\"unit\":null,\"scale\":null,\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].v\",\"_metaType\":\"VariableNode\"},\"a\":{\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0].a\",\"_metaType\":\"ParameterNode\"},\"instancePath\":\"Entity1.AspectA.SimulationTree.hhpop[0]\",\"_metaType\":\"CompositeNode\"}],\"type\":\"SimulationTree\",\"modified\":true,\"instancePath\":\"Entity1.AspectA.SimulationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"id\":\"12\",\"simulator\":\"test\",\"modelInterpreter\":\"Test Model interpreter\",\"instancePath\":\"Entity1.AspectA\",\"_metaType\":\"AspectNode\"},\"instancePath\":\"Entity1\",\"_metaType\":\"EntityNode\"},\"_metaType\":\"RuntimeTreeRoot\"}}", serialized); } + + @Test + public void testNetworks() { + + RuntimeTreeRoot runtimeTree = new RuntimeTreeRoot("RuntimeTree"); + + EntityNode entity1 = new EntityNode("Entity1"); + EntityNode entity2 = new EntityNode("Entity2"); + EntityNode entity3 = new EntityNode("Entity3"); + + AspectNode aspectA = new AspectNode("Aspect1"); + aspectA.setId("12"); + TestSimulator sim = new TestSimulator(); + aspectA.setSimulator(sim); + TestModelInterpreter modelInt = new TestModelInterpreter(); + aspectA.setModelInterpreter(modelInt); + + AspectNode aspectB = new AspectNode("Aspect2"); + aspectA.setId("125"); + aspectA.setSimulator(sim); + aspectA.setModelInterpreter(modelInt); + + AspectNode aspectC = new AspectNode("Aspect3"); + aspectB.setId("123"); + aspectB.setSimulator(sim); + aspectB.setModelInterpreter(modelInt); + + AspectSubTreeNode model = new AspectSubTreeNode(AspectTreeType.MODEL_TREE); + model.setModified(true); + + DynamicsSpecificationNode dynamics = new DynamicsSpecificationNode("Dynamics"); + + PhysicalQuantity value = new PhysicalQuantity(); + value.setScalingFactor("10"); + value.setUnit("ms"); + value.setValue(new DoubleValue(10)); + dynamics.setInitialConditions(value); + + FunctionNode function = new FunctionNode("Function"); + function.setExpression("y=x+2"); + List argumentsF = new ArrayList(); + argumentsF.add("1"); + argumentsF.add("2"); + function.setArgument(argumentsF); + + dynamics.setDynamics(function); + + ParameterSpecificationNode parameter = new ParameterSpecificationNode("Parameter"); + + PhysicalQuantity value1 = new PhysicalQuantity(); + value1.setScalingFactor("10"); + value1.setUnit("ms"); + value1.setValue(new DoubleValue(10)); + + parameter.setValue(value1); + + FunctionNode functionNode = new FunctionNode("FunctionNode"); + functionNode.setExpression("y=x^2"); + List arguments = new ArrayList(); + arguments.add("1"); + functionNode.setArgument(arguments); + + + AspectSubTreeNode visualization = new AspectSubTreeNode(AspectTreeType.VISUALIZATION_TREE); + visualization.setModified(true); + + SphereNode sphere = new SphereNode("sphere"); + Point p = new Point(); + p.setX(new Double(3.3)); + p.setY(new Double(4)); + p.setZ(new Double(-1.444)); + sphere.setPosition(p); + sphere.setRadius(new Double(33)); + + CylinderNode cylinder = new CylinderNode("cylinder"); + Point p2 = new Point(); + p2.setX(new Double(6.3)); + p2.setY(new Double(8)); + p2.setZ(new Double(-3.999)); + cylinder.setPosition(p2); + Point p3 = new Point(); + p3.setX(new Double(6.3)); + p3.setY(new Double(8)); + p3.setZ(new Double(-3.999)); + cylinder.setDistal(p3); + cylinder.setRadiusBottom(new Double(34.55)); + cylinder.setRadiusTop(new Double(34.55)); + + CylinderNode cylinder2 = new CylinderNode("cylinder"); + cylinder2.setPosition(p2); + cylinder2.setDistal(p3); + cylinder2.setRadiusBottom(new Double(34.55)); + cylinder2.setRadiusTop(new Double(34.55)); + + CylinderNode cylinder3 = new CylinderNode("cylinder"); + cylinder3.setPosition(p2); + cylinder3.setDistal(p3); + cylinder3.setRadiusBottom(new Double(34.55)); + cylinder3.setRadiusTop(new Double(34.55)); + + CylinderNode cylinder4 = new CylinderNode("cylinder"); + cylinder4.setPosition(p2); + cylinder4.setDistal(p3); + cylinder4.setRadiusBottom(new Double(34.55)); + cylinder4.setRadiusTop(new Double(34.55)); + + CylinderNode cylinder5 = new CylinderNode("cylinder"); + cylinder5.setPosition(p2); + cylinder5.setDistal(p3); + cylinder5.setRadiusBottom(new Double(34.55)); + cylinder5.setRadiusTop(new Double(34.55)); + + CompositeNode vg = new CompositeNode("vg"); + vg.addChild(sphere); + vg.addChild(cylinder); + vg.addChild(cylinder2); + vg.addChild(cylinder3); + vg.addChild(cylinder4); + vg.addChild(cylinder5); + + CompositeNode vg2 = new CompositeNode("vg2"); + vg2.addChild(cylinder); + vg2.addChild(cylinder2); + vg2.addChild(cylinder3); + vg2.addChild(cylinder4); + vg2.addChild(cylinder5); + vg2.addChild(sphere); + + AspectSubTreeNode simulation = new AspectSubTreeNode(AspectTreeType.WATCH_TREE); + simulation.setModified(true); + + CompositeNode hhpop = new CompositeNode("hhpop[0]"); + + VariableNode v = new VariableNode("v"); + PhysicalQuantity quantity = new PhysicalQuantity(); + quantity.setValue(ValuesFactory.getDoubleValue(20d)); + + PhysicalQuantity quantity2 = new PhysicalQuantity(); + quantity2.setValue(ValuesFactory.getDoubleValue(100d)); + + v.addPhysicalQuantity(quantity); + v.addPhysicalQuantity(quantity2); + + ParameterNode a1 = new ParameterNode("a"); + + runtimeTree.addChild(entity1); + runtimeTree.addChild(entity2); + entity1.addChild(entity2); + entity2.addChild(entity3); + entity2.getAspects().add(aspectB); + entity1.getAspects().add(aspectA); + entity3.getAspects().add(aspectC); + aspectC.setParent(entity3); + aspectB.setParent(entity2); + aspectA.setParent(entity1); + aspectA.addChild(model); + model.addChild(parameter); + model.addChild(dynamics); + model.addChild(functionNode); + + aspectA.addChild(visualization); + visualization.addChild(vg); + visualization.addChild(vg2); + + aspectA.addChild(simulation); + simulation.addChild(hhpop); + hhpop.addChild(v); + hhpop.addChild(a1); + + SerializeTreeVisitor visitor = new SerializeTreeVisitor(); + runtimeTree.apply(visitor); + String serialized = visitor.getSerializedTree(); + System.out.println(serialized); + + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + JsonParser jp = new JsonParser(); + JsonElement je = jp.parse(serialized); + String prettyJsonString = gson.toJson(je); + + System.out.println(prettyJsonString); + } } \ No newline at end of file From 510dc56216b9a9e180f9f36618c2b32eefad57d0 Mon Sep 17 00:00:00 2001 From: Matteo Cantarelli Date: Thu, 18 Sep 2014 23:31:42 -0700 Subject: [PATCH 15/21] Runtime model changes --- .../org/geppetto/core/model/runtime/AspectNode.java | 12 ++++++------ .../core/model/runtime/AspectSubTreeNode.java | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/org/geppetto/core/model/runtime/AspectNode.java b/src/main/java/org/geppetto/core/model/runtime/AspectNode.java index 7e1901b0..81d20b42 100644 --- a/src/main/java/org/geppetto/core/model/runtime/AspectNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/AspectNode.java @@ -105,7 +105,7 @@ public void flushSubTree(AspectTreeType tree) * @param modelTree * @return */ - private ACompositeNode addSubTree(AspectTreeType modelTree) + private AspectSubTreeNode addSubTree(AspectTreeType modelTree) { AspectSubTreeNode subTree = new AspectSubTreeNode(modelTree); addChild(subTree); @@ -114,19 +114,19 @@ private ACompositeNode addSubTree(AspectTreeType modelTree) /** * It creates the subtree if it doesn't exist - * @param modelTree + * @param treeType * @return */ - public ACompositeNode getSubTree(AspectTreeType modelTree) + public AspectSubTreeNode getSubTree(AspectTreeType treeType) { for (ANode node:getChildren()) { - if( node.getName().equals(modelTree.toString())) + if( node.getName().equals(treeType.toString())) { - return (ACompositeNode) node; + return (AspectSubTreeNode) node; } } - return addSubTree(modelTree); + return addSubTree(treeType); } @Override diff --git a/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java b/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java index f4970ef5..50f87215 100644 --- a/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java @@ -69,16 +69,16 @@ public String toString() { } } - private AspectTreeType type; - private boolean _modified = false; + private AspectTreeType _type; + private boolean _modified = true; /** * @param modelTree.toString() */ - public AspectSubTreeNode(AspectTreeType modelTree) + public AspectSubTreeNode(AspectTreeType treeType) { - super(modelTree.toString()); - this.type = modelTree; + super(treeType.toString()); + this._type = treeType; } /** @@ -96,7 +96,7 @@ public AspectSubTreeNode(String treeType) } public String getType(){ - return this.type.toString(); + return this._type.toString(); } public boolean isModified(){ From 52d5a3930bc50d645d5c2ce7a5a7970f46efae6b Mon Sep 17 00:00:00 2001 From: Matteo Cantarelli Date: Thu, 18 Sep 2014 23:41:09 -0700 Subject: [PATCH 16/21] Test fix. By default now newly created aspectsubtreenodes are marked as true since creation=modification. --- src/test/java/org/geppetto/core/TestTreeSerialization.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/org/geppetto/core/TestTreeSerialization.java b/src/test/java/org/geppetto/core/TestTreeSerialization.java index f993ec22..562e9c6e 100644 --- a/src/test/java/org/geppetto/core/TestTreeSerialization.java +++ b/src/test/java/org/geppetto/core/TestTreeSerialization.java @@ -256,7 +256,7 @@ public void testSkeletonTree() { System.out.println(prettyJsonString); - Assert.assertEquals("{\"root\":{\"Entity_A\":{\"Aspect_A\":{\"ModelTree\":{\"type\":\"ModelTree\",\"modified\":false,\"instancePath\":\"Entity_A.Aspect_A.ModelTree\",\"_metaType\":\"AspectSubTreeNode\"},\"VisualizationTree\":{\"type\":\"VisualizationTree\",\"modified\":false,\"instancePath\":\"Entity_A.Aspect_A.VisualizationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"SimulationTree\":{\"type\":\"SimulationTree\",\"modified\":false,\"instancePath\":\"Entity_A.Aspect_A.SimulationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"instancePath\":\"Entity_A.Aspect_A\",\"_metaType\":\"AspectNode\"},\"instancePath\":\"Entity_A\",\"_metaType\":\"EntityNode\"},\"_metaType\":\"RuntimeTreeRoot\"}}", serialized); + Assert.assertEquals("{\"root\":{\"Entity_A\":{\"Aspect_A\":{\"ModelTree\":{\"type\":\"ModelTree\",\"modified\":true,\"instancePath\":\"Entity_A.Aspect_A.ModelTree\",\"_metaType\":\"AspectSubTreeNode\"},\"VisualizationTree\":{\"type\":\"VisualizationTree\",\"modified\":true,\"instancePath\":\"Entity_A.Aspect_A.VisualizationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"SimulationTree\":{\"type\":\"SimulationTree\",\"modified\":true,\"instancePath\":\"Entity_A.Aspect_A.SimulationTree\",\"_metaType\":\"AspectSubTreeNode\"},\"instancePath\":\"Entity_A.Aspect_A\",\"_metaType\":\"AspectNode\"},\"instancePath\":\"Entity_A\",\"_metaType\":\"EntityNode\"},\"_metaType\":\"RuntimeTreeRoot\"}}", serialized); } /** From cba53a267ca2d17afbe012bda8a321102a108a66 Mon Sep 17 00:00:00 2001 From: jrmartin Date: Sat, 20 Sep 2014 14:46:17 -0700 Subject: [PATCH 17/21] remove unnecessary comments --- .../state/visitors/SerializeTreeVisitor.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java index 44bbc037..6ac5500d 100644 --- a/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java +++ b/src/main/java/org/geppetto/core/model/state/visitors/SerializeTreeVisitor.java @@ -68,18 +68,18 @@ public void generalACompositeStateNodeIn(ACompositeNode node){ if(parent != null){ ACompositeNode castParent = ((ACompositeNode) parent); - if(castParent.getChildren().indexOf(node) > 0 ){ - if(_serialized.length() != 0){ - namePath = namePath.replace("{", ""); - } + if(castParent.getChildren().indexOf(node) > 0 ){ + if(_serialized.length() != 0){ + namePath = namePath.replace("{", ""); } + } } _serialized.append(namePath); - //add bracket if node hsa more children + //add bracket if node haa more children if(node.getChildren().size() >= 1){ - //add brakcet if not instance of compositenode + //add bracket if not instance of compositenode if(!(node.getChildren().get(0) instanceof ACompositeNode)){ _serialized.append("{"); } @@ -195,9 +195,7 @@ public boolean inAspectNode(AspectNode node) public boolean outAspectNode(AspectNode node) { - //add bracket if node hsa more children if(node.getChildren().size() == 0){ - //add brakcet if not instance of compositenode _serialized.append("{"); } @@ -244,10 +242,8 @@ public boolean inEntityNode(EntityNode node) _serialized.append(namePath); - //add bracket if node hsa more children if(node.getChildren().size() == 0){ - //add brakcet if not instance of compositenode - _serialized.append("{"); + _serialized.append("{"); } return super.inEntityNode(node); From dd50af54cc5f6c2680d5dc1304df2adbe4b003a0 Mon Sep 17 00:00:00 2001 From: Matteo Cantarelli Date: Sun, 21 Sep 2014 03:27:08 -0700 Subject: [PATCH 18/21] Subentities changes --- .../core/model/runtime/AspectSubTreeNode.java | 4 +- .../utilities/VariablePathSerializer.java | 82 +++++++++++++------ 2 files changed, 58 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java b/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java index 50f87215..5a5aaee8 100644 --- a/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java +++ b/src/main/java/org/geppetto/core/model/runtime/AspectSubTreeNode.java @@ -95,8 +95,8 @@ public AspectSubTreeNode(String treeType) this.setName(treeType); } - public String getType(){ - return this._type.toString(); + public AspectTreeType getType(){ + return this._type; } public boolean isModified(){ diff --git a/src/main/java/org/geppetto/core/utilities/VariablePathSerializer.java b/src/main/java/org/geppetto/core/utilities/VariablePathSerializer.java index bd6d0ccc..2b61d00c 100644 --- a/src/main/java/org/geppetto/core/utilities/VariablePathSerializer.java +++ b/src/main/java/org/geppetto/core/utilities/VariablePathSerializer.java @@ -40,30 +40,60 @@ import org.geppetto.core.data.model.SimpleType; import org.geppetto.core.data.model.StructuredType; -public class VariablePathSerializer { - public static void GetFullVariablePath(AVariable var, String parentName, List variablePaths) - { - String varName = parentName.equals("")? var.getName() : (parentName + "." + var.getName()); - - if(var.getType() instanceof StructuredType) - { - // NODE - StructuredType strucT = (StructuredType)var.getType(); - List vars = strucT.getVariables(); - - for(AVariable v : vars){ - GetFullVariablePath(v, varName, variablePaths); - } - } - else if(var.getType() instanceof SimpleType) - { - // LEAF - if(variablePaths == null) - { - variablePaths = new ArrayList(); - } - - variablePaths.add(varName); - } - } +/** + * @author matteocantarelli + * + */ +public class VariablePathSerializer +{ + /** + * @param var + * @param parentName + * @param variablePaths + */ + public static void GetFullVariablePath(AVariable var, String parentName, List variablePaths) + { + String varName = parentName.equals("") ? var.getName() : (parentName + "." + var.getName()); + + if(var.getType() instanceof StructuredType) + { + // NODE + StructuredType strucT = (StructuredType) var.getType(); + List vars = strucT.getVariables(); + + for(AVariable v : vars) + { + GetFullVariablePath(v, varName, variablePaths); + } + } + else if(var.getType() instanceof SimpleType) + { + // LEAF + if(variablePaths == null) + { + variablePaths = new ArrayList(); + } + + variablePaths.add(varName); + } + } + + /** + * @param var + * @param index + * @return + */ + public static String getArrayName(String var, String index) + { + return var+"_"+index; + } + /** + * @param var + * @param index + * @return + */ + public static String getArrayName(String var, Integer index) + { + return getArrayName(var, index.toString()); + } } From b536e8e4a0d12c9fe5fc428e1c8a4ac79950ce89 Mon Sep 17 00:00:00 2001 From: Matteo Cantarelli Date: Sun, 21 Sep 2014 10:13:57 -0700 Subject: [PATCH 19/21] Missing class --- .../geppetto/core/utilities/URLReader.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/main/java/org/geppetto/core/utilities/URLReader.java diff --git a/src/main/java/org/geppetto/core/utilities/URLReader.java b/src/main/java/org/geppetto/core/utilities/URLReader.java new file mode 100644 index 00000000..f801ef10 --- /dev/null +++ b/src/main/java/org/geppetto/core/utilities/URLReader.java @@ -0,0 +1,24 @@ +/** + * + */ +package org.geppetto.core.utilities; + +import java.io.IOException; +import java.net.URL; +import java.util.Scanner; + +/** + * @author matteocantarelli + * + */ +public class URLReader +{ + + public static String readStringFromURL(URL url) throws IOException + { + Scanner s = new Scanner(url.openStream(), "UTF-8"); + String content = s.useDelimiter("\\A").next(); + s.close(); + return content; + } +} From 2baa279cb620f6b15469dbf0487bbd6b95ca0837 Mon Sep 17 00:00:00 2001 From: Matteo Cantarelli Date: Sun, 21 Sep 2014 21:33:06 -0700 Subject: [PATCH 20/21] Release 0.1.7 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 1467b34f..528f1a42 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.geppetto core Geppetto Core Bundle - 0.1.6 + 0.1.7 bundle github From fd62e93522f0e99ae3f4a1698b1f41f1d9234aed Mon Sep 17 00:00:00 2001 From: Matteo Cantarelli Date: Sun, 21 Sep 2014 23:10:44 -0700 Subject: [PATCH 21/21] Track when trees are emptied --- .../geppetto/core/simulator/ASimulator.java | 48 +++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/geppetto/core/simulator/ASimulator.java b/src/main/java/org/geppetto/core/simulator/ASimulator.java index 91621012..9485d0a5 100644 --- a/src/main/java/org/geppetto/core/simulator/ASimulator.java +++ b/src/main/java/org/geppetto/core/simulator/ASimulator.java @@ -84,6 +84,8 @@ public abstract class ASimulator implements ISimulator private boolean _initialized = false; + protected boolean _treesEmptied = false; + private boolean _watching = false; private VariableList _forceableVariables = new VariableList(); @@ -112,7 +114,7 @@ public void initialize(List models, ISimulatorCallbackListener listener) { setListener(listener); _models = models; - + // initialize recordings for(IModel model : models) { @@ -136,6 +138,10 @@ else if(model instanceof RecordingModel) _runtime = 0; _initialized = true; + if(!_watchableVariables.getVariables().isEmpty()) + { + _treesEmptied = true; + } } /** @@ -155,11 +161,11 @@ public boolean isInitialized() { return _initialized; } - + @Override public void setInitialized(boolean initialized) { - _initialized = initialized; + _initialized = initialized; } /** @@ -292,11 +298,11 @@ public void setTimeStepUnit(String timeStepUnit) protected void advanceTimeStep(double timestep) { _runtime += timestep; - ACompositeNode timeStepsNode =new CompositeNode("time tree"); + ACompositeNode timeStepsNode = new CompositeNode("time tree"); { VariableNode time = new VariableNode("time"); timeStepsNode.addChild(time); - PhysicalQuantity t= new PhysicalQuantity(); + PhysicalQuantity t = new PhysicalQuantity(); t.setUnit(_timeStepUnit); } ATimeSeriesNode leafNode = (ATimeSeriesNode) timeStepsNode.getChildren().get(0); @@ -310,7 +316,7 @@ protected void advanceRecordings(AspectNode aspect) throws GeppettoExecutionExce if(_recordings != null && isWatching()) { AspectSubTreeNode watchTree = (AspectSubTreeNode) aspect.getSubTree(AspectTreeType.WATCH_TREE); - + if(watchTree.getChildren().isEmpty() || watchListModified()) { for(RecordingModel recording : _recordings) @@ -325,7 +331,7 @@ protected void advanceRecordings(AspectNode aspect) throws GeppettoExecutionExce if(getWatchList().contains(fullPath)) { fullPath = fullPath.replace(watchTree.getInstancePath() + ".", ""); - + StringTokenizer tokenizer = new StringTokenizer(fullPath, "."); ACompositeNode node = watchTree; while(tokenizer.hasMoreElements()) @@ -361,8 +367,8 @@ protected void advanceRecordings(AspectNode aspect) throws GeppettoExecutionExce { // it's a leaf node VariableNode newNode = new VariableNode(current); - int[] start = { _currentRecordingIndex}; - int[] lenght = {1}; + int[] start = { _currentRecordingIndex }; + int[] lenght = { 1 }; Array value; try { @@ -496,6 +502,27 @@ protected void setWatchableVariablesFromRecordings() } } + /** + * @return + */ + protected boolean treesEmptied() + { + return _treesEmptied; + } + + /** + * @param b + */ + protected void treesEmptied(boolean b) + { + _treesEmptied = b; + } + + /** + * @param s + * @param list + * @return + */ protected static AVariable getVariable(String s, List list) { String searchVar = s; @@ -509,6 +536,9 @@ protected static AVariable getVariable(String s, List list) return null; } + /** + * @throws GeppettoExecutionException + */ protected void notifyStateTreeUpdated() throws GeppettoExecutionException { getListener().stateTreeUpdated();