\r
@Override\r
public String getEquation() {\r
+ return getEquation(true);\r
+ }\r
+ \r
+ private String getEquation(boolean modelicaEquation) {\r
\r
// Build range e.g. Stock[2,3]\r
String range = IndexUtils.rangeToIndexes(parent, this.getArrayRange());\r
// Stock equation is always der(Stock)\r
StringBuilder b = new StringBuilder();\r
b.append(" der(")\r
- .append(parent.getModelicaName() + range)\r
+ .append(modelicaEquation ? parent.getModelicaName() : parent.getName() + range)\r
.append(") = ");\r
\r
if (integralEquation != null) {\r
- String equation = FormatUtils.replaceWhitespace(this.integralEquation);\r
- equation = FormatUtils.formatExpressionForModelica(parent, equation);\r
- b.append(equation).append(";\n");\r
+ if (modelicaEquation) {\r
+ String equation = FormatUtils.replaceWhitespace(this.integralEquation);\r
+ equation = FormatUtils.formatExpressionForModelica(parent, equation);\r
+ b.append(equation).append(";\n");\r
+ } else {\r
+ b.append(integralEquation).append(";\n");\r
+ }\r
} else {\r
// Stock equation is formed automatically using incoming and outgoing flows (actually the nearest valves in those flows)\r
ArrayList<Valve> incoming = ((Stock)parent).getIncomingValves();\r
} else {\r
b.append(" zeros(");\r
for(int i = 0; i < enumerations.size(); i++) {\r
- b.append(enumerations.get(i).getModelicaName() + ".size");\r
+ b.append(modelicaEquation ? enumerations.get(i).getModelicaName() : enumerations.get(i).getName() + ".size");\r
if(i != enumerations.size() - 1)\r
b.append(", ");\r
}\r
} else {\r
// incoming valves add and outgoing valves reduce the stock\r
for(Valve valve : outgoing)\r
- b.append("\n - ").append(valve.getModelicaName() + range);\r
+ b.append("\n - ").append(modelicaEquation ? valve.getModelicaName() : valve.getName() + range);\r
for(Valve valve : incoming)\r
- b.append("\n + ").append(valve.getModelicaName() + range);\r
+ b.append("\n + ").append(modelicaEquation ? valve.getModelicaName() : valve.getName() + range);\r
}\r
b.append(";\n");\r
}\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
+ String integralEquation = getEquation(false);\r
if(integralEquation.contains("="))\r
result = UnitUtils.matchUnits(\r
graph, \r