<graph />\r
<this />\r
</type>\r
- </target>\r \r <target\r interface="org.simantics.sysdyn.ui.browser.nodes.AbstractNode">\r <type\r uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Sysdyn-1.0/IndependentVariable"\r class="org.simantics.sysdyn.ui.browser.nodes.VariableNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Simulation-1.0/Types/Experiment"\r class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Sysdyn-1.0/Result"\r class="org.simantics.sysdyn.ui.browser.nodes.SimulationResultNode">\r <this />\r </type>\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-1.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-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r\r <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r </target>\r \r <!-- Sysdyn connections -->\r <target interface="org.simantics.diagram.adapter.ElementFactory">\r <!-- Edges -->\r <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.FlowEdgeFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.DependencyEdgeFactory" />\r <!-- : SYSDYN.Connection-->\r <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.FlowConnectionFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.DependencyConnectionFactory" />\r </target>\r \r <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>none 0</string>\r </resource>\r <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>fill 1</string>\r </resource>\r </target>\r \r
+ </target>\r \r <target\r interface="org.simantics.sysdyn.ui.browser.nodes.AbstractNode">\r <type\r uri="http://www.simantics.org/Sysdyn-1.0/SysdynModel"\r class="org.simantics.sysdyn.ui.browser.nodes.ModelNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Sysdyn-1.0/IndependentVariable"\r class="org.simantics.sysdyn.ui.browser.nodes.VariableNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Sysdyn-1.0/Module"\r class="org.simantics.sysdyn.ui.browser.nodes.ModuleNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Simulation-1.0/Types/Experiment"\r class="org.simantics.sysdyn.ui.browser.nodes.ExperimentNode">\r <this />\r </type>\r \r <type\r uri="http://www.simantics.org/Sysdyn-1.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-1.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-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r\r <type uri="http://www.simantics.org/Sysdyn-1.0/StockSymbol"\r class="org.simantics.sysdyn.ui.elements2.StockFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/ValveSymbol"\r class="org.simantics.sysdyn.ui.elements2.ValveFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/AuxiliarySymbol"\r class="org.simantics.sysdyn.ui.elements2.AuxiliaryFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/CloudSymbol"\r class="org.simantics.sysdyn.ui.elements2.CloudFactory" />\r </target>\r \r <!-- Sysdyn connections -->\r <target interface="org.simantics.diagram.adapter.ElementFactory">\r <!-- Edges -->\r <resource uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.FlowEdgeFactory" />\r <resource uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.DependencyEdgeFactory" />\r <!-- : SYSDYN.Connection-->\r <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.FlowConnectionFactory" />\r <type uri="http://www.simantics.org/Sysdyn-1.0/DependencyConnection"\r class="org.simantics.sysdyn.ui.elements2.DependencyConnectionFactory" />\r </target>\r \r <target interface="org.simantics.g2d.connection.EdgeVisualsConfigurer">\r <baseType uri="http://www.simantics.org/Diagram-2.0/HasConnector" />\r <resource uri="http://www.simantics.org/Diagram-2.0/HasPlainConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>none 0</string>\r </resource>\r <resource uri="http://www.simantics.org/Diagram-2.0/HasArrowConnector"\r class="org.simantics.diagram.content.ArrowConfigurer">\r <string>fill 1</string>\r </resource>\r </target>\r \r
</adapters>
\ No newline at end of file
<binding\r
browseContext="http://www.simantics.org/Sysdyn-1.0/Browser">\r
<implementation\r
- class="org.simantics.sysdyn.ui.browser.contributions.Variable"\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Configuration"\r
preference="1.0">\r
</implementation>\r
<implementation\r
class="org.simantics.sysdyn.ui.browser.contributions.SimulationResult"\r
preference="2.0">\r
</implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.Module"\r
+ preference="1.0">\r
+ </implementation>\r
</binding>\r
</extension>\r
<extension\r
class="org.simantics.sysdyn.ui.browser.contributions.SimulationResultLabeler"\r
preference="2.0">\r
</implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ModuleLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
</binding>\r
</extension>\r
<extension\r
class="org.simantics.sysdyn.ui.browser.contributions.SimulationResultImager"\r
preference="2.0">\r
</implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.ModuleImager"\r
+ preference="2.0">\r
+ </implementation>\r
</binding>\r
</extension>\r
<extension\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
+\r
+public class Configuration extends ViewpointContributor<ConfigurationNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ConfigurationNode configuration) throws DatabaseException {\r
+ ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+ Builtins b = graph.getBuiltins();\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.IndependentVariable))) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.Module))) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+\r
+public class Module extends ViewpointContributor<ModuleNode> {\r
+\r
+ @Override\r
+ public Collection<?> getContribution(ReadGraph graph, ModuleNode module) throws DatabaseException {\r
+ ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
+ Builtins b = graph.getBuiltins();\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(module.resource, b.ConsistsOf, sr.IndependentVariable))) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(module.resource, b.ConsistsOf, sr.Module))) {\r
+ try {\r
+ result.add(graph.adapt(r, AbstractNode.class));\r
+ } catch(DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ }\r
+ return result;\r
+ }\r
+\r
+ @Override\r
+ public String getViewpointId() {\r
+ return "Standard";\r
+ }\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.eclipse.jface.resource.ImageDescriptor;\r
+import org.simantics.browsing.ui.swt.ImagerContributor;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.Activator;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+\r
+public class ModuleImager extends ImagerContributor<ModuleNode> {\r
+\r
+ @Override\r
+ public ImageDescriptor getDescriptor(ReadGraph graph, ModuleNode node) throws DatabaseException {\r
+ return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/bricks.png"));\r
+ }\r
+}\r
--- /dev/null
+/*******************************************************************************\r
+ * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
+ * in Industry THTH ry.\r
+ * All rights reserved. This program and the accompanying materials\r
+ * are made available under the terms of the Eclipse Public License v1.0\r
+ * which accompanies this distribution, and is available at\r
+ * http://www.eclipse.org/legal/epl-v10.html\r
+ *\r
+ * Contributors:\r
+ * VTT Technical Research Centre of Finland - initial API and implementation\r
+ *******************************************************************************/\r
+package org.simantics.sysdyn.ui.browser.contributions;\r
+\r
+import org.simantics.browsing.ui.graph.contributor.labeler.LabelerContributor;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.ReadGraph;\r
+import org.simantics.db.Resource;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.sysdyn.ui.browser.nodes.ModuleNode;\r
+\r
+public class ModuleLabeler extends LabelerContributor<ModuleNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, ModuleNode module) throws DatabaseException {\r
+ Builtins b = graph.getBuiltins();\r
+ Resource resource = module.resource;\r
+ StringBuilder sb = new StringBuilder();\r
+ for(Resource r : graph.getObjects(resource, b.HasName))\r
+ sb.append(graph.getValue(r));\r
+ sb.append(" : ");\r
+ for(Resource t : graph.getObjects(resource, b.InstanceOf))\r
+ for(Resource r : graph.getObjects(t, b.HasName))\r
+ sb.append(graph.getValue(r));\r
+ return sb.toString();\r
+ }\r
+\r
+}\r
+++ /dev/null
-/*******************************************************************************\r
- * Copyright (c) 2007, 2010 Association for Decentralized Information Management\r
- * in Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.sysdyn.ui.browser.contributions;\r
-\r
-import java.util.ArrayList;\r
-import java.util.Collection;\r
-\r
-import org.simantics.browsing.ui.graph.contributor.viewpoint.ViewpointContributor;\r
-import org.simantics.db.Builtins;\r
-import org.simantics.db.ReadGraph;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.common.request.ObjectsWithType;\r
-import org.simantics.db.exception.DatabaseException;\r
-import org.simantics.sysdyn.SysdynResource;\r
-import org.simantics.sysdyn.ui.browser.nodes.AbstractNode;\r
-import org.simantics.sysdyn.ui.browser.nodes.ConfigurationNode;\r
-\r
-public class Variable extends ViewpointContributor<ConfigurationNode> {\r
-\r
- @Override\r
- public Collection<?> getContribution(ReadGraph graph, ConfigurationNode configuration) throws DatabaseException {\r
- ArrayList<AbstractNode> result = new ArrayList<AbstractNode>();\r
- Builtins b = graph.getBuiltins();\r
- SysdynResource sr = SysdynResource.getInstance(graph);\r
- for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.IndependentVariable))) {\r
- try {\r
- result.add(graph.adapt(r, AbstractNode.class));\r
- } catch(DatabaseException e) {\r
- e.printStackTrace();\r
- }\r
- }\r
- return result;\r
- }\r
-\r
- @Override\r
- public String getViewpointId() {\r
- return "Standard";\r
- }\r
-\r
-}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.browsing.ui.common.node.IDeletable;\r
+import org.simantics.db.Resource;\r
+\r
+public class ModuleNode extends AbstractNode implements IDeletable {\r
+\r
+ public ModuleNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+}\r
SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession());\r
SysdynModel model = sdm.getModel(configuration);\r
Configuration conf = model.getConfiguration();\r
- ArrayList<IElement> elements = conf.elements;\r
+ ArrayList<IElement> elements = conf.getElements();\r
for(IElement e : elements) {\r
if(e instanceof Variable) {\r
Variable v = (Variable) e;\r
SysdynModel model = sdm.getModel(rei.getResource());\r
Configuration conf = model.getConfiguration();\r
IElement thisElement = model.getElement(variable);\r
- ArrayList<IElement> elements = conf.elements;\r
+ ArrayList<IElement> elements = conf.getElements();\r
for(IElement e : elements) {\r
if(e instanceof Variable) {\r
Variable v = (Variable)e;\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties;\r
+\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
+import org.simantics.db.management.ISessionContext;\r
+\r
+public class ModuleTab extends PropertyTabContributorImpl {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ \r
+ }\r
+}\r
0,\r
r,\r
"Configuration Properties"));\r
+ if (backend.isInstanceOf(r, sr.Module))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ModuleTab(),\r
+ 0,\r
+ r,\r
+ "Module Properties"));\r
if (backend.isInstanceOf(r, sr.Experiment))\r
return Collections.singleton(\r
new ComparableTabContributor(\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.management.ISessionContext;\r
import org.simantics.db.request.Read;\r
+import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.properties.widgets.ExpressionTypes.ExpressionType;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.AuxiliaryExpression;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.ConstantExpression;\r
\r
@Override\r
public Resource perform(ReadGraph graph) throws DatabaseException {\r
- Resource configuration = graph.getSingleObject(variable, graph.getBuiltins().PartOf);\r
- return configuration;\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ Resource configuration = variable;\r
+ \r
+ do {\r
+ configuration = graph.getSingleObject(configuration, graph.getBuiltins().PartOf);\r
+ if(graph.isInstanceOf(configuration, sr.Configuration))\r
+ return configuration;\r
+ } while (configuration != null);\r
+ \r
+ return null;\r
}\r
});\r
ExpressionValidation.validateExpressionFields(expression, connectedVariables, configuration);\r
SysdynModelManager sdm = SysdynModelManager.getInstance(SimanticsUI.getSession());\r
SysdynModel model = sdm.getModel(configuration);\r
Configuration conf = model.getConfiguration();\r
- ArrayList<IElement> elements = conf.elements;\r
+ ArrayList<IElement> elements = conf.getElements();\r
for(IElement e : elements) {\r
if(e instanceof Variable) {\r
Variable v = (Variable) e;\r
public final Resource HasExpression;\r
public final Resource HasHead;\r
public final Resource HasInitialEquation;\r
+ public final Resource HasInput;\r
public final Resource HasLookup;\r
public final Resource HasMaxX;\r
public final Resource HasMaxY;\r
public final Resource HasMinX;\r
public final Resource HasMinY;\r
+ public final Resource HasOutput;\r
public final Resource HasParameterFile;\r
public final Resource HasRangeEnd;\r
public final Resource HasRangeStart;\r
public final Resource HasStopTime;\r
public final Resource HasTail;\r
public final Resource HasTerminal;\r
- public final Resource HasType;\r
public final Resource HasUnit;\r
public final Resource HasX;\r
public final Resource HasY;\r
public final Resource IndependentVariable;\r
+ public final Resource Input;\r
public final Resource IsHeadOf;\r
public final Resource IsHeadOfTerminal;\r
public final Resource IsTailOf;\r
public static final String HasExpression = "http://www.simantics.org/Sysdyn-1.0/HasExpression";\r
public static final String HasHead = "http://www.simantics.org/Sysdyn-1.0/HasHead";\r
public static final String HasInitialEquation = "http://www.simantics.org/Sysdyn-1.0/HasInitialEquation";\r
+ public static final String HasInput = "http://www.simantics.org/Sysdyn-1.0/HasInput";\r
public static final String HasLookup = "http://www.simantics.org/Sysdyn-1.0/HasLookup";\r
public static final String HasMaxX = "http://www.simantics.org/Sysdyn-1.0/HasMaxX";\r
public static final String HasMaxY = "http://www.simantics.org/Sysdyn-1.0/HasMaxY";\r
public static final String HasMinX = "http://www.simantics.org/Sysdyn-1.0/HasMinX";\r
public static final String HasMinY = "http://www.simantics.org/Sysdyn-1.0/HasMinY";\r
+ public static final String HasOutput = "http://www.simantics.org/Sysdyn-1.0/HasOutput";\r
public static final String HasParameterFile = "http://www.simantics.org/Sysdyn-1.0/HasParameterFile";\r
public static final String HasRangeEnd = "http://www.simantics.org/Sysdyn-1.0/HasRangeEnd";\r
public static final String HasRangeStart = "http://www.simantics.org/Sysdyn-1.0/HasRangeStart";\r
public static final String HasStopTime = "http://www.simantics.org/Sysdyn-1.0/HasStopTime";\r
public static final String HasTail = "http://www.simantics.org/Sysdyn-1.0/HasTail";\r
public static final String HasTerminal = "http://www.simantics.org/Sysdyn-1.0/HasTerminal";\r
- public static final String HasType = "http://www.simantics.org/Sysdyn-1.0/HasType";\r
public static final String HasUnit = "http://www.simantics.org/Sysdyn-1.0/HasUnit";\r
public static final String HasX = "http://www.simantics.org/Sysdyn-1.0/HasX";\r
public static final String HasY = "http://www.simantics.org/Sysdyn-1.0/HasY";\r
public static final String IndependentVariable = "http://www.simantics.org/Sysdyn-1.0/IndependentVariable";\r
+ public static final String Input = "http://www.simantics.org/Sysdyn-1.0/Input";\r
public static final String IsHeadOf = "http://www.simantics.org/Sysdyn-1.0/IsHeadOf";\r
public static final String IsHeadOfTerminal = "http://www.simantics.org/Sysdyn-1.0/IsHeadOfTerminal";\r
public static final String IsTailOf = "http://www.simantics.org/Sysdyn-1.0/IsTailOf";\r
HasExpression = getResourceOrNull(graph, URIs.HasExpression);\r
HasHead = getResourceOrNull(graph, URIs.HasHead);\r
HasInitialEquation = getResourceOrNull(graph, URIs.HasInitialEquation);\r
+ HasInput = getResourceOrNull(graph, URIs.HasInput);\r
HasLookup = getResourceOrNull(graph, URIs.HasLookup);\r
HasMaxX = getResourceOrNull(graph, URIs.HasMaxX);\r
HasMaxY = getResourceOrNull(graph, URIs.HasMaxY);\r
HasMinX = getResourceOrNull(graph, URIs.HasMinX);\r
HasMinY = getResourceOrNull(graph, URIs.HasMinY);\r
+ HasOutput = getResourceOrNull(graph, URIs.HasOutput);\r
HasParameterFile = getResourceOrNull(graph, URIs.HasParameterFile);\r
HasRangeEnd = getResourceOrNull(graph, URIs.HasRangeEnd);\r
HasRangeStart = getResourceOrNull(graph, URIs.HasRangeStart);\r
HasStopTime = getResourceOrNull(graph, URIs.HasStopTime);\r
HasTail = getResourceOrNull(graph, URIs.HasTail);\r
HasTerminal = getResourceOrNull(graph, URIs.HasTerminal);\r
- HasType = getResourceOrNull(graph, URIs.HasType);\r
HasUnit = getResourceOrNull(graph, URIs.HasUnit);\r
HasX = getResourceOrNull(graph, URIs.HasX);\r
HasY = getResourceOrNull(graph, URIs.HasY);\r
IndependentVariable = getResourceOrNull(graph, URIs.IndependentVariable);\r
+ Input = getResourceOrNull(graph, URIs.Input);\r
IsHeadOf = getResourceOrNull(graph, URIs.IsHeadOf);\r
IsHeadOfTerminal = getResourceOrNull(graph, URIs.IsHeadOfTerminal);\r
IsTailOf = getResourceOrNull(graph, URIs.IsTailOf);\r
SysdynSchema schema = new SysdynSchema(g);\r
mapping = Mappings.createWithListening(schema);\r
mapping.addMappingListener(SysdynModel.this);\r
- configuration = (Configuration)mapping.map(g, configurationResource); \r
+ configuration = (Configuration)mapping.map(g, configurationResource); \r
}\r
\r
public SysdynModel(ReadGraph g, Resource configurationResource) {\r
writer.write(configuration);\r
\r
result = ModelicaManager.runModelica(\r
- configuration.name,\r
+ configuration.getName(),\r
writer.toString(), \r
monitor,\r
configuration.startTime,\r
*******************************************************************************/\r
package org.simantics.sysdyn.modelica;\r
\r
+import java.util.ArrayList;\r
+\r
import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.IModule;\r
+import org.simantics.sysdyn.representation.Module;\r
import org.simantics.sysdyn.representation.Stock;\r
import org.simantics.sysdyn.representation.Variable;\r
import org.simantics.sysdyn.representation.expressions.IExpression;\r
boolean insertInterpolate = false;\r
\r
public void write(Configuration conf) {\r
- conf.update();\r
- b.append("model ").append(conf.name.replace(" ", "")).append('\n');\r
- for(IElement element : conf.elements)\r
- if(element instanceof Variable) {\r
- IExpression expr = ((Variable)element).expression;\r
- if(expr != null) {\r
- app = expr.getDeclaration((Variable)element);\r
- if (app != null) b.append(app);\r
- if (expr instanceof WithLookupExpression) insertInterpolate = true;\r
- }\r
- }\r
-\r
- for(IElement element : conf.elements)\r
- if(element instanceof Stock) {\r
- IExpression expr = ((Stock)element).expression;\r
- if(expr != null) {\r
- app = expr.getInitialEquation((Stock)element);\r
- if (app != null) {\r
- if(initialEquations == false) {\r
- initialEquations = true;\r
- b.append("initial equation\n");\r
- }\r
- b.append(app);\r
- }\r
- }\r
- }\r
- b.append("equation\n");\r
- for(IElement element : conf.elements)\r
- if(element instanceof Variable) {\r
- IExpression expr = ((Variable)element).expression;\r
- if(expr != null) {\r
- app = expr.getEquation((Variable)element);\r
- if (app != null) b.append(app);\r
- }\r
- }\r
- b.append("end ").append(conf.name.replace(" ", "")).append(";\n");\r
\r
+ writeModule(conf);\r
+ \r
if(insertInterpolate)\r
b.append(\r
"\nfunction Interpolate\n" +\r
" end if;\n" +\r
" end for;\n" +\r
" end Interpolate;\n");\r
+ }\r
+ \r
+ private void writeModule(IModule module) {\r
\r
+ module.update();\r
+ \r
+ ArrayList<IElement> variables = new ArrayList<IElement>();\r
+ ArrayList<Module> modules = new ArrayList<Module>();\r
+ ArrayList<IElement> stocks = new ArrayList<IElement>();\r
+\r
+ // Initialize lists\r
+ for(IElement element : module.getElements()) {\r
+ if(element instanceof Variable) {\r
+ variables.add(element);\r
+ if(element instanceof Stock)\r
+ stocks.add(element);\r
+ } else if (element instanceof Module) {\r
+ modules.add((Module)element);\r
+ }\r
+ }\r
\r
- }\r
\r
+ b.append("class ").append(module.getName().replace(" ", "")).append('\n');\r
+ for(IElement element : variables) {\r
+ IExpression expr = ((Variable)element).expression;\r
+ if(expr != null && insertInterpolate == false) {\r
+ app = expr.getDeclaration((Variable)element);\r
+ if (app != null) b.append(app);\r
+ if (expr instanceof WithLookupExpression) insertInterpolate = true;\r
+ }\r
+ }\r
+\r
+ for(IElement element : stocks) {\r
+ IExpression expr = ((Stock)element).expression;\r
+ if(expr != null) {\r
+ app = expr.getInitialEquation((Stock)element);\r
+ if (app != null) {\r
+ if(initialEquations == false) {\r
+ initialEquations = true;\r
+ b.append("initial equation\n");\r
+ }\r
+ b.append(app);\r
+ }\r
+ }\r
+ }\r
+ \r
+ b.append("equation\n");\r
+ for(IElement element : variables) {\r
+ IExpression expr = ((Variable)element).expression;\r
+ if(expr != null) {\r
+ app = expr.getEquation((Variable)element);\r
+ if (app != null) b.append(app);\r
+ }\r
+ }\r
+ b.append("end ").append(module.getName().replace(" ", "")).append(";\n\n");\r
+ \r
+ \r
+ for(Module m : modules) {\r
+ writeModule(m);\r
+ }\r
+ }\r
+ \r
public String escape(String name) {\r
return name.replace(' ', '_');\r
}\r
\r
\r
@GraphType("http://www.simantics.org/Sysdyn-1.0/Configuration")\r
-public class Configuration {\r
- @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
- public String name = "Unnamed";\r
+public class Configuration implements IModule {\r
\r
@RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasStartTime")\r
public Double startTime = 0.0;\r
@RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasStopTime")\r
public Double stopTime = 10.0;\r
\r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+ private String name;\r
+\r
@RelatedElements(\r
- value = "http://www.simantics.org/Layer0-1.0/ConsistsOf",\r
- composition = true)\r
- public ArrayList<IElement> elements = new ArrayList<IElement>();\r
- \r
+ value = "http://www.simantics.org/Layer0-1.0/ConsistsOf",\r
+ composition = true)\r
+ private ArrayList<IElement> elements = new ArrayList<IElement>();\r
+\r
IElementVisitorVoid clearVisitor = new ElementVisitorVoidAdapter() {\r
public void visit(Stock stock) {\r
stock.incomingFlows.clear();\r
stock.outgoingFlows.clear();\r
}\r
};\r
- \r
+\r
IElementVisitorVoid updateVisitor = new ElementVisitorVoidAdapter() {\r
public void visit(Flow flow) {\r
if(flow.head instanceof Stock) {\r
for(IElement element : elements)\r
element.accept(updateVisitor);\r
}\r
+\r
+ @Override\r
+ public ArrayList<IElement> getElements() {\r
+ return elements;\r
+ }\r
+\r
+ @Override\r
+ public String getName() {\r
+ return name;\r
+ }\r
+ \r
+ \r
}\r
--- /dev/null
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+public interface IModule {\r
+ \r
+ public ArrayList<IElement> getElements(); \r
+ public String getName(); \r
+ public void update();\r
+\r
+}\r
--- /dev/null
+package org.simantics.sysdyn.representation;\r
+\r
+import java.util.ArrayList;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElements;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.visitors.ElementVisitorVoidAdapter;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Module")\r
+public class Module implements IElement, IModule {\r
+\r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+ private String name;\r
+\r
+ @RelatedElements(\r
+ value = "http://www.simantics.org/Layer0-1.0/ConsistsOf",\r
+ composition = true)\r
+ private ArrayList<IElement> elements = new ArrayList<IElement>();\r
+\r
+ IElementVisitorVoid clearVisitor = new ElementVisitorVoidAdapter() {\r
+ public void visit(Stock stock) {\r
+ stock.incomingFlows.clear();\r
+ stock.outgoingFlows.clear();\r
+ }\r
+ };\r
+\r
+ IElementVisitorVoid updateVisitor = new ElementVisitorVoidAdapter() {\r
+ public void visit(Flow flow) {\r
+ if(flow.head instanceof Stock) {\r
+ ((Stock)flow.head).incomingFlows.add((Variable)flow.tail);\r
+ }\r
+ else if(flow.tail instanceof Stock) {\r
+ ((Stock)flow.tail).outgoingFlows.add((Variable)flow.head);\r
+ }\r
+ }\r
+ };\r
+ \r
+ public void update() {\r
+ for(IElement element : elements)\r
+ element.accept(clearVisitor);\r
+ for(IElement element : elements)\r
+ element.accept(updateVisitor);\r
+ }\r
+ \r
+\r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this);\r
+ }\r
+\r
+ @Override\r
+ public ArrayList<IElement> getElements() {\r
+ return elements;\r
+ }\r
+\r
+ @Override\r
+ public String getName() {\r
+ return name;\r
+ }\r
+}\r
addLinkType(MappingSchemas.fromAnnotations(g, Flow.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, Stock.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, Valve.class));\r
+ addLinkType(MappingSchemas.fromAnnotations(g, Module.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, NormalExpression.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, ParameterExpression.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, StockExpression.class));\r
protected String name;\r
@RelatedValue("http://www.simantics.org/Layer0-1.0/HasType")\r
protected String type;\r
- //@RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasValue")\r
- //public String value;\r
@RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasExpression")\r
public IExpression expression;\r
\r
\r
import org.simantics.sysdyn.representation.Auxiliary;\r
import org.simantics.sysdyn.representation.Cloud;\r
+import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.Dependency;\r
import org.simantics.sysdyn.representation.Flow;\r
+import org.simantics.sysdyn.representation.Module;\r
import org.simantics.sysdyn.representation.Stock;\r
import org.simantics.sysdyn.representation.Valve;\r
\r
@Override\r
public void visit(Flow flow) {\r
}\r
+ \r
+ @Override\r
+ public void visit(Module module) {\r
+ }\r
\r
+ @Override\r
+ public void visit(Configuration configuration) {\r
+ }\r
}\r
\r
import org.simantics.sysdyn.representation.Auxiliary;\r
import org.simantics.sysdyn.representation.Cloud;\r
+import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.Dependency;\r
import org.simantics.sysdyn.representation.Flow;\r
+import org.simantics.sysdyn.representation.Module;\r
import org.simantics.sysdyn.representation.Stock;\r
import org.simantics.sysdyn.representation.Valve;\r
\r
void visit(Cloud cloud);\r
void visit(Dependency dependency);\r
void visit(Flow flow); \r
- \r
+ void visit(Module module);\r
+ void visit(Configuration configuration);\r
}\r
ModelicaMonitor monitor;\r
\r
public SimulationJob(SysdynModel model) {\r
- super("Simulate " + model.getConfiguration().name);\r
+ super("Simulate " + model.getConfiguration().getName());\r
this.model = model;\r
this.monitor = new ModelicaMonitor();\r
}\r
PROJ.RequiresFeature MOD.ModelingProject\r
PROJ.RequiresFeature PROJ.ExperimentControl\r
\r
+\r
+SysdynModuleTestProject : PROJ.Project2\r
+ PROJ.HasFeature SysdynProject\r
+ L0.PartOf L0.Projects\r
+\r
######################################################################\r
# Model\r
###################################################################### \r
L0.ConsistsOf\r
BasicSymbolLibrary @ "Basic Symbols" : DIA.SymbolReferenceLibrary\r
\r
-Configuration <T ST.Composite\r
- [L0.ConsistsOf all (Variable or Dependency)]\r
+Configuration <T Module\r
+ [L0.ConsistsOf all (Variable or Dependency or Module)]\r
[HasStartTime card "1"]\r
[HasStopTime card "1"]\r
\r
HasExpression <R L0.IsRelatedTo : L0.FunctionalRelation\r
L0.HasRange Expression\r
\r
-HasType <R L0.HasProperty : L0.FunctionalRelation\r
- L0.HasRange L0.String\r
+#HasType <R L0.HasProperty : L0.FunctionalRelation\r
+# L0.HasRange L0.String\r
\r
HasUnit <R L0.HasProperty\r
L0.HasRange L0.String\r
L0.HasRange L0.Double \r
\r
IndependentVariable <T Variable\r
- [HasType card "1"]\r
+ [L0.HasType card "1"]\r
[HasUnit card "0..1"]\r
[HasExpression card "0..1"] \r
[HasRangeStart card "0..1"]\r
L0.HasObject "Real" : L0.String\r
\r
Cloud <T Variable\r
-\r
-Module <T Variable\r
- [HasTerminal]\r
\r
-Terminal <T Variable\r
+Input <T Variable\r
[RefersTo card "0..1"]\r
+ \r
+Terminal <T Input\r
+\r
+######################################################################\r
+# Modules\r
+######################################################################\r
\r
\r
+Module <T ST.Composite\r
+ [L0.ConsistsOf all (Variable or Dependency or Module)]\r
+ [HasInput]\r
+ [HasOutput]\r
+ \r
+HasInput <R L0.HasProperty\r
+ L0.HasRange IndependentVariable \r
+\r
+HasOutput <R L0.HasProperty\r
+ L0.HasRange IndependentVariable \r
+ \r
######################################################################\r
# Connections and Relations\r
######################################################################\r
[HasTail card "1"]\r
\r
RefersTo <R L0.IsRelatedTo\r
- L0.HasDomain [Terminal]\r
+ L0.HasDomain [IndependentVariable]\r
L0.HasRange [IndependentVariable]\r
\r
HasTerminal <R L0.IsRelatedTo\r
MOD.DiagramConnectionTypeToConnectionType\r
Dependency\r
\r
+ \r
+ \r
+ \r
+######################################################################\r
+# Example model with modules\r
+######################################################################\r
+\r
+ModuleModel @ "ModuleModel" : SysdynModel\r
+ L0.HasLabel "Malli" : L0.String\r
+ L0.PartOf SysdynModuleTestProject\r
+ SIMU.HasConfiguration ModuleConfiguration\r
+ \r
+ \r
+ModuleConfiguration @ "ModuleConfiguration" : Configuration\r
+ HasStartTime "0.0" : L0.Double\r
+ HasStopTime "10.0" : L0.Double\r
+ L0.ConsistsOf\r
+ Module1\r
+ RootAux1 @ "Aux1" : Auxiliary\r
+ L0.HasType "Real" : L0.String\r
+ HasUnit "m" : L0.String\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "1+1" : L0.String\r
+ RootAux2 @ "Aux2" : Auxiliary\r
+ L0.HasType "Real" : L0.String\r
+ HasUnit "s" : L0.String\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "Aux1" : L0.String\r
+ RootInput1 @ "rootInput" : Auxiliary\r
+ L0.HasType "Real" : L0.String\r
+ HasUnit "s" : L0.String\r
+ HasExpression _ : NormalExpression\r
+ HasEquation "1000" : L0.String\r
+ RefersTo FirstModuleOutput1\r
+ _ : Dependency\r
+ HasHead RootAux2\r
+ HasTail RootAux1\r
+ HasOutput RootAux2\r
+ \r
+Module1 @ "FirstModule" : Module\r
+ L0.ConsistsOf \r
+ FirstModuleInput1 @ "Aux1" : Auxiliary\r
+ L0.HasType "Real" : L0.String\r
+ HasUnit "s" : L0.String\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "2+2" : L0.String\r
+ RefersTo RootAux2\r
+ FirstModuleInput2 @ "Aux2" : Auxiliary\r
+ L0.HasType "Real" : L0.String\r
+ HasUnit "s" : L0.String\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "2+2" : L0.String\r
+ FirstModuleStock @ "Stock1" : Stock\r
+ HasExpression _ : StockExpression\r
+ HasInitialEquation "0" : L0.String\r
+ FirstModuleCloud : Cloud\r
+ FirstModuleOutput1 @ "Valve" : Valve\r
+ HasUnit "s" : L0.String\r
+ HasExpression _ : ParameterExpression\r
+ HasEquation "Aux1 + Aux2" : L0.String \r
+ _ : Flow\r
+ HasHead FirstModuleOutput1\r
+ HasTail FirstModuleCloud\r
+ _ : Flow\r
+ HasHead FirstModuleStock\r
+ HasTail FirstModuleOutput1\r
+ _ : Dependency\r
+ HasHead FirstModuleOutput1\r
+ HasTail FirstModuleInput1\r
+ _ : Dependency\r
+ HasHead FirstModuleOutput1\r
+ HasTail FirstModuleInput2\r
+ HasInput FirstModuleInput1\r
+ HasInput FirstModuleInput2\r
+ HasOutput FirstModuleOutput1\r
+ \r
+ \r