]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
First introduction of modules: basic user-created module with a few variables. Modeli...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 29 Jun 2010 14:48:44 +0000 (14:48 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 29 Jun 2010 14:48:44 +0000 (14:48 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16426 ac1ea38d-2e2b-0410-8846-a27921b304fc

26 files changed:
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Module.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Variable.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/EquationView.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/equation/NameComposite.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/ExpressionValidation.java
org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Configuration.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/IModule.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Module.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/SysdynSchema.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Variable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/ElementVisitorVoidAdapter.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/IElementVisitorVoid.java
org.simantics.sysdyn/src/org/simantics/sysdyn/simulation/SimulationJob.java
sysdyn_ontologies/sysdyn.graph

index 4c6b40d22410a5e5d2764a69900b388bd3fd397c..2b16b6676486e350f8890ff03a732740dedc7c94 100644 (file)
@@ -25,5 +25,5 @@
                        <graph />\r
                        <this />\r
                </type>\r
-       </target>\r      \r       <target\r                interface="org.simantics.sysdyn.ui.browser.nodes.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/IndependentVariable"\r                  class="org.simantics.sysdyn.ui.browser.nodes.VariableNode">\r                    <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Simulation-1.0/Types/Experiment"\r                 class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r        </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r      </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->\r         <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                     class="org.simantics.sysdyn.ui.elements2.FlowEdgeFactory" />\r           <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.DependencyEdgeFactory" />\r             <!-- : SYSDYN.Connection-->\r            <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.FlowConnectionFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.DependencyConnectionFactory" />\r       </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r
+       </target>\r      \r       <target\r                interface="org.simantics.sysdyn.ui.browser.nodes.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/IndependentVariable"\r                  class="org.simantics.sysdyn.ui.browser.nodes.VariableNode">\r                    <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Module"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ModuleNode">\r                      <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Simulation-1.0/Types/Experiment"\r                 class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-1.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-1.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r      </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->\r         <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                     class="org.simantics.sysdyn.ui.elements2.FlowEdgeFactory" />\r           <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.DependencyEdgeFactory" />\r             <!-- : SYSDYN.Connection-->\r            <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.FlowConnectionFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.DependencyConnectionFactory" />\r       </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r
 </adapters>
\ No newline at end of file
index 4d1fce63ee5a3c41515d38a1d3c065eee6cb4d62..e3c3fe6841473629bd88357daa397d1807558c7a 100644 (file)
       <binding\r
             browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
          <implementation\r
-               class="org.simantics.sysdyn.ui.browser.contributions.Variable"\r
+               class="org.simantics.sysdyn.ui.browser.contributions.Configuration"\r
                preference="1.0">\r
          </implementation>\r
          <implementation\r
                class="org.simantics.sysdyn.ui.browser.contributions.SimulationResult"\r
                preference="2.0">\r
          </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.Module"\r
+               preference="1.0">\r
+         </implementation>\r
       </binding>\r
    </extension>\r
    <extension\r
                class="org.simantics.sysdyn.ui.browser.contributions.SimulationResultLabeler"\r
                preference="2.0">\r
          </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.ModuleLabeler"\r
+               preference="2.0">\r
+         </implementation>\r
       </binding>\r
    </extension>\r
    <extension\r
                class="org.simantics.sysdyn.ui.browser.contributions.SimulationResultImager"\r
                preference="2.0">\r
          </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.ModuleImager"\r
+               preference="2.0">\r
+         </implementation>\r
       </binding>\r
    </extension>\r
    <extension\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java
new file mode 100644 (file)
index 0000000..9423274
--- /dev/null
@@ -0,0 +1,44 @@
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+\r
+public class Configuration extends ViewpointContributor<ConfigurationNode> {\r
+\r
+        @Override\r
+        public Collection<?> getContribution(ReadGraph graph, ConfigurationNode configuration) throws DatabaseException {\r
+            ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+            Builtins b = graph.getBuiltins();\r
+            SysdynResource sr = SysdynResource.getInstance(graph);\r
+            for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.IndependentVariable))) {\r
+                try {\r
+                    result.add(graph.adapt(r, AbstractNode.class));\r
+                } catch(DatabaseException e) {\r
+                    e.printStackTrace();\r
+                }\r
+            }\r
+            for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.Module))) {\r
+                try {\r
+                    result.add(graph.adapt(r, AbstractNode.class));\r
+                } catch(DatabaseException e) {\r
+                    e.printStackTrace();\r
+                }\r
+            }\r
+            return result;\r
+        }\r
+\r
+        @Override\r
+        public String getViewpointId() {\r
+            return "Standard";\r
+        }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Module.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Module.java
new file mode 100644 (file)
index 0000000..4ba24a4
--- /dev/null
@@ -0,0 +1,45 @@
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+\r
+public class Module  extends ViewpointContributor<ModuleNode> {\r
+\r
+    @Override\r
+    public Collection<?> getContribution(ReadGraph graph, ModuleNode module) throws DatabaseException {\r
+        ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+        Builtins b = graph.getBuiltins();\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        for(Resource r : graph.syncRequest(new ObjectsWithType(module.resource, b.ConsistsOf, sr.IndependentVariable))) {\r
+            try {\r
+                result.add(graph.adapt(r, AbstractNode.class));\r
+            } catch(DatabaseException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
+        for(Resource r : graph.syncRequest(new ObjectsWithType(module.resource, b.ConsistsOf, sr.Module))) {\r
+            try {\r
+                result.add(graph.adapt(r, AbstractNode.class));\r
+            } catch(DatabaseException e) {\r
+                e.printStackTrace();\r
+            }\r
+        }\r
+        return result;\r
+    }\r
+\r
+    @Override\r
+    public String getViewpointId() {\r
+        return "Standard";\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleImager.java
new file mode 100644 (file)
index 0000000..b6ecea3
--- /dev/null
@@ -0,0 +1,16 @@
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.swt.ImagerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+\r
+public class ModuleImager extends ImagerContributor<ModuleNode> {\r
+\r
+    @Override\r
+    public ImageDescriptor getDescriptor(ReadGraph graph, ModuleNode node) throws DatabaseException {\r
+        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/bricks.png"));\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/ModuleLabeler.java
new file mode 100644 (file)
index 0000000..78e02ff
--- /dev/null
@@ -0,0 +1,37 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+\r
+public class ModuleLabeler  extends LabelerContributor<ModuleNode>{\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, ModuleNode module) throws DatabaseException {\r
+        Builtins b = graph.getBuiltins();\r
+        Resource resource = module.resource;\r
+        StringBuilder sb = new StringBuilder();\r
+        for(Resource r : graph.getObjects(resource, b.HasName))\r
+            sb.append(graph.getValue(r));\r
+        sb.append(" : ");\r
+        for(Resource t : graph.getObjects(resource, b.InstanceOf))\r
+            for(Resource r : graph.getObjects(t, b.HasName))\r
+                sb.append(graph.getValue(r));\r
+        return sb.toString();\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Variable.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Variable.java
deleted file mode 100644 (file)
index 333f1c2..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.browser.contributions;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-\r
-import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
-import org.simantics.db.Builtins;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ObjectsWithType;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
-import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
-\r
-public class Variable  extends ViewpointContributor<ConfigurationNode> {\r
-\r
-    @Override\r
-    public Collection<?> getContribution(ReadGraph graph, ConfigurationNode configuration) throws DatabaseException {\r
-        ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
-        Builtins b = graph.getBuiltins();\r
-        SysdynResource sr = SysdynResource.getInstance(graph);\r
-        for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.IndependentVariable))) {\r
-            try {\r
-                result.add(graph.adapt(r, AbstractNode.class));\r
-            } catch(DatabaseException e) {\r
-                e.printStackTrace();\r
-            }\r
-        }\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public String getViewpointId() {\r
-        return "Standard";\r
-    }\r
-\r
-}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/ModuleNode.java
new file mode 100644 (file)
index 0000000..1689c07
--- /dev/null
@@ -0,0 +1,11 @@
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.db.Resource;\r
+\r
+public class ModuleNode extends AbstractNode implements IDeletable {\r
+\r
+    public ModuleNode(Resource resource) {\r
+        super(resource);\r
+    }\r
+}\r
index 2e1555449fda2fc32749c3730afe1f3f261b265b..b301587910ddf0a4277be0f421e41c6cae188e71 100644 (file)
@@ -404,7 +404,7 @@ public class EquationView extends ViewPart implements ISelectionListener {
             SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession());\r
             SysdynModel model = sdm.getModel(configuration);\r
             Configuration conf = model.getConfiguration();\r
-            ArrayList<IElement> elements = conf.elements;\r
+            ArrayList<IElement> elements = conf.getElements();\r
             for(IElement e : elements) {\r
                 if(e instanceof Variable) {\r
                     Variable v = (Variable) e;\r
index f5418efa72d3154f52237bcc574c8c50b937fc95..fbc5fef65bd4c2fc5bcb9a9a500fa7ff987d7b24 100644 (file)
@@ -116,7 +116,7 @@ public class NameComposite extends Composite {
             SysdynModel model = sdm.getModel(rei.getResource());\r
             Configuration conf = model.getConfiguration();\r
             IElement thisElement = model.getElement(variable);\r
-            ArrayList<IElement> elements = conf.elements;\r
+            ArrayList<IElement> elements = conf.getElements();\r
             for(IElement e : elements) {\r
                 if(e instanceof Variable) {\r
                     Variable v = (Variable)e;\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ModuleTab.java
new file mode 100644 (file)
index 0000000..5977c09
--- /dev/null
@@ -0,0 +1,15 @@
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+public class ModuleTab extends PropertyTabContributorImpl {\r
+\r
+    @Override\r
+    public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+        \r
+    }\r
+}\r
index 18fd9e9181ebb7724d1499eb647d4b5da2933bcc..2f2bc2982e2d095a0161769a912f3ad6a1c67ab2 100644 (file)
@@ -62,6 +62,13 @@ public class ResourceSelectionProcessor implements SelectionProcessor<ISelection
                                 0,\r
                                 r,\r
                         "Configuration Properties"));\r
+            if (backend.isInstanceOf(r, sr.Module))\r
+                return Collections.singleton(\r
+                        new ComparableTabContributor(\r
+                                new ModuleTab(),\r
+                                0,\r
+                                r,\r
+                        "Module Properties"));\r
             if (backend.isInstanceOf(r, sr.Experiment))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
index 6ed0546e3ae31662cc46e741af793f23edbb1231..94643afabf11f61a43470a64d52c8422eb86893d 100644 (file)
@@ -18,6 +18,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.management.ISessionContext;\r
 import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.properties.widgets.ExpressionTypes.ExpressionType;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.AuxiliaryExpression;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ConstantExpression;\r
@@ -126,8 +127,16 @@ public class ExpressionWidget implements Widget {
 \r
                 @Override\r
                 public Resource perform(ReadGraph graph) throws DatabaseException {\r
-                    Resource configuration = graph.getSingleObject(variable, graph.getBuiltins().PartOf);\r
-                    return configuration;\r
+                    SysdynResource sr = SysdynResource.getInstance(graph);\r
+                    Resource configuration = variable;\r
+                    \r
+                    do {\r
+                    configuration = graph.getSingleObject(configuration, graph.getBuiltins().PartOf);\r
+                        if(graph.isInstanceOf(configuration, sr.Configuration))\r
+                            return configuration;\r
+                    } while (configuration != null);\r
+                    \r
+                    return null;\r
                 }\r
             });\r
             ExpressionValidation.validateExpressionFields(expression, connectedVariables, configuration);\r
index a4448215389a68499dc4e261511075e1959aa0a7..5c8a2cdd38627bc5fabb152ce25febbb44d47909 100644 (file)
@@ -54,7 +54,7 @@ public class ExpressionValidation {
             SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession());\r
             SysdynModel model = sdm.getModel(configuration);\r
             Configuration conf = model.getConfiguration();\r
-            ArrayList<IElement> elements = conf.elements;\r
+            ArrayList<IElement> elements = conf.getElements();\r
             for(IElement e : elements) {\r
                 if(e instanceof Variable) {\r
                     Variable v = (Variable) e;\r
index 723dc2348dd00048c23c6cca932fba4f2d7afb88..e847edb487dcd81d1f36a80d897b12ef76dc79c6 100644 (file)
@@ -42,11 +42,13 @@ public class SysdynResource {
     public final Resource HasExpression;\r
     public final Resource HasHead;\r
     public final Resource HasInitialEquation;\r
+    public final Resource HasInput;\r
     public final Resource HasLookup;\r
     public final Resource HasMaxX;\r
     public final Resource HasMaxY;\r
     public final Resource HasMinX;\r
     public final Resource HasMinY;\r
+    public final Resource HasOutput;\r
     public final Resource HasParameterFile;\r
     public final Resource HasRangeEnd;\r
     public final Resource HasRangeStart;\r
@@ -57,11 +59,11 @@ public class SysdynResource {
     public final Resource HasStopTime;\r
     public final Resource HasTail;\r
     public final Resource HasTerminal;\r
-    public final Resource HasType;\r
     public final Resource HasUnit;\r
     public final Resource HasX;\r
     public final Resource HasY;\r
     public final Resource IndependentVariable;\r
+    public final Resource Input;\r
     public final Resource IsHeadOf;\r
     public final Resource IsHeadOfTerminal;\r
     public final Resource IsTailOf;\r
@@ -110,11 +112,13 @@ public class SysdynResource {
         public static final String HasExpression = "http://www.simantics.org/Sysdyn-1.0/HasExpression";\r
         public static final String HasHead = "http://www.simantics.org/Sysdyn-1.0/HasHead";\r
         public static final String HasInitialEquation = "http://www.simantics.org/Sysdyn-1.0/HasInitialEquation";\r
+        public static final String HasInput = "http://www.simantics.org/Sysdyn-1.0/HasInput";\r
         public static final String HasLookup = "http://www.simantics.org/Sysdyn-1.0/HasLookup";\r
         public static final String HasMaxX = "http://www.simantics.org/Sysdyn-1.0/HasMaxX";\r
         public static final String HasMaxY = "http://www.simantics.org/Sysdyn-1.0/HasMaxY";\r
         public static final String HasMinX = "http://www.simantics.org/Sysdyn-1.0/HasMinX";\r
         public static final String HasMinY = "http://www.simantics.org/Sysdyn-1.0/HasMinY";\r
+        public static final String HasOutput = "http://www.simantics.org/Sysdyn-1.0/HasOutput";\r
         public static final String HasParameterFile = "http://www.simantics.org/Sysdyn-1.0/HasParameterFile";\r
         public static final String HasRangeEnd = "http://www.simantics.org/Sysdyn-1.0/HasRangeEnd";\r
         public static final String HasRangeStart = "http://www.simantics.org/Sysdyn-1.0/HasRangeStart";\r
@@ -125,11 +129,11 @@ public class SysdynResource {
         public static final String HasStopTime = "http://www.simantics.org/Sysdyn-1.0/HasStopTime";\r
         public static final String HasTail = "http://www.simantics.org/Sysdyn-1.0/HasTail";\r
         public static final String HasTerminal = "http://www.simantics.org/Sysdyn-1.0/HasTerminal";\r
-        public static final String HasType = "http://www.simantics.org/Sysdyn-1.0/HasType";\r
         public static final String HasUnit = "http://www.simantics.org/Sysdyn-1.0/HasUnit";\r
         public static final String HasX = "http://www.simantics.org/Sysdyn-1.0/HasX";\r
         public static final String HasY = "http://www.simantics.org/Sysdyn-1.0/HasY";\r
         public static final String IndependentVariable = "http://www.simantics.org/Sysdyn-1.0/IndependentVariable";\r
+        public static final String Input = "http://www.simantics.org/Sysdyn-1.0/Input";\r
         public static final String IsHeadOf = "http://www.simantics.org/Sysdyn-1.0/IsHeadOf";\r
         public static final String IsHeadOfTerminal = "http://www.simantics.org/Sysdyn-1.0/IsHeadOfTerminal";\r
         public static final String IsTailOf = "http://www.simantics.org/Sysdyn-1.0/IsTailOf";\r
@@ -188,11 +192,13 @@ public class SysdynResource {
         HasExpression = getResourceOrNull(graph, URIs.HasExpression);\r
         HasHead = getResourceOrNull(graph, URIs.HasHead);\r
         HasInitialEquation = getResourceOrNull(graph, URIs.HasInitialEquation);\r
+        HasInput = getResourceOrNull(graph, URIs.HasInput);\r
         HasLookup = getResourceOrNull(graph, URIs.HasLookup);\r
         HasMaxX = getResourceOrNull(graph, URIs.HasMaxX);\r
         HasMaxY = getResourceOrNull(graph, URIs.HasMaxY);\r
         HasMinX = getResourceOrNull(graph, URIs.HasMinX);\r
         HasMinY = getResourceOrNull(graph, URIs.HasMinY);\r
+        HasOutput = getResourceOrNull(graph, URIs.HasOutput);\r
         HasParameterFile = getResourceOrNull(graph, URIs.HasParameterFile);\r
         HasRangeEnd = getResourceOrNull(graph, URIs.HasRangeEnd);\r
         HasRangeStart = getResourceOrNull(graph, URIs.HasRangeStart);\r
@@ -203,11 +209,11 @@ public class SysdynResource {
         HasStopTime = getResourceOrNull(graph, URIs.HasStopTime);\r
         HasTail = getResourceOrNull(graph, URIs.HasTail);\r
         HasTerminal = getResourceOrNull(graph, URIs.HasTerminal);\r
-        HasType = getResourceOrNull(graph, URIs.HasType);\r
         HasUnit = getResourceOrNull(graph, URIs.HasUnit);\r
         HasX = getResourceOrNull(graph, URIs.HasX);\r
         HasY = getResourceOrNull(graph, URIs.HasY);\r
         IndependentVariable = getResourceOrNull(graph, URIs.IndependentVariable);\r
+        Input = getResourceOrNull(graph, URIs.Input);\r
         IsHeadOf = getResourceOrNull(graph, URIs.IsHeadOf);\r
         IsHeadOfTerminal = getResourceOrNull(graph, URIs.IsHeadOfTerminal);\r
         IsTailOf = getResourceOrNull(graph, URIs.IsTailOf);\r
index 0d888a64b5eae03581c7ba32ac2bcba661ae6b58..1aea00e47d15d5105dd65d61832123fdd7f83158 100644 (file)
@@ -63,7 +63,7 @@ public class SysdynModel implements IMappingListener, IModel {
         SysdynSchema schema = new SysdynSchema(g);\r
         mapping = Mappings.createWithListening(schema);\r
         mapping.addMappingListener(SysdynModel.this);\r
-        configuration = (Configuration)mapping.map(g, configurationResource);           \r
+        configuration = (Configuration)mapping.map(g, configurationResource);    \r
     }\r
 \r
     public SysdynModel(ReadGraph g, Resource configurationResource) {\r
@@ -91,7 +91,7 @@ public class SysdynModel implements IMappingListener, IModel {
             writer.write(configuration);\r
 \r
             result = ModelicaManager.runModelica(\r
-                    configuration.name,\r
+                    configuration.getName(),\r
                     writer.toString(), \r
                     monitor,\r
                     configuration.startTime,\r
index 8ba54a9087cfa90d84c5d6a973f3562a8a1de664..b7072dcc452cd87b275d98ea07202604478174b0 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.modelica;\r
 \r
+import java.util.ArrayList;\r
+\r
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.IModule;\r
+import org.simantics.sysdyn.representation.Module;\r
 import org.simantics.sysdyn.representation.Stock;\r
 import org.simantics.sysdyn.representation.Variable;\r
 import org.simantics.sysdyn.representation.expressions.IExpression;\r
@@ -26,43 +30,9 @@ public class ModelicaWriter {
     boolean insertInterpolate = false;\r
 \r
     public void write(Configuration conf) {\r
-        conf.update();\r
-        b.append("model ").append(conf.name.replace(" ", "")).append('\n');\r
-        for(IElement element : conf.elements)\r
-            if(element instanceof Variable) {\r
-                IExpression expr = ((Variable)element).expression;\r
-                if(expr != null) {\r
-                    app = expr.getDeclaration((Variable)element);\r
-                    if (app != null) b.append(app);\r
-                    if (expr instanceof WithLookupExpression) insertInterpolate = true;\r
-                }\r
-            }\r
-\r
-        for(IElement element : conf.elements)\r
-            if(element instanceof Stock) {\r
-                IExpression expr = ((Stock)element).expression;\r
-                if(expr != null) {\r
-                    app = expr.getInitialEquation((Stock)element);\r
-                    if (app != null) {\r
-                        if(initialEquations == false) {\r
-                            initialEquations = true;\r
-                            b.append("initial equation\n");\r
-                        }\r
-                        b.append(app);\r
-                    }\r
-                }\r
-            }\r
-        b.append("equation\n");\r
-        for(IElement element : conf.elements)\r
-            if(element instanceof Variable) {\r
-                IExpression expr = ((Variable)element).expression;\r
-                if(expr != null) {\r
-                    app = expr.getEquation((Variable)element);\r
-                    if (app != null) b.append(app);\r
-                }\r
-            }\r
-        b.append("end ").append(conf.name.replace(" ", "")).append(";\n");\r
 \r
+        writeModule(conf);\r
+        \r
         if(insertInterpolate)\r
             b.append(\r
                     "\nfunction Interpolate\n" +\r
@@ -81,10 +51,68 @@ public class ModelicaWriter {
                     "    end if;\n" +\r
                     "    end for;\n" +\r
             " end Interpolate;\n");\r
+    }\r
+    \r
+    private void writeModule(IModule module) {\r
         \r
+        module.update();\r
+        \r
+        ArrayList<IElement> variables = new ArrayList<IElement>();\r
+        ArrayList<Module> modules = new ArrayList<Module>();\r
+        ArrayList<IElement> stocks = new ArrayList<IElement>();\r
+\r
+        // Initialize lists\r
+        for(IElement element : module.getElements()) {\r
+            if(element instanceof Variable) {\r
+                variables.add(element);\r
+                if(element instanceof Stock)\r
+                    stocks.add(element);\r
+            } else if (element instanceof Module) {\r
+                modules.add((Module)element);\r
+            }\r
+        }\r
 \r
-    }\r
 \r
+        b.append("class ").append(module.getName().replace(" ", "")).append('\n');\r
+        for(IElement element : variables) {\r
+            IExpression expr = ((Variable)element).expression;\r
+            if(expr != null && insertInterpolate == false) {\r
+                app = expr.getDeclaration((Variable)element);\r
+                if (app != null) b.append(app);\r
+                if (expr instanceof WithLookupExpression) insertInterpolate = true;\r
+            }\r
+        }\r
+\r
+        for(IElement element : stocks) {\r
+            IExpression expr = ((Stock)element).expression;\r
+            if(expr != null) {\r
+                app = expr.getInitialEquation((Stock)element);\r
+                if (app != null) {\r
+                    if(initialEquations == false) {\r
+                        initialEquations = true;\r
+                        b.append("initial equation\n");\r
+                    }\r
+                    b.append(app);\r
+                }\r
+            }\r
+        }\r
+        \r
+        b.append("equation\n");\r
+        for(IElement element : variables) {\r
+                IExpression expr = ((Variable)element).expression;\r
+                if(expr != null) {\r
+                    app = expr.getEquation((Variable)element);\r
+                    if (app != null) b.append(app);\r
+                }\r
+            }\r
+        b.append("end ").append(module.getName().replace(" ", "")).append(";\n\n");\r
+        \r
+        \r
+        for(Module m : modules) {\r
+            writeModule(m);\r
+        }\r
+    }\r
\r
     public String escape(String name) {\r
         return name.replace(' ', '_');\r
     }\r
index cc0df887a006ad2eea012966033bd8f3cbc53e0b..2308eaa4fc145d24a38aa2f6267dca0bfed82e11 100644 (file)
@@ -21,9 +21,7 @@ import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;
 \r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/Configuration")\r
-public class Configuration {\r
-    @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
-    public String name = "Unnamed";\r
+public class Configuration implements IModule {\r
     \r
     @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasStartTime")\r
     public Double startTime = 0.0;\r
@@ -31,18 +29,21 @@ public class Configuration {
     @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasStopTime")\r
     public Double stopTime = 10.0;\r
     \r
+    @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+    private String name;\r
+\r
     @RelatedElements(\r
-         value = "http://www.simantics.org/Layer0-1.0/ConsistsOf",\r
-         composition = true)\r
-    public ArrayList<IElement> elements = new ArrayList<IElement>();\r
-    \r
+            value = "http://www.simantics.org/Layer0-1.0/ConsistsOf",\r
+            composition = true)\r
+            private ArrayList<IElement> elements = new ArrayList<IElement>();\r
+\r
     IElementVisitorVoid clearVisitor = new ElementVisitorVoidAdapter() {\r
         public void visit(Stock stock) {\r
             stock.incomingFlows.clear();\r
             stock.outgoingFlows.clear();\r
         }\r
     };\r
-    \r
+\r
     IElementVisitorVoid updateVisitor = new ElementVisitorVoidAdapter() {\r
         public void visit(Flow flow) {\r
             if(flow.head instanceof Stock) {\r
@@ -60,4 +61,16 @@ public class Configuration {
         for(IElement element : elements)\r
             element.accept(updateVisitor);\r
     }\r
+\r
+    @Override\r
+    public ArrayList<IElement> getElements() {\r
+        return elements;\r
+    }\r
+\r
+    @Override\r
+    public String getName() {\r
+        return name;\r
+    }\r
+    \r
+    \r
 }\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/IModule.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/IModule.java
new file mode 100644 (file)
index 0000000..af462ef
--- /dev/null
@@ -0,0 +1,11 @@
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+public interface IModule {\r
+    \r
+    public ArrayList<IElement> getElements(); \r
+    public String getName(); \r
+    public void update();\r
+\r
+}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Module.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Module.java
new file mode 100644 (file)
index 0000000..b19e804
--- /dev/null
@@ -0,0 +1,62 @@
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.visitors.ElementVisitorVoidAdapter;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Module")\r
+public class Module implements IElement, IModule {\r
+\r
+    @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+    private String name;\r
+\r
+    @RelatedElements(\r
+            value = "http://www.simantics.org/Layer0-1.0/ConsistsOf",\r
+            composition = true)\r
+            private ArrayList<IElement> elements = new ArrayList<IElement>();\r
+\r
+    IElementVisitorVoid clearVisitor = new ElementVisitorVoidAdapter() {\r
+        public void visit(Stock stock) {\r
+            stock.incomingFlows.clear();\r
+            stock.outgoingFlows.clear();\r
+        }\r
+    };\r
+\r
+    IElementVisitorVoid updateVisitor = new ElementVisitorVoidAdapter() {\r
+        public void visit(Flow flow) {\r
+            if(flow.head instanceof Stock) {\r
+                ((Stock)flow.head).incomingFlows.add((Variable)flow.tail);\r
+            }\r
+            else if(flow.tail instanceof Stock) {\r
+                ((Stock)flow.tail).outgoingFlows.add((Variable)flow.head);\r
+            }\r
+        }\r
+    };\r
+    \r
+    public void update() {\r
+        for(IElement element : elements)\r
+            element.accept(clearVisitor);\r
+        for(IElement element : elements)\r
+            element.accept(updateVisitor);\r
+    }\r
+    \r
+\r
+    @Override\r
+    public void accept(IElementVisitorVoid v) {\r
+        v.visit(this);\r
+    }\r
+\r
+    @Override\r
+    public ArrayList<IElement> getElements() {\r
+        return elements;\r
+    }\r
+\r
+    @Override\r
+    public String getName() {\r
+        return name;\r
+    }\r
+}\r
index 0ce8a6e36f0fd8a9012493521c448ec2b0b7e8a5..a4279318182b6c35dea75eb28030cbb7630d0969 100644 (file)
@@ -33,6 +33,7 @@ public class SysdynSchema extends SimpleSchema {
             addLinkType(MappingSchemas.fromAnnotations(g, Flow.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, Stock.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, Valve.class));\r
+            addLinkType(MappingSchemas.fromAnnotations(g, Module.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, NormalExpression.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, ParameterExpression.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, StockExpression.class));\r
index 10372b32f2c164cd284a6753356f3c3db8bd275b..6c0d58c58404e6a9542df275bd0d8d3c9ac8179c 100644 (file)
@@ -20,8 +20,6 @@ public abstract class Variable implements IElement {
     protected String name;\r
     @RelatedValue("http://www.simantics.org/Layer0-1.0/HasType")\r
     protected String type;\r
-    //@RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasValue")\r
-    //public String value;\r
     @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasExpression")\r
     public IExpression expression;\r
 \r
index ecb0c11fcb686d6642fa15ca304463636201858e..b5f372251fb005d07f0895d03f6988c385d498c0 100644 (file)
@@ -13,8 +13,10 @@ package org.simantics.sysdyn.representation.visitors;
 \r
 import org.simantics.sysdyn.representation.Auxiliary;\r
 import org.simantics.sysdyn.representation.Cloud;\r
+import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.Dependency;\r
 import org.simantics.sysdyn.representation.Flow;\r
+import org.simantics.sysdyn.representation.Module;\r
 import org.simantics.sysdyn.representation.Stock;\r
 import org.simantics.sysdyn.representation.Valve;\r
 \r
@@ -43,5 +45,12 @@ public class ElementVisitorVoidAdapter implements IElementVisitorVoid {
     @Override\r
     public void visit(Flow flow) {\r
     }\r
+    \r
+    @Override\r
+    public void visit(Module module) {\r
+    }\r
 \r
+    @Override\r
+    public void visit(Configuration configuration) {\r
+    }\r
 }\r
index 3e12a3d2eacde9727b5061583a7f4958bf5ddbf1..a80acc0dcf4e13ba52fb5fe1bd2de899f59d43f8 100644 (file)
@@ -13,8 +13,10 @@ package org.simantics.sysdyn.representation.visitors;
 \r
 import org.simantics.sysdyn.representation.Auxiliary;\r
 import org.simantics.sysdyn.representation.Cloud;\r
+import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.Dependency;\r
 import org.simantics.sysdyn.representation.Flow;\r
+import org.simantics.sysdyn.representation.Module;\r
 import org.simantics.sysdyn.representation.Stock;\r
 import org.simantics.sysdyn.representation.Valve;\r
 \r
@@ -26,5 +28,6 @@ public interface IElementVisitorVoid {
     void visit(Cloud cloud);\r
     void visit(Dependency dependency);\r
     void visit(Flow flow);   \r
-    \r
+    void visit(Module module);\r
+    void visit(Configuration configuration);\r
 }\r
index 5b08665906dc3ec2a921b80db783063791890252..172d3275cb999b063f09513ec8526c39a03eec99 100644 (file)
@@ -29,7 +29,7 @@ public class SimulationJob extends Job {
     ModelicaMonitor monitor;\r
 \r
     public SimulationJob(SysdynModel model) {\r
-        super("Simulate " + model.getConfiguration().name);\r
+        super("Simulate " + model.getConfiguration().getName());\r
         this.model = model;\r
         this.monitor = new ModelicaMonitor();\r
     }\r
index adbc0f3b9511dbaccb1d364cb8df75ade6a19035..a38e485326c33a1a8f0de6a1d8e6b11f3b0afe81 100644 (file)
@@ -53,6 +53,11 @@ SysdynProject : PROJ.Feature
         PROJ.RequiresFeature MOD.ModelingProject\r
         PROJ.RequiresFeature PROJ.ExperimentControl\r
 \r
+\r
+SysdynModuleTestProject : PROJ.Project2\r
+    PROJ.HasFeature SysdynProject\r
+    L0.PartOf L0.Projects\r
+\r
 ######################################################################\r
 # Model\r
 ######################################################################    \r
@@ -88,8 +93,8 @@ SymbolReferences : DIA.SymbolReferenceLibrary
   L0.ConsistsOf\r
     BasicSymbolLibrary @ "Basic Symbols" : DIA.SymbolReferenceLibrary\r
 \r
-Configuration <T ST.Composite\r
-    [L0.ConsistsOf all (Variable or Dependency)]\r
+Configuration <T Module\r
+    [L0.ConsistsOf all (Variable or Dependency or Module)]\r
     [HasStartTime card "1"]\r
     [HasStopTime card "1"]\r
               \r
@@ -114,8 +119,8 @@ HasY <R L0.HasProperty : L0.FunctionalRelation
 HasExpression <R L0.IsRelatedTo : L0.FunctionalRelation\r
     L0.HasRange Expression\r
     \r
-HasType <R L0.HasProperty : L0.FunctionalRelation\r
-    L0.HasRange L0.String\r
+#HasType <R L0.HasProperty : L0.FunctionalRelation\r
+#    L0.HasRange L0.String\r
 \r
 HasUnit <R L0.HasProperty\r
     L0.HasRange L0.String\r
@@ -130,7 +135,7 @@ HasRangeStep <R L0.HasProperty
     L0.HasRange L0.Double  \r
 \r
 IndependentVariable <T Variable\r
-    [HasType card "1"]\r
+    [L0.HasType card "1"]\r
     [HasUnit card "0..1"]\r
     [HasExpression card "0..1"]    \r
     [HasRangeStart card "0..1"]\r
@@ -152,14 +157,28 @@ Stock <T IndependentVariable
     L0.HasObject "Real" : L0.String\r
 \r
 Cloud <T Variable\r
-\r
-Module <T Variable\r
-    [HasTerminal]\r
     \r
-Terminal <T Variable\r
+Input <T Variable\r
     [RefersTo card "0..1"]\r
+    \r
+Terminal <T Input\r
+\r
+######################################################################\r
+# Modules\r
+######################################################################\r
 \r
 \r
+Module <T ST.Composite\r
+    [L0.ConsistsOf all (Variable or Dependency or Module)]\r
+    [HasInput]\r
+    [HasOutput]\r
+    \r
+HasInput <R L0.HasProperty\r
+    L0.HasRange IndependentVariable \r
+\r
+HasOutput <R L0.HasProperty\r
+    L0.HasRange IndependentVariable   \r
+     \r
 ######################################################################\r
 # Connections and Relations\r
 ######################################################################\r
@@ -186,7 +205,7 @@ Flow <T ST.Connection
     [HasTail card "1"]\r
 \r
 RefersTo <R L0.IsRelatedTo\r
-    L0.HasDomain [Terminal]\r
+    L0.HasDomain [IndependentVariable]\r
     L0.HasRange [IndependentVariable]\r
 \r
 HasTerminal <R L0.IsRelatedTo\r
@@ -401,3 +420,80 @@ DependencyConnection <T DIA.Connection
   MOD.DiagramConnectionTypeToConnectionType\r
     Dependency\r
     \r
+    \r
+    \r
+    \r
+######################################################################\r
+# Example model with modules\r
+######################################################################\r
+\r
+ModuleModel @ "ModuleModel" : SysdynModel\r
+  L0.HasLabel "Malli" : L0.String\r
+  L0.PartOf SysdynModuleTestProject\r
+  SIMU.HasConfiguration ModuleConfiguration\r
+      \r
+  \r
+ModuleConfiguration @ "ModuleConfiguration" : Configuration\r
+  HasStartTime "0.0" : L0.Double\r
+  HasStopTime "10.0" : L0.Double\r
+  L0.ConsistsOf\r
+    Module1\r
+    RootAux1 @ "Aux1" : Auxiliary\r
+      L0.HasType "Real" : L0.String\r
+      HasUnit "m" : L0.String\r
+      HasExpression _ : NormalExpression\r
+        HasEquation "1+1" : L0.String\r
+    RootAux2 @ "Aux2" : Auxiliary\r
+      L0.HasType "Real" : L0.String\r
+      HasUnit "s" : L0.String\r
+      HasExpression _ : NormalExpression\r
+        HasEquation "Aux1" : L0.String\r
+    RootInput1 @ "rootInput" : Auxiliary\r
+      L0.HasType "Real" : L0.String\r
+      HasUnit "s" : L0.String\r
+      HasExpression _ : NormalExpression\r
+        HasEquation "1000" : L0.String\r
+      RefersTo FirstModuleOutput1\r
+    _ : Dependency\r
+      HasHead RootAux2\r
+      HasTail RootAux1\r
+  HasOutput RootAux2\r
+  \r
+Module1 @ "FirstModule" : Module\r
+  L0.ConsistsOf \r
+    FirstModuleInput1 @ "Aux1" : Auxiliary\r
+      L0.HasType "Real" : L0.String\r
+      HasUnit "s" : L0.String\r
+      HasExpression _ : ParameterExpression\r
+        HasEquation "2+2" : L0.String\r
+      RefersTo RootAux2\r
+    FirstModuleInput2 @ "Aux2" : Auxiliary\r
+      L0.HasType "Real" : L0.String\r
+      HasUnit "s" : L0.String\r
+      HasExpression _ : ParameterExpression\r
+        HasEquation "2+2" : L0.String\r
+    FirstModuleStock @ "Stock1" : Stock\r
+      HasExpression _ : StockExpression\r
+        HasInitialEquation "0" : L0.String\r
+    FirstModuleCloud : Cloud\r
+    FirstModuleOutput1 @ "Valve" : Valve\r
+      HasUnit "s" : L0.String\r
+      HasExpression _ : ParameterExpression\r
+        HasEquation "Aux1 + Aux2" : L0.String      \r
+    _ : Flow\r
+      HasHead FirstModuleOutput1\r
+      HasTail FirstModuleCloud\r
+    _ : Flow\r
+      HasHead FirstModuleStock\r
+      HasTail FirstModuleOutput1\r
+    _ : Dependency\r
+      HasHead FirstModuleOutput1\r
+      HasTail FirstModuleInput1\r
+    _ : Dependency\r
+      HasHead FirstModuleOutput1\r
+      HasTail FirstModuleInput2\r
+  HasInput FirstModuleInput1\r
+  HasInput FirstModuleInput2\r
+  HasOutput FirstModuleOutput1\r
+  \r
+  \r