PROJ.RequiresNamespace
"http://www.simantics.org/Sysdyn-1.1" : L0.URI
"http://www.simantics.org/Layer0-1.0" : L0.URI
-// "http://www.simantics.org/Documentation-1.0" : L0.URI // Experimental documentation tool
+ "http://www.simantics.org/Documentation-1.0" : L0.URI // Experimental documentation tool
"http://www.simantics.org/SelectionView-1.1" : L0.URI
SYSDYN.SharedFunctionOntology <T L0.Ontology
>-- SYSDYN.Variable.unit --> L0.String <R L0.HasProperty : L0.FunctionalRelation
>-- SYSDYN.Variable.variability --> L0.String <R L0.HasProperty : L0.FunctionalRelation
>-- SYSDYN.Variable.isTailOf --> STR.Connection <R STR.IsConnectedTo
- L0.InverseOf SYSDYN.HasTail
+ L0.InverseOf SYSDYN.Variable.HasTail
STR.AllowsConnectionType SYSDYN.SysdynConnectionType
STR.HasAttachmentRelation DIA.HasPlainConnector
>-- SYSDYN.Variable.isHeadOf --> STR.Connection <R STR.IsConnectedTo
- L0.InverseOf SYSDYN.HasHead
+ L0.InverseOf SYSDYN.Variable.HasHead
STR.AllowsConnectionType SYSDYN.SysdynConnectionType
STR.HasAttachmentRelation DIA.HasArrowConnector
@L0.assert L0.HasDataType $Double
//#####################################################################
// Connections and Relations
//#####################################################################
+SYSDYN.HasHead <R STR.IsConnectedTo
+SYSDYN.HasTail <R STR.IsConnectedTo
+
SYSDYN.Dependency <T STR.Connection
>-- SYSDYN.Dependency.angle --> L0.Double <R L0.HasProperty : L0.FunctionalRelation
>-- SYSDYN.Dependency.refersTo --> SYSDYN.Variable <R L0.IsRelatedTo : L0.FunctionalRelation
- @L0.singleProperty SYSDYN.HasHead
- @L0.singleProperty SYSDYN.HasTail
+ @L0.singleProperty SYSDYN.Variable.HasHead
+ @L0.singleProperty SYSDYN.Variable.HasTail
SYSDYN.Flow <T STR.Connection
- @L0.singleProperty SYSDYN.HasHead
- @L0.singleProperty SYSDYN.HasTail
+ @L0.singleProperty SYSDYN.Variable.HasHead
+ @L0.singleProperty SYSDYN.Variable.HasTail
//#####################################################################
public final Resource HasEquationOrEmpty_Inverse;\r
public final Resource HasHead;\r
public final Resource HasHeadTerminal;\r
+ public final Resource HasHead_Inverse;\r
public final Resource HasRangeEnd;\r
public final Resource HasRangeEnd_Inverse;\r
public final Resource HasRangeStart;\r
public final Resource HasRangeStep_Inverse;\r
public final Resource HasTail;\r
public final Resource HasTailTerminal;\r
+ public final Resource HasTail_Inverse;\r
public final Resource HasUnit;\r
public final Resource HasUnit_Inverse;\r
public final Resource HistoryDataset;\r
public final Resource ValveSymbol_orientation;\r
public final Resource ValveSymbol_textLocation;\r
public final Resource Variable;\r
+ public final Resource Variable_HasHead;\r
+ public final Resource Variable_HasTail;\r
public final Resource Variable_arrayIndexes;\r
public final Resource Variable_arrayIndexes_Inverse;\r
public final Resource Variable_expressions;\r
public static final String HasEquationOrEmpty_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasEquationOrEmpty/Inverse";\r
public static final String HasHead = "http://www.simantics.org/Sysdyn-1.1/HasHead";\r
public static final String HasHeadTerminal = "http://www.simantics.org/Sysdyn-1.1/HasHeadTerminal";\r
+ public static final String HasHead_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasHead/Inverse";\r
public static final String HasRangeEnd = "http://www.simantics.org/Sysdyn-1.1/HasRangeEnd";\r
public static final String HasRangeEnd_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasRangeEnd/Inverse";\r
public static final String HasRangeStart = "http://www.simantics.org/Sysdyn-1.1/HasRangeStart";\r
public static final String HasRangeStep_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasRangeStep/Inverse";\r
public static final String HasTail = "http://www.simantics.org/Sysdyn-1.1/HasTail";\r
public static final String HasTailTerminal = "http://www.simantics.org/Sysdyn-1.1/HasTailTerminal";\r
+ public static final String HasTail_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasTail/Inverse";\r
public static final String HasUnit = "http://www.simantics.org/Sysdyn-1.1/HasUnit";\r
public static final String HasUnit_Inverse = "http://www.simantics.org/Sysdyn-1.1/HasUnit/Inverse";\r
public static final String HistoryDataset = "http://www.simantics.org/Sysdyn-1.1/HistoryDataset";\r
public static final String ValveSymbol_orientation = "http://www.simantics.org/Sysdyn-1.1/ValveSymbol/orientation";\r
public static final String ValveSymbol_textLocation = "http://www.simantics.org/Sysdyn-1.1/ValveSymbol/textLocation";\r
public static final String Variable = "http://www.simantics.org/Sysdyn-1.1/Variable";\r
+ public static final String Variable_HasHead = "http://www.simantics.org/Sysdyn-1.1/Variable/HasHead";\r
+ public static final String Variable_HasTail = "http://www.simantics.org/Sysdyn-1.1/Variable/HasTail";\r
public static final String Variable_arrayIndexes = "http://www.simantics.org/Sysdyn-1.1/Variable/arrayIndexes";\r
public static final String Variable_arrayIndexes_Inverse = "http://www.simantics.org/Sysdyn-1.1/Variable/arrayIndexes/Inverse";\r
public static final String Variable_expressions = "http://www.simantics.org/Sysdyn-1.1/Variable/expressions";\r
HasEquationOrEmpty_Inverse = getResourceOrNull(graph, URIs.HasEquationOrEmpty_Inverse);\r
HasHead = getResourceOrNull(graph, URIs.HasHead);\r
HasHeadTerminal = getResourceOrNull(graph, URIs.HasHeadTerminal);\r
+ HasHead_Inverse = getResourceOrNull(graph, URIs.HasHead_Inverse);\r
HasRangeEnd = getResourceOrNull(graph, URIs.HasRangeEnd);\r
HasRangeEnd_Inverse = getResourceOrNull(graph, URIs.HasRangeEnd_Inverse);\r
HasRangeStart = getResourceOrNull(graph, URIs.HasRangeStart);\r
HasRangeStep_Inverse = getResourceOrNull(graph, URIs.HasRangeStep_Inverse);\r
HasTail = getResourceOrNull(graph, URIs.HasTail);\r
HasTailTerminal = getResourceOrNull(graph, URIs.HasTailTerminal);\r
+ HasTail_Inverse = getResourceOrNull(graph, URIs.HasTail_Inverse);\r
HasUnit = getResourceOrNull(graph, URIs.HasUnit);\r
HasUnit_Inverse = getResourceOrNull(graph, URIs.HasUnit_Inverse);\r
HistoryDataset = getResourceOrNull(graph, URIs.HistoryDataset);\r
ValveSymbol_orientation = getResourceOrNull(graph, URIs.ValveSymbol_orientation);\r
ValveSymbol_textLocation = getResourceOrNull(graph, URIs.ValveSymbol_textLocation);\r
Variable = getResourceOrNull(graph, URIs.Variable);\r
+ Variable_HasHead = getResourceOrNull(graph, URIs.Variable_HasHead);\r
+ Variable_HasTail = getResourceOrNull(graph, URIs.Variable_HasTail);\r
Variable_arrayIndexes = getResourceOrNull(graph, URIs.Variable_arrayIndexes);\r
Variable_arrayIndexes_Inverse = getResourceOrNull(graph, URIs.Variable_arrayIndexes_Inverse);\r
Variable_expressions = getResourceOrNull(graph, URIs.Variable_expressions);\r
</command>\r
<command\r
commandId="org.simantics.documentation.workbench.newDocumentation"\r
- icon="platform:/plugin/com.famfamfam.silk/icons/application_form.png"\r
+ icon="platform:/plugin/com.famfamfam.silk/icons/script.png"\r
id="org.simantics.sysdyn.ui.browser.newDocumentation"\r
label="Document"\r
style="push">\r
refersTo = graph.getPossibleObject(dependency, sr.Dependency_refersTo);\r
if(refersTo != null) {\r
referenceName = (String) graph.getPossibleRelatedValue(refersTo, l0.HasName);\r
- module = graph.getPossibleObject(dependency, sr.HasTail);\r
+ module = graph.getPossibleObject(dependency, sr.Variable_HasTail);\r
moduleName = (String) graph.getPossibleRelatedValue(module, l0.HasName);\r
}\r
} else {\r
for(Resource dep : graph.getObjects(module, sr.Variable_isHeadOf)) {\r
Resource reference = graph.getPossibleObject(dep, sr.Dependency_refersTo);\r
if(reference!= null && reference.equals(component)) {\r
- refersTo = graph.getSingleObject(dep, sr.HasTail);\r
+ refersTo = graph.getSingleObject(dep, sr.Variable_HasTail);\r
referenceName = (String) graph.getPossibleRelatedValue(refersTo, l0.HasName);\r
Variable parent = null;\r
if(v instanceof ChildVariable)\r
\r
import java.io.File;\r
import java.io.IOException;\r
+import java.util.ArrayList;\r
+import java.util.Collection;\r
import java.util.HashMap;\r
\r
import org.eclipse.core.commands.AbstractHandler;\r
import org.simantics.databoard.container.DataContainers;\r
import org.simantics.databoard.container.DataFormatException;\r
import org.simantics.databoard.container.FormatHandler;\r
+import org.simantics.db.ReadGraph;\r
import org.simantics.db.Resource;\r
import org.simantics.db.WriteGraph;\r
+import org.simantics.db.common.request.ObjectsWithType;\r
import org.simantics.db.common.request.WriteRequest;\r
import org.simantics.db.common.utils.NameUtils;\r
import org.simantics.db.exception.DatabaseException;\r
import org.simantics.db.layer0.adapter.impl.DefaultPasteImportAdvisor;\r
import org.simantics.graph.representation.TransferableGraph1;\r
import org.simantics.layer0.Layer0;\r
+import org.simantics.simulation.ontology.SimulationResource;\r
+import org.simantics.structural.stubs.StructuralResource2;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.ui.Activator;\r
import org.simantics.ui.SimanticsUI;\r
}\r
});\r
\r
- } \r
+ } else {\r
+ fixHasTailAndHasHead(graph, ModelRoot);\r
+ }\r
}\r
});\r
} catch (DatabaseException e) {\r
\r
}\r
\r
+ protected void fixHasTailAndHasHead(WriteGraph graph, Resource modelRoot) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ for(Resource configuration : findAllConfigurations(graph, modelRoot)) {\r
+ Collection<Resource> connections = graph.syncRequest(new ObjectsWithType(configuration, L0.ConsistsOf, sr.Dependency));\r
+ connections.addAll(graph.syncRequest(new ObjectsWithType(configuration, L0.ConsistsOf, sr.Flow)));\r
+\r
+ for(Resource connection : connections) {\r
+ Resource head = graph.getPossibleObject(connection, sr.HasHead);\r
+ Resource tail = graph.getPossibleObject(connection, sr.HasTail);\r
+\r
+ if(head != null && tail != null) {\r
+ graph.deny(connection, sr.HasHead, head);\r
+ graph.deny(connection, sr.HasTail, tail);\r
+\r
+ graph.claim(connection, sr.Variable_HasHead, head);\r
+ graph.claim(connection, sr.Variable_HasTail, tail);\r
+ }\r
+ }\r
+ }\r
+ }\r
+ \r
+ private Collection<Resource> findAllConfigurations(ReadGraph graph, Resource modelRoot) throws DatabaseException {\r
+ Layer0 L0 = Layer0.getInstance(graph);\r
+ SysdynResource sr = SysdynResource.getInstance(graph);\r
+ StructuralResource2 SR2 = StructuralResource2.getInstance(graph);\r
+ Collection<Resource> configurations = new ArrayList<Resource>();\r
+ configurations.add(graph.getPossibleObject(modelRoot, SimulationResource.getInstance(graph).HasConfiguration));\r
+\r
+ for(Resource r : graph.getObjects(modelRoot, L0.ConsistsOf)) {\r
+ if(graph.isInheritedFrom(r, sr.Module)) {\r
+ configurations.add(graph.getPossibleObject(r, SR2.IsDefinedBy));\r
+ }\r
+ }\r
+ \r
+ return configurations;\r
+ }\r
+ \r
private void displayErrorMessage(Shell shell, String message) {\r
MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ERROR);\r
mb.setText("Error");\r
\r
for(Resource d : dependencies) {\r
if(graph.isInstanceOf(d, sr.Dependency)) {\r
- Resource tail = graph.getPossibleObject(d, sr.HasTail);\r
+ Resource tail = graph.getPossibleObject(d, sr.Variable_HasTail);\r
if(tail != null) {\r
Object name = graph.getPossibleRelatedValue(tail, l0.HasName);\r
if(name != null)\r
for(Resource dependency : graph.syncRequest(new ObjectsWithType(module, sr.Variable_isHeadOf, sr.Dependency))) {\r
if(graph.getPossibleObject(dependency, sr.Dependency_refersTo) == null ||\r
graph.getPossibleObject(dependency, sr.Dependency_refersTo).equals(inputVariable)) {\r
- Resource output = graph.getSingleObject(dependency, sr.HasTail);\r
+ Resource output = graph.getSingleObject(dependency, sr.Variable_HasTail);\r
result.put((String)graph.getRelatedValue(output, l0.HasName), dependency);\r
}\r
}\r
if(graph.getPossibleObject(dependency, sr.Dependency_refersTo) == null \r
|| !graph.hasStatement(graph.getPossibleObject(dependency, sr.Dependency_refersTo), l0.HasName)\r
|| graph.getPossibleObject(dependency, sr.Dependency_refersTo).equals(outputVariable)) {\r
- Resource input = graph.getSingleObject(dependency, sr.HasHead);\r
+ Resource input = graph.getSingleObject(dependency, sr.Variable_HasHead);\r
result.put((String)graph.getRelatedValue(input, l0.HasName), dependency);\r
}\r
}\r
public String perform(ReadGraph graph) throws DatabaseException {\r
Layer0 l0 = Layer0.getInstance(graph);\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
- Resource valueResource = graph.getPossibleObject(dependency, sr.HasTail);\r
+ Resource valueResource = graph.getPossibleObject(dependency, sr.Variable_HasTail);\r
if(!graph.isInstanceOf(valueResource, sr.Variable))\r
- valueResource = graph.getPossibleObject(dependency, sr.HasHead);\r
+ valueResource = graph.getPossibleObject(dependency, sr.Variable_HasHead);\r
if(!graph.isInstanceOf(valueResource, sr.Variable))\r
return "";\r
return (String)graph.getRelatedValue(valueResource, l0.HasName, Bindings.STRING);\r
\r
Collection<Resource> dependants;\r
if(isInverted)\r
- dependants = getDependants(g, graph, r, sr.Variable_isTailOf, sr.HasHead, sr.Dependency);\r
+ dependants = getDependants(g, graph, r, sr.Variable_isTailOf, sr.Variable_HasHead, sr.Dependency);\r
else {\r
- dependants = getDependants(g, graph, r, sr.Variable_isHeadOf, sr.HasTail, sr.Dependency);\r
+ dependants = getDependants(g, graph, r, sr.Variable_isHeadOf, sr.Variable_HasTail, sr.Dependency);\r
if (g.isInstanceOf(r, sr.Stock)) {\r
- dependants.addAll(getDependants(g, graph, r, sr.Variable_isTailOf, sr.HasHead, sr.Flow));\r
- dependants.addAll(getDependants(g, graph, r, sr.Variable_isHeadOf, sr.HasTail, sr.Flow));\r
+ dependants.addAll(getDependants(g, graph, r, sr.Variable_isTailOf, sr.Variable_HasHead, sr.Flow));\r
+ dependants.addAll(getDependants(g, graph, r, sr.Variable_isHeadOf, sr.Variable_HasTail, sr.Flow));\r
}\r
}\r
\r
\r
for(Resource d : dependencies) {\r
if(graph.isInstanceOf(d, sr.Dependency)) {\r
- Resource tail = graph.getPossibleObject(d, sr.HasTail);\r
+ Resource tail = graph.getPossibleObject(d, sr.Variable_HasTail);\r
if(tail != null) {\r
Object name = graph.getPossibleRelatedValue(tail, l0.HasName);\r
if(name != null)\r
// Set value for all referred variables in modules\r
SysdynResource sr = SysdynResource.getInstance(graph);\r
for(Resource dependency : graph.getObjects(this.resource, sr.Variable_isTailOf)) {\r
- Resource head = graph.getPossibleObject(dependency, sr.HasHead);\r
+ Resource head = graph.getPossibleObject(dependency, sr.Variable_HasHead);\r
Resource ref = graph.getPossibleObject(dependency, sr.Dependency_refersTo);\r
if(ref != null && head != null) {\r
String module = "";\r
// Build the connection to configuration\r
Resource connection = GraphUtils.create2(graph, \r
connectionType,\r
- sr.HasHead, end.getResource(),\r
- sr.HasTail, start.getResource(),\r
+ sr.Variable_HasHead, end.getResource(),\r
+ sr.Variable_HasTail, start.getResource(),\r
l0.PartOf, configuration);\r
graph.claim(connection, mr.Mapped, connection);\r
\r
\r
@GraphType(SysdynResource.URIs.Dependency)\r
public class Dependency implements IElement {\r
- @RelatedElement(SysdynResource.URIs.HasTail)\r
+ @RelatedElement(SysdynResource.URIs.Variable_HasTail)\r
private IElement tail;\r
- @RelatedElement(SysdynResource.URIs.HasHead)\r
+ @RelatedElement(SysdynResource.URIs.Variable_HasHead)\r
private IElement head;\r
@RelatedElement(SysdynResource.URIs.Dependency_refersTo)\r
private IElement refersTo;\r
\r
@GraphType(SysdynResource.URIs.Flow)\r
public class Flow implements IElement {\r
- @RelatedElement(SysdynResource.URIs.HasTail)\r
+ @RelatedElement(SysdynResource.URIs.Variable_HasTail)\r
private IElement tail;\r
- @RelatedElement(SysdynResource.URIs.HasHead)\r
+ @RelatedElement(SysdynResource.URIs.Variable_HasHead)\r
private IElement head;\r
\r
@Override\r