]> gerrit.simantics Code Review - simantics/sysdyn.git/commitdiff
History data support as history datasets in experiments. History datasets work like...
authorlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 1 Mar 2012 07:47:57 +0000 (07:47 +0000)
committerlempinen <lempinen@ac1ea38d-2e2b-0410-8846-a27921b304fc>
Thu, 1 Mar 2012 07:47:57 +0000 (07:47 +0000)
git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@24316 ac1ea38d-2e2b-0410-8846-a27921b304fc

24 files changed:
org.simantics.modelica/src/org/simantics/modelica/data/SimulationResult.java
org.simantics.sysdyn.ontology/META-INF/MANIFEST.MF
org.simantics.sysdyn.ontology/graph.tg
org.simantics.sysdyn.ontology/graph/PropertyViewpoints.pgraph [new file with mode: 0644]
org.simantics.sysdyn.ontology/graph/Sysdyn.pgraph
org.simantics.sysdyn.ontology/src/org/simantics/sysdyn/SysdynResource.java
org.simantics.sysdyn.ui/adapters.xml
org.simantics.sysdyn.ui/plugin.xml
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SimulationResult.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SimulationResultDecorator.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SimulationResultImager.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/contributions/SimulationResultLabeler.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/HistoryDataNode.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/SimulationResultNode.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewHistoryDataHandler.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/HistoryDataTab.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/ResourceSelectionProcessor.java
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/historyDataset/VariableChildRule.java [new file with mode: 0644]
org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/historyDataset/VariableLabelRule.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/HistoryDatasetResult.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/HistoryDatasetUtils.java [new file with mode: 0644]
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynModel.java
org.simantics.sysdyn/src/org/simantics/sysdyn/manager/SysdynResult.java
org.simantics.sysdyn/src/org/simantics/sysdyn/representation/IndependentVariable.java

index 766d4c2c452aa3797049e74323332ccbbf287298..725d7e71befd5a111ed8dac7901f7aa8a2c8b871 100644 (file)
@@ -48,14 +48,14 @@ import org.xml.sax.SAXException;
  */\r
 public class SimulationResult {    \r
 \r
-    List<DataSet> variables = new ArrayList<DataSet>();\r
-    List<DataSet> initials = new ArrayList<DataSet>();\r
+    protected List<DataSet> variables = new ArrayList<DataSet>();\r
+    protected List<DataSet> initials = new ArrayList<DataSet>();\r
     protected int numberOfTimeSteps = 0;\r
     \r
     /**\r
      * Private class used in displaying errors\r
      */\r
-    class TimeValuePair {\r
+    protected class TimeValuePair {\r
         public String time;\r
         public String value;\r
 \r
@@ -65,7 +65,7 @@ public class SimulationResult {
         }\r
     }\r
 \r
-    HashMap<String, ArrayList<TimeValuePair>> errors = new HashMap<String, ArrayList<TimeValuePair>>();\r
+    protected HashMap<String, ArrayList<TimeValuePair>> errors = new HashMap<String, ArrayList<TimeValuePair>>();\r
 \r
     /**\r
      * Get the next line in the plt-file\r
index 86466a568f8a405cf30aa260a3543d27acabeb16..f4ca250c91862d1910de091a8e3fcffd60d8d866 100644 (file)
@@ -17,7 +17,8 @@ Require-Bundle: org.simantics.layer0,
  org.simantics.image2.ontology;bundle-version="1.1.0",
  org.simantics.color.ontology;bundle-version="1.0.0",
  org.simantics.simulation.ontology;bundle-version="1.0.0",
- org.simantics.silk.ontology;bundle-version="1.0.0"
+ org.simantics.silk.ontology;bundle-version="1.0.0",
+ org.simantics.spreadsheet.ontology;bundle-version="1.1.0"
 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
 Export-Package: org.simantics.sysdyn
 Bundle-Vendor: VTT Technical Reserarch Centre of Finland
index 1d7f07a7f85445c75f5442b722d46d484d36bc4d..d1dcc33a4b740c5a8113585809344d74e411f1d5 100644 (file)
Binary files a/org.simantics.sysdyn.ontology/graph.tg and b/org.simantics.sysdyn.ontology/graph.tg differ
diff --git a/org.simantics.sysdyn.ontology/graph/PropertyViewpoints.pgraph b/org.simantics.sysdyn.ontology/graph/PropertyViewpoints.pgraph
new file mode 100644 (file)
index 0000000..3d93928
--- /dev/null
@@ -0,0 +1,24 @@
+L0 = <http://www.simantics.org/Layer0-1.0>\r
+VP = <http://www.simantics.org/Viewpoint-1.1>\r
+SYSDYN = <http://www.simantics.org/Sysdyn-1.1>\r
+\r
+HDBC = SYSDYN.HistoryDataset.HistoryDatasetVariablesBrowseContext : VP.BrowseContext\r
+\r
+HDBC.StringNodeType <T VP.NodeType\r
+    @L0.assert VP.HasContentType "java.lang.String"\r
+\r
+HDBC.VariableChildRule : VP.ChildRule\r
+HDBC.VariableLabelRule : VP.LabelRule\r
+\r
+HDBC\r
+    @VP.customChildRule SYSDYN.HistoryDataset HDBC.VariableChildRule\r
+        SYSDYN.HistoryDataset.FoundVariableNameNode : HDBC.StringNodeType\r
+\r
+HDBC        \r
+    @VP.customLabelRule SYSDYN.HistoryDataset.FoundVariableNameNode HDBC.VariableLabelRule\r
+    \r
+HDBC    \r
+    VP.BrowseContext.HasVisualsContribution _ : VP.VisualsContribution\r
+        VP.VisualsContribution.HasNodeType SYSDYN.HistoryDataset\r
+        VP.VisualsContribution.HasRule VP.PassThruSorterRule\r
+    \r
index 0258eda288353c31176c940ab4d48cc8bd891915..0e46d521d847a1669406942a2518435341efe65d 100644 (file)
@@ -7,6 +7,7 @@ SIMU = <http://www.simantics.org/Simulation-1.0>
 MOD = <http://www.simantics.org/Modeling-1.1>
 PROJ = <http://www.simantics.org/Project-1.1>
 JFREE = <http://www.simantics.org/JFreeChart-1.0>
+SHEET = <http://www.simantics.org/Spreadsheet-1.1>
  
 //#####################################################################
 // Defines ontology and attaches it to SimanticsDomain
@@ -267,7 +268,7 @@ SYSDYN.SimulateOnChangeExperiment <T SYSDYN.Experiment
 SYSDYN.PlaybackExperiment <T SYSDYN.Experiment
 
 //#####################################################################
-// Results
+// Results and history datasets
 //#####################################################################
 
 SYSDYN.Result <T L0.Entity
@@ -276,6 +277,16 @@ SYSDYN.Result <T L0.Entity
     >-- SYSDYN.Result.resultFile --> L0.String <R L0.HasProperty
     >-- SYSDYN.Result.showResult --> SYSDYN.Result <R L0.IsRelatedTo : L0.Tag
         @L0.symmetric
+        
+SYSDYN.HistoryDataset <T SYSDYN.Result
+    @L0.singleProperty L0.HasName
+    @L0.singleProperty L0.HasLabel
+    >-- SYSDYN.HistoryDataset.start --> L0.String <R L0.HasProperty     // Start of the history data table (e.g. B3)
+    >-- SYSDYN.HistoryDataset.end --> L0.String <R L0.HasProperty       // End of the history data table (e.g. D56)
+    >-- SYSDYN.HistoryDataset.timeName --> L0.String <R L0.HasProperty  // Name of the time variable. Will be saved as "time"
+    >-- SYSDYN.HistoryDataset.columns --> L0.Boolean <R L0.HasProperty  // Is the data in columns. If false, data is in rows
+    >-- SYSDYN.HistoryDataset.sheet --> SHEET.Spreadsheet <R L0.IsRelatedTo : L0.FunctionalRelation
+    
 
 //#####################################################################
 //#####################################################################
index 6b1fb3980b6b32ee9808ba1e039a4b1e709097a3..7a12eda3d8c79b7d397688f335f02abb2d0495f4 100644 (file)
@@ -135,6 +135,21 @@ public class SysdynResource {
     public final Resource HasTailTerminal;\r
     public final Resource HasUnit;\r
     public final Resource HasUnit_Inverse;\r
+    public final Resource HistoryDataset;\r
+    public final Resource HistoryDataset_FoundVariableNameNode;\r
+    public final Resource HistoryDataset_HistoryDatasetVariablesBrowseContext;\r
+    public final Resource HistoryDataset_HistoryDatasetVariablesBrowseContext_StringNodeType;\r
+    public final Resource HistoryDataset_HistoryDatasetVariablesBrowseContext_VariableChildRule;\r
+    public final Resource HistoryDataset_HistoryDatasetVariablesBrowseContext_VariableLabelRule;\r
+    public final Resource HistoryDataset_columns;\r
+    public final Resource HistoryDataset_columns_Inverse;\r
+    public final Resource HistoryDataset_end;\r
+    public final Resource HistoryDataset_end_Inverse;\r
+    public final Resource HistoryDataset_sheet;\r
+    public final Resource HistoryDataset_start;\r
+    public final Resource HistoryDataset_start_Inverse;\r
+    public final Resource HistoryDataset_timeName;\r
+    public final Resource HistoryDataset_timeName_Inverse;\r
     public final Resource HistoryRealization;\r
     public final Resource Horizontal;\r
     public final Resource ImportModuleTree;\r
@@ -436,6 +451,21 @@ public class SysdynResource {
         public static final String HasTailTerminal = "http://www.simantics.org/Sysdyn-1.1/HasTailTerminal";\r
         public static final String HasUnit = "http://www.simantics.org/Sysdyn-1.1/HasUnit";\r
         public static final String HasUnit_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasUnit/Inverse";\r
+        public static final String HistoryDataset = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset";\r
+        public static final String HistoryDataset_FoundVariableNameNode = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/FoundVariableNameNode";\r
+        public static final String HistoryDataset_HistoryDatasetVariablesBrowseContext = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/HistoryDatasetVariablesBrowseContext";\r
+        public static final String HistoryDataset_HistoryDatasetVariablesBrowseContext_StringNodeType = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/HistoryDatasetVariablesBrowseContext/StringNodeType";\r
+        public static final String HistoryDataset_HistoryDatasetVariablesBrowseContext_VariableChildRule = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableChildRule";\r
+        public static final String HistoryDataset_HistoryDatasetVariablesBrowseContext_VariableLabelRule = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableLabelRule";\r
+        public static final String HistoryDataset_columns = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/columns";\r
+        public static final String HistoryDataset_columns_Inverse = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/columns/Inverse";\r
+        public static final String HistoryDataset_end = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/end";\r
+        public static final String HistoryDataset_end_Inverse = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/end/Inverse";\r
+        public static final String HistoryDataset_sheet = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/sheet";\r
+        public static final String HistoryDataset_start = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/start";\r
+        public static final String HistoryDataset_start_Inverse = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/start/Inverse";\r
+        public static final String HistoryDataset_timeName = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/timeName";\r
+        public static final String HistoryDataset_timeName_Inverse = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset/timeName/Inverse";\r
         public static final String HistoryRealization = "http://www.simantics.org/Sysdyn-1.1/HistoryRealization";\r
         public static final String Horizontal = "http://www.simantics.org/Sysdyn-1.1/Horizontal";\r
         public static final String ImportModuleTree = "http://www.simantics.org/Sysdyn-1.1/ImportModuleTree";\r
@@ -747,6 +777,21 @@ public class SysdynResource {
         HasTailTerminal = getResourceOrNull(graph, URIs.HasTailTerminal);\r
         HasUnit = getResourceOrNull(graph, URIs.HasUnit);\r
         HasUnit_Inverse = getResourceOrNull(graph, URIs.HasUnit_Inverse);\r
+        HistoryDataset = getResourceOrNull(graph, URIs.HistoryDataset);\r
+        HistoryDataset_FoundVariableNameNode = getResourceOrNull(graph, URIs.HistoryDataset_FoundVariableNameNode);\r
+        HistoryDataset_HistoryDatasetVariablesBrowseContext = getResourceOrNull(graph, URIs.HistoryDataset_HistoryDatasetVariablesBrowseContext);\r
+        HistoryDataset_HistoryDatasetVariablesBrowseContext_StringNodeType = getResourceOrNull(graph, URIs.HistoryDataset_HistoryDatasetVariablesBrowseContext_StringNodeType);\r
+        HistoryDataset_HistoryDatasetVariablesBrowseContext_VariableChildRule = getResourceOrNull(graph, URIs.HistoryDataset_HistoryDatasetVariablesBrowseContext_VariableChildRule);\r
+        HistoryDataset_HistoryDatasetVariablesBrowseContext_VariableLabelRule = getResourceOrNull(graph, URIs.HistoryDataset_HistoryDatasetVariablesBrowseContext_VariableLabelRule);\r
+        HistoryDataset_columns = getResourceOrNull(graph, URIs.HistoryDataset_columns);\r
+        HistoryDataset_columns_Inverse = getResourceOrNull(graph, URIs.HistoryDataset_columns_Inverse);\r
+        HistoryDataset_end = getResourceOrNull(graph, URIs.HistoryDataset_end);\r
+        HistoryDataset_end_Inverse = getResourceOrNull(graph, URIs.HistoryDataset_end_Inverse);\r
+        HistoryDataset_sheet = getResourceOrNull(graph, URIs.HistoryDataset_sheet);\r
+        HistoryDataset_start = getResourceOrNull(graph, URIs.HistoryDataset_start);\r
+        HistoryDataset_start_Inverse = getResourceOrNull(graph, URIs.HistoryDataset_start_Inverse);\r
+        HistoryDataset_timeName = getResourceOrNull(graph, URIs.HistoryDataset_timeName);\r
+        HistoryDataset_timeName_Inverse = getResourceOrNull(graph, URIs.HistoryDataset_timeName_Inverse);\r
         HistoryRealization = getResourceOrNull(graph, URIs.HistoryRealization);\r
         Horizontal = getResourceOrNull(graph, URIs.Horizontal);\r
         ImportModuleTree = getResourceOrNull(graph, URIs.ImportModuleTree);\r
index ac87af2b877466788022a575b488502b11a15265..6c3dcbee8620e51aa853ba8b5dadd67a8b9baaac 100644 (file)
@@ -10,5 +10,5 @@
         VTT Technical Research Centre of Finland - initial API and implementation\r
  -->\r
 
-<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r     <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-0.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-0.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                       \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-0.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-0.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-0.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.VariableChildRule"/>  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>           \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>                          \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisLabelRule"/> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>       \r                     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>       \r                                               \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/OpenWorkbook"\r            class="org.simantics.sysdyn.ui.browser.actions.OpenWorkbookAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" />            \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/AxisDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisDropAction" />            \r            \r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />                        \r    </target>     \r  \r  <!-- PROFILES -->\r    <target interface="org.simantics.scenegraph.profile.Style">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/SimulationPlaybackStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.IssueDecorationStyle">\r        </resource>\r    </target>\r    \r  <!-- Charts -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r        <resource uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementFactory" />\r            \r        <type uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementFactory" />\r    </target>\r                \r    <target interface="org.simantics.diagram.synchronization.graph.ElementWriter">\r        <resource uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementWriter" />\r    </target>\r                    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IJFreeChart">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/Chart"\r            class="org.simantics.sysdyn.ui.trend.chart.JFreeChart">\r            <graph />\r            <this />\r        </type>\r    </target>  \r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IDataset">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.XYDataset">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryDataset">\r            <graph />\r            <this />\r        </type>        \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PieDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.PieDataset">\r            <graph />\r            <this />\r        </type>          \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.ITitle">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/TextTitle"\r            class="org.simantics.sysdyn.ui.trend.chart.TextTitle">\r            <graph />\r            <this />\r        </type>\r    </target>\r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IAxis">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/NumberAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.NumberAxis">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryAxis">\r            <graph />\r            <this />\r        </type>        \r    </target>\r       \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IPlot">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.XYPlot">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryPlot">\r            <graph />\r            <this />\r        </type>      \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PiePlot"\r            class="org.simantics.sysdyn.ui.trend.chart.PiePlot">\r            <graph />\r            <this />\r        </type>               \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.IRenderer">\r     \r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYLineRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.XYLineRenderer">\r            <graph />\r            <this />\r        </type>  \r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYAreaRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.XYAreaRenderer">\r            <graph />\r            <this />\r        </type>        \r                \r        <type uri="http://www.simantics.org/JFreeChart-1.0/BarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.BarRenderer">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/StackedBarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.StackedBarRenderer">\r            <graph />\r            <this />\r        </type>        \r    </target>    \r       \r
+<adapters>\r\r   <target interface="org.simantics.db.layer0.adapter.Realization">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/Module"\r                 class="org.simantics.structural2.realization.StructuralRealization">\r                   <this />\r               </type>\r        </target>\r\r     <target interface="org.simantics.layer0.utils.triggers.ITrigger">\r      <type uri = "http://www.simantics.org/Sysdyn-0.0/DiagramToCompositeMapping"\r          class = "org.simantics.sysdyn.ui.editor.DiagramToCompositeMapping3">\r         <graph/>\r           <this />\r       </type>\r        </target>\r      \r       <target interface="org.simantics.structural.ui.modelBrowser.nodes.AbstractNode">\r               <type uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                    class="org.simantics.structural.ui.modelBrowser.nodes.ModelNode">\r                      <this />\r               </type>\r        </target>               \r               \r\r      <target\r                interface="org.simantics.browsing.ui.common.node.AbstractNode">\r                <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/SysdynModel"\r                  class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r                       <this />\r               </type>\r\r               <resource\r                      uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                 class="org.simantics.sysdyn.ui.browser.nodes.SymbolNode">\r                      <this />\r               </resource>\r\r           <type\r                  uri="http://www.simantics.org/Simulation-1.0/Experiment"\r                       class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r                  <this />\r               </type>\r                \r               <type\r                  uri="http://www.simantics.org/Sysdyn-0.0/Result"\r                       class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r                    <this />\r               </type>\r                \r       </target>\r\r     <!-- Inject default connection routing algorithm for sysdyn diagrams -->\r       <target interface="org.simantics.g2d.diagram.DiagramClass">\r            <adapter uri="http://www.simantics.org/Sysdyn-0.0/ConfigurationDiagram"\r                        adapterClass="org.simantics.sysdyn.ui.elements2.ConfigurationDiagramClassAdapter" />\r   </target>\r\r     <!-- Sysdyn symbols -->\r        <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                       class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <resource uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                    class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <resource uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <resource uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                        class="org.simantics.sysdyn.ui.elements2.InputFactory" />\r\r             <type uri="http://www.simantics.org/Sysdyn-0.0/StockSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/ModuleSymbol"\r                   class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\r             <type uri="http://www.simantics.org/Sysdyn-0.0/ValveSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/AuxiliarySymbol"\r                        class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r          <type uri="http://www.simantics.org/Sysdyn-0.0/CloudSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r              <type uri="http://www.simantics.org/Sysdyn-0.0/InputSymbol"\r                    class="org.simantics.sysdyn.ui.elements2.InputFactory" />                       \r       </target>\r      \r       <!-- Sysdyn connections -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r              <!-- Edges -->       \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />\r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowEdgeFactory" />            \r        <type uri="http://www.simantics.org/Sysdyn-0.0/FlowConnection"\r            class="org.simantics.sysdyn.ui.elements2.connections.RouteFlowConnectionFactory">\r            <graph/>\r        </type>                       \r                       \r               <resource uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                       class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyEdgeFactory" />\r         <type uri="http://www.simantics.org/Sysdyn-0.0/DependencyConnection"\r                   class="org.simantics.sysdyn.ui.elements2.connections.DependencyConnectionFactory" />\r   </target>\r      \r       <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r          <baseType uri="http://www.simantics.org/Diagram-0.0/HasConnector" />\r   <resource uri="http://www.simantics.org/Diagram-0.0/HasPlainConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>none 0</string>\r       </resource>\r    <resource uri="http://www.simantics.org/Diagram-0.0/HasArrowConnector"\r          class="org.simantics.diagram.content.ArrowConfigurer">\r         <string>fill 1</string>\r       </resource>\r  </target>\r      \r       <!-- ModelBrowser2 -->\r \r       <target interface="org.simantics.browsing.ui.model.children.ChildRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleTypeChildRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleContentChildRule"\r            class="org.simantics.sysdyn.ui.browser.childrules.ModuleContentChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisChildRule"/>     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.VariableChildRule"/>  \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>           \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesChildRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesChildRule"/>    \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableChildRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableChildRule"/>                \r    </target>\r    \r    <target interface="org.simantics.browsing.ui.model.visuals.VisualsRule">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectBrowseContext/ModuleTypeLabelRule"\r            class="org.simantics.sysdyn.ui.browser.labelrules.ModuleTypeLabelRule"/>\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/AxisLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisLabelRule"/> \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/HistoryDataset/HistoryDatasetVariablesBrowseContext/VariableLabelRule"\r            class="org.simantics.sysdyn.ui.properties.widgets.historyDataset.VariableLabelRule"/>                \r                \r                     \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>   \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>         \r        <resource uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesBrowseContext/SeriesLabelDecorationRule"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesLabelDecorationRule"/>     \r    </target>    \r    \r    <target interface="org.simantics.db.layer0.adapter.ActionFactory">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewModuleType"\r            class="org.simantics.sysdyn.ui.browser.actions.NewModuleTypeAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewEnumeration"\r            class="org.simantics.sysdyn.ui.browser.actions.NewEnumerationAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/OpenWorkbook"\r            class="org.simantics.sysdyn.ui.browser.actions.OpenWorkbookAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunction"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewFunctionLibraryAction" />\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/ProjectActionContext/Actions/NewSharedFunctionLibrary"\r            class="org.simantics.sysdyn.ui.browser.actions.NewSharedFunctionLibraryAction" />            \r    </target>         \r    \r   <target interface="org.simantics.db.layer0.adapter.DropActionFactory">\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/ChartAxisAndVariablesActionContext/Actions/AxisDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.AxisDropAction" />            \r            \r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/BarSeriesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />\r        <resource\r            uri="http://www.simantics.org/Sysdyn-0.0/PieSeriesActionContext/Actions/SeriesDropAction"\r            class="org.simantics.sysdyn.ui.trend.chart.graphexplorer.SeriesDropAction" />                        \r    </target>     \r  \r  <!-- PROFILES -->\r    <target interface="org.simantics.scenegraph.profile.Style">\r        <resource uri="http://www.simantics.org/Sysdyn-0.0/SimulationPlaybackStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.SimulationPlaybackStyle">\r        </resource>\r                <resource uri="http://www.simantics.org/Sysdyn-0.0/IssueStyle"\r            class="org.simantics.sysdyn.ui.elements2.profiles.IssueDecorationStyle">\r        </resource>\r    </target>\r    \r  <!-- Charts -->\r    <target interface="org.simantics.diagram.adapter.ElementFactory">\r        <resource uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementFactory" />\r            \r        <type uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementFactory" />\r    </target>\r                \r    <target interface="org.simantics.diagram.synchronization.graph.ElementWriter">\r        <resource uri="http://www.simantics.org/JFreeChart-1.0/ChartElement"\r            class="org.simantics.sysdyn.ui.trend.chart.element.ChartElementWriter" />\r    </target>\r                    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IJFreeChart">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/Chart"\r            class="org.simantics.sysdyn.ui.trend.chart.JFreeChart">\r            <graph />\r            <this />\r        </type>\r    </target>  \r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IDataset">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.XYDataset">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryDataset">\r            <graph />\r            <this />\r        </type>        \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PieDataset"\r            class="org.simantics.sysdyn.ui.trend.chart.PieDataset">\r            <graph />\r            <this />\r        </type>          \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.ITitle">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/TextTitle"\r            class="org.simantics.sysdyn.ui.trend.chart.TextTitle">\r            <graph />\r            <this />\r        </type>\r    </target>\r    \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IAxis">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/NumberAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.NumberAxis">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryAxis"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryAxis">\r            <graph />\r            <this />\r        </type>        \r    </target>\r       \r    <target interface="org.simantics.sysdyn.ui.trend.chart.IPlot">\r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.XYPlot">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/CategoryPlot"\r            class="org.simantics.sysdyn.ui.trend.chart.CategoryPlot">\r            <graph />\r            <this />\r        </type>      \r        <type uri="http://www.simantics.org/JFreeChart-1.0/PiePlot"\r            class="org.simantics.sysdyn.ui.trend.chart.PiePlot">\r            <graph />\r            <this />\r        </type>               \r    </target>\r    \r     <target interface="org.simantics.sysdyn.ui.trend.chart.IRenderer">\r     \r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYLineRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.XYLineRenderer">\r            <graph />\r            <this />\r        </type>  \r        <type uri="http://www.simantics.org/JFreeChart-1.0/XYAreaRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.XYAreaRenderer">\r            <graph />\r            <this />\r        </type>        \r                \r        <type uri="http://www.simantics.org/JFreeChart-1.0/BarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.BarRenderer">\r            <graph />\r            <this />\r        </type>\r        <type uri="http://www.simantics.org/JFreeChart-1.0/StackedBarRenderer"\r            class="org.simantics.sysdyn.ui.trend.chart.StackedBarRenderer">\r            <graph />\r            <this />\r        </type>        \r    </target>    \r       \r
 </adapters>
\ No newline at end of file
index 144ef94112a3e1058a43c9ae65594c60fd0845e9..949c5febffa64767f915200e589241af1fa38437 100644 (file)
                   </with>\r
                </visibleWhen>\r
             </command>\r
+            <command\r
+                  commandId="org.simantics.sysdyn.ui.newHistoryData"\r
+                  icon="platform:/plugin/com.famfamfam.silk/icons/table.png"\r
+                  id="org.simantics.sysdyn.ui.browser.newHistoryData"\r
+                  label="History Data"\r
+                  style="push">\r
+               <visibleWhen\r
+                     checkEnabled="true">\r
+                  <with\r
+                        variable="selection">\r
+                     <test\r
+                           args="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode"\r
+                           property="org.simantics.sysdyn.ui.nodeClass">\r
+                     </test>\r
+                  </with>\r
+               </visibleWhen>\r
+            </command>\r
          </menu>\r
          <dynamic\r
                class="org.simantics.ui.contribution.OpenWithMenuContribution"\r
             id="org.simantics.sysdyn.ui.newPieChart"\r
             name="New Pie Chart">\r
       </command>\r
+      <command\r
+            defaultHandler="org.simantics.sysdyn.ui.handlers.newComponents.NewHistoryDataHandler"\r
+            id="org.simantics.sysdyn.ui.newHistoryData"\r
+            name="New History Data">\r
+      </command>\r
    </extension>\r
    <extension\r
          point="org.eclipse.ui.handlers">\r
index 40bcbe6efc8e41732d534c511ff40f93c7d2b13f..8c9a821b55cef2573a6b3abc5a0eb4820b14dc6d 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 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
@@ -26,34 +26,35 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.ExperimentNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.HistoryDataNode;\r
 \r
 public class SimulationResult  extends ViewpointContributor<ExperimentNode> {\r
 \r
     @SuppressWarnings("unchecked")\r
-       @Override\r
+    @Override\r
     public Collection<?> getContribution(ReadGraph graph, ExperimentNode experiment) throws DatabaseException {\r
         ArrayList<AbstractNode<Resource>> result = new ArrayList<AbstractNode<Resource>>();\r
         SysdynResource sr = SysdynResource.getInstance(graph);\r
         for(final Resource r : graph.syncRequest(new ObjectsWithType(experiment.data, sr.Experiment_result, sr.Result))) {\r
-            String resultPath = (String)graph.getPossibleRelatedValue(r, sr.Result_resultFile);\r
-            File file = new File(resultPath);\r
-            if(file.exists()) {\r
-                try {\r
-                    result.add(graph.adapt(r, AbstractNode.class));\r
-                } catch(DatabaseException e) {\r
-                    e.printStackTrace();\r
-                }\r
+            if(graph.isInstanceOf(r, sr.HistoryDataset)) {\r
+                result.add(graph.adapt(r, AbstractNode.class));\r
             } else {\r
-                graph.asyncRequest(new WriteRequest() {\r
-                    \r
-                    @Override\r
-                    public void perform(WriteGraph graph) throws DatabaseException {\r
-                       Layer0 l0 = Layer0.getInstance(graph);\r
-                        graph.deny(r, l0.PartOf);\r
-                        graph.deny(r, graph.getInverse(SysdynResource.getInstance(graph).Experiment_result));\r
-                        \r
-                    }\r
-                });\r
+                String resultPath = (String)graph.getPossibleRelatedValue(r, sr.Result_resultFile);\r
+                File file = new File(resultPath);\r
+                if(file.exists()) {\r
+                    result.add(new HistoryDataNode(r));\r
+                } else {\r
+                    graph.asyncRequest(new WriteRequest() {\r
+\r
+                        @Override\r
+                        public void perform(WriteGraph graph) throws DatabaseException {\r
+                            Layer0 l0 = Layer0.getInstance(graph);\r
+                            graph.deny(r, l0.PartOf);\r
+                            graph.deny(r, graph.getInverse(SysdynResource.getInstance(graph).Experiment_result));\r
+\r
+                        }\r
+                    });\r
+                }\r
             }\r
         }\r
         return result;\r
index f3abbfa761ddcf303fb2e685d28bd347e351eb24..442e91a02dbdbaaeb346c9b8bb8af9abc726a45a 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 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
@@ -16,14 +16,15 @@ import org.eclipse.swt.SWT;
 import org.simantics.browsing.ui.content.LabelDecorator;\r
 import org.simantics.browsing.ui.graph.contributor.labeler.LabelDecoratorContributor;\r
 import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode;\r
 \r
-public class SimulationResultDecorator extends LabelDecoratorContributor<SimulationResultNode>{\r
+public class SimulationResultDecorator extends LabelDecoratorContributor<SimulationResultNode<Resource>>{\r
 \r
     @Override\r
-    public LabelDecorator getDecorator(ReadGraph graph, SimulationResultNode result) throws DatabaseException {\r
+    public LabelDecorator getDecorator(ReadGraph graph, SimulationResultNode<Resource> result) throws DatabaseException {\r
         if (graph.hasStatement(result.data, SysdynResource.getInstance(graph).Result_showResult)) {\r
             return new LabelDecorator.Stub() {\r
 \r
index 3c2de6cf8b602a60ad38506f5157023cc349e202..3dc688d5d9a6eec53b003742fdb946b462341d47 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 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
@@ -14,16 +14,20 @@ package org.simantics.sysdyn.ui.browser.contributions;
 import org.eclipse.jface.resource.ImageDescriptor;\r
 import org.simantics.browsing.ui.swt.ImagerContributor;\r
 import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.sysdyn.SysdynResource;\r
 import org.simantics.sysdyn.ui.Activator;\r
 import org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode;\r
 \r
-public class SimulationResultImager extends ImagerContributor<SimulationResultNode>{\r
+public class SimulationResultImager extends ImagerContributor<SimulationResultNode<Resource>>{\r
 \r
     @Override\r
-    public ImageDescriptor getDescriptor(ReadGraph graph, SimulationResultNode result) throws DatabaseException {\r
-        if(graph.hasStatement(result.data, SysdynResource.getInstance(graph).Result_showResult))\r
+    public ImageDescriptor getDescriptor(ReadGraph graph, SimulationResultNode<Resource> result) throws DatabaseException {\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        if(graph.isInstanceOf(result.data, sr.HistoryDataset))\r
+            return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/table.png"));\r
+        if(graph.hasStatement(result.data, sr.Result_showResult))\r
             return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_bar.png"));\r
         else\r
             return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/chart_bar_blackAndWhite.png"));\r
index 917adb9c54f3b49792b512aca78f50a0dbcb87ce..f0e968edfc2f970f42ac018cb77f25f71f27bc44 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 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
@@ -13,14 +13,15 @@ package org.simantics.sysdyn.ui.browser.contributions;
 \r
 import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
 import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode;\r
 \r
-public class SimulationResultLabeler extends LabelerContributor<SimulationResultNode>{\r
+public class SimulationResultLabeler extends LabelerContributor<SimulationResultNode<Resource>>{\r
 \r
     @Override\r
-    public String getLabel(ReadGraph graph, SimulationResultNode result) throws DatabaseException {\r
+    public String getLabel(ReadGraph graph, SimulationResultNode<Resource> result) throws DatabaseException {\r
         String name = graph.getPossibleRelatedValue(result.data, Layer0.getInstance(graph).HasLabel);\r
         return name == null ? "Experiment (no name)" : name;\r
     }\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/HistoryDataNode.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/browser/nodes/HistoryDataNode.java
new file mode 100644 (file)
index 0000000..196a52e
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************\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.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.DeleteException;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.exception.CancelTransactionException;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.util.RemoverUtil;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.utils.ui.ExceptionUtils;\r
+\r
+public class HistoryDataNode extends SimulationResultNode<Resource> {\r
+\r
+    public HistoryDataNode(Resource resource) {\r
+        super(resource);\r
+    }\r
+\r
+    @Override\r
+    public void delete() throws DeleteException {\r
+        try {\r
+            SimanticsUI.getSession().syncRequest(new WriteRequest() {\r
+                @Override\r
+                public void perform(WriteGraph graph) throws DatabaseException, CancelTransactionException {\r
+                    RemoverUtil.remove(graph, data);\r
+                }\r
+            });\r
+        } catch (DatabaseException e) {\r
+            ExceptionUtils.logAndShowError(e);\r
+        }\r
+        \r
+    }\r
+}\r
index 768b591e03b47d763fdd8d67aa4cfa9483573b60..bc9c4a3f467bbaa3cb3f3d8dd2047993e1335793 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 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
@@ -31,7 +31,7 @@ import org.simantics.sysdyn.ui.handlers.ToggleResultActivation;
 import org.simantics.ui.SimanticsUI;\r
 import org.simantics.utils.ui.ExceptionUtils;\r
 \r
-public class SimulationResultNode  extends AbstractNode<Resource> implements IDoubleClickableNode, IDeletableNode, IModifiableNode {\r
+public class SimulationResultNode<T>  extends AbstractNode<Resource> implements IDoubleClickableNode, IDeletableNode, IModifiableNode {\r
 \r
     public SimulationResultNode(Resource resource) {\r
         super(resource);\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewHistoryDataHandler.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/handlers/newComponents/NewHistoryDataHandler.java
new file mode 100644 (file)
index 0000000..09d7beb
--- /dev/null
@@ -0,0 +1,69 @@
+/*******************************************************************************\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.ui.handlers.newComponents;\r
+\r
+import java.util.UUID;\r
+\r
+import org.eclipse.core.commands.AbstractHandler;\r
+import org.eclipse.core.commands.ExecutionEvent;\r
+import org.eclipse.core.commands.ExecutionException;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.ui.handlers.HandlerUtil;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.layer0.utils.direct.GraphUtils;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.ui.SimanticsUI;\r
+import org.simantics.ui.utils.AdaptionUtils;\r
+\r
+/**\r
+ * Handler for creating new history dataset\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class NewHistoryDataHandler extends AbstractHandler {\r
+\r
+    @Override\r
+    public Object execute(ExecutionEvent event) throws ExecutionException {\r
+\r
+        ISelection sel = HandlerUtil.getCurrentSelection(event);\r
+\r
+        final Resource experiment = AdaptionUtils.adaptToSingle(sel, Resource.class);\r
+\r
+        SimanticsUI.getSession().asyncRequest(new WriteRequest() {\r
+\r
+            @Override\r
+            public void perform(WriteGraph g) throws DatabaseException {\r
+                SysdynResource sr = SysdynResource.getInstance(g);\r
+                Layer0 l0 = Layer0.getInstance(g);\r
+                if(!g.isInstanceOf(experiment, sr.Experiment))\r
+                    return; // Not called from an experiment\r
+\r
+                Resource model = g.getPossibleObject(experiment, l0.PartOf);\r
+                // Create the history dataset\r
+                GraphUtils.create2(g, \r
+                        sr.HistoryDataset,\r
+                        l0.HasName, "HistoryDataset" + UUID.randomUUID().toString(),\r
+                        l0.HasLabel, NameUtils.findFreshLabel(g, "History Dataset", experiment),\r
+                        sr.Experiment_result_Inverse, experiment, \r
+                        sr.HistoryDataset_columns, Boolean.TRUE,\r
+                        l0.PartOf, model);\r
+            }\r
+        });\r
+        return null;\r
+    }\r
+\r
+}
\ No newline at end of file
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/HistoryDataTab.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/HistoryDataTab.java
new file mode 100644 (file)
index 0000000..fe3694d
--- /dev/null
@@ -0,0 +1,286 @@
+/*******************************************************************************\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.ui.properties;\r
+\r
+import java.util.Collection;\r
+import java.util.LinkedHashMap;\r
+import java.util.Map;\r
+\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.custom.ScrolledComposite;\r
+import org.eclipse.swt.widgets.Combo;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Group;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
+import org.simantics.browsing.ui.swt.widgets.Button;\r
+import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyFactory;\r
+import org.simantics.browsing.ui.swt.widgets.StringPropertyModifier;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedCombo;\r
+import org.simantics.browsing.ui.swt.widgets.TrackedText;\r
+import org.simantics.browsing.ui.swt.widgets.impl.ReadFactoryImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TextModifyListener;\r
+import org.simantics.browsing.ui.swt.widgets.impl.TrackedModifyEvent;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.request.PossibleObjectWithType;\r
+import org.simantics.db.common.request.WriteRequest;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.spreadsheet.resource.SpreadsheetResource;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.datastructures.ArrayMap;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+/**\r
+ * Tab for displaying and modifying history data settings in SysDyn.\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class HistoryDataTab  extends LabelPropertyTabContributor {\r
+\r
+    @Override\r
+    public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+        \r
+        // Scrolled composite for scrollable tab\r
+        ScrolledComposite sc = new ScrolledComposite(body, SWT.H_SCROLL | SWT.V_SCROLL);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(sc);\r
+        GridLayoutFactory.fillDefaults().margins(3, 3).applyTo(sc);\r
+\r
+        // Container for all components\r
+        Composite composite = new Composite(sc, SWT.NONE);\r
+        GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+        GridLayoutFactory.fillDefaults().numColumns(3).margins(3, 3).applyTo(composite);\r
+\r
+        // Name\r
+        Label label = new Label(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+        label.setText("Name: ");\r
+        \r
+        TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+        nameText.setTextFactory(new StringPropertyFactory(Layer0.URIs.HasLabel));\r
+        nameText.addModifyListener(new StringPropertyModifier(context, Layer0.URIs.HasLabel));\r
+        GridDataFactory.fillDefaults().grab(true, false).span(2, 1).applyTo(nameText.getWidget());\r
+\r
+        // Sheet selection \r
+        label = new Label(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+        label.setText("Sheet: ");\r
+        \r
+        TrackedCombo sheet = new TrackedCombo(composite, support, SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);\r
+        sheet.setItemFactory(new SheetItemFactory());\r
+        sheet.setSelectionFactory(new SheetSelectionFactory());\r
+        sheet.addModifyListener(new SheetModifyListener());\r
+        GridDataFactory.fillDefaults().span(2, 1).applyTo(sheet.getWidget());\r
+\r
+        // Orientation (columns or rows)\r
+        label = new Label(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+        label.setText("Orientation: ");\r
+        \r
+        Composite orientation = new Composite(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().applyTo(orientation);\r
+        GridLayoutFactory.fillDefaults().numColumns(2).applyTo(orientation);\r
+        \r
+        // Radio buttons for orientation\r
+        Button columns = new Button(orientation, support, SWT.RADIO);\r
+        GridDataFactory.fillDefaults().applyTo(columns.getWidget());\r
+        columns.setText("Columns");\r
+        columns.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+            @Override\r
+            public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+                graph.claimLiteral(input, SysdynResource.getInstance(graph).HistoryDataset_columns, Boolean.TRUE, Bindings.BOOLEAN);\r
+            }\r
+        });\r
+        columns.setSelectionFactory(new ReadFactoryImpl<Resource, Boolean>() {\r
+\r
+            @Override\r
+            public Boolean perform(ReadGraph graph, Resource input) throws DatabaseException {\r
+                return graph.getPossibleRelatedValue(input, SysdynResource.getInstance(graph).HistoryDataset_columns);\r
+            }\r
+        });\r
+        \r
+        Button rows = new Button(orientation, support, SWT.RADIO);\r
+        rows.setText("Rows");\r
+        rows.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+            @Override\r
+            public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+                graph.claimLiteral(input, SysdynResource.getInstance(graph).HistoryDataset_columns, Boolean.FALSE, Bindings.BOOLEAN);\r
+            }\r
+        });\r
+        rows.setSelectionFactory(new ReadFactoryImpl<Resource, Boolean>() {\r
+\r
+            @Override\r
+            public Boolean perform(ReadGraph graph, Resource input) throws DatabaseException {\r
+                return Boolean.FALSE.equals(graph.getPossibleRelatedValue(input, SysdynResource.getInstance(graph).HistoryDataset_columns));\r
+            }\r
+        });\r
+        \r
+        \r
+        // Group container displaying all variables found in the defined range\r
+        Group c = new Group(composite, SWT.NONE);\r
+        c.setText("Variables in range");\r
+        GridDataFactory.fillDefaults().span(1, 4).applyTo(c);\r
+        GridLayoutFactory.fillDefaults().margins(3, 1).spacing(0, 0).applyTo(c);\r
+        \r
+        GraphExplorerComposite explorer = new GraphExplorerComposite(ArrayMap.keys(\r
+                "displaySelectors", "displayFilter").values(false, false), site, c, support, SWT.FULL_SELECTION | SWT.BORDER);\r
+        explorer.setBrowseContexts(SysdynResource.URIs.HistoryDataset_HistoryDatasetVariablesBrowseContext);\r
+        explorer.setInputSource(new SingleSelectionInputSource(Resource.class));\r
+        explorer.finish();\r
+        GridDataFactory.fillDefaults().hint(SWT.DEFAULT,100).grab(true, false).applyTo(explorer);\r
+        \r
+        // Range start \r
+        label = new Label(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+        label.setText("Range Start: ");\r
+        \r
+        TrackedText start = new TrackedText(composite, support, SWT.BORDER);\r
+        start.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.HistoryDataset_start));\r
+        start.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.HistoryDataset_start));\r
+        GridDataFactory.fillDefaults().applyTo(start.getWidget());\r
+        \r
+        // Range end\r
+        label = new Label(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+        label.setText("Range End: ");\r
+        \r
+        TrackedText end = new TrackedText(composite, support, SWT.BORDER);\r
+        end.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.HistoryDataset_end));\r
+        end.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.HistoryDataset_end));\r
+        GridDataFactory.fillDefaults().applyTo(end.getWidget());\r
+        \r
+        // Time variable. This variable is used as time values in the history dataset\r
+        label = new Label(composite, SWT.NONE);\r
+        GridDataFactory.fillDefaults().align(SWT.END, SWT.FILL).applyTo(label);\r
+        label.setText("Time variable: ");\r
+        \r
+        TrackedText time = new TrackedText(composite, support, SWT.BORDER);\r
+        time.setTextFactory(new StringPropertyFactory(SysdynResource.URIs.HistoryDataset_timeName));\r
+        time.addModifyListener(new StringPropertyModifier(context, SysdynResource.URIs.HistoryDataset_timeName));\r
+        GridDataFactory.fillDefaults().applyTo(time.getWidget());\r
+        \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
+    /**\r
+     * Item factory for finding spreadsheets from a model\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class SheetItemFactory extends ReadFactoryImpl<Resource, Map<String,Object>> {\r
+\r
+        @Override\r
+        public Map<String, Object> perform(ReadGraph graph, Resource historyData) throws DatabaseException {\r
+            Layer0 l0 = Layer0.getInstance(graph);\r
+            SimulationResource simu = SimulationResource.getInstance(graph);\r
+            SpreadsheetResource spreadSheet = SpreadsheetResource.getInstance(graph);\r
+\r
+            Resource model = graph.getPossibleObject(historyData, l0.PartOf);\r
+            Resource config = graph.getPossibleObject(model, simu.HasConfiguration);\r
+            Resource book = graph.syncRequest(new PossibleObjectWithType(config, l0.ConsistsOf, spreadSheet.Book));\r
+            Collection<Resource> sheets = graph.syncRequest(new ObjectsWithType(book, l0.ConsistsOf, spreadSheet.Spreadsheet));\r
+\r
+            Map<String, Object> map = new LinkedHashMap<String, Object>();\r
+\r
+            for(Resource sheet : sheets) {\r
+                map.put(NameUtils.getSafeName(graph, sheet), sheet);\r
+            }\r
+            return map;\r
+        }\r
+    };\r
+    \r
+    /**\r
+     * Selection factory for finding the defined sheet name for a history dataset\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class SheetSelectionFactory extends ReadFactoryImpl<Resource, String> {\r
+\r
+        @Override\r
+        public String perform(ReadGraph graph, Resource historyData) throws DatabaseException {\r
+            Resource selectedSheet = graph.getPossibleObject(historyData, SysdynResource.getInstance(graph).HistoryDataset_sheet);\r
+            if(selectedSheet != null) {\r
+                String name = NameUtils.getSafeName(graph, selectedSheet);\r
+                return name;// Return the selected sheet, if it exits\r
+            } else {\r
+                return null;\r
+            }\r
+        }\r
+    };\r
+\r
+    /**\r
+     * Listener for listening sheet selections in sheet combo\r
+     * @author Teemu Lempinen\r
+     *\r
+     */\r
+    private class SheetModifyListener implements TextModifyListener, Widget {\r
+\r
+        private ISessionContext context;\r
+        private Object lastInput = null;\r
+\r
+        @Override\r
+        public void modifyText(TrackedModifyEvent e) {\r
+\r
+            Combo combo = (Combo)e.getWidget();\r
+            String textValue = combo.getText();\r
+            Map<?,?> data = (Map<?, ?>) combo.getData();\r
+            if(data == null) return;\r
+            final Resource value = (Resource) data.get(textValue);\r
+            if(value == null) return;\r
+            final Object input = lastInput;\r
+\r
+            try {\r
+                context.getSession().syncRequest(new WriteRequest() {\r
+                    @Override\r
+                    public void perform(WriteGraph graph) throws DatabaseException {\r
+\r
+                        Resource resource = (Resource) ISelectionUtils.filterSingleSelection((ISelection)input, Resource.class);\r
+                        SysdynResource sr = SysdynResource.getInstance(graph);\r
+                        graph.deny(resource, sr.HistoryDataset_sheet);\r
+                        graph.claim(resource, SysdynResource.getInstance(graph).HistoryDataset_sheet, value);\r
+                    }\r
+\r
+                });\r
+            } catch (DatabaseException e1) {\r
+                e1.printStackTrace();\r
+            }\r
+        }\r
+\r
+        @Override\r
+        public void setInput(ISessionContext context, Object parameter) {\r
+            this.context = context;\r
+            lastInput = parameter;\r
+        }\r
+    }\r
+}\r
index d26e366817b21fdf1960ef101ed46b5bc3863cbf..35f0299ff9004320b2a9121184e6e17e2a0da593 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010, 2011 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 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
@@ -246,6 +246,15 @@ public class ResourceSelectionProcessor implements SelectionProcessor<Object, Re
                                 r,\r
                                 "Experiment Properties"));\r
 \r
+            // History data\r
+            if (backend.isInstanceOf(r, sr.HistoryDataset))\r
+                return Collections.singleton(\r
+                        new ComparableTabContributor(\r
+                                new HistoryDataTab(),\r
+                                0,\r
+                                r,\r
+                                "History Data Properties"));\r
+            \r
             // Saved simulation result\r
             if (backend.isInstanceOf(r, sr.Result))\r
                 return Collections.singleton(\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/historyDataset/VariableChildRule.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/historyDataset/VariableChildRule.java
new file mode 100644 (file)
index 0000000..45b2924
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************\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.ui.properties.widgets.historyDataset;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.model.children.ChildRule;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.manager.HistoryDatasetUtils;\r
+import org.simantics.sysdyn.ui.properties.HistoryDataTab;\r
+\r
+/**\r
+ * Variable child rule for GE in {@link HistoryDataTab}\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class VariableChildRule implements ChildRule {\r
+\r
+    @Override\r
+    public boolean isCompatible(Class<?> contentType) {\r
+        return contentType.equals(Resource.class);\r
+    }\r
+\r
+    @Override\r
+    public Collection<?> getChildren(ReadGraph graph, Object parent) throws DatabaseException {\r
+        ArrayList<String> result = new ArrayList<String>();\r
+        if(!(parent instanceof Resource))\r
+            return result;\r
+        result.addAll(HistoryDatasetUtils.getVariableNamesInRange(graph, (Resource)parent));\r
+        return result;\r
+\r
+\r
+    }\r
+\r
+    @Override\r
+    public Collection<?> getParents(ReadGraph graph, Object child) throws DatabaseException {\r
+        return new ArrayList<Resource>();\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/historyDataset/VariableLabelRule.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/properties/widgets/historyDataset/VariableLabelRule.java
new file mode 100644 (file)
index 0000000..0cb9459
--- /dev/null
@@ -0,0 +1,40 @@
+/*******************************************************************************\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.ui.properties.widgets.historyDataset;\r
+\r
+import java.util.Collections;\r
+import java.util.Map;\r
+\r
+import org.simantics.browsing.ui.common.ColumnKeys;\r
+import org.simantics.browsing.ui.model.labels.LabelRule;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.properties.HistoryDataTab;\r
+\r
+/**\r
+ * Variable label rule for GE in {@link HistoryDataTab}\r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class VariableLabelRule implements LabelRule {\r
+\r
+    @Override\r
+    public boolean isCompatible(Class<?> contentType) {\r
+        return contentType.equals(String.class);\r
+    }\r
+\r
+    @Override\r
+    public Map<String, String> getLabel(ReadGraph graph, Object content) throws DatabaseException {\r
+        return Collections.singletonMap(ColumnKeys.SINGLE, (content instanceof String ? (String)content : "No content"));\r
+    }\r
+\r
+}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/HistoryDatasetResult.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/HistoryDatasetResult.java
new file mode 100644 (file)
index 0000000..21ed8b0
--- /dev/null
@@ -0,0 +1,309 @@
+/*******************************************************************************\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.io.File;\r
+import java.io.InputStream;\r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
+import java.util.List;\r
+\r
+import org.simantics.Simantics;\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.binding.mutable.Variant;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.utils.NameUtils;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.db.procedure.Listener;\r
+import org.simantics.db.request.Read;\r
+import org.simantics.layer0.Layer0;\r
+import org.simantics.modelica.data.DataSet;\r
+import org.simantics.modelica.data.SimulationResult;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.spreadsheet.SheetVariables;\r
+import org.simantics.spreadsheet.common.matrix.VariantMatrix;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.representation.Configuration;\r
+import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.Module;\r
+import org.simantics.sysdyn.representation.utils.IndexUtils;\r
+import org.simantics.utils.datastructures.Pair;\r
+\r
+/**\r
+ * A result built from a spreadsheet table. Imitates a normal simulation result for \r
+ * easy display on charts and tables.\r
+ * \r
+ * @author Teemu Lempinen\r
+ *\r
+ */\r
+public class HistoryDatasetResult extends SimulationResult {\r
+    @Override\r
+    public void read(File file) {} // Do nothing\r
+    @Override\r
+    public void read(InputStream stream) {} // Do nothing\r
+\r
+    private boolean disposed;\r
+\r
+    /**\r
+     * Dispose listeners of this result. It is important to dispose all listeners \r
+     * when they are not needed anymore.\r
+     */\r
+    public void disposeListeners() {\r
+        this.disposed = true;\r
+    }\r
+\r
+    /**\r
+     * Reads history data to this result. Location of the data is described in historyData resource.\r
+     * \r
+     * @param sysdynResult SysdynResult to which this simulation result is read\r
+     * @param historyData Resource describing the history data to be read from a spreadsheet\r
+     */\r
+    public void read(final SysdynResult sysdynResult, final Resource historyData) {\r
+\r
+        Simantics.getSession().asyncRequest(new Read<Pair<SysdynModel, List<DataSet>>>() {\r
+\r
+            @Override\r
+            public Pair<SysdynModel, List<DataSet>> perform(ReadGraph graph) throws DatabaseException {\r
+                ArrayList<DataSet> variables = new ArrayList<DataSet>();\r
+\r
+                SysdynResource sr = SysdynResource.getInstance(graph);\r
+                Layer0 l0 = Layer0.getInstance(graph);\r
+                SimulationResource simu = SimulationResource.getInstance(graph);\r
+\r
+                String datasetName = "History Dataset";\r
+                VariantMatrix vm = null;\r
+                SysdynModel sdmodel = null;\r
+                String timeVariable = "time";\r
+                boolean columns = true;\r
+                try {\r
+                    Pair<SysdynModel, List<DataSet>> emptyResult = new Pair<SysdynModel, List<DataSet>>(sdmodel, variables);\r
+\r
+                    \r
+                    // Find the SysdynModel of this historyData\r
+                    Resource model = graph.getPossibleObject(historyData, l0.PartOf);\r
+                    Resource config = graph.getPossibleObject(model, simu.HasConfiguration);\r
+                    sdmodel = SysdynModelManager.getInstance(graph.getSession()).getModel(graph, config);\r
+                    sdmodel.update(graph);\r
+                    \r
+                    // Find properties of the result: name, sheet, range, time variable, orientation\r
+                    datasetName = NameUtils.getSafeLabel(graph, historyData);\r
+                    \r
+\r
+                    Resource sheet = graph.getPossibleObject(historyData, sr.HistoryDataset_sheet);\r
+                    if(sheet == null)\r
+                        return emptyResult;\r
+                    \r
+                    String start = graph.getPossibleRelatedValue(historyData, sr.HistoryDataset_start);\r
+                    String end = graph.getPossibleRelatedValue(historyData, sr.HistoryDataset_end);\r
+                    if(start == null || start.isEmpty() || end == null || end.isEmpty())\r
+                        return emptyResult;\r
+                    String r = start + ":" + end;\r
+                    \r
+                    String time = graph.getPossibleRelatedValue(historyData, sr.HistoryDataset_timeName);\r
+                    if(time != null && !time.isEmpty())\r
+                        timeVariable = time;\r
+                    \r
+                    if(graph.hasStatement(historyData, sr.HistoryDataset_columns))\r
+                        columns = graph.getRelatedValue(historyData, sr.HistoryDataset_columns, Bindings.BOOLEAN);\r
+                        \r
+                    // Find the sheet variable\r
+                    Variable v = graph.adapt(sheet, Variable.class);\r
+                    Variable range = v.getChild(graph, r);\r
+                    if(range == null)\r
+                        return emptyResult;\r
+                    \r
+                    // Find the content of the range\r
+                    Variant content = range.getPropertyValue(graph, SheetVariables.CONTENT, Bindings.VARIANT);\r
+                    Object matrixValue = content.getValue();\r
+                    if(matrixValue instanceof VariantMatrix) {\r
+                        vm = (VariantMatrix)matrixValue;\r
+                    }\r
+\r
+                } catch(DatabaseException e) {\r
+                    return new Pair<SysdynModel, List<DataSet>>(sdmodel, variables);\r
+                } catch(NegativeArraySizeException e) {\r
+                    // Negative array size may be result of mofifying start and end variables\r
+                    return new Pair<SysdynModel, List<DataSet>>(sdmodel, variables);\r
+                }\r
+\r
+                \r
+                // Orientation\r
+                int x = columns ? vm.getColumnCount() : vm.getRowCount();\r
+                int y = columns ? vm.getRowCount() : vm.getColumnCount();\r
+                \r
+                /*\r
+                 * The table needs at least:\r
+                 * \r
+                 * headers for variables + one value\r
+                 * two variables (of which one is time-variable)\r
+                 * \r
+                 * => minimum of 2x2 matrix\r
+                 */\r
+                if(vm == null || x < 2 || y < 2)\r
+                    return new Pair<SysdynModel, List<DataSet>>(sdmodel, variables);\r
+\r
+                String[] names = new String[x];\r
+                HashMap<String, ArrayList<Pair<Double, Double>>> values = new HashMap<String, ArrayList<Pair<Double,Double>>>();\r
+                Integer timeIndex = null;\r
+                \r
+                // Find variable names\r
+                for(int i = 0; i < x ; i++) {\r
+                    Variant cell = columns ? vm.get(0, i) : vm.get(i, 0);\r
+                    if(cell != null && cell.getValue() != null) {\r
+                        String name = cell.getValue().toString();\r
+                        if(!values.containsKey(name)) {\r
+                            names[i] = name;\r
+                            values.put(names[i], new ArrayList<Pair<Double,Double>>());\r
+\r
+                            // Time column index\r
+                            if(names[i].equals(timeVariable))\r
+                                timeIndex = i;\r
+                        }\r
+                    } else {\r
+                        names[i] = null;\r
+                    }\r
+                }\r
+\r
+                // If times were not found, return empty\r
+                if(timeIndex == null || names[timeIndex] == null)\r
+                    return new Pair<SysdynModel, List<DataSet>>(sdmodel, variables);\r
+\r
+                // Get time column ready first\r
+                for(int i = 1; i < y; i++) {\r
+                    Variant cell = columns ? vm.get(i, timeIndex) : vm.get(timeIndex, i);\r
+                    Double value = null;\r
+                    if(cell != null)\r
+                        value = getDoubleValue(cell);\r
+                    values.get(names[timeIndex]).add(new Pair<Double, Double>(value, value)); // add also null-values\r
+                }\r
+\r
+                // Get variable values column by column (or row by row\r
+                for(int i = 0; i < x; i++) {\r
+                    if(i == timeIndex || names[i] == null) \r
+                        continue;\r
+\r
+                    for(int j = 1; j < y; j++) {\r
+                        Variant cell = columns ? vm.get(j, i) : vm.get(i, j);\r
+                        if(cell != null && cell.getValue() != null) {\r
+                            Double value = getDoubleValue(cell);\r
+                            if(value != null) {\r
+                                Pair<Double, Double> time = values.get(names[timeIndex]).get(j - 1);\r
+                                if(time != null && time.first != null) {\r
+                                    values.get(names[i]).add(\r
+                                            new Pair<Double, Double>(\r
+                                                    time.first, \r
+                                                    value)\r
+                                            );\r
+                                }\r
+                            }\r
+                        }\r
+                    }\r
+\r
+                    ArrayList<Pair<Double, Double>> doubles = values.get(names[i]);\r
+                    \r
+                    String name = names[i];\r
+                    // If the variable has array indexes, they need to be converted to numbers\r
+                    if(name.contains("[")) {\r
+                        org.simantics.sysdyn.representation.Variable variable = getVariable(name, sdmodel.getConfiguration());\r
+                        if(variable != null)\r
+                            name = IndexUtils.equationRangesToIndexes(variable, name);\r
+                    }\r
+\r
+                    // Read values to SysdynDataSet\r
+                    SysdynDataSet ds = new SysdynDataSet(name, datasetName, new double[doubles.size()], new double[doubles.size()]);\r
+                    variables.add(ds);\r
+                    for(int d = 0; d < doubles.size(); d++) {\r
+                        Pair<Double, Double> pair = doubles.get(d);\r
+                        ds.times[d] = pair.first;\r
+                        ds.values[d] = pair.second;\r
+                    }\r
+                }\r
+                return new Pair<SysdynModel, List<DataSet>>(sdmodel, variables);\r
+            }\r
+\r
+        }, new Listener<Pair<SysdynModel, List<DataSet>>>() {\r
+\r
+            @Override\r
+            public void execute(Pair<SysdynModel, List<DataSet>> result) {\r
+                // Update result set and send message to model that results have been changed\r
+                HistoryDatasetResult.this.variables = result.second;\r
+                sysdynResult.setResult(HistoryDatasetResult.this);\r
+                result.first.resultChanged();\r
+            }\r
+\r
+            @Override\r
+            public void exception(Throwable t) {\r
+                t.printStackTrace();\r
+            }\r
+\r
+            @Override\r
+            public boolean isDisposed() {\r
+                return disposed;\r
+            }\r
+        });\r
+\r
+\r
+    }\r
+    \r
+    /**\r
+     * Finds a variable defined by path starting from configuration \r
+     * @param path Path of the variable\r
+     * @param configuration Configuration where to look for the variable\r
+     * @return Variable\r
+     */\r
+    private org.simantics.sysdyn.representation.Variable getVariable(String path, Configuration configuration) {\r
+        String next = path;\r
+        int index = next.indexOf(".");\r
+\r
+        // If path has commas, we are looking for a module\r
+        if(index > 0) {\r
+            path = path.substring(index + 1);\r
+            next = next.substring(0, index);\r
+        } else {\r
+            // No commas, we are looking for a variable\r
+            if(next.contains("["))\r
+                // Variable has array indexes, remove the array indexes\r
+                next = next.substring(0, next.indexOf("["));\r
+        }\r
+\r
+        for(IElement e : configuration.getElements()) {\r
+            if(e instanceof org.simantics.sysdyn.representation.Variable) {\r
+                org.simantics.sysdyn.representation.Variable v = (org.simantics.sysdyn.representation.Variable) e;\r
+                if(v.getName().equals(next)) {\r
+                    return v; // found the variable\r
+                }\r
+            } else if(e instanceof Module && ((Module)e).getName().equals(next)) {\r
+                return getVariable(path, ((Module)e).getType().getConfiguration()); // Recursive call with a shorter path\r
+            }\r
+        }\r
+        return null;\r
+    }\r
+\r
+    /**\r
+     * Finds the double value from a spreadsheet cell. \r
+     * @param cell Cell where to look for\r
+     * @return Double value of the cell or null if not double or if empty\r
+     */\r
+    private Double getDoubleValue(Variant cell) {\r
+        if(cell.getValue() == null)\r
+            return null;\r
+\r
+        Double value = null;\r
+        try {\r
+            value = Double.parseDouble(cell.getValue().toString());\r
+        } catch (NumberFormatException e) {\r
+        }\r
+        return value;\r
+    }\r
+}\r
diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/HistoryDatasetUtils.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/manager/HistoryDatasetUtils.java
new file mode 100644 (file)
index 0000000..e164c81
--- /dev/null
@@ -0,0 +1,92 @@
+/*******************************************************************************\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.List;\r
+\r
+import org.simantics.databoard.Bindings;\r
+import org.simantics.databoard.binding.mutable.Variant;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.layer0.variable.Variable;\r
+import org.simantics.spreadsheet.SheetVariables;\r
+import org.simantics.spreadsheet.common.matrix.VariantMatrix;\r
+import org.simantics.sysdyn.SysdynResource;\r
+\r
+public class HistoryDatasetUtils {\r
+    \r
+    public static List<String> getVariableNamesInRange(ReadGraph graph, Resource historyData) throws DatabaseException {\r
+        SysdynResource sr = SysdynResource.getInstance(graph);\r
+        \r
+        ArrayList<String> values = new ArrayList<String>();\r
+\r
+\r
+        Resource sheet = graph.getPossibleObject(historyData, sr.HistoryDataset_sheet);\r
+        if(sheet == null)\r
+            return values;\r
+        \r
+        String start = graph.getPossibleRelatedValue(historyData, sr.HistoryDataset_start);\r
+        String end = graph.getPossibleRelatedValue(historyData, sr.HistoryDataset_end);\r
+        if(start == null || start.isEmpty() || end == null || end.isEmpty())\r
+            return values;\r
+        String r = start + ":" + end;\r
+        \r
+        if(!graph.hasStatement(historyData, sr.HistoryDataset_columns))\r
+            return values;\r
+            \r
+        boolean columns = graph.getRelatedValue(historyData, sr.HistoryDataset_columns, Bindings.BOOLEAN);\r
+            \r
+        Variable v = graph.adapt(sheet, Variable.class);\r
+        Variable range = v.getChild(graph, r);\r
+        if(range == null)\r
+            return values;\r
+        \r
+        Variant content = range.getPropertyValue(graph, SheetVariables.CONTENT, Bindings.VARIANT);\r
+        Object matrixValue = content.getValue();\r
+        if(!(matrixValue instanceof VariantMatrix))\r
+            return values;\r
+        \r
+        VariantMatrix vm = (VariantMatrix)matrixValue;\r
+        \r
+        /*\r
+         * The table needs at least:\r
+         * \r
+         * headers for variables + one value\r
+         * two variables (of which one is time-variable)\r
+         * \r
+         * => minimum of 2x2 matrix\r
+         */\r
+        \r
+        int x = columns ? vm.getColumnCount() : vm.getRowCount();\r
+        int y = columns ? vm.getRowCount() : vm.getColumnCount();\r
+        \r
+        if(vm == null || x < 2 || y < 2)\r
+            return values;\r
+\r
+        \r
+        // Names\r
+        for(int i = 0; i < x ; i++) {\r
+            Variant cell = columns ? vm.get(0, i) : vm.get(i, 0);\r
+            if(cell != null && cell.getValue() != null) {\r
+                String name = cell.getValue().toString();\r
+                if(!values.contains(name)) {\r
+                    values.add(name);\r
+                }\r
+            }\r
+        }\r
+        \r
+        return values;\r
+    }\r
+\r
+}\r
index 4f5315117ba374d8339c1c51f369866349d9d081..057885a67336f9e3af2235f985723b448d7b0a23 100644 (file)
@@ -33,6 +33,7 @@ import org.simantics.db.ReadGraph;
 import org.simantics.db.Resource;\r
 import org.simantics.db.Session;\r
 import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.common.utils.NameUtils;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.exception.ManyObjectsForFunctionalRelationException;\r
 import org.simantics.db.exception.ServiceException;\r
@@ -93,6 +94,7 @@ public class SysdynModel implements IMappingListener, IModel {
     private SimulationResult result;\r
     private SysdynResult sysdynResult;\r
     private ArrayList<SysdynResult> activeResults;\r
+    private ArrayList<HistoryDatasetResult> listeningHistories = new ArrayList<HistoryDatasetResult>();\r
 \r
     private CopyOnWriteArrayList<Runnable> modificationListeners =\r
             new CopyOnWriteArrayList<Runnable>();\r
@@ -187,12 +189,16 @@ public class SysdynModel implements IMappingListener, IModel {
         sysdynResult.setResult(new SimulationResult());\r
 \r
         previousModelStructure = "";\r
-        \r
+\r
         g.asyncRequest(new Read<ArrayList<SysdynResult>> () {\r
             @Override\r
             public ArrayList<SysdynResult> perform(ReadGraph graph) throws DatabaseException {\r
                 ArrayList<SysdynResult> activeResults = new ArrayList<SysdynResult>();\r
                 // TODO: this can be done automatically with a listener\r
+                \r
+                for(HistoryDatasetResult hs : listeningHistories)\r
+                    hs.disposeListeners(); // dispose old histories listening to spreadsheets\r
+                \r
                 try {\r
                     // Find all active saved results\r
                     Layer0 l0 = Layer0.getInstance(graph);\r
@@ -206,10 +212,21 @@ public class SysdynModel implements IMappingListener, IModel {
                         Collection<Resource> experimentResults = graph.getObjects(experiment, sr.Experiment_result);\r
                         for(Resource result : experimentResults) {\r
                             if(graph.hasStatement(result, sr.Result_showResult)) {\r
-                                SysdynResult sysdynResult = new SysdynResult(\r
-                                        (String) graph.getPossibleRelatedValue(result, l0.HasLabel),\r
-                                        (String) graph.getPossibleRelatedValue(result, sr.Result_resultFile));\r
-                                activeResults.add(sysdynResult);\r
+                                SysdynResult sysdynResult = null;\r
+                                if(graph.isInstanceOf(result, sr.HistoryDataset)) {\r
+                                    HistoryDatasetResult r = new HistoryDatasetResult();\r
+                                    listeningHistories.add(r);\r
+                                    sysdynResult = new SysdynResult(r, NameUtils.getSafeLabel(graph, result));\r
+                                    r.read(sysdynResult, result);\r
+                                } else {\r
+                                    sysdynResult = new SysdynResult(\r
+                                            (String) graph.getPossibleRelatedValue(result, l0.HasLabel),\r
+                                            (String) graph.getPossibleRelatedValue(result, sr.Result_resultFile));\r
+                                }\r
+                                \r
+                                if(sysdynResult != null)\r
+                                    activeResults.add(sysdynResult);\r
+\r
                             }\r
                         }\r
                     }\r
@@ -223,7 +240,7 @@ public class SysdynModel implements IMappingListener, IModel {
 \r
                 return activeResults;\r
             }\r
-            \r
+\r
         }, new Listener<ArrayList<SysdynResult>> () {\r
 \r
             @Override\r
@@ -241,7 +258,7 @@ public class SysdynModel implements IMappingListener, IModel {
             public boolean isDisposed() {\r
                 return false;\r
             }\r
-            \r
+\r
         });\r
     }\r
 \r
index d0771f50cfee1bd3602845663c8374d0c7c356cc..1bfe6621eac24a1678fa9cc337dbe0c89047397d 100644 (file)
@@ -1,5 +1,5 @@
 /*******************************************************************************\r
- * Copyright (c) 2010 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 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
@@ -50,8 +50,8 @@ import org.simantics.modelica.data.SimulationResult;
  */\r
 public class SysdynResult {\r
 \r
-    RecordAccessor accessor;\r
-    String resultName;\r
+    protected RecordAccessor accessor;\r
+    protected String resultName;\r
 \r
     /**\r
      * Create an empty result\r
@@ -68,6 +68,17 @@ public class SysdynResult {
         if(result != null)\r
             setResult(result);\r
     }\r
+    \r
+    /**\r
+     * Create a sysdynresult accessor using a {@link SimulationResult}\r
+     * @param result\r
+     * @param resultName Name of the result (seen in visualization)\r
+     */\r
+    public SysdynResult(SimulationResult result, String resultName) {\r
+        this.resultName = resultName;\r
+        if(result != null)\r
+            setResult(result);\r
+    }\r
 \r
     /**\r
      * Open result from a file\r
index 945f9d785ce0675e34112db9c432adb9d1f7c4fa..4ae415bfb4b72ede74bbac16eb86473ec4feb8cd 100644 (file)
@@ -15,6 +15,7 @@ import java.util.ArrayList;
 import java.util.Iterator;\r
 \r
 import org.simantics.sysdyn.representation.expressions.IExpression;\r
+import org.simantics.sysdyn.representation.utils.FormatUtils;\r
 \r
 /**\r
  * Representation of an independent variable\r
@@ -42,7 +43,8 @@ public abstract class IndependentVariable extends Variable {
         // [= expression]\r
         if(variability == Variability.PARAMETER || variability == Variability.CONSTANT) {\r
             // parameters and constants are guaranteed to have only one expression\r
-            sb.append(" = " + getExpressions().getExpressions().get(0).getExpression(this));\r
+            String equation = FormatUtils.formatExpressionForModelica(this, getExpressions().getExpressions().get(0).getExpression(this));\r
+            sb.append(" = " + equation);\r
         }\r
 \r
         // ;\n\r