for(Sheet sheet : getSpreadSheets(configurations))\r
sheetNames.add(sheet.getName());\r
\r
+ // Write all module configurations to the declarations part (first)\r
for(Configuration conf : configurations) {\r
conf.setIsGameConfiguration(isGame);\r
- writeConfiguration(conf, sheetNames, b);\r
+ if(!conf.equals(modelConf))\r
+ writeConfiguration(conf, sheetNames, b);\r
}\r
\r
+ // Write model configuration last, so that equations-part does not contain module definitions\r
+ modelConf.setIsGameConfiguration(isGame);\r
+ writeConfiguration(modelConf, sheetNames, b);\r
+ \r
b.append("end " + modelName + ";\n\n");\r
\r
b.append(getGlobalSpreadSheets(configurations));\r
String className = mt != null ? (mt.getName().replace(" ", "")) : null;\r
\r
if(className != null)\r
- b.append("class ").append(className);\r
+ b.append("\nclass ").append(className);\r
\r
// Add spreadsheets to all modules and model. Model is "inner" and modules "outer"\r
String globalStatus = mt != null ? "outer" : "inner";\r
}\r
}\r
\r
- boolean first = true;\r
+ boolean equation = false;\r
b.append("// Equations\n");\r
for(IndependentVariable variable : variables) {\r
app = variable.getEquation();\r
if (app != null) {\r
- if(first) {\r
+ if(!equation) {\r
b.append("equation\n");\r
- first = false;\r
+ equation = true;\r
}\r
\r
b.append(app);\r
}\r
}\r
\r
+ // If "equation" has not been added but there are still equations to be defined, add "equation"\r
+ if(!equation && (!inputReferences.isEmpty() || !outputDependencies.isEmpty() ||\r
+ !moduleInputs.isEmpty() || !modules.isEmpty()))\r
+ b.append("equation\n");\r
+\r
// Continous input references\r
continuousInputReferences(b, inputReferences);\r
\r