]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
refs #6860 Sysdyn update site on top of Simantics Desktop trunk
authorvillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 8 Dec 2016 13:03:33 +0000 (13:03 +0000)
committervillberg <villberg@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 8 Dec 2016 13:03:33 +0000 (13:03 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@33407 ac1ea38d-2e2b-0410-8846-a27921b304fc

16 files changed:
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ontology/graph/SysdynModelingViewpoint.pgraph
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/META-INF/MANIFEST.MF
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/project/SysdynProject.java
org.simantics.sysdyn/META-INF/MANIFEST.MF
org.simantics.sysdyn/src/org/simantics/sysdyn/Activator.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/InternalGameExperimentFactory.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperimentFactory.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperimentBase.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
org.simantics.sysdyn/src/org/simantics/sysdyn/solver/ModelicaSolver.java [deleted file]
org.simantics.sysdyn/src/org/simantics/sysdyn/solver/Solvers.java [new file with mode: 0644]

index 8700d51bd699ba3e45de82f120ad6e0922fa818a..21006429bec0916f51146b5021720eba0a9be123 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index ffd674d8c42cf494e589ad99d4a4ea3891b063df..04c7a5d6b16743097e74a9a732021b62091f44d1 100644 (file)
@@ -120,39 +120,41 @@ SYSDYN.Variable <T SYSDYN.Component
     >-- SYSDYN.Variable.value <R L0.HasProperty : L0.FunctionalRelation
     @L0.assert SYSDYN.Variable.value 
         _ : L0.Value    
-            L0.domainProperties FUNCTIONS.valuePropertyProperties : L0.ExternalValue
-            L0.valueAccessor FUNCTIONS.valuePropertyValue : L0.ExternalValue
+            L0.domainProperties FUNCTIONS.valuePropertyProperties
+            L0.valueAccessor FUNCTIONS.valuePropertyValue
     >-- SYSDYN.Variable.values <R L0.HasProperty : L0.FunctionalRelation
     @L0.assert SYSDYN.Variable.values 
         _ : L0.Value    
-            L0.domainProperties FUNCTIONS.valuePropertyProperties : L0.ExternalValue
-            L0.valueAccessor FUNCTIONS.valuePropertyValue : L0.ExternalValue
+            L0.domainProperties FUNCTIONS.valuePropertyProperties
+            L0.valueAccessor FUNCTIONS.valuePropertyValue
     >-- SYSDYN.Variable.times <R L0.HasProperty : L0.FunctionalRelation
     @L0.assert SYSDYN.Variable.times
         _ : L0.Value
-            L0.domainProperties FUNCTIONS.valuePropertyProperties : L0.ExternalValue
-            L0.valueAccessor FUNCTIONS.valuePropertyValue : L0.ExternalValue
+            L0.domainProperties FUNCTIONS.valuePropertyProperties
+            L0.valueAccessor FUNCTIONS.valuePropertyValue
     >-- SYSDYN.Variable.names <R L0.HasProperty : L0.FunctionalRelation
     @L0.assert SYSDYN.Variable.names 
         _ : L0.Value    
-            L0.domainProperties FUNCTIONS.valuePropertyProperties : L0.ExternalValue
-            L0.valueAccessor FUNCTIONS.valuePropertyValue : L0.ExternalValue
+            L0.domainProperties FUNCTIONS.valuePropertyProperties
+            L0.valueAccessor FUNCTIONS.valuePropertyValue
     >-- SYSDYN.Variable.activeDatasets <R L0.HasProperty : L0.FunctionalRelation
     @L0.assert SYSDYN.Variable.activeDatasets 
         _ : L0.Value    
-            L0.domainProperties FUNCTIONS.valuePropertyProperties : L0.ExternalValue
-            L0.valueAccessor FUNCTIONS.valuePropertyValue : L0.ExternalValue    
+            L0.domainProperties FUNCTIONS.valuePropertyProperties
+            L0.valueAccessor FUNCTIONS.valuePropertyValue    
     >-- SYSDYN.Variable.time <R L0.HasProperty : L0.FunctionalRelation
     @L0.assert SYSDYN.Variable.time 
         _ : L0.Value    
-            L0.domainProperties FUNCTIONS.valuePropertyProperties : L0.ExternalValue
-            L0.valueAccessor FUNCTIONS.valuePropertyValue : L0.ExternalValue
+            L0.domainProperties FUNCTIONS.valuePropertyProperties
+            L0.valueAccessor FUNCTIONS.valuePropertyValue
 
     >-- SYSDYN.Variable.equation <R L0.HasProperty : L0.FunctionalRelation
         L0.valueAccessor FUNCTIONS.equationPropertyValue : L0.ExternalValue
     @L0.assert SYSDYN.Variable.equation 
         _ : L0.Value
 
+FUNCTIONS.valuePropertyProperties : L0.ExternalValue
+FUNCTIONS.valuePropertyValue : L0.ExternalValue
     
 FUNCTIONS.runChildren : L0.ExternalValue
     
@@ -361,14 +363,13 @@ SYSDYN.GameExperiment <T SYSDYN.Experiment
     @L0.assert SYSDYN.GameExperiment.stepLength 0.1
 
 
-FUNCTIONS.runChildren : L0.ExternalValue
 SYSDYN.Experiment.Run <T SIMU.Run
     @L0.assert L0.domainChildren FUNCTIONS.runChildren
     >-- SYSDYN.Experiment.Run.time <R L0.HasProperty : L0.FunctionalRelation
     @L0.assert SYSDYN.Experiment.Run.time 
         _ : L0.Value    
             L0.domainProperties FUNCTIONS.runProperties : L0.ExternalValue
-            L0.valueAccessor FUNCTIONS.valuePropertyValue : L0.ExternalValue    
+            L0.valueAccessor FUNCTIONS.valuePropertyValue    
 
 SYSDYN.SimulateOnChangeExperiment <T SYSDYN.Experiment
 
@@ -435,7 +436,7 @@ SYSDYN.HistoryDataset <T SYSDYN.Result
     >-- SYSDYN.HistoryDataset.sheet --> SHEET.Spreadsheet <R L0.IsRelatedTo : L0.FunctionalRelation
     
 SYSDYN.ResultSet <T L0.Entity
-    >-- SYSDYN.Experiment.result --> SYSDYN.Result <R L0.IsComposedOf
+    >-- SYSDYN.Experiment.result
 
 SYSDYN.InitialCondition <T MOD.InitialCondition
     >-- SYSDYN.InitialCondition.HasInitialValues --> MOD.PartialIC <R L0.HasProperty : L0.FunctionalRelation
@@ -497,7 +498,7 @@ SYSDYN.ValveSymbol <T SYSDYN.SysdynSymbol
     @L0.assert SYSDYN.ValveSymbol.orientation SYSDYN.Horizontal
     >-- SYSDYN.ValveSymbol.textLocation --> SYSDYN.Location <R L0.IsWeaklyRelatedTo : L0.FunctionalRelation
     L0.IsDependencyOf BasicSymbols
-    STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext 
+    STR.IsDefinedBy _ : DIA.Composite 
         @L0.orderedSet 
             _ : SYSDYN.SysdynTerminal
                 @MOD.terminal SYSDYN.ValveSymbol SYSDYN.IsHeadOfTerminal
@@ -513,7 +514,7 @@ SYSDYN.AuxiliarySymbol <T SYSDYN.SysdynSymbol
     @MOD.defSymbol "Auxiliary" SYSDYN.Auxiliary
     L0.HasDescription "(Shift+A)"
     L0.IsDependencyOf BasicSymbols
-    STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext 
+    STR.IsDefinedBy _ : DIA.Composite 
         @L0.orderedSet 
             _ : SYSDYN.SysdynTerminal
                 @MOD.terminal SYSDYN.AuxiliarySymbol SYSDYN.IsHeadOfTerminal
@@ -529,7 +530,7 @@ SYSDYN.CloudSymbol <T SYSDYN.SysdynSymbol
     @MOD.defSymbol "Cloud" SYSDYN.Cloud
     L0.HasDescription "(Shift+C)"
     L0.IsDependencyOf BasicSymbols
-    STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext 
+    STR.IsDefinedBy _ : DIA.Composite 
         @L0.orderedSet 
             _ : SYSDYN.SysdynTerminal
                 @MOD.terminal SYSDYN.CloudSymbol SYSDYN.IsHeadOfTerminal
@@ -545,7 +546,7 @@ SYSDYN.InputSymbol <T SYSDYN.SysdynSymbol
     @MOD.defSymbol "Input" SYSDYN.Input
     L0.HasDescription "(Shift+I)"
     L0.IsDependencyOf BasicSymbols
-    STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext 
+    STR.IsDefinedBy _ : DIA.Composite 
         @L0.orderedSet
             _ : SYSDYN.SysdynTerminal
                 @MOD.terminal SYSDYN.InputSymbol SYSDYN.IsHeadOfTerminal
@@ -561,7 +562,7 @@ SYSDYN.StockSymbol <T SYSDYN.SysdynSymbol
     @MOD.defSymbol "Stock" SYSDYN.Stock
     L0.HasDescription "(Shift+S)"
     L0.IsDependencyOf BasicSymbols
-    STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext 
+    STR.IsDefinedBy _ : DIA.Composite 
         @L0.orderedSet 
             _ : SYSDYN.SysdynTerminal
                 @MOD.terminal SYSDYN.StockSymbol SYSDYN.IsHeadOfTerminal
@@ -577,7 +578,7 @@ SYSDYN.ShadowSymbol <T SYSDYN.SysdynSymbol
     @MOD.defSymbol "Shadow" SYSDYN.Shadow
     L0.HasDescription "(Shift+G)"
     L0.IsDependencyOf BasicSymbols
-    STR.IsDefinedBy _ : DIA.Composite <R L0.HasNext 
+    STR.IsDefinedBy _ : DIA.Composite 
         @L0.orderedSet 
             _ : SYSDYN.SysdynTerminal
                 @MOD.terminal SYSDYN.ShadowSymbol SYSDYN.IsHeadOfTerminal
index 8267cfa488b5ce0b1fac18e54baa14240f23cfbf..63acc013347374b2136ec7cb4e86a53f2756a803 100644 (file)
@@ -18,7 +18,10 @@ SAC = SYSDYN.ModelingActionContext : VP.BrowseContext
 \r
 SBC.VariableNodeType <T VP.NodeType\r
     @L0.assert VP.HasContentType "Variable"\r
-    \r
+\r
+SYSDYN.BrowseContextContribution : VP.BrowseContextContribution\r
+    VP.BrowseContextContribution.HasType SYSDYN.SysdynModel\r
+    VP.BrowseContextContribution.HasBrowseContext SBC\r
 \r
 ////////////////////////////////\r
 // From Project Viewpoint\r
index 060bf69637912d923d2842fd370438b5327ea32a..dd937a96a069e327b674e9d1e2927fcc21044890 100644 (file)
@@ -21,6 +21,7 @@ public class SysdynResource {
     public final Resource AvailableVariableIndexes;\r
     public final Resource BasicExperiment;\r
     public final Resource Bottom;\r
+    public final Resource BrowseContextContribution;\r
     public final Resource Browser;\r
     public final Resource Built$in_Functions;\r
     public final Resource Built$in_Functions_Modelica_Array_Functions;\r
@@ -880,6 +881,7 @@ public class SysdynResource {
         public static final String AvailableVariableIndexes = "http://www.simantics.org/Sysdyn-1.1/AvailableVariableIndexes";\r
         public static final String BasicExperiment = "http://www.simantics.org/Sysdyn-1.1/BasicExperiment";\r
         public static final String Bottom = "http://www.simantics.org/Sysdyn-1.1/Bottom";\r
+        public static final String BrowseContextContribution = "http://www.simantics.org/Sysdyn-1.1/BrowseContextContribution";\r
         public static final String Browser = "http://www.simantics.org/Sysdyn-1.1/Browser";\r
         public static final String Built$in_Functions = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions";\r
         public static final String Built$in_Functions_Modelica_Array_Functions = "http://www.simantics.org/Sysdyn-1.1/Built-in%20Functions/Modelica%20Array%20Functions";\r
@@ -1749,6 +1751,7 @@ public class SysdynResource {
         AvailableVariableIndexes = getResourceOrNull(graph, URIs.AvailableVariableIndexes);\r
         BasicExperiment = getResourceOrNull(graph, URIs.BasicExperiment);\r
         Bottom = getResourceOrNull(graph, URIs.Bottom);\r
+        BrowseContextContribution = getResourceOrNull(graph, URIs.BrowseContextContribution);\r
         Browser = getResourceOrNull(graph, URIs.Browser);\r
         Built$in_Functions = getResourceOrNull(graph, URIs.Built$in_Functions);\r
         Built$in_Functions_Modelica_Array_Functions = getResourceOrNull(graph, URIs.Built$in_Functions_Modelica_Array_Functions);\r
index f52e9876ba83895a158506b57d5bd098e44f8a04..15e1d2cb914b69252e50fee0fadadb0d004db391 100644 (file)
@@ -54,7 +54,6 @@ Require-Bundle: org.simantics.layer0.utils;bundle-version="0.6.2",
  org.eclipse.ui.forms;bundle-version="3.5.2",
  org.simantics.scenegraph.swing;bundle-version="1.0.0",
  org.eclipse.nebula.widgets.tablecombo;bundle-version="1.0.0",
- org.simantics.fmu;bundle-version="1.0.0",
  org.simantics.jfreechart;bundle-version="1.0.0",
  org.simantics.db.indexing;bundle-version="1.1.0",
  org.simantics.workbench,
index 449a6609cfecd6ca747e12741a7b8f45edad7ee3..2aff5e8a2b3d8870e06de46bafb19e08a74a5ed5 100644 (file)
             name="Trend"\r
             restorable="true">\r
       </view>\r
-      <view\r
+      <!--<view\r
             category="org.simantics.sysdyn.ui.category"\r
             class="org.simantics.sysdyn.ui.browser.SysdynBrowser"\r
             icon="platform:/plugin/com.famfamfam.silk/icons/chart_organisation.png"\r
             id="org.simantics.sysdyn.ui.browser"\r
             name="Model Browser"\r
             restorable="true">\r
-      </view>\r
+      </view>-->\r
       <view\r
             allowMultiple="false"\r
             category="org.simantics.sysdyn.ui.category"\r
@@ -81,7 +81,7 @@
             name="Values"\r
             restorable="true">\r
       </view>\r
-      <view\r
+      <!--<view\r
             category="org.simantics.sysdyn.ui.category"\r
             class="org.simantics.sysdyn.ui.browser.SysdynModelBrowser"\r
             icon="platform:/plugin/com.famfamfam.silk/icons/chart_organisation.png"\r
@@ -91,7 +91,7 @@
          <description>\r
             Structural model browser view for Sysdyn.\r
          </description>\r
-      </view>\r
+      </view>-->\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.perspectives">\r
                relative="org.simantics.sysdyn.ui.trend.view">\r
          </view>\r
          <view\r
-               id="org.simantics.sysdyn.ui.browser"\r
+               id="org.simantics.modeling.ui.browser"\r
                ratio="0.25f"\r
                relationship="left"\r
                relative="org.eclipse.ui.editorss">\r
                id="org.simantics.diagram.symbollibrary"\r
                minimized="false"\r
                relationship="stack"\r
-               relative="org.simantics.sysdyn.ui.browser">\r
+               relative="org.simantics.modeling.ui.browser">\r
          </view>\r
          <view\r
                id="org.simantics.sysdyn.ui.values.view"\r
                id="org.simantics.workbench.search.browser"\r
                minimized="false"\r
                relationship="stack"\r
-               relative="org.simantics.sysdyn.ui.browser">\r
+               relative="org.simantics.modeling.ui.browser">\r
          </view>\r
          <!--\r
          <view\r
                relative="org.simantics.sysdyn.ui.trend.view">\r
          </view>\r
          <view\r
-               id="org.simantics.sysdyn.ui.browser"\r
+               id="org.simantics.modeling.ui.browser"\r
                minimized="true"\r
                ratio="0.25f"\r
                relationship="left"\r
                id="org.simantics.diagram.symbollibrary"\r
                minimized="true"\r
                relationship="stack"\r
-               relative="org.simantics.sysdyn.ui.browser">\r
+               relative="org.simantics.modeling.ui.browser">\r
          </view>\r
          <view\r
                id="org.simantics.sysdyn.ui.values.view"\r
                id="org.simantics.workbench.search.browser"\r
                minimized="false"\r
                relationship="stack"\r
-               relative="org.simantics.sysdyn.ui.browser">\r
+               relative="org.simantics.modeling.ui.browser">\r
          </view>\r
       </perspectiveExtension>\r
       <perspectiveExtension\r
                relative="org.simantics.sysdyn.ui.trend.view">\r
          </view>\r
          <view\r
-               id="org.simantics.sysdyn.ui.browser"\r
+               id="org.simantics.modeling.ui.browser"\r
                minimized="true"\r
                ratio="0.25f"\r
                relationship="left"\r
                id="org.simantics.diagram.symbollibrary"\r
                minimized="false"\r
                relationship="stack"\r
-               relative="org.simantics.sysdyn.ui.browser">\r
+               relative="org.simantics.modeling.ui.browser">\r
          </view>\r
          <view\r
                id="org.simantics.sysdyn.ui.values.view"\r
                id="org.simantics.workbench.search.browser"\r
                minimized="false"\r
                relationship="stack"\r
-               relative="org.simantics.sysdyn.ui.browser">\r
+               relative="org.simantics.modeling.ui.browser">\r
          </view>\r
       </perspectiveExtension>\r
    </extension>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.menus">\r
-      <menuContribution\r
+      <!--<menuContribution\r
             locationURI="menu:sFile?after=import.ext">\r
          <command commandId="org.eclipse.ui.file.import" />\r
          <command commandId="org.eclipse.ui.file.export" />\r
-      </menuContribution>\r
+      </menuContribution>-->\r
       <menuContribution\r
             locationURI="toolbar:org.eclipse.ui.main.toolbar">\r
          <toolbar\r
index 96f4a89ca96b31665f500f5f0c0c9ef6fa843802..b29642abaaecb30d6246479fe1837aa90034e2a6 100644 (file)
@@ -12,7 +12,6 @@
 package org.simantics.sysdyn.ui.project;\r
 \r
 import java.io.File;\r
-import java.io.IOException;\r
 import java.util.HashMap;\r
 \r
 import org.eclipse.core.runtime.Platform;\r
@@ -30,7 +29,6 @@ import org.simantics.db.layer0.service.ActivationManager;
 import org.simantics.db.request.Read;\r
 import org.simantics.db.service.GraphChangeListenerSupport;\r
 import org.simantics.db.service.VirtualGraphSupport;\r
-import org.simantics.fmu.FMUControlJNI;\r
 import org.simantics.issues.common.IssueUtils;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.modeling.ModelingUtils;\r
@@ -48,7 +46,6 @@ import org.simantics.simulation.project.IExperimentManager;
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.editor.SysdynEditorNamingService;\r
 import org.simantics.ui.workbench.IEditorNamingService;\r
-import org.simantics.utils.FileUtils;\r
 import org.simantics.utils.ui.BundleUtils;\r
 \r
 public class SysdynProject extends AbstractProjectFeature {\r
@@ -139,9 +136,6 @@ public class SysdynProject extends AbstractProjectFeature {
 \r
                cleanProjectFolder(session, project.get());\r
 \r
-               // Clean all temporary files possibly left by previous sysdyn instances\r
-               clearFMUTempDirectory();\r
-\r
 \r
                // Issues\r
                try {\r
@@ -156,35 +150,6 @@ public class SysdynProject extends AbstractProjectFeature {
                }\r
        }\r
 \r
-       /**\r
-        * Clears fmu temp directory. This directory hosts\r
-        * fmu files for game experiments. In normal situations\r
-        * experiments clean up their temp files, but for example\r
-        * a system crash may leave files to temp directory. \r
-        */\r
-       private void clearFMUTempDirectory() {\r
-               // Find commone "TEMP/fmu" directory\r
-               File commonDir = new File(FMUControlJNI.TEMP_FMU_COMMON_DIRECTORY);\r
-               if(commonDir != null && commonDir.isDirectory()) {\r
-\r
-                       // List all files and directories in "TEMP/fmu" \r
-                       for(File child : commonDir.listFiles()) {\r
-                               if(child.isDirectory()) {\r
-                                       // If directory is found, try to get the lock file in it\r
-                                       File lock = new File(child, FMUControlJNI.LOCK_FILE_NAME);\r
-                                       if(!lock.isFile() || lock.delete()) {\r
-                                               // If lock is not found, or the lock can be delted, the directory is not locked. -> Delete the rest of the directory\r
-                                               try {\r
-                                                       FileUtils.deleteAll(child);\r
-                                                       child.delete();\r
-                                               } catch (IOException e) {\r
-\r
-                                               }\r
-                                       }\r
-                               }\r
-                       }\r
-               }\r
-       }\r
 \r
        @Override\r
        public void deconfigure() throws ProjectException {\r
index 8bf988ceeb52e574e8a0d5f3782e1ea0b1c31d0c..2083aad03060a778818d65ac241e3c779023e39d 100644 (file)
@@ -26,7 +26,6 @@ Require-Bundle: org.simantics.objmap;bundle-version="0.1.0",
  org.simantics.spreadsheet;bundle-version="1.1.0",
  org.eclipse.jface.text;bundle-version="3.6.1",
  org.simantics.spreadsheet.ontology;bundle-version="1.2.0",
- org.simantics.fmu;bundle-version="1.0.0",
  org.simantics.issues;bundle-version="1.1.0",
  org.simantics.issues.common;bundle-version="1.1.0",
  org.simantics.jfreechart;bundle-version="1.0.0",
index 2970af2851148129c611e3b546ef5767035f487b..39ba5a16cdb39cd229f3e4ba2cb1b764fc128582 100644 (file)
@@ -15,6 +15,9 @@ import java.io.File;
 \r
 import org.osgi.framework.BundleActivator;\r
 import org.osgi.framework.BundleContext;\r
+import org.simantics.sysdyn.manager.InternalGameExperimentFactory;\r
+import org.simantics.sysdyn.solver.SolverSettings.SolverType;\r
+import org.simantics.sysdyn.solver.Solvers;\r
 \r
 public class Activator implements BundleActivator {\r
 \r
@@ -34,16 +37,17 @@ public class Activator implements BundleActivator {
             modelsDir.mkdir();\r
         }\r
         plugin = this;\r
+               Solvers.registerGameExperimentFactory(SolverType.INTERNAL, new InternalGameExperimentFactory());\r
     }\r
 \r
     @Override\r
     public void stop(BundleContext context) throws Exception {\r
+               Solvers.unregisterGameExperimentFactory(SolverType.INTERNAL);\r
         File modelsDir = Activator.getBundleContext().getDataFile("models");\r
         if (modelsDir.exists()) {\r
             recursiveDelete(modelsDir);\r
         }\r
         plugin = null;\r
-\r
     }\r
 \r
     public static Activator getDefault() {\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/InternalGameExperimentFactory.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/InternalGameExperimentFactory.java
new file mode 100644 (file)
index 0000000..818487c
--- /dev/null
@@ -0,0 +1,12 @@
+package org.simantics.sysdyn.manager;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class InternalGameExperimentFactory implements SysdynExperimentFactory {\r
+\r
+       @Override\r
+       public SysdynExperiment create(Resource experiment, Resource model) {\r
+               return new SysdynGameExperimentInternal(experiment, model);\r
+       }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperimentFactory.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynExperimentFactory.java
new file mode 100644 (file)
index 0000000..b0c8cdf
--- /dev/null
@@ -0,0 +1,9 @@
+package org.simantics.sysdyn.manager;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public interface SysdynExperimentFactory {\r
+\r
+       SysdynExperiment create(Resource experiment, Resource model);\r
+       \r
+}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynGameExperiment.java
deleted file mode 100644 (file)
index 3a39667..0000000
+++ /dev/null
@@ -1,415 +0,0 @@
-/*******************************************************************************\r
- * Copyright (c) 2007, 2012, 2015 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- *     VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.manager;\r
-\r
-import gnu.trove.list.array.TDoubleArrayList;\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.FileNotFoundException;\r
-import java.io.FileOutputStream;\r
-import java.io.IOException;\r
-import java.lang.reflect.Field;\r
-import java.util.HashMap;\r
-\r
-import org.eclipse.core.runtime.IProgressMonitor;\r
-import org.eclipse.core.runtime.NullProgressMonitor;\r
-import org.simantics.Simantics;\r
-import org.simantics.databoard.Bindings;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Session;\r
-import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.WriteRequest;\r
-import org.simantics.db.common.utils.Logger;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.db.layer0.util.Layer0Utils;\r
-import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.layer0.variable.Variables;\r
-import org.simantics.db.request.Read;\r
-import org.simantics.fmu.FMUControlJNI;\r
-import org.simantics.fmu.FMUJNIException;\r
-import org.simantics.modelica.IModelicaMonitor;\r
-import org.simantics.modelica.ModelicaManager;\r
-import org.simantics.modelica.SimulationLocation;\r
-import org.simantics.modeling.PartialIC;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.simulation.SimulationJob.HeadlessModelicaMonitor;\r
-import org.simantics.sysdyn.solver.ISolver;\r
-import org.simantics.sysdyn.solver.ModelicaSolver;\r
-\r
-/**\r
- * Game experiment\r
- * @author Teemu Lempinen\r
- *\r
- */\r
-public class SysdynGameExperiment extends SysdynGameExperimentBase {\r
-\r
-       private ModelicaSolver solver;\r
-       public FMUControlJNI control;\r
-       private boolean loaded = false;\r
-       \r
-       private static boolean fortranLibrariesLoaded = false;\r
-       \r
-       public SysdynGameExperiment(Resource experiment, Resource model) {\r
-               super(experiment, model);\r
-               this.solver = new ModelicaSolver(this);\r
-       }\r
-       \r
-       public FMUControlJNI getFMUControl() {\r
-               return control;\r
-       }\r
-       \r
-       @Override\r
-       public void init(ReadGraph g) {\r
-               super.init(g);\r
-\r
-               if(control == null)\r
-                       control = new FMUControlJNI();\r
-               \r
-               results = new TDoubleArrayList[results != null ? results.length : 0];\r
-               \r
-       }\r
-       \r
-       @Override\r
-       protected void onExperimentDisposed() {\r
-               super.onExperimentDisposed();\r
-               if(control!=null) {\r
-                       try {\r
-                               control.unloadFMU();\r
-                               loaded = false;\r
-                       } catch (FMUJNIException e) {\r
-                               e.printStackTrace();\r
-                       }\r
-               }\r
-       }\r
-\r
-       private boolean isValidFMU(File file) {\r
-               if(!file.exists()) return false;\r
-               if(!file.isFile()) return false;\r
-               if(file.length() == 0) return false;\r
-               return true;\r
-       }\r
-       \r
-\r
-       @Override\r
-       public synchronized void simulate(final IModelicaMonitor monitor, final IProgressMonitor progressMonitor, String modelName) throws IOException {\r
-               canceled = false;\r
-\r
-               progressMonitor.subTask("Write modelica classes");\r
-\r
-               // Write Modelica files       \r
-               String modelText = getModelicaCode(monitor, true, getOpenModelicaVersion());\r
-               if(modelText == null)\r
-                       return;\r
-               \r
-        omcVersion = ModelicaManager.getDefaultOMVersion();\r
-        \r
-        monitor.message("Simulate " + modelName + " using OpenModelica " + omcVersion);\r
-        \r
-               progressMonitor.worked(1);\r
-\r
-               // Write initial files and add init-parameters\r
-               progressMonitor.subTask("Write simulation files");\r
-               HashMap<String, String> inits = getExperimentParameters(monitor);\r
-\r
-\r
-               // add loadFile script to load all related functions and function libraries \r
-               String additionalScript = getAdditionalScripts();\r
-\r
-               // Create simulation files\r
-               SimulationLocation simulationLocation = createSimulationFiles(sysdynModel, modelText, inits, additionalScript, true);\r
-               progressMonitor.worked(1);\r
-\r
-               // Load precompiled fmu if structure has not changed and it has not yet been loaded\r
-               File fmu = null;\r
-               if(!sysdynModel.isStructureModified()) {\r
-                   if(!simulationLocation.executableFile.isFile()) {\r
-                       fmu = loadModelFmu(simulationLocation);\r
-                   } else {\r
-                       fmu = simulationLocation.executableFile;\r
-                   }\r
-               }\r
-               // Build the model and store previous model structure and inits that affect the building\r
-               // If there is no exe file OR the model structure has not changed, no need to build\r
-               if (fmu == null && (!isValidFMU(simulationLocation.executableFile) || sysdynModel.isStructureModified())) {\r
-                       progressMonitor.subTask("Build model");\r
-                       buildModel(simulationLocation, monitor);\r
-                       \r
-                       saveModelFmu(simulationLocation);\r
-               }\r
-\r
-               progressMonitor.worked(1);\r
-\r
-               if(simulationLocation != null && !canceled) {\r
-                       // Load fmu and initialize it for simulation\r
-                       try {\r
-                               if (!fortranLibrariesLoaded) { // Enable this when we update from OpenModelica 1.9.0beta4!\r
-                                       File omDir = ModelicaManager.getOMHome();\r
-                                       File mingw = new File(omDir, "MinGW");\r
-                                       File mbin = new File(mingw, "bin");\r
-                                       \r
-                                       // Add MinGW path to java.library.path. This is a bit of a hack because \r
-                                       // java.library.path isn't intended to be set programmatically.\r
-                                       String newLibPath = System.getProperty("java.library.path") + File.pathSeparator + mbin.getAbsolutePath();\r
-                                       System.setProperty("java.library.path", newLibPath);\r
-                                       Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");\r
-                                       fieldSysPath.setAccessible(true);\r
-                                       if (fieldSysPath != null) {\r
-                                               fieldSysPath.set(System.class.getClassLoader(), null);\r
-                                       }\r
-                                       \r
-                                       System.loadLibrary("libgfortran-3");\r
-                                       System.out.println("Loaded libgfortran-3.dll");\r
-                                       System.loadLibrary("pthreadGC2");\r
-                                       System.out.println("Loaded pthreadGC2.dll");\r
-                                       fortranLibrariesLoaded = true;\r
-                               }\r
-                \r
-                               control.loadFMUFile(simulationLocation.executableFile.getAbsolutePath()); // unzip and load fmu\r
-                               loaded = true;\r
-                               instantiate();\r
-                               \r
-                       } catch (FMUJNIException e) {\r
-                               System.err.println("SysdynGameExperiment initialization failed:\n\t" + e.getMessage());\r
-                       } catch (SecurityException e) {\r
-                               // TODO Auto-generated catch block\r
-                               e.printStackTrace();\r
-                       } catch (NoSuchFieldException e) {\r
-                               // TODO Auto-generated catch block\r
-                               e.printStackTrace();\r
-                       } catch (IllegalArgumentException e) {\r
-                               // TODO Auto-generated catch block\r
-                               e.printStackTrace();\r
-                       } catch (IllegalAccessException e) {\r
-                               // TODO Auto-generated catch block\r
-                               e.printStackTrace();\r
-                       }\r
-\r
-               }\r
-               process = null;\r
-               simulate(false); \r
-       }\r
-\r
-       /**\r
-        * Load fmu file from database, if it exists for the model of this experiment\r
-        * \r
-        * @param simulationLocation SimulationLocation indicating where the fmu should be loaded\r
-        * @return Loaded fmu or null if it was not loaded from database\r
-        */\r
-       private File loadModelFmu(SimulationLocation simulationLocation) {\r
-           File fmu = null;\r
-           try {\r
-               final String fmuLocation = simulationLocation.executableFile.getAbsolutePath();\r
-            fmu = session.syncRequest(new Read<File>() {\r
-                @Override\r
-                public File perform(ReadGraph graph) throws DatabaseException {\r
-                    File result = null;\r
-                    FileOutputStream fos;\r
-                    try {\r
-                        fos = new FileOutputStream(fmuLocation);\r
-                        byte[] fileBArray = graph.getPossibleRelatedValue(\r
-                                getModel(), SysdynResource.getInstance(graph).SysdynModel_fmuFile, Bindings.BYTE_ARRAY);\r
-                        \r
-                        if(fileBArray != null) {\r
-                            fos.write(fileBArray);\r
-                            fos.close();\r
-                            result = new File(fmuLocation);\r
-                        } else {\r
-                            fos.close();\r
-                            return null;\r
-                        }\r
-                        \r
-                    } catch (FileNotFoundException e) {\r
-                        e.printStackTrace();\r
-                    } catch (IOException e) {\r
-                        e.printStackTrace();\r
-                    }\r
-                    return result;\r
-                }\r
-            });\r
-        } catch (DatabaseException e) {\r
-            e.printStackTrace();\r
-        }\r
-           \r
-           return fmu;\r
-       }\r
-       \r
-       /**\r
-        * Save fmu file from simulationLocation to database\r
-        * @param simulationLocation Location for finding fmu\r
-        */\r
-       private void saveModelFmu(SimulationLocation simulationLocation) {\r
-           final String fmuLocation = simulationLocation.executableFile.getAbsolutePath();\r
-           session.asyncRequest(new WriteRequest() {\r
-\r
-               @Override\r
-               public void perform(WriteGraph graph) throws DatabaseException {\r
-                   File file = new File(fmuLocation);\r
-                   byte[] fileBArray = new byte[(int)file.length()];\r
-                   FileInputStream fis;\r
-                   try {\r
-                       fis = new FileInputStream(file);\r
-\r
-                       fis.read(fileBArray);\r
-                       graph.claimLiteral(\r
-                               getModel(), \r
-                               SysdynResource.getInstance(graph).SysdynModel_fmuFile, \r
-                               fileBArray, Bindings.BYTE_ARRAY);\r
-                       fis.close();\r
-                   } catch (FileNotFoundException e) {\r
-                       e.printStackTrace();\r
-                   } catch (IOException e) {\r
-                       e.printStackTrace();\r
-                   }\r
-            }\r
-        });\r
-       }\r
-\r
-\r
-       @Override\r
-    public void rewindTo(double time) {\r
-       \r
-        if(control == null)\r
-            return;\r
-        \r
-        if(time >-0.001 && time < 0.001) {\r
-               try {\r
-                               simulate(new HeadlessModelicaMonitor(), new NullProgressMonitor(), sysdynModel.getConfiguration().getLabel());\r
-                   //instantiate();\r
-                       } catch (IOException e) {\r
-                               Logger.defaultLogError(e);\r
-                       }\r
-        } else {\r
-            System.out.println("rewindTo");\r
-        }\r
-    }\r
-    \r
-    @Override\r
-    public void refresh(Session session) {\r
-        try {\r
-            control.initializeSimulation();\r
-            clearResults();\r
-            //getInitialResultValues();\r
-            \r
-        } catch (FMUJNIException e) {\r
-            System.err.println("SysdynGameExperiment instantiate failed: " + e.getMessage());\r
-        }\r
-    }\r
-    \r
-    private synchronized void instantiate() {\r
-        try {\r
-            HashMap<String, String> inits = getExperimentParameters(null);\r
-\r
-            control.setStepLength(stepLength); // FIXME: fixed step lenghth\r
-            control.setTime(startTime);\r
-            control.instantiateSimulation(); // instantiate simulation\r
-\r
-            if(!control.isInitialized()) {\r
-                       control.initializeSimulation();\r
-                   }\r
-\r
-            if(inits.get("variableFilter") == null || inits.get("variableFilter").equals(".*"))\r
-                subscription = control.getAllVariables();\r
-            else\r
-                subscription = control.filterVariables(inits.get("variableFilter"));\r
-            \r
-            // Initialize subscription indexes map for fast result reading in getValue()\r
-            if(subscriptionIndexes == null)\r
-                subscriptionIndexes = new HashMap<String, Integer>();\r
-            \r
-            subscriptionIndexes.clear();\r
-            for(int i = 0; i < subscription.length; i++) {\r
-                subscriptionIndexes.put(subscription[i], i);\r
-            }\r
-            \r
-            results = new TDoubleArrayList[subscription.length];\r
-\r
-            // Initialize container for current simulation results\r
-            currentValues = new double[subscription.length];\r
-            \r
-            // subscribe all variables\r
-            control.subscribe(subscription); \r
-\r
-            clearResults();\r
-            //getInitialResultValues();\r
-            \r
-                       Simantics.getSession().syncRequest(new WriteRequest() {\r
-\r
-                               @Override\r
-                               public void perform(WriteGraph graph) throws DatabaseException {\r
-\r
-                                       Resource run = Layer0Utils.getPossibleChild(graph, SysdynGameExperiment.this.experiment, getIdentifier());\r
-                                       if(run == null) {\r
-                                               System.err.println("No run");\r
-                                               return;\r
-                                       }\r
-                                       \r
-                                       Variable base = Variables.getVariable(graph, run);\r
-                                       \r
-                                       SysdynResource SYSDYN = SysdynResource.getInstance(graph);\r
-                                       \r
-                                       Resource ic = graph.getPossibleObject(SysdynGameExperiment.this.experiment, SYSDYN.Experiment_ic);\r
-                                       if(ic == null) return;\r
-                                       \r
-                                       PartialIC data = graph.getPossibleRelatedValue(ic, SYSDYN.InitialCondition_HasInitialValues, PartialIC.BINDING);\r
-                                       data.apply(graph, base);\r
-                                       \r
-                               }\r
-                               \r
-                       });\r
-            \r
-        } catch (FMUJNIException e) {\r
-            System.err.println("SysdynGameExperiment instantiate failed: " + e.getMessage());\r
-        } catch (DatabaseException e) {\r
-            System.err.println("SysdynGameExperiment instantiate failed: " + e.getMessage());\r
-               }\r
-    }\r
-\r
-//    private synchronized void getInitialResultValues() {\r
-//        try {\r
-//            // Initialize results\r
-//            results.clear();\r
-//\r
-//            currentValues = control.getSubscribedResults(currentValues);\r
-//            for(int k = 0; k < subscription.length; k++) {\r
-//                results.put(subscription[k], new ArrayList<Double>());\r
-//                results.get(subscription[k]).add(currentValues[k]);\r
-//            }\r
-//\r
-//            ((MemoryResult)getCurrentResult()).setResult(new GameResult(this.results, this.subscription));\r
-//            resultsChanged();  \r
-//        } catch (FMUJNIException e) {\r
-//            System.err.println("SysdynGameExperiment getInitialResultValues failed: " + e.getMessage());\r
-//        }\r
-//    }\r
-    \r
-    @Override\r
-    public void updateSubscriptions() {\r
-       \r
-       if(!loaded) return;\r
-       \r
-        try {\r
-            if(control.isInitialized())\r
-                currentValues = control.getSubscribedResults(currentValues);\r
-        } catch (FMUJNIException e) {\r
-            e.printStackTrace();\r
-        }\r
-        super.updateSubscriptions();\r
-    }\r
-\r
-       @Override\r
-       public ISolver getSolver() {\r
-               return solver;\r
-       }\r
-    \r
- }\r
index 79f17152e0fe30c712692d9b983f9ca6a7de8958..797c843940837695d636a4474ec140e70fd0896d 100644 (file)
@@ -23,7 +23,6 @@ import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.procedure.AsyncListener;\r
 import org.simantics.db.request.Read;\r
-import org.simantics.fmu.FMUJNIException;\r
 import org.simantics.simulation.experiment.ExperimentState;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.solver.ISolver;\r
@@ -46,7 +45,7 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment {
        public HashMap<String, Integer> subscriptionIndexes;\r
        protected double[] currentValues; // Current values from FMU. Updated with updateSubscriptions\r
        \r
-       TDoubleArrayList[] results;\r
+       protected TDoubleArrayList[] results;\r
 \r
        public String[] subscription;\r
        \r
@@ -117,7 +116,7 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment {
         return null;\r
     }\r
 \r
-       public void setSubscribedResults(IProgressMonitor monitor, double time) throws FMUJNIException {\r
+       public void setSubscribedResults(IProgressMonitor monitor, double time) throws Exception {\r
 \r
                monitor.subTask("Get results (time = " + time + ")");\r
                currentValues = getSolver().getSubscribedResults(currentValues);\r
@@ -230,7 +229,7 @@ abstract public class SysdynGameExperimentBase extends OldSysdynExperiment {
     protected void onPublishResults() {\r
        try {\r
                        setSubscribedResults(new NullProgressMonitor(), getSolver().getTime());\r
-               } catch (FMUJNIException e) {\r
+               } catch (Exception e) {\r
                        Logger.defaultLogError(e);\r
                }\r
                ((MemoryResult)getCurrentResult()).setResult(new GameResult(this, this.results, this.subscription));\r
index fedac97a249a1e00f20725430472216fd8a0fe92..d4879b710011737fd39088975e15fba748f2557d 100644 (file)
@@ -12,8 +12,6 @@
  *******************************************************************************/\r
 package org.simantics.sysdyn.manager;\r
 \r
-import gnu.trove.set.hash.THashSet;\r
-\r
 import java.util.ArrayList;\r
 import java.util.Collection;\r
 import java.util.HashMap;\r
@@ -71,6 +69,9 @@ import org.simantics.sysdyn.representation.expressions.ParameterExpression;
 import org.simantics.sysdyn.representation.expressions.StockExpression;\r
 import org.simantics.sysdyn.solver.SolverSettings;\r
 import org.simantics.sysdyn.solver.SolverSettings.SolverType;\r
+import org.simantics.sysdyn.solver.Solvers;\r
+\r
+import gnu.trove.set.hash.THashSet;\r
 \r
 /**\r
  * Maintains a Java representation of system dynamic model.\r
@@ -435,12 +436,13 @@ public class SysdynModel implements IModel, IMappingListener, VariableSubscripti
             if(g.isInstanceOf(experiment, sr.PlaybackExperiment)) {\r
                 exp = new SysdynPlaybackExperiment(experiment, modelResource);\r
             } else if(g.isInstanceOf(experiment, sr.GameExperiment)) {\r
-               if (SolverType.INTERNAL.equals(SolverSettings.getSelectedSolverType())) {\r
-                       exp = new SysdynGameExperimentInternal(experiment, modelResource);\r
-               }\r
-               else {\r
-                    exp = new SysdynGameExperiment(experiment, modelResource);\r
-               }\r
+               exp = Solvers.instantiateGameExperiment(SolverSettings.getSelectedSolverType(), experiment, modelResource);\r
+//             if (SolverType.INTERNAL.equals()) {\r
+//                     exp = new SysdynGameExperimentInternal(experiment, modelResource);\r
+//             }\r
+//             else {\r
+//                    exp = new SysdynGameExperiment(experiment, modelResource);\r
+//             }\r
             } else if(g.isInstanceOf(experiment, sr.SensitivityAnalysisExperiment)) {\r
                 exp = new SysdynSensitivityAnalysisExperiment(experiment, modelResource);\r
             } else if(g.isInstanceOf(experiment, sr.BasicExperiment)) {\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/solver/ModelicaSolver.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/solver/ModelicaSolver.java
deleted file mode 100644 (file)
index 2538068..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-package org.simantics.sysdyn.solver;\r
-\r
-import org.simantics.fmu.FMUJNIException;\r
-import org.simantics.sysdyn.manager.SysdynGameExperiment;\r
-import org.simantics.sysdyn.solver.SolverSettings.SolverType;\r
-\r
-public class ModelicaSolver implements ISolver {\r
-       \r
-       SysdynGameExperiment exp;\r
-       \r
-       public ModelicaSolver(SysdynGameExperiment exp) {\r
-               this.exp = exp;\r
-       }\r
-       \r
-       @Override\r
-       public void initialize() throws Exception {\r
-               // TODO Auto-generated method stub\r
-               \r
-       }\r
-\r
-       @Override\r
-       public void buildModel() throws Exception {\r
-               // TODO Auto-generated method stub\r
-               \r
-       }\r
-\r
-       @Override\r
-       public void runSolver() throws Exception {\r
-               // TODO Auto-generated method stub\r
-               \r
-       }\r
-\r
-       @Override\r
-       public void updateResults() throws Exception {\r
-               // TODO Auto-generated method stub\r
-               \r
-       }\r
-\r
-       @Override\r
-       public SolverType getType() {\r
-               // TODO Auto-generated method stub\r
-               return null;\r
-       }\r
-\r
-       @Override\r
-       public double[] getSubscribedResults(double[] array) {\r
-               // TODO Auto-generated method stub\r
-               return null;\r
-       }\r
-\r
-       @Override\r
-       public void prepareToStep() throws Exception {\r
-\r
-               // initialize if not initialized\r
-               if(!exp.control.isInitialized()) {\r
-                       exp.control.setTime(exp.startTime);\r
-                       exp.control.initializeSimulation();\r
-                       exp.clearResults();\r
-                       //                              getInitialResultValues();\r
-               }\r
-\r
-               exp.control.setStepLength(exp.stepLength); // Set step length each time in case there has been changes\r
-               \r
-       }\r
-\r
-       @Override\r
-       public void simulateStep() throws Exception {\r
-               exp.control.simulateStep();\r
-       }\r
-\r
-       @Override\r
-       public void setStepLength(double length) throws Exception {\r
-               exp.control.setStepLength(length);\r
-       }\r
-\r
-       @Override\r
-       public double getTime() {\r
-               if(exp.control != null) {\r
-                       try {\r
-                               return exp.control.getTime();\r
-                       } catch (FMUJNIException e) {\r
-                       }\r
-               }\r
-               return 0.0;\r
-       }\r
-\r
-       @Override\r
-       public void setRealValue(String name, double value) throws Exception {\r
-               exp.control.setRealValue(name, value);\r
-       }\r
-\r
-       \r
-}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/solver/Solvers.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/solver/Solvers.java
new file mode 100644 (file)
index 0000000..4a73479
--- /dev/null
@@ -0,0 +1,52 @@
+package org.simantics.sysdyn.solver;\r
+\r
+import java.util.HashMap;\r
+import java.util.Map;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.sysdyn.manager.SysdynExperiment;\r
+import org.simantics.sysdyn.manager.SysdynExperimentFactory;\r
+\r
+public class Solvers {\r
+\r
+       private Map<SolverSettings.SolverType,SysdynExperimentFactory> gameExperimentFactories = new HashMap<>();\r
+\r
+       private static Solvers INSTANCE;\r
+       \r
+       private Solvers() {\r
+               \r
+       }\r
+       \r
+       public static synchronized Solvers getInstance() {\r
+               \r
+               if(INSTANCE == null) {\r
+                       INSTANCE = new Solvers();\r
+               }\r
+               return INSTANCE;\r
+               \r
+       }\r
+       \r
+       public static synchronized SysdynExperiment instantiateGameExperiment(SolverSettings.SolverType solver, Resource experiment, Resource model) throws Exception {\r
+\r
+               Solvers s = getInstance();\r
+               SysdynExperimentFactory factory = s.gameExperimentFactories.get(solver);\r
+               if(factory == null) throw new Exception("No game experiment factory registered as " + solver);\r
+               return factory.create(experiment, model);\r
+               \r
+       }\r
+       \r
+       public static synchronized void registerGameExperimentFactory(SolverSettings.SolverType solver, SysdynExperimentFactory factory) {\r
+               \r
+               Solvers s = getInstance();\r
+               s.gameExperimentFactories.put(solver, factory);\r
+               \r
+       }\r
+       \r
+       public static synchronized void unregisterGameExperimentFactory(SolverSettings.SolverType solver) {\r
+               \r
+               Solvers s = getInstance();\r
+               s.gameExperimentFactories.remove(solver);\r
+               \r
+       }\r
+       \r
+}\r