// Function, FunctionLibrary, and SharedFunctionLibrary are not\r
// allowed to have whitespace.\r
if (graph.isInstanceOf(resource, sr.Variable)\r
-// || graph.isInstanceOf(resource, sr.Module)\r
-// || graph.isInstanceOf(resource, sr.ModuleType)\r
+ || graph.isInstanceOf(resource, sr.Module)\r
+ || graph.isInheritedFrom(resource, sr.ModuleSymbol)\r
|| graph.isInstanceOf(resource, sr.Enumeration)\r
|| graph.isInstanceOf(resource, sr.EnumerationIndex)\r
|| graph.isInstanceOf(resource, sheet.Spreadsheet)\r
/*******************************************************************************\r
- * Copyright (c) 2010, 2013 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2013, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
\r
/**\r
* Maintains a Java representation of system dynamic model.\r
- * @author Hannu Niemistö, Teemu Lempinen\r
+ * @author Hannu Niemistö, Teemu Lempinen, Tuomas Miettinen\r
*/\r
public class SysdynModel implements IModel, IMappingListener, VariableSubscriptionManager {\r
\r
if (element instanceof Module) {\r
Module module = (Module) element;\r
Configuration conf = module.getType().getConfiguration();\r
- String prfx = prefix + module.getName() + ".";\r
+ String prfx = prefix + module.getModelicaName() + ".";\r
inits.putAll(getInits(conf, prfx));\r
for(ParameterOverride po : module.getParameterOverrides()) {\r
inits.put(prfx + po.getVariable().getName(), po.getExpression());\r
/*******************************************************************************\r
- * Copyright (c) 2007, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2007, 2012, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
// Module\r
Module m = (Module)element; \r
modules.add(m);\r
- moduleInputs.put(m.getName(), new ArrayList<Input>());\r
+ moduleInputs.put(m.getModelicaName(), new ArrayList<Input>());\r
for(IElement e : m.getType().getConfiguration().getElements())\r
// Inputs inside the module\r
if(e instanceof Input && !((Input)e).isHeadOfDependency()) {\r
- moduleInputs.get(m.getName()).add((Input)e);\r
+ moduleInputs.get(m.getModelicaName()).add((Input)e);\r
}\r
} else if (element instanceof Input) {\r
// Input variables\r
ModuleType mt = configuration.getModuleType();\r
\r
// className == null, if this is a model configuration. model configuration start and end are written in ModelicaWriter.write\r
- String className = mt != null ? (mt.getName().replace(" ", "")) : null;\r
+ String className = mt != null ? (mt.getModelicaName()) : null;\r
\r
if(className != null)\r
b.append("class "+className+"\n");\r
Module module = (Module)dependency.getHead();\r
Input reference = (Input)dependency.refersTo();\r
if(reference != null && reference.getName() != null && (reference.getVariability() == null || reference.getVariability().isEmpty())) {\r
- b.append(" " + module.getName() + "." + reference.getModelicaName() + " = " + variable.getModelicaName() + ";\n");\r
- moduleInputs.get(module.getName()).remove(reference);\r
+ b.append(" " + module.getModelicaName() + "." + reference.getModelicaName() + " = " + variable.getModelicaName() + ";\n");\r
+ moduleInputs.get(module.getModelicaName()).remove(reference);\r
}\r
}\r
\r
if(configuration.isGameConfiguration() && !modules.isEmpty()) {\r
b.append("// Time values for module\n");\r
for(Module m : modules) {\r
- b.append(" " + m.getName() + ".time = time;\n");\r
+ b.append(" " + m.getModelicaName() + ".time = time;\n");\r
}\r
}\r
}\r
String expression;\r
// If reference exists, use reference name. Otherwise, use default value.\r
if(reference != null && reference.getName() != null)\r
- expression = module.getName() + "." + reference.getModelicaName() + ";\n";\r
+ expression = module.getModelicaName() + "." + reference.getModelicaName() + ";\n";\r
\r
else\r
expression = input.getDefaultInputValue() + ";\n";\r
/*******************************************************************************\r
- * Copyright (c) 2010, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2012, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
public String getName() {\r
return name;\r
}\r
+ \r
+ /**\r
+ * Get Modelica compliant name\r
+ * @return The name of this variable with spaces (' ') replaced with \r
+ * underscore characters ('_')\r
+ */\r
+ public String getModelicaName() {\r
+ if (this.name == null)\r
+ return null;\r
+ return this.name.replace(' ', '_');\r
+ }\r
\r
public ModuleType getType() {\r
return type;\r
}\r
\r
sb.append(" ");\r
- sb.append(getType().getName());\r
+ sb.append(getType().getModelicaName());\r
sb.append(" ");\r
- sb.append(getName());\r
+ sb.append(getModelicaName());\r
sb.append(redeclarations.toString()); // possible redeclarations\r
sb.append(";\n");\r
return sb.toString();\r
/*******************************************************************************\r
- * Copyright (c) 2010, 2012 Association for Decentralized Information Management in\r
+ * Copyright (c) 2010, 2012, 2014 Association for Decentralized Information Management in\r
* Industry THTH ry.\r
* All rights reserved. This program and the accompanying materials\r
* are made available under the terms of the Eclipse Public License v1.0\r
* Representation of a module type\r
* \r
* @author Teemu Lempinen\r
+ * @author Tuomas Miettinen\r
*\r
*/\r
@GraphType(StructuralResource2.URIs.ComponentType)\r
\r
@RelatedElement(Layer0.URIs.PartOf)\r
protected Object parent;\r
-\r
+ \r
+ /**\r
+ * Get Modelica compliant name\r
+ * @return The name of this variable with spaces (' ') replaced with \r
+ * underscore characters ('_')\r
+ */\r
+ public String getModelicaName() {\r
+ if (this.name == null)\r
+ return null;\r
+ return this.name.replace(' ', '_');\r
+ }\r
+ \r
public String getName() {\r
return name;\r
}\r