Program: 72863
Project: 72863
Buggy source:
/** 
 * Build the Modelica model. Then, run the executable result file of buildModel() in both interactive and non-interactive processing mode in order to generate the simulation result file.
 * @param fileName File which the model should be loaded from.
 * @param modelName Name of the model which should be built.
 * @param fileNamePrefix User preferable name for the result file.
 * @param startTime The start time of simulation.
 * @param stopTime The stop time of simulation.
 * @param numberOfIntervals Number of intervals in the result file.
 * @param tolerance Tolerance used by the integration method.
 * @param method Integration method used for simulation.
 * @param outputFormat Format of the result file.
 * @param variableFilter Filter for variables that should be stored in the result file.
 * @param cflags Any standard C language flags.
 * @param simflags Simulation flags.
 * @param processingType Type of processing for running the executable result file of building the Modelica model.
 * @throws ConnectException If commands couldn'tbe sent to the (OpenModelic Compiler)OMC.
 * @throws IOException If the executable result file of buildModel()couldn't be executed.
 * @throws IllegalActionException 
 */
public void simulateModel(String fileName,String modelName,String fileNamePrefix,String startTime,String stopTime,int numberOfIntervals,String tolerance,String method,String outputFormat,String variableFilter,String cflags,String simflags,String processingType) throws ConnectException, IOException, IllegalActionException {
  String commands=null;
  String loggerInfo=null;
  if (fileNamePrefix.compareTo("String_Node_Str") == 0) {
    commands=modelName + "String_Node_Str" + Float.valueOf(startTime).floatValue()+ "String_Node_Str"+ Float.valueOf(stopTime).floatValue()+ "String_Node_Str"+ numberOfIntervals+ "String_Node_Str"+ Float.valueOf(tolerance).floatValue()+ "String_Node_Str"+ method+ "String_Node_Str"+ outputFormat+ "String_Node_Str"+ variableFilter+ "String_Node_Str"+ cflags+ "String_Node_Str"+ simflags+ "String_Node_Str";
    loggerInfo="String_Node_Str" + modelName + "String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
  }
 else {
    commands=fileNamePrefix + "String_Node_Str" + Float.valueOf(startTime).floatValue()+ "String_Node_Str"+ Float.valueOf(stopTime).floatValue()+ "String_Node_Str"+ numberOfIntervals+ "String_Node_Str"+ Float.valueOf(tolerance).floatValue()+ "String_Node_Str"+ method+ "String_Node_Str"+ fileNamePrefix+ "String_Node_Str"+ outputFormat+ "String_Node_Str"+ variableFilter+ "String_Node_Str"+ cflags+ "String_Node_Str"+ simflags+ "String_Node_Str";
    loggerInfo="String_Node_Str" + modelName + "String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
  }
  CompilerResult buildModelResult=buildModel(commands);
  if (buildModelResult.getFirstResult().compareTo("String_Node_Str") != 0 && buildModelResult.getError().compareTo("String_Node_Str") == 0) {
    loggerInfo=modelName + "String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
  }
  if (buildModelResult.getError().compareTo("String_Node_Str") != 0) {
    loggerInfo="String_Node_Str" + modelName + "String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
    throw new ConnectException(loggerInfo);
  }
  if (!outputFormat.equals("String_Node_Str")) {
    if (processingType.compareTo("String_Node_Str") == 0) {
      loggerInfo="String_Node_Str";
      _omcLogger.getInfo(loggerInfo);
      if (fileNamePrefix.compareTo("String_Node_Str") == 0) {
switch (getOs()) {
case WINDOWS:
          commands=_temp + _username + "String_Node_Str"+ modelName+ "String_Node_Str";
        break;
case UNIX:
      commands=_temp + "String_Node_Str" + _username+ "String_Node_Str"+ modelName;
    break;
case MAC:
  commands=_temp + _username + "String_Node_Str"+ modelName;
break;
}
}
 else {
switch (getOs()) {
case WINDOWS:
commands=_temp + _username + "String_Node_Str"+ fileNamePrefix+ "String_Node_Str";
break;
case UNIX:
commands=_temp + "String_Node_Str" + _username+ "String_Node_Str"+ fileNamePrefix;
break;
case MAC:
commands=_temp + _username + "String_Node_Str"+ fileNamePrefix;
break;
}
}
try {
Runtime.getRuntime().exec(commands,_environmentalVariables,_workDir);
}
 catch (IOException e) {
loggerInfo="String_Node_Str" + commands;
_omcLogger.getInfo(loggerInfo);
hasInitialized=false;
StringUtilities.exit(1);
}
loggerInfo="String_Node_Str";
_omcLogger.getInfo(loggerInfo);
if (fileNamePrefix.compareTo("String_Node_Str") == 0) {
switch (getOs()) {
case WINDOWS:
loggerInfo=modelName + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
case UNIX:
loggerInfo=modelName + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ "String_Node_Str"+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
case MAC:
loggerInfo=modelName + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
}
}
 else if (fileNamePrefix.length() != 0) {
switch (getOs()) {
case WINDOWS:
loggerInfo=fileNamePrefix + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
case UNIX:
loggerInfo=fileNamePrefix + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ "String_Node_Str"+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
case MAC:
loggerInfo=fileNamePrefix + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
}
}
}
 else {
loggerInfo="String_Node_Str";
_omcLogger.getInfo(loggerInfo);
switch (getOs()) {
case WINDOWS:
commands=_temp + _username + "String_Node_Str"+ modelName+ "String_Node_Str";
break;
case UNIX:
commands=_temp + "String_Node_Str" + _username+ "String_Node_Str"+ modelName;
break;
case MAC:
commands=_temp + _username + "String_Node_Str"+ modelName;
break;
}
commands=commands + "String_Node_Str";
try {
loggerInfo="String_Node_Str" + commands + "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
Runtime.getRuntime().exec(commands,_environmentalVariables,_workDir);
}
 catch (IOException e) {
loggerInfo="String_Node_Str" + commands;
_omcLogger.getInfo(loggerInfo);
hasInitialized=false;
return;
}
loggerInfo="String_Node_Str";
_omcLogger.getInfo(loggerInfo);
}
}
 else {
loggerInfo=modelName + "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
}
}

Fixed version (ground truth):
/** 
 * Build the Modelica model. Then, run the executable result file of buildModel() in both interactive and non-interactive processing mode in order to generate the simulation result file.
 * @param fileName File which the model should be loaded from.
 * @param modelName Name of the model which should be built.
 * @param fileNamePrefix User preferable name for the result file.
 * @param startTime The start time of simulation.
 * @param stopTime The stop time of simulation.
 * @param numberOfIntervals Number of intervals in the result file.
 * @param tolerance Tolerance used by the integration method.
 * @param method Integration method used for simulation.
 * @param outputFormat Format of the result file.
 * @param variableFilter Filter for variables that should be stored in the result file.
 * @param cflags Any standard C language flags.
 * @param simflags Simulation flags.
 * @param processingType Type of processing for running the executable result file of building the Modelica model.
 * @throws ConnectException If commands couldn'tbe sent to the (OpenModelic Compiler)OMC.
 * @throws IOException If the executable result file of buildModel()couldn't be executed.
 * @throws IllegalActionException 
 */
public void simulateModel(String fileName,String modelName,String fileNamePrefix,String startTime,String stopTime,int numberOfIntervals,String tolerance,String method,String outputFormat,String variableFilter,String cflags,String simflags,String processingType) throws ConnectException, IOException, IllegalActionException {
  String commands=null;
  String loggerInfo=null;
  if (fileNamePrefix.compareTo("String_Node_Str") == 0) {
    commands=modelName + "String_Node_Str" + Float.valueOf(startTime).floatValue()+ "String_Node_Str"+ Float.valueOf(stopTime).floatValue()+ "String_Node_Str"+ numberOfIntervals+ "String_Node_Str"+ Float.valueOf(tolerance).floatValue()+ "String_Node_Str"+ method+ "String_Node_Str"+ outputFormat+ "String_Node_Str"+ variableFilter+ "String_Node_Str"+ cflags+ "String_Node_Str"+ simflags+ "String_Node_Str";
    loggerInfo="String_Node_Str" + modelName + "String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
  }
 else {
    commands=fileNamePrefix + "String_Node_Str" + Float.valueOf(startTime).floatValue()+ "String_Node_Str"+ Float.valueOf(stopTime).floatValue()+ "String_Node_Str"+ numberOfIntervals+ "String_Node_Str"+ Float.valueOf(tolerance).floatValue()+ "String_Node_Str"+ method+ "String_Node_Str"+ fileNamePrefix+ "String_Node_Str"+ outputFormat+ "String_Node_Str"+ variableFilter+ "String_Node_Str"+ cflags+ "String_Node_Str"+ simflags+ "String_Node_Str";
    loggerInfo="String_Node_Str" + modelName + "String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
  }
  CompilerResult buildModelResult=buildModel(commands);
  if (buildModelResult.getFirstResult().compareTo("String_Node_Str") != 0 && buildModelResult.getError().compareTo("String_Node_Str") == 0) {
    loggerInfo=modelName + "String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
  }
  if (buildModelResult.getError().compareTo("String_Node_Str") != 0) {
    loggerInfo="String_Node_Str" + modelName + "String_Node_Str";
    _omcLogger.getInfo(loggerInfo);
    throw new ConnectException(loggerInfo);
  }
  if (!outputFormat.equals("String_Node_Str")) {
    if (processingType.compareTo("String_Node_Str") == 0) {
      loggerInfo="String_Node_Str";
      _omcLogger.getInfo(loggerInfo);
      if (fileNamePrefix.compareTo("String_Node_Str") == 0) {
switch (getOs()) {
case WINDOWS:
          commands=_temp + _username + "String_Node_Str"+ modelName+ "String_Node_Str";
        break;
case UNIX:
      commands=_temp + "String_Node_Str" + _username+ "String_Node_Str"+ modelName;
    break;
case MAC:
  commands=_temp + _username + "String_Node_Str"+ modelName;
break;
}
}
 else {
switch (getOs()) {
case WINDOWS:
commands=_temp + _username + "String_Node_Str"+ fileNamePrefix+ "String_Node_Str";
break;
case UNIX:
commands=_temp + "String_Node_Str" + _username+ "String_Node_Str"+ fileNamePrefix;
break;
case MAC:
commands=_temp + _username + "String_Node_Str"+ fileNamePrefix;
break;
}
}
try {
Runtime.getRuntime().exec(commands,_environmentalVariables,_workDir);
}
 catch (IOException e) {
loggerInfo="String_Node_Str" + commands;
_omcLogger.getInfo(loggerInfo);
hasInitialized=false;
StringUtilities.exit(1);
}
loggerInfo="String_Node_Str";
_omcLogger.getInfo(loggerInfo);
if (fileNamePrefix.compareTo("String_Node_Str") == 0) {
switch (getOs()) {
case WINDOWS:
loggerInfo=modelName + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
case UNIX:
loggerInfo=modelName + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ "String_Node_Str"+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
case MAC:
loggerInfo=modelName + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
}
}
 else if (fileNamePrefix.length() != 0) {
switch (getOs()) {
case WINDOWS:
loggerInfo=fileNamePrefix + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
case UNIX:
loggerInfo=fileNamePrefix + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ "String_Node_Str"+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
case MAC:
loggerInfo=fileNamePrefix + "String_Node_Str" + outputFormat+ "String_Node_Str"+ _temp+ _username+ "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
break;
}
}
}
 else {
loggerInfo="String_Node_Str";
_omcLogger.getInfo(loggerInfo);
switch (getOs()) {
case WINDOWS:
commands=_temp + _username + "String_Node_Str"+ modelName+ "String_Node_Str";
break;
case UNIX:
commands=_temp + "String_Node_Str" + _username+ "String_Node_Str"+ modelName;
break;
case MAC:
commands=_temp + _username + "String_Node_Str"+ modelName;
break;
}
commands=commands + "String_Node_Str";
try {
loggerInfo="String_Node_Str" + commands + "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
Runtime.getRuntime().exec(commands,_environmentalVariables,_workDir);
loggerInfo="String_Node_Str" + commands + "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
}
 catch (IOException e) {
loggerInfo="String_Node_Str" + commands;
_omcLogger.getInfo(loggerInfo);
hasInitialized=false;
return;
}
loggerInfo="String_Node_Str";
_omcLogger.getInfo(loggerInfo);
}
}
 else {
loggerInfo=modelName + "String_Node_Str";
_omcLogger.getInfo(loggerInfo);
}
}