From 7f2a82ce490e67e884bc96097768c48b845260db Mon Sep 17 00:00:00 2001 From: lempinen Date: Wed, 11 May 2011 12:15:35 +0000 Subject: [PATCH] Use default input value also if a dependency from module to input exists, but reference has not been set. git-svn-id: https://www.simantics.org/svn/simantics/sysdyn/trunk@20864 ac1ea38d-2e2b-0410-8846-a27921b304fc --- .../simantics/sysdyn/modelica/ModelicaWriter.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java b/org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java index f1b60899..bd462953 100644 --- a/org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java +++ b/org.simantics.sysdyn/src/org/simantics/sysdyn/modelica/ModelicaWriter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010 Association for Decentralized Information Management in + * Copyright (c) 2007, 2011 Association for Decentralized Information Management in * Industry THTH ry. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -73,7 +73,7 @@ public class ModelicaWriter { inputs.add((Input)element); } else if (element instanceof Enumeration) { enumerations.add((Enumeration)element); - } else if (element instanceof Dependency && ((Dependency)element).refersTo() != null) { + } else if (element instanceof Dependency) { Dependency dependency = (Dependency)element; if(dependency.getHead() instanceof Module) { outputDependencies.add(dependency); @@ -141,7 +141,10 @@ public class ModelicaWriter { Input variable = (Input)dependency.getHead(); Module module = (Module)dependency.getTail(); Variable reference = (Variable)dependency.refersTo(); - b.append(" " + variable.getName() + " = " + module.getName() + "." + reference.getName() + ";\n"); + if(reference != null) + b.append(" " + variable.getName() + " = " + module.getName() + "." + reference.getName() + ";\n"); + else + b.append(" " + variable.getName() + " = " + variable.getDefaultInputValue() + ";\n"); } b.append("// Outputs\n"); @@ -149,8 +152,10 @@ public class ModelicaWriter { Variable variable = (Variable)dependency.getTail(); Module module = (Module)dependency.getHead(); Input reference = (Input)dependency.refersTo(); - b.append(" " + module.getName() + "." + reference.getName() + " = " + variable.getName() + ";\n"); - moduleInputs.get(module.getName()).remove(reference); + if(reference != null) { + b.append(" " + module.getName() + "." + reference.getName() + " = " + variable.getName() + ";\n"); + moduleInputs.get(module.getName()).remove(reference); + } } b.append("// Default values for inputs in modules\n"); -- 2.47.1