]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Treat variables with pre() and delay() functions as continuous variables instead...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 8 Feb 2013 12:38:33 +0000 (12:38 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 8 Feb 2013 12:38:33 +0000 (12:38 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@26742 ac1ea38d-2e2b-0410-8846-a27921b304fc

org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Variability.java

index dda7cbd41b818d645ae95c3f4381fded08a08770..c5d0a34015b43f273f7d83f2f551737f3250a904 100644 (file)
@@ -13,7 +13,9 @@ package org.simantics.sysdyn.representation;
 \r
 import java.io.StringReader;\r
 import java.util.ArrayList;\r
+import java.util.Arrays;\r
 import java.util.HashMap;\r
+import java.util.List;\r
 import java.util.Set;\r
 \r
 import org.simantics.sysdyn.expressionParser.ExpressionParser;\r
@@ -33,6 +35,12 @@ public enum Variability {
     PARAMETER("parameter"),\r
     CONSTANT("constant"),\r
     CONTINUOUS("");\r
+    \r
+    \r
+    private static List<String> timeDependentFunctions = Arrays.asList(\r
+        "pre",\r
+        "delay"\r
+    );\r
 \r
     private String text;\r
 \r
@@ -256,6 +264,15 @@ public enum Variability {
                                references.remove(t.image);\r
                        }\r
                 }\r
+                \r
+                // Check used functions\r
+                for(String function : parser.getFunctionCallReferences().keySet()) {\r
+                    if(functions.containsKey(function) && functions.get(function).hasTimeReference())\r
+                        return Variability.CONTINUOUS;\r
+                    else if (timeDependentFunctions.contains(function)) {\r
+                        return Variability.CONTINUOUS;\r
+                    }\r
+                }\r
 \r
                 // Go through each reference\r
                 for(String reference : references) {\r
@@ -264,11 +281,6 @@ public enum Variability {
                     }\r
                 }\r
 \r
-                for(String function : parser.getFunctionCallReferences().keySet()) {\r
-                    if(functions.containsKey(function) && functions.get(function).hasTimeReference())\r
-                        return Variability.CONTINUOUS;\r
-                }\r
-\r
                 // All found variables were sheets or non-continuous\r
                 return Variability.PARAMETER;\r
             }\r