]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
Initial version of the user interface for the sensitivity analysis simulation (refs...
authormiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 15 Mar 2013 07:02:42 +0000 (07:02 +0000)
committermiettinen <miettinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Fri, 15 Mar 2013 07:02:42 +0000 (07:02 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@27102 ac1ea38d-2e2b-0410-8846-a27921b304fc

18 files changed:
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/icons/rainbow.png [new file with mode: 0644]
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/AbstractNodeImager.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewGameExperimentNodeHandler.java [moved from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewGameExperimentNodeHanlder.java with 94% similarity]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSensitivityAnalysisExperimentNodeHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/sensitivityAnalysis/RunSensitivityAnalysisExperiment.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/sensitivityAnalysis/SaveResultsHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/sensitivityAnalysis/ToggleSimulation.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/listeners/SysdynExperimentManagerListener.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/IntegerPropertyFactory.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/IntegerPropertyModifier.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynSensitivityAnalysisExperiment.java [new file with mode: 0644]

index 138c666ddf7ebd40296ee66842597ac8e4c07a96..a7b7d77e4d60bc63d49fa91846c27fd24e7fbb2d 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
index 12ada0e598be05c576f23f747889044207b4a776..30c5641a0035065c31020adbf6e4234c78f854ce 100644 (file)
@@ -345,6 +345,14 @@ SYSDYN.SimulateOnChangeExperiment <T SYSDYN.Experiment
 
 SYSDYN.PlaybackExperiment <T SYSDYN.Experiment
     
+SYSDYN.SensitivityAnalysisExperiment <T SYSDYN.Experiment
+    >-- SYSDYN.SensitivityAnalysisExperiment.propabilityDistribution --> L0.String <R L0.HasProperty : L0.FunctionalRelation
+//>-- SYSDYN.SensitivityAnalysisExperiment.variedParameter --> SYSDYN.Auxiliary <R L0.HasProperty : L0.FunctionalRelation
+    >-- SYSDYN.SensitivityAnalysisExperiment.variedParameter --> L0.String <R L0.HasProperty : L0.FunctionalRelation
+    >-- SYSDYN.SensitivityAnalysisExperiment.minValue --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
+    >-- SYSDYN.SensitivityAnalysisExperiment.maxValue --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
+    >-- SYSDYN.SensitivityAnalysisExperiment.numValues --> L0.Integer <R L0.HasProperty : L0.FunctionalRelation
+
 //#####################################################################
 // Results and history datasets
 //#####################################################################
index 3b6a342fa02f0ed331c36369faae1eb8a752666b..458c0d4826413c3f039700ec8879a560abc97ac2 100644 (file)
@@ -507,6 +507,17 @@ public class SysdynResource {
     public final Resource Result_showResult;\r
     public final Resource Right;\r
     public final Resource SelectedSharedFunctionLibraries;\r
+    public final Resource SensitivityAnalysisExperiment;\r
+    public final Resource SensitivityAnalysisExperiment_maxValue;\r
+    public final Resource SensitivityAnalysisExperiment_maxValue_Inverse;\r
+    public final Resource SensitivityAnalysisExperiment_minValue;\r
+    public final Resource SensitivityAnalysisExperiment_minValue_Inverse;\r
+    public final Resource SensitivityAnalysisExperiment_numValues;\r
+    public final Resource SensitivityAnalysisExperiment_numValues_Inverse;\r
+    public final Resource SensitivityAnalysisExperiment_propabilityDistribution;\r
+    public final Resource SensitivityAnalysisExperiment_propabilityDistribution_Inverse;\r
+    public final Resource SensitivityAnalysisExperiment_variedParameter;\r
+    public final Resource SensitivityAnalysisExperiment_variedParameter_Inverse;\r
     public final Resource SharedFunctionOntology;\r
     public final Resource SharedModuleOntology;\r
     public final Resource SimulateOnChangeExperiment;\r
@@ -1154,6 +1165,17 @@ public class SysdynResource {
         public static final String Result_showResult = "http://www.simantics.org/Sysdyn-1.1/Result/showResult";\r
         public static final String Right = "http://www.simantics.org/Sysdyn-1.1/Right";\r
         public static final String SelectedSharedFunctionLibraries = "http://www.simantics.org/Sysdyn-1.1/SelectedSharedFunctionLibraries";\r
+        public static final String SensitivityAnalysisExperiment = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment";\r
+        public static final String SensitivityAnalysisExperiment_maxValue = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/maxValue";\r
+        public static final String SensitivityAnalysisExperiment_maxValue_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/maxValue/Inverse";\r
+        public static final String SensitivityAnalysisExperiment_minValue = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/minValue";\r
+        public static final String SensitivityAnalysisExperiment_minValue_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/minValue/Inverse";\r
+        public static final String SensitivityAnalysisExperiment_numValues = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/numValues";\r
+        public static final String SensitivityAnalysisExperiment_numValues_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/numValues/Inverse";\r
+        public static final String SensitivityAnalysisExperiment_propabilityDistribution = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/propabilityDistribution";\r
+        public static final String SensitivityAnalysisExperiment_propabilityDistribution_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/propabilityDistribution/Inverse";\r
+        public static final String SensitivityAnalysisExperiment_variedParameter = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/variedParameter";\r
+        public static final String SensitivityAnalysisExperiment_variedParameter_Inverse = "http://www.simantics.org/Sysdyn-1.1/SensitivityAnalysisExperiment/variedParameter/Inverse";\r
         public static final String SharedFunctionOntology = "http://www.simantics.org/Sysdyn-1.1/SharedFunctionOntology";\r
         public static final String SharedModuleOntology = "http://www.simantics.org/Sysdyn-1.1/SharedModuleOntology";\r
         public static final String SimulateOnChangeExperiment = "http://www.simantics.org/Sysdyn-1.1/SimulateOnChangeExperiment";\r
@@ -1811,6 +1833,17 @@ public class SysdynResource {
         Result_showResult = getResourceOrNull(graph, URIs.Result_showResult);\r
         Right = getResourceOrNull(graph, URIs.Right);\r
         SelectedSharedFunctionLibraries = getResourceOrNull(graph, URIs.SelectedSharedFunctionLibraries);\r
+        SensitivityAnalysisExperiment = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment);\r
+        SensitivityAnalysisExperiment_maxValue = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_maxValue);\r
+        SensitivityAnalysisExperiment_maxValue_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_maxValue_Inverse);\r
+        SensitivityAnalysisExperiment_minValue = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_minValue);\r
+        SensitivityAnalysisExperiment_minValue_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_minValue_Inverse);\r
+        SensitivityAnalysisExperiment_numValues = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_numValues);\r
+        SensitivityAnalysisExperiment_numValues_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_numValues_Inverse);\r
+        SensitivityAnalysisExperiment_propabilityDistribution = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_propabilityDistribution);\r
+        SensitivityAnalysisExperiment_propabilityDistribution_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_propabilityDistribution_Inverse);\r
+        SensitivityAnalysisExperiment_variedParameter = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_variedParameter);\r
+        SensitivityAnalysisExperiment_variedParameter_Inverse = getResourceOrNull(graph, URIs.SensitivityAnalysisExperiment_variedParameter_Inverse);\r
         SharedFunctionOntology = getResourceOrNull(graph, URIs.SharedFunctionOntology);\r
         SharedModuleOntology = getResourceOrNull(graph, URIs.SharedModuleOntology);\r
         SimulateOnChangeExperiment = getResourceOrNull(graph, URIs.SimulateOnChangeExperiment);\r
diff --git a/org.simantics.sysdyn.ui/icons/rainbow.png b/org.simantics.sysdyn.ui/icons/rainbow.png
new file mode 100644 (file)
index 0000000..5ede989
Binary files /dev/null and b/org.simantics.sysdyn.ui/icons/rainbow.png differ
index 420781a58d183353779d8a2e60854ca13608a98d..46659c965039766eb0bc50c63137f82e1c430c7f 100644 (file)
             id="org.simantics.sysdyn.ui.gameExperiment"\r
             name="Game experiment">\r
       </context>\r
+      <context\r
+            id="org.simantics.sysdyn.ui.sensitivityAnalysisExperiment"\r
+            name="Sensitivity analysis experiment">\r
+      </context>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.menus">\r
                </visibleWhen>\r
             </command>\r
          </toolbar>\r
+         <toolbar\r
+               id="org.simantics.sysdyn.ui.sensitivityAnalysisControlToolbar">\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.runSensitivityAnalysis"\r
+                  hoverIcon="platform:/plugin/com.famfamfam.silk/icons/control_play_blue.png"\r
+                  icon="platform:/plugin/com.famfamfam.silk/icons/control_play.png"\r
+                  id="org.simantics.sysdyn.ui.runSensitivityAnalysis.button"\r
+                  label="Simulate"\r
+                  style="push">\r
+               <visibleWhen>\r
+                  <with\r
+                        variable="activeContexts">\r
+                     <iterate\r
+                           ifEmpty="false"\r
+                           operator="or">\r
+                        <equals\r
+                              value="org.simantics.sysdyn.ui.sensitivityAnalysisExperiment">\r
+                        </equals>\r
+                     </iterate>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.toggleSensitivityAnalysisSimulation"\r
+                  hoverIcon="platform:/plugin/com.famfamfam.silk/icons/control_repeat_blue.png"\r
+                  icon="platform:/plugin/com.famfamfam.silk/icons/control_repeat.png"\r
+                  label="Simulate On Change"\r
+                  style="toggle"\r
+                  tooltip="Simulate On Change">\r
+               <visibleWhen>\r
+                  <with\r
+                        variable="activeContexts">\r
+                     <iterate\r
+                           ifEmpty="false"\r
+                           operator="or">\r
+                        <equals\r
+                              value="org.simantics.sysdyn.ui.sensitivityAnalysisExperiment">\r
+                        </equals>\r
+                     </iterate>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.dispose"\r
+                  hoverIcon="platform:/plugin/com.famfamfam.silk/icons/control_eject_blue.png"\r
+                  icon="platform:/plugin/com.famfamfam.silk/icons/control_eject.png"\r
+                  id="org.simantics.sysdyn.ui.dispose.button"\r
+                  label="Quit Experiment"\r
+                  tooltip="Quit Experiment">\r
+               <visibleWhen>\r
+                  <with\r
+                        variable="activeContexts">\r
+                     <iterate\r
+                           ifEmpty="false"\r
+                           operator="or">\r
+                        <equals\r
+                              value="org.simantics.sysdyn.ui.sensitivityAnalysisExperiment">\r
+                        </equals>\r
+                     </iterate>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.saveSensitivityAnalysisResults"\r
+                  icon="platform:/plugin/com.famfamfam.silk/icons/disk.png"\r
+                  id="org.simantics.sysdyn.ui.saveSensitivityAnalysis.button">\r
+               <visibleWhen>\r
+                  <with\r
+                        variable="activeContexts">\r
+                     <iterate\r
+                           ifEmpty="false"\r
+                           operator="or">\r
+                        <equals\r
+                              value="org.simantics.sysdyn.ui.sensitivityAnalysisExperiment">\r
+                        </equals>\r
+                     </iterate>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
+         </toolbar>\r
       </menuContribution>\r
       <menuContribution\r
             locationURI="toolbar:org.simantics.sysdyn.ui.trend.view">\r
                   </with>\r
                </visibleWhen>\r
             </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.newSensitivityAnalysisExperiment"\r
+                  icon="platform:/plugin/com.famfamfam.silk/icons/rainbow.png"\r
+                  id="org.simantics.sysdyn.ui.browser.newSensitivityAnalysisExperiment"\r
+                  label="Sensitivity Analysis Experiment"\r
+                  style="push">\r
+               <visibleWhen\r
+                     checkEnabled="true">\r
+                  <with\r
+                        variable="selection">\r
+                     <test\r
+                           args="org.simantics.sysdyn.ui.browser.nodes.ExperimentsFolder"\r
+                           property="org.simantics.sysdyn.ui.nodeClass">\r
+                     </test>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
             <command\r
                   commandId="org.simantics.sysdyn.ui.newEnumeration"\r
                   id="org.simantics.sysdyn.ui.browser.newEnumeration"\r
             id="org.simantics.sysdyn.ui.newGameExperiment"\r
             name="New Game Experiment">\r
       </command>\r
+      <command\r
+            id="org.simantics.sysdyn.ui.newSensitivityAnalysisExperiment"\r
+            name="New Sensitivity Analysis Experiment">\r
+      </command>\r
       <command\r
             defaultHandler="org.simantics.sysdyn.ui.handlers.simulationPlayback.PlaybackExperimentHandler"\r
             id="org.simantics.sysdyn.ui.playback"\r
             id="org.simantics.sysdyn.ui.reloadGame"\r
             name="Reload Game">\r
       </command>\r
+      <command\r
+            id="org.simantics.sysdyn.ui.newSensitivityAnalysisExperiment"\r
+            name="New Game Experiment">\r
+      </command>\r
+      <command\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.sensitivityAnalysis.RunSensitivityAnalysisExperiment"\r
+            id="org.simantics.sysdyn.ui.runSensitivityAnalysis"\r
+            name="Run Basic Simulation">\r
+      </command>\r
+      <command\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.sensitivityAnalysis.ToggleSimulation"\r
+            id="org.simantics.sysdyn.ui.toggleSensitivityAnalysisSimulation"\r
+            name="Toggle Simulate">\r
+         <state\r
+               class="org.eclipse.jface.commands.ToggleState"\r
+               id="org.simantics.sysdyn.ui.toggleSensitivityAnalysisSimulation.state">\r
+         </state>\r
+      </command>\r
+      <command\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.sensitivityAnalysis.SaveResultsHandler"\r
+            id="org.simantics.sysdyn.ui.saveSensitivityAnalysisResults"\r
+            name="Save Results">\r
+      </command>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.handlers">\r
             commandId="org.simantics.sysdyn.ui.newPlaybackExperiment">\r
       </handler>\r
       <handler\r
-            class="org.simantics.sysdyn.ui.handlers.newComponents.NewGameExperimentNodeHanlder"\r
+            class="org.simantics.sysdyn.ui.handlers.newComponents.NewGameExperimentNodeHandler"\r
             commandId="org.simantics.sysdyn.ui.newGameExperiment">\r
       </handler>\r
+      <handler\r
+            class="org.simantics.sysdyn.ui.handlers.newComponents.NewSensitivityAnalysisExperimentNodeHandler"\r
+            commandId="org.simantics.sysdyn.ui.newSensitivityAnalysisExperiment">\r
+      </handler>\r
    </extension>\r
    <extension\r
          point="org.simantics.browsing.ui.common.viewpointContributionBinding">\r
index 966a8b4716a496edcfef88932a170500488cd1dd..7b41ca1413738426777f0354a0e2f3ec8cc2a71d 100644 (file)
@@ -76,6 +76,8 @@ public class AbstractNodeImager extends ImagerContributor<AbstractNode<Resource>
                 image = "icons/timeline_marker.png";\r
             else if(graph.isInstanceOf(node.data, sr.GameExperiment))\r
                 image = "icons/time_go.png";\r
+            else if(graph.isInstanceOf(node.data, sr.SensitivityAnalysisExperiment))\r
+                image = "icons//rainbow.png";\r
             else\r
                 image = "icons/time.png";\r
         } else if (node instanceof InputNode)\r
similarity index 94%
rename from org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewGameExperimentNodeHanlder.java
rename to org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewGameExperimentNodeHandler.java
index fb83a750304b4f6b908b83fee47406bba211c40f..7d759c34380b201a45a6be7eed0d5ee236fa8d47 100644 (file)
@@ -23,7 +23,7 @@ import org.simantics.sysdyn.manager.SysdynGameExperiment;
  * @author Teemu Lempinen\r
  *\r
  */\r
-public class NewGameExperimentNodeHanlder extends NewExperimentNodeHandler  {\r
+public class NewGameExperimentNodeHandler extends NewExperimentNodeHandler  {\r
 \r
     protected Resource getExperimentType(ReadGraph g) {\r
         return SysdynResource.getInstance(g).GameExperiment;\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSensitivityAnalysisExperimentNodeHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewSensitivityAnalysisExperimentNodeHandler.java
new file mode 100644 (file)
index 0000000..26d63da
--- /dev/null
@@ -0,0 +1,47 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.newComponents;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.manager.SysdynSensitivityAnalysisExperiment;\r
+\r
+/**\r
+ * Creates a new sensitivity analysis experiment.\r
+ * \r
+ * @author Tuomas Miettinen\r
+ *\r
+ */\r
+public class NewSensitivityAnalysisExperimentNodeHandler extends NewExperimentNodeHandler  {\r
+\r
+    @Override\r
+    protected void configureExperiment(WriteGraph graph, Resource experiment) throws DatabaseException {\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_minValue, SysdynSensitivityAnalysisExperiment.DEFAULT_MIN_VALUE);\r
+        graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_maxValue, SysdynSensitivityAnalysisExperiment.DEFAULT_MAX_VALUE);\r
+        graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_numValues, SysdynSensitivityAnalysisExperiment.DEFAULT_NUM_VALUES);\r
+        graph.claimLiteral(experiment, sr.SensitivityAnalysisExperiment_propabilityDistribution, "uniform");\r
+    }\r
+\r
+    @Override\r
+    protected Resource getExperimentType(ReadGraph g) {\r
+        return SysdynResource.getInstance(g).SensitivityAnalysisExperiment;\r
+    }\r
+\r
+    @Override\r
+    protected String getNameSuggestion() {\r
+        return "Sensitivity Experiment";\r
+    }\r
+}
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/sensitivityAnalysis/RunSensitivityAnalysisExperiment.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/sensitivityAnalysis/RunSensitivityAnalysisExperiment.java
new file mode 100644 (file)
index 0000000..9702a8e
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.sensitivityAnalysis;\r
+\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.ui.commands.IElementUpdater;\r
+import org.eclipse.ui.menus.UIElement;\r
+import org.simantics.simulation.experiment.ExperimentState;\r
+import org.simantics.simulation.experiment.IDynamicExperiment;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.manager.SysdynExperiment;\r
+import org.simantics.sysdyn.ui.utils.HandlerUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+/**\r
+ * Handler for starting a sensitivity analysis simulation\r
+ * @author Tuomas Miettinen\r
+ *\r
+ */\r
+public class RunSensitivityAnalysisExperiment extends AbstractHandler implements IElementUpdater {\r
+    \r
+    public static final String COMMAND = "org.simantics.sysdyn.ui.runSensitivityAnalysis";\r
+    \r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        // Current functionality is normal run experiment\r
+        \r
+        HandlerUtils.saveEquation(event);\r
+        \r
+        IExperimentManager manager = \r
+            SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+        IExperiment experiment = manager.getActiveExperiment();\r
+        if(experiment instanceof IDynamicExperiment)\r
+            ((IDynamicExperiment)experiment).simulate(true);\r
+        return null;\r
+    }\r
+\r
+    // What does this method do, is this needed?\r
+    @SuppressWarnings("rawtypes")\r
+       @Override\r
+    public void updateElement(UIElement element, Map parameters) {\r
+        IExperimentManager manager = \r
+            SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+        IExperiment experiment = manager.getActiveExperiment();\r
+        if(experiment instanceof SysdynExperiment) {\r
+               ExperimentState state = experiment.getState();\r
+               if(state == ExperimentState.RUNNING) {\r
+                       this.setBaseEnabled(false);\r
+               } else {\r
+                        this.setBaseEnabled(true);\r
+               }\r
+        }        \r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/sensitivityAnalysis/SaveResultsHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/sensitivityAnalysis/SaveResultsHandler.java
new file mode 100644 (file)
index 0000000..e0bc013
--- /dev/null
@@ -0,0 +1,45 @@
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.sensitivityAnalysis;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.simantics.simulation.experiment.IDynamicExperiment;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.ui.utils.HandlerUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+/**\r
+ * Save the results of a sensitivity analysis experiment\r
+ * @author Tuomas Miettinen\r
+ *\r
+ */\r
+public class SaveResultsHandler extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        // Current functionality is normal run experiment\r
+        \r
+        HandlerUtils.saveEquation(event);\r
+        \r
+        IExperimentManager manager = \r
+            SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+        IExperiment experiment = manager.getActiveExperiment();\r
+        if(experiment instanceof IDynamicExperiment) {\r
+            ((IDynamicExperiment)experiment).saveState();\r
+        }\r
+        return null;\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/sensitivityAnalysis/ToggleSimulation.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/sensitivityAnalysis/ToggleSimulation.java
new file mode 100644 (file)
index 0000000..291f936
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.handlers.sensitivityAnalysis;\r
+\r
+\r
+import java.util.Map;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.Command;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.core.commands.State;\r
+import org.eclipse.ui.PlatformUI;\r
+import org.eclipse.ui.commands.ICommandService;\r
+import org.eclipse.ui.commands.IElementUpdater;\r
+import org.eclipse.ui.menus.UIElement;\r
+import org.simantics.simulation.experiment.IExperiment;\r
+import org.simantics.simulation.project.IExperimentManager;\r
+import org.simantics.sysdyn.manager.SysdynExperiment;\r
+import org.simantics.sysdyn.ui.utils.HandlerUtils;\r
+import org.simantics.ui.SimanticsUI;\r
+\r
+/**\r
+ * Handle for the Toggle Simulation button. When the button is down, the\r
+ * simulation is run every time the model is changed.\r
+ * @author Tuomas Miettinen\r
+ *\r
+ */\r
+public class ToggleSimulation extends AbstractHandler implements IElementUpdater {\r
+\r
+    public static final String COMMAND = "org.simantics.sysdyn.ui.toggleSensitivityAnalysisSimulation";\r
+    public static final String STATE = "org.simantics.sysdyn.ui.toggleSensitivityAnalysisSimulation.state";\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+        // Current functionality is normal run experiment\r
+        \r
+        ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+        Command command = service.getCommand(COMMAND);\r
+        State state = command.getState(STATE);\r
+        Boolean value = (Boolean) state.getValue();\r
+        value = !value;\r
+        state.setValue(value);\r
+        service.refreshElements(RunSensitivityAnalysisExperiment.COMMAND, null);\r
+        \r
+        IExperimentManager manager = \r
+            SimanticsUI.getProject().getHint(IExperimentManager.KEY_EXPERIMENT_MANAGER);\r
+        IExperiment experiment = manager.getActiveExperiment();\r
+        if(experiment instanceof SysdynExperiment) {\r
+            if(getState()) {\r
+                ((SysdynExperiment)experiment).toggleSimulation(true);\r
+            } else {\r
+                ((SysdynExperiment)experiment).toggleSimulation(false);\r
+            }\r
+        }\r
+            \r
+        HandlerUtils.saveEquation(event);\r
+\r
+        return null;\r
+    }\r
+\r
+    public static Boolean getState() {\r
+        ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+        Command command = service.getCommand(COMMAND);\r
+        State state = command.getState(STATE);\r
+        return (Boolean)state.getValue();\r
+    }\r
+\r
+    @SuppressWarnings("rawtypes")\r
+       @Override\r
+    public void updateElement(UIElement element, Map parameters) {\r
+        ICommandService commandService =\r
+            (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class);\r
+        Command command = commandService.getCommand(COMMAND);\r
+        boolean checked = (Boolean) command.getState(STATE).getValue();\r
+        element.setChecked(checked);\r
+    }\r
+}\r
index 4201112a70540311ad1d27fd43d3682196c3b258..d9c50e813e291796c9a38d658d492ac4126b705b 100644 (file)
@@ -26,13 +26,15 @@ import org.simantics.simulation.project.IExperimentManagerListener;
 import org.simantics.sysdyn.manager.SysdynExperiment;\r
 import org.simantics.sysdyn.manager.SysdynGameExperiment;\r
 import org.simantics.sysdyn.manager.SysdynPlaybackExperiment;\r
+import org.simantics.sysdyn.manager.SysdynSensitivityAnalysisExperiment;\r
 \r
 public class SysdynExperimentManagerListener implements IExperimentManagerListener{\r
 \r
     public static final String BASIC_EXPERIMENT_CONTEXT = "org.simantics.sysdyn.ui.basicExperiment";\r
     public static final String PLAYBACK_EXPERIMENT_CONTEXT = "org.simantics.sysdyn.ui.playbackExperiment";\r
     public static final String GAME_EXPERIMENT_CONTEXT = "org.simantics.sysdyn.ui.gameExperiment";\r
-   \r
+    public static final String SENSITIVITY_ANALYSIS_EXPERIMENT_CONTEXT = "org.simantics.sysdyn.ui.sensitivityAnalysisExperiment";\r
+    \r
     static Set<IExperimentManager> managers = \r
         new HashSet<IExperimentManager>();\r
     \r
@@ -72,8 +74,11 @@ public class SysdynExperimentManagerListener implements IExperimentManagerListen
                         contextActivations.add(contextService.activateContext(PLAYBACK_EXPERIMENT_CONTEXT));\r
                         experiment.addListener(new SysdynPlaybackExperimentListener((SysdynPlaybackExperiment)experiment));\r
                     } else if(experiment instanceof SysdynGameExperiment) {\r
-                       contextActivations.add(contextService.activateContext(GAME_EXPERIMENT_CONTEXT));\r
-                       // TODO: some listener?\r
+                        contextActivations.add(contextService.activateContext(GAME_EXPERIMENT_CONTEXT));\r
+                        // TODO: some listener?\r
+                    } else if(experiment instanceof SysdynSensitivityAnalysisExperiment) {\r
+                        contextActivations.add(contextService.activateContext(SENSITIVITY_ANALYSIS_EXPERIMENT_CONTEXT));\r
+                        // TODO: some listener?\r
                     } else if(experiment instanceof SysdynExperiment) {\r
                         contextActivations.add(contextService.activateContext(BASIC_EXPERIMENT_CONTEXT));\r
                     }\r
index ab4c39b58de5ea522cd008c9ffccfe26f4a17f59..28e01ecc8f5f4d04d95cbd69f42485450788a8f8 100644 (file)
@@ -295,7 +295,7 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                 r,\r
                                 "Experiment Properties"));\r
 \r
-            // Game experiment\r
+         // Game experiment\r
             if (backend.isInstanceOf(r, sr.GameExperiment))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
@@ -304,7 +304,16 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                 r,\r
                                 "Experiment Properties"));\r
 \r
-            // Default experiment\r
+         // Sensitivity analysis experiment\r
+            if (backend.isInstanceOf(r, sr.SensitivityAnalysisExperiment))\r
+                return Collections.singleton(\r
+                        new ComparableTabContributor(\r
+                                new SensitivityAnalysisExperimentTab(),\r
+                                0,\r
+                                r,\r
+                                "Experiment Properties"));\r
+\r
+         // Default experiment\r
             if (backend.isInstanceOf(r, simu.Experiment))\r
                 return Collections.singleton(\r
                         new ComparableTabContributor(\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/SensitivityAnalysisExperimentTab.java
new file mode 100644 (file)
index 0000000..701e0cb
--- /dev/null
@@ -0,0 +1,115 @@
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.resource.JFaceResources;\r
+import org.eclipse.jface.resource.LocalResourceManager;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.ScrolledComposite;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.IntegerPropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.IntegerPropertyModifier;\r
+import org.simantics.utils.ui.validators.DoubleValidator;\r
+import org.simantics.utils.ui.validators.IntegerValidator;\r
+\r
+/**\r
+ * Tab for displaying sensitivity analysis experiment properties\r
+ * \r
+ * @author Tuomas Miettinen\r
+ *\r
+ */\r
+public class SensitivityAnalysisExperimentTab extends LabelPropertyTabContributor {\r
+\r
+       @Override\r
+       public void createControls(Composite body, IWorkbenchSite site,\r
+               ISessionContext context, WidgetSupport support) {\r
+               \r
+        ScrolledComposite sc = new ScrolledComposite(body,  SWT.H_SCROLL | SWT.V_SCROLL);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
+        GridLayoutFactory.fillDefaults().applyTo(sc);\r
+        \r
+        Composite composite = new Composite(sc, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite);\r
+        \r
+        // Label\r
+        Label label = new Label(composite, SWT.NONE);\r
+        label.setText("Name");\r
+        \r
+        TrackedText name = new TrackedText(composite, support, SWT.BORDER);\r
+        name.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
+        name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
+        name.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasName));\r
+        name.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), name.getWidget())));\r
+\r
+        // The propability distribution\r
+        label = new Label(composite, SWT.NONE);\r
+        label.setText("Propability distribution");\r
+        \r
+        TrackedText propabilityDistributionName = new TrackedText(composite, support, SWT.BORDER);\r
+        propabilityDistributionName.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_propabilityDistribution));\r
+        propabilityDistributionName.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.SensitivityAnalysisExperiment_propabilityDistribution));\r
+        //parameterName.setInputValidator(new DoubleValidator());\r
+        propabilityDistributionName.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), propabilityDistributionName.getWidget())));\r
+        \r
+        // Parameter the value of which is varied \r
+        label = new Label(composite, SWT.NONE);\r
+        label.setText("Varied parameter name");\r
+        \r
+        TrackedText parameterName = new TrackedText(composite, support, SWT.BORDER);\r
+        parameterName.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_variedParameter));\r
+        parameterName.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.SensitivityAnalysisExperiment_variedParameter));\r
+        //parameterName.setInputValidator(new DoubleValidator());\r
+        parameterName.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), parameterName.getWidget())));\r
+        \r
+        // minValue\r
+        label = new Label(composite, SWT.NONE);\r
+        label.setText("Min value");\r
+        \r
+        TrackedText minValue = new TrackedText(composite, support, SWT.BORDER);\r
+        minValue.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_minValue));\r
+        minValue.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.SensitivityAnalysisExperiment_minValue));\r
+        minValue.setInputValidator(new DoubleValidator());\r
+        minValue.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), minValue.getWidget())));\r
+        GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).applyTo(name.getWidget());\r
+\r
+        // maxValue\r
+        label = new Label(composite, SWT.NONE);\r
+        label.setText("Max value");\r
+        \r
+        TrackedText maxValue = new TrackedText(composite, support, SWT.BORDER);\r
+        maxValue.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_maxValue));\r
+        maxValue.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.SensitivityAnalysisExperiment_maxValue));\r
+        maxValue.setInputValidator(new DoubleValidator());\r
+        maxValue.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), maxValue.getWidget())));\r
+        \r
+        // number of values\r
+        label = new Label(composite, SWT.NONE);\r
+        label.setText("Number of values");\r
+        \r
+        TrackedText numValues = new TrackedText(composite, support, SWT.BORDER);\r
+        numValues.setTextFactory(new IntegerPropertyFactory(SysdynResource.URIs.SensitivityAnalysisExperiment_numValues));\r
+        numValues.addModifyListener(new IntegerPropertyModifier(context, SysdynResource.URIs.SensitivityAnalysisExperiment_numValues));\r
+        numValues.setInputValidator(new IntegerValidator());\r
+        numValues.setColorProvider(new SysdynBasicColorProvider(new LocalResourceManager(JFaceResources.getResources(), numValues.getWidget())));\r
+        \r
+        // Scrolled composite settings\r
+        sc.setContent(composite);\r
+        sc.setMinSize(composite.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
+        sc.setExpandHorizontal(true);\r
+        sc.setExpandVertical(true);\r
+               \r
+       }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/IntegerPropertyFactory.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/IntegerPropertyFactory.java
new file mode 100644 (file)
index 0000000..d362956
--- /dev/null
@@ -0,0 +1,43 @@
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.factories;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.utils.datastructures.Triple;\r
+\r
+public class IntegerPropertyFactory extends ReadFactoryImpl<Resource, String> {\r
+\r
+    final private String propertyURI;\r
+    \r
+    public IntegerPropertyFactory(String propertyURI) {\r
+        this.propertyURI = propertyURI;\r
+    }\r
+\r
+    @Override\r
+    public Object getIdentity(Object inputContents) {\r
+        return new Triple<Resource, String, Object>((Resource)inputContents, propertyURI, getClass());\r
+    }\r
+    \r
+    @Override\r
+    public String perform(ReadGraph graph, Resource issue) throws DatabaseException {\r
+        \r
+        Integer value = graph.getPossibleRelatedValue(issue, graph.getResource(propertyURI));\r
+        if (value != null)\r
+            return value.toString();\r
+        else\r
+            return "";\r
+    }\r
+    \r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/IntegerPropertyModifier.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/factories/IntegerPropertyModifier.java
new file mode 100644 (file)
index 0000000..fb61240
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************\r
+ * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ *     VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.properties.widgets.factories;\r
+\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListenerImpl;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+public class IntegerPropertyModifier extends TextModifyListenerImpl<Resource> {\r
+\r
+    final private String propertyURI;\r
+    \r
+    public IntegerPropertyModifier(ISessionContext context, String propertyURI) {\r
+        this.propertyURI = propertyURI;\r
+    }\r
+\r
+    @Override\r
+    public void applyText(WriteGraph graph, Resource input, String text) throws DatabaseException {\r
+       if (text == null || text.equals("")) {\r
+               if(graph.hasStatement(input, graph.getResource(propertyURI)))\r
+                       graph.deny(input, graph.getResource(propertyURI));\r
+       } else {\r
+               graph.claimLiteral(input, graph.getResource(propertyURI), Integer.parseInt(text), Bindings.INTEGER);\r
+       }\r
+    }\r
+\r
+}\r
index b5c5e6e079d1d2b5c7cb60a5b11397e4c9f0331d..bfe35fa1ea09a0ba0fcbc1bc5236caa1beecb27d 100644 (file)
@@ -74,12 +74,12 @@ public class SysdynModel implements IMappingListener, IModel, VariableSubscripti
 \r
     private Configuration configuration;\r
 \r
-    private Set<Configuration> modules = new HashSet<Configuration>();\r
+    private final Set<Configuration> modules = new HashSet<Configuration>();\r
 \r
     private ArrayList<SysdynResult> displayedResults;\r
-    private ArrayList<HistoryDatasetResult> listeningHistories = new ArrayList<HistoryDatasetResult>();\r
+    private final ArrayList<HistoryDatasetResult> listeningHistories = new ArrayList<HistoryDatasetResult>();\r
 \r
-    private CopyOnWriteArrayList<Runnable> modificationListeners =\r
+    private final CopyOnWriteArrayList<Runnable> modificationListeners =\r
             new CopyOnWriteArrayList<Runnable>();\r
     \r
     @SuppressWarnings("rawtypes")\r
@@ -88,7 +88,7 @@ public class SysdynModel implements IMappingListener, IModel, VariableSubscripti
     protected volatile VariableValueSubscription[] variableValueSubscriptionsSnapshot = null;\r
 \r
     @SuppressWarnings("rawtypes")\r
-    private Map<Class, Object> services = new HashMap<Class, Object>();\r
+    private final Map<Class, Object> services = new HashMap<Class, Object>();\r
 \r
     /**\r
      * Recursively read all module configurations that are used in \r
@@ -413,6 +413,8 @@ public class SysdynModel implements IMappingListener, IModel, VariableSubscripti
                 exp = new SysdynPlaybackExperiment(experiment, modelResource);\r
             } else if(g.isInstanceOf(experiment, sr.GameExperiment)) {\r
                 exp = new SysdynGameExperiment(experiment, modelResource);\r
+            } else if(g.isInstanceOf(experiment, sr.SensitivityAnalysisExperiment)) {\r
+                exp = new SysdynSensitivityAnalysisExperiment(experiment, modelResource);\r
             } else if(g.isInstanceOf(experiment, sr.BasicExperiment)) {\r
                 exp = new SysdynExperiment(experiment, modelResource);\r
             } else {\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynSensitivityAnalysisExperiment.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynSensitivityAnalysisExperiment.java
new file mode 100644 (file)
index 0000000..c7da152
--- /dev/null
@@ -0,0 +1,158 @@
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2012 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 java.util.ArrayList;\r
+import java.util.Collection;\r
+import java.util.concurrent.ScheduledExecutorService;\r
+\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.simulation.experiment.IDynamicExperiment;\r
+\r
+/**\r
+ * Sensitivity analysis experiment\r
+ * @author Tuomas Miettinen\r
+ *\r
+ */\r
+public class SysdynSensitivityAnalysisExperiment extends SysdynExperiment implements IDynamicExperiment {\r
+\r
+    public enum Distribution {\r
+        UNIFORM,\r
+        NORMAL\r
+    }\r
+    \r
+    private final Distribution propabilityDistribution = DEFAULT_PROPABILITY_DISTRIBUTION;\r
+    \r
+    public static Distribution DEFAULT_PROPABILITY_DISTRIBUTION = Distribution.UNIFORM;\r
+    public static double DEFAULT_MIN_VALUE = 1.0;\r
+    public static double DEFAULT_MAX_VALUE = 3.0;\r
+    public static int DEFAULT_NUM_VALUES = 3;\r
+    \r
+    private final Collection<Runnable> timeListeners = new ArrayList<Runnable>();\r
+\r
+    ScheduledExecutorService playbackExecutionService;\r
+    //SensitivityAnalysisConfiguration playbackConfiguration;\r
+\r
+    public SysdynSensitivityAnalysisExperiment(Resource experiment, Resource model) {\r
+        super(experiment, model);\r
+    }\r
+\r
+\r
+    /**\r
+     * Interrupts a possible ongoing playback\r
+     * \r
+     * @param time\r
+     */\r
+//    public void setTimeInterrupting(double time) {\r
+//        stopPlayback();\r
+//        setTime(time);\r
+//    }\r
+//\r
+//    /**\r
+//     * Sets a new time and continues playback from that point if \r
+//     * playback was running  \r
+//     * @param time\r
+//     */\r
+//    public void setTimeAndContinue(double time) {\r
+//        if(isPlaybackRunning()) {\r
+//            stopPlayback();\r
+//            setTime(time);\r
+//            startPlayback(500);\r
+//        } else {\r
+//            setTime(time);\r
+//        }\r
+//    }\r
+/*\r
+  private void setTime(double time) {\r
+        this.time = time;\r
+        resultsChanged(); \r
+    }\r
+\r
+    public double getTime() {\r
+        return this.time;\r
+    }\r
+\r
+    public double getStartTime() {\r
+        return this.startTime;\r
+    }\r
+\r
+    public double getEndTime() {\r
+        return this.endTime;\r
+    }\r
+\r
+    public void setPlaybackDuration(long duration) {\r
+        this.playbackDuration = duration;\r
+        if(isPlaybackRunning()) {\r
+            //Restart playback with different time settings\r
+            startPlayback();\r
+        }\r
+    }\r
+\r
+    public long getPlaybackDuration() {\r
+        return this.playbackDuration;\r
+    }\r
+\r
+    @Override\r
+    public void init(ReadGraph g) {\r
+        super.init(g);\r
+        this.session = g.getSession();\r
+        session.asyncRequest(new ReadRequest() {\r
+\r
+            @Override\r
+            public void run(ReadGraph graph) throws DatabaseException {\r
+                changeState(ExperimentState.RUNNING);\r
+                final Resource configuration = graph.getPossibleObject(model, SimulationResource.getInstance(graph).HasConfiguration);\r
+                sysdynModel = SysdynModelManager.getInstance(session).getModel(graph, configuration);\r
+                toggleActivation(graph, true);\r
+                //getPlaybackConfiguration(graph);\r
+                startSimulationJob();\r
+            }\r
+        });\r
+    }\r
+\r
+\r
+\r
+    private class SensitivityAnalysisConfiguration {\r
+        public double simulationDuration, simulationStepLength, intervals, endTime, startTime;\r
+        public long playbackDuration;\r
+    }\r
+\r
+    @Override\r
+    protected void localStateChange() {\r
+        super.localStateChange();\r
+    }\r
+\r
+    // TIME LISTENERS\r
+    public void addTimeListener(Runnable timeListener) {\r
+        if(!this.timeListeners.contains(timeListener))\r
+            this.timeListeners.add(timeListener);\r
+    }\r
+\r
+    public Collection<Runnable> getTimeListeners() {\r
+        return this.timeListeners;\r
+    }\r
+\r
+    public void removeTimeListener(Runnable timeListener) {\r
+        this.timeListeners.remove(timeListener);\r
+    }\r
+\r
+    @Override\r
+    public void resultsChanged() {\r
+        for(Runnable listener : timeListeners) {\r
+            listener.run();\r
+        }\r
+        super.resultsChanged();\r
+\r
+    }\r
+*/\r
+}\r