]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
First take on user-defined functions
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 23 Mar 2011 11:25:21 +0000 (11:25 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Wed, 23 Mar 2011 11:25:21 +0000 (11:25 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@20188 ac1ea38d-2e2b-0410-8846-a27921b304fc

44 files changed:
org.simantics.modelica/src/org/simantics/modelica/ModelicaManager.java
org.simantics.objmap/src/org/simantics/objmap/schema/SimpleLinkType.java
org.simantics.objmap/src/org/simantics/objmap/schema/SimpleSchema.java
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ontology/graph/SysdynFunctions.pgraph [new file with mode: 0644]
org.simantics.sysdyn.ontology/graph/WorkModel.pgraph
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Functions.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionsLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Model.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionsFolder.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportExternalFunctionFilesHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportExternalFunctionFilesHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewExperimentNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewModuleNodeHandler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/SysdynExperimentActivator.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/EquationTab.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExternalFilesTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ChartTableWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ChartWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/ExpressionWidget.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/FunctionLabelFactory.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/BasicExpression.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/LookupInputOutputTable.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/expressions/WithLookupExpression.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileImager.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileLabeler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFiles.java [new file with mode: 0644]
org.simantics.sysdyn/META-INF/MANIFEST.MF
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/FunctionUtils.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperiment.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/StockExpression.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/expressions/WithLookupExpression.java

index 2cde76e9533b0b76e1eede5a671e3a5aa93c9468..2137e9e51c3f9351da9e30b5ba53f17b607c6ee0 100644 (file)
@@ -165,7 +165,7 @@ public class ModelicaManager {
 \r
        }\r
 \r
-       public static SimulationLocation createInputFiles(File simulationDir, String modelName, String modelText, HashMap<String, String> inits) throws IOException {\r
+       public static SimulationLocation createInputFiles(File simulationDir, String modelName, String modelText, HashMap<String, String> inits, String additionalScript) throws IOException {\r
                System.out.println(simulationDir.getAbsolutePath());\r
                modelName = modelName.replace(" ", "");\r
                File modelFile = new File(simulationDir, modelName + ".mo");\r
@@ -179,11 +179,14 @@ public class ModelicaManager {
 \r
                {\r
                        PrintStream s = new PrintStream(scriptFile);\r
+                       if(additionalScript != null)\r
+                               s.println(additionalScript);\r
                        s.println("loadFile(\"" + modelName + ".mo\");");\r
                        s.print("buildModel("+modelName+\r
                                        ",startTime="+inits.get("start value")+\r
                                        ",stopTime="+inits.get("stop value")+\r
-                                       ",method="+inits.get("method")\r
+                                       ",method="+inits.get("method")+\r
+                                       ",outputFormat=\"plt\""\r
                        );\r
                        if(inits.containsKey("tolerance")) {\r
                                s.print(",tolerance="+inits.get("tolerance"));\r
index f0366ca402b3258ca6d743f41a98a9be2f07288d..3d7b4aade274db7db604a5fc48507b8d25368268 100644 (file)
@@ -17,8 +17,8 @@ import org.apache.log4j.Logger;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\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.layer0.utils.direct.GraphUtils;\r
 import org.simantics.objmap.IFunction;\r
 import org.simantics.objmap.ILinkType;\r
 import org.simantics.objmap.IMappingRule;\r
@@ -79,7 +79,7 @@ public class SimpleLinkType implements ILinkType {
             if(LOGGER.isInfoEnabled())\r
                 try { \r
                     LOGGER.info("SimpleLinkType.createRangeElement " +\r
-                            GraphUtils.getReadableName(g, domainElement)\r
+                               NameUtils.getSafeName(g, domainElement)\r
                             );\r
                 } catch(DatabaseException e) {\r
                     throw new MappingException(e);\r
@@ -98,7 +98,7 @@ public class SimpleLinkType implements ILinkType {
         if(LOGGER.isInfoEnabled())\r
             try { \r
                 LOGGER.info("SimpleLinkType.updateDomain " +\r
-                        GraphUtils.getReadableName(g, domainElement) + " " +\r
+                        NameUtils.getSafeName(g, domainElement) + " " +\r
                         rangeElement.toString()\r
                         );\r
             } catch(DatabaseException e) {\r
@@ -117,7 +117,7 @@ public class SimpleLinkType implements ILinkType {
         if(LOGGER.isInfoEnabled())\r
             try { \r
                 LOGGER.info("SimpleLinkType.updateRange " +\r
-                        GraphUtils.getReadableName(g, domainElement) + " " +\r
+                               NameUtils.getSafeName(g, domainElement) + " " +\r
                         rangeElement.toString()\r
                         );\r
             } catch(DatabaseException e) {\r
index 9c77925134b661a3ddcda8fb42bf64f2ced90bf3..5c15c009fa93d921e1cc095ffec040ae06249789 100644 (file)
@@ -13,12 +13,10 @@ package org.simantics.objmap.schema;
 \r
 import gnu.trove.THashMap;\r
 \r
-import java.util.Set;\r
-\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.objmap.ILinkType;\r
 import org.simantics.objmap.IMappingSchema;\r
 import org.simantics.objmap.MappingException;\r
@@ -54,7 +52,7 @@ public class SimpleSchema implements IMappingSchema {
                }\r
                \r
                throw new MappingException("Didn't find a link type for " +\r
-                               GraphUtils.getReadableName(g, element) + ".");\r
+                               NameUtils.getSafeName(g, element) + ".");\r
                                \r
         } catch (DatabaseException e) {\r
             throw new MappingException(e);\r
index 26fe477257822f243d7aa7329c77ccfe52678f94..4c21a0a3ef21d6786453dba68e6154776fe48aff 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index 04b8db89960459c81c5021e235ab016269ff56d9..b0bdaa2427a0f9a8980a7cd6972fa045f6416c02 100644 (file)
@@ -296,6 +296,25 @@ SYSDYN.Redeclaration <T L0.Entity
     
 SYSDYN.HasRedeclaration <R L0.IsComposedOf
     L0.HasRange SYSDYN.Redeclaration
+    
+//#####################################################################
+// Functions
+//#####################################################################    
+
+SYSDYN.SysdynModelicaFunction <T L0.Entity
+    @L0.singleProperty L0.HasName
+    @L0.singleProperty SYSDYN.HasModelicaFunctionCode
+    @L0.optionalProperty L0.HasDescription
+    
+SYSDYN.HasModelicaFunctionCode <R L0.HasProperty : L0.FunctionalRelation
+     L0.HasRange L0.String
+       
+SYSDYN.ExternalFunctionFile <T L0.Entity
+    @L0.singleProperty L0.HasName
+    @L0.singleProperty SYSDYN.HasExternalFile
+
+SYSDYN.HasExternalFile <R L0.HasProperty
+    L0.HasRange L0.ByteArray
 
     
 //#####################################################################
@@ -329,6 +348,13 @@ SYSDYN.HasParameterFile <R L0.HasProperty
 
 SYSDYN.HasResultFile <R L0.HasProperty
     L0.HasRange L0.String
+    
+    
+//#####################################################################
+//#####################################################################
+//################              DIAGRAM               #################
+//#####################################################################
+//#####################################################################    
 
 //#####################################################################
 // Component types
diff --git a/org.simantics.sysdyn.ontology/graph/SysdynFunctions.pgraph b/org.simantics.sysdyn.ontology/graph/SysdynFunctions.pgraph
new file mode 100644 (file)
index 0000000..18a279f
--- /dev/null
@@ -0,0 +1,78 @@
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+SYSDYN = <http://www.simantics.org/Sysdyn-1.0>\r
+\r
+FL = <http://www.simantics.org/Sysdyn-1.0/BasicFunctions> : L0.Library\r
+\r
+\r
+FL.xidz : SYSDYN.SysdynModelicaFunction\r
+    L0.HasDescription "X if divided by zero"\r
+    SYSDYN.HasModelicaFunctionCode """    input Real a;\r
+       input Real b;\r
+       input Real x;\r
+       output Real z;\r
+algorithm\r
+       if b > 0.0 or b < 0.0 then\r
+           z := a / b;\r
+       else\r
+           z := x;\r
+       end if;"""\r
+\r
+FL.zidz : SYSDYN.SysdynModelicaFunction\r
+    L0.HasDescription "Zero if divided by zero"\r
+    SYSDYN.HasModelicaFunctionCode """    input Real a;\r
+    input Real b;\r
+    output Real z;\r
+algorithm\r
+    z := xidz(a,b,0.0);"""\r
+\r
+FL.interpolate : SYSDYN.SysdynModelicaFunction\r
+    L0.HasDescription "Interpolate function for two-dimensional table"\r
+    SYSDYN.HasModelicaFunctionCode """    input Real u "input value (first column of table)";\r
+    input Real table[:, :] "table to be interpolated";\r
+    output Real y "interpolated input value (icol column of table)";\r
+algorithm\r
+    y := interpolateFull(u, table, 2);"""\r
+    \r
+    \r
+FL.interpolateFull : SYSDYN.SysdynModelicaFunction\r
+    L0.HasDescription "The full interpolate function"\r
+    SYSDYN.HasModelicaFunctionCode """    input Real u "input value (first column of table)";\r
+    input Real table[:, :] "table to be interpolated";\r
+    input Integer icol "column of table to be interpolated";\r
+    output Real y "interpolated input value (icol column of table)";\r
+protected \r
+    Integer i;\r
+    Integer n "number of rows of table";\r
+    Real u1;\r
+    Real u2;\r
+    Real y1;\r
+    Real y2;\r
+algorithm \r
+    n := size(table, 1);\r
+    if n <= 1 then\r
+        y := table[1, icol];\r
+    else\r
+        /* Search interval */\r
+        if u <= table[1, 1] then\r
+            i := 1;\r
+        else\r
+            i := 2;\r
+            while i < n and u > table[i, 1] loop\r
+                i := i + 1;\r
+            end while;\r
+            i := i - 1;\r
+        end if;\r
+\r
+        /* Get interpolation data */\r
+        u1 := table[i, 1];\r
+        u2 := table[i + 1, 1];\r
+        y1 := table[i, icol];\r
+        y2 := table[i + 1, icol];\r
+        /* Interpolate */\r
+        if u1 >= u2 then\r
+            y := y1;\r
+            /* since not possible to throw error */\r
+        else\r
+            y := y1 + (y2 - y1)*(u - u1)/(u2 - u1);\r
+        end if;\r
+    end if;"""
\ No newline at end of file
index f6f742caf4f99eaf43291586f9d729b6f5c8c0f3..4670d952a119b83d598c22154d94fe819f606352 100644 (file)
@@ -18,11 +18,16 @@ WM = <http://www.simantics.org/Sysdyn-1.0/WorkModel> : PROJ.Project
     L0.PartOf <http://Projects>\r
 */\r
 \r
-WM = <http://www.simantics.org/Sysdyn-1.0/DevelopmentProject> : PROJ.Project\r
+WORKMODEL = <http://www.simantics.org/WorkModel> : L0.Ontology\r
+    @L0.new\r
+    \r
+WORKMODEL.WM : PROJ.Project\r
     PROJ.HasFeature _ : PROJ.FeatureSpec\r
         PROJ.HasGroupId "org.simantics.sysdyn.feature.group"\r
     L0.PartOf <http://Projects>\r
 \r
+WM = WORKMODEL.WM\r
+\r
 TAGS = WM.Tags : L0.Library\r
    \r
     \r
index 789b2e70ed89ffa3a8581cbef0a085060612630b..ad496fe540bcf5ab5b3bdacd8f4b7801b16c813c 100644 (file)
@@ -13,6 +13,11 @@ public class SysdynResource {
     public final Resource Auxiliary;\r
     public final Resource AuxiliarySymbol;\r
     public final Resource BasicExperiment;\r
+    public final Resource BasicFunctions;\r
+    public final Resource BasicFunctions_interpolate;\r
+    public final Resource BasicFunctions_interpolateFull;\r
+    public final Resource BasicFunctions_xidz;\r
+    public final Resource BasicFunctions_zidz;\r
     public final Resource Cloud;\r
     public final Resource CloudSymbol;\r
     public final Resource Configuration;\r
@@ -22,116 +27,6 @@ public class SysdynResource {
     public final Resource DelayExpression;\r
     public final Resource Dependency;\r
     public final Resource DependencyConnection;\r
-    public final Resource DevelopmentProject;\r
-    public final Resource DevelopmentProject_Admin;\r
-    public final Resource DevelopmentProject_Tags;\r
-    public final Resource DevelopmentProject_Tags_AdminIsFocusable;\r
-    public final Resource DevelopmentProject_Tags_AdminIsVisible;\r
-    public final Resource DevelopmentProject_WorkModel;\r
-    public final Resource DevelopmentProject_WorkModel_Experiment;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_EnumerationTest;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeed1;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeed2;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeedTotal;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_TotalPossibleWorkingSpeedInput;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_Work1;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_Work1CompletionTime;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_Work1WorkDone;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_Work2;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_Work2Amount;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_Work2CompletionTime;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_Work2WorkDone;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_Workforce;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d1;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d10;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d11;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d12;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d13;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d14;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d15;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d2;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d3;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d4;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d5;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d6;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d7;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d8;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModelConfiguration_d9;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModule;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_Errors;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsFoundRate;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsFoundTime;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsGenerated;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_MaximumWorkingSpeed;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_PossibleWorkingSpeedInput;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectIsReady;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectReadyness;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectWorkAmount;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_RequiredWorkingSpeed;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_RequiredWorkingSpeedTotalInput;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_TimeToDeadline;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkAllocation;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkCompletionTimeInput;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkDone;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkQuality;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkToDo;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkingSpeed;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_c31;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_c33;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d31;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d32;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d33;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d34;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d35;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d36;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d37;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d38;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d40;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d41;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d42;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d43;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d44;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d45;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d46;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d47;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d48;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_d49;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_f31;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_f32;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_f33;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_f34;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_f35;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_f36;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_f37;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_f40;\r
-    public final Resource DevelopmentProject_WorkModel_WorkModuleConfiguration_f41;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModule;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_NetResources;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_PossibleWorkingSpeed;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_Productivity;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_RequiredWorkingSpeedInput;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_TimeToAllocateResources;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_WorkForceRequired;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_WorkforceStock;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_c21;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d21;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d22;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d23;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d24;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d25;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d26;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d27;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_f21;\r
-    public final Resource DevelopmentProject_WorkModel_WorkforceModuleConfiguration_f22;\r
-    public final Resource DevelopmentProject_WorkSymbol;\r
-    public final Resource DevelopmentProject_WorkforceSymbol;\r
-    public final Resource DevelopmentProject_conf_dependency;\r
-    public final Resource DevelopmentProject_conf_dependency_ref;\r
-    public final Resource DevelopmentProject_dependency;\r
-    public final Resource DevelopmentProject_flow;\r
     public final Resource DiagramToCompositeMapping;\r
     public final Resource Enumeration;\r
     public final Resource EnumerationIndex;\r
@@ -141,6 +36,7 @@ public class SysdynResource {
     public final Resource Expression;\r
     public final Resource Expressions;\r
     public final Resource Expressions_Inverse;\r
+    public final Resource ExternalFunctionFile;\r
     public final Resource Flow;\r
     public final Resource FlowConnection;\r
     public final Resource GameExperiment;\r
@@ -158,6 +54,8 @@ public class SysdynResource {
     public final Resource HasEquation_Inverse;\r
     public final Resource HasExpressions;\r
     public final Resource HasExpressions_Inverse;\r
+    public final Resource HasExternalFile;\r
+    public final Resource HasExternalFile_Inverse;\r
     public final Resource HasHead;\r
     public final Resource HasHeadTerminal;\r
     public final Resource HasInitialEquation;\r
@@ -172,6 +70,8 @@ public class SysdynResource {
     public final Resource HasMinX_Inverse;\r
     public final Resource HasMinY;\r
     public final Resource HasMinY_Inverse;\r
+    public final Resource HasModelicaFunctionCode;\r
+    public final Resource HasModelicaFunctionCode_Inverse;\r
     public final Resource HasOutputInterval;\r
     public final Resource HasOutputInterval_Inverse;\r
     public final Resource HasParameterFile;\r
@@ -236,6 +136,7 @@ public class SysdynResource {
     public final Resource SysdynConnectionType;\r
     public final Resource SysdynDiagramModelingRules;\r
     public final Resource SysdynModel;\r
+    public final Resource SysdynModelicaFunction;\r
     public final Resource SysdynTerminal;\r
     public final Resource Valve;\r
     public final Resource ValveSymbol;\r
@@ -250,6 +151,11 @@ public class SysdynResource {
         public static final String Auxiliary = "http://www.simantics.org/Sysdyn-1.0/Auxiliary";\r
         public static final String AuxiliarySymbol = "http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol";\r
         public static final String BasicExperiment = "http://www.simantics.org/Sysdyn-1.0/BasicExperiment";\r
+        public static final String BasicFunctions = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions";\r
+        public static final String BasicFunctions_interpolate = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions/interpolate";\r
+        public static final String BasicFunctions_interpolateFull = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions/interpolateFull";\r
+        public static final String BasicFunctions_xidz = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions/xidz";\r
+        public static final String BasicFunctions_zidz = "http://www.simantics.org/Sysdyn-1.0/BasicFunctions/zidz";\r
         public static final String Cloud = "http://www.simantics.org/Sysdyn-1.0/Cloud";\r
         public static final String CloudSymbol = "http://www.simantics.org/Sysdyn-1.0/CloudSymbol";\r
         public static final String Configuration = "http://www.simantics.org/Sysdyn-1.0/Configuration";\r
@@ -259,116 +165,6 @@ public class SysdynResource {
         public static final String DelayExpression = "http://www.simantics.org/Sysdyn-1.0/DelayExpression";\r
         public static final String Dependency = "http://www.simantics.org/Sysdyn-1.0/Dependency";\r
         public static final String DependencyConnection = "http://www.simantics.org/Sysdyn-1.0/DependencyConnection";\r
-        public static final String DevelopmentProject = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject";\r
-        public static final String DevelopmentProject_Admin = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/Admin";\r
-        public static final String DevelopmentProject_Tags = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/Tags";\r
-        public static final String DevelopmentProject_Tags_AdminIsFocusable = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/Tags/AdminIsFocusable";\r
-        public static final String DevelopmentProject_Tags_AdminIsVisible = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/Tags/AdminIsVisible";\r
-        public static final String DevelopmentProject_WorkModel = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel";\r
-        public static final String DevelopmentProject_WorkModel_Experiment = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/Experiment";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_EnumerationTest = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/EnumerationTest";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeed1 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/RequiredWorkingSpeed1";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeed2 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/RequiredWorkingSpeed2";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeedTotal = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/RequiredWorkingSpeedTotal";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_TotalPossibleWorkingSpeedInput = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/TotalPossibleWorkingSpeedInput";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_Work1 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/Work1";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_Work1CompletionTime = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/Work1CompletionTime";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_Work1WorkDone = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/Work1WorkDone";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_Work2 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/Work2";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_Work2Amount = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/Work2Amount";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_Work2CompletionTime = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/Work2CompletionTime";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_Work2WorkDone = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/Work2WorkDone";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_Workforce = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/Workforce";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d1 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d1";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d10 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d10";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d11 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d11";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d12 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d12";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d13 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d13";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d14 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d14";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d15 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d15";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d2 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d2";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d3 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d3";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d4 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d4";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d5 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d5";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d6 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d6";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d7 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d7";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d8 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d8";\r
-        public static final String DevelopmentProject_WorkModel_WorkModelConfiguration_d9 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModelConfiguration/d9";\r
-        public static final String DevelopmentProject_WorkModel_WorkModule = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModule";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_Errors = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/Errors";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsFoundRate = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/ErrorsFoundRate";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsFoundTime = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/ErrorsFoundTime";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsGenerated = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/ErrorsGenerated";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_MaximumWorkingSpeed = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/MaximumWorkingSpeed";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_PossibleWorkingSpeedInput = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/PossibleWorkingSpeedInput";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectIsReady = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/ProjectIsReady";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectReadyness = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/ProjectReadyness";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectWorkAmount = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/ProjectWorkAmount";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_RequiredWorkingSpeed = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/RequiredWorkingSpeed";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_RequiredWorkingSpeedTotalInput = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/RequiredWorkingSpeedTotalInput";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_TimeToDeadline = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/TimeToDeadline";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkAllocation = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/WorkAllocation";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkCompletionTimeInput = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/WorkCompletionTimeInput";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkDone = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/WorkDone";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkQuality = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/WorkQuality";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkToDo = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/WorkToDo";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkingSpeed = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/WorkingSpeed";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_c31 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/c31";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_c33 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/c33";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d31 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d31";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d32 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d32";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d33 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d33";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d34 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d34";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d35 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d35";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d36 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d36";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d37 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d37";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d38 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d38";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d40 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d40";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d41 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d41";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d42 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d42";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d43 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d43";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d44 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d44";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d45 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d45";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d46 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d46";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d47 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d47";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d48 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d48";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_d49 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/d49";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_f31 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/f31";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_f32 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/f32";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_f33 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/f33";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_f34 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/f34";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_f35 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/f35";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_f36 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/f36";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_f37 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/f37";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_f40 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/f40";\r
-        public static final String DevelopmentProject_WorkModel_WorkModuleConfiguration_f41 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkModuleConfiguration/f41";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModule = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModule";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_NetResources = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/NetResources";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_PossibleWorkingSpeed = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/PossibleWorkingSpeed";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_Productivity = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/Productivity";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_RequiredWorkingSpeedInput = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/RequiredWorkingSpeedInput";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_TimeToAllocateResources = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/TimeToAllocateResources";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_WorkForceRequired = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/WorkForceRequired";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_WorkforceStock = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/WorkforceStock";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_c21 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/c21";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d21 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/d21";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d22 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/d22";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d23 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/d23";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d24 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/d24";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d25 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/d25";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d26 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/d26";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d27 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/d27";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_f21 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/f21";\r
-        public static final String DevelopmentProject_WorkModel_WorkforceModuleConfiguration_f22 = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkModel/WorkforceModuleConfiguration/f22";\r
-        public static final String DevelopmentProject_WorkSymbol = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkSymbol";\r
-        public static final String DevelopmentProject_WorkforceSymbol = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/WorkforceSymbol";\r
-        public static final String DevelopmentProject_conf_dependency = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/conf_dependency";\r
-        public static final String DevelopmentProject_conf_dependency_ref = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/conf_dependency_ref";\r
-        public static final String DevelopmentProject_dependency = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/dependency";\r
-        public static final String DevelopmentProject_flow = "http://www.simantics.org/Sysdyn-1.0/DevelopmentProject/flow";\r
         public static final String DiagramToCompositeMapping = "http://www.simantics.org/Sysdyn-1.0/DiagramToCompositeMapping";\r
         public static final String Enumeration = "http://www.simantics.org/Sysdyn-1.0/Enumeration";\r
         public static final String EnumerationIndex = "http://www.simantics.org/Sysdyn-1.0/EnumerationIndex";\r
@@ -378,6 +174,7 @@ public class SysdynResource {
         public static final String Expression = "http://www.simantics.org/Sysdyn-1.0/Expression";\r
         public static final String Expressions = "http://www.simantics.org/Sysdyn-1.0/Expressions";\r
         public static final String Expressions_Inverse = "http://www.simantics.org/Sysdyn-1.0/Expressions/Inverse";\r
+        public static final String ExternalFunctionFile = "http://www.simantics.org/Sysdyn-1.0/ExternalFunctionFile";\r
         public static final String Flow = "http://www.simantics.org/Sysdyn-1.0/Flow";\r
         public static final String FlowConnection = "http://www.simantics.org/Sysdyn-1.0/FlowConnection";\r
         public static final String GameExperiment = "http://www.simantics.org/Sysdyn-1.0/GameExperiment";\r
@@ -395,6 +192,8 @@ public class SysdynResource {
         public static final String HasEquation_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasEquation/Inverse";\r
         public static final String HasExpressions = "http://www.simantics.org/Sysdyn-1.0/HasExpressions";\r
         public static final String HasExpressions_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasExpressions/Inverse";\r
+        public static final String HasExternalFile = "http://www.simantics.org/Sysdyn-1.0/HasExternalFile";\r
+        public static final String HasExternalFile_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasExternalFile/Inverse";\r
         public static final String HasHead = "http://www.simantics.org/Sysdyn-1.0/HasHead";\r
         public static final String HasHeadTerminal = "http://www.simantics.org/Sysdyn-1.0/HasHeadTerminal";\r
         public static final String HasInitialEquation = "http://www.simantics.org/Sysdyn-1.0/HasInitialEquation";\r
@@ -409,6 +208,8 @@ public class SysdynResource {
         public static final String HasMinX_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasMinX/Inverse";\r
         public static final String HasMinY = "http://www.simantics.org/Sysdyn-1.0/HasMinY";\r
         public static final String HasMinY_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasMinY/Inverse";\r
+        public static final String HasModelicaFunctionCode = "http://www.simantics.org/Sysdyn-1.0/HasModelicaFunctionCode";\r
+        public static final String HasModelicaFunctionCode_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasModelicaFunctionCode/Inverse";\r
         public static final String HasOutputInterval = "http://www.simantics.org/Sysdyn-1.0/HasOutputInterval";\r
         public static final String HasOutputInterval_Inverse = "http://www.simantics.org/Sysdyn-1.0/HasOutputInterval/Inverse";\r
         public static final String HasParameterFile = "http://www.simantics.org/Sysdyn-1.0/HasParameterFile";\r
@@ -473,6 +274,7 @@ public class SysdynResource {
         public static final String SysdynConnectionType = "http://www.simantics.org/Sysdyn-1.0/SysdynConnectionType";\r
         public static final String SysdynDiagramModelingRules = "http://www.simantics.org/Sysdyn-1.0/SysdynDiagramModelingRules";\r
         public static final String SysdynModel = "http://www.simantics.org/Sysdyn-1.0/SysdynModel";\r
+        public static final String SysdynModelicaFunction = "http://www.simantics.org/Sysdyn-1.0/SysdynModelicaFunction";\r
         public static final String SysdynTerminal = "http://www.simantics.org/Sysdyn-1.0/SysdynTerminal";\r
         public static final String Valve = "http://www.simantics.org/Sysdyn-1.0/Valve";\r
         public static final String ValveSymbol = "http://www.simantics.org/Sysdyn-1.0/ValveSymbol";\r
@@ -497,6 +299,11 @@ public class SysdynResource {
         Auxiliary = getResourceOrNull(graph, URIs.Auxiliary);\r
         AuxiliarySymbol = getResourceOrNull(graph, URIs.AuxiliarySymbol);\r
         BasicExperiment = getResourceOrNull(graph, URIs.BasicExperiment);\r
+        BasicFunctions = getResourceOrNull(graph, URIs.BasicFunctions);\r
+        BasicFunctions_interpolate = getResourceOrNull(graph, URIs.BasicFunctions_interpolate);\r
+        BasicFunctions_interpolateFull = getResourceOrNull(graph, URIs.BasicFunctions_interpolateFull);\r
+        BasicFunctions_xidz = getResourceOrNull(graph, URIs.BasicFunctions_xidz);\r
+        BasicFunctions_zidz = getResourceOrNull(graph, URIs.BasicFunctions_zidz);\r
         Cloud = getResourceOrNull(graph, URIs.Cloud);\r
         CloudSymbol = getResourceOrNull(graph, URIs.CloudSymbol);\r
         Configuration = getResourceOrNull(graph, URIs.Configuration);\r
@@ -506,116 +313,6 @@ public class SysdynResource {
         DelayExpression = getResourceOrNull(graph, URIs.DelayExpression);\r
         Dependency = getResourceOrNull(graph, URIs.Dependency);\r
         DependencyConnection = getResourceOrNull(graph, URIs.DependencyConnection);\r
-        DevelopmentProject = getResourceOrNull(graph, URIs.DevelopmentProject);\r
-        DevelopmentProject_Admin = getResourceOrNull(graph, URIs.DevelopmentProject_Admin);\r
-        DevelopmentProject_Tags = getResourceOrNull(graph, URIs.DevelopmentProject_Tags);\r
-        DevelopmentProject_Tags_AdminIsFocusable = getResourceOrNull(graph, URIs.DevelopmentProject_Tags_AdminIsFocusable);\r
-        DevelopmentProject_Tags_AdminIsVisible = getResourceOrNull(graph, URIs.DevelopmentProject_Tags_AdminIsVisible);\r
-        DevelopmentProject_WorkModel = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel);\r
-        DevelopmentProject_WorkModel_Experiment = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_Experiment);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_EnumerationTest = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_EnumerationTest);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeed1 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeed1);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeed2 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeed2);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeedTotal = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_RequiredWorkingSpeedTotal);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_TotalPossibleWorkingSpeedInput = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_TotalPossibleWorkingSpeedInput);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_Work1 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_Work1);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_Work1CompletionTime = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_Work1CompletionTime);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_Work1WorkDone = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_Work1WorkDone);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_Work2 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_Work2);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_Work2Amount = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_Work2Amount);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_Work2CompletionTime = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_Work2CompletionTime);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_Work2WorkDone = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_Work2WorkDone);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_Workforce = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_Workforce);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d1 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d1);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d10 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d10);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d11 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d11);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d12 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d12);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d13 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d13);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d14 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d14);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d15 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d15);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d2 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d2);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d3 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d3);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d4 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d4);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d5 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d5);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d6 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d6);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d7 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d7);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d8 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d8);\r
-        DevelopmentProject_WorkModel_WorkModelConfiguration_d9 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModelConfiguration_d9);\r
-        DevelopmentProject_WorkModel_WorkModule = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModule);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_Errors = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_Errors);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsFoundRate = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsFoundRate);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsFoundTime = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsFoundTime);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsGenerated = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_ErrorsGenerated);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_MaximumWorkingSpeed = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_MaximumWorkingSpeed);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_PossibleWorkingSpeedInput = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_PossibleWorkingSpeedInput);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectIsReady = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectIsReady);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectReadyness = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectReadyness);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectWorkAmount = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_ProjectWorkAmount);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_RequiredWorkingSpeed = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_RequiredWorkingSpeed);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_RequiredWorkingSpeedTotalInput = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_RequiredWorkingSpeedTotalInput);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_TimeToDeadline = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_TimeToDeadline);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkAllocation = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkAllocation);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkCompletionTimeInput = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkCompletionTimeInput);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkDone = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkDone);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkQuality = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkQuality);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkToDo = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkToDo);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkingSpeed = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_WorkingSpeed);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_c31 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_c31);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_c33 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_c33);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d31 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d31);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d32 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d32);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d33 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d33);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d34 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d34);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d35 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d35);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d36 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d36);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d37 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d37);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d38 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d38);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d40 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d40);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d41 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d41);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d42 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d42);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d43 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d43);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d44 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d44);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d45 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d45);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d46 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d46);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d47 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d47);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d48 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d48);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_d49 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_d49);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_f31 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_f31);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_f32 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_f32);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_f33 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_f33);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_f34 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_f34);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_f35 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_f35);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_f36 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_f36);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_f37 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_f37);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_f40 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_f40);\r
-        DevelopmentProject_WorkModel_WorkModuleConfiguration_f41 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkModuleConfiguration_f41);\r
-        DevelopmentProject_WorkModel_WorkforceModule = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModule);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_NetResources = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_NetResources);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_PossibleWorkingSpeed = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_PossibleWorkingSpeed);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_Productivity = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_Productivity);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_RequiredWorkingSpeedInput = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_RequiredWorkingSpeedInput);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_TimeToAllocateResources = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_TimeToAllocateResources);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_WorkForceRequired = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_WorkForceRequired);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_WorkforceStock = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_WorkforceStock);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_c21 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_c21);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d21 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d21);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d22 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d22);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d23 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d23);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d24 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d24);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d25 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d25);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d26 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d26);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d27 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_d27);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_f21 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_f21);\r
-        DevelopmentProject_WorkModel_WorkforceModuleConfiguration_f22 = getResourceOrNull(graph, URIs.DevelopmentProject_WorkModel_WorkforceModuleConfiguration_f22);\r
-        DevelopmentProject_WorkSymbol = getResourceOrNull(graph, URIs.DevelopmentProject_WorkSymbol);\r
-        DevelopmentProject_WorkforceSymbol = getResourceOrNull(graph, URIs.DevelopmentProject_WorkforceSymbol);\r
-        DevelopmentProject_conf_dependency = getResourceOrNull(graph, URIs.DevelopmentProject_conf_dependency);\r
-        DevelopmentProject_conf_dependency_ref = getResourceOrNull(graph, URIs.DevelopmentProject_conf_dependency_ref);\r
-        DevelopmentProject_dependency = getResourceOrNull(graph, URIs.DevelopmentProject_dependency);\r
-        DevelopmentProject_flow = getResourceOrNull(graph, URIs.DevelopmentProject_flow);\r
         DiagramToCompositeMapping = getResourceOrNull(graph, URIs.DiagramToCompositeMapping);\r
         Enumeration = getResourceOrNull(graph, URIs.Enumeration);\r
         EnumerationIndex = getResourceOrNull(graph, URIs.EnumerationIndex);\r
@@ -625,6 +322,7 @@ public class SysdynResource {
         Expression = getResourceOrNull(graph, URIs.Expression);\r
         Expressions = getResourceOrNull(graph, URIs.Expressions);\r
         Expressions_Inverse = getResourceOrNull(graph, URIs.Expressions_Inverse);\r
+        ExternalFunctionFile = getResourceOrNull(graph, URIs.ExternalFunctionFile);\r
         Flow = getResourceOrNull(graph, URIs.Flow);\r
         FlowConnection = getResourceOrNull(graph, URIs.FlowConnection);\r
         GameExperiment = getResourceOrNull(graph, URIs.GameExperiment);\r
@@ -642,6 +340,8 @@ public class SysdynResource {
         HasEquation_Inverse = getResourceOrNull(graph, URIs.HasEquation_Inverse);\r
         HasExpressions = getResourceOrNull(graph, URIs.HasExpressions);\r
         HasExpressions_Inverse = getResourceOrNull(graph, URIs.HasExpressions_Inverse);\r
+        HasExternalFile = getResourceOrNull(graph, URIs.HasExternalFile);\r
+        HasExternalFile_Inverse = getResourceOrNull(graph, URIs.HasExternalFile_Inverse);\r
         HasHead = getResourceOrNull(graph, URIs.HasHead);\r
         HasHeadTerminal = getResourceOrNull(graph, URIs.HasHeadTerminal);\r
         HasInitialEquation = getResourceOrNull(graph, URIs.HasInitialEquation);\r
@@ -656,6 +356,8 @@ public class SysdynResource {
         HasMinX_Inverse = getResourceOrNull(graph, URIs.HasMinX_Inverse);\r
         HasMinY = getResourceOrNull(graph, URIs.HasMinY);\r
         HasMinY_Inverse = getResourceOrNull(graph, URIs.HasMinY_Inverse);\r
+        HasModelicaFunctionCode = getResourceOrNull(graph, URIs.HasModelicaFunctionCode);\r
+        HasModelicaFunctionCode_Inverse = getResourceOrNull(graph, URIs.HasModelicaFunctionCode_Inverse);\r
         HasOutputInterval = getResourceOrNull(graph, URIs.HasOutputInterval);\r
         HasOutputInterval_Inverse = getResourceOrNull(graph, URIs.HasOutputInterval_Inverse);\r
         HasParameterFile = getResourceOrNull(graph, URIs.HasParameterFile);\r
@@ -720,6 +422,7 @@ public class SysdynResource {
         SysdynConnectionType = getResourceOrNull(graph, URIs.SysdynConnectionType);\r
         SysdynDiagramModelingRules = getResourceOrNull(graph, URIs.SysdynDiagramModelingRules);\r
         SysdynModel = getResourceOrNull(graph, URIs.SysdynModel);\r
+        SysdynModelicaFunction = getResourceOrNull(graph, URIs.SysdynModelicaFunction);\r
         SysdynTerminal = getResourceOrNull(graph, URIs.SysdynTerminal);\r
         Valve = getResourceOrNull(graph, URIs.Valve);\r
         ValveSymbol = getResourceOrNull(graph, URIs.ValveSymbol);\r
index e44c5c49384b449818f94a5a2b1db1364cfc067a..b1e3e43682eb64448b6299aa4587b99bb53981c7 100644 (file)
                      checkEnabled="true">\r
                </visibleWhen>\r
             </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.newFunction"\r
+                  id="org.simantics.sysdyn.ui.browser.newFunction"\r
+                  label="Function"\r
+                  style="push">\r
+               <visibleWhen\r
+                     checkEnabled="true">\r
+                  <with\r
+                        variable="selection">\r
+                     <test\r
+                           args="org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder"\r
+                           property="org.simantics.sysdyn.ui.nodeClass">\r
+                     </test>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
          </menu>\r
          <command\r
                commandId="org.simantics.image.ui.importImage"\r
             </visibleWhen>\r
          </command>\r
       </menuContribution>\r
+      <menuContribution\r
+            locationURI="popup:#ExternalFunctionFileBrowser?after=wbStart">\r
+         <command\r
+               commandId="org.simantics.sysdyn.ui.importExternalFunctionFile"\r
+               label="Import Files"\r
+               style="push">\r
+         </command>\r
+         <command\r
+               commandId="org.simantics.sysdyn.ui.exportExternalFunctionFile"\r
+               label="Export Files"\r
+               style="push">\r
+         </command>\r
+         <command\r
+               commandId="org.simantics.sysdyn.ui.removeNode"\r
+               icon="icons/cross.png"\r
+               id="org.simantics.sysdyn.ui.browser.remove"\r
+               label="Remove"\r
+               style="push">\r
+            <visibleWhen\r
+                  checkEnabled="true">\r
+            </visibleWhen>\r
+         </command>\r
+      </menuContribution>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.commands">\r
             id="org.simantics.sysdyn.ui.importMdl"\r
             name="Import .mdl">\r
       </command>\r
+      <command\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.NewFunctionHandler"\r
+            id="org.simantics.sysdyn.ui.newFunction"\r
+            name="NewFunction">\r
+      </command>\r
+      <command\r
+            id="org.simantics.sysdyn.ui.importExternalFunctionFile"\r
+            name="ImportExternalFunctionFile">\r
+      </command>\r
+      <command\r
+            id="org.simantics.sysdyn.ui.exportExternalFunctionFile"\r
+            name="ExportExternalFunctionFile">\r
+      </command>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.handlers">\r
                         args="org.simantics.operating.ui.modelBrowser.CompositeNode"\r
                         property="org.simantics.sysdyn.ui.nodeClass">\r
                   </test>\r
+                  <test\r
+                        args="org.simantics.sysdyn.ui.properties.widgets.externalFiles.ExternalFileNode"\r
+                        property="org.simantics.sysdyn.ui.nodeClass">\r
+                  </test>\r
                </or>\r
             </with>\r
          </activeWhen>\r
             </with>\r
          </activeWhen>\r
       </handler>\r
+      <handler\r
+            class="org.simantics.sysdyn.ui.handlers.ImportExternalFunctionFilesHandler"\r
+            commandId="org.simantics.sysdyn.ui.importExternalFunctionFile">\r
+      </handler>\r
+      <handler\r
+            class="org.simantics.sysdyn.ui.handlers.ExportExternalFunctionFilesHandler"\r
+            commandId="org.simantics.sysdyn.ui.exportExternalFunctionFile">\r
+      </handler>\r
    </extension>\r
    <extension\r
          point="org.simantics.browsing.ui.common.viewpointContributionBinding">\r
                class="org.simantics.sysdyn.ui.browser.contributions.Configuration"\r
                preference="2.0">\r
          </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.Functions"\r
+               preference="2.0">\r
+         </implementation>\r
       </binding>\r
       <binding browseContext="http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser">\r
         <implementation class="org.simantics.sysdyn.ui.property.OperationProjectContributor" preference="1.0"/>\r
                preference="2.0">\r
          </implementation>\r
       </binding>\r
+      <binding\r
+            browseContext="http://www.simantics.org/Sysdyn-1.0/ExternalFiles">\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.properties.widgets.externalFiles.ExternalFiles"\r
+               preference="2.0">\r
+         </implementation>\r
+      </binding>\r
    </extension>\r
    <extension\r
          point="org.simantics.browsing.ui.common.labelerBinding">\r
                class="org.simantics.sysdyn.ui.browser.contributions.ModuleTypeLabeler"\r
                preference="2.0">\r
          </implementation>\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.browser.contributions.FunctionsLabeler"\r
+               preference="2.0">\r
+         </implementation>\r
       </binding>\r
       <binding browseContext="http://www.simantics.org/Sysdyn-1.0/SysdynOperationBrowser">\r
         <implementation class="org.simantics.sysdyn.ui.property.OperationModelLabels" preference="1.0"/>\r
                preference="2.0">\r
          </implementation>\r
       </binding>\r
+      <binding\r
+            browseContext="http://www.simantics.org/Sysdyn-1.0/ExternalFiles">\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.properties.widgets.externalFiles.ExternalFileLabeler"\r
+               preference="2.0">\r
+         </implementation>\r
+      </binding>\r
    </extension>\r
    <extension\r
          point="org.simantics.browsing.ui.common.imagerBinding">\r
 <!--        <implementation class="org.simantics.sysdyn.ui.property.LibraryVariableImager" preference="2.0"/> -->\r
         <implementation class="org.simantics.sysdyn.ui.property.OperationVariableImager" preference="1.0"/>\r
       </binding>\r
+      <binding\r
+            browseContext="http://www.simantics.org/Sysdyn-1.0/ExternalFiles">\r
+         <implementation\r
+               class="org.simantics.sysdyn.ui.properties.widgets.externalFiles.ExternalFileImager"\r
+               preference="2.0">\r
+         </implementation>\r
+      </binding>\r
    </extension>\r
    <extension\r
          point="org.simantics.browsing.ui.common.labelDecoratorBinding">\r
index 78e47e0b2b545e965aba49274f29a98b864e2261..82738b663d5aa21db4b9180c5f68baa8d7c6fe30 100644 (file)
@@ -21,6 +21,7 @@ import org.simantics.sysdyn.ui.Activator;
 import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
 import org.simantics.sysdyn.ui.browser.nodes.InputNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
@@ -35,7 +36,7 @@ public class AbstractNodeImager extends ImagerContributor<AbstractNode<Resource>
         \r
         String image = null;\r
         if (node instanceof ExperimentsFolder || \r
-                node instanceof ModulesNode)\r
+                node instanceof ModulesNode || node instanceof FunctionsFolder)\r
             image = "icons/folder.png";\r
         else if (node instanceof ModuleTypeNode || node instanceof ModuleNode || node instanceof ConfigurationNode)\r
             image = "icons/bricks.png";\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Functions.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/Functions.java
new file mode 100644 (file)
index 0000000..344f6af
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.scl.runtime.function.Function;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
+\r
+public class Functions  extends ViewpointContributor<FunctionsFolder> {\r
+\r
+    @Override\r
+    public Collection<?> getContribution(ReadGraph graph, FunctionsFolder functionsFolder)\r
+    throws DatabaseException {\r
+\r
+        ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
+        Function index = graph.adapt(L0.Dependencies, Function.class);\r
+        Collection<Map<String, Object>> results = (Collection<Map<String, Object>>)index.apply(graph, functionsFolder.data, "Types:SysdynModelicaFunction");\r
+        for(Map<String, Object> r : results) {\r
+               Resource function = (Resource)r.get("Resource");\r
+               if(function != null);\r
+                       result.add(new FunctionNode(function));\r
+        }\r
+        return result;\r
+\r
+    }\r
+\r
+    @Override\r
+    public String getViewpointId() {\r
+        return "Standard";\r
+    }\r
+    \r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionsLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/FunctionsLabeler.java
new file mode 100644 (file)
index 0000000..35d2bec
--- /dev/null
@@ -0,0 +1,25 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
+\r
+public class FunctionsLabeler  extends LabelerContributor<FunctionsFolder>{\r
+\r
+    @Override\r
+    public String getLabel(ReadGraph graph, FunctionsFolder input) throws DatabaseException {\r
+        return "Functions";\r
+    }\r
+}\r
index b64675460f034d1d0dc52cff9eab46c30618e038..bf6a2270c8d5392573133086275405fef3708057 100644 (file)
@@ -24,6 +24,7 @@ import org.simantics.layer0.Layer0;
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModelNode;\r
 import org.simantics.sysdyn.ui.browser.nodes.ModulesNode;\r
 \r
@@ -41,6 +42,7 @@ public class Model  extends ViewpointContributor<ModelNode> {
         }\r
         result.add(new ExperimentsFolder(model.data));\r
         result.add(new ModulesNode(model.data));\r
+        result.add(new FunctionsFolder(model.data));\r
         return result;\r
     }\r
 \r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionNode.java
new file mode 100644 (file)
index 0000000..31589a4
--- /dev/null
@@ -0,0 +1,23 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.db.Resource;\r
+\r
+public class FunctionNode extends VariableNode<Resource> implements IDeletable {\r
+       \r
+    public FunctionNode(final Resource resource) {\r
+       super(resource);\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionsFolder.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/FunctionsFolder.java
new file mode 100644 (file)
index 0000000..c8c5735
--- /dev/null
@@ -0,0 +1,30 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.db.Resource;\r
+\r
+public class FunctionsFolder extends AbstractNode<Resource> {\r
+\r
+    public FunctionsFolder(Resource resource) {\r
+        super(resource);\r
+    }\r
+    \r
+    @SuppressWarnings("rawtypes")\r
+    @Override\r
+    public Object getAdapter(Class adapter) {\r
+        if(clazz == adapter) // There is no resource for this node..\r
+            return null;\r
+        return super.getAdapter(adapter);\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportExternalFunctionFilesHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ExportExternalFunctionFilesHandler.java
new file mode 100644 (file)
index 0000000..8457376
--- /dev/null
@@ -0,0 +1,79 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.io.FileOutputStream;\r
+import java.io.IOException;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.widgets.DirectoryDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.ResourceAdaptionUtils;\r
+\r
+public class ExportExternalFunctionFilesHandler extends AbstractHandler {\r
+\r
+       @Override\r
+       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+               \r
+               Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+               ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+               final Resource[] resources = ResourceAdaptionUtils.toResources(sel);\r
+               if (resources.length < 1)\r
+                       return null;\r
+\r
+               DirectoryDialog dd = new DirectoryDialog(shell);\r
+               dd.setFilterPath(Platform.getLocation().toOSString());\r
+               dd.setText("Export files to...");\r
+               dd.setMessage("Select a directory");\r
+               final String dir = dd.open();\r
+               if (dir == null) {\r
+                       return null;\r
+               }\r
+\r
+               SimanticsUI.getSession().asyncRequest(new ReadRequest() {\r
+\r
+                       @Override\r
+                       public void run(ReadGraph graph) throws DatabaseException {\r
+                               SysdynResource sr = SysdynResource.getInstance(graph);\r
+                               for(Resource r : resources) {\r
+                                       try {\r
+                                               String name = NameUtils.getSafeName(graph, r);\r
+                                               FileOutputStream fos = new FileOutputStream(dir + "\\" + name);\r
+                                               byte[] fileBArray = graph.getPossibleRelatedValue(r, sr.HasExternalFile, Bindings.BYTE_ARRAY);\r
+                                               fos.write(fileBArray);\r
+                                               fos.close();\r
+                                       } catch (IOException e) {\r
+                                               e.printStackTrace();\r
+                                       }\r
+                               }\r
+                               \r
+                       }\r
+               });\r
+\r
+               return null;\r
+       }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportExternalFunctionFilesHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/ImportExternalFunctionFilesHandler.java
new file mode 100644 (file)
index 0000000..c8f30da
--- /dev/null
@@ -0,0 +1,112 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.IOException;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.runtime.Platform;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.FileDialog;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.ui.IWorkbenchPart;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.browsing.ui.platform.PropertyPageView;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.SysdynPropertyPage;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class ImportExternalFunctionFilesHandler extends AbstractHandler {\r
+\r
+       public static final String[] C_EXTENSIONS = {"*.c","*.h","*.a","*.o"};\r
+       @Override\r
+       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+               IWorkbenchPart part = HandlerUtil.getActivePart(event);\r
+               PropertyPageView ppv = (PropertyPageView)part;\r
+               SysdynPropertyPage page = (SysdynPropertyPage)ppv.getCurrentPage();\r
+               Object o = page.getAdapter(Resource.class);\r
+        if (part == null)\r
+            return null;\r
+               \r
+               Shell shell = HandlerUtil.getActiveShellChecked(event);\r
+               Pair<String, String[]> selected = importFiles(shell, "Import...", C_EXTENSIONS);\r
+               if(selected.second == null || selected.second.length < 1) return null;\r
+\r
+               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                       \r
+                       @Override\r
+                       public void perform(WriteGraph graph) throws DatabaseException {\r
+                               // TODO: include files to database\r
+                       }\r
+               });\r
+               \r
+               return null;\r
+       }\r
+       \r
+       /**\r
+        * Import \r
+        * \r
+        * @param shell\r
+        * @return\r
+        */\r
+       public static Pair<String, String[]> importFiles(Shell shell, String text, String[] filter) {\r
+               FileDialog fd = new FileDialog(shell, SWT.OPEN);\r
+               fd.setText(text);\r
+               fd.setFilterPath(Platform.getLocation().toOSString());\r
+               fd.setFilterExtensions(filter);\r
+               fd.open();\r
+               return new Pair<String, String[]>(fd.getFilterPath(), fd.getFileNames());\r
+       }\r
+       \r
+       public static void addFilesToFunction(WriteGraph graph, Resource function, Pair<String, String[]> files) throws DatabaseException {\r
+               SysdynResource sr = SysdynResource.getInstance(graph);\r
+               Layer0 l0 = Layer0.getInstance(graph);\r
+               \r
+               if(!graph.isInstanceOf(function, sr.SysdynModelicaFunction))\r
+                       return;\r
+\r
+               for(String filename : files.second) {\r
+                       File file = new File(files.first, filename);\r
+                                       \r
+                       String name = file.getName();\r
+                       \r
+                       Resource externalFile = GraphUtils.create2(graph, \r
+                                       sr.ExternalFunctionFile,\r
+                                       l0.PartOf, function,\r
+                                       l0.HasName, name);\r
+                       \r
+                       try {\r
+                               byte[] fileBArray = new byte[(int)file.length()];\r
+                               FileInputStream fis = new FileInputStream(file);\r
+                               fis.read(fileBArray);\r
+                               graph.claimLiteral(externalFile, sr.HasExternalFile, fileBArray, Bindings.BYTE_ARRAY);\r
+                       } catch (IOException e) {\r
+                               // TODO Auto-generated catch block\r
+                               e.printStackTrace();\r
+                       }\r
+\r
+               }\r
+       }\r
+\r
+}\r
index 303ea4b536e09a8e92578fc3ea324f6e9817ccfc..43508c9dcb819c3a4cc584316d3074634823a88e 100644 (file)
@@ -20,6 +20,7 @@ import org.simantics.db.Builtins;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\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.layer0.utils.direct.GraphUtils;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
@@ -48,7 +49,7 @@ public class NewExperimentNodeHandler extends AbstractHandler {
                 Builtins b = g.getBuiltins();\r
                 Resource report = GraphUtils.create2(g, b.Report,  b.HasDocumentation, "===Report===");\r
 \r
-                String name = GraphUtils.findFreshName(g, "Experiment", model, b.ConsistsOf, "%s%d");\r
+                String name = NameUtils.findFreshName(g, "Experiment", model, b.ConsistsOf, "%s%d");\r
 \r
                 @SuppressWarnings("unused")\r
                 Resource experiment = GraphUtils.create2(g, SimulationResource.getInstance(g).Experiment,\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/NewFunctionHandler.java
new file mode 100644 (file)
index 0000000..926cde5
--- /dev/null
@@ -0,0 +1,67 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\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.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.sysdyn.ui.browser.nodes.FunctionsFolder;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+public class NewFunctionHandler  extends AbstractHandler {\r
+\r
+       @Override\r
+       public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+        ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+        \r
+        FunctionsFolder node = AdaptionUtils.adaptToSingle(sel, FunctionsFolder.class);\r
+        if (node == null)\r
+            return null;\r
+\r
+        final Resource model = node.data;\r
+\r
+        SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+            @Override\r
+            public void perform(WriteGraph g) throws DatabaseException {\r
+               Layer0 l0 = Layer0.getInstance(g);\r
+                String name = NameUtils.findFreshName(g, "Function", model, l0.ConsistsOf, "%s%d");\r
+\r
+                SysdynResource sr = SysdynResource.getInstance(g);\r
+                GraphUtils.create2(g, sr.SysdynModelicaFunction,\r
+                        l0.HasName, name,\r
+                        l0.HasDescription, "",\r
+                        sr.HasModelicaFunctionCode, "",\r
+                        l0.PartOf, model);\r
+                \r
+                FunctionUtils.updateFunctionFileForLibrary(g, model);\r
+            }\r
+        });\r
+        \r
+        return null;\r
+       }\r
+\r
+\r
+}\r
index 9c940ed1ae999fa5dc9b9c304cf33cb8c57ed56e..048d6291041972f025c381f45f1534abd3f9946a 100644 (file)
@@ -19,6 +19,7 @@ import org.eclipse.ui.handlers.HandlerUtil;
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.diagram.DiagramConstants;\r
@@ -58,7 +59,7 @@ public class NewModuleNodeHandler extends AbstractHandler {
                 StructuralResource2 sr2 = StructuralResource2.getInstance(g);\r
                 DiagramResource dr = DiagramResource.getInstance(g);\r
                 \r
-                String name = GraphUtils.findFreshName(g, "ModuleType", model, l0.ConsistsOf, "%s%d");\r
+                String name = NameUtils.findFreshName(g, "ModuleType", model, l0.ConsistsOf, "%s%d");\r
                 \r
                 Resource moduleType = g.newResource();\r
                 g.claimLiteral(moduleType, l0.HasName, name);\r
index 31591dc4639b581083fd02d03053a0189bc85fd2..8fa80b3b70b63a93fa7860b8ef866eef2f784e2a 100644 (file)
@@ -20,10 +20,10 @@ import org.eclipse.core.runtime.jobs.Job;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.RequestProcessor;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.AdaptionException;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.request.Read;\r
-import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.message.MessageService;\r
 import org.simantics.project.IProject;\r
 import org.simantics.simulation.experiment.IExperiment;\r
@@ -83,7 +83,7 @@ public class SysdynExperimentActivator {
                     try {\r
                         return graph.adapt(resource, String.class);\r
                     } catch (AdaptionException e) {\r
-                        return GraphUtils.getReadableName(graph, resource);\r
+                        return NameUtils.getSafeName(graph, resource);\r
                     }\r
                 }\r
             });\r
index d8db6fe4b780dad89e8549d93eae8cac79cf53d7..23f182ed360580e18931c9d8915f4b55d0d04616 100644 (file)
@@ -20,20 +20,22 @@ import org.eclipse.core.runtime.preferences.InstanceScope;
 import org.eclipse.swt.widgets.Shell;\r
 import org.eclipse.ui.PartInitException;\r
 import org.osgi.service.prefs.BackingStoreException;\r
-import org.simantics.databoard.accessor.Accessor;\r
 import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.accessor.Accessor;\r
 import org.simantics.db.Builtins;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.VirtualGraph;\r
 import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.procedure.single.SingleSetListener;\r
+import org.simantics.db.common.procedure.single.SingleSetSyncListener;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
 import org.simantics.db.common.request.Queries;\r
 import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.adapter.GenericRelationIndex;\r
 import org.simantics.db.layer0.adapter.RuntimeValuations;\r
 import org.simantics.db.layer0.adapter.TrendVariable;\r
 import org.simantics.db.layer0.service.ActivationManager;\r
@@ -58,6 +60,7 @@ import org.simantics.project.ProjectElements;
 import org.simantics.project.ProjectKeys;\r
 import org.simantics.project.exception.ProjectException;\r
 import org.simantics.project.features.AbstractProjectFeature;\r
+import org.simantics.project.ontology.ProjectResource;\r
 import org.simantics.simulation.experiment.IExperiment;\r
 import org.simantics.simulation.ontology.SimulationResource;\r
 import org.simantics.simulation.project.IExperimentManager;\r
@@ -117,7 +120,7 @@ public class SysdynProject extends AbstractProjectFeature {
                 ModelingResources mr = ModelingResources.getInstance(g);\r
                 ModelingUtils mu = new ModelingUtils(g);\r
 \r
-                String modelName = GraphUtils.findFreshName(g, "Model", SimanticsUI.getProject().get(), l0.ConsistsOf, "%s%d");\r
+                String modelName = NameUtils.findFreshName(g, "Model", SimanticsUI.getProject().get(), l0.ConsistsOf, "%s%d");\r
 \r
                 Resource model = g.newResource();\r
                 g.claimLiteral(model, l0.HasName, modelName);\r
@@ -152,6 +155,23 @@ public class SysdynProject extends AbstractProjectFeature {
                         l0.HasReportFactory, report,\r
                         l0.PartOf, model);\r
 \r
+                ProjectResource PROJ = ProjectResource.getInstance(g);\r
+                for(Resource dep : g.getObjects(library, l0.IsLinkedTo)) {\r
+                       if(g.isInstanceOf(dep, PROJ.NamespaceRequirement)) {\r
+                               for(Resource req : g.getObjects(dep, PROJ.RequiresNamespace)) {\r
+                                       String uri = g.getPossibleValue(req, Bindings.STRING);\r
+                                       System.err.println("dep uri=" + uri);\r
+                                       if(uri != null) {\r
+                                               Resource target = g.getResource(uri);\r
+                                               if(target != null) {\r
+                                                       g.claim(model, l0.IsLinkedTo, null, target);\r
+                                               }\r
+                                       }\r
+                               }\r
+                       }\r
+                }\r
+\r
+                \r
                 callback.run(model);\r
             } catch(Exception e) {\r
                 errorCallback.run(e);\r
@@ -222,10 +242,14 @@ public class SysdynProject extends AbstractProjectFeature {
             final VirtualGraph graph = session.getService(VirtualGraph.class);\r
 \r
             SysdynResource SYSDYN = SysdynResource.getInstance(session);\r
-            session.asyncRequest(new ObjectsWithType(projectResource, l0.ConsistsOf, SYSDYN.SysdynModel), new SingleSetListener<Resource>() {\r
+            session.asyncRequest(new ObjectsWithType(projectResource, l0.ConsistsOf, SYSDYN.SysdynModel), new SingleSetSyncListener<Resource>() {\r
 \r
                 @Override\r
-                public void add(final Resource model) {\r
+                public void add(ReadGraph g, final Resource model) throws DatabaseException {\r
+                       \r
+                       GenericRelationIndex index = g.adapt(l0.DependenciesRelation, GenericRelationIndex.class);\r
+                       index.trackAndIndex(g.getSession(), model);\r
+                       \r
                     // FIXME:\r
                     Simantics.async(new Runnable() {\r
 \r
@@ -245,7 +269,7 @@ public class SysdynProject extends AbstractProjectFeature {
                 }\r
 \r
                 @Override\r
-                public void exception(Throwable t) {\r
+                public void exception(ReadGraph graph, Throwable t) {\r
                     t.printStackTrace();\r
                 }\r
 \r
index e1cabac3d220eca26a8b95fcfd45be841619d7c4..21e8764ecb53a018505bd756594f07ae6bdc19f4 100644 (file)
@@ -210,6 +210,8 @@ public class EquationTab extends PropertyTabContributorImpl implements Widget {
                                                                        @Override\r
                                                                        public void perform(WriteGraph graph) throws DatabaseException {\r
                                                                                SysdynResource sr = SysdynResource.getInstance(graph);\r
+                                                                               if(graph.hasStatement(variable, sr.HasActiveExpression))\r
+                                                                                       graph.deny(variable, sr.HasActiveExpression);\r
                                                                                graph.claim(variable, sr.HasActiveExpression, expression);\r
                                                                        }\r
                                                                }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExternalFilesTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ExternalFilesTab.java
new file mode 100644 (file)
index 0000000..7abe614
--- /dev/null
@@ -0,0 +1,109 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Control;\r
+import org.eclipse.swt.widgets.Shell;\r
+import org.eclipse.swt.widgets.Tree;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
+import org.simantics.browsing.ui.swt.widgets.Button;\r
+import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.ui.handlers.ImportExternalFunctionFilesHandler;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+public class ExternalFilesTab extends PropertyTabContributorImpl implements Widget {\r
+\r
+       GraphExplorerComposite externalFilesExplorer;\r
+       Button importButton; \r
+       \r
+       @Override\r
+       public void createControls(Composite body, IWorkbenchSite site,\r
+                       final ISessionContext context, WidgetSupport support) {\r
+               support.register(this);\r
+               \r
+        Composite composite = new Composite(body, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(composite);\r
+               \r
+               externalFilesExplorer = new GraphExplorerComposite(ArrayMap.keys(\r
+                               "displaySelectors", "displayFilter").values(false, false), site, composite, SWT.FULL_SELECTION | SWT.BORDER | SWT.MULTI);\r
+               \r
+               externalFilesExplorer\r
+               .setBrowseContexts("http://www.simantics.org/Sysdyn-1.0/ExternalFiles");\r
+               externalFilesExplorer.setInputSource(new SingleSelectionInputSource(\r
+                               Resource.class));\r
+\r
+               externalFilesExplorer.setContextMenuId("#ExternalFunctionFileBrowser");\r
+               externalFilesExplorer.finish();\r
+\r
+               GridDataFactory.fillDefaults().grab(true, true).applyTo(\r
+                               externalFilesExplorer);\r
+               \r
+               Control c = externalFilesExplorer.getExplorerControl();\r
+               if (c instanceof Tree)\r
+                       ((Tree) c).setLinesVisible(true);\r
+               \r
+               importButton = new Button(composite, support, SWT.NONE);\r
+               importButton.setText("Import");\r
+               importButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+                       @Override\r
+                       public void apply(WriteGraph graph, final Resource input)\r
+                                       throws DatabaseException {\r
+                               \r
+                               importButton.getWidget().getDisplay().asyncExec(new Runnable() {\r
+                                       \r
+                                       @Override\r
+                                       public void run() {\r
+                                               Shell shell = importButton.getWidget().getShell();\r
+                                               \r
+                                               final Pair<String, String[]> importedFiles = ImportExternalFunctionFilesHandler.importFiles(shell, "Import files", ImportExternalFunctionFilesHandler.C_EXTENSIONS);\r
+                                               \r
+                                               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+                                                       \r
+                                                       @Override\r
+                                                       public void perform(WriteGraph graph) throws DatabaseException {\r
+                                                               ImportExternalFunctionFilesHandler.addFilesToFunction(graph, input, importedFiles);\r
+                                                       }\r
+                                               });\r
+                                       }\r
+                               });\r
+                               \r
+                               \r
+                       }\r
+               });\r
+               \r
+       }\r
+\r
+       @Override\r
+       public void setInput(ISessionContext context, Object input) {\r
+               externalFilesExplorer.setInput(context, input);\r
+       }\r
+\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/FunctionTab.java
new file mode 100644 (file)
index 0000000..c0b315b
--- /dev/null
@@ -0,0 +1,97 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
+import org.simantics.browsing.ui.swt.widgets.Label;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.FunctionUtils;\r
+import org.simantics.sysdyn.ui.properties.widgets.FunctionLabelFactory;\r
+\r
+public class FunctionTab extends PropertyTabContributorImpl {\r
+\r
+       @Override\r
+       public void createControls(Composite body, IWorkbenchSite site,\r
+                       ISessionContext context, WidgetSupport support) {\r
+               \r
+        Composite composite = new Composite(body, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).margins(3, 3).applyTo(composite);\r
+\r
+        TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+        nameText.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasName));\r
+        nameText.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasName));\r
+        nameText.addModifyListener(new TextModifyListenerImpl<Resource>() {\r
+\r
+                       @Override\r
+                       public void applyText(WriteGraph graph, Resource input, String text)\r
+                                       throws DatabaseException {\r
+                               Resource library = graph.getSingleObject(input, Layer0.getInstance(graph).PartOf);\r
+                               FunctionUtils.updateFunctionFileForLibrary(graph, library);\r
+                       }\r
+               });\r
+        GridDataFactory.fillDefaults().span(2, 1).grab(true, false).applyTo(nameText.getWidget());\r
+        \r
+        \r
+        Group modelicaGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);\r
+        modelicaGroup.setText("Modelica code");\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(modelicaGroup);\r
+        GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(modelicaGroup);\r
+        \r
+        Label startLabel = new Label(modelicaGroup, support, SWT.NONE);\r
+        startLabel.setTextFactory(new FunctionLabelFactory(Builtins.URIs.HasName, false));\r
+        TrackedText modelicaCode = new TrackedText(modelicaGroup, support, SWT.MULTI | SWT.BORDER | SWT.V_SCROLL);\r
+        modelicaCode.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.HasModelicaFunctionCode));\r
+        modelicaCode.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.HasModelicaFunctionCode));\r
+        modelicaCode.addModifyListener(new TextModifyListenerImpl<Resource>() {\r
+\r
+                       @Override\r
+                       public void applyText(WriteGraph graph, Resource input, String text)\r
+                                       throws DatabaseException {\r
+                               Resource library = graph.getSingleObject(input, Layer0.getInstance(graph).PartOf);\r
+                               FunctionUtils.updateFunctionFileForLibrary(graph, library);\r
+                       }\r
+               });\r
+        \r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(modelicaCode.getWidget());\r
+        Label endLabel = new Label(modelicaGroup, support, SWT.NONE);\r
+        endLabel.setTextFactory(new FunctionLabelFactory(Builtins.URIs.HasName, true));\r
+\r
+        Group documentationGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);\r
+        documentationGroup.setText("Documentation");\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(documentationGroup);\r
+        GridLayoutFactory.fillDefaults().spacing(0, 0).margins(3, 3).applyTo(documentationGroup);\r
+\r
+        TrackedText information = new TrackedText(documentationGroup, support, SWT.MULTI | SWT.BORDER);\r
+        information.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasDescription));\r
+        information.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasDescription));\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(information.getWidget());\r
+       }\r
+\r
+}\r
index 8966861143578f94e74ff4caaa9b2920de2f554c..7c159ebb9d52220a6262dc4c94845b52311838ce 100644 (file)
@@ -231,6 +231,21 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                                                        r,\r
                                                        "Module Type Properties"));\r
                        }\r
+                       \r
+                       if (backend.isInstanceOf(r, sr.SysdynModelicaFunction)) {\r
+                               tabs.add(new ComparableTabContributor(\r
+                                               new FunctionTab(),\r
+                                               2,\r
+                                               r,\r
+                               "Function"));\r
+                               tabs.add(new ComparableTabContributor(\r
+                                               new ExternalFilesTab(),\r
+                                               1,\r
+                                               r,\r
+                               "External files"));\r
+                               return tabs;\r
+                       }\r
+                       \r
                } catch (ServiceException e) {\r
                        e.printStackTrace();\r
                } catch (ManyObjectsForFunctionalRelationException e) {\r
index 0a5c8bc29053ae550c48c998f62a64317be56128..bc78c153e898a9e251387d1486bd3c9e41a99c31 100644 (file)
@@ -15,6 +15,7 @@ import java.awt.event.MouseEvent;
 import java.awt.geom.Point2D;\r
 import java.io.StringReader;\r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.Iterator;\r
 \r
 import org.eclipse.jface.layout.GridDataFactory;\r
@@ -169,7 +170,7 @@ public class ChartTableWidget implements Widget {
                     SysdynResource sr = SysdynResource.getInstance(graph);\r
                     if(!graph.isInstanceOf(expression, sr.WithLookupExpression))\r
                        return null;\r
-                    return graph.getRelatedValue(expression, sr.HasLookup);\r
+                    return graph.getPossibleRelatedValue(expression, sr.HasLookup);\r
                 }\r
             }, new Listener<String>() {\r
 \r
@@ -221,7 +222,9 @@ public class ChartTableWidget implements Widget {
     private void tableModified() {\r
         StringBuilder b = new StringBuilder();\r
         b.append("{");\r
-        Iterator<InputOutput> iterator = ((ArrayList<InputOutput>)table.getTableViewer().getInput()).iterator();\r
+        ArrayList<InputOutput> inputOutputList = (ArrayList<InputOutput>)table.getTableViewer().getInput();\r
+        Collections.sort(inputOutputList, table.new InputOutputComparator());\r
+        Iterator<InputOutput> iterator = inputOutputList.iterator();\r
         while(iterator.hasNext()){\r
             InputOutput io = iterator.next();\r
             b.append("{" + io.getInput(String.class) + "," + io.getOutput(String.class) + "}");\r
index 990bb3de7cd8131e3183ba6e119647f12fc3235b..742264c1194b260c39b060b427ccfa4bf64e92d2 100644 (file)
@@ -18,8 +18,10 @@ import java.awt.geom.Ellipse2D;
 import java.io.StringReader;\r
 import java.util.ArrayList;\r
 import java.util.Iterator;\r
+\r
 import javax.swing.JComponent;\r
 import javax.swing.JPanel;\r
+\r
 import org.eclipse.jface.layout.GridDataFactory;\r
 import org.eclipse.jface.viewers.ISelection;\r
 import org.eclipse.swt.SWT;\r
@@ -102,11 +104,11 @@ public class ChartWidget implements Widget {
                        if(!graph.isInstanceOf(expression, sr.WithLookupExpression))\r
                                return null;\r
                        Auxiliary auxiliary = new Auxiliary();\r
-                    auxiliary.minX = graph.getRelatedValue(expression, sr.HasMinX);\r
-                    auxiliary.maxX = graph.getRelatedValue(expression, sr.HasMaxX);\r
-                    auxiliary.minY = graph.getRelatedValue(expression, sr.HasMinY);\r
-                    auxiliary.maxY = graph.getRelatedValue(expression, sr.HasMaxY);\r
-                    auxiliary.table = graph.getRelatedValue(expression, sr.HasLookup);\r
+                    auxiliary.minX = graph.getPossibleRelatedValue(expression, sr.HasMinX);\r
+                    auxiliary.maxX = graph.getPossibleRelatedValue(expression, sr.HasMaxX);\r
+                    auxiliary.minY = graph.getPossibleRelatedValue(expression, sr.HasMinY);\r
+                    auxiliary.maxY = graph.getPossibleRelatedValue(expression, sr.HasMaxY);\r
+                    auxiliary.table = graph.getPossibleRelatedValue(expression, sr.HasLookup);\r
                     return auxiliary;\r
                 }\r
             }, new Listener<Auxiliary>() {\r
@@ -126,9 +128,13 @@ public class ChartWidget implements Widget {
                     XYPlot plot = (XYPlot) chart.getPlot();\r
                     ValueAxis rangeAxis = plot.getRangeAxis();\r
                     rangeAxis.setAutoRange(false);\r
+                    if(result.minY == null) result.minY = rangeAxis.getLowerBound();\r
+                    if(result.maxY == null) result.maxY = rangeAxis.getUpperBound();\r
                     rangeAxis.setRange(result.minY, result.maxY);\r
                     ValueAxis domainAxis = plot.getDomainAxis();\r
                     domainAxis.setAutoRange(false);\r
+                    if(result.minX == null) result.minX = domainAxis.getLowerBound();\r
+                    if(result.maxX == null) result.maxX = domainAxis.getUpperBound();\r
                     domainAxis.setRange(result.minX, result.maxX);\r
 \r
                 }\r
index 45062c669ff4c1d460e5146667bcc361432848f0..ac2e1c8e36f6525679f45e5ab70bebf51e8a2a3a 100644 (file)
@@ -199,7 +199,8 @@ public class ExpressionWidget implements Widget {
        }\r
 \r
        public void save() {\r
-               this.expression.save(expr, data);\r
+               if(this.expression != null)\r
+                       this.expression.save(expr, data);\r
        }\r
 \r
 }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/FunctionLabelFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/FunctionLabelFactory.java
new file mode 100644 (file)
index 0000000..2b4cdcb
--- /dev/null
@@ -0,0 +1,49 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.utils.datastructures.Quad;\r
+\r
+\r
+\r
+public class FunctionLabelFactory  extends ReadFactoryImpl<Resource, String> {\r
+\r
+    private final String propertyURI;\r
+    private boolean end;\r
+    \r
+    public FunctionLabelFactory(String propertyURI, boolean end) {\r
+        this.propertyURI = propertyURI;\r
+        this.end = end;\r
+    }\r
+\r
+    @Override\r
+    public Object getIdentity(Object inputContents) {\r
+        return new Quad<Resource, String, Object, Boolean>((Resource) inputContents, propertyURI, getClass(), end);\r
+    }\r
+\r
+       \r
+    @Override\r
+    public String perform(ReadGraph graph, Resource resource) throws DatabaseException {\r
+        String value = graph.getPossibleRelatedValue(resource, graph.getResource(propertyURI));\r
+        if(end) {\r
+               return "end " + value + ";";\r
+        } else {\r
+               return "function " + value;\r
+        }\r
+    }\r
+       \r
+       \r
+}\r
index 66dd8622b985fe38c63d9cec3798d580732edbec..d1edbb2b446c17a2deb01e6b7c21b6255aa642b7 100644 (file)
@@ -27,13 +27,16 @@ import org.eclipse.swt.events.ModifyListener;
 import org.eclipse.swt.graphics.Point;\r
 import org.eclipse.swt.widgets.Composite;\r
 import org.eclipse.swt.widgets.Label;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.VirtualGraph;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.request.Read;\r
-import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.utils.ExpressionUtils;\r
 import org.simantics.ui.SimanticsUI;\r
@@ -135,13 +138,31 @@ public class BasicExpression implements IExpression {
                         return;\r
                     }\r
                     \r
-                    Layer0 l0 = Layer0.getInstance(g);\r
-                    \r
-                    g.deny(expression, l0.InstanceOf);\r
-                    g.deny(expression, sr.HasEquation);\r
-                    \r
-                    g.claim(expression, l0.InstanceOf, null, expressionType);\r
-                    g.claimLiteral(expression, sr.HasEquation, currentText);\r
+                    if(!g.isInstanceOf(expression, expressionType)) {\r
+                       Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression);\r
+                       final Resource newExpression = GraphUtils.create2(g, expressionType, \r
+                                       sr.HasEquation, currentText);\r
+                       String arrayRange = g.getPossibleRelatedValue(expression, sr.HasArrayRange, Bindings.STRING);\r
+                       if(arrayRange != null)\r
+                               g.claimLiteral(newExpression, sr.HasArrayRange, arrayRange);\r
+                       \r
+                       OrderedSetUtils.replace(g, ownerList, expression, newExpression);\r
+                       \r
+                       final Resource activefor = g.getPossibleObject(expression, sr.HasActiveExpression_Inverse);\r
+                                               VirtualGraph runtime = g.getService(VirtualGraph.class);\r
+                                               g.syncRequest(new WriteRequest(runtime) {\r
+                                                       @Override\r
+                                                       public void perform(WriteGraph graph) throws DatabaseException {\r
+                                                               SysdynResource sr = SysdynResource.getInstance(graph);\r
+                                                               if(graph.hasStatement(activefor, sr.HasActiveExpression))\r
+                                                                       graph.deny(activefor, sr.HasActiveExpression);\r
+                                                               graph.claim(activefor, sr.HasActiveExpression, newExpression);\r
+                                                       }\r
+                                               }\r
+                                               );\r
+                    } else {\r
+                       g.claimLiteral(expression, sr.HasEquation, currentText);\r
+                    }\r
                 }\r
 \r
             });\r
index bbd5d254a326122a8eeacdbab959b11e685ce296..e6eb4775b9f4ab1dcb5468e329ecdf9bcca48ebc 100644 (file)
@@ -13,6 +13,7 @@ package org.simantics.sysdyn.ui.properties.widgets.expressions;
 \r
 import java.awt.geom.Point2D;\r
 import java.util.ArrayList;\r
+import java.util.Comparator;\r
 import java.util.List;\r
 \r
 import org.eclipse.jface.layout.GridDataFactory;\r
@@ -197,19 +198,25 @@ public class LookupInputOutputTable extends Composite {
 \r
     }\r
 \r
-    class InputOutputComparator extends ViewerComparator {\r
+    public class InputOutputComparator extends ViewerComparator implements Comparator<InputOutput>{\r
         @Override\r
         public int compare(Viewer viewer, Object e1, Object e2) {\r
             if ((e1 instanceof InputOutput) &&\r
                     (e2 instanceof InputOutput)) {\r
+               return compare((InputOutput)e1, (InputOutput)e2);\r
+            } else {\r
+               return 0;\r
+            }\r
+        }\r
+\r
+               @Override\r
+               public int compare(InputOutput e1, InputOutput e2) {\r
                 InputOutput io1 = (InputOutput)e1;\r
                 InputOutput io2 = (InputOutput)e2;\r
                 Double d1 = (Double)io1.getInput((Double.class));\r
                 Double d2 = (Double)io2.getInput((Double.class));\r
                 return d1.compareTo(d2);\r
-            }\r
-            return 0;\r
-        }\r
+               }\r
     }\r
 \r
     public TableViewer getTableViewer() {\r
index d01c6ce0be73947a4e7c4113410ccc25cae16147..c60fca1922049cdf43fe7eaa9cc31787f9d82a6a 100644 (file)
@@ -47,17 +47,18 @@ import org.jfree.chart.plot.PlotOrientation;
 import org.jfree.data.xy.XYDataset;\r
 import org.jfree.data.xy.XYSeries;\r
 import org.jfree.data.xy.XYSeriesCollection;\r
+import org.simantics.databoard.Bindings;\r
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
+import org.simantics.db.VirtualGraph;\r
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.common.utils.OrderedSetUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.procedure.Listener;\r
 import org.simantics.db.request.Read;\r
-import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
 import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.representation.Auxiliary;\r
 import org.simantics.sysdyn.tableParser.ParseException;\r
 import org.simantics.sysdyn.tableParser.TableParser;\r
 import org.simantics.sysdyn.tableParser.Token;\r
@@ -149,7 +150,7 @@ public class WithLookupExpression implements IExpression {
                 SysdynResource sr = SysdynResource.getInstance(graph);\r
                 String result = "";\r
                 if (expr != null && graph.isInstanceOf(expr, sr.WithLookupExpression)) {\r
-                    result = graph.getRelatedValue(expr, sr.HasLookup);\r
+                    result = graph.getPossibleRelatedValue(expr, sr.HasLookup);\r
                 }\r
                 return result;\r
             }\r
@@ -213,8 +214,8 @@ public class WithLookupExpression implements IExpression {
                         Auxiliary results = new Auxiliary();\r
                         SysdynResource sr = SysdynResource.getInstance(graph);\r
                         if (expression != null && graph.isInstanceOf(expression, sr.WithLookupExpression)) {\r
-                            results.equation = graph.getRelatedValue(expression, sr.HasEquation);\r
-                            results.lookup = graph.getRelatedValue(expression, sr.HasLookup);\r
+                            results.equation = graph.getPossibleRelatedValue(expression, sr.HasEquation);\r
+                            results.lookup = graph.getPossibleRelatedValue(expression, sr.HasLookup);\r
                         } else {\r
                             results.equation = "";\r
                             results.lookup = "";\r
@@ -225,8 +226,8 @@ public class WithLookupExpression implements IExpression {
             } catch (DatabaseException e1) {\r
                 e1.printStackTrace();\r
             }\r
-            data.put("equation", results.equation);\r
-            data.put("lookup", results.lookup);\r
+            data.put("equation", results.equation == null ? "" : results.equation);\r
+            data.put("lookup", results.lookup == null ? "" : results.lookup);\r
         }\r
 \r
     }\r
@@ -246,8 +247,8 @@ public class WithLookupExpression implements IExpression {
     }\r
 \r
     @Override\r
-    public void save(final Resource variable, Map<String, Object> data) {\r
-        final String currentExpression = expression.getExpression();\r
+    public void save(final Resource expression, Map<String, Object> data) {\r
+        final String currentExpression = this.expression.getExpression();\r
         final String currentLookupTable = lookup.getExpression();\r
         String oldExpression = (String)data.get("equation");\r
         String oldLookupTable = (String)data.get("lookup");\r
@@ -264,20 +265,34 @@ public class WithLookupExpression implements IExpression {
                 public void perform(WriteGraph g)\r
                 throws DatabaseException {\r
                     SysdynResource sr = SysdynResource.getInstance(g);\r
-                    Layer0 l0 = Layer0.getInstance(g);\r
                     if(!g.isInstanceOf(expr, sr.WithLookupExpression)) {\r
-                               Resource expressionList = g.getSingleObject(expr, l0.HasNext);\r
-                       Resource temp = g.newResource();\r
-                       OrderedSetUtils.replace(g, expressionList, expr, temp);\r
-                       for(Resource predicate : g.getPredicates(expr)) {\r
-                               g.deny(expr, predicate);\r
-                       }\r
-                        g.claim(expr, l0.InstanceOf, null, sr.WithLookupExpression);\r
-                        g.claimLiteral(expr, sr.HasMinX, 0.0);\r
-                        g.claimLiteral(expr, sr.HasMaxX, 10.0);\r
-                        g.claimLiteral(expr, sr.HasMinY, 0.0);\r
-                        g.claimLiteral(expr, sr.HasMaxY, 10.0);\r
-                       OrderedSetUtils.replace(g, expressionList, temp, expr);\r
+                       \r
+                       \r
+                       Resource ownerList = OrderedSetUtils.getSingleOwnerList(g, expression);\r
+                       final Resource newExpression = GraphUtils.create2(g, sr.WithLookupExpression,\r
+                                       sr.HasMinX, 0.0,\r
+                                       sr.HasMaxX, 10.0,\r
+                                       sr.HasMinY, 0.0,\r
+                                       sr.HasMaxY, 10.0);\r
+                       String arrayRange = g.getPossibleRelatedValue(expression, sr.HasArrayRange, Bindings.STRING);\r
+                       if(arrayRange != null)\r
+                               g.claimLiteral(newExpression, sr.HasArrayRange, arrayRange);\r
+                       \r
+                       OrderedSetUtils.replace(g, ownerList, expr, newExpression);\r
+                       final Resource activefor = g.getPossibleObject(expression, sr.HasActiveExpression_Inverse);\r
+                                               VirtualGraph runtime = g.getService(VirtualGraph.class);\r
+                                               g.syncRequest(new WriteRequest(runtime) {\r
+                                                       @Override\r
+                                                       public void perform(WriteGraph graph) throws DatabaseException {\r
+                                                               SysdynResource sr = SysdynResource.getInstance(graph);\r
+                                                               if(graph.hasStatement(activefor, sr.HasActiveExpression))\r
+                                                                       graph.deny(activefor, sr.HasActiveExpression);\r
+                                                               graph.claim(activefor, sr.HasActiveExpression, newExpression);\r
+                                                       }\r
+                                               }\r
+                                               );\r
+                       expr = newExpression;\r
+                       \r
                     }\r
                     g.claimLiteral(expr, sr.HasEquation, currentExpression);\r
                     g.claimLiteral(expr, sr.HasLookup, currentLookupTable);\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileImager.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileImager.java
new file mode 100644 (file)
index 0000000..9af9a0d
--- /dev/null
@@ -0,0 +1,28 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.externalFiles;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.swt.ImagerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class ExternalFileImager extends ImagerContributor<ExternalFileNode> {\r
+\r
+       @Override\r
+       public ImageDescriptor getDescriptor(ReadGraph graph, ExternalFileNode input)\r
+                       throws DatabaseException {\r
+               return null;\r
+       }\r
+\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileLabeler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileLabeler.java
new file mode 100644 (file)
index 0000000..ee94d5a
--- /dev/null
@@ -0,0 +1,27 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.externalFiles;\r
+\r
+import org.simantics.browsing.ui.graph.impl.contributor.labeler.LabelerContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+\r
+public class ExternalFileLabeler extends LabelerContributorImpl<ExternalFileNode>{\r
+\r
+       @Override\r
+       public String getLabel(ReadGraph graph, ExternalFileNode input)\r
+                       throws DatabaseException {\r
+               return NameUtils.getSafeName(graph, input.data);\r
+       }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFileNode.java
new file mode 100644 (file)
index 0000000..493a574
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.externalFiles;\r
+\r
+import org.simantics.browsing.ui.common.node.AbstractNode;\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.browsing.ui.common.node.IDeletableNode;\r
+import org.simantics.browsing.ui.common.node.IModifiableNode;\r
+import org.simantics.browsing.ui.content.Labeler.Modifier;\r
+import org.simantics.browsing.ui.graph.impl.LabelModifier;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+public class ExternalFileNode extends AbstractNode<Resource> implements IModifiableNode, IDeletableNode {\r
+\r
+       public ExternalFileNode(Resource data) {\r
+               super(data);\r
+       }\r
+\r
+       @Override\r
+       public Modifier getModifier(String columnId) {\r
+               try {\r
+                       Resource hasName = Layer0.getInstance(SimanticsUI.getSession()).HasName;\r
+                       LabelModifier modifier = new LabelModifier(SimanticsUI.getSession(), data, hasName) {\r
+                               @Override\r
+                               public String isValid(String label) {\r
+                                       if (label.isEmpty())\r
+                                               return "Empty label not allowed";\r
+                                       if (label.contains(" "))\r
+                                               return "Spaces are not allowed";\r
+                                       return null;\r
+                               }\r
+                       };\r
+                       return modifier;\r
+               } catch (DatabaseException e) {\r
+                       e.printStackTrace();\r
+               }\r
+               return null;\r
+       }\r
+\r
+       @Override\r
+       public void delete() throws DeleteException {\r
+               SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+                       @Override\r
+                       public void perform(WriteGraph graph) throws DatabaseException {\r
+                               Layer0 l0 = Layer0.getInstance(graph);\r
+                               Resource function = graph.getSingleObject(data, l0.PartOf);\r
+                               if(function != null) {\r
+                                       graph.deny(data, l0.PartOf, function);\r
+                               }\r
+                       }\r
+               });\r
+       }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFiles.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/externalFiles/ExternalFiles.java
new file mode 100644 (file)
index 0000000..59ad535
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 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
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.externalFiles;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.impl.contributor.viewpoint.ViewpointContributorImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class ExternalFiles extends ViewpointContributorImpl<Resource> {\r
+\r
+       @Override\r
+       public Collection<?> getContribution(ReadGraph graph, Resource input)\r
+                       throws DatabaseException {\r
+               \r
+               if(input == null) \r
+                       return null;\r
+               SysdynResource sr = SysdynResource.getInstance(graph);\r
+               Layer0 l0 = Layer0.getInstance(graph);\r
+               \r
+               ArrayList<ExternalFileNode> result = new ArrayList<ExternalFileNode>();\r
+               for(Resource r : graph.syncRequest(new ObjectsWithType(input, l0.ConsistsOf, sr.ExternalFunctionFile))) {\r
+                       result.add(new ExternalFileNode(r));\r
+               }\r
+               \r
+               return result;\r
+       }\r
+\r
+       @Override\r
+       public String getViewpointId() {\r
+               return "External Files";\r
+       }\r
+       \r
+\r
+\r
+}\r
index 2c91a1308069b9f90486e34d1a9bcff895128c07..1e115e1150723b1bbf09e6e1e769f65d8ee059a9 100644 (file)
@@ -20,7 +20,8 @@ Require-Bundle: org.simantics.objmap;bundle-version="0.1.0",
  org.simantics.sysdyn.ontology;bundle-version="1.0.0",
  org.simantics.modeling;bundle-version="1.1.1",
  org.simantics.diagram;bundle-version="1.1.1",
- org.simantics.diagram.ontology;bundle-version="1.1.1"
+ org.simantics.diagram.ontology;bundle-version="1.1.1",
+ org.simantics.scl.runtime;bundle-version="0.1.3"
 Export-Package: org.simantics.sysdyn,
  org.simantics.sysdyn.expressionParser,
  org.simantics.sysdyn.manager,
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/FunctionUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/FunctionUtils.java
new file mode 100644 (file)
index 0000000..b85894a
--- /dev/null
@@ -0,0 +1,147 @@
+package org.simantics.sysdyn.manager;\r
+\r
+import java.io.File;\r
+import java.io.FileNotFoundException;\r
+import java.io.PrintStream;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.HashSet;\r
+import java.util.List;\r
+import java.util.Map;\r
+import java.util.Set;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.ReadRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.scl.runtime.function.Function;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.sysdyn.Activator;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class FunctionUtils {\r
+       \r
+       public static List<String> getLibraryPathsForModelica(final SysdynModel model) {\r
+               final ArrayList<String> paths = new ArrayList<String>();\r
+               \r
+               try {\r
+                       model.session.syncRequest(new ReadRequest() {\r
+                               \r
+                               @Override\r
+                               public void run(ReadGraph graph) throws DatabaseException {\r
+                                       SysdynResource sr = SysdynResource.getInstance(graph);\r
+                                       Layer0 l0 = Layer0.getInstance(graph);\r
+                                       SimulationResource simu = SimulationResource.getInstance(graph);\r
+                                       \r
+                                       Set<Resource> parents = getParents(graph, model);\r
+                                       for(Resource parent : parents) {\r
+                                               Resource partof = graph.getPossibleObject(parent, l0.PartOf);\r
+                                               if(graph.isInstanceOf(parent, sr.SysdynModel)) {\r
+                                                       Resource configuration = graph.getPossibleObject(parent, simu.HasConfiguration);\r
+                                                       if(configuration.equals(model.configurationResource)) {\r
+                                                               paths.add(model.getConfiguration().getName().replace(" ", "") + "_functions.mo");\r
+                                                       }\r
+                                               } else if (graph.isInstanceOf(partof, sr.SysdynModel)) {\r
+                                                       // TODO\r
+                                               } else {\r
+                                                       String libraryname = NameUtils.getSafeName(graph, parent);\r
+                                                       paths.add("..\\\\..\\\\libraries\\\\functions\\\\" + libraryname + ".mo");\r
+                                               }\r
+                                       }\r
+                               }\r
+                       });\r
+               } catch (DatabaseException e) {\r
+                       e.printStackTrace();\r
+               }\r
+               \r
+               return paths;\r
+       }\r
+       \r
+       private static Set<Resource> getParents(ReadGraph graph, SysdynModel model) throws DatabaseException{\r
+               HashSet<Resource> parents = new HashSet<Resource>();\r
+\r
+               Layer0 l0 = Layer0.getInstance(graph);\r
+               SimulationResource simu = SimulationResource.getInstance(graph);\r
+               Resource modelResource = graph.getPossibleObject(model.configurationResource, simu.IsConfigurationOf);\r
+               if(modelResource != null) {\r
+                       Function index = graph.adapt(l0.Dependencies, Function.class);\r
+                       Collection<Map<String, Object>> results = (Collection<Map<String, Object>>)index.apply(graph, modelResource, "Types:SysdynModelicaFunction");\r
+                       for(Map<String, Object> r : results) {\r
+                               Resource function = (Resource)r.get("Resource");\r
+                               if(function != null) {\r
+                                       parents.add(graph.getSingleObject(function, l0.PartOf));\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               return parents;\r
+               \r
+       }\r
+       \r
+       public static void updateFunctionFilesForModel(ReadGraph graph, SysdynModel model) throws DatabaseException {\r
+               SysdynResource sr = SysdynResource.getInstance(graph);\r
+               \r
+               Set<Resource> parents = getParents(graph, model);\r
+               \r
+               for(Resource parent : parents) {\r
+                       if(graph.isInstanceOf(parent, sr.SysdynModel)) {\r
+                               String parentName = NameUtils.getSafeName(graph, parent);\r
+                               File scriptFile = new File(model.getSimulationDir(), parentName + "_functions.mo");\r
+                               updateFunctionFile(graph, parent, scriptFile);\r
+                       } else {\r
+                               updateFunctionFileForLibrary(graph, parent);\r
+                       }\r
+               }\r
+               return;\r
+       }\r
+       \r
+       public static void updateFunctionFileForLibrary(ReadGraph graph, Resource library) throws DatabaseException {\r
+               SysdynResource sr = SysdynResource.getInstance(graph);\r
+               if(graph.isInstanceOf(library, sr.SysdynModel)) {\r
+                       SimulationResource simu = SimulationResource.getInstance(graph);\r
+                       Resource configuration = graph.getSingleObject(library, simu.HasConfiguration);\r
+                       SysdynModelManager smm = SysdynModelManager.getInstance(graph.getSession());\r
+                       SysdynModel model = smm.getModel(graph, configuration);\r
+                       updateFunctionFilesForModel(graph, model);\r
+               } else {\r
+                       File librariesDir  = Activator.getBundleContext().getDataFile("libraries");\r
+                       if (!librariesDir.exists()) {\r
+                               librariesDir.mkdir();\r
+                       }\r
+                       File dir = new File(librariesDir, "functions");\r
+                       if (!dir.exists()) {\r
+                               dir.mkdir();\r
+                       }\r
+                       String parentName = NameUtils.getSafeName(graph, library);\r
+                       File scriptFile = new File(dir, parentName + ".mo");\r
+                       updateFunctionFile(graph, library, scriptFile);\r
+               }\r
+                \r
+\r
+       }\r
+       \r
+       private static void updateFunctionFile(ReadGraph graph, Resource library, File scriptFile) throws DatabaseException {\r
+               Layer0 l0 = Layer0.getInstance(graph);\r
+               SysdynResource sr = SysdynResource.getInstance(graph);\r
+               \r
+               PrintStream s;\r
+               try {\r
+                       s = new PrintStream(scriptFile);\r
+               } catch (FileNotFoundException e) {\r
+                       e.printStackTrace();\r
+                       return;\r
+               }\r
+\r
+               for(Resource function : graph.syncRequest(new ObjectsWithType(library, l0.ConsistsOf, sr.SysdynModelicaFunction))) {\r
+                       String name = NameUtils.getSafeName(graph, function);\r
+                       String functionCode = graph.getRelatedValue(function, sr.HasModelicaFunctionCode);\r
+                       s.println("function " + name);\r
+               s.println(functionCode);\r
+               s.println("end " + name + ";\n");\r
+               }\r
+               s.close();\r
+       }\r
+}\r
index df26b56f34894fef70381d3f3a967fc5e7194093..8fc4baa83c25864988e9fce1d38feea7788b1d5b 100644 (file)
@@ -23,6 +23,7 @@ import org.simantics.db.VirtualGraph;
 import org.simantics.db.WriteGraph;\r
 import org.simantics.db.common.request.ReadRequest;\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.service.VirtualGraphSupport;\r
 import org.simantics.layer0.Layer0;\r
@@ -78,7 +79,7 @@ public class SysdynExperiment extends Experiment implements IDynamicExperiment {
                                        if(!projectRoot.isDirectory()) projectRoot.mkdir();\r
                                        File file = new File( projectRoot, UUID.randomUUID().toString() + ".dbb");\r
 \r
-                                       String name = GraphUtils.findFreshName(graph, "Result", model, l0.ConsistsOf, "%s%d");\r
+                                       String name = NameUtils.findFreshName(graph, "Result", model, l0.ConsistsOf, "%s%d");\r
 \r
                                        SysdynResource sr = SysdynResource.getInstance(graph);\r
                                        Resource res = GraphUtils.create2(graph, sr.Result,\r
index ea60079fb6550aed13b4cac2b76b3aff92ce4a58..1b5df7cee7062cf43fd9b15923590781562f50e9 100644 (file)
@@ -156,6 +156,14 @@ public class SysdynModel implements IMappingListener, IModel {
                if (!simulationDir.exists()) {\r
                        simulationDir.mkdir();\r
                }\r
+               \r
+               try {\r
+                       FunctionUtils.updateFunctionFilesForModel(g, this);\r
+               } catch (DatabaseException e) {\r
+                       System.err.println("Error creating functions");\r
+                       e.printStackTrace();\r
+               }\r
+               \r
        }\r
 \r
 \r
@@ -194,11 +202,19 @@ public class SysdynModel implements IMappingListener, IModel {
                if(model.getTolerance() != null)\r
                        inits.put("tolerance", model.getTolerance().toString());\r
 \r
+               StringBuilder functionscript = new StringBuilder();\r
+               for(String path : FunctionUtils.getLibraryPathsForModelica(this)) {\r
+                       System.out.println("loadFile(\"" + path + "\");\n");\r
+                       functionscript.append("loadFile(\"" + path + "\");\n"); \r
+               }\r
+               \r
                final SimulationLocation simulationLocation = ModelicaManager.createInputFiles(\r
                                simulationDir,\r
                                configuration.getName(),\r
                                writer.toString(),\r
-                               inits);\r
+                               inits,\r
+                               functionscript.toString());\r
+               \r
 \r
                progressMonitor.worked(1);\r
 \r
@@ -473,5 +489,9 @@ public class SysdynModel implements IMappingListener, IModel {
                }\r
                return inits;\r
        }\r
+       \r
+       public File getSimulationDir() {\r
+               return simulationDir;\r
+       }\r
 \r
 }\r
index 9bfc195dcfc67006c85a851c266deee01d8b0e9d..1c2bc559817dabe2e6f3e0c60fe9c3280af891bd 100644 (file)
@@ -43,7 +43,7 @@ public class ModelicaWriter {
        \r
         writeConfiguration(conf);\r
 \r
-        if(!functionsWritten) {\r
+        if(false) {\r
 \r
             b.append(\r
                     "\nfunction interpolate\n" +\r
index 620c8b5169ed1d13d23ae987cb7424b1745a5c84..968041b3e06d782b6dce31dc6a08c4d27e111b53 100644 (file)
@@ -53,7 +53,9 @@ public class StockExpression extends Expression {
                range = sb.toString();\r
        }\r
         \r
-        String each = variable.getArrayIndexes().getEnumerations().isEmpty() ? "" : "each";\r
+       String each = "";\r
+       if(ai != null && !ai.getEnumerations().isEmpty())\r
+               each = "each";\r
         if (value == null) {\r
             return "    " + variable.getType() + " " + variable.getName() + range + "(" + each + " fixed=false);\n";\r
         } else {\r
index 02ed6ba79b3f80d278d2a6c2e9d64264509dd76b..5eb54fdbc525aeabb8c1f39a71e1b62fbd7e629a 100644 (file)
  *******************************************************************************/\r
 package org.simantics.sysdyn.representation.expressions;\r
 \r
+import java.util.ArrayList;\r
+import java.util.Iterator;\r
+\r
 import org.simantics.objmap.annotations.GraphType;\r
 import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.ArrayIndexes;\r
+import org.simantics.sysdyn.representation.Enumeration;\r
 import org.simantics.sysdyn.representation.IndependentVariable;\r
+import org.simantics.sysdyn.representation.utils.IndexUtils;\r
 \r
 \r
 @GraphType("http://www.simantics.org/Sysdyn-1.0/WithLookupExpression")\r
@@ -26,13 +32,37 @@ public class WithLookupExpression extends Expression {
 \r
     @Override\r
     public String getDeclaration(IndependentVariable variable) {\r
-        return "    " + variable.getType() + " " + variable.getName() + ";\n";\r
+       ArrayIndexes ai = variable.getArrayIndexes();\r
+       ArrayList<Enumeration> enumerations = null;\r
+       if(ai != null) \r
+               enumerations = ai.getEnumerations();\r
+       \r
+       String range = "";\r
+       if(enumerations != null && enumerations.size() > 0) {\r
+               StringBuilder sb = new StringBuilder();\r
+               sb.append("[");\r
+               Iterator<Enumeration> iterator = enumerations.iterator();\r
+               while(iterator.hasNext()) {\r
+                       sb.append(iterator.next().getName() + ".size");\r
+                       if(iterator.hasNext()) {\r
+                               sb.append(", ");\r
+                       }\r
+               }\r
+               sb.append("]");\r
+               range = sb.toString();\r
+       }\r
+       \r
+        return "    " + variable.getType() + " " + variable.getName() + range + ";\n";\r
+\r
     }\r
 \r
     @Override\r
     public String getEquation(IndependentVariable variable) {\r
+       String equation = IndexUtils.equationRangesToIndexes(variable, this.equation);\r
+       String range = IndexUtils.rangeToIndexes(variable, this.getArrayRange());\r
+\r
         return \r
-        "    " + variable.getName() + " = interpolate(" + equation + ", " + lookupTable + ");\n";\r
+        "    " + variable.getName() + (range.equals("[:]") ? "" : range) + " = interpolate(" + equation + ", " + lookupTable + ");\n";\r
     }\r
 \r
 }\r