\r
@RelatedElement(SimulationResource.URIs.HasConfiguration)\r
private Configuration configuration;\r
-\r
+ \r
+ @RelatedValue(SysdynResource.URIs.SysdynModel_timeUnit)\r
+ private String timeUnit;\r
+ \r
@RelatedElements(\r
value = Layer0.URIs.ConsistsOf,\r
composition = true)\r
public Configuration getModelConfiguration() {\r
return configuration;\r
}\r
+ \r
+ \r
+ public String getTimeUnit() {\r
+ return timeUnit;\r
+ }\r
}\r
import java.util.ArrayList;\r
import java.util.Set;\r
\r
+import org.simantics.db.ReadGraph;\r
import org.simantics.objmap.annotations.GraphType;\r
import org.simantics.objmap.annotations.RelatedValue;\r
import org.simantics.sysdyn.SysdynResource;\r
import org.simantics.sysdyn.expressionParser.ExpressionParser;\r
import org.simantics.sysdyn.expressionParser.ParseException;\r
+import org.simantics.sysdyn.manager.SysdynModel;\r
import org.simantics.sysdyn.representation.Book;\r
import org.simantics.sysdyn.representation.Enumeration;\r
import org.simantics.sysdyn.representation.IElement;\r
import org.simantics.sysdyn.representation.Valve;\r
import org.simantics.sysdyn.representation.utils.FormatUtils;\r
import org.simantics.sysdyn.representation.utils.IndexUtils;\r
+import org.simantics.sysdyn.representation.utils.UnitUtils;\r
\r
/**\r
* Class representing a stock expression in a variable\r
return value;\r
}\r
\r
-\r
+ \r
+ @Override\r
+ public String validateUnits(ReadGraph graph, SysdynModel model) {\r
+ String result = UnitUtils.matchUnits(graph, model, parent.getParentConfiguration(), parent.getUnit(), initialEquation);\r
+ if(result == null) {\r
+ String integralEquation = getEquation();\r
+ if(integralEquation.contains("="))\r
+ result = UnitUtils.matchUnits(\r
+ graph, \r
+ model, \r
+ parent.getParentConfiguration(), \r
+ parent.getUnit(), \r
+ "(" + integralEquation.substring(integralEquation.indexOf("=") + 1, integralEquation.lastIndexOf(";")) +") * time");\r
+ }\r
+ \r
+ return result;\r
+ }\r
}\r