<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/Sysdyn-1.0/Module"\r class="org.simantics.sysdyn.ui.browser.nodes.ModuleNode">\r <this />\r </type>\r \r <resource\r uri="http://www.simantics.org/Sysdyn-1.0/Module"\r class="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode">\r <this />\r </resource>\r\r <resource\r uri="http://www.simantics.org/Sysdyn-1.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/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/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\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/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\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 <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.FlowEdgeFactory" />\r <type 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/Input"\r class="org.simantics.sysdyn.ui.browser.nodes.InputNode">\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 <resource\r uri="http://www.simantics.org/Sysdyn-1.0/Module"\r class="org.simantics.sysdyn.ui.browser.nodes.ModuleTypeNode">\r <this />\r </resource>\r\r <resource\r uri="http://www.simantics.org/Sysdyn-1.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/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/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\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 <resource uri="http://www.simantics.org/Sysdyn-1.0/InputSymbol"\r class="org.simantics.sysdyn.ui.elements2.InputFactory" />\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/ModuleSymbol"\r class="org.simantics.sysdyn.ui.elements2.ModuleFactory" />\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 <type uri="http://www.simantics.org/Sysdyn-1.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-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 <type uri="http://www.simantics.org/Sysdyn-1.0/FlowConnection"\r class="org.simantics.sysdyn.ui.elements2.FlowEdgeFactory" />\r <type 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
class="org.simantics.sysdyn.ui.browser.contributions.ModuleLabeler"\r
preference="2.0">\r
</implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.InputLabeler"\r
+ preference="2.0">\r
+ </implementation>\r
</binding>\r
</extension>\r
<extension\r
class="org.simantics.sysdyn.ui.browser.contributions.ModuleImager"\r
preference="2.0">\r
</implementation>\r
+ <implementation\r
+ class="org.simantics.sysdyn.ui.browser.contributions.InputImager"\r
+ preference="2.0">\r
+ </implementation>\r
</binding>\r
</extension>\r
<extension\r
e.printStackTrace();\r
}\r
}\r
+ for(Resource r : graph.syncRequest(new ObjectsWithType(configuration.resource, b.ConsistsOf, sr.Input))) {\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
--- /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.InputNode;\r
+\r
+public class InputImager extends ImagerContributor<InputNode> {\r
+\r
+ @Override\r
+ public ImageDescriptor getDescriptor(ReadGraph graph, InputNode node) throws DatabaseException {\r
+ return ImageDescriptor.createFromURL(Activator.getDefault().getBundle().getResource("icons/brick_link.png"));\r
+ }\r
+\r
+}\r
--- /dev/null
+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.InputNode;\r
+\r
+public class InputLabeler extends LabelerContributor<InputNode>{\r
+\r
+ @Override\r
+ public String getLabel(ReadGraph graph, InputNode var) throws DatabaseException {\r
+ Builtins b = graph.getBuiltins();\r
+ Resource varres = var.resource;\r
+ StringBuilder sb = new StringBuilder();\r
+ for(Resource r : graph.getObjects(varres, b.HasName))\r
+ sb.append(graph.getValue(r));\r
+ sb.append(" : ");\r
+ for(Resource t : graph.getObjects(varres, 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
+}\r
--- /dev/null
+package org.simantics.sysdyn.ui.browser.nodes;\r
+\r
+import org.simantics.db.Resource;\r
+\r
+public class InputNode extends AbstractNode {\r
+\r
+ public InputNode(Resource resource) {\r
+ super(resource);\r
+ }\r
+}\r
this.modelingRules = modelingRules;\r
this.processor = processor;\r
}\r
- \r
+\r
IConnectionPoint getConnectionPoint(ReadGraph g, IElement element, Terminal term) throws DatabaseException {\r
Object obj = null;\r
if (element != null)\r
Resource elementResource = (Resource) obj;\r
return ConnectionUtil.toConnectionPoint(g, elementResource, term);\r
}\r
- \r
+\r
if(element.getElementClass().containsClass(FlagHandler.class)) {\r
return new CPFlag(null);\r
}\r
- \r
+\r
return null;\r
}\r
\r
if(!g.hasStatement(connectionVariable, str2.Binds, sr.IsHeadOfTerminal)) {\r
return null;\r
}\r
+\r
+ // Only one incoming dependency allowed in inputs. That dependency must be from a module\r
+ Object obj1 = ElementUtils.getObject(element1);\r
+ Object obj2 = ElementUtils.getObject(element2);\r
+ if(obj2 instanceof Resource) {\r
+ Resource startElementResource = (Resource)obj1;\r
+ Resource endElementResource = (Resource)obj2;\r
+ if(g.isInstanceOf(endElementResource, sr.InputSymbol)) {\r
+ if(g.isInheritedFrom(startElementResource, sr.ModuleSymbol)) return null;\r
+ if(g.getObjects(endElementResource, sr.IsHeadOfTerminal).size() > 0) return null;\r
+ }\r
+ }\r
+\r
IConnection connection = modelingRules.createConnection()\r
- .attachNew(g, getConnectionPoint(g, element1, term1));\r
+ .attachNew(g, getConnectionPoint(g, element1, term1));\r
if(element2 != null)\r
connection = connection.attachNew(g, getConnectionPoint(g, element2, term2));\r
if(connection.isLegal())\r
--- /dev/null
+package org.simantics.sysdyn.ui.elements2;\r
+\r
+import java.awt.BasicStroke;\r
+import java.awt.Shape;\r
+import java.awt.geom.Path2D;\r
+import java.util.Collection;\r
+\r
+import org.simantics.db.Resource;\r
+import org.simantics.diagram.elements.TextElementHandler;\r
+import org.simantics.g2d.element.ElementClass;\r
+import org.simantics.g2d.element.handler.impl.BoundsOutline;\r
+import org.simantics.g2d.element.handler.impl.DefaultTransform;\r
+import org.simantics.g2d.element.handler.impl.ObjectTerminal;\r
+import org.simantics.g2d.element.handler.impl.OutlinePick;\r
+import org.simantics.g2d.element.handler.impl.SimpleElementLayers;\r
+import org.simantics.g2d.element.handler.impl.StaticObjectAdapter;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImageInitializer;\r
+import org.simantics.g2d.element.handler.impl.StaticSymbolImpl;\r
+import org.simantics.g2d.element.handler.impl.TextColorImpl;\r
+import org.simantics.g2d.element.handler.impl.TextFontImpl;\r
+import org.simantics.g2d.element.handler.impl.TextImpl;\r
+import org.simantics.g2d.image.Image;\r
+import org.simantics.g2d.image.impl.ShapeImage;\r
+\r
+public class InputFactory extends SysdynElementFactory {\r
+\r
+ private static final BasicStroke STROKE = new BasicStroke(1f);\r
+ private static final Image INPUT_IMAGE = new ShapeImage(getInputShape(), null, STROKE, true);\r
+\r
+ static Shape getInputShape() {\r
+ Path2D path = new Path2D.Double();\r
+ path.moveTo(0, -1);\r
+ path.lineTo(5, -1);\r
+ path.lineTo(5, -2.5);\r
+ path.lineTo(7.5, 0);\r
+ path.curveTo(7.5, -2.5, 12.5, -2.5, 12.5, 0);\r
+ path.curveTo(12.5, 2.5, 7.5, 2.5, 7.5, 0);\r
+ path.lineTo(5, 2.5);\r
+ path.lineTo(5, 1);\r
+ path.lineTo(0, 1);\r
+ path.closePath();\r
+ return path;\r
+ }\r
+ @Override\r
+ protected ElementClass compileElementClass(Resource elementType, Collection<ObjectTerminal> terminals) {\r
+ return ElementClass.compile(\r
+ SimpleElementLayers.INSTANCE,\r
+ OutlinePick.INSTANCE,\r
+ TextImpl.INSTANCE,\r
+ TextColorImpl.BLACK,\r
+ TextFontImpl.DEFAULT,\r
+ DefaultTransform.INSTANCE,\r
+ new StaticObjectAdapter(elementType),\r
+ new StaticSymbolImpl(INPUT_IMAGE),\r
+ StaticSymbolImageInitializer.INSTANCE,\r
+ TextElementHandler.INSTANCE,\r
+ BoundsOutline.INSTANCE,\r
+ new WholeElementTerminals(terminals)\r
+ ).setId(AuxiliaryFactory.class.getSimpleName());\r
+ }\r
+\r
+\r
+}\r
import org.simantics.sysdyn.manager.SysdynModelManager;\r
import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.IElement;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
import org.simantics.sysdyn.ui.equation.expressions.ExpressionField;\r
import org.simantics.sysdyn.ui.equation.expressions.StockExpressionViewFactor;\r
import org.simantics.ui.SimanticsUI;\r
Configuration conf = model.getConfiguration();\r
ArrayList<IElement> elements = conf.getElements();\r
for(IElement e : elements) {\r
- if(e instanceof Variable) {\r
- Variable v = (Variable) e;\r
+ if(e instanceof IndependentVariable) {\r
+ IndependentVariable v = (IndependentVariable) e;\r
modelVariables.add(v.getName());\r
}\r
}\r
import org.simantics.sysdyn.manager.SysdynModelManager;\r
import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.IElement;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.ui.workbench.ResourceEditorInput;\r
\r
IElement thisElement = model.getElement(variable);\r
ArrayList<IElement> elements = conf.getElements();\r
for(IElement e : elements) {\r
- if(e instanceof Variable) {\r
- Variable v = (Variable)e;\r
+ if(e instanceof IndependentVariable) {\r
+ IndependentVariable v = (IndependentVariable)e;\r
if(v != thisElement && v.getName().equals(this.nameText.getText())) {\r
this.nameText.setText(this.originalName);\r
this.nameText.setSelection(this.originalName.length());\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties;\r
+\r
+\r
+import org.eclipse.jface.dialogs.IInputValidator;\r
+import org.eclipse.jface.layout.GridDataFactory;\r
+import org.eclipse.jface.layout.GridLayoutFactory;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Label;\r
+import org.eclipse.ui.IWorkbenchSite;\r
+import org.simantics.browsing.ui.swt.PropertyTabContributorImpl;\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.WidgetSupport;\r
+import org.simantics.db.Builtins;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.sysdyn.ui.properties.widgets.IsOutputWidget;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyFactory;\r
+import org.simantics.sysdyn.ui.properties.widgets.factories.DoublePropertyModifier;\r
+\r
+public class InputVariableTab extends PropertyTabContributorImpl {\r
+\r
+ TrackedCombo expressionTypeCombo;\r
+ IsOutputWidget isOutput;\r
+ \r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ Composite composite = new Composite(body, SWT.NONE);\r
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(composite);\r
+ GridLayoutFactory.fillDefaults().margins(3, 3).numColumns(2).applyTo(composite);\r
+\r
+ TrackedText nameText = new TrackedText(composite, support, SWT.BORDER);\r
+ nameText.setTextFactory(new StringPropertyFactory(Builtins.URIs.HasName));\r
+ nameText.addModifyListener(new StringPropertyModifier(context, Builtins.URIs.HasName));\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(nameText.getWidget());\r
+\r
+ isOutput = new IsOutputWidget(composite, support, SWT.NULL);\r
+\r
+ Label label = new Label(composite, SWT.NULL);\r
+ label.setText("Default Value");\r
+ \r
+ TrackedText rangeStep = new TrackedText(composite, support, SWT.RIGHT | SWT.BORDER);\r
+ rangeStep.setTextFactory(new DoublePropertyFactory(SysdynResource.URIs.HasRangeStep));\r
+ rangeStep.addModifyListener(new DoublePropertyModifier(context, SysdynResource.URIs.HasDefaultInputValue));\r
+ rangeStep.setInputValidator(new DoubleValidator());\r
+ GridDataFactory.fillDefaults().grab(true, false).applyTo(rangeStep.getWidget());\r
+\r
+\r
+ }\r
+\r
+ private class DoubleValidator implements IInputValidator {\r
+\r
+ @Override\r
+ public String isValid(String newText) {\r
+ for(int i = 0; i < newText.length(); i++){\r
+ if(!Character.isDigit(newText.charAt(i))){\r
+ if(newText.charAt(i) != '.') {\r
+ return "Invalid character '" + newText.charAt(i) + "'";\r
+ } else if(newText.indexOf('.') != newText.lastIndexOf('.')) {\r
+ return "There can be only one '.'";\r
+ }\r
+ }\r
+ }\r
+ return null;\r
+ }\r
+ }\r
+}\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 ReferenceDependencyTab extends PropertyTabContributorImpl {\r
+\r
+ @Override\r
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
+ }\r
+\r
+}\r
Collection<ComparableTabContributor> tabs = new ArrayList<ComparableTabContributor>();\r
if (backend.isInstanceOf(r, dr.Element)) {\r
Resource component = backend.getPossibleObject(r, mr.ElementToComponent);\r
- if (component != null)\r
+ if (component != null) {\r
r = component;\r
+ } else {\r
+ Resource connection = backend.getPossibleObject(r, mr.DiagramConnectionToConnection);\r
+ if(connection != null)\r
+ r = connection;\r
+ }\r
}\r
if (backend.isInstanceOf(r, sr.IndependentVariable)) {\r
- tabs.add(new ComparableTabContributor(\r
- new EquationTab(),\r
- 2,\r
- r,\r
- "Equation"));\r
Resource expression = backend.getPossibleObject(r, sr.HasExpression);\r
+ tabs.add(new ComparableTabContributor(\r
+ new EquationTab(),\r
+ 2,\r
+ r,\r
+ "Equation"));\r
if(expression != null && backend.isInstanceOf(expression, sr.WithLookupExpression)) {\r
tabs.add(new ComparableTabContributor(\r
new LookupTableTab(),\r
"Additional Information"));\r
return tabs;\r
}\r
+ if (backend.isInstanceOf(r, sr.Input)) {\r
+ return Collections.singleton(new ComparableTabContributor(\r
+ new InputVariableTab(),\r
+ 2,\r
+ r,\r
+ "Input"));\r
+ }\r
if (backend.isInstanceOf(r, sr.Configuration))\r
return Collections.singleton(\r
new ComparableTabContributor(\r
0,\r
r,\r
"Result Properties"));\r
+ if (backend.isInstanceOf(r, sr.Dependency))\r
+ if (backend.hasStatement(r, sr.RefersTo))\r
+ return Collections.singleton(\r
+ new ComparableTabContributor(\r
+ new ReferenceDependencyTab(),\r
+ 0,\r
+ r,\r
+ "Reference Properties"));\r
} catch (ServiceException e) {\r
e.printStackTrace();\r
} catch (ManyObjectsForFunctionalRelationException e) {\r
\r
public class ExpressionTypes {\r
\r
- public static enum ExpressionType {Auxiliary, Parameter, Constant, Lookup, WithLookup, Stock, Delay, Empty, Input};\r
+ public static enum ExpressionType {Auxiliary, Parameter, Constant, Lookup, WithLookup, Stock, Delay, Empty};\r
\r
public static ExpressionType[] auxiliaryExpressions = new ExpressionType[] {\r
ExpressionType.Parameter, \r
et = ExpressionType.Lookup;\r
} else if (graph.isInstanceOf(expression, sr.WithLookupExpression)) {\r
et = ExpressionType.WithLookup;\r
- } else if (graph.isInstanceOf(expression, sr.InputExpression)) {\r
- et = ExpressionType.Input; \r
} else {\r
et = ExpressionType.Empty;\r
}\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.EmptyExpression;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.ExpressionValidation;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.IExpression;\r
-import org.simantics.sysdyn.ui.properties.widgets.expressions.InputExpression;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.LookupExpression;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.ParameterExpression;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.StockExpression;\r
exp = new StockExpression(); break;\r
case Delay: \r
exp = new DelayExpression(); break;\r
- case Input:\r
- exp = new InputExpression(); break;\r
default: \r
exp = new EmptyExpression();\r
}\r
--- /dev/null
+package org.simantics.sysdyn.ui.properties.widgets;\r
+\r
+import org.eclipse.jface.viewers.ISelection;\r
+import org.eclipse.jface.viewers.IStructuredSelection;\r
+import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.widgets.Button;\r
+import org.eclipse.swt.widgets.Composite;\r
+import org.simantics.browsing.ui.swt.widgets.impl.SelectionListenerImpl;\r
+import org.simantics.browsing.ui.swt.widgets.impl.Widget;\r
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\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.ReadRequest;\r
+import org.simantics.db.exception.DatabaseException;\r
+import org.simantics.db.management.ISessionContext;\r
+import org.simantics.sysdyn.SysdynResource;\r
+import org.simantics.utils.ui.ISelectionUtils;\r
+\r
+public class IsOutputWidget implements Widget{\r
+ \r
+ Resource variable = null; \r
+ org.simantics.browsing.ui.swt.widgets.Button isOutputButton;\r
+ \r
+ public IsOutputWidget(Composite parent, WidgetSupport support, int style) {\r
+ support.register(this);\r
+ isOutputButton = new org.simantics.browsing.ui.swt.widgets.Button(parent, support, style |= SWT.CHECK);\r
+ isOutputButton.setText("Is Output");\r
+ }\r
+\r
+ @Override\r
+ public void setInput(ISessionContext context, Object input) {\r
+ if(input instanceof ISelection) {\r
+ ISelection selection = (ISelection)input;\r
+ if(selection instanceof IStructuredSelection) {\r
+ Resource resource = ISelectionUtils.filterSingleSelection(selection, Resource.class);\r
+ if(resource != null) {\r
+ variable = resource;\r
+ }\r
+ }\r
+ }\r
+ \r
+ if(variable == null) return;\r
+ \r
+ try {\r
+ context.getSession().syncRequest(new ReadRequest() {\r
+ \r
+ @Override\r
+ public void run(ReadGraph graph) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ final boolean isOutput = graph.hasStatement(variable, sr.IsOutput);\r
+ final Button button = getWidget();\r
+ button.getDisplay().asyncExec(new Runnable() {\r
+ \r
+ @Override\r
+ public void run() {\r
+ if(button.isDisposed()) return;\r
+ \r
+ if(isOutput)\r
+ button.setSelection(true);\r
+ else\r
+ button.setSelection(false);\r
+ }\r
+ });\r
+\r
+ \r
+ }\r
+ });\r
+ } catch (DatabaseException e) {\r
+ e.printStackTrace();\r
+ }\r
+ \r
+ isOutputButton.addSelectionListener(new SelectionListenerImpl<Resource>(context) {\r
+\r
+ @Override\r
+ public void apply(WriteGraph graph, Resource input) throws DatabaseException {\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ if(graph.hasStatement(input, sr.IsOutput)) {\r
+ graph.deny(input, sr.IsOutput);\r
+ } else {\r
+ graph.claim(input, SysdynResource.getInstance(graph).IsOutput, null, input);\r
+ }\r
+ }\r
+ });\r
+ }\r
+ \r
+ public Button getWidget() {\r
+ return isOutputButton.getWidget();\r
+ }\r
+\r
+}\r
import org.simantics.sysdyn.manager.SysdynModelManager;\r
import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.IElement;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
import org.simantics.sysdyn.ui.properties.widgets.expressions.IExpression;\r
import org.simantics.ui.SimanticsUI;\r
\r
Configuration conf = model.getConfiguration();\r
ArrayList<IElement> elements = conf.getElements();\r
for(IElement e : elements) {\r
- if(e instanceof Variable) {\r
- Variable v = (Variable) e;\r
+ if(e instanceof IndependentVariable) {\r
+ IndependentVariable v = (IndependentVariable) e;\r
modelVariables.add(v.getName());\r
}\r
}\r
+++ /dev/null
-package org.simantics.sysdyn.ui.properties.widgets.expressions;\r
-\r
-import java.util.Collections;\r
-import java.util.List;\r
-import java.util.Map;\r
-\r
-import org.eclipse.jface.layout.GridLayoutFactory;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.events.FocusListener;\r
-import org.eclipse.swt.events.KeyListener;\r
-import org.eclipse.swt.events.ModifyListener;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.simantics.db.Resource;\r
-\r
-public class InputExpression implements IExpression {\r
-\r
- @Override\r
- public void createExpressionFields(Composite parent, Map<String, Object> data) {\r
- GridLayoutFactory.fillDefaults().applyTo(parent);\r
- Label label = new Label(parent, SWT.NONE);\r
- label.setText("Input");\r
- }\r
-\r
- @Override\r
- public void readData(Resource variable, Map<String, Object> data) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- @Override\r
- public void save(Resource variable, Map<String, Object> data) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- @Override\r
- public void focus() {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- @Override\r
- public void replaceSelection(String var) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- @Override\r
- public void updateData(Map<String, Object> data) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- @SuppressWarnings("unchecked")\r
- @Override\r
- public List<ExpressionField> getExpressionFields() {\r
- // TODO Auto-generated method stub\r
- return Collections.EMPTY_LIST;\r
- }\r
-\r
- @Override\r
- public void addModifyListener(ModifyListener listener) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- @Override\r
- public void addKeyListener(KeyListener listener) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
- @Override\r
- public void addFocusListener(FocusListener listener) {\r
- // TODO Auto-generated method stub\r
- \r
- }\r
-\r
-}\r
\r
import java.awt.Frame;\r
import java.util.ArrayList;\r
-import java.util.HashMap;\r
import java.util.Set;\r
\r
import javax.swing.SwingUtilities;\r
import org.simantics.modeling.ModelingUtils;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.manager.SysdynDataSet;\r
-import org.simantics.sysdyn.manager.SysdynModel;\r
-import org.simantics.sysdyn.manager.SysdynModelManager;\r
import org.simantics.ui.SimanticsUI;\r
import org.simantics.utils.ui.ISelectionUtils;\r
import org.simantics.utils.ui.jface.ActiveSelectionProvider;\r
System.out.println("load dataset for '" + item.getURI(g) + "'");\r
\r
Accessor accessor = item.getInterface(g, Accessor.class);\r
+ if(accessor == null) return null;\r
try {\r
return (SysdynDataSet)accessor.getValue(Bindings.getBindingUnchecked(SysdynDataSet.class));\r
} catch (RuntimeBindingConstructionException e) {\r
public final Resource Flow;\r
public final Resource FlowConnection;\r
public final Resource GameExperiment;\r
+ public final Resource HasDefaultInputValue;\r
public final Resource HasEquation;\r
public final Resource HasExpression;\r
public final Resource HasHead;\r
public final Resource HasY;\r
public final Resource HistoryRealization;\r
public final Resource IndependentVariable;\r
- public final Resource InputExpression;\r
+ public final Resource Input;\r
+ public final Resource InputSymbol;\r
public final Resource IsHeadOf;\r
public final Resource IsHeadOfTerminal;\r
public final Resource IsInput;\r
public static final String Flow = "http://www.simantics.org/Sysdyn-1.0/Flow";\r
public static final String FlowConnection = "http://www.simantics.org/Sysdyn-1.0/FlowConnection";\r
public static final String GameExperiment = "http://www.simantics.org/Sysdyn-1.0/GameExperiment";\r
+ public static final String HasDefaultInputValue = "http://www.simantics.org/Sysdyn-1.0/HasDefaultInputValue";\r
public static final String HasEquation = "http://www.simantics.org/Sysdyn-1.0/HasEquation";\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 HasY = "http://www.simantics.org/Sysdyn-1.0/HasY";\r
public static final String HistoryRealization = "http://www.simantics.org/Sysdyn-1.0/HistoryRealization";\r
public static final String IndependentVariable = "http://www.simantics.org/Sysdyn-1.0/IndependentVariable";\r
- public static final String InputExpression = "http://www.simantics.org/Sysdyn-1.0/InputExpression";\r
+ public static final String Input = "http://www.simantics.org/Sysdyn-1.0/Input";\r
+ public static final String InputSymbol = "http://www.simantics.org/Sysdyn-1.0/InputSymbol";\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 IsInput = "http://www.simantics.org/Sysdyn-1.0/IsInput";\r
Flow = getResourceOrNull(graph, URIs.Flow);\r
FlowConnection = getResourceOrNull(graph, URIs.FlowConnection);\r
GameExperiment = getResourceOrNull(graph, URIs.GameExperiment);\r
+ HasDefaultInputValue = getResourceOrNull(graph, URIs.HasDefaultInputValue);\r
HasEquation = getResourceOrNull(graph, URIs.HasEquation);\r
HasExpression = getResourceOrNull(graph, URIs.HasExpression);\r
HasHead = getResourceOrNull(graph, URIs.HasHead);\r
HasY = getResourceOrNull(graph, URIs.HasY);\r
HistoryRealization = getResourceOrNull(graph, URIs.HistoryRealization);\r
IndependentVariable = getResourceOrNull(graph, URIs.IndependentVariable);\r
- InputExpression = getResourceOrNull(graph, URIs.InputExpression);\r
+ Input = getResourceOrNull(graph, URIs.Input);\r
+ InputSymbol = getResourceOrNull(graph, URIs.InputSymbol);\r
IsHeadOf = getResourceOrNull(graph, URIs.IsHeadOf);\r
IsHeadOfTerminal = getResourceOrNull(graph, URIs.IsHeadOfTerminal);\r
IsInput = getResourceOrNull(graph, URIs.IsInput);\r
package org.simantics.sysdyn.modelica;\r
\r
import java.util.ArrayList;\r
+import java.util.HashMap;\r
\r
import org.simantics.sysdyn.representation.Configuration;\r
import org.simantics.sysdyn.representation.Dependency;\r
import org.simantics.sysdyn.representation.IElement;\r
+import org.simantics.sysdyn.representation.Input;\r
import org.simantics.sysdyn.representation.Module;\r
import org.simantics.sysdyn.representation.ModuleType;\r
import org.simantics.sysdyn.representation.Stock;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
import org.simantics.sysdyn.representation.Variable;\r
import org.simantics.sysdyn.representation.expressions.IExpression;\r
import org.simantics.sysdyn.representation.expressions.WithLookupExpression;\r
\r
configuration.update();\r
\r
- ArrayList<Variable> variables = new ArrayList<Variable>();\r
+ ArrayList<IndependentVariable> variables = new ArrayList<IndependentVariable>();\r
+ ArrayList<Input> inputs = new ArrayList<Input>();\r
ArrayList<Module> modules = new ArrayList<Module>();\r
ArrayList<Stock> stocks = new ArrayList<Stock>();\r
ArrayList<Dependency> inputDependencies = new ArrayList<Dependency>();\r
ArrayList<Dependency> outputDependencies = new ArrayList<Dependency>();\r
-\r
+ HashMap<Module, ArrayList<Input>> moduleInputs = new HashMap<Module, ArrayList<Input>>();\r
+ \r
// Initialize lists\r
for(IElement element : configuration.getElements()) {\r
- if(element instanceof Variable) {\r
- variables.add((Variable)element);\r
+ if(element instanceof IndependentVariable) {\r
+ variables.add((IndependentVariable)element);\r
if(element instanceof Stock)\r
stocks.add((Stock)element);\r
} else if (element instanceof Module) {\r
- modules.add((Module)element);\r
+ Module m = (Module)element; \r
+ modules.add(m);\r
+ ArrayList<Input> inputsInModule = new ArrayList<Input>();\r
+ for(IElement e : m.getType().getConfiguration().getElements())\r
+ if(e instanceof Input && ((Input)e).isInput())\r
+ inputsInModule.add((Input)e);\r
+ moduleInputs.put(m, inputsInModule);\r
+ } else if (element instanceof Input) {\r
+ inputs.add((Input)element);\r
} else if (element instanceof Dependency && ((Dependency)element).refersTo() != null) {\r
Dependency dependency = (Dependency)element;\r
if(dependency.getHead() instanceof Module) {\r
b.append("class ").append(className).append('\n');\r
\r
b.append("// Variable definitions\n");\r
- for(Variable variable : variables) {\r
- IExpression expr = (variable).getExpression();\r
+ for(IndependentVariable variable : variables) {\r
+ IExpression expr = variable.getExpression();\r
if(expr != null && insertInterpolate == false) {\r
app = expr.getDeclaration(variable);\r
if (app != null) b.append(app);\r
b.append(" " + m.getType().getName() + " " + m.getLabel() + ";\n");\r
}\r
}\r
-\r
+ \r
+ if(!inputs.isEmpty()) {\r
+ b.append("// Input definitions\n");\r
+ for(Input i : inputs) {\r
+ b.append(" " + i.getType() + " " + i.getName() + ";\n");\r
+ }\r
+ }\r
+ \r
for(Stock stock : stocks) {\r
IExpression expr = stock.getExpression();\r
if(expr != null) {\r
b.append("equation\n");\r
\r
b.append("// Equations\n");\r
- for(Variable variable : variables) {\r
+ for(IndependentVariable variable : variables) {\r
IExpression expr = variable.getExpression();\r
if(expr != null) {\r
app = expr.getEquation(variable);\r
\r
b.append("// Inputs\n");\r
for(Dependency dependency : inputDependencies) {\r
- Variable variable = (Variable)dependency.getHead();\r
+ Input variable = (Input)dependency.getHead();\r
Module module = (Module)dependency.getTail();\r
Variable reference = (Variable)dependency.refersTo();\r
b.append(" " + variable.getName() + " = " + module.getLabel() + "." + reference.getName() + ";\n");\r
for(Dependency dependency : outputDependencies) {\r
Variable variable = (Variable)dependency.getTail();\r
Module module = (Module)dependency.getHead();\r
- Variable reference = (Variable)dependency.refersTo();\r
+ Input reference = (Input)dependency.refersTo();\r
b.append(" " + module.getLabel() + "." + reference.getName() + " = " + variable.getName() + ";\n");\r
+ moduleInputs.get(module).remove(reference);\r
}\r
-\r
+ \r
+ b.append("// Default values for inputs in modules\n");\r
+ for(Module module : moduleInputs.keySet()) {\r
+ for(Input input : moduleInputs.get(module)) {\r
+ b.append(" " + module.getLabel() + "." + input.getName() + " = " + input.getDefaultInputValue() + ";\n");\r
+ }\r
+ }\r
+ \r
b.append("end ").append(className).append(";\n\n");\r
\r
\r
import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
\r
@GraphType("http://www.simantics.org/Sysdyn-1.0/Auxiliary")\r
-public class Auxiliary extends Variable {\r
+public class Auxiliary extends IndependentVariable {\r
@Override\r
public void accept(IElementVisitorVoid v) {\r
v.visit(this);\r
IElementVisitorVoid updateVisitor = new ElementVisitorVoidAdapter() {\r
public void visit(Flow flow) {\r
if(flow.getHead() instanceof Stock) {\r
- ((Stock)flow.getHead()).incomingFlows.add((Variable)flow.getTail());\r
+ ((Stock)flow.getHead()).incomingFlows.add((IndependentVariable)flow.getTail());\r
}\r
else if(flow.getTail() instanceof Stock) {\r
- ((Stock)flow.getTail()).outgoingFlows.add((Variable)flow.getHead());\r
+ ((Stock)flow.getTail()).outgoingFlows.add((IndependentVariable)flow.getHead());\r
}\r
}\r
};\r
* Contributors:\r
* VTT Technical Research Centre of Finland - initial API and implementation\r
*******************************************************************************/\r
-package org.simantics.sysdyn.representation.expressions;\r
+package org.simantics.sysdyn.representation;\r
\r
-import org.simantics.objmap.annotations.GraphType;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.sysdyn.representation.expressions.IExpression;\r
\r
-@GraphType("http://www.simantics.org/Sysdyn-1.0/InputExpression")\r
-public class InputExpression extends Expression {\r
+public abstract class IndependentVariable extends Variable {\r
\r
- @Override\r
- public String getDeclaration(Variable variable) {\r
- return " " + variable.getType() + " " + variable.getName() + ";\n";\r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasExpression")\r
+ protected IExpression expression;\r
+ \r
+ public IExpression getExpression() {\r
+ return this.expression;\r
}\r
-\r
}\r
--- /dev/null
+package org.simantics.sysdyn.representation;\r
+\r
+import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
+import org.simantics.objmap.annotations.RelatedValue;\r
+import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
+\r
+@GraphType("http://www.simantics.org/Sysdyn-1.0/Input")\r
+public class Input extends Variable {\r
+\r
+ @RelatedValue("http://www.simantics.org/Sysdyn-1.0/HasDefaultInputValue")\r
+ private Double defaultInputValue;\r
+ @RelatedElement("http://www.simantics.org/Sysdyn-1.0/IsInput")\r
+ private IElement isInput;\r
+ \r
+ @Override\r
+ public void accept(IElementVisitorVoid v) {\r
+ v.visit(this);\r
+ }\r
+\r
+ public String getDefaultInputValue() {\r
+ return defaultInputValue.toString();\r
+ }\r
+ \r
+ public boolean isInput() {\r
+ return isInput != null;\r
+ }\r
+\r
+}\r
@RelatedElement("http://www.simantics.org/Layer0-1.0/InstanceOf")\r
private ModuleType type;\r
\r
- @RelatedElement("http://www.simantics.org/Structural-1.0/IsDefinedBy")\r
- private Configuration configuration;\r
-\r
IElementVisitorVoid clearVisitor = new ElementVisitorVoidAdapter() {\r
public void visit(Stock stock) {\r
stock.incomingFlows.clear();\r
IElementVisitorVoid updateVisitor = new ElementVisitorVoidAdapter() {\r
public void visit(Flow flow) {\r
if(flow.getHead() instanceof Stock) {\r
- ((Stock)flow.getHead()).incomingFlows.add((Variable)flow.getTail());\r
+ ((Stock)flow.getHead()).incomingFlows.add((IndependentVariable)flow.getTail());\r
}\r
else if(flow.getTail() instanceof Stock) {\r
- ((Stock)flow.getTail()).outgoingFlows.add((Variable)flow.getHead());\r
+ ((Stock)flow.getTail()).outgoingFlows.add((IndependentVariable)flow.getHead());\r
}\r
}\r
};\r
return this.parentConfiguration;\r
}\r
\r
- public Configuration getConfiguration() {\r
- return this.configuration;\r
- }\r
}\r
package org.simantics.sysdyn.representation;\r
\r
import org.simantics.objmap.annotations.GraphType;\r
+import org.simantics.objmap.annotations.RelatedElement;\r
import org.simantics.objmap.annotations.RelatedValue;\r
import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
\r
\r
@RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
private String name;\r
+ \r
+ @RelatedElement("http://www.simantics.org/Structural-1.0/IsDefinedBy")\r
+ private Configuration configuration;\r
\r
public String getName() {\r
return name;\r
}\r
+\r
+ public Configuration getConfiguration() {\r
+ return this.configuration;\r
+ }\r
\r
@Override\r
public void accept(IElementVisitorVoid v) {\r
import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
\r
@GraphType("http://www.simantics.org/Sysdyn-1.0/Stock")\r
-public class Stock extends Variable {\r
- public ArrayList<Variable> incomingFlows = new ArrayList<Variable>(2);\r
- public ArrayList<Variable> outgoingFlows = new ArrayList<Variable>(2);\r
+public class Stock extends IndependentVariable {\r
+ public ArrayList<IndependentVariable> incomingFlows = new ArrayList<IndependentVariable>(2);\r
+ public ArrayList<IndependentVariable> outgoingFlows = new ArrayList<IndependentVariable>(2);\r
\r
public Stock() {\r
name = "Valve" + hashCode(); // FIXME\r
import org.simantics.objmap.schema.MappingSchemas;\r
import org.simantics.objmap.schema.SimpleSchema;\r
import org.simantics.sysdyn.representation.expressions.ConstantExpression;\r
-import org.simantics.sysdyn.representation.expressions.InputExpression;\r
import org.simantics.sysdyn.representation.expressions.LookupExpression;\r
import org.simantics.sysdyn.representation.expressions.NormalExpression;\r
import org.simantics.sysdyn.representation.expressions.ParameterExpression;\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, Input.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, ModuleType.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, NormalExpression.class));\r
- addLinkType(MappingSchemas.fromAnnotations(g, InputExpression.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, ParameterExpression.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, StockExpression.class));\r
addLinkType(MappingSchemas.fromAnnotations(g, ConstantExpression.class));\r
import org.simantics.sysdyn.representation.visitors.IElementVisitorVoid;\r
\r
@GraphType("http://www.simantics.org/Sysdyn-1.0/Valve")\r
-public class Valve extends Variable {\r
+public class Valve extends IndependentVariable {\r
@Override\r
public void accept(IElementVisitorVoid v) {\r
v.visit(this);\r
-/*******************************************************************************\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.representation;\r
\r
import org.simantics.objmap.annotations.RelatedElement;\r
import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.expressions.IExpression;\r
\r
public abstract class Variable implements IElement {\r
- @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
- protected String name;\r
+ \r
@RelatedValue("http://www.simantics.org/Layer0-1.0/HasType")\r
protected String type;\r
- @RelatedElement("http://www.simantics.org/Sysdyn-1.0/HasExpression")\r
- protected IExpression expression;\r
+ @RelatedValue("http://www.simantics.org/Layer0-1.0/HasName")\r
+ protected String name;\r
@RelatedElement("http://www.simantics.org/Layer0-1.0/PartOf")\r
protected Configuration configuration;\r
\r
- \r
-\r
public String getName() {\r
return this.name;\r
}\r
-\r
- public String getType() {\r
- return this.type;\r
- }\r
- \r
- public IExpression getExpression() {\r
- return this.expression;\r
- }\r
\r
public Configuration getParentConfiguration() {\r
return this.configuration;\r
}\r
+\r
+ public String getType() {\r
+ return this.type;\r
+ }\r
}\r
\r
import org.simantics.objmap.annotations.GraphType;\r
import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
\r
@GraphType("http://www.simantics.org/Sysdyn-1.0/ConstantExpression")\r
public class ConstantExpression extends Expression {\r
private String equation;\r
\r
@Override\r
- public String getDeclaration(Variable variable) {\r
+ public String getDeclaration(IndependentVariable variable) {\r
StringBuilder b = new StringBuilder();\r
b.append(" constant " + variable.getType() + " " + variable.getName());\r
b.append(" = " + equation + ";\n");\r
*******************************************************************************/\r
package org.simantics.sysdyn.representation.expressions;\r
\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
\r
public abstract class Expression implements IExpression {\r
\r
@Override\r
- public String getDeclaration(Variable variable) {\r
+ public String getDeclaration(IndependentVariable variable) {\r
return null;\r
}\r
\r
@Override\r
- public String getEquation(Variable variable) {\r
+ public String getEquation(IndependentVariable variable) {\r
return null;\r
}\r
\r
@Override\r
- public String getInitialEquation(Variable variable) {\r
+ public String getInitialEquation(IndependentVariable variable) {\r
return null;\r
}\r
\r
*******************************************************************************/\r
package org.simantics.sysdyn.representation.expressions;\r
\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
\r
public interface IExpression {\r
\r
- String getDeclaration(Variable variable);\r
- String getInitialEquation(Variable variable);\r
- String getEquation(Variable variable);\r
+ String getDeclaration(IndependentVariable variable);\r
+ String getInitialEquation(IndependentVariable variable);\r
+ String getEquation(IndependentVariable variable);\r
\r
}\r
\r
import org.simantics.objmap.annotations.GraphType;\r
import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
\r
@GraphType("http://www.simantics.org/Sysdyn-1.0/NormalExpression")\r
public class NormalExpression extends Expression {\r
private String equation;\r
\r
@Override\r
- public String getDeclaration(Variable variable) {\r
+ public String getDeclaration(IndependentVariable variable) {\r
return " " + variable.getType() + " " + variable.getName() + ";\n";\r
}\r
\r
@Override\r
- public String getEquation(Variable variable) {\r
+ public String getEquation(IndependentVariable variable) {\r
return " " + variable.getName() + " = " + equation + ";\n";\r
}\r
\r
\r
import org.simantics.objmap.annotations.GraphType;\r
import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
\r
@GraphType("http://www.simantics.org/Sysdyn-1.0/ParameterExpression")\r
public class ParameterExpression extends Expression {\r
private String equation;\r
\r
@Override\r
- public String getDeclaration(Variable variable) {\r
+ public String getDeclaration(IndependentVariable variable) {\r
StringBuilder b = new StringBuilder();\r
b.append(" parameter " + variable.getType() + " " + variable.getName());\r
b.append(" = " + equation + ";\n");\r
import org.simantics.objmap.annotations.GraphType;\r
import org.simantics.objmap.annotations.RelatedValue;\r
import org.simantics.sysdyn.representation.Stock;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
\r
@GraphType("http://www.simantics.org/Sysdyn-1.0/StockExpression")\r
public class StockExpression extends Expression {\r
private String initialEquation;\r
\r
@Override\r
- public String getDeclaration(Variable variable) {\r
+ public String getDeclaration(IndependentVariable variable) {\r
Double value = null;\r
try {\r
value = Double.parseDouble(initialEquation);\r
}\r
\r
@Override\r
- public String getEquation(Variable variable) {\r
+ public String getEquation(IndependentVariable variable) {\r
StringBuilder b = new StringBuilder();\r
b.append(" der(")\r
.append(variable.getName())\r
.append(") =");\r
- for(Variable flow : ((Stock)variable).incomingFlows)\r
+ for(IndependentVariable flow : ((Stock)variable).incomingFlows)\r
b.append("\n + ").append(flow.getName());\r
- for(Variable flow : ((Stock)variable).outgoingFlows)\r
+ for(IndependentVariable flow : ((Stock)variable).outgoingFlows)\r
b.append("\n - ").append(flow.getName());\r
b.append(";\n");\r
return b.toString();\r
}\r
\r
@Override\r
- public String getInitialEquation(Variable variable) {\r
+ public String getInitialEquation(IndependentVariable variable) {\r
Double value = null;\r
try {\r
value = Double.parseDouble(initialEquation);\r
\r
import org.simantics.objmap.annotations.GraphType;\r
import org.simantics.objmap.annotations.RelatedValue;\r
-import org.simantics.sysdyn.representation.Variable;\r
+import org.simantics.sysdyn.representation.IndependentVariable;\r
\r
\r
@GraphType("http://www.simantics.org/Sysdyn-1.0/WithLookupExpression")\r
private String equation;\r
\r
@Override\r
- public String getDeclaration(Variable variable) {\r
+ public String getDeclaration(IndependentVariable variable) {\r
return " " + variable.getType() + " " + variable.getName() + ";\n";\r
}\r
\r
@Override\r
- public String getEquation(Variable variable) {\r
+ public String getEquation(IndependentVariable variable) {\r
return \r
" " + variable.getName() + " = Interpolate(table = " + lookupTable + ", xp = " + equation + ");\n";\r
}\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.Input;\r
import org.simantics.sysdyn.representation.Module;\r
import org.simantics.sysdyn.representation.Stock;\r
import org.simantics.sysdyn.representation.Valve;\r
public void visit(Cloud cloud) {\r
}\r
\r
+ @Override\r
+ public void visit(Input input) {\r
+ }\r
+\r
@Override\r
public void visit(Dependency dependency) {\r
}\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.Input;\r
import org.simantics.sysdyn.representation.Module;\r
import org.simantics.sysdyn.representation.Stock;\r
import org.simantics.sysdyn.representation.Valve;\r
void visit(Stock stock);\r
void visit(Valve valve);\r
void visit(Cloud cloud);\r
+ void visit(Input input);\r
void visit(Dependency dependency);\r
void visit(Flow flow); \r
void visit(Module module);\r
######################################################################\r
\r
Variable <T ST.Component \r
+ [L0.HasType card "1"]\r
[HasX card "1"]\r
[HasY card "1"]\r
\r
L0.HasRange L0.Double \r
\r
IndependentVariable <T Variable\r
- [L0.HasType card "1"]\r
[HasUnit card "0..1"]\r
[HasExpression card "0..1"] \r
[HasRangeStart card "0..1"]\r
\r
Cloud <T Variable\r
\r
+Input <T Variable\r
+ [HasDefaultInputValue card "0..1"]\r
+ [L0.HasDescription card "0..1"]\r
+ [HasUnit card "0..1"] \r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate HasDefaultInputValue\r
+ L0.HasObject "0" : L0.Double\r
+ L0.Asserts _ : L0.Assertion\r
+ L0.HasPredicate L0.HasType\r
+ L0.HasObject "Real" : L0.String\r
+\r
######################################################################\r
# Modules\r
######################################################################\r
[HasTail card "1"]\r
\r
RefersTo <R L0.IsRelatedTo : L0.FunctionalRelation\r
- L0.HasDomain [IndependentVariable]\r
- L0.HasRange [IndependentVariable]\r
+ L0.HasDomain [Variable]\r
+ L0.HasRange [Variable]\r
\r
\r
######################################################################\r
\r
ParameterExpression <T Expression\r
[HasEquation card "1"] \r
-\r
-InputExpression <T Expression\r
- [HasEquation card "1"] \r
-\r
+ \r
ConstantExpression <T Expression\r
[HasEquation card "1"] \r
\r
[HasMinY card "1"]\r
[HasMaxY card "1"]\r
\r
+HasDefaultInputValue <R L0.HasProperty\r
+ L0.HasRange L0.Double\r
\r
######################################################################\r
# Experiments\r
terminal(CloudSymbol, IsHeadOfTerminal)\r
_ : SysdynTerminal\r
terminal(CloudSymbol, IsTailOfTerminal)\r
+ \r
+######################################################################\r
+Input\r
+ def()\r
+ connection(IsTailOf)\r
+ connection(IsHeadOf)\r
+\r
+InputSymbol <T DIA.FontProvider <T DIA.ColorProvider\r
+ defSymbol("Input", Input)\r
+ L0.IsDependencyOf BasicSymbolLibrary\r
+ ST.IsDefinedBy %list : DIA.Composite <R L0.HasNext\r
+ _ : SysdynTerminal\r
+ terminal(InputSymbol, IsHeadOfTerminal)\r
+ _ : SysdynTerminal\r
+ terminal(InputSymbol, IsTailOfTerminal) \r
\r
######################################################################\r
# Diagram connection types\r
SalesElement : AuxiliarySymbol\r
MOD.ElementToComponent Sales\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 92.0, 102.0" : G2D.Transform\r
- WidgetsPerPersonInputElement : AuxiliarySymbol\r
+ WidgetsPerPersonInputElement : InputSymbol\r
MOD.ElementToComponent WidgetsPerPersonInput\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 61.0, 90.0" : G2D.Transform\r
- NewCustomersInputElement : AuxiliarySymbol\r
+ NewCustomersInputElement : InputSymbol\r
MOD.ElementToComponent NewCustomersInput\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 91.0, 113.0" : G2D.Transform\r
- WordOfMouthDemandInputElement : AuxiliarySymbol\r
+ WordOfMouthDemandInputElement : InputSymbol\r
MOD.ElementToComponent WordOfMouthDemandInput\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 49.0, 98.0" : G2D.Transform\r
- CapacityInputElement : AuxiliarySymbol\r
+ CapacityInputElement : InputSymbol\r
MOD.ElementToComponent CapacityInput\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 136.0, 90.0" : G2D.Transform\r
_ : FlowConnection\r
DummyCloud : Cloud\r
tag(MOD.Mapped)\r
### Input variables\r
- WidgetsPerPersonInput @ "WidgettejaHenkilolle" : Auxiliary\r
+ WidgetsPerPersonInput @ "WidgettejaHenkilolle" : Input\r
tag(MOD.Mapped)\r
- HasExpression _ : InputExpression\r
- NewCustomersInput @ "UusiaAsiakkaita" : Auxiliary\r
+ NewCustomersInput @ "UusiaAsiakkaita" : Input\r
tag(MOD.Mapped)\r
- HasExpression _ : InputExpression\r
- WordOfMouthDemandInput @ "PuskaradioKysynta" : Auxiliary\r
+ WordOfMouthDemandInput @ "PuskaradioKysynta" : Input\r
tag(MOD.Mapped)\r
- HasExpression _ : InputExpression\r
- CapacityInput @ "KapasiteettiInput" : Auxiliary\r
+ CapacityInput @ "KapasiteettiInput" : Input\r
tag(MOD.Mapped)\r
- HasExpression _ : InputExpression\r
\r
%define conf_dep($v1, $v2)\r
$subject\r
HasEquation "Kapasiteetti/Kapasiteettielama" : L0.String \r
\r
### Input variables\r
- WordOfMouthDemandInput2 @ "PuskaradioKysynta" : Auxiliary\r
- HasExpression _ : InputExpression\r
- #tag(IsInput)\r
+ WordOfMouthDemandInput2 @ "PuskaradioKysynta" : Input\r
+ tag(IsInput)\r
\r
### Dependencies \r
Flow3 : Flow\r
WidgetsPerPersonOutputElement : AuxiliarySymbol\r
MOD.ElementToComponent WidgetsPerPersonOutput\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 130.0, 150.0" : G2D.Transform \r
- WordOfMouthDemandInput2Element : AuxiliarySymbol\r
+ WordOfMouthDemandInput2Element : InputSymbol\r
MOD.ElementToComponent WordOfMouthDemandInput2\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 150.0" : G2D.Transform\r
_ : DependencyConnection\r
HasEquation " min({Puskaradiokysynta, Kapasiteetti/WidgettejaHenkilolle})" : L0.String \r
tag(IsOutput)\r
### Input variables\r
- CapacityInput2 @ "Kapasiteetti" : Auxiliary\r
- HasExpression _ : InputExpression\r
+ CapacityInput2 @ "Kapasiteetti" : Input\r
tag(IsInput)\r
- WidgetsPerPersonInput2 @ "WidgettejaHenkilolle" : Auxiliary\r
- HasExpression _ : InputExpression\r
+ WidgetsPerPersonInput2 @ "WidgettejaHenkilolle" : Input\r
tag(IsInput)\r
\r
### Dependencies \r
NewCustomersElement : ValveSymbol\r
MOD.ElementToComponent NewCustomers\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 100.0, 90.0" : G2D.Transform\r
- CapacityInput2Element : AuxiliarySymbol\r
+ CapacityInput2Element : InputSymbol\r
MOD.ElementToComponent CapacityInput2\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 90.0, 105.0" : G2D.Transform\r
- WidgetsPerPersonInput2Element : AuxiliarySymbol\r
+ WidgetsPerPersonInput2Element : InputSymbol\r
MOD.ElementToComponent WidgetsPerPersonInput2\r
DIA.HasTransform "1.0, 0.0, 0.0, 1.0, 130.0, 110.0" : G2D.Transform\r
\r