]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
new variable type: Input.
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 21 Jul 2010 07:39:21 +0000 (07:39 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 21 Jul 2010 07:39:21 +0000 (07:39 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16740 ac1ea38d-2e2b-0410-8846-a27921b304fc

42 files changed:
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/icons/brick_link.png [new file with mode: 0644]
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Configuration.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/InputNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/editor/SysdynConnectionAdvisor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.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/InputVariableTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ReferenceDependencyTab.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/ExpressionTypes.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/IsOutputWidget.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/ExpressionValidation.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/InputExpression.java [deleted file]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java
org.simantics.sysdyn/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Auxiliary.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Configuration.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/IndependentVariable.java [moved from org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/InputExpression.java with 58% similarity]
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Input.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Module.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/ModuleType.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Stock.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/SysdynSchema.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Valve.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Variable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ConstantExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/Expression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/IExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/NormalExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/ParameterExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/StockExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/WithLookupExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/ElementVisitorVoidAdapter.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/visitors/IElementVisitorVoid.java
sysdyn_ontologies/sysdyn.graph

index 99230159f4ab62424d6da5a4e97524b45c86f153..339b34aadbeebef2d09c70ee156ba6c584cc8a7e 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/Sysdyn-1.0/Module"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ModuleNode">\r                      <this />\r               </type>\r                \r               <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/Module"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode">\r                  <this />\r               </resource>\r\r           <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\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/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\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/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\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             <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.FlowEdgeFactory" />\r           <type 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/Input"\r                        class="org.simantics.sysdyn.ui.browser.nodes.InputNode">\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               <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/Module"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode">\r                  <this />\r               </resource>\r\r           <resource\r                      uri="http://www.simantics.org/Sysdyn-1.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\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/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\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              <resource uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\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/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\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              <type uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \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             <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r                 class="org.simantics.sysdyn.ui.elements2.FlowEdgeFactory" />\r           <type 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
diff --git a/org.simantics.sysdyn.ui/icons/brick_link.png b/org.simantics.sysdyn.ui/icons/brick_link.png
new file mode 100644 (file)
index 0000000..9ebf013
Binary files /dev/null and b/org.simantics.sysdyn.ui/icons/brick_link.png differ
index 602cf20622ca3ed1f87f26d9b2d44613c4e79ac5..90babd615a8d8432a22da3f1a4e598f8e5d064f7 100644 (file)
                class="org.simantics.sysdyn.ui.browser.contributions.ModuleLabeler"\r
                preference="2.0">\r
          </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.InputLabeler"\r
+               preference="2.0">\r
+         </implementation>\r
       </binding>\r
    </extension>\r
    <extension\r
                class="org.simantics.sysdyn.ui.browser.contributions.ModuleImager"\r
                preference="2.0">\r
          </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.InputImager"\r
+               preference="2.0">\r
+         </implementation>\r
       </binding>\r
    </extension>\r
    <extension\r
index 9423274fb56ff19ccf18671dec27e3fa5e515105..086ccde09516af801c3bf857e0bb8542c5a915fb 100644 (file)
@@ -27,6 +27,13 @@ public class Configuration extends ViewpointContributor<ConfigurationNode> {
                     e.printStackTrace();\r
                 }\r
             }\r
+            for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.Input))) {\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
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputImager.java
new file mode 100644 (file)
index 0000000..c70b366
--- /dev/null
@@ -0,0 +1,17 @@
+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.InputNode;\r
+\r
+public class InputImager extends ImagerContributor<InputNode> {\r
+\r
+    @Override\r
+    public ImageDescriptor getDescriptor(ReadGraph graph, InputNode node) throws DatabaseException {\r
+        return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/brick_link.png"));\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/InputLabeler.java
new file mode 100644 (file)
index 0000000..3e042c6
--- /dev/null
@@ -0,0 +1,27 @@
+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.InputNode;\r
+\r
+public class InputLabeler extends LabelerContributor<InputNode>{\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, InputNode var) throws DatabaseException {\r
+        Builtins b = graph.getBuiltins();\r
+        Resource varres = var.resource;\r
+        StringBuilder sb = new StringBuilder();\r
+        for(Resource r : graph.getObjects(varres, b.HasName))\r
+            sb.append(graph.getValue(r));\r
+        sb.append(" : ");\r
+        for(Resource t : graph.getObjects(varres, 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
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/InputNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/InputNode.java
new file mode 100644 (file)
index 0000000..b0efeb7
--- /dev/null
@@ -0,0 +1,10 @@
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class InputNode  extends AbstractNode {\r
+\r
+    public InputNode(Resource resource) {\r
+        super(resource);\r
+    }\r
+}\r
index bcec3c9aeb08cc8a3f644d4a94a6b35403c02fd9..bcf578251bf44bd4e1dd29985511c5d86da4ad5e 100644 (file)
@@ -30,7 +30,7 @@ public class SysdynConnectionAdvisor  implements IConnectionAdvisor {
         this.modelingRules = modelingRules;\r
         this.processor = processor;\r
     }\r
-    \r
+\r
     IConnectionPoint getConnectionPoint(ReadGraph g, IElement element, Terminal term) throws DatabaseException {\r
         Object obj = null;\r
         if (element != null)\r
@@ -40,11 +40,11 @@ public class SysdynConnectionAdvisor  implements IConnectionAdvisor {
             Resource elementResource = (Resource) obj;\r
             return ConnectionUtil.toConnectionPoint(g, elementResource, term);\r
         }\r
-        \r
+\r
         if(element.getElementClass().containsClass(FlagHandler.class)) {\r
             return new CPFlag(null);\r
         }\r
-        \r
+\r
         return null;\r
     }\r
 \r
@@ -67,8 +67,21 @@ public class SysdynConnectionAdvisor  implements IConnectionAdvisor {
                     if(!g.hasStatement(connectionVariable, str2.Binds, sr.IsHeadOfTerminal)) {\r
                         return null;\r
                     }\r
+\r
+                    // Only one incoming dependency allowed in inputs. That dependency must be from a module\r
+                    Object obj1 = ElementUtils.getObject(element1);\r
+                    Object obj2 = ElementUtils.getObject(element2);\r
+                    if(obj2 instanceof Resource) {\r
+                        Resource startElementResource = (Resource)obj1;\r
+                        Resource endElementResource = (Resource)obj2;\r
+                        if(g.isInstanceOf(endElementResource, sr.InputSymbol)) {\r
+                            if(g.isInheritedFrom(startElementResource, sr.ModuleSymbol)) return null;\r
+                            if(g.getObjects(endElementResource, sr.IsHeadOfTerminal).size() > 0) return null;\r
+                        }\r
+                    }\r
+\r
                     IConnection connection = modelingRules.createConnection()\r
-                        .attachNew(g, getConnectionPoint(g, element1, term1));\r
+                    .attachNew(g, getConnectionPoint(g, element1, term1));\r
                     if(element2 != null)\r
                         connection = connection.attachNew(g, getConnectionPoint(g, element2, term2));\r
                     if(connection.isLegal())\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/elements2/InputFactory.java
new file mode 100644 (file)
index 0000000..e266bf2
--- /dev/null
@@ -0,0 +1,63 @@
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Shape;\r
+import java.awt.geom.Path2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.diagram.elements.TextElementHandler;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
+import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.g2d.element.handler.impl.OutlinePick;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;\r
+import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
+import org.simantics.g2d.element.handler.impl.TextFontImpl;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
+import org.simantics.g2d.image.Image;\r
+import org.simantics.g2d.image.impl.ShapeImage;\r
+\r
+public class InputFactory extends SysdynElementFactory {\r
+\r
+    private static final BasicStroke    STROKE           = new BasicStroke(1f);\r
+    private static final Image       INPUT_IMAGE = new ShapeImage(getInputShape(), null, STROKE, true);\r
+\r
+    static Shape getInputShape() {\r
+        Path2D path = new Path2D.Double();\r
+        path.moveTo(0, -1);\r
+        path.lineTo(5, -1);\r
+        path.lineTo(5, -2.5);\r
+        path.lineTo(7.5, 0);\r
+        path.curveTo(7.5, -2.5, 12.5, -2.5, 12.5, 0);\r
+        path.curveTo(12.5, 2.5, 7.5, 2.5, 7.5, 0);\r
+        path.lineTo(5, 2.5);\r
+        path.lineTo(5, 1);\r
+        path.lineTo(0, 1);\r
+        path.closePath();\r
+        return path;\r
+    }\r
+    @Override\r
+    protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
+        return ElementClass.compile(\r
+                SimpleElementLayers.INSTANCE,\r
+                OutlinePick.INSTANCE,\r
+                TextImpl.INSTANCE,\r
+                TextColorImpl.BLACK,\r
+                TextFontImpl.DEFAULT,\r
+                DefaultTransform.INSTANCE,\r
+                new StaticObjectAdapter(elementType),\r
+                new StaticSymbolImpl(INPUT_IMAGE),\r
+                StaticSymbolImageInitializer.INSTANCE,\r
+                TextElementHandler.INSTANCE,\r
+                BoundsOutline.INSTANCE,\r
+                new WholeElementTerminals(terminals)\r
+        ).setId(AuxiliaryFactory.class.getSimpleName());\r
+    }\r
+\r
+\r
+}\r
index b301587910ddf0a4277be0f421e41c6cae188e71..ae407a9687cff46b5e321e82de0ce46d522b7d27 100644 (file)
@@ -60,7 +60,7 @@ import org.simantics.sysdyn.manager.SysdynModel;
 import org.simantics.sysdyn.manager.SysdynModelManager;\r
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.IElement;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 import org.simantics.sysdyn.ui.equation.expressions.ExpressionField;\r
 import org.simantics.sysdyn.ui.equation.expressions.StockExpressionViewFactor;\r
 import org.simantics.ui.SimanticsUI;\r
@@ -406,8 +406,8 @@ public class EquationView extends ViewPart implements ISelectionListener {
             Configuration conf = model.getConfiguration();\r
             ArrayList<IElement> elements = conf.getElements();\r
             for(IElement e : elements) {\r
-                if(e instanceof Variable) {\r
-                    Variable v = (Variable) e;\r
+                if(e instanceof IndependentVariable) {\r
+                    IndependentVariable v = (IndependentVariable) e;\r
                     modelVariables.add(v.getName());\r
                 }\r
             }\r
index fbc5fef65bd4c2fc5bcb9a9a500fa7ff987d7b24..bc959253ff37beffc87b76f7ee6347bf59598693 100644 (file)
@@ -36,7 +36,7 @@ import org.simantics.sysdyn.manager.SysdynModel;
 import org.simantics.sysdyn.manager.SysdynModelManager;\r
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.IElement;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.ui.workbench.ResourceEditorInput;\r
 \r
@@ -118,8 +118,8 @@ public class NameComposite extends Composite {
             IElement thisElement = model.getElement(variable);\r
             ArrayList<IElement> elements = conf.getElements();\r
             for(IElement e : elements) {\r
-                if(e instanceof Variable) {\r
-                    Variable v = (Variable)e;\r
+                if(e instanceof IndependentVariable) {\r
+                    IndependentVariable v = (IndependentVariable)e;\r
                     if(v != thisElement && v.getName().equals(this.nameText.getText())) {\r
                         this.nameText.setText(this.originalName);\r
                         this.nameText.setSelection(this.originalName.length());\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/InputVariableTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/InputVariableTab.java
new file mode 100644 (file)
index 0000000..357bdf6
--- /dev/null
@@ -0,0 +1,70 @@
+package org.simantics.sysdyn.ui.properties;\r
+\r
+\r
+import org.eclipse.jface.dialogs.IInputValidator;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedCombo;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.IsOutputWidget;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
+\r
+public class InputVariableTab  extends PropertyTabContributorImpl {\r
+\r
+    TrackedCombo expressionTypeCombo;\r
+    IsOutputWidget isOutput;\r
+    \r
+    @Override\r
+    public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+        Composite composite = new Composite(body, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite);\r
+\r
+        TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+        nameText.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasName));\r
+        nameText.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasName));\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget());\r
+\r
+        isOutput = new IsOutputWidget(composite, support, SWT.NULL);\r
+\r
+        Label label = new Label(composite, SWT.NULL);\r
+        label.setText("Default Value");\r
+        \r
+        TrackedText rangeStep = new TrackedText(composite, support, SWT.RIGHT | SWT.BORDER);\r
+        rangeStep.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasRangeStep));\r
+        rangeStep.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasDefaultInputValue));\r
+        rangeStep.setInputValidator(new DoubleValidator());\r
+        GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStep.getWidget());\r
+\r
+\r
+    }\r
+\r
+    private class DoubleValidator implements IInputValidator {\r
+\r
+        @Override\r
+        public String isValid(String newText) {\r
+            for(int i = 0; i < newText.length(); i++){\r
+                if(!Character.isDigit(newText.charAt(i))){\r
+                    if(newText.charAt(i) != '.') {\r
+                        return "Invalid character '" + newText.charAt(i) + "'";\r
+                    } else if(newText.indexOf('.') != newText.lastIndexOf('.')) {\r
+                        return "There can be only one '.'";\r
+                    }\r
+                }\r
+            }\r
+            return null;\r
+        }\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ReferenceDependencyTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ReferenceDependencyTab.java
new file mode 100644 (file)
index 0000000..56fa104
--- /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 ReferenceDependencyTab extends PropertyTabContributorImpl {\r
+\r
+    @Override\r
+    public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+    }\r
+\r
+}\r
index 2f2bc2982e2d095a0161769a912f3ad6a1c67ab2..e2756e9a0599b81ca1522408beb2473bb8c20d83 100644 (file)
@@ -31,16 +31,21 @@ public class ResourceSelectionProcessor implements SelectionProcessor<ISelection
             Collection<ComparableTabContributor> tabs = new ArrayList<ComparableTabContributor>();\r
             if (backend.isInstanceOf(r, dr.Element)) {\r
                 Resource component = backend.getPossibleObject(r, mr.ElementToComponent);\r
-                if (component != null)\r
+                if (component != null) {\r
                     r = component;\r
+                } else {\r
+                    Resource connection = backend.getPossibleObject(r, mr.DiagramConnectionToConnection);\r
+                    if(connection != null)\r
+                        r = connection;\r
+                }\r
             }\r
             if (backend.isInstanceOf(r, sr.IndependentVariable)) {\r
-                tabs.add(new ComparableTabContributor(\r
-                        new EquationTab(),\r
-                        2,\r
-                        r,\r
-                        "Equation"));\r
                 Resource expression = backend.getPossibleObject(r, sr.HasExpression);\r
+                    tabs.add(new ComparableTabContributor(\r
+                            new EquationTab(),\r
+                            2,\r
+                            r,\r
+                    "Equation"));\r
                 if(expression != null && backend.isInstanceOf(expression, sr.WithLookupExpression)) {\r
                     tabs.add(new ComparableTabContributor(\r
                             new LookupTableTab(),\r
@@ -55,6 +60,13 @@ public class ResourceSelectionProcessor implements SelectionProcessor<ISelection
                 "Additional Information"));\r
                 return tabs;\r
             }\r
+            if (backend.isInstanceOf(r, sr.Input)) {\r
+                return Collections.singleton(new ComparableTabContributor(\r
+                        new InputVariableTab(),\r
+                        2,\r
+                        r,\r
+                "Input"));\r
+            }\r
             if (backend.isInstanceOf(r, sr.Configuration))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
@@ -90,6 +102,14 @@ public class ResourceSelectionProcessor implements SelectionProcessor<ISelection
                                 0,\r
                                 r,\r
                         "Result Properties"));\r
+            if (backend.isInstanceOf(r, sr.Dependency))\r
+                if (backend.hasStatement(r, sr.RefersTo))\r
+                    return Collections.singleton(\r
+                            new ComparableTabContributor(\r
+                                    new ReferenceDependencyTab(),\r
+                                    0,\r
+                                    r,\r
+                            "Reference Properties"));\r
         } catch (ServiceException e) {\r
             e.printStackTrace();\r
         } catch (ManyObjectsForFunctionalRelationException e) {\r
index a26ebdfdc3f400adbe554e0ee40384284c0ceae1..3741a34ed21e07ec3850f42bdeb2fe9605c2a0c5 100644 (file)
@@ -9,7 +9,7 @@ import org.simantics.ui.SimanticsUI;
 \r
 public class ExpressionTypes {\r
 \r
-    public static enum ExpressionType {Auxiliary, Parameter, Constant, Lookup, WithLookup, Stock, Delay, Empty, Input};\r
+    public static enum ExpressionType {Auxiliary, Parameter, Constant, Lookup, WithLookup, Stock, Delay, Empty};\r
 \r
     public static ExpressionType[] auxiliaryExpressions = new ExpressionType[] {\r
         ExpressionType.Parameter, \r
@@ -75,8 +75,6 @@ public class ExpressionTypes {
                     et = ExpressionType.Lookup;\r
                 } else if (graph.isInstanceOf(expression, sr.WithLookupExpression)) {\r
                     et = ExpressionType.WithLookup;\r
-                } else if (graph.isInstanceOf(expression, sr.InputExpression)) {\r
-                    et = ExpressionType.Input;                    \r
                 } else {\r
                     et =  ExpressionType.Empty;\r
                 }\r
index b7e7bf7fa40cc529675c69ea20caa43061aec54c..94643afabf11f61a43470a64d52c8422eb86893d 100644 (file)
@@ -26,7 +26,6 @@ import org.simantics.sysdyn.ui.properties.widgets.expressions.DelayExpression;
 import org.simantics.sysdyn.ui.properties.widgets.expressions.EmptyExpression;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionValidation;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.IExpression;\r
-import org.simantics.sysdyn.ui.properties.widgets.expressions.InputExpression;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.LookupExpression;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.ParameterExpression;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.StockExpression;\r
@@ -91,8 +90,6 @@ public class ExpressionWidget implements Widget {
                 exp = new StockExpression(); break;\r
             case Delay: \r
                 exp = new DelayExpression(); break;\r
-            case Input:\r
-                exp = new InputExpression(); break;\r
             default: \r
                 exp = new EmptyExpression();\r
         }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/IsOutputWidget.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/IsOutputWidget.java
new file mode 100644 (file)
index 0000000..2c90f66
--- /dev/null
@@ -0,0 +1,91 @@
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class IsOutputWidget implements Widget{\r
+    \r
+    Resource variable = null; \r
+    org.simantics.browsing.ui.swt.widgets.Button isOutputButton;\r
+    \r
+    public IsOutputWidget(Composite parent, WidgetSupport support, int style) {\r
+        support.register(this);\r
+        isOutputButton = new org.simantics.browsing.ui.swt.widgets.Button(parent, support, style |= SWT.CHECK);\r
+        isOutputButton.setText("Is Output");\r
+    }\r
+\r
+    @Override\r
+    public void setInput(ISessionContext context, Object input) {\r
+        if(input instanceof ISelection) {\r
+            ISelection selection = (ISelection)input;\r
+            if(selection instanceof IStructuredSelection) {\r
+                Resource resource = ISelectionUtils.filterSingleSelection(selection, Resource.class);\r
+                if(resource != null) {\r
+                    variable = resource;\r
+                }\r
+            }\r
+        }\r
+        \r
+        if(variable == null) return;\r
+        \r
+        try {\r
+            context.getSession().syncRequest(new ReadRequest() {\r
+                \r
+                @Override\r
+                public void run(ReadGraph graph) throws DatabaseException {\r
+                    SysdynResource sr = SysdynResource.getInstance(graph);\r
+                    final boolean isOutput = graph.hasStatement(variable, sr.IsOutput);\r
+                    final Button button = getWidget();\r
+                    button.getDisplay().asyncExec(new Runnable() {\r
+                        \r
+                        @Override\r
+                        public void run() {\r
+                            if(button.isDisposed()) return;\r
+                            \r
+                            if(isOutput)\r
+                                button.setSelection(true);\r
+                            else\r
+                                button.setSelection(false);\r
+                        }\r
+                    });\r
+\r
+                        \r
+                }\r
+            });\r
+        } catch (DatabaseException e) {\r
+            e.printStackTrace();\r
+        }\r
+        \r
+        isOutputButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+            @Override\r
+            public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+                SysdynResource sr =  SysdynResource.getInstance(graph);\r
+                if(graph.hasStatement(input, sr.IsOutput)) {\r
+                    graph.deny(input, sr.IsOutput);\r
+                } else {\r
+                    graph.claim(input, SysdynResource.getInstance(graph).IsOutput, null, input);\r
+                }\r
+            }\r
+        });\r
+    }\r
+    \r
+    public Button getWidget() {\r
+        return isOutputButton.getWidget();\r
+    }\r
+\r
+}\r
index 5c8a2cdd38627bc5fabb152ce25febbb44d47909..92ef23264a6cb01d4e56e64f5a88baa6561ce0c6 100644 (file)
@@ -19,7 +19,7 @@ import org.simantics.sysdyn.manager.SysdynModel;
 import org.simantics.sysdyn.manager.SysdynModelManager;\r
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.IElement;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 import org.simantics.sysdyn.ui.properties.widgets.expressions.IExpression;\r
 import org.simantics.ui.SimanticsUI;\r
 \r
@@ -56,8 +56,8 @@ public class ExpressionValidation {
             Configuration conf = model.getConfiguration();\r
             ArrayList<IElement> elements = conf.getElements();\r
             for(IElement e : elements) {\r
-                if(e instanceof Variable) {\r
-                    Variable v = (Variable) e;\r
+                if(e instanceof IndependentVariable) {\r
+                    IndependentVariable v = (IndependentVariable) e;\r
                     modelVariables.add(v.getName());\r
                 }\r
             }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/InputExpression.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/InputExpression.java
deleted file mode 100644 (file)
index 384182d..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
-\r
-import java.util.Collections;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.FocusListener;\r
-import org.eclipse.swt.events.KeyListener;\r
-import org.eclipse.swt.events.ModifyListener;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.simantics.db.Resource;\r
-\r
-public class InputExpression  implements IExpression {\r
-\r
-    @Override\r
-    public void createExpressionFields(Composite parent, Map<String, Object> data) {\r
-        GridLayoutFactory.fillDefaults().applyTo(parent);\r
-        Label label = new Label(parent, SWT.NONE);\r
-        label.setText("Input");\r
-    }\r
-\r
-    @Override\r
-    public void readData(Resource variable, Map<String, Object> data) {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void save(Resource variable, Map<String, Object> data) {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void focus() {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void replaceSelection(String var) {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void updateData(Map<String, Object> data) {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-    @SuppressWarnings("unchecked")\r
-    @Override\r
-    public List<ExpressionField> getExpressionFields() {\r
-        // TODO Auto-generated method stub\r
-        return Collections.EMPTY_LIST;\r
-    }\r
-\r
-    @Override\r
-    public void addModifyListener(ModifyListener listener) {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void addKeyListener(KeyListener listener) {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-    @Override\r
-    public void addFocusListener(FocusListener listener) {\r
-        // TODO Auto-generated method stub\r
-        \r
-    }\r
-\r
-}\r
index 67d3649b79ba4eb2cfff71e990da69f20f6addf0..8ad31ef2ebed097815afb8a41c8137ea04a0437d 100644 (file)
@@ -13,7 +13,6 @@ package org.simantics.sysdyn.ui.trend;
 \r
 import java.awt.Frame;\r
 import java.util.ArrayList;\r
-import java.util.HashMap;\r
 import java.util.Set;\r
 \r
 import javax.swing.SwingUtilities;\r
@@ -49,8 +48,6 @@ import org.simantics.diagram.stubs.DiagramResource;
 import org.simantics.modeling.ModelingUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.manager.SysdynDataSet;\r
-import org.simantics.sysdyn.manager.SysdynModel;\r
-import org.simantics.sysdyn.manager.SysdynModelManager;\r
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.ui.ISelectionUtils;\r
 import org.simantics.utils.ui.jface.ActiveSelectionProvider;\r
@@ -249,6 +246,7 @@ public class TrendView extends ViewPart {
         System.out.println("load dataset for '" + item.getURI(g) + "'");\r
         \r
         Accessor accessor = item.getInterface(g, Accessor.class);\r
+        if(accessor == null) return null;\r
         try {\r
                        return (SysdynDataSet)accessor.getValue(Bindings.getBindingUnchecked(SysdynDataSet.class));\r
                } catch (RuntimeBindingConstructionException e) {\r
index 924b6fdf08f9c4b2ce3bb55b0e217c75a5166abd..75411206623e2d4bcb58c1100004d326aa58b528 100644 (file)
@@ -46,6 +46,7 @@ public class SysdynResource {
     public final Resource Flow;\r
     public final Resource FlowConnection;\r
     public final Resource GameExperiment;\r
+    public final Resource HasDefaultInputValue;\r
     public final Resource HasEquation;\r
     public final Resource HasExpression;\r
     public final Resource HasHead;\r
@@ -71,7 +72,8 @@ public class SysdynResource {
     public final Resource HasY;\r
     public final Resource HistoryRealization;\r
     public final Resource IndependentVariable;\r
-    public final Resource InputExpression;\r
+    public final Resource Input;\r
+    public final Resource InputSymbol;\r
     public final Resource IsHeadOf;\r
     public final Resource IsHeadOfTerminal;\r
     public final Resource IsInput;\r
@@ -130,6 +132,7 @@ public class SysdynResource {
         public static final String Flow = "http://www.simantics.org/Sysdyn-1.0/Flow";\r
         public static final String FlowConnection = "http://www.simantics.org/Sysdyn-1.0/FlowConnection";\r
         public static final String GameExperiment = "http://www.simantics.org/Sysdyn-1.0/GameExperiment";\r
+        public static final String HasDefaultInputValue = "http://www.simantics.org/Sysdyn-1.0/HasDefaultInputValue";\r
         public static final String HasEquation = "http://www.simantics.org/Sysdyn-1.0/HasEquation";\r
         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
@@ -155,7 +158,8 @@ public class SysdynResource {
         public static final String HasY = "http://www.simantics.org/Sysdyn-1.0/HasY";\r
         public static final String HistoryRealization = "http://www.simantics.org/Sysdyn-1.0/HistoryRealization";\r
         public static final String IndependentVariable = "http://www.simantics.org/Sysdyn-1.0/IndependentVariable";\r
-        public static final String InputExpression = "http://www.simantics.org/Sysdyn-1.0/InputExpression";\r
+        public static final String Input = "http://www.simantics.org/Sysdyn-1.0/Input";\r
+        public static final String InputSymbol = "http://www.simantics.org/Sysdyn-1.0/InputSymbol";\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 IsInput = "http://www.simantics.org/Sysdyn-1.0/IsInput";\r
@@ -224,6 +228,7 @@ public class SysdynResource {
         Flow = getResourceOrNull(graph, URIs.Flow);\r
         FlowConnection = getResourceOrNull(graph, URIs.FlowConnection);\r
         GameExperiment = getResourceOrNull(graph, URIs.GameExperiment);\r
+        HasDefaultInputValue = getResourceOrNull(graph, URIs.HasDefaultInputValue);\r
         HasEquation = getResourceOrNull(graph, URIs.HasEquation);\r
         HasExpression = getResourceOrNull(graph, URIs.HasExpression);\r
         HasHead = getResourceOrNull(graph, URIs.HasHead);\r
@@ -249,7 +254,8 @@ public class SysdynResource {
         HasY = getResourceOrNull(graph, URIs.HasY);\r
         HistoryRealization = getResourceOrNull(graph, URIs.HistoryRealization);\r
         IndependentVariable = getResourceOrNull(graph, URIs.IndependentVariable);\r
-        InputExpression = getResourceOrNull(graph, URIs.InputExpression);\r
+        Input = getResourceOrNull(graph, URIs.Input);\r
+        InputSymbol = getResourceOrNull(graph, URIs.InputSymbol);\r
         IsHeadOf = getResourceOrNull(graph, URIs.IsHeadOf);\r
         IsHeadOfTerminal = getResourceOrNull(graph, URIs.IsHeadOfTerminal);\r
         IsInput = getResourceOrNull(graph, URIs.IsInput);\r
index 02e71a7ded9e2caf0e9d35d9e11a62fb31ebe680..9270f113fdf7a0cb9ba4bed48300da7b4f4c7c89 100644 (file)
 package org.simantics.sysdyn.modelica;\r
 \r
 import java.util.ArrayList;\r
+import java.util.HashMap;\r
 \r
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.Dependency;\r
 import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.Input;\r
 import org.simantics.sysdyn.representation.Module;\r
 import org.simantics.sysdyn.representation.ModuleType;\r
 import org.simantics.sysdyn.representation.Stock;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 import org.simantics.sysdyn.representation.Variable;\r
 import org.simantics.sysdyn.representation.expressions.IExpression;\r
 import org.simantics.sysdyn.representation.expressions.WithLookupExpression;\r
@@ -58,20 +61,30 @@ public class ModelicaWriter {
 \r
         configuration.update();\r
 \r
-        ArrayList<Variable> variables = new ArrayList<Variable>();\r
+        ArrayList<IndependentVariable> variables = new ArrayList<IndependentVariable>();\r
+        ArrayList<Input> inputs = new ArrayList<Input>();\r
         ArrayList<Module> modules = new ArrayList<Module>();\r
         ArrayList<Stock> stocks = new ArrayList<Stock>();\r
         ArrayList<Dependency> inputDependencies = new ArrayList<Dependency>();\r
         ArrayList<Dependency> outputDependencies = new ArrayList<Dependency>();\r
-\r
+        HashMap<Module, ArrayList<Input>> moduleInputs = new HashMap<Module, ArrayList<Input>>();\r
+        \r
         // Initialize lists\r
         for(IElement element : configuration.getElements()) {\r
-            if(element instanceof Variable) {\r
-                variables.add((Variable)element);\r
+            if(element instanceof IndependentVariable) {\r
+                variables.add((IndependentVariable)element);\r
                 if(element instanceof Stock)\r
                     stocks.add((Stock)element);\r
             } else if (element instanceof Module) {\r
-                modules.add((Module)element);\r
+                Module m = (Module)element; \r
+                modules.add(m);\r
+                ArrayList<Input> inputsInModule = new ArrayList<Input>();\r
+                for(IElement e : m.getType().getConfiguration().getElements())\r
+                    if(e instanceof Input && ((Input)e).isInput())\r
+                        inputsInModule.add((Input)e);\r
+                moduleInputs.put(m, inputsInModule);\r
+            } else if (element instanceof Input) {\r
+                inputs.add((Input)element);\r
             } else if (element instanceof Dependency && ((Dependency)element).refersTo() != null) {\r
                 Dependency dependency = (Dependency)element;\r
                 if(dependency.getHead() instanceof Module) {\r
@@ -88,8 +101,8 @@ public class ModelicaWriter {
         b.append("class ").append(className).append('\n');\r
         \r
         b.append("// Variable definitions\n");\r
-        for(Variable variable : variables) {\r
-            IExpression expr = (variable).getExpression();\r
+        for(IndependentVariable variable : variables) {\r
+            IExpression expr = variable.getExpression();\r
             if(expr != null && insertInterpolate == false) {\r
                 app = expr.getDeclaration(variable);\r
                 if (app != null) b.append(app);\r
@@ -103,7 +116,14 @@ public class ModelicaWriter {
                 b.append("    " + m.getType().getName() + " " + m.getLabel() + ";\n");\r
             }\r
         }\r
-\r
+        \r
+        if(!inputs.isEmpty()) {\r
+            b.append("// Input definitions\n");\r
+            for(Input i : inputs) {\r
+                b.append("    " + i.getType() + " " + i.getName() + ";\n");\r
+            }\r
+        }\r
+        \r
         for(Stock stock : stocks) {\r
             IExpression expr = stock.getExpression();\r
             if(expr != null) {\r
@@ -122,7 +142,7 @@ public class ModelicaWriter {
         b.append("equation\n");\r
 \r
         b.append("// Equations\n");\r
-        for(Variable variable : variables) {\r
+        for(IndependentVariable variable : variables) {\r
             IExpression expr = variable.getExpression();\r
             if(expr != null) {\r
                 app = expr.getEquation(variable);\r
@@ -133,7 +153,7 @@ public class ModelicaWriter {
 \r
         b.append("// Inputs\n");\r
         for(Dependency dependency : inputDependencies) {\r
-            Variable variable = (Variable)dependency.getHead();\r
+            Input variable = (Input)dependency.getHead();\r
             Module module = (Module)dependency.getTail();\r
             Variable reference = (Variable)dependency.refersTo();\r
             b.append("    " + variable.getName() + " = " + module.getLabel() + "." + reference.getName() + ";\n");\r
@@ -143,10 +163,18 @@ public class ModelicaWriter {
         for(Dependency dependency : outputDependencies) {\r
             Variable variable = (Variable)dependency.getTail();\r
             Module module = (Module)dependency.getHead();\r
-            Variable reference = (Variable)dependency.refersTo();\r
+            Input reference = (Input)dependency.refersTo();\r
             b.append("    " + module.getLabel() + "." + reference.getName() + " = " + variable.getName() + ";\n");\r
+            moduleInputs.get(module).remove(reference);\r
         }\r
-\r
+        \r
+        b.append("// Default values for inputs in modules\n");\r
+        for(Module module : moduleInputs.keySet()) {\r
+            for(Input input : moduleInputs.get(module)) {\r
+                b.append("    " + module.getLabel() + "." + input.getName() + " = " + input.getDefaultInputValue() + ";\n");\r
+            }\r
+        }\r
+        \r
         b.append("end ").append(className).append(";\n\n");\r
 \r
 \r
index a79be2789b9da8fcaaef35f9050bc1bf31281fd4..d4aae21f1480bfa529a78dd8e98cfad1f4b30f55 100644 (file)
@@ -15,7 +15,7 @@ import org.simantics.objmap.annotations.GraphType;
 import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/Auxiliary")\r
-public class Auxiliary extends Variable {\r
+public class Auxiliary extends IndependentVariable {\r
     @Override\r
     public void accept(IElementVisitorVoid v) {\r
         v.visit(this);\r
index e59128a8be946cf11e73c5cbc2c6445c8427b952..77e632bfe5cb6532bd665b8b75f9d18de06a5de9 100644 (file)
@@ -54,10 +54,10 @@ public class Configuration {
     IElementVisitorVoid updateVisitor = new ElementVisitorVoidAdapter() {\r
         public void visit(Flow flow) {\r
             if(flow.getHead() instanceof Stock) {\r
-                ((Stock)flow.getHead()).incomingFlows.add((Variable)flow.getTail());\r
+                ((Stock)flow.getHead()).incomingFlows.add((IndependentVariable)flow.getTail());\r
             }\r
             else if(flow.getTail() instanceof Stock) {\r
-                ((Stock)flow.getTail()).outgoingFlows.add((Variable)flow.getHead());\r
+                ((Stock)flow.getTail()).outgoingFlows.add((IndependentVariable)flow.getHead());\r
             }\r
         }\r
     };\r
similarity index 58%
rename from org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/InputExpression.java
rename to org.simantics.sysdyn/src/org/simantics/sysdyn/representation/IndependentVariable.java
index 84590be64aa8808e1124078f723524c219350b36..24aa1f16c3ebbdcc8b4b0f92b9f26e6dd05846db 100644 (file)
@@ -9,17 +9,17 @@
  * Contributors:\r
  *     VTT Technical Research Centre of Finland - initial API and implementation\r
  *******************************************************************************/\r
-package org.simantics.sysdyn.representation.expressions;\r
+package org.simantics.sysdyn.representation;\r
 \r
-import org.simantics.objmap.annotations.GraphType;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.sysdyn.representation.expressions.IExpression;\r
 \r
-@GraphType("http://www.simantics.org/Sysdyn-1.0/InputExpression")\r
-public class InputExpression extends Expression {\r
+public abstract class IndependentVariable extends Variable {\r
 \r
-    @Override\r
-    public String getDeclaration(Variable variable) {\r
-        return "    " + variable.getType() + " " + variable.getName() + ";\n";\r
+    @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasExpression")\r
+    protected IExpression expression;\r
+    \r
+    public IExpression getExpression() {\r
+        return this.expression;\r
     }\r
-\r
 }\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Input.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Input.java
new file mode 100644 (file)
index 0000000..b280fe0
--- /dev/null
@@ -0,0 +1,29 @@
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Input")\r
+public class Input extends Variable {\r
+\r
+    @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasDefaultInputValue")\r
+    private Double defaultInputValue;\r
+    @RelatedElement("http://www.simantics.org/Sysdyn-1.0/IsInput")\r
+    private IElement isInput;\r
+    \r
+    @Override\r
+    public void accept(IElementVisitorVoid v) {\r
+        v.visit(this);\r
+    }\r
+\r
+    public String getDefaultInputValue() {\r
+        return defaultInputValue.toString();\r
+    }\r
+    \r
+    public boolean isInput() {\r
+        return isInput != null;\r
+    }\r
+\r
+}\r
index b28a7ffef45337b002bbf2a6211185c00b6271fb..7aed35d3b216cbf4f1098c783fb6c31c7c82667d 100644 (file)
@@ -21,9 +21,6 @@ public class Module implements IElement {
     @RelatedElement("http://www.simantics.org/Layer0-1.0/InstanceOf")\r
     private ModuleType type;\r
 \r
-    @RelatedElement("http://www.simantics.org/Structural-1.0/IsDefinedBy")\r
-    private Configuration configuration;\r
-\r
     IElementVisitorVoid clearVisitor = new ElementVisitorVoidAdapter() {\r
         public void visit(Stock stock) {\r
             stock.incomingFlows.clear();\r
@@ -34,10 +31,10 @@ public class Module implements IElement {
     IElementVisitorVoid updateVisitor = new ElementVisitorVoidAdapter() {\r
         public void visit(Flow flow) {\r
             if(flow.getHead() instanceof Stock) {\r
-                ((Stock)flow.getHead()).incomingFlows.add((Variable)flow.getTail());\r
+                ((Stock)flow.getHead()).incomingFlows.add((IndependentVariable)flow.getTail());\r
             }\r
             else if(flow.getTail() instanceof Stock) {\r
-                ((Stock)flow.getTail()).outgoingFlows.add((Variable)flow.getHead());\r
+                ((Stock)flow.getTail()).outgoingFlows.add((IndependentVariable)flow.getHead());\r
             }\r
         }\r
     };\r
@@ -64,7 +61,4 @@ public class Module implements IElement {
         return this.parentConfiguration;\r
     }\r
 \r
-    public Configuration getConfiguration() {\r
-        return this.configuration;\r
-    }\r
 }\r
index af9345551dc77a855eb3b0b30c52ac62160bd6f4..bbf7277e2ecc362ec9676d204e5fcc91ea520318 100644 (file)
@@ -1,6 +1,7 @@
 package org.simantics.sysdyn.representation;\r
 \r
 import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
 import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
 \r
@@ -9,10 +10,17 @@ public class ModuleType implements IElement {
 \r
     @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
     private String name;\r
+    \r
+    @RelatedElement("http://www.simantics.org/Structural-1.0/IsDefinedBy")\r
+    private Configuration configuration;\r
 \r
     public String getName() {\r
        return name;\r
     }\r
+\r
+    public Configuration getConfiguration() {\r
+        return this.configuration;\r
+    }\r
     \r
        @Override\r
        public void accept(IElementVisitorVoid v) {\r
index 4d522590e67355be5157105f42b3bd5483f93554..906fb094c59dfe27b98c53044e203d7402863522 100644 (file)
@@ -17,9 +17,9 @@ import org.simantics.objmap.annotations.GraphType;
 import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/Stock")\r
-public class Stock extends Variable {\r
-    public ArrayList<Variable> incomingFlows = new ArrayList<Variable>(2);\r
-    public ArrayList<Variable> outgoingFlows = new ArrayList<Variable>(2);\r
+public class Stock extends IndependentVariable {\r
+    public ArrayList<IndependentVariable> incomingFlows = new ArrayList<IndependentVariable>(2);\r
+    public ArrayList<IndependentVariable> outgoingFlows = new ArrayList<IndependentVariable>(2);\r
     \r
     public Stock() {\r
         name = "Valve" + hashCode(); // FIXME\r
index 877401e28bb61c8fb43416ff143d2706ef03737a..c837a3caba25699578b6acd91ac3ac6f1e8d4e39 100644 (file)
@@ -16,7 +16,6 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.objmap.schema.MappingSchemas;\r
 import org.simantics.objmap.schema.SimpleSchema;\r
 import org.simantics.sysdyn.representation.expressions.ConstantExpression;\r
-import org.simantics.sysdyn.representation.expressions.InputExpression;\r
 import org.simantics.sysdyn.representation.expressions.LookupExpression;\r
 import org.simantics.sysdyn.representation.expressions.NormalExpression;\r
 import org.simantics.sysdyn.representation.expressions.ParameterExpression;\r
@@ -35,9 +34,9 @@ public class SysdynSchema extends SimpleSchema {
             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, Input.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, ModuleType.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, NormalExpression.class));\r
-            addLinkType(MappingSchemas.fromAnnotations(g, InputExpression.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, ParameterExpression.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, StockExpression.class));\r
             addLinkType(MappingSchemas.fromAnnotations(g, ConstantExpression.class));\r
index d4d8dbeec774f775069a456f470c062365b220f7..5773fc4773d3826990d76b77a355085e1d7640d8 100644 (file)
@@ -15,7 +15,7 @@ import org.simantics.objmap.annotations.GraphType;
 import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/Valve")\r
-public class Valve extends Variable {\r
+public class Valve extends IndependentVariable {\r
     @Override\r
     public void accept(IElementVisitorVoid v) {\r
         v.visit(this);\r
index e18bd33e611e9ff0aace67320712ab4ca6884f90..c77814ecba5207c05f33516e87a46fb260c53479 100644 (file)
@@ -1,45 +1,26 @@
-/*******************************************************************************\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.representation;\r
 \r
 import org.simantics.objmap.annotations.RelatedElement;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.expressions.IExpression;\r
 \r
 public abstract class Variable implements IElement {\r
-    @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
-    protected String name;\r
+    \r
     @RelatedValue("http://www.simantics.org/Layer0-1.0/HasType")\r
     protected String type;\r
-    @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasExpression")\r
-    protected IExpression expression;\r
+    @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+    protected String name;\r
     @RelatedElement("http://www.simantics.org/Layer0-1.0/PartOf")\r
     protected Configuration configuration;\r
 \r
-    \r
-\r
     public String getName() {\r
         return this.name;\r
     }\r
-\r
-    public String getType() {\r
-        return this.type;\r
-    }\r
-    \r
-    public IExpression getExpression() {\r
-        return this.expression;\r
-    }\r
     \r
     public Configuration getParentConfiguration() {\r
         return this.configuration;\r
     }\r
+\r
+    public String getType() {\r
+        return this.type;\r
+    }\r
 }\r
index cb845067e7457cafd9cf3f798e517b2e6fa32105..1491a72a910c6ca2fd994f037c293b14f79ebc8f 100644 (file)
@@ -13,7 +13,7 @@ package org.simantics.sysdyn.representation.expressions;
 \r
 import org.simantics.objmap.annotations.GraphType;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/ConstantExpression")\r
 public class ConstantExpression extends Expression {\r
@@ -22,7 +22,7 @@ public class ConstantExpression extends Expression {
     private String equation;\r
 \r
     @Override\r
-    public String getDeclaration(Variable variable) {\r
+    public String getDeclaration(IndependentVariable variable) {\r
         StringBuilder b = new StringBuilder();\r
         b.append("    constant " + variable.getType() + " " + variable.getName());\r
         b.append(" = " + equation + ";\n");\r
index 887438cfea57c8cf4d0362dbdb8d3bd24fc46930..c8d77e34ca0bb29daa899edf453c4fb09e70a183 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.representation.expressions;\r
 \r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 \r
 public abstract class Expression implements IExpression {\r
         \r
     @Override\r
-    public String getDeclaration(Variable variable) {\r
+    public String getDeclaration(IndependentVariable variable) {\r
         return null;\r
     }\r
 \r
     @Override\r
-    public String getEquation(Variable variable) {\r
+    public String getEquation(IndependentVariable variable) {\r
         return null;\r
     }\r
 \r
     @Override\r
-    public String getInitialEquation(Variable variable) {\r
+    public String getInitialEquation(IndependentVariable variable) {\r
         return null;\r
     }\r
 \r
index 1481f4b4869b74899a65ce1f784770fbbdab3626..0bf75a77ff7fe11a3123529d9bcbd6e06ec1118b 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.representation.expressions;\r
 \r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 \r
 public interface IExpression {\r
 \r
-    String getDeclaration(Variable variable);\r
-    String getInitialEquation(Variable variable);\r
-    String getEquation(Variable variable);\r
+    String getDeclaration(IndependentVariable variable);\r
+    String getInitialEquation(IndependentVariable variable);\r
+    String getEquation(IndependentVariable variable);\r
 \r
 }\r
index e08a459434de4d7b2c9bfcc44179f962adf9aa91..fa83da50ecc66b6e7d1f93e41aa7b93fb9ee056e 100644 (file)
@@ -13,7 +13,7 @@ package org.simantics.sysdyn.representation.expressions;
 \r
 import org.simantics.objmap.annotations.GraphType;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/NormalExpression")\r
 public class NormalExpression extends Expression {\r
@@ -22,12 +22,12 @@ public class NormalExpression extends Expression {
     private String equation;\r
 \r
     @Override\r
-    public String getDeclaration(Variable variable) {\r
+    public String getDeclaration(IndependentVariable variable) {\r
         return "    " + variable.getType() + " " + variable.getName() + ";\n";\r
     }\r
 \r
     @Override\r
-    public String getEquation(Variable variable) {\r
+    public String getEquation(IndependentVariable variable) {\r
         return "    " + variable.getName() + " = " + equation + ";\n";\r
     }\r
 \r
index cb11e66131caedb6a355a7d426685030ff8590ec..6a92d4c136ff9e0d11a334dc448ab6174ef83056 100644 (file)
@@ -13,7 +13,7 @@ package org.simantics.sysdyn.representation.expressions;
 \r
 import org.simantics.objmap.annotations.GraphType;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/ParameterExpression")\r
 public class ParameterExpression extends Expression {\r
@@ -22,7 +22,7 @@ public class ParameterExpression extends Expression {
     private String equation;\r
     \r
     @Override\r
-    public String getDeclaration(Variable variable) {\r
+    public String getDeclaration(IndependentVariable variable) {\r
         StringBuilder b = new StringBuilder();\r
         b.append("    parameter " + variable.getType() + " " + variable.getName());\r
         b.append(" = " + equation + ";\n");\r
index 20bf189b8ebf46fd34fd2a02b9545c9be7a8e8b5..afcccc5694e635f69ba55ae63fb51e104cfb4ba9 100644 (file)
@@ -14,7 +14,7 @@ package org.simantics.sysdyn.representation.expressions;
 import org.simantics.objmap.annotations.GraphType;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
 import org.simantics.sysdyn.representation.Stock;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/StockExpression")\r
 public class StockExpression extends Expression {\r
@@ -23,7 +23,7 @@ public class StockExpression extends Expression {
     private String initialEquation;\r
 \r
     @Override\r
-    public String getDeclaration(Variable variable) {\r
+    public String getDeclaration(IndependentVariable variable) {\r
         Double value = null;\r
         try {\r
             value = Double.parseDouble(initialEquation);\r
@@ -39,21 +39,21 @@ public class StockExpression extends Expression {
     }\r
 \r
     @Override\r
-    public String getEquation(Variable variable) {\r
+    public String getEquation(IndependentVariable variable) {\r
         StringBuilder b = new StringBuilder();\r
         b.append("    der(")\r
         .append(variable.getName())\r
         .append(") =");\r
-        for(Variable flow : ((Stock)variable).incomingFlows)\r
+        for(IndependentVariable flow : ((Stock)variable).incomingFlows)\r
             b.append("\n        + ").append(flow.getName());\r
-        for(Variable flow : ((Stock)variable).outgoingFlows)\r
+        for(IndependentVariable flow : ((Stock)variable).outgoingFlows)\r
             b.append("\n        - ").append(flow.getName());\r
         b.append(";\n");\r
         return b.toString();\r
     }\r
 \r
     @Override\r
-    public String getInitialEquation(Variable variable) {\r
+    public String getInitialEquation(IndependentVariable variable) {\r
         Double value = null;\r
         try {\r
             value = Double.parseDouble(initialEquation);\r
index 81eb5be6699facf4fa08907e690f51013abd6ee5..017a11bf478daf9e2cc149f56bd23fc236fcb603 100644 (file)
@@ -13,7 +13,7 @@ package org.simantics.sysdyn.representation.expressions;
 \r
 import org.simantics.objmap.annotations.GraphType;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
 \r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/WithLookupExpression")\r
@@ -25,12 +25,12 @@ public class WithLookupExpression extends Expression {
     private String equation;\r
 \r
     @Override\r
-    public String getDeclaration(Variable variable) {\r
+    public String getDeclaration(IndependentVariable variable) {\r
         return "    " + variable.getType() + " " + variable.getName() + ";\n";\r
     }\r
 \r
     @Override\r
-    public String getEquation(Variable variable) {\r
+    public String getEquation(IndependentVariable variable) {\r
         return \r
         "    " + variable.getName() + " = Interpolate(table = " + lookupTable + ", xp = " + equation + ");\n";\r
     }\r
index b5f372251fb005d07f0895d03f6988c385d498c0..fc6168de6e5278cac8adf0838574e5d1e82cd2f5 100644 (file)
@@ -16,6 +16,7 @@ import org.simantics.sysdyn.representation.Cloud;
 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.Input;\r
 import org.simantics.sysdyn.representation.Module;\r
 import org.simantics.sysdyn.representation.Stock;\r
 import org.simantics.sysdyn.representation.Valve;\r
@@ -38,6 +39,10 @@ public class ElementVisitorVoidAdapter implements IElementVisitorVoid {
     public void visit(Cloud cloud) {\r
     }\r
 \r
+    @Override\r
+    public void visit(Input input) {\r
+    }\r
+\r
     @Override\r
     public void visit(Dependency dependency) {\r
     }\r
index a80acc0dcf4e13ba52fb5fe1bd2de899f59d43f8..0f1f2e141dcc027485cc1fa0920293fd85460317 100644 (file)
@@ -16,6 +16,7 @@ import org.simantics.sysdyn.representation.Cloud;
 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.Input;\r
 import org.simantics.sysdyn.representation.Module;\r
 import org.simantics.sysdyn.representation.Stock;\r
 import org.simantics.sysdyn.representation.Valve;\r
@@ -26,6 +27,7 @@ public interface IElementVisitorVoid {
     void visit(Stock stock);\r
     void visit(Valve valve);\r
     void visit(Cloud cloud);\r
+    void visit(Input input);\r
     void visit(Dependency dependency);\r
     void visit(Flow flow);   \r
     void visit(Module module);\r
index 863918a305143ae39fad5b9b59d0a78500ea1218..ca34717e306a6b55cffaea4c33b5737e4dde4b43 100644 (file)
@@ -128,6 +128,7 @@ DefaultRealization <T L0.Realization
 ######################################################################\r
 \r
 Variable <T ST.Component    \r
+    [L0.HasType card "1"]\r
     [HasX card "1"]\r
     [HasY card "1"]\r
     \r
@@ -152,7 +153,6 @@ HasRangeStep <R L0.HasProperty
     L0.HasRange L0.Double  \r
 \r
 IndependentVariable <T Variable\r
-    [L0.HasType card "1"]\r
     [HasUnit card "0..1"]\r
     [HasExpression card "0..1"]    \r
     [HasRangeStart card "0..1"]\r
@@ -177,6 +177,17 @@ Stock <T IndependentVariable
 \r
 Cloud <T Variable\r
 \r
+Input <T Variable\r
+  [HasDefaultInputValue card "0..1"]\r
+  [L0.HasDescription card "0..1"]\r
+  [HasUnit card "0..1"]  \r
+  L0.Asserts _ : L0.Assertion\r
+    L0.HasPredicate HasDefaultInputValue\r
+    L0.HasObject "0" : L0.Double\r
+  L0.Asserts _ : L0.Assertion\r
+    L0.HasPredicate L0.HasType\r
+    L0.HasObject "Real" : L0.String\r
+\r
 ######################################################################\r
 # Modules\r
 ######################################################################\r
@@ -226,8 +237,8 @@ Flow <T ST.Connection
     [HasTail card "1"]\r
 \r
 RefersTo <R L0.IsRelatedTo : L0.FunctionalRelation\r
-    L0.HasDomain [IndependentVariable]\r
-    L0.HasRange [IndependentVariable]\r
+    L0.HasDomain [Variable]\r
+    L0.HasRange [Variable]\r
 \r
 \r
 ######################################################################\r
@@ -262,10 +273,7 @@ NormalExpression <T Expression
 \r
 ParameterExpression <T Expression\r
     [HasEquation card "1"]   \r
-\r
-InputExpression <T Expression\r
-    [HasEquation card "1"]   \r
-\r
+    \r
 ConstantExpression <T Expression\r
     [HasEquation card "1"]   \r
 \r
@@ -286,6 +294,8 @@ WithLookupExpression <T Expression
     [HasMinY card "1"]\r
     [HasMaxY card "1"]\r
 \r
+HasDefaultInputValue <R L0.HasProperty\r
+    L0.HasRange L0.Double\r
 \r
 ######################################################################\r
 # Experiments\r
@@ -414,6 +424,21 @@ CloudSymbol <T DIA.FontProvider <T DIA.ColorProvider
         terminal(CloudSymbol, IsHeadOfTerminal)\r
       _ : SysdynTerminal\r
         terminal(CloudSymbol, IsTailOfTerminal)\r
+        \r
+######################################################################\r
+Input\r
+  def()\r
+  connection(IsTailOf)\r
+  connection(IsHeadOf)\r
+\r
+InputSymbol <T DIA.FontProvider <T DIA.ColorProvider\r
+  defSymbol("Input", Input)\r
+  L0.IsDependencyOf BasicSymbolLibrary\r
+  ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+      _ : SysdynTerminal\r
+        terminal(InputSymbol, IsHeadOfTerminal)\r
+      _ : SysdynTerminal\r
+        terminal(InputSymbol, IsTailOfTerminal)        \r
 \r
 ######################################################################\r
 # Diagram connection types\r
@@ -648,16 +673,16 @@ RootConfigurationDiagram : ConfigurationDiagram <R L0.HasNext
     SalesElement : AuxiliarySymbol\r
         MOD.ElementToComponent Sales\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 92.0, 102.0" : G2D.Transform\r
-    WidgetsPerPersonInputElement : AuxiliarySymbol\r
+    WidgetsPerPersonInputElement : InputSymbol\r
         MOD.ElementToComponent WidgetsPerPersonInput\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 61.0, 90.0" : G2D.Transform\r
-    NewCustomersInputElement : AuxiliarySymbol\r
+    NewCustomersInputElement : InputSymbol\r
         MOD.ElementToComponent NewCustomersInput\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 91.0, 113.0" : G2D.Transform\r
-    WordOfMouthDemandInputElement : AuxiliarySymbol\r
+    WordOfMouthDemandInputElement : InputSymbol\r
         MOD.ElementToComponent WordOfMouthDemandInput\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 49.0, 98.0" : G2D.Transform\r
-    CapacityInputElement : AuxiliarySymbol\r
+    CapacityInputElement : InputSymbol\r
         MOD.ElementToComponent CapacityInput\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 136.0, 90.0" : G2D.Transform\r
     _ : FlowConnection\r
@@ -732,18 +757,14 @@ RootConfiguration @ "RootConfiguration" : Configuration
     DummyCloud : Cloud\r
       tag(MOD.Mapped)\r
     ### Input variables\r
-    WidgetsPerPersonInput @ "WidgettejaHenkilolle" : Auxiliary\r
+    WidgetsPerPersonInput @ "WidgettejaHenkilolle" : Input\r
       tag(MOD.Mapped)\r
-      HasExpression _ : InputExpression\r
-    NewCustomersInput @ "UusiaAsiakkaita" : Auxiliary\r
+    NewCustomersInput @ "UusiaAsiakkaita" : Input\r
       tag(MOD.Mapped)\r
-      HasExpression _ : InputExpression\r
-    WordOfMouthDemandInput @ "PuskaradioKysynta" : Auxiliary\r
+    WordOfMouthDemandInput @ "PuskaradioKysynta" : Input\r
       tag(MOD.Mapped)\r
-      HasExpression _ : InputExpression\r
-    CapacityInput @ "KapasiteettiInput" : Auxiliary\r
+    CapacityInput @ "KapasiteettiInput" : Input\r
       tag(MOD.Mapped)\r
-      HasExpression _ : InputExpression\r
 \r
 %define conf_dep($v1, $v2)\r
     $subject\r
@@ -839,9 +860,8 @@ CapacityModuleConfiguration @ "Kapasiteettimoduulikonfiguraatio" : Configuration
         HasEquation "Kapasiteetti/Kapasiteettielama" : L0.String     \r
                    \r
     ### Input variables\r
-    WordOfMouthDemandInput2 @ "PuskaradioKysynta" : Auxiliary\r
-      HasExpression _ : InputExpression\r
-      #tag(IsInput)\r
+    WordOfMouthDemandInput2 @ "PuskaradioKysynta" : Input\r
+      tag(IsInput)\r
 \r
     ### Dependencies    \r
     Flow3 : Flow\r
@@ -969,7 +989,7 @@ CapacityModuleConfigurationDiagram : ConfigurationDiagram <R L0.HasNext
     WidgetsPerPersonOutputElement : AuxiliarySymbol\r
         MOD.ElementToComponent WidgetsPerPersonOutput\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 130.0, 150.0" : G2D.Transform    \r
-    WordOfMouthDemandInput2Element : AuxiliarySymbol\r
+    WordOfMouthDemandInput2Element : InputSymbol\r
         MOD.ElementToComponent WordOfMouthDemandInput2\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 150.0" : G2D.Transform\r
     _ : DependencyConnection\r
@@ -1050,11 +1070,9 @@ CustomerModuleConfiguration @ "Asiakasmoduulikonfiguraatio" : Configuration
         HasEquation " min({Puskaradiokysynta, Kapasiteetti/WidgettejaHenkilolle})" : L0.String    \r
       tag(IsOutput)\r
     ### Input variables\r
-    CapacityInput2 @ "Kapasiteetti" : Auxiliary\r
-      HasExpression _ : InputExpression\r
+    CapacityInput2 @ "Kapasiteetti" : Input\r
       tag(IsInput)\r
-    WidgetsPerPersonInput2 @ "WidgettejaHenkilolle" : Auxiliary\r
-      HasExpression _ : InputExpression\r
+    WidgetsPerPersonInput2 @ "WidgettejaHenkilolle" : Input\r
       tag(IsInput)\r
       \r
     ### Dependencies    \r
@@ -1157,10 +1175,10 @@ CustomerModuleConfigurationDiagram : ConfigurationDiagram <R L0.HasNext
     NewCustomersElement : ValveSymbol\r
         MOD.ElementToComponent NewCustomers\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 90.0" : G2D.Transform\r
-    CapacityInput2Element : AuxiliarySymbol\r
+    CapacityInput2Element : InputSymbol\r
         MOD.ElementToComponent CapacityInput2\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 90.0, 105.0" : G2D.Transform\r
-    WidgetsPerPersonInput2Element : AuxiliarySymbol\r
+    WidgetsPerPersonInput2Element : InputSymbol\r
         MOD.ElementToComponent WidgetsPerPersonInput2\r
         DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 130.0, 110.0" : G2D.Transform\r
     \r