]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
(refs #5538) Initial equations are evaluated during experiment run in Simupedia
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 9 Dec 2014 09:49:59 +0000 (09:49 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Tue, 9 Dec 2014 09:49:59 +0000 (09:49 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@30665 ac1ea38d-2e2b-0410-8846-a27921b304fc

fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Solver.java
fi.semantum.sysdyn.solver/src/fi/semantum/sysdyn/solver/Variable.java

index 591ba337d71ea43b2175a978608a5a645671218d..fd5e12458b2a1c7baabc5e68e427f2157144aa8b 100644 (file)
@@ -252,14 +252,14 @@ public class Solver {
 //                                     Object value = assignments[i].expression.evaluate(env);\r
 //                                     assignments[i].target.assign(env, assignments[i].subscripts, value);\r
                                }\r
-                               for(Assignment ass : model.initials) {\r
-                                       if(ass.isConstant) continue;\r
-                                       ass.assign(env);\r
-//                                     Object value = ass.expression.evaluate(env);\r
-//                                     ass.target.assign(env, ass.subscripts, value);\r
-                               }\r
-       \r
+\r
                                if (!started) {\r
+\r
+                                       for(Assignment ass : model.initials) {\r
+                                               if(ass.isConstant) continue;\r
+                                               ass.assign(env);\r
+                                       }\r
+       \r
                                        for(VariableDeclaration vd : model.variables) {\r
                                                try {\r
                                                        for(Argument arg : vd.modification.args) {\r
@@ -300,6 +300,8 @@ public class Solver {
        \r
        public void step() {\r
                \r
+               System.err.println("step @ " + getTime());\r
+               \r
 //             printEnvironment();\r
 //             \r
 //             new Exception().printStackTrace();\r
index 581ccecb8815a105be407b8ec3826b86330d6658..abc6700e159a952400c951b4dc5189735c7f12d0 100644 (file)
@@ -20,6 +20,7 @@ public class Variable implements IExpression {
        public VariableBase base;\r
        public IExpression[] subscripts = null;\r
        public int line = -1;\r
+       public VariableDeclaration decl = null;\r
        \r
        public Variable(IFrame frame, String name, IExpression[] subscripts, int line) {\r
                base = frame.getBase(name);\r
@@ -43,7 +44,20 @@ public class Variable implements IExpression {
                this.base = base;\r
                this.subscripts = subscripts;\r
        }\r
-       \r
+\r
+       public VariableDeclaration getDeclaration(Model model) {\r
+               if(decl == null) {\r
+                       for(VariableDeclaration d : model.variables) {\r
+                               if(d.variable.base.name.equals(base.name)) {\r
+                                       decl = d;\r
+                                       break;\r
+                               }\r
+                       }\r
+               }\r
+               return decl;\r
+               \r
+       }\r
+\r
        @Override\r
        public String toString() {\r
                // updated to print the double value as an integer value in subscripts\r