]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Merged trunk@30110, @30126, @30139, @30147, @30190, @30206, @30230, @30233 to branche...
authorjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 16 Oct 2014 08:06:44 +0000 (08:06 +0000)
committerjsimomaa <jsimomaa@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 16 Oct 2014 08:06:44 +0000 (08:06 +0000)
refs #5178
refs #5197
refs #5227
refs #5261
refs #5278
refs #5275

git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/branches/1.8@30424 ac1ea38d-2e2b-0410-8846-a27921b304fc

29 files changed:
org.simantics.sysdyn/META-INF/MANIFEST.MF
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/IndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableBase.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/ValueIndexVariableI.java
org.simantics.sysdyn/src/org/simantics/sysdyn/adapter/VariableRVIUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.java
org.simantics.sysdyn/src/org/simantics/sysdyn/expressionParser/ExpressionParser.jj
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/OldSysdynExperiment.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynConsole.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiments.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentInternal.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/IModelParser.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/MdlParser.java
org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/mdl/MdlVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/mdl/SubscriptVariable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/model/Model.java
org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java
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/Variable.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/DelayExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/Expression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/utils/UnitUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/solver/SolverSettings.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/DocumentationUtils.java
org.simantics.sysdyn/src/org/simantics/sysdyn/utils/imports/ImportUtils.java

index 886074f727cd706c01f152204aad26b8c22fe94f..66b45852df55829373d27974e24738bcfb9f8a64 100644 (file)
@@ -27,7 +27,6 @@ Require-Bundle: org.simantics.objmap;bundle-version="0.1.0",
  org.eclipse.jface.text;bundle-version="3.6.1",
  org.simantics.spreadsheet.ontology;bundle-version="1.2.0",
  org.simantics.fmu;bundle-version="1.0.0",
- org.simantics.fmu.me.win32;bundle-version="1.0.0",
  org.simantics.issues;bundle-version="1.1.0",
  org.simantics.issues.common;bundle-version="1.1.0",
  org.simantics.jfreechart;bundle-version="1.0.0",
index 606b9f332c84469adf3660c18d7b8c36c3d79f30..bf71e39fd2d4e3fd5e4bc5154a52225323e73d90 100644 (file)
@@ -38,6 +38,7 @@ public abstract class IndexVariable<T> extends AbstractPropertyVariable {
        protected HashMap<String, String> rvis;\r
        protected String indexes;\r
        protected VariableSubscriptionManager subscriptionManager;\r
+       protected Pair<ArrayList<String>,ArrayList<String>> variableNameArrays;\r
        \r
        public IndexVariable(ReadGraph graph, Variable parent, String indexes) throws DatabaseException {\r
                this.parent = parent;\r
@@ -164,68 +165,83 @@ public abstract class IndexVariable<T> extends AbstractPropertyVariable {
        }\r
        \r
        protected void ensureInformationAvailable(ReadGraph graph) throws DatabaseException {\r
-               SimulationResource SIMU = SimulationResource.getInstance(graph);\r
-               ModelingResources MOD = ModelingResources.getInstance(graph);\r
                \r
         if(model == null) {\r
+               SimulationResource SIMU = SimulationResource.getInstance(graph);\r
             Resource modelResource = Variables.getModel(graph, parent);\r
             Resource configuration = graph.getPossibleObject(modelResource, SIMU.HasConfiguration);\r
             model = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, configuration);\r
         }\r
-        \r
-        Variable var = parent.getParent(graph);\r
-        Resource represents = var.getRepresents(graph);\r
-        \r
-        Resource activeRun = null;\r
-        if(represents != null) {\r
-            do {\r
-                if(graph.isInstanceOf(represents, SIMU.Run)) {\r
-                    activeRun = represents;\r
-                    break;\r
-                }\r
-                var = var.getParent(graph);\r
-                represents = var.getRepresents(graph);\r
-            } while(represents != null && !graph.isInstanceOf(represents, MOD.StructuralModel));\r
-        }\r
 \r
-        IProject project = Simantics.peekProject();\r
-        if(activeRun != null && project != null) {\r
-            IExperimentManager expMan = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
-               IExperiment e = expMan.getExperiment(NameUtils.getSafeName(graph, activeRun));\r
-               if(e instanceof SysdynExperiment)\r
-                       this.experiment = (SysdynExperiment)e;\r
+        if(this.experiment == null || this.subscriptionManager == null) {\r
+               SimulationResource SIMU = SimulationResource.getInstance(graph);\r
+               ModelingResources MOD = ModelingResources.getInstance(graph);\r
+               Variable var = parent.getParent(graph);\r
+               Resource represents = var.getRepresents(graph);\r
+               Resource activeRun = null;\r
+               if(represents != null) {\r
+                       do {\r
+                               if(graph.isInstanceOf(represents, SIMU.Run)) {\r
+                                       activeRun = represents;\r
+                                       break;\r
+                               }\r
+                               var = var.getParent(graph);\r
+                               represents = var.getRepresents(graph);\r
+                       } while(represents != null && !graph.isInstanceOf(represents, MOD.StructuralModel));\r
+               }\r
+\r
+               IProject project = Simantics.peekProject();\r
+               if(activeRun != null && project != null) {\r
+                       IExperimentManager expMan = project.getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+                       IExperiment e = expMan.getExperiment(NameUtils.getSafeName(graph, activeRun));\r
+                       if(e instanceof SysdynExperiment)\r
+                               this.experiment = (SysdynExperiment)e;\r
+               }\r
+               this.subscriptionManager = getSubscriptionManager();\r
         }\r
         \r
-        this.subscriptionManager = getSubscriptionManager();\r
-               rvi =  Variables.getPossibleRVI(graph, this);\r
+        if(rvi == null)\r
+               rvi =  Variables.getPossibleRVI(graph, this);\r
+        \r
                if(rvi != null)\r
-                   rvis = VariableRVIUtils.getActiveRVIs(graph, parent.getParent(graph));      \r
+                   rvis = graph.syncRequest(new VariableRVIUtils.GetActiveRVIs(parent.getParent(graph))); //VariableRVIUtils.getActiveRVIs(graph, parent.getParent(graph));\r
+               \r
        }\r
        \r
        private Pair<ArrayList<String>,ArrayList<String>> getVariableNameArrays() {\r
-               Pair<ArrayList<String>,ArrayList<String>> result = new Pair<ArrayList<String>,ArrayList<String>>(new ArrayList<String>(), new ArrayList<String>());\r
-               if(rvi == null || rvis == null)\r
-                   return result;\r
                \r
-        if(rvi.indexOf('#') > 0)\r
-               rvi = rvi.substring(0, rvi.indexOf('#'));\r
-        \r
-        String test = rvi;\r
-        if(indexes != null && !indexes.isEmpty()) {\r
-               String regexIndexes = indexes.trim().replaceAll(":", "[a-zA-Z0-9_]*"); // Why was there was ".replace('.', ',')" ? - Removed by Teemu 2.9.2012\r
-               test = rvi + "\\[" + regexIndexes + "\\]";\r
-        } else {\r
-               test = rvi + "(\\[.*\\])?";\r
-        }\r
-        for(String k : rvis.keySet()) {\r
-               String value = rvis.get(k);\r
-               if(k.matches(test) || value.matches(test)) {\r
-                       result.first.add(k.substring(1).replace("/", ".").replace("%20", "_"));\r
-                       result.second.add(value.substring(1).replace("/", ".").replace("%20", " "));\r
-               }\r
-        }\r
-        \r
-        return result;\r
+               if(variableNameArrays == null) {\r
+               \r
+                       Pair<ArrayList<String>,ArrayList<String>> result = new Pair<ArrayList<String>,ArrayList<String>>(new ArrayList<String>(), new ArrayList<String>());\r
+                       if(rvi != null && rvis != null) {\r
+                       \r
+                       if(rvi.indexOf('#') > 0)\r
+                               rvi = rvi.substring(0, rvi.indexOf('#'));\r
+                       \r
+                       String test = rvi;\r
+                       if(indexes != null && !indexes.isEmpty()) {\r
+                               String regexIndexes = indexes.trim().replaceAll(":", "[a-zA-Z0-9_]*"); // Why was there was ".replace('.', ',')" ? - Removed by Teemu 2.9.2012\r
+                               test = rvi + "\\[" + regexIndexes + "\\]";\r
+                       } else {\r
+                               test = rvi + "(\\[.*\\])?";\r
+                       }\r
+                       for(String k : rvis.keySet()) {\r
+                               String value = rvis.get(k);\r
+                               if(k.matches(test) || value.matches(test)) {\r
+                                       result.first.add(k.substring(1).replace("/", ".").replace("%20", "_"));\r
+                                       result.second.add(value.substring(1).replace("/", ".").replace("%20", " "));\r
+                               }\r
+                       }\r
+                       \r
+                       variableNameArrays = result;\r
+\r
+                       }\r
+               \r
+               }\r
+               \r
+               if(variableNameArrays == null) return new Pair<ArrayList<String>,ArrayList<String>>(new ArrayList<String>(), new ArrayList<String>());\r
+               \r
+               return variableNameArrays;\r
                \r
        }\r
        \r
index 6fb6f77d5b7c1c40f1dca6716a60cdc32337345f..e2ab2e44f46e6f65c7a4c960c2bd64b5a5e633c8 100644 (file)
@@ -1,5 +1,7 @@
 package org.simantics.sysdyn.adapter;\r
 \r
+import org.simantics.databoard.Datatypes;\r
+import org.simantics.databoard.type.Datatype;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
@@ -28,4 +30,13 @@ public class ValueIndexVariable extends ValueIndexVariableBase<Object> {
                }\r
        }\r
        \r
+       @Override\r
+       public Datatype getDatatype(ReadGraph graph) throws DatabaseException {\r
+               if (scalar) {\r
+                       return Datatypes.DOUBLE;\r
+               } else {\r
+                       return Datatypes.DOUBLE_ARRAY;\r
+               }\r
+       }\r
+       \r
 }\r
index 0b308f70ef7564691982be8baa8b147cfb46651e..cbb948bca58ae4c2417d3eb64388bd5f85bd0a51 100644 (file)
@@ -14,6 +14,7 @@ import org.simantics.simulation.experiment.ExperimentState;
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.manager.SysdynDataSet;\r
 import org.simantics.sysdyn.manager.SysdynGameExperimentBase;\r
+import org.simantics.sysdyn.manager.SysdynGameExperimentBase.Subscription;\r
 import org.simantics.sysdyn.manager.SysdynResult;\r
 import org.simantics.sysdyn.solver.ISolver;\r
 \r
@@ -22,31 +23,45 @@ abstract public class ValueIndexVariableBase<T> extends IndexVariable<T> {
        public ValueIndexVariableBase(ReadGraph graph, Variable parent, String indexes)\r
                        throws DatabaseException {\r
            super(graph, parent, indexes);\r
+           ensureInformationAvailable(graph);\r
+        if(experiment instanceof SysdynGameExperimentBase) {\r
+            s = ((SysdynGameExperimentBase) experiment).subscribe(getVariableNamesWithIndexNumbers());\r
+        }\r
        }\r
 \r
        public static double[] UNRESOLVED = new double[0];\r
        \r
+       public Subscription s;\r
+       \r
        public double[] getValueFull() {\r
+           \r
            if(experiment == null)\r
                return UNRESOLVED;\r
 \r
+        if(experiment instanceof SysdynGameExperimentBase) {\r
+            double[] arr = new double[s.indexes.length];\r
+            s.getValues(arr);\r
+            return arr;\r
+        }\r
+\r
+           \r
         Collection<SysdynResult> results = experiment.getActiveResults();\r
                ArrayList<String> variableNames = getVariableNamesWithIndexNumbers();\r
 \r
                double[] result = new double[variableNames.size()];\r
                for(int i = 0; i < variableNames.size(); i++) {\r
                    for(SysdynResult r : results) {            \r
-                       if(experiment instanceof SysdynGameExperimentBase) {\r
-                           Double d = ((SysdynGameExperimentBase)experiment).getCurrentValue(variableNames.get(i)); \r
-                           result[i] = d != null ? d : 0;\r
-                       } else {\r
+//                     if(experiment instanceof SysdynGameExperimentBase) {\r
+//                         Double d = ((SysdynGameExperimentBase)experiment).getCurrentValue(variableNames.get(i)); \r
+//                         result[i] = d != null ? d : 0;\r
+//                     } else {\r
                            SysdynDataSet ds = r.getDataSet(variableNames.get(i));\r
                            if(ds != null && ds.values != null && ds.values.length > 0) {\r
                                result[i] =  ds.values[ds.values.length-1];\r
                            } else {\r
                                return UNRESOLVED;\r
                            }\r
-                       }\r
+//                     }\r
                    }\r
                }\r
                return result;\r
index c414f3d6857ff34dba58c7ae6a96e2e6d7fe2a67..baed93ed56d375a65518807c479937a72444efe2 100644 (file)
@@ -2,7 +2,9 @@ package org.simantics.sysdyn.adapter;
 \r
 import java.util.Arrays;\r
 \r
+import org.simantics.databoard.Datatypes;\r
 import org.simantics.databoard.binding.Binding;\r
+import org.simantics.databoard.type.Datatype;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.exception.DatabaseException;\r
@@ -48,4 +50,9 @@ public class  ValueIndexVariableI extends ValueIndexVariableBase<Double> {
                return "$" + index;\r
        }\r
        \r
+       @Override\r
+       public Datatype getDatatype(ReadGraph graph) throws DatabaseException {\r
+               return Datatypes.DOUBLE;\r
+       }\r
+       \r
 }\r
index 0f24cc580059018bceec79914e3a727712a4f915..7b6a68bcd492a97c28f56770bd12aa1a71e8acb0 100644 (file)
@@ -22,6 +22,7 @@ import org.simantics.db.Resource;
 import org.simantics.db.common.request.ObjectsWithType;\r
 import org.simantics.db.common.utils.ListUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.request.VariableRead;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
 import org.simantics.layer0.Layer0;\r
@@ -158,30 +159,39 @@ public class VariableRVIUtils {
      * @throws DatabaseException\r
      */\r
     public static HashMap<String, String> getActiveRVIs(ReadGraph graph, Variable variable) throws DatabaseException {\r
-        HashMap<String, String> rvis = new LinkedHashMap<String, String>();\r
-\r
-        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        return graph.syncRequest(new GetActiveRVIs(variable));\r
+    }\r
+    \r
+    public static class GetActiveRVIs extends VariableRead<HashMap<String, String>> {\r
 \r
-        String rvi = Variables.getRVI(graph, variable);\r
+        public GetActiveRVIs(Variable variable) {\r
+            super(variable);\r
+        }\r
 \r
-        Resource r = variable.getRepresents(graph);\r
+        @Override\r
+        public HashMap<String, String> perform(ReadGraph graph) throws DatabaseException {\r
+            HashMap<String, String> rvis = new LinkedHashMap<String, String>();\r
 \r
-        Resource arrayIndexes = graph.getPossibleObject(r, sr.Variable_arrayIndexesList);\r
-        if(arrayIndexes == null) {\r
-            // If variable is single-dimensional, use the same rvi\r
-            rvis.put(rvi, rvi);\r
-        } else {\r
-            // If variable is multidimensional, get all indexes that are active and add them to rvis-map\r
-            List<Resource> arrayIndexList = ListUtils.toList(graph, arrayIndexes);\r
-            resolveActiveArrayIndexes(graph, variable, arrayIndexList);\r
+            SysdynResource sr = SysdynResource.getInstance(graph);\r
+            String rvi = Variables.getRVI(graph, variable);\r
+            Resource r = variable.getRepresents(graph);\r
 \r
-            if(arrayIndexList.size() > 0)\r
-                traverseIndexes(graph, rvi, rvis, arrayIndexList);\r
-            else\r
+            Resource arrayIndexes = graph.getPossibleObject(r, sr.Variable_arrayIndexesList);\r
+            if(arrayIndexes == null) {\r
+                // If variable is single-dimensional, use the same rvi\r
                 rvis.put(rvi, rvi);\r
-        }\r
+            } else {\r
+                // If variable is multidimensional, get all indexes that are active and add them to rvis-map\r
+                List<Resource> arrayIndexList = ListUtils.toList(graph, arrayIndexes);\r
+                resolveActiveArrayIndexes(graph, variable, arrayIndexList);\r
 \r
-        return rvis;\r
+                if(arrayIndexList.size() > 0)\r
+                    traverseIndexes(graph, rvi, rvis, arrayIndexList);\r
+                else\r
+                    rvis.put(rvi, rvi);\r
+            }\r
+            return rvis;\r
+        }\r
     }\r
 \r
     \r
index 5b37fb688f6f1fe02ce782175e64f19f51362fff..88dd5eb53ec3943a0fcbd350efc3d05e688dbdf1 100644 (file)
@@ -598,6 +598,7 @@ public class ExpressionParser implements ExpressionParserConstants {
     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
     case 6:\r
     case 12:\r
+    case 26:\r
     case 31:\r
     case 33:\r
     case 35:\r
@@ -642,6 +643,7 @@ public class ExpressionParser implements ExpressionParserConstants {
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 6:\r
       case 12:\r
+      case 26:\r
       case 31:\r
       case 33:\r
       case 35:\r
@@ -657,7 +659,59 @@ public class ExpressionParser implements ExpressionParserConstants {
       case STRING:\r
       case UNSIGNED_INTEGER:\r
       case UNSIGNED_NUMBER:\r
-        expression();\r
+        switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+        case 6:\r
+        case 12:\r
+        case 31:\r
+        case 33:\r
+        case 35:\r
+        case 60:\r
+        case 62:\r
+        case 64:\r
+        case 76:\r
+        case 77:\r
+        case 78:\r
+        case 79:\r
+        case IDENT:\r
+        case QIDENT:\r
+        case STRING:\r
+        case UNSIGNED_INTEGER:\r
+        case UNSIGNED_NUMBER:\r
+          expression();\r
+          break;\r
+        case 26:\r
+          jj_consume_token(26);\r
+          name();\r
+          jj_consume_token(60);\r
+          switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+          case IDENT:\r
+          case QIDENT:\r
+            named_argument();\r
+            label_8:\r
+            while (true) {\r
+              switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
+              case 69:\r
+                ;\r
+                break;\r
+              default:\r
+                jj_la1[28] = jj_gen;\r
+                break label_8;\r
+              }\r
+              jj_consume_token(69);\r
+              named_argument();\r
+            }\r
+            break;\r
+          default:\r
+            jj_la1[29] = jj_gen;\r
+            ;\r
+          }\r
+          jj_consume_token(61);\r
+          break;\r
+        default:\r
+          jj_la1[30] = jj_gen;\r
+          jj_consume_token(-1);\r
+          throw new ParseException();\r
+        }\r
         switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
         case 21:\r
         case 69:\r
@@ -671,18 +725,18 @@ public class ExpressionParser implements ExpressionParserConstants {
             for_indices();\r
             break;\r
           default:\r
-            jj_la1[28] = jj_gen;\r
+            jj_la1[31] = jj_gen;\r
             jj_consume_token(-1);\r
             throw new ParseException();\r
           }\r
           break;\r
         default:\r
-          jj_la1[29] = jj_gen;\r
+          jj_la1[32] = jj_gen;\r
           ;\r
         }\r
         break;\r
       default:\r
-        jj_la1[30] = jj_gen;\r
+        jj_la1[33] = jj_gen;\r
         jj_consume_token(-1);\r
         throw new ParseException();\r
       }\r
@@ -691,15 +745,15 @@ public class ExpressionParser implements ExpressionParserConstants {
 \r
   final public void for_indices() throws ParseException {\r
     for_index();\r
-    label_8:\r
+    label_9:\r
     while (true) {\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 69:\r
         ;\r
         break;\r
       default:\r
-        jj_la1[31] = jj_gen;\r
-        break label_8;\r
+        jj_la1[34] = jj_gen;\r
+        break label_9;\r
       }\r
       jj_consume_token(69);\r
       for_index();\r
@@ -723,7 +777,7 @@ public class ExpressionParser implements ExpressionParserConstants {
                   forRanges.add(forRange);\r
       break;\r
     default:\r
-      jj_la1[32] = jj_gen;\r
+      jj_la1[35] = jj_gen;\r
       ;\r
     }\r
                 forIndex = false;\r
@@ -763,18 +817,18 @@ void named_arguments() : {
       expression();\r
       break;\r
     default:\r
-      jj_la1[33] = jj_gen;\r
+      jj_la1[36] = jj_gen;\r
       ;\r
     }\r
-    label_9:\r
+    label_10:\r
     while (true) {\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 69:\r
         ;\r
         break;\r
       default:\r
-        jj_la1[34] = jj_gen;\r
-        break label_9;\r
+        jj_la1[37] = jj_gen;\r
+        break label_10;\r
       }\r
       jj_consume_token(69);\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
@@ -798,7 +852,7 @@ void named_arguments() : {
         expression();\r
         break;\r
       default:\r
-        jj_la1[35] = jj_gen;\r
+        jj_la1[38] = jj_gen;\r
         ;\r
       }\r
     }\r
@@ -806,15 +860,15 @@ void named_arguments() : {
 \r
   final public void expression_list() throws ParseException {\r
     expression();\r
-    label_10:\r
+    label_11:\r
     while (true) {\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 69:\r
         ;\r
         break;\r
       default:\r
-        jj_la1[36] = jj_gen;\r
-        break label_10;\r
+        jj_la1[39] = jj_gen;\r
+        break label_11;\r
       }\r
       jj_consume_token(69);\r
       expression();\r
@@ -829,15 +883,15 @@ void named_arguments() : {
         currentRange = new ArrayList<Token>();\r
     jj_consume_token(64);\r
     subscript(currentRange);\r
-    label_11:\r
+    label_12:\r
     while (true) {\r
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
       case 69:\r
         ;\r
         break;\r
       default:\r
-        jj_la1[37] = jj_gen;\r
-        break label_11;\r
+        jj_la1[40] = jj_gen;\r
+        break label_12;\r
       }\r
       jj_consume_token(69);\r
       subscript(currentRange);\r
@@ -856,7 +910,7 @@ void named_arguments() : {
             currentRange.add(token);\r
       break;\r
     default:\r
-      jj_la1[40] = jj_gen;\r
+      jj_la1[43] = jj_gen;\r
       if (jj_2_3(2147483647)) {\r
         functionCall = null;\r
         name();\r
@@ -878,7 +932,7 @@ void named_arguments() : {
             rangeIndex(rangeToken, false, ":");\r
             break;\r
           default:\r
-            jj_la1[38] = jj_gen;\r
+            jj_la1[41] = jj_gen;\r
             ;\r
           }\r
             rangeToken.endColumn = token.endColumn;\r
@@ -889,15 +943,15 @@ void named_arguments() : {
           jj_consume_token(62);\r
             rangeToken.image = rangeToken.image + token.image;\r
           rangeIndex(rangeToken, true, ",");\r
-          label_12:\r
+          label_13:\r
           while (true) {\r
             switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {\r
             case 69:\r
               ;\r
               break;\r
             default:\r
-              jj_la1[39] = jj_gen;\r
-              break label_12;\r
+              jj_la1[42] = jj_gen;\r
+              break label_13;\r
             }\r
             jj_consume_token(69);\r
             rangeIndex(rangeToken, false, ",");\r
@@ -909,7 +963,7 @@ void named_arguments() : {
                 rangeToken.image = rangeToken.image + token.image;\r
           break;\r
         default:\r
-          jj_la1[41] = jj_gen;\r
+          jj_la1[44] = jj_gen;\r
           jj_consume_token(-1);\r
           throw new ParseException();\r
         }\r
@@ -932,7 +986,7 @@ void named_arguments() : {
                 rangeToken.image = rangeToken.image + identToken;\r
       break;\r
     default:\r
-      jj_la1[42] = jj_gen;\r
+      jj_la1[45] = jj_gen;\r
       jj_consume_token(-1);\r
       throw new ParseException();\r
     }\r
@@ -959,30 +1013,30 @@ void named_arguments() : {
     finally { jj_save(2, xla); }\r
   }\r
 \r
-  private boolean jj_3R_74() {\r
-    if (jj_scan_token(67)) return true;\r
-    if (jj_3R_73()) return true;\r
+  private boolean jj_3R_32() {\r
+    if (jj_scan_token(9)) return true;\r
+    if (jj_3R_31()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_35() {\r
-    if (jj_3R_39()) return true;\r
+  private boolean jj_3R_36() {\r
+    if (jj_3R_40()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_33() {\r
+  private boolean jj_3R_34() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_35()) jj_scanpos = xsp;\r
-    if (jj_3R_36()) return true;\r
+    if (jj_3R_36()) jj_scanpos = xsp;\r
+    if (jj_3R_37()) return true;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_37()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_38()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_38() {\r
+  private boolean jj_3R_39() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(70)) {\r
@@ -1004,397 +1058,445 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_16() {\r
-    if (jj_scan_token(66)) return true;\r
-    if (jj_3R_13()) return true;\r
+  private boolean jj_3R_27() {\r
+    if (jj_scan_token(67)) return true;\r
+    if (jj_3R_26()) return true;\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_30()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_26() {\r
-    if (jj_scan_token(67)) return true;\r
-    if (jj_3R_25()) return true;\r
+  private boolean jj_3R_29() {\r
+    if (jj_scan_token(22)) return true;\r
+    if (jj_3R_28()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_85() {\r
+    if (jj_scan_token(41)) return true;\r
+    if (jj_3R_18()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_33() {\r
+    if (jj_3R_34()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_29()) jj_scanpos = xsp;\r
+    if (jj_3R_35()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_79() {\r
-    if (jj_3R_15()) return true;\r
+  private boolean jj_3R_31() {\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_scan_token(12)) jj_scanpos = xsp;\r
+    if (jj_3R_33()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_28() {\r
-    if (jj_scan_token(22)) return true;\r
-    if (jj_3R_27()) return true;\r
+  private boolean jj_3R_82() {\r
+    if (jj_scan_token(69)) return true;\r
+    if (jj_3R_81()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_80() {\r
-    if (jj_scan_token(41)) return true;\r
-    if (jj_3R_17()) return true;\r
+  private boolean jj_3R_28() {\r
+    if (jj_3R_31()) return true;\r
+    Token xsp;\r
+    while (true) {\r
+      xsp = jj_scanpos;\r
+      if (jj_3R_32()) { jj_scanpos = xsp; break; }\r
+    }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_32() {\r
-    if (jj_3R_33()) return true;\r
+  private boolean jj_3R_65() {\r
+    if (jj_scan_token(26)) return true;\r
+    if (jj_3R_14()) return true;\r
+    if (jj_scan_token(60)) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_34()) jj_scanpos = xsp;\r
+    if (jj_3R_69()) jj_scanpos = xsp;\r
+    if (jj_scan_token(61)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_78() {\r
-    if (jj_scan_token(UNSIGNED_INTEGER)) return true;\r
+  private boolean jj_3R_58() {\r
+    if (jj_scan_token(66)) return true;\r
+    if (jj_3R_52()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_73() {\r
+  private boolean jj_3R_26() {\r
+    if (jj_3R_28()) return true;\r
     Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_78()) {\r
-    jj_scanpos = xsp;\r
-    if (jj_3R_79()) return true;\r
+    while (true) {\r
+      xsp = jj_scanpos;\r
+      if (jj_3R_29()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_30() {\r
+  private boolean jj_3R_81() {\r
+    if (jj_3R_16()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_scan_token(12)) jj_scanpos = xsp;\r
-    if (jj_3R_32()) return true;\r
+    if (jj_3R_85()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_13() {\r
-    if (jj_3R_15()) return true;\r
+  private boolean jj_3R_24() {\r
+    if (jj_3R_26()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_16()) jj_scanpos = xsp;\r
+    if (jj_3R_27()) jj_scanpos = xsp;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3_2() {\r
+    if (jj_3R_15()) return true;\r
     return false;\r
   }\r
 \r
   private boolean jj_3R_77() {\r
-    if (jj_scan_token(69)) return true;\r
-    if (jj_3R_76()) return true;\r
+    if (jj_3R_81()) return true;\r
+    Token xsp;\r
+    while (true) {\r
+      xsp = jj_scanpos;\r
+      if (jj_3R_82()) { jj_scanpos = xsp; break; }\r
+    }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_27() {\r
-    if (jj_3R_30()) return true;\r
+  private boolean jj_3R_22() {\r
+    if (jj_scan_token(31)) return true;\r
+    if (jj_3R_18()) return true;\r
+    if (jj_scan_token(28)) return true;\r
+    if (jj_3R_18()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_31()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_25()) { jj_scanpos = xsp; break; }\r
     }\r
+    if (jj_scan_token(15)) return true;\r
+    if (jj_3R_18()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_66() {\r
-    if (jj_scan_token(69)) return true;\r
-    if (jj_3R_54()) return true;\r
+  private boolean jj_3R_64() {\r
+    if (jj_3R_18()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_63() {\r
+  private boolean jj_3R_18() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_66()) {\r
+    if (jj_3R_21()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_67()) return true;\r
+    if (jj_3R_22()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_57() {\r
-    if (jj_scan_token(66)) return true;\r
-    if (jj_3R_51()) return true;\r
+  private boolean jj_3R_21() {\r
+    if (jj_3R_24()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_76() {\r
-    if (jj_3R_15()) return true;\r
+  private boolean jj_3R_61() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_80()) jj_scanpos = xsp;\r
+    if (jj_3R_64()) {\r
+    jj_scanpos = xsp;\r
+    if (jj_3R_65()) return true;\r
+    }\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_66()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_25() {\r
-    if (jj_3R_27()) return true;\r
+  private boolean jj_3R_55() {\r
     Token xsp;\r
-    while (true) {\r
-      xsp = jj_scanpos;\r
-      if (jj_3R_28()) { jj_scanpos = xsp; break; }\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_60()) {\r
+    jj_scanpos = xsp;\r
+    if (jj_3R_61()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3_2() {\r
-    if (jj_3R_14()) return true;\r
+  private boolean jj_3R_60() {\r
+    if (jj_3R_15()) return true;\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_63()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_23() {\r
-    if (jj_3R_25()) return true;\r
+  private boolean jj_3R_56() {\r
+    if (jj_3R_55()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_51() {\r
+    if (jj_scan_token(60)) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_26()) jj_scanpos = xsp;\r
+    if (jj_3R_56()) jj_scanpos = xsp;\r
+    if (jj_scan_token(61)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_19() {\r
-    if (jj_scan_token(QIDENT)) return true;\r
+  private boolean jj_3R_57() {\r
+    if (jj_3R_62()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_72() {\r
-    if (jj_3R_76()) return true;\r
-    Token xsp;\r
-    while (true) {\r
-      xsp = jj_scanpos;\r
-      if (jj_3R_77()) { jj_scanpos = xsp; break; }\r
-    }\r
+  private boolean jj_3R_80() {\r
+    if (jj_scan_token(69)) return true;\r
+    if (jj_3R_78()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_71() {\r
-    if (jj_scan_token(62)) return true;\r
-    if (jj_3R_73()) return true;\r
+  private boolean jj_3R_52() {\r
+    if (jj_3R_16()) return true;\r
     Token xsp;\r
-    while (true) {\r
-      xsp = jj_scanpos;\r
-      if (jj_3R_75()) { jj_scanpos = xsp; break; }\r
-    }\r
-    if (jj_scan_token(63)) return true;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_57()) jj_scanpos = xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_58()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_53() {\r
-    if (jj_scan_token(68)) return true;\r
-    if (jj_3R_52()) return true;\r
+  private boolean jj_3R_79() {\r
+    if (jj_scan_token(67)) return true;\r
+    if (jj_3R_78()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_21() {\r
-    if (jj_scan_token(31)) return true;\r
-    if (jj_3R_17()) return true;\r
-    if (jj_scan_token(28)) return true;\r
-    if (jj_3R_17()) return true;\r
-    Token xsp;\r
-    while (true) {\r
-      xsp = jj_scanpos;\r
-      if (jj_3R_24()) { jj_scanpos = xsp; break; }\r
-    }\r
-    if (jj_scan_token(15)) return true;\r
-    if (jj_3R_17()) return true;\r
+  private boolean jj_3R_17() {\r
+    if (jj_scan_token(66)) return true;\r
+    if (jj_3R_14()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_60() {\r
-    if (jj_3R_17()) return true;\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_63()) jj_scanpos = xsp;\r
+  private boolean jj_3R_84() {\r
+    if (jj_3R_16()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_65() {\r
-    if (jj_scan_token(69)) return true;\r
-    if (jj_3R_64()) return true;\r
+  private boolean jj_3R_71() {\r
+    if (jj_scan_token(21)) return true;\r
+    if (jj_3R_77()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_20() {\r
-    if (jj_3R_23()) return true;\r
+  private boolean jj_3R_83() {\r
+    if (jj_scan_token(UNSIGNED_INTEGER)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_17() {\r
+  private boolean jj_3R_14() {\r
+    if (jj_3R_16()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_20()) {\r
+    if (jj_3R_17()) jj_scanpos = xsp;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_78() {\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_83()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_21()) return true;\r
+    if (jj_3R_84()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3_3() {\r
-    if (jj_3R_13()) return true;\r
-    if (jj_scan_token(60)) return true;\r
+  private boolean jj_3R_20() {\r
+    if (jj_scan_token(QIDENT)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_70() {\r
-    if (jj_3R_73()) return true;\r
+  private boolean jj_3R_54() {\r
+    if (jj_scan_token(68)) return true;\r
+    if (jj_3R_53()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_75() {\r
+    if (jj_scan_token(62)) return true;\r
+    if (jj_3R_78()) return true;\r
     Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_74()) jj_scanpos = xsp;\r
+    while (true) {\r
+      xsp = jj_scanpos;\r
+      if (jj_3R_80()) { jj_scanpos = xsp; break; }\r
+    }\r
+    if (jj_scan_token(63)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_59() {\r
+  private boolean jj_3_3() {\r
     if (jj_3R_14()) return true;\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_62()) jj_scanpos = xsp;\r
+    if (jj_scan_token(60)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_54() {\r
+  private boolean jj_3R_66() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_59()) {\r
+    if (jj_3R_70()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_60()) return true;\r
+    if (jj_3R_71()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_55() {\r
-    if (jj_3R_54()) return true;\r
+  private boolean jj_3R_68() {\r
+    if (jj_scan_token(69)) return true;\r
+    if (jj_3R_67()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_22() {\r
-    if (jj_3R_15()) return true;\r
+  private boolean jj_3R_70() {\r
+    if (jj_scan_token(69)) return true;\r
+    if (jj_3R_55()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_69() {\r
-    if (jj_3R_13()) return true;\r
-    if (jj_3R_50()) return true;\r
+  private boolean jj_3R_74() {\r
+    if (jj_3R_78()) return true;\r
+    Token xsp;\r
+    xsp = jj_scanpos;\r
+    if (jj_3R_79()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_18() {\r
-    if (jj_scan_token(IDENT)) return true;\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_22()) jj_scanpos = xsp;\r
+  private boolean jj_3R_23() {\r
+    if (jj_3R_16()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_15() {\r
+  private boolean jj_3R_73() {\r
+    if (jj_3R_14()) return true;\r
+    if (jj_3R_51()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_16() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_18()) {\r
+    if (jj_3R_19()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_19()) return true;\r
+    if (jj_3R_20()) return true;\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_50() {\r
-    if (jj_scan_token(60)) return true;\r
+  private boolean jj_3R_19() {\r
+    if (jj_scan_token(IDENT)) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_55()) jj_scanpos = xsp;\r
-    if (jj_scan_token(61)) return true;\r
+    if (jj_3R_23()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_56() {\r
-    if (jj_3R_61()) return true;\r
+  private boolean jj_3_1() {\r
+    if (jj_3R_14()) return true;\r
+    if (jj_scan_token(60)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_68() {\r
-    if (jj_scan_token(67)) return true;\r
+  private boolean jj_3R_50() {\r
+    if (jj_scan_token(62)) return true;\r
+    if (jj_3R_55()) return true;\r
+    if (jj_scan_token(63)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_64() {\r
+  private boolean jj_3R_67() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_68()) {\r
+    if (jj_3R_72()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_69()) {\r
+    if (jj_3R_73()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_70()) {\r
+    if (jj_3R_74()) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_71()) return true;\r
+    if (jj_3R_75()) return true;\r
     }\r
     }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3_1() {\r
-    if (jj_3R_13()) return true;\r
-    if (jj_scan_token(60)) return true;\r
+  private boolean jj_3R_72() {\r
+    if (jj_scan_token(67)) return true;\r
     return false;\r
   }\r
 \r
   private boolean jj_3R_49() {\r
-    if (jj_scan_token(62)) return true;\r
-    if (jj_3R_54()) return true;\r
-    if (jj_scan_token(63)) return true;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_48() {\r
     if (jj_scan_token(64)) return true;\r
-    if (jj_3R_52()) return true;\r
+    if (jj_3R_53()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_53()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_54()) { jj_scanpos = xsp; break; }\r
     }\r
     if (jj_scan_token(65)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_47() {\r
+  private boolean jj_3R_48() {\r
     if (jj_scan_token(60)) return true;\r
-    if (jj_3R_17()) return true;\r
+    if (jj_3R_18()) return true;\r
     if (jj_scan_token(61)) return true;\r
     return false;\r
   }\r
 \r
+  private boolean jj_3R_47() {\r
+    if (jj_3R_52()) return true;\r
+    return false;\r
+  }\r
+\r
   private boolean jj_3R_46() {\r
+    if (jj_3R_14()) return true;\r
     if (jj_3R_51()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_58() {\r
+  private boolean jj_3R_59() {\r
     if (jj_scan_token(69)) return true;\r
-    if (jj_3R_17()) return true;\r
+    if (jj_3R_18()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_61() {\r
-    if (jj_scan_token(64)) return true;\r
-    if (jj_3R_64()) return true;\r
+  private boolean jj_3R_44() {\r
     Token xsp;\r
-    while (true) {\r
-      xsp = jj_scanpos;\r
-      if (jj_3R_65()) { jj_scanpos = xsp; break; }\r
+    xsp = jj_scanpos;\r
+    if (jj_scan_token(84)) {\r
+    jj_scanpos = xsp;\r
+    if (jj_scan_token(85)) return true;\r
     }\r
-    if (jj_scan_token(65)) return true;\r
+    if (jj_3R_43()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_45() {\r
-    if (jj_3R_13()) return true;\r
-    if (jj_3R_50()) return true;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_43() {\r
+  private boolean jj_3R_62() {\r
+    if (jj_scan_token(64)) return true;\r
+    if (jj_3R_67()) return true;\r
     Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_scan_token(84)) {\r
-    jj_scanpos = xsp;\r
-    if (jj_scan_token(85)) return true;\r
+    while (true) {\r
+      xsp = jj_scanpos;\r
+      if (jj_3R_68()) { jj_scanpos = xsp; break; }\r
     }\r
-    if (jj_3R_42()) return true;\r
+    if (jj_scan_token(65)) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_42() {\r
+  private boolean jj_3R_43() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(92)) {\r
@@ -1407,8 +1509,6 @@ void named_arguments() : {
     jj_scanpos = xsp;\r
     if (jj_scan_token(33)) {\r
     jj_scanpos = xsp;\r
-    if (jj_3R_45()) {\r
-    jj_scanpos = xsp;\r
     if (jj_3R_46()) {\r
     jj_scanpos = xsp;\r
     if (jj_3R_47()) {\r
@@ -1417,6 +1517,8 @@ void named_arguments() : {
     jj_scanpos = xsp;\r
     if (jj_3R_49()) {\r
     jj_scanpos = xsp;\r
+    if (jj_3R_50()) {\r
+    jj_scanpos = xsp;\r
     if (jj_scan_token(35)) return true;\r
     }\r
     }\r
@@ -1431,31 +1533,25 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_29() {\r
-    if (jj_scan_token(67)) return true;\r
-    if (jj_3R_25()) return true;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_41() {\r
-    if (jj_3R_44()) return true;\r
-    if (jj_3R_40()) return true;\r
+  private boolean jj_3R_76() {\r
+    if (jj_scan_token(69)) return true;\r
+    if (jj_3R_15()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_34() {\r
-    if (jj_3R_38()) return true;\r
-    if (jj_3R_33()) return true;\r
+  private boolean jj_3R_30() {\r
+    if (jj_scan_token(67)) return true;\r
+    if (jj_3R_26()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_37() {\r
-    if (jj_3R_39()) return true;\r
-    if (jj_3R_36()) return true;\r
+  private boolean jj_3R_42() {\r
+    if (jj_3R_45()) return true;\r
+    if (jj_3R_41()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_44() {\r
+  private boolean jj_3R_45() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(80)) {\r
@@ -1471,68 +1567,78 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_40() {\r
-    if (jj_3R_42()) return true;\r
+  private boolean jj_3R_38() {\r
+    if (jj_3R_40()) return true;\r
+    if (jj_3R_37()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_35() {\r
+    if (jj_3R_39()) return true;\r
+    if (jj_3R_34()) return true;\r
+    return false;\r
+  }\r
+\r
+  private boolean jj_3R_41() {\r
+    if (jj_3R_43()) return true;\r
     Token xsp;\r
     xsp = jj_scanpos;\r
-    if (jj_3R_43()) jj_scanpos = xsp;\r
+    if (jj_3R_44()) jj_scanpos = xsp;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_52() {\r
-    if (jj_3R_17()) return true;\r
+  private boolean jj_3R_53() {\r
+    if (jj_3R_18()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_58()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_59()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_75() {\r
-    if (jj_scan_token(69)) return true;\r
-    if (jj_3R_73()) return true;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_62() {\r
+  private boolean jj_3R_63() {\r
     if (jj_scan_token(69)) return true;\r
-    if (jj_3R_54()) return true;\r
+    if (jj_3R_55()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_14() {\r
-    if (jj_3R_15()) return true;\r
-    if (jj_scan_token(86)) return true;\r
-    if (jj_3R_17()) return true;\r
+  private boolean jj_3R_37() {\r
+    if (jj_3R_41()) return true;\r
+    Token xsp;\r
+    while (true) {\r
+      xsp = jj_scanpos;\r
+      if (jj_3R_42()) { jj_scanpos = xsp; break; }\r
+    }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_67() {\r
-    if (jj_scan_token(21)) return true;\r
-    if (jj_3R_72()) return true;\r
+  private boolean jj_3R_25() {\r
+    if (jj_scan_token(20)) return true;\r
+    if (jj_3R_18()) return true;\r
+    if (jj_scan_token(28)) return true;\r
+    if (jj_3R_18()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_24() {\r
-    if (jj_scan_token(20)) return true;\r
-    if (jj_3R_17()) return true;\r
-    if (jj_scan_token(28)) return true;\r
-    if (jj_3R_17()) return true;\r
+  private boolean jj_3R_15() {\r
+    if (jj_3R_16()) return true;\r
+    if (jj_scan_token(86)) return true;\r
+    if (jj_3R_18()) return true;\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_36() {\r
-    if (jj_3R_40()) return true;\r
+  private boolean jj_3R_69() {\r
+    if (jj_3R_15()) return true;\r
     Token xsp;\r
     while (true) {\r
       xsp = jj_scanpos;\r
-      if (jj_3R_41()) { jj_scanpos = xsp; break; }\r
+      if (jj_3R_76()) { jj_scanpos = xsp; break; }\r
     }\r
     return false;\r
   }\r
 \r
-  private boolean jj_3R_39() {\r
+  private boolean jj_3R_40() {\r
     Token xsp;\r
     xsp = jj_scanpos;\r
     if (jj_scan_token(76)) {\r
@@ -1548,22 +1654,6 @@ void named_arguments() : {
     return false;\r
   }\r
 \r
-  private boolean jj_3R_51() {\r
-    if (jj_3R_15()) return true;\r
-    Token xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_56()) jj_scanpos = xsp;\r
-    xsp = jj_scanpos;\r
-    if (jj_3R_57()) jj_scanpos = xsp;\r
-    return false;\r
-  }\r
-\r
-  private boolean jj_3R_31() {\r
-    if (jj_scan_token(9)) return true;\r
-    if (jj_3R_30()) return true;\r
-    return false;\r
-  }\r
-\r
   /** Generated Token Manager. */\r
   public ExpressionParserTokenManager token_source;\r
   SimpleCharStream jj_input_stream;\r
@@ -1575,7 +1665,7 @@ void named_arguments() : {
   private Token jj_scanpos, jj_lastpos;\r
   private int jj_la;\r
   private int jj_gen;\r
-  final private int[] jj_la1 = new int[43];\r
+  final private int[] jj_la1 = new int[46];\r
   static private int[] jj_la1_0;\r
   static private int[] jj_la1_1;\r
   static private int[] jj_la1_2;\r
@@ -1585,13 +1675,13 @@ void named_arguments() : {
       jj_la1_init_2();\r
    }\r
    private static void jj_la1_init_0() {\r
-      jj_la1_0 = new int[] {0x100000,0x80001040,0x100000,0x80001040,0x0,0x0,0x400000,0x200,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x80001040,0x0,0x200000,0x200000,0x80001040,0x0,0x0,0x80001040,0x0,0x80001040,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};\r
+      jj_la1_0 = new int[] {0x100000,0x80001040,0x100000,0x80001040,0x0,0x0,0x400000,0x200,0x1000,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x40,0x0,0x0,0x0,0x0,0x0,0x0,0x84001040,0x0,0x0,0x0,0x84001040,0x200000,0x200000,0x84001040,0x0,0x0,0x80001040,0x0,0x80001040,0x0,0x0,0x0,0x0,0x0,0x0,0x0,};\r
    }\r
    private static void jj_la1_init_1() {\r
-      jj_la1_1 = new int[] {0x0,0x5000000a,0x0,0x5000000a,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x50000008,0x0,0x0,0x0,0x0,0x0,0x5000000a,0x0,0x0,0x0,0x5000000a,0x0,0x200,0x5000000a,0x0,0x5000000a,0x0,0x0,0x0,0x0,0x0,0x40000000,0x0,};\r
+      jj_la1_1 = new int[] {0x0,0x5000000a,0x0,0x5000000a,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x2,0x50000008,0x0,0x0,0x0,0x0,0x0,0x5000000a,0x0,0x0,0x0,0x5000000a,0x0,0x0,0x5000000a,0x0,0x200,0x5000000a,0x0,0x5000000a,0x0,0x0,0x0,0x0,0x0,0x40000000,0x0,};\r
    }\r
    private static void jj_la1_init_2() {\r
-      jj_la1_2 = new int[] {0x0,0x1f00f001,0x0,0x1f00f001,0x8,0x8,0x0,0x0,0x0,0xfc0,0xfc0,0xf000,0xf000,0xf000,0xf0000,0x300000,0x300000,0xf0000,0x10,0x1c000000,0x3000001,0x3000000,0x3000000,0x4,0x1,0x4,0x1f00f001,0x20,0x20,0x20,0x1f00f001,0x20,0x0,0x1f00f001,0x20,0x1f00f001,0x20,0x20,0x8,0x20,0x8,0xb000000,0xb000000,};\r
+      jj_la1_2 = new int[] {0x0,0x1f00f001,0x0,0x1f00f001,0x8,0x8,0x0,0x0,0x0,0xfc0,0xfc0,0xf000,0xf000,0xf000,0xf0000,0x300000,0x300000,0xf0000,0x10,0x1c000000,0x3000001,0x3000000,0x3000000,0x4,0x1,0x4,0x1f00f001,0x20,0x20,0x3000000,0x1f00f001,0x20,0x20,0x1f00f001,0x20,0x0,0x1f00f001,0x20,0x1f00f001,0x20,0x20,0x8,0x20,0x8,0xb000000,0xb000000,};\r
    }\r
   final private JJCalls[] jj_2_rtns = new JJCalls[3];\r
   private boolean jj_rescan = false;\r
@@ -1608,7 +1698,7 @@ void named_arguments() : {
     token = new Token();\r
     jj_ntk = -1;\r
     jj_gen = 0;\r
-    for (int i = 0; i < 43; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 46; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -1623,7 +1713,7 @@ void named_arguments() : {
     token = new Token();\r
     jj_ntk = -1;\r
     jj_gen = 0;\r
-    for (int i = 0; i < 43; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 46; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -1634,7 +1724,7 @@ void named_arguments() : {
     token = new Token();\r
     jj_ntk = -1;\r
     jj_gen = 0;\r
-    for (int i = 0; i < 43; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 46; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -1645,7 +1735,7 @@ void named_arguments() : {
     token = new Token();\r
     jj_ntk = -1;\r
     jj_gen = 0;\r
-    for (int i = 0; i < 43; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 46; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -1655,7 +1745,7 @@ void named_arguments() : {
     token = new Token();\r
     jj_ntk = -1;\r
     jj_gen = 0;\r
-    for (int i = 0; i < 43; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 46; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -1665,7 +1755,7 @@ void named_arguments() : {
     token = new Token();\r
     jj_ntk = -1;\r
     jj_gen = 0;\r
-    for (int i = 0; i < 43; i++) jj_la1[i] = -1;\r
+    for (int i = 0; i < 46; i++) jj_la1[i] = -1;\r
     for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new JJCalls();\r
   }\r
 \r
@@ -1782,7 +1872,7 @@ void named_arguments() : {
       la1tokens[jj_kind] = true;\r
       jj_kind = -1;\r
     }\r
-    for (int i = 0; i < 43; i++) {\r
+    for (int i = 0; i < 46; i++) {\r
       if (jj_la1[i] == jj_gen) {\r
         for (int j = 0; j < 32; j++) {\r
           if ((jj_la1_0[i] & (1<<j)) != 0) {\r
index ce3aa44a22d86d2c7559263448355fa14c9954c8..18e77d189e8114644f4f2877759580d7a9854e80 100644 (file)
@@ -315,7 +315,7 @@ void function_arguments() : {
        //expression [ "," function_arguments | for for_indices ]\r
        //| named_arguments\r
        LOOKAHEAD(named_argument()) named_argument()  ( "," function_arguments() )?\r
-       | expression() ( "," function_arguments() | "for" for_indices() )?\r
+       | (expression() | "function" name() "(" ( named_argument() ( "," named_argument() )* )? ")" ) ( "," function_arguments() | "for" for_indices() )?\r
        \r
 }\r
 \r
index 123bede42a2d53a15fcbabc7c0def4b9f5a0f979..24fd7453f88abbaa5e5eb623a782db195e55a4b4 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010, 2013 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2013, 2014 Association for Decentralized Information Management in\r
  * 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
@@ -39,6 +39,7 @@ import org.simantics.db.common.request.WriteRequest;
 import org.simantics.db.common.utils.Logger;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.request.Read;\r
 import org.simantics.db.service.VirtualGraphSupport;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modelica.IModelicaMonitor;\r
@@ -55,11 +56,13 @@ import org.simantics.simulation.experiment.ExperimentState;
 import org.simantics.simulation.experiment.IExperimentListener;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.sysdyn.Activator;\r
+import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.adapter.VariableValueSubscription;\r
 import org.simantics.sysdyn.modelica.ModelicaWriter;\r
 import org.simantics.sysdyn.representation.Configuration;\r
 import org.simantics.sysdyn.representation.Model;\r
 import org.simantics.sysdyn.simulation.SimulationScheduler;\r
+import org.simantics.ui.SimanticsUI;\r
 \r
 public class OldSysdynExperiment extends SysdynExperiment {\r
 \r
@@ -431,8 +434,28 @@ public class OldSysdynExperiment extends SysdynExperiment {
      * @return\r
      */\r
     protected String getAdditionalScripts() {\r
-        StringBuilder functionscript = new StringBuilder();\r
-        for(String path : FunctionUtils.getLibraryPathsForModelica(this)) {\r
+       StringBuilder functionscript = new StringBuilder();\r
+        \r
+       boolean useModelicaLibraries = false;\r
+       try {\r
+                       useModelicaLibraries = SimanticsUI.getSession().syncRequest(new Read<Boolean>() {\r
+\r
+                               @Override\r
+                               public Boolean perform(ReadGraph graph) throws DatabaseException {\r
+                                       SysdynResource SR = SysdynResource.getInstance(graph);\r
+                                       SimulationResource SIM = SimulationResource.getInstance(graph);\r
+                                       Resource configuration = graph.getPossibleObject(OldSysdynExperiment.this.model, SIM.HasConfiguration);\r
+                                       return graph.hasStatement(configuration, SR.SysdynModel_useModelicaLibraries);\r
+                               }\r
+                       });\r
+               } catch (DatabaseException e) {\r
+                       // TODO Auto-generated catch block\r
+                       e.printStackTrace();\r
+               }\r
+       if (useModelicaLibraries)\r
+               functionscript.append("loadModel(Modelica);\n");\r
+        \r
+       for(String path : FunctionUtils.getLibraryPathsForModelica(this)) {\r
             functionscript.append("loadFile(\"" + path + "\");\n");\r
         }\r
         return functionscript.toString();\r
@@ -826,10 +849,16 @@ public class OldSysdynExperiment extends SysdynExperiment {
     public void resultsChanged() {\r
        resultsChanged(false);\r
     }\r
+\r
+    protected void onPublishResults() {\r
+               resultsChanged(true);\r
+    }\r
     \r
     public void setPublishResults(boolean value) {\r
        publishResults = value;\r
-       if(publishResults) resultsChanged(true);\r
+       if(publishResults) {\r
+               onPublishResults();\r
+       }\r
     }\r
 \r
     public void resultsChanged(boolean force) {\r
index 3d20128c460f332daf274e65d2a95d034da4eb9a..6a79068f19d4ad33a9a347a381212e84820fcbb1 100644 (file)
@@ -127,20 +127,26 @@ public class SysdynConsole implements ISolverMonitor {
         }\r
     }\r
 \r
+    final static private SimpleDateFormat hhmmss = new SimpleDateFormat("hh:mm:ss");\r
+    \r
     @Override\r
     public void message(String message) {\r
-        message(message, "hh:mm:ss");\r
+        message(message, hhmmss);\r
+    }\r
+\r
+    public void message(String message, String timeStampFormat) {\r
+        message(message, new SimpleDateFormat(timeStampFormat));\r
     }\r
 \r
+    final static Calendar cal = Calendar.getInstance();\r
+\r
     /**\r
      * Print message to a console with a specified time stamp format\r
      * \r
      * @param message the message to be printed\r
      * @param timeStampFormat simpledateformat timestamp format. null if no timestamp wanted\r
      */\r
-    public void message(String message, String timeStampFormat) {\r
-        Calendar cal = Calendar.getInstance();\r
-        SimpleDateFormat sdf = new SimpleDateFormat(timeStampFormat);\r
+    public void message(String message, SimpleDateFormat sdf) {\r
         String time = sdf.format(cal.getTime());\r
 \r
         MessageConsoleStream out = this.console.newMessageStream();\r
index 1e0f76de6758752d80dd518db2addd64e395d21f..5c7ac3de05f526d79df3a2c70364da1fb70cc3b8 100644 (file)
@@ -14,12 +14,17 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.impl.DefaultCopyHandler;\r
+import org.simantics.db.layer0.adapter.impl.DefaultPasteHandler;\r
 import org.simantics.db.layer0.util.Layer0Utils;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.layer0.variable.RVI;\r
 import org.simantics.db.layer0.variable.Variable;\r
 import org.simantics.db.layer0.variable.Variables;\r
+import org.simantics.db.service.VirtualGraphSupport;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingResources;\r
 import org.simantics.modeling.PartialIC;\r
@@ -30,6 +35,7 @@ import org.simantics.simulation.experiment.IExperiment;
 import org.simantics.simulation.model.ExperimentLoadingFailed;\r
 import org.simantics.simulation.project.IExperimentActivationListener;\r
 import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.utils.DataContainer;\r
 \r
@@ -148,9 +154,18 @@ public class SysdynExperiments {
     }\r
 \r
        private static void processChild(ReadGraph graph, Variable child, PartialIC IC) throws DatabaseException {\r
+<<<<<<< .working\r
 \r
+=======\r
+               \r
+               StructuralResource2 STR = StructuralResource2.getInstance(graph);\r
+               \r
+>>>>>>> .merge-right.r30389\r
                for(Variable c : child.getChildren(graph)) {\r
-                       processChild(graph, c, IC);\r
+                       Resource type = c.getPossibleType(graph);\r
+                       if(type == null) continue;\r
+                       if(graph.isInheritedFrom(type, STR.Component))\r
+                               processChild(graph, c, IC);\r
                }\r
                Variable values = child.getPossibleProperty(graph, "values");\r
                if(values == null) return;\r
@@ -162,7 +177,9 @@ public class SysdynExperiments {
                SysdynResource SYSDYN = SysdynResource.getInstance(graph);\r
                \r
                Collection<Resource> exprs = graph.syncRequest(new ObjectsWithType(represents, L0.ConsistsOf, SYSDYN.ParameterExpression));\r
-               if(exprs.size() == 0) return;\r
+               if(exprs.size() == 0) {\r
+                       if(graph.hasStatement(represents, SYSDYN.Variable_isHeadOf)) return;\r
+               }\r
                        \r
                Variable v = values.getPossibleProperty(graph, "");\r
                if(v == null) return;\r
@@ -176,11 +193,18 @@ public class SysdynExperiments {
                        if(target != null && ds.length > 0) {\r
                                RVI rvi = target.getRVI(graph);\r
                                double initial = ds[0];\r
-                               System.err.println("rvi=" + rvi + " value=" + initial);\r
+//                             System.err.println("rvi=" + rvi + " value=" + initial);\r
                                IC.add(rvi, Variant.ofInstance(initial));\r
                        }\r
                }\r
        }\r
+       \r
+       public static Resource saveIC(WriteGraph graph, Variable input) throws DatabaseException {\r
+           Layer0 L0 = Layer0.getInstance(graph);\r
+           Resource model = Variables.getModel(graph, input);\r
+           String name = NameUtils.findFreshName(graph, "IC", model, L0.ConsistsOf);\r
+           return saveIC(graph, input, name);\r
+       }\r
 \r
     public static Resource saveIC(WriteGraph graph, Variable input, String name) throws DatabaseException {\r
         graph.markUndoPoint();\r
@@ -198,7 +222,7 @@ public class SysdynExperiments {
        \r
                PartialIC IC = new PartialIC();\r
                processChild(graph, input, IC);\r
-\r
+               \r
                Layer0 L0 = Layer0.getInstance(graph);\r
                ModelingResources MOD = ModelingResources.getInstance(graph);\r
                Resource ic = graph.newResource();\r
@@ -206,6 +230,19 @@ public class SysdynExperiments {
                graph.addLiteral(ic, L0.HasName, L0.NameOf, L0.String, name, Bindings.STRING);\r
                graph.addLiteral(ic, SYSDYN.InitialCondition_HasInitialValues, SYSDYN.InitialCondition_HasInitialValues_Inverse, MOD.PartialIC, IC, PartialIC.BINDING);\r
                graph.claim(model, L0.ConsistsOf, ic);\r
+\r
+               Resource represents = input.getPossibleRepresents(graph);\r
+               if(represents != null) {\r
+                       Resource state = Layer0Utils.getPossibleChild(graph, represents, "__simupedia__");   \r
+                   Layer0Utils.copyTo(graph, ic, state, null, new DefaultCopyHandler(state) {\r
+                       \r
+                       @Override\r
+                       protected boolean ignoreVirtualResources() {\r
+                               return false;\r
+                       }\r
+                       \r
+                   }, new DefaultPasteHandler(ic));\r
+               }\r
                \r
                Layer0Utils.addCommentMetadata(graph, "Saved new Initial Condition " + name + " " + ic);\r
                return ic;\r
@@ -214,12 +251,11 @@ public class SysdynExperiments {
 \r
     public static void assignIC(WriteGraph graph, Variable experiment, String name) throws DatabaseException {\r
         graph.markUndoPoint();\r
-       System.err.println("assignIC " + experiment.getURI(graph));\r
 \r
                Layer0 L0 = Layer0.getInstance(graph);\r
                SysdynResource SYSDYN = SysdynResource.getInstance(graph);\r
 \r
-       Resource run = experiment.getPossibleRepresents(graph);\r
+       final Resource run = experiment.getPossibleRepresents(graph);\r
        if(run == null) return;\r
        Resource exp = graph.getPossibleObject(run, L0.PartOf);\r
        if(exp == null) return;\r
@@ -233,12 +269,29 @@ public class SysdynExperiments {
                graph.deny(exp, SYSDYN.Experiment_ic);\r
                graph.claim(exp, SYSDYN.Experiment_ic, ic);\r
        Layer0Utils.addCommentMetadata(graph, "Assigned Initial Condition " + graph.getRelatedValue2(ic, L0.HasName, Bindings.STRING) + " to experiment " + graph.getRelatedValue2(exp, L0.HasName, Bindings.STRING));\r
+       \r
+       Resource oldState = Layer0Utils.getPossibleChild(graph, run, "__simupedia__");\r
+       if(oldState != null) {\r
+               graph.deny(run, L0.ConsistsOf, oldState);\r
+       }\r
+       \r
+       final Resource storedState = Layer0Utils.getPossibleChild(graph, ic, "__simupedia__");\r
+       if(storedState != null) {\r
+               VirtualGraphSupport vgs = graph.getService(VirtualGraphSupport.class);\r
+               graph.syncRequest(new WriteRequest(vgs.getMemoryPersistent("experiments")) {\r
+\r
+                               @Override\r
+                               public void perform(WriteGraph graph) throws DatabaseException {\r
+                                   Layer0Utils.copyTo(graph, run, storedState, null, new DefaultCopyHandler(storedState), new DefaultPasteHandler(run));\r
+                               }\r
+                       \r
+               });\r
+       }\r
+       \r
     }\r
     \r
     public static void deassignIC(WriteGraph graph, Variable experiment) throws DatabaseException {\r
 \r
-       System.err.println("deassignIC " + experiment.getURI(graph));\r
-\r
                Layer0 L0 = Layer0.getInstance(graph);\r
                SysdynResource SYSDYN = SysdynResource.getInstance(graph);\r
 \r
@@ -253,8 +306,6 @@ public class SysdynExperiments {
 \r
     public static void applyIC(WriteGraph graph, Variable experiment, String name) throws DatabaseException {\r
 \r
-       System.err.println("applyIC " + experiment.getURI(graph));\r
-\r
                Layer0 L0 = Layer0.getInstance(graph);\r
                SysdynResource SYSDYN = SysdynResource.getInstance(graph);\r
 \r
@@ -271,8 +322,13 @@ public class SysdynExperiments {
        \r
                Variable base = Variables.getVariable(graph, run);\r
                \r
+               SysdynExperiments.setPublishResults(graph, base, false);\r
+               \r
                PartialIC data = graph.getPossibleRelatedValue(ic, SYSDYN.InitialCondition_HasInitialValues, PartialIC.BINDING);\r
                data.apply(graph, base);\r
+               \r
+               SysdynExperiments.setPublishResults(graph, base, true);\r
+\r
        \r
     }\r
     \r
index 421e75d26325f13f4dbd6ead3bbd04a41ca7e07d..31314bbdf4df9e7ac046b41924679428e33f30af 100644 (file)
@@ -14,13 +14,16 @@ package org.simantics.sysdyn.manager;
 import gnu.trove.list.array.TDoubleArrayList;\r
 import gnu.trove.map.hash.THashMap;\r
 \r
+import java.util.Collection;\r
 import java.util.HashMap;\r
 \r
 import org.eclipse.core.runtime.IProgressMonitor;\r
+import org.eclipse.core.runtime.NullProgressMonitor;\r
 import org.eclipse.core.runtime.jobs.Job;\r
 import org.simantics.db.AsyncReadGraph;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.Logger;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.procedure.AsyncListener;\r
 import org.simantics.db.request.Read;\r
@@ -47,7 +50,7 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment {
        \r
        THashMap<String, TDoubleArrayList> results;\r
 \r
-       protected String[] subscription;\r
+       public String[] subscription;\r
        \r
        public static double DEFAULT_STEP_DURATION = 1.0;\r
        public static double DEFAULT_STEP_LENGTH        = 0.1;\r
@@ -82,6 +85,25 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment {
                this.savePer = interval;\r
        }\r
        \r
+       public static class Subscription {\r
+           public SysdynGameExperimentBase exp;\r
+           public int[] indexes;\r
+           public void getValues(double[] data) {\r
+               for(int i=0;i<indexes.length;i++) data[i] = exp.currentValues[indexes[i]];\r
+           }\r
+       }\r
+       \r
+       public Subscription subscribe(Collection<String> names) {\r
+           Subscription result = new Subscription();\r
+           int[] indexes = new int[names.size()];\r
+           int index = 0;\r
+           for(String name : names)\r
+               indexes[index++] = subscriptionIndexes.get(name);\r
+           result.exp = this;\r
+           result.indexes = indexes;\r
+           return result;\r
+       }\r
+       \r
     public Double getCurrentValue(String name) {\r
         if(subscriptionIndexes != null && name != null) {\r
             Integer index = subscriptionIndexes.get(name);\r
@@ -194,5 +216,16 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment {
        }\r
        \r
     }\r
+\r
+    @Override\r
+    protected void onPublishResults() {\r
+       try {\r
+                       setSubscribedResults(new NullProgressMonitor(), getSolver().getTime());\r
+               } catch (FMUJNIException e) {\r
+                       Logger.defaultLogError(e);\r
+               }\r
+               ((MemoryResult)getCurrentResult()).setResult(new GameResult(this, this.results, this.subscription));\r
+               super.onPublishResults();\r
+    }\r
     \r
 }\r
index 1dfc9a8d676ca7af19de84c2b5fd438386be6c37..71025a735443b329df6f16984bdbbf41d477237e 100644 (file)
@@ -153,9 +153,11 @@ public class SysdynGameExperimentInternal extends SysdynGameExperimentBase {
        @Override\r
        public void refresh() {\r
                try {\r
-                       setSubscribedResults(new NullProgressMonitor(), solver.getTime());\r
-       \r
-                       ((MemoryResult)getCurrentResult()).setResult(new GameResult(this, this.results, this.subscription));\r
+                       \r
+                       if(publishResults) {\r
+                               setSubscribedResults(new NullProgressMonitor(), solver.getTime());\r
+                               ((MemoryResult)getCurrentResult()).setResult(new GameResult(this, this.results, this.subscription));\r
+                       }\r
        \r
                        resultsChanged(true);\r
                } catch (Exception e) {\r
index ab040550c3ac762df896a04c2aa97183e7b9c8e1..93df521edd922040c6ddd910180dc3eb182c6302 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010, 2013 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2013, 2014 Association for Decentralized Information Management in\r
  * 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
@@ -23,9 +23,11 @@ import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;\r
 \r
 import org.simantics.Simantics;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
+import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
@@ -34,11 +36,14 @@ import org.simantics.db.procedure.Listener;
 import org.simantics.db.request.Read;\r
 import org.simantics.db.service.VirtualGraphSupport;\r
 import org.simantics.layer0.Layer0;\r
+import org.simantics.modeling.ModelingResources;\r
 import org.simantics.objmap.IMapping;\r
 import org.simantics.objmap.IMappingListener;\r
 import org.simantics.objmap.MappingException;\r
 import org.simantics.objmap.Mappings;\r
 import org.simantics.project.IProject;\r
+import org.simantics.scl.runtime.function.Function2;\r
+import org.simantics.scl.runtime.function.FunctionImpl2;\r
 import org.simantics.simulation.experiment.IExperiment;\r
 import org.simantics.simulation.model.IModel;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
@@ -66,7 +71,7 @@ import org.simantics.sysdyn.solver.SolverSettings.SolverType;
 \r
 /**\r
  * Maintains a Java representation of system dynamic model.\r
- * @author Hannu Niemistö, Teemu Lempinen\r
+ * @author Hannu Niemistö, Teemu Lempinen, Tuomas Miettinen\r
  */\r
 public class SysdynModel implements IModel, IMappingListener, VariableSubscriptionManager {\r
 \r
@@ -453,8 +458,27 @@ public class SysdynModel implements IModel, IMappingListener, VariableSubscripti
             \r
             exp.init(g);\r
             \r
+            Function2<WriteGraph, Resource, Object> scl = new FunctionImpl2<WriteGraph, Resource, Object>() {\r
+\r
+                               @Override\r
+                               public Object apply(WriteGraph graph, Resource run) {\r
+                                       try {\r
+                                               Layer0 L0 = Layer0.getInstance(graph);\r
+                                               ModelingResources MOD = ModelingResources.getInstance(graph);\r
+                                               Resource session = graph.newResource();\r
+                                               graph.claim(session, L0.InstanceOf, MOD.SCLCommandSession);\r
+                                               graph.addLiteral(session, L0.HasName, L0.NameOf, L0.String, "__scl__", Bindings.STRING);\r
+                                               graph.claim(run, L0.ConsistsOf, session);\r
+                                       } catch (DatabaseException e) {\r
+                                               e.printStackTrace();\r
+                                       }\r
+                                       return null;\r
+                               }\r
+                               \r
+                       };\r
+            \r
             VirtualGraphSupport support = g.getSession().getService(VirtualGraphSupport.class);\r
-            ExperimentRuns.createRun(g.getSession(), support.getWorkspacePersistent("experiments"), experiment, exp, SysdynResource.URIs.Experiment_Run, listener, null);\r
+            ExperimentRuns.createRun(g.getSession(), support.getWorkspacePersistent("experiments"), experiment, exp, SysdynResource.URIs.Experiment_Run, listener, scl, null);\r
             if(listener != null)\r
                 listener.onExperimentActivated(exp);\r
             return exp;\r
@@ -493,7 +517,7 @@ public class SysdynModel implements IModel, IMappingListener, VariableSubscripti
             if (element instanceof Module) {\r
                 Module module = (Module) element;\r
                 Configuration conf = module.getType().getConfiguration();\r
-                String prfx = prefix + module.getName() + ".";\r
+                String prfx = prefix + module.getModelicaName() + ".";\r
                 inits.putAll(getInits(conf, prfx));\r
                 for(ParameterOverride po : module.getParameterOverrides()) {\r
                        inits.put(prfx + po.getVariable().getName(), po.getExpression());\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/IModelParser.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/modelImport/IModelParser.java
new file mode 100644 (file)
index 0000000..a179b6c
--- /dev/null
@@ -0,0 +1,9 @@
+package org.simantics.sysdyn.modelImport;\r
+\r
+import java.io.File;\r
+\r
+import org.simantics.sysdyn.modelImport.model.Model;\r
+\r
+public interface IModelParser {\r
+       public Model parse(File file) throws Exception; \r
+}\r
index 25c77c0e48daacabdde5b32fc6a00328b26da604..876390a5a9bc1745c05447fc9dd53deadc7dc572 100644 (file)
@@ -20,6 +20,7 @@ import java.util.regex.Pattern;
 import org.simantics.sysdyn.modelImport.mdl.Declaration;\r
 import org.simantics.sysdyn.modelImport.mdl.Lookup;\r
 import org.simantics.sysdyn.modelImport.mdl.MdlModel;\r
+import org.simantics.sysdyn.modelImport.mdl.MdlVariable;\r
 import org.simantics.sysdyn.modelImport.mdl.Sketch;\r
 import org.simantics.sysdyn.modelImport.mdl.SketchComment;\r
 import org.simantics.sysdyn.modelImport.mdl.SketchConnection;\r
@@ -28,7 +29,6 @@ import org.simantics.sysdyn.modelImport.mdl.SketchValve;
 import org.simantics.sysdyn.modelImport.mdl.SketchVariable;\r
 import org.simantics.sysdyn.modelImport.mdl.Subscript;\r
 import org.simantics.sysdyn.modelImport.mdl.SubscriptVariable;\r
-import org.simantics.sysdyn.modelImport.mdl.MdlVariable;\r
 import org.simantics.sysdyn.modelImport.model.Comment;\r
 import org.simantics.sysdyn.modelImport.model.Connection;\r
 import org.simantics.sysdyn.modelImport.model.Model;\r
@@ -37,7 +37,7 @@ import org.simantics.sysdyn.modelImport.model.Shadow;
 import org.simantics.sysdyn.modelImport.model.Symbol;\r
 import org.simantics.sysdyn.modelImport.model.Valve;\r
 \r
-public class MdlParser {\r
+public class MdlParser implements IModelParser {\r
        \r
        private static final String UTF_8 = "{UTF-8}";\r
        private static final String SKETCH_VERSION = "V300";\r
@@ -48,7 +48,8 @@ public class MdlParser {
        private static final String PARAMETER_STOP = "FINAL TIME";\r
        private static final String PARAMETER_STEP = "TIME STEP";\r
 \r
-       public static Model parse(File file) throws Exception {\r
+       @Override\r
+       public Model parse(File file) throws Exception {\r
                // generate a mdl model based on the contents of the file\r
                MdlModel mdl = parseFile(file);\r
                \r
index ad63d0034f96aec58be9728a486850ceb1b8eaf2..2be6234efad03b187520a577b7f3839fac78e063 100644 (file)
@@ -158,22 +158,20 @@ public class MdlVariable extends Declaration {
        \r
        private static Range parseRange(String unit) {\r
                Matcher matcher = Pattern.compile(\r
-                       "\\["+MdlUtil.DBL_G+",(\\?|"+MdlUtil.DBL_G+"|"+MdlUtil.DBL_G+","+MdlUtil.DBL_G+")\\]"\r
+                       "\\[(\\?|"+MdlUtil.DBL+"),(\\?|"+MdlUtil.DBL+")(,(\\?|"+MdlUtil.DBL+"))?\\]"\r
                                ).matcher(unit);\r
                if (matcher.find()) {\r
-                       Double start, end, step;\r
-                       start = Double.parseDouble(matcher.group(1));\r
-                       if (matcher.group(2).equals("?")) {\r
-                               end = null;\r
-                               step = null;\r
+                       Double start = null;\r
+                       if (!matcher.group(1).equals("?")) {\r
+                               start = Double.parseDouble(matcher.group(1));\r
                        }\r
-                       else if (matcher.group(2).contains(",")){\r
-                               end = Double.parseDouble(matcher.group(4));\r
-                               step = Double.parseDouble(matcher.group(5));\r
+                       Double end = null;\r
+                       if (!matcher.group(2).equals("?")) {\r
+                               end = Double.parseDouble(matcher.group(2));\r
                        }\r
-                       else {\r
-                               end = Double.parseDouble(matcher.group(3));\r
-                               step = null;    \r
+                       Double step = null;\r
+                       if (matcher.group(3) != null && !matcher.group(4).equals("?")) {\r
+                               step = Double.parseDouble(matcher.group(4));\r
                        }\r
                        return new Range(start, end, step);\r
                }\r
index ef397f4e1c906b4fcd23e23fddce2839b4fd0519..156ec931bfd7a6c4c8179caaeed8ecb1e41c18d6 100644 (file)
@@ -125,14 +125,17 @@ public class SubscriptVariable extends MdlVariable {
                // bar[b] = 2\r
                // bar[c] = 3\r
                \r
+               // remove spaces, should maybe remove all whitespace\r
+               String exprstr = getExpressionString().replaceAll(" ", "");\r
+               \r
                valuearray:\r
                if (next == null) {\r
                        // number(,number)*\r
                        if (enumerations.size() == 1 && \r
-                                       Pattern.matches(MdlUtil.DBL+"(,"+MdlUtil.DBL+")*", getExpressionString())) {\r
+                                       Pattern.matches(MdlUtil.DBL+"(,"+MdlUtil.DBL+")*", exprstr)) {\r
                                EnumerationExpression expr = new EnumerationExpression(enumerations);\r
                                \r
-                               String[] values = getExpressionString().split(",");\r
+                               String[] values = exprstr.split(",");\r
                                if (enumerations.get(0).getValues().size() != values.length) {\r
                                        // could not find a value for each enumeration index, \r
                                        // attempt to parse the equation normally\r
@@ -148,10 +151,10 @@ public class SubscriptVariable extends MdlVariable {
                        }\r
                        // (number(,number)*;)*\r
                        else if (enumerations.size() == 2 && \r
-                                       Pattern.matches("("+MdlUtil.DBL+"(,"+MdlUtil.DBL+")*;)+", getExpressionString())) {\r
+                                       Pattern.matches("("+MdlUtil.DBL+"(,"+MdlUtil.DBL+")*;)+", exprstr)) {\r
                                EnumerationExpression expr = new EnumerationExpression(enumerations);\r
                                \r
-                               String[] rows = getExpressionString().split(";");\r
+                               String[] rows = exprstr.split(";");\r
                                if (enumerations.get(0).getValues().size() != rows.length) {\r
                                        // could not find a value for each enumeration index \r
                                        // in the first enumeration, attempt to parse the equation \r
index 14a82c8083acb06f5cc8b4f0d60bdd77cbf56bbf..5bfd82ae944db5215df9081c4fc0611d1c067d86 100644 (file)
@@ -156,6 +156,10 @@ public class Model implements IWriteableObject {
        public Collection<Function> getFunctions() {\r
                return functions.values();\r
        }\r
+       \r
+       public Resource write(WriteGraph graph, Resource project) throws DatabaseException {\r
+               return write(graph, project, new WriteContext());\r
+       }\r
 \r
        @Override\r
        public Resource write(WriteGraph graph, Resource parent, WriteContext context) throws DatabaseException {\r
index f2c0a1b7d54bddc6134c1f3ad3c25220f720896e..87dd09e2ca44985ddf162e99e77d34ebab700365 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2007, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2007, 2012, 2014 Association for Decentralized Information Management in\r
  * 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
@@ -99,24 +99,41 @@ public class ModelicaWriter {
 \r
                // find out which delays are used in the model and create the\r
                // necessary classes\r
-               HashSet<Integer> delays = new HashSet<Integer>();\r
+               List<String> generated = new ArrayList<String>();\r
                for (Configuration configuration : configurations) {\r
                        for (IElement element : configuration.getElements()) {\r
                                if (element instanceof IndependentVariable) {\r
-                                       for (IExpression expression : ((IndependentVariable)element).getExpressions()) {\r
+                                       IndependentVariable variable = (IndependentVariable)element;\r
+                                       for (IExpression expression : variable.getExpressions()) {\r
                                                if (expression instanceof DelayExpression) {\r
-                                                       delays.add(((DelayExpression)expression).getOrder());\r
+                                                       DelayExpression delay = (DelayExpression)expression;\r
+                                                       \r
+                                                       int order = delay.getOrder();                                                   \r
+                                                       int[] dimensions = null;\r
+                                                       \r
+                                                       // TODO: is it cool to assume an expression is in the array\r
+                                                       // shorthand form if the expression does not have an array range\r
+                                                       // even though the variable has array indices? (if this \r
+                                                       // assumption does not hold DelayExpression must be updated as well)\r
+                                                       \r
+                                                       if (expression.getArrayRange() == null) {\r
+                                                               dimensions = variable.getDimensionArray();\r
+                                                       }\r
+                                                       \r
+                                                       // create the appropriate delay class if it has not \r
+                                                       // been created already\r
+                                                       \r
+                                                       if (!generated.contains(getDelayName(order, dimensions))) {\r
+                                                               b.append(getDelayClass(order, dimensions));\r
+                                                               b.append("\n");\r
+                                                               generated.add(getDelayName(order, dimensions));\r
+                                                       }\r
                                                }\r
                                        }\r
                                }\r
                        }\r
                }\r
 \r
-               for (Integer i : delays) {\r
-                       b.append(getDelayClass(i));\r
-                       b.append("\n");\r
-               }\r
-\r
                HashSet<String> sheetNames = new HashSet<String>();\r
                for(Sheet sheet : getSpreadSheets(configurations))\r
                        sheetNames.add(sheet.getModelicaName());\r
@@ -212,11 +229,11 @@ public class ModelicaWriter {
                                // Module\r
                                Module m = (Module)element; \r
                                modules.add(m);\r
-                               moduleInputs.put(m.getName(), new ArrayList<Input>());\r
+                               moduleInputs.put(m.getModelicaName(), new ArrayList<Input>());\r
                                for(IElement e : m.getType().getConfiguration().getElements())\r
                                        // Inputs inside the module\r
                                        if(e instanceof Input && !((Input)e).isHeadOfDependency()) {\r
-                                               moduleInputs.get(m.getName()).add((Input)e);\r
+                                               moduleInputs.get(m.getModelicaName()).add((Input)e);\r
                                        }\r
                        } else if (element instanceof Input) {\r
                                // Input variables\r
@@ -245,7 +262,7 @@ public class ModelicaWriter {
                ModuleType mt = configuration.getModuleType();\r
 \r
                // className == null, if this is a model configuration. model configuration start and end are written in ModelicaWriter.write\r
-               String className = mt != null ? (mt.getName().replace(" ", "")) : null;\r
+               String className = mt != null ? (mt.getModelicaName()) : null;\r
 \r
                if(className != null)\r
                        b.append("class "+className+"\n");\r
@@ -335,8 +352,8 @@ public class ModelicaWriter {
                        Module module = (Module)dependency.getHead();\r
                        Input reference = (Input)dependency.refersTo();\r
                        if(reference != null && reference.getName() != null && (reference.getVariability() == null || reference.getVariability().isEmpty())) {\r
-                               b.append("    " + module.getName() + "." + reference.getModelicaName() + " = " + variable.getModelicaName() + ";\n");\r
-                               moduleInputs.get(module.getName()).remove(reference);\r
+                               b.append("    " + module.getModelicaName() + "." + reference.getModelicaName() + " = " + variable.getModelicaName() + ";\n");\r
+                               moduleInputs.get(module.getModelicaName()).remove(reference);\r
                        }\r
                }\r
 \r
@@ -352,7 +369,7 @@ public class ModelicaWriter {
                        if(configuration.isGameConfiguration() && !modules.isEmpty()) {\r
                                b.append("// Time values for module\n");\r
                                for(Module m : modules) {\r
-                                       b.append("    " + m.getName() + ".time = time;\n");\r
+                                       b.append("    " + m.getModelicaName() + ".time = time;\n");\r
                                }\r
                        }\r
                }\r
@@ -391,7 +408,7 @@ public class ModelicaWriter {
                        String expression;\r
                        // If reference exists, use reference name. Otherwise, use default value.\r
                        if(reference != null && reference.getName() != null)\r
-                               expression = module.getName() + "." + reference.getModelicaName() + ";\n";\r
+                               expression = module.getModelicaName() + "." + reference.getModelicaName() + ";\n";\r
 \r
                        else\r
                                expression = input.getDefaultInputValue() + ";\n";\r
@@ -445,28 +462,37 @@ public class ModelicaWriter {
        \r
        public static final String DELAY_TIME = "delayTime";\r
        public static final String DELAY_INITIAL = "initialValue";\r
-\r
-       private static String getDelayClass(int order) {\r
+       \r
+       private static String getDelayClass(int order, int...dimensions) {\r
+               boolean array = dimensions != null && dimensions.length > 0;\r
+               \r
                StringBuilder buffer = new StringBuilder();\r
 \r
-               buffer.append("class " + getDelayName(order) + "\n");\r
+               buffer.append("class ").append(getDelayName(order, dimensions)).append("\n");\r
 \r
                // variable block\r
 \r
                // (possibly) continuous auxiliary variable\r
-               buffer.append("\tReal DL;\n");\r
+               buffer.append('\t')\r
+                       .append(getReal("DL")).append(";\n");\r
                // (possibly) continuous delay time\r
-               buffer.append("\tReal " + DELAY_TIME + ";\n");\r
+               buffer.append('\t')\r
+                       .append(getReal(DELAY_TIME)).append(";\n");\r
                // (possibly) continuous initial value\r
-               buffer.append("\tReal " + DELAY_INITIAL + ";\n");\r
+               buffer.append('\t')\r
+                       .append(getReal(DELAY_INITIAL, dimensions)).append(";\n");\r
 \r
                // first valve\r
-               buffer.append("\tReal " + getDelayValve(0) + ";\n");\r
+               buffer.append('\t')\r
+                       .append(getReal(getDelayValve(0), dimensions)).append(";\n");\r
 \r
                // stocks and valves, valves are delayed values of the variable\r
                for (int i = 1; i <= order; i++) {\r
-                       buffer.append("\tReal LV"+i + "(fixed=false);\n");\r
-                       buffer.append("\tReal "+ getDelayValve(i) + ";\n");\r
+                       buffer.append('\t')\r
+                               .append(getReal("LV"+i, dimensions)).append(' ')\r
+                               .append("(" + (array ? "each " : "") + "fixed=false)").append(";\n");\r
+                       buffer.append('\t')\r
+                               .append(getReal(getDelayValve(i), dimensions)).append(";\n");\r
                }\r
 \r
                // initial equation block\r
@@ -474,29 +500,64 @@ public class ModelicaWriter {
 \r
                // Each stock gets the same initial value\r
                for (int i = 1; i <= order; i++) {\r
-                       buffer.append("\tLV"+i + " = DL * " + DELAY_INITIAL + ";\n");\r
+                       buffer.append('\t')\r
+                               .append("LV"+i)\r
+                               .append(" = ")\r
+                               .append("DL" + (array ? " .* " : " * ") + DELAY_INITIAL)\r
+                               .append(";\n");\r
                }\r
 \r
                // equation block\r
                buffer.append("equation\n");\r
                \r
-               buffer.append("\tDL = " + DELAY_TIME + " / "+order+";\n");\r
-\r
+               buffer.append('\t')\r
+                       .append("DL")\r
+                       .append(" = ")\r
+                       .append(DELAY_TIME +" / " + order)\r
+                       .append(";\n");\r
+               \r
                // valves and stocks\r
                for (int i = 1; i <= order; i++) {\r
-                       buffer.append("\tder(LV"+i + ") = - " + getDelayValve(i) + " + " + getDelayValve(i-1) + ";\n");\r
-                       buffer.append("\t"+ getDelayValve(i) + " = LV"+i + " / DL;\n");\r
+                       buffer.append('\t')\r
+                               .append("der(LV"+i + ")")\r
+                               .append(" = ")\r
+                               .append("-" + getDelayValve(i) + (array ? " .+ " : " + ") + getDelayValve(i-1))\r
+                               .append(";\n");\r
+                       buffer.append('\t')\r
+                               .append(getDelayValve(i))\r
+                               .append(" = ")\r
+                               .append("LV"+i + (array ? " ./ " : " / ") + "DL")\r
+                               .append(";\n");\r
                }\r
 \r
-               buffer.append("end ");\r
-               buffer.append(getDelayName(order));\r
-               buffer.append(";\n");\r
+               buffer.append("end ").append(getDelayName(order, dimensions)).append(";\n");\r
 \r
                return buffer.toString();\r
        }\r
-\r
-       public static String getDelayName(int order) {\r
-               return "order_"+order+"_delay";\r
+       \r
+       private static String getReal(String name, int...dims) {\r
+               StringBuilder buffer = new StringBuilder();\r
+               buffer.append("Real ").append(name);\r
+               if (dims != null && dims.length > 0) {\r
+                       buffer.append('[');\r
+                       for (int i = 0; i < dims.length; i++) {\r
+                               if (i > 0) buffer.append(',');\r
+                               buffer.append(dims[i]);\r
+                       }\r
+                       buffer.append(']');\r
+               }\r
+               return buffer.toString();\r
+       }\r
+       \r
+       public static String getDelayName(int order, int...dims) {\r
+               StringBuilder buffer = new StringBuilder();\r
+               buffer.append("o_").append(order).append('_');\r
+               if (dims != null && dims.length > 0) {\r
+                       buffer.append("d_");\r
+                       for (int dim : dims) buffer.append(dim).append('_');\r
+               }\r
+               buffer.append("delay");\r
+               return buffer.toString();\r
        }\r
        \r
        public static String getDelayValve(int order) {\r
index 3938f20051a41dd25abb5ddb556e5606e6c1bf11..e8908c9bb1642da3ce9a04d42cbb62899c65b41b 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2012, 2014 Association for Decentralized Information Management in\r
  * 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
@@ -58,6 +58,17 @@ public class Module implements IElement {
        public String getName() {\r
                return name;\r
        }\r
+       \r
+    /**\r
+     * Get Modelica compliant name\r
+     * @return The name of this variable with spaces (' ') replaced with \r
+     * underscore characters ('_')\r
+     */\r
+    public String getModelicaName() {\r
+       if (this.name == null)\r
+               return null;\r
+        return this.name.replace(' ', '_');\r
+    }\r
 \r
        public ModuleType getType() {\r
                return type;\r
@@ -114,9 +125,9 @@ public class Module implements IElement {
                }\r
 \r
                sb.append("    ");\r
-               sb.append(getType().getName());\r
+               sb.append(getType().getModelicaName());\r
                sb.append(" ");\r
-               sb.append(getName());\r
+               sb.append(getModelicaName());\r
                sb.append(redeclarations.toString()); // possible redeclarations\r
                sb.append(";\n");\r
                return sb.toString();\r
index bf7b84a9ff8a5617d04be25b43490f7c1b0b99a3..1dbabb0c94c7e08cdb6d12204ba9ac2db76ba2f5 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2012, 2014 Association for Decentralized Information Management in\r
  * 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
@@ -22,6 +22,7 @@ import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;
  * Representation of a module type\r
  * \r
  * @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
  *\r
  */\r
 @GraphType(StructuralResource2.URIs.ComponentType)\r
@@ -35,7 +36,18 @@ public class ModuleType implements IElement {
     \r
     @RelatedElement(Layer0.URIs.PartOf)\r
     protected Object parent;\r
-\r
+       \r
+    /**\r
+     * Get Modelica compliant name\r
+     * @return The name of this variable with spaces (' ') replaced with \r
+     * underscore characters ('_')\r
+     */\r
+    public String getModelicaName() {\r
+       if (this.name == null)\r
+               return null;\r
+        return this.name.replace(' ', '_');\r
+    }\r
+    \r
     public String getName() {\r
        return name;\r
     }\r
index 997e61db62f375b5c11427d712014b7c3961cb83..92b49941915a0dd87360ef780f813e439e849ff1 100644 (file)
@@ -114,6 +114,17 @@ public abstract class Variable implements IElement {
        return this.arrayIndexes;\r
     }\r
     \r
+    public int[] getDimensionArray() {\r
+       if (arrayIndexes == null)\r
+               return null;\r
+       \r
+       int[] dimensions = new int[arrayIndexes.size()];\r
+       for (int i = 0; i < arrayIndexes.size(); i++) {\r
+               dimensions[i] = arrayIndexes.get(i).getEnumerationIndexes().size();\r
+       }\r
+       return dimensions;\r
+    }\r
+    \r
     /**\r
      * \r
      * @return Expressions of this variable\r
index 4edf308950d77eb46d0538ebcec61cc4f42cfe66..6865e11262a3541d890728538173be94a95f0fe4 100644 (file)
@@ -65,7 +65,15 @@ public class DelayExpression extends Expression {
        @Override\r
        public String getDeclarationAddition() {\r
                // instantiate the correct delay class for this expression\r
-               return "\t" + ModelicaWriter.getDelayName(order) + " " + instance() + ";\n";\r
+               \r
+               // TODO: this is not necessary correct, see discussion in delay class \r
+               // generation code in ModelicaWriter.java\r
+               int[] dimensions = null;\r
+               if (getArrayRange() == null) {\r
+                       dimensions = getParent().getDimensionArray();\r
+               }\r
+               \r
+               return "\t" + ModelicaWriter.getDelayName(order, dimensions) + " " + instance() + ";\n";\r
        }\r
 \r
        @Override\r
index 7463bfccaae6b0adb825071af26413654d94d6fa..98c51a57b131363a11ce391a1cdfde7d33d96ccd 100644 (file)
@@ -67,10 +67,7 @@ public abstract class Expression implements IExpression {
     \r
     @Override\r
     public String getArrayRange() {\r
-       if(range == null)\r
-               return "";\r
-       else\r
-               return range;\r
+       return range;\r
     }\r
 \r
     @Override\r
@@ -80,7 +77,7 @@ public abstract class Expression implements IExpression {
     \r
     @Override\r
     public String validateUnits(ReadGraph graph, SysdynModel model) {\r
-        return UnitUtils.matchUnits(graph, model, parent.getParentConfiguration(), parent.getUnit(), getExpression());\r
+       return UnitUtils.matchUnits(graph, model, parent.getParentConfiguration(), parent.getUnit(), getExpression());\r
     }\r
     \r
     @Override\r
index 8418b14fe91cee2f3b4d7d35e9b8b406b4b02173..66566c80cd0678175c81c0326073bd9f85326bf7 100644 (file)
@@ -35,6 +35,7 @@ import org.simantics.sysdyn.representation.Module;
 import org.simantics.sysdyn.representation.Shadow;\r
 import org.simantics.sysdyn.representation.Variable;\r
 import org.simantics.sysdyn.unitParser.ParseException;\r
+import org.simantics.sysdyn.unitParser.TokenMgrError;\r
 import org.simantics.sysdyn.unitParser.UnitCheckingException;\r
 import org.simantics.sysdyn.unitParser.UnitCheckingNode;\r
 import org.simantics.sysdyn.unitParser.UnitParser;\r
@@ -128,6 +129,8 @@ public class UnitUtils {
             }\r
         } catch (ParseException e) {\r
                return "Cannot validate units: Syntax error in expression.";\r
+       } catch (TokenMgrError e) {\r
+               return "Cannot validate units: Syntax error in expression.";\r
         }\r
         return null;\r
     }\r
index b3e8fb06117eefa4459d363b6c75d806e3301de2..65ec03b9f53132ecfa19b4f7951062fdd9e2500e 100644 (file)
@@ -1,7 +1,6 @@
 package org.simantics.sysdyn.solver;\r
 \r
-import org.eclipse.core.runtime.preferences.ConfigurationScope;\r
-import org.osgi.service.prefs.Preferences;\r
+import org.eclipse.core.runtime.Platform;\r
 \r
 public class SolverSettings {\r
        \r
@@ -16,10 +15,13 @@ public class SolverSettings {
        public static final String SOLVER_TYPE_OPENMODELICA = "OPENMODELICA";\r
        \r
        public static SolverType getSelectedSolverType() {\r
-               Preferences preferences = ConfigurationScope.INSTANCE.getNode(SolverSettings.QUALIFIER);\r
-               // default to internal solver\r
-               String type = preferences.get(SolverSettings.SOLVER_TYPE, SolverSettings.SOLVER_TYPE_INTERNAL);\r
+               String type = Platform.getPreferencesService().getString(QUALIFIER, SOLVER_TYPE, null, null);\r
                \r
+               if (type == null) {\r
+                       // solver type is not set, should not happen since the default \r
+                       // value should be in plugin_customization.ini\r
+                       return SolverType.OPENMODELICA;\r
+               }\r
                if (SOLVER_TYPE_INTERNAL.equals(type)) {\r
                        return SolverType.INTERNAL;\r
                }\r
index 28ec9bf63d30876ba1c70d162eb4bf4281f388db..b8b06837bb56871ae0ae391a4f597a4af2fc4303 100644 (file)
@@ -16,6 +16,7 @@ import org.simantics.databoard.Bindings;
 import org.simantics.databoard.util.Base64;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.BinaryRead;\r
 import org.simantics.db.common.request.ObjectsWithSupertype;\r
 import org.simantics.db.common.request.UniqueRead;\r
 import org.simantics.db.common.request.WriteRequest;\r
@@ -558,11 +559,17 @@ public class DocumentationUtils {
        \r
     }\r
 \r
-    public static org.simantics.db.layer0.variable.Variable lastValue2(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException {\r
+    public static org.simantics.db.layer0.variable.Variable lastValue2(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException {\r
        \r
-       if(run == null) return null;\r
+       if(input == null) return null;\r
+       \r
+       org.simantics.db.layer0.variable.Variable context = Variables.getPossibleContext(graph, input);\r
+       if(context == null) {\r
+               context = Variables.getConfigurationContext(graph, input);\r
+               if(context == null) return null;\r
+       }\r
 \r
-       org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + path);\r
+       org.simantics.db.layer0.variable.Variable v = context.browsePossible(graph, "/" + path);\r
        if(v == null) return null;\r
 \r
        org.simantics.db.layer0.variable.Variable p = v.browsePossible(graph, "#value#$0");\r
@@ -572,6 +579,26 @@ public class DocumentationUtils {
        \r
     }\r
 \r
+    public static org.simantics.db.layer0.variable.Variable currentValue(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException {\r
+       \r
+       if(input == null) return null;\r
+       \r
+       org.simantics.db.layer0.variable.Variable context = Variables.getPossibleContext(graph, input);\r
+       if(context == null) {\r
+               context = Variables.getConfigurationContext(graph, input);\r
+               if(context == null) return null;\r
+       }\r
+\r
+       org.simantics.db.layer0.variable.Variable v = context.browsePossible(graph, "/" + path);\r
+       if(v == null) return null;\r
+\r
+       org.simantics.db.layer0.variable.Variable p = v.browsePossible(graph, "#value#$0");\r
+       if(p == null) return null;\r
+       \r
+       return p;\r
+       \r
+    }\r
+    \r
     /**\r
      * Splits indexed variable reference into name and indices part.\r
      * \r
@@ -591,23 +618,40 @@ public class DocumentationUtils {
 \r
     }\r
     \r
-    public static org.simantics.db.layer0.variable.Variable lastValueIndexed(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException {\r
-       \r
-       if(run == null) return null;\r
+    public static class LastValueIndexed extends BinaryRead<Resource, String, org.simantics.db.layer0.variable.Variable> {\r
 \r
-       Pair<String, String> nameAndIndices = splitToNameAndIndices(path);\r
+        public LastValueIndexed(Resource resource, String path) {\r
+            super(resource, path);\r
+        }\r
 \r
-       org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second);\r
-       if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + path);\r
-       \r
-       return v;\r
+        @Override\r
+        public org.simantics.db.layer0.variable.Variable perform(ReadGraph graph) throws DatabaseException {\r
+            \r
+            org.simantics.db.layer0.variable.Variable run = Variables.getVariable(graph, parameter);\r
+            Pair<String, String> nameAndIndices = splitToNameAndIndices(parameter2);\r
+            org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + nameAndIndices.first + "#value#" + nameAndIndices.second);\r
+            if(v == null) throw new MissingVariableException("No variable for SysDyn reference path: " + parameter2);\r
+            return v;\r
+        }\r
+    }\r
+    \r
+    \r
+    public static org.simantics.db.layer0.variable.Variable lastValueIndexed(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException {\r
+       if(run == null) return null;\r
+       return graph.syncRequest(new LastValueIndexed(run.getRepresents(graph), path));\r
     }    \r
     \r
-    public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable run, String path) throws DatabaseException {\r
+    public static org.simantics.db.layer0.variable.Variable equation(ReadGraph graph, org.simantics.db.layer0.variable.Variable input, String path) throws DatabaseException {\r
 \r
-       if(run == null) return null;\r
+       if(input == null) return null;\r
+       \r
+       org.simantics.db.layer0.variable.Variable context = Variables.getPossibleContext(graph, input);\r
+       if(context == null) {\r
+               context = Variables.getConfigurationContext(graph, input);\r
+               if(context == null) return null;\r
+       }\r
        \r
-       org.simantics.db.layer0.variable.Variable v = run.browsePossible(graph, "/" + path);\r
+       org.simantics.db.layer0.variable.Variable v = context.browsePossible(graph, "/" + path);\r
        if(v == null) return null;\r
 \r
        org.simantics.db.layer0.variable.Variable p = v.browsePossible(graph, "#equation");\r
index ceeff8aaefb53262cfa14a45a6e3a15a99e42fac..18be49f708d1ef6ce3624aea23e6f4351c295af7 100644 (file)
@@ -173,7 +173,7 @@ public class ImportUtils {
             for(ModelDependency dependency : dependenciesBean.dependencies) {\r
                 Resource existing = session.sync(new PossibleResource(dependency.uri));\r
                 if(existing == null) {\r
-                    MigrationUtils.importSharedOntology(session, dependency.tg);\r
+                    MigrationUtils.importSharedOntology(session, dependency.tg, false);\r
                 }\r
             }\r
         }\r