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