From 863b4b5e204fa83d774d40b706cb29c99c6e63f2 Mon Sep 17 00:00:00 2001 From: lempinen Date: Wed, 30 Jun 2010 09:06:17 +0000 Subject: [PATCH] Show results of variables inside modules git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@16438 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../simantics/sysdyn/ui/trend/TrendView.java | 11 +++--- .../sysdyn/representation/Module.java | 8 +++++ .../sysdyn/representation/Variable.java | 10 ++++++ sysdyn_ontologies/sysdyn.graph | 36 +++++++++++++++++++ 4 files changed, 61 insertions(+), 4 deletions(-) diff --git a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java index fc730f29..5e20e19e 100644 --- a/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java +++ b/org.simantics.sysdyn.ui/src/org/simantics/sysdyn/ui/trend/TrendView.java @@ -227,9 +227,12 @@ public class TrendView extends ViewPart { if(map != null) resource = map; if(g.isInstanceOf(resource, sr.Variable)) { - Resource configuration = g.getPossibleObject(resource, b.PartOf); - if(g.isInstanceOf(configuration, sr.Configuration)) { - SysdynModel model = getModel(g, configuration); + Resource module = g.getPossibleObject(resource, b.PartOf); + while(!g.isInstanceOf(module, sr.Configuration)) { + module = g.getPossibleObject(module, b.PartOf); + } + if(g.isInstanceOf(module, sr.Configuration)) { + SysdynModel model = getModel(g, module); if(model == null) return null; @@ -240,7 +243,7 @@ public class TrendView extends ViewPart { Collection activeResults = model.getActiveResults(g); ArrayList datasets = new ArrayList(); for(SysdynResult r : activeResults) { - datasets.add(r.getDataSet(var.getName())); + datasets.add(r.getDataSet(var.getFullName())); } return datasets; } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Module.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Module.java index bdb37afd..985483ed 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Module.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Module.java @@ -3,6 +3,7 @@ package org.simantics.sysdyn.representation; import java.util.ArrayList; import org.simantics.objmap.annotations.GraphType; +import org.simantics.objmap.annotations.RelatedElement; import org.simantics.objmap.annotations.RelatedElements; import org.simantics.objmap.annotations.RelatedValue; import org.simantics.sysdyn.representation.visitors.ElementVisitorVoidAdapter; @@ -16,6 +17,9 @@ public class Module implements IElement, IModule { @RelatedValue("http://www.simantics.org/Layer0-1.0/HasLabel") private String label; + + @RelatedElement("http://www.simantics.org/Layer0-1.0/PartOf") + protected IModule module; @RelatedElements( value = "http://www.simantics.org/Layer0-1.0/ConsistsOf", @@ -68,4 +72,8 @@ public class Module implements IElement, IModule { public String getLabel() { return label; } + + public IModule getParentModule() { + return this.module; + } } diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Variable.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Variable.java index 6b9b50f0..78f9e585 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Variable.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/representation/Variable.java @@ -39,6 +39,16 @@ public abstract class Variable implements IElement { public String getName() { return this.name; } + + public String getFullName() { + String name = getName(); + IModule m = getParentModule(); + while(!(m instanceof Configuration) && m instanceof Module) { + name = m.getLabel() + "." + name; + m = ((Module)m).getParentModule(); + } + return name; + } public String getType() { return this.type; diff --git a/sysdyn_ontologies/sysdyn.graph b/sysdyn_ontologies/sysdyn.graph index 6bead35c..79532037 100644 --- a/sysdyn_ontologies/sysdyn.graph +++ b/sysdyn_ontologies/sysdyn.graph @@ -457,6 +457,8 @@ ModuleConfiguration @ "ModuleConfiguration" : Configuration Module1 @ "FirstModule" : Module L0.ConsistsOf + Module2 + L0.HasLabel "TokaModuuli" : L0.String FirstModuleInput1 @ "Aux1" : Auxiliary L0.HasType "Real" : L0.String HasUnit "s" : L0.String @@ -493,4 +495,38 @@ Module1 @ "FirstModule" : Module HasInput FirstModuleInput2 HasOutput FirstModuleOutput1 +Module2 @ "SecondModule" : Module + L0.ConsistsOf + SecondModuleInput1 @ "Aux1" : Auxiliary + L0.HasType "Real" : L0.String + HasUnit "s" : L0.String + HasExpression _ : NormalExpression + HasEquation "2+2" : L0.String + RefersTo FirstModuleOutput1 + SecondModuleInput2 @ "Aux2" : Auxiliary + L0.HasType "Real" : L0.String + HasUnit "s" : L0.String + HasExpression _ : NormalExpression + HasEquation "2+2" : L0.String + SecondModuleStock @ "Stock1" : Stock + HasExpression _ : StockExpression + HasInitialEquation "0" : L0.String + SecondModuleCloud : Cloud + SecondModuleOutput1 @ "Valve" : Valve + HasUnit "s" : L0.String + HasExpression _ : NormalExpression + HasEquation "Aux1 + Aux2" : L0.String + _ : Flow + HasHead SecondModuleOutput1 + HasTail SecondModuleCloud + _ : Flow + HasHead SecondModuleStock + HasTail SecondModuleOutput1 + _ : Dependency + HasHead SecondModuleOutput1 + HasTail SecondModuleInput1 + _ : Dependency + HasHead SecondModuleOutput1 + HasTail SecondModuleInput2 + HasInput SecondModuleInput1 -- 2.47.1